本文整理汇总了TypeScript中tinymce/core/util/Tools.isArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isArray函数的具体用法?TypeScript isArray怎么用?TypeScript isArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isArray函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: isEqual
// Todo: Maybe this should be shallow compare since it might be huge object references
function isEqual(a, b) {
let k, checked;
// Strict equals
if (a === b) {
return true;
}
// Compare null
if (a === null || b === null) {
return a === b;
}
// Compare number, boolean, string, undefined
if (typeof a !== 'object' || typeof b !== 'object') {
return a === b;
}
// Compare arrays
if (Tools.isArray(b)) {
if (a.length !== b.length) {
return false;
}
k = a.length;
while (k--) {
if (!isEqual(a[k], b[k])) {
return false;
}
}
}
// Shallow compare nodes
if (isNode(a) || isNode(b)) {
return a === b;
}
// Compare objects
checked = {};
for (k in b) {
if (!isEqual(a[k], b[k])) {
return false;
}
checked[k] = true;
}
for (k in a) {
if (!checked[k] && !isEqual(a[k], b[k])) {
return false;
}
}
return true;
}
示例2: function
const stripAttribs = function ($el, attr) {
if (Tools.isArray(attr)) {
Tools.each(attr, function (attr) {
stripAttribs($el, attr);
});
return;
}
$el.removeAttr(attr);
$el.find('[' + attr + ']').removeAttr(attr);
};
示例3: function
const getToolbars = function (editor) {
const toolbar = editor.getParam('toolbar');
const defaultToolbar = 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image';
if (toolbar === false) {
return [];
} else if (Tools.isArray(toolbar)) {
return Tools.grep(toolbar, function (toolbar) {
return toolbar.length > 0;
});
} else {
return getIndexedToolbars(editor.settings, defaultToolbar);
}
};
示例4: function
const splitAndApply = function (editor, container, found, space) {
const formatArray = Tools.isArray(found.pattern.format) ? found.pattern.format : [found.pattern.format];
const validFormats = Tools.grep(formatArray, function (formatName) {
const format = editor.formatter.get(formatName);
return format && format[0].inline;
});
if (validFormats.length !== 0) {
editor.undoManager.transact(function () {
container = splitContainer(container, found.pattern, found.endOffset, found.startOffset, space);
formatArray.forEach(function (format) {
editor.formatter.apply(format, {}, container);
});
});
return container;
}
};
示例5: function
const createCustomMenuItems = function (editor, names) {
let items, nameList;
if (typeof names === 'string') {
nameList = names.split(' ');
} else if (Tools.isArray(names)) {
return Arr.flatten(Tools.map(names, function (names) {
return createCustomMenuItems(editor, names);
}));
}
items = Tools.grep(nameList, function (name) {
return name === '|' || name in editor.menuItems;
});
return Tools.map(items, function (name) {
return name === '|' ? { text: '-' } : editor.menuItems[name];
});
};
示例6: add
this.add(items);
}
},
/**
* Adds new items to the control collection.
*
* @method add
* @param {Array} items Array if items to add to collection.
* @return {tinymce.ui.Collection} Current collection instance.
*/
add (items) {
const self = this;
// Force single item into array
if (!Tools.isArray(items)) {
if (items instanceof Collection) {
self.add(items.toArray());
} else {
push.call(self, items);
}
} else {
push.apply(self, items);
}
return self;
},
/**
* Sets the contents of the collection. This will remove any existing items
* and replace them with the ones specified in the input array.