本文整理汇总了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)
};
}
}
};