本文整理匯總了TypeScript中@ephox/katamari.Type.isString方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Type.isString方法的具體用法?TypeScript Type.isString怎麽用?TypeScript Type.isString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/katamari.Type
的用法示例。
在下文中一共展示了Type.isString方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
Tools.each(list, function (item) {
const text: string = Type.isString(item.text) ? item.text : Type.isString(item.title) ? item.title : '';
if (item.menu !== undefined) {
const items = sanitizeList(item.menu, extractValue);
out.push({ text, items }); // list group
} else {
const value = extractValue(item);
out.push({ text, value }); // list value
}
});
示例2: if
const createToolbar = (toolbarConfig: Partial<RenderUiConfig>): ToolbarGroupSetting[] => {
if (toolbarConfig.toolbar === false) {
return [];
} else if (toolbarConfig.toolbar === undefined || toolbarConfig.toolbar === true) {
return removeUnusedDefaults(toolbarConfig.buttons);
} else if (Type.isString(toolbarConfig.toolbar)) {
return convertStringToolbar(toolbarConfig.toolbar);
} else if (Type.isArray(toolbarConfig.toolbar) && Type.isString(toolbarConfig.toolbar[0])) {
return convertStringToolbar(toolbarConfig.toolbar.join(' | '));
} else {
return toolbarConfig.toolbar;
}
};
示例3: function
Tools.each(list, function (item) {
const text: string = Type.isString(item.text) ? item.text : Type.isString(item.title) ? item.title : '';
if (item.menu !== undefined) {
// TODO TINY-2236 re-enable this (support will need to be added to bridge)
/*
const items = sanitizeList(item.menu, extractValue);
out.push({ text, items }); // list group
*/
} else {
const value = extractValue(item);
out.push({ text, value }); // list value
}
});
示例4: function
const normalizePlugins = function (plugins) {
const pluginNames = Type.isArray(plugins) ? plugins.join(' ') : plugins;
const trimmedPlugins = Arr.map(Type.isString(pluginNames) ? pluginNames.split(' ') : [ ], Strings.trim);
return Arr.filter(trimmedPlugins, function (item) {
return item.length > 0;
});
};
示例5: switch
const makeContextItem = (item: string | Menu.ContextMenuItem | Menu.SeparatorMenuItemApi | Menu.ContextSubMenu): MenuItem => {
if (Type.isString(item)) {
return item;
} else {
switch (item.type) {
case 'separator':
return separator;
case 'submenu':
return {
type: 'nestedmenuitem',
text: item.text,
icon: item.icon,
getSubmenuItems: () => {
const items = item.getSubmenuItems();
if (Type.isString(items)) {
return items;
} else {
return Arr.map(items, makeContextItem);
}
}
};
default:
// case 'item', or anything else really
return {
type: 'menuitem',
text: item.text,
icon: item.icon,
// disconnect the function from the menu item API bridge defines
onAction: Fun.noarg(item.onAction)
};
}
}
};
示例6:
getSubmenuItems: () => {
const items = item.getSubmenuItems();
if (Type.isString(items)) {
return items;
} else {
return Arr.map(items, makeContextItem);
}
}
示例7: Error
const block = (message: string) => {
if (!Type.isString(message)) {
throw new Error('The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument');
}
withRoot((root) => {
AlloyTriggers.emitWith(root, formBlockEvent, { message });
});
};
示例8: Error
const handler = (value: string, meta?: Record<string, any>) => {
if (!Type.isString(value)) {
throw new Error('Expected value to be string');
}
if (meta !== undefined && !Type.isObject(meta)) {
throw new Error('Expected meta to be a object');
}
const r: UrlData = { value, meta };
completer(r);
};
示例9: if
const getCloneElements = (editor: Editor): Option<string[]> => {
const cloneElements = editor.getParam('table_clone_elements');
if (Type.isString(cloneElements)) {
return Option.some(cloneElements.split(/[ ,]/));
} else if (Array.isArray(cloneElements)) {
return Option.some(cloneElements);
} else {
return Option.none();
}
};
示例10: function
const createComplex = function (item: HtmlItem | string): Node {
if (Type.isString(item)) {
return document.createTextNode(item);
} else {
const i = document.createElement(item.n);
Arr.each(item.cs, (child) => {
i.appendChild(createComplex(child));
});
return i;
}
};