本文整理匯總了TypeScript中@ephox/katamari.Type.isArray方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Type.isArray方法的具體用法?TypeScript Type.isArray怎麽用?TypeScript Type.isArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/katamari.Type
的用法示例。
在下文中一共展示了Type.isArray方法的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:
const isToolbarEnabled = (editor: Editor) => {
const toolbarConfig = editor.getParam('toolbar');
if (Type.isArray(toolbarConfig)) {
return toolbarConfig.length > 0;
} else {
return editor.getParam('toolbar', true, 'boolean') !== false;
}
};
示例3: 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 [];
}
};
示例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: createPatternSet
const getPatternSet = (editorSettings): PatternSet => {
const patterns = Obj.get(editorSettings, 'textpattern_patterns').getOr(defaultPatterns);
if (!Type.isArray(patterns)) {
error('The setting textpattern_patterns should be an array');
return {
inlinePatterns: [],
blockPatterns: [],
};
}
const normalized = Results.partition(Arr.map(patterns, normalizePattern));
Arr.each(normalized.errors, (err) => error(err.message, err.pattern));
return createPatternSet(normalized.values);
};
示例6: 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'];
}
};
示例7: 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;
};
示例8: function
const register = function (name: string | Formats, format?: Format | Format[]) {
if (name) {
if (typeof name !== 'string') {
Tools.each(name, function (format, name) {
register(name, format);
});
} else {
// Force format into array and add it to internal collection
if (!Type.isArray(format)) {
format = [format];
}
Tools.each(format, function (format: any) {
// Set deep to false by default on selector formats this to avoid removing
// alignment on images inside paragraphs when alignment is changed on paragraphs
if (typeof format.deep === 'undefined') {
format.deep = !format.selector;
}
// Default to true
if (typeof format.split === 'undefined') {
format.split = !format.selector || format.inline;
}
// Default to true
if (typeof format.remove === 'undefined' && format.selector && !format.inline) {
format.remove = 'none';
}
// Mark format as a mixed format inline + block level
if (format.selector && format.inline) {
format.mixed = true;
format.block_expand = true;
}
// Split classes if needed
if (typeof format.classes === 'string') {
format.classes = format.classes.split(/\s+/);
}
});
formats[name] = format;
}
}
};
示例9: err
const formatOrCmd = <T> (name: string, onFormat: (formats: string[]) => T, onCommand: (cmd: string, value: any) => T): Result<T, PatternError> => {
if (pattern.format !== undefined) {
let formats: string[];
if (Type.isArray(pattern.format)) {
if (!Arr.forall(pattern.format, Type.isString)) {
return err(name + ' pattern has non-string items in the `format` array');
}
formats = pattern.format;
} else if (Type.isString(pattern.format)) {
formats = [pattern.format];
} else {
return err(name + ' pattern has non-string `format` parameter');
}
return Result.value(onFormat(formats));
} else if (pattern.cmd !== undefined) {
if (!Type.isString(pattern.cmd)) {
return err(name + ' pattern has non-string `cmd` parameter');
}
return Result.value(onCommand(pattern.cmd, pattern.value));
} else {
return err(name + ' pattern is missing both `format` and `cmd` parameters');
}
};
示例10:
const isTokenised = (str: any): str is TokenisedString => Type.isArray(str) && str.length > 1;