本文整理匯總了TypeScript中@ephox/katamari.Type類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Type類的具體用法?TypeScript Type怎麽用?TypeScript Type使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Type類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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;
});
};
示例2: 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);
};
示例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) {
const items = sanitizeList(item.menu, extractValue);
out.push({ text, items }); // list group
} else {
const value = extractValue(item);
out.push({ text, value }); // list value
}
});
示例4: 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;
}
};
示例5: if
const getContentCss = (editor: Editor): string[] => {
const contentCss = editor.settings.content_css;
if (Type.isString(contentCss)) {
return Arr.map(contentCss.split(','), Strings.trim);
} else if (Type.isArray(contentCss)) {
return contentCss;
} else if (contentCss === false || editor.inline) {
return [];
} else {
return ['default'];
}
};
示例6: function
const renderThemeUi = function (editor) {
const settings = editor.settings, elm = editor.getElement();
editor.orgDisplay = elm.style.display;
if (Type.isString(settings.theme)) {
return renderFromLoadedTheme(editor);
} else if (Type.isFunction(settings.theme)) {
return renderFromThemeFunc(editor);
} else {
return renderThemeFalse(editor);
}
};
示例7: if
const getToolbar = (editor: Editor): string[] => {
const toolbar = editor.getParam('table_toolbar', defaultTableToolbar);
if (toolbar === '' || toolbar === false) {
return [];
} else if (Type.isString(toolbar)) {
return toolbar.split(/[ ,]/);
} else if (Type.isArray(toolbar)) {
return toolbar;
} else {
return [];
}
};
示例8: 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
}
});
示例9: Error
const items = (value: boolean | string, defaultValue: string): string => {
if (Type.isArray(value) || Type.isObject(value)) {
throw new Error('expected a string but found: ' + value);
}
if (Type.isUndefined(value)) {
return defaultValue;
}
if (Type.isBoolean(value)) {
return value === false ? '' : defaultValue;
}
return value;
};
示例10: 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)
};
}
}
};