本文整理汇总了TypeScript中tinymce/core/util/Tools.each函数的典型用法代码示例。如果您正苦于以下问题:TypeScript each函数的具体用法?TypeScript each怎么用?TypeScript each使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了each函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: append
function append(styleSheet, imported?) {
let href = styleSheet.href, rules;
href = removeCacheSuffix(href);
if (!href || !fileFilter(href, imported) || isSkinContentCss(editor, href)) {
return;
}
Tools.each(styleSheet.imports, function (styleSheet) {
append(styleSheet, true);
});
try {
rules = styleSheet.cssRules || styleSheet.rules;
} catch (e) {
// Firefox fails on rules to remote domain for example:
// @import url(//fonts.googleapis.com/css?family=Pathway+Gothic+One);
}
Tools.each(rules, function (cssRule) {
if (cssRule.styleSheet) {
append(cssRule.styleSheet, true);
} else if (cssRule.selectorText) {
Tools.each(cssRule.selectorText.split(','), function (selector) {
selectors.push(Tools.trim(selector));
});
}
});
}
示例2: function
const togglePositionClass = function (panel, relPos) {
relPos = relPos ? relPos.substr(0, 2) : '';
Tools.each({
t: 'down',
b: 'up',
c: 'center'
}, function (cls, pos) {
panel.classes.toggle('arrow-' + cls, pos === relPos.substr(0, 1));
});
if (relPos === 'cr') {
panel.classes.toggle('arrow-left', true);
panel.classes.toggle('arrow-right', false);
} else if (relPos === 'cl') {
panel.classes.toggle('arrow-left', true);
panel.classes.toggle('arrow-right', true);
} else {
Tools.each({
l: 'left',
r: 'right'
}, function (cls, pos) {
panel.classes.toggle('arrow-' + cls, pos === relPos.substr(1, 1));
});
}
};
示例3: function
const extractDataFromElement = function (editor, elm) {
const dom = editor.dom;
const data: any = {
width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'),
height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
scope: dom.getAttrib(elm, 'scope'),
class: dom.getAttrib(elm, 'class')
};
data.type = elm.nodeName.toLowerCase();
Tools.each('left center right'.split(' '), function (name) {
if (editor.formatter.matchNode(elm, 'align' + name)) {
data.align = name;
}
});
Tools.each('top middle bottom'.split(' '), function (name) {
if (editor.formatter.matchNode(elm, 'valign' + name)) {
data.valign = name;
}
});
if (editor.settings.table_cell_advtab !== false) {
Tools.extend(data, Helpers.extractAdvancedStyles(dom, elm));
}
return data;
};
示例4: function
editor.on('ObjectResized', function (e) {
if (isTable(e.target)) {
const table = e.target;
if (percentageBasedSizeRegex.test(startRawW)) {
const percentW = parseFloat(percentageBasedSizeRegex.exec(startRawW)[1]);
const targetPercentW = e.width * percentW / startW;
editor.dom.setStyle(table, 'width', targetPercentW + '%');
} else {
const newCellSizes = [];
Tools.each(table.rows, function (row) {
Tools.each(row.cells, function (cell) {
const width = editor.dom.getStyle(cell, 'width', true);
newCellSizes.push({
cell,
width
});
});
});
Tools.each(newCellSizes, function (newCellSize) {
editor.dom.setStyle(newCellSize.cell, 'width', newCellSize.width);
editor.dom.setAttrib(newCellSize.cell, 'width', null);
});
}
}
});
示例5: function
editor.on('renderFormatsMenu', function (e) {
const globallyUniqueSelectors = {};
const selectorFilter = compileFilter(Settings.getSelectorFilter(editor)), ctrl = e.control;
const groups = compileUserDefinedGroups(Settings.getCssGroups(editor));
const processSelector = function (selector, group) {
if (isUniqueSelector(editor, selector, group, globallyUniqueSelectors)) {
markUniqueSelector(editor, selector, group, globallyUniqueSelectors);
const format = convertSelectorToFormat(editor, editor.plugins.importcss, selector, group);
if (format) {
const formatName = format.name || DOMUtils.DOM.uniqueId();
editor.formatter.register(formatName, format);
return Tools.extend({}, ctrl.settings.itemDefaults, {
text: format.title,
format: formatName
});
}
}
return null;
};
if (!Settings.shouldAppend(editor)) {
ctrl.items().remove();
}
Tools.each(getSelectors(editor, e.doc || editor.getDoc(), compileFilter(Settings.getFileFilter(editor))), function (selector) {
if (selector.indexOf('.mce-') === -1) {
if (!selectorFilter || selectorFilter(selector)) {
const selectorGroups = getGroupsBySelector(groups, selector);
if (selectorGroups.length > 0) {
Tools.each(selectorGroups, function (group) {
const menuItem = processSelector(selector, group);
if (menuItem) {
group.item.menu.push(menuItem);
}
});
} else {
const menuItem = processSelector(selector, null);
if (menuItem) {
ctrl.add(menuItem);
}
}
}
}
});
Tools.each(groups, function (group) {
if (group.item.menu.length > 0) {
ctrl.add(group.item);
}
});
e.control.renderNew();
});
示例6: function
const createMenu = function (editorMenuItems, menus, removedMenuItems, context) {
let menuButton, menu, namedMenuItems, isUserDefined;
// User defined menu
if (menus) {
menu = menus[context];
isUserDefined = true;
} else {
menu = defaultMenus[context];
}
if (menu) {
menuButton = { text: menu.title };
namedMenuItems = [];
// Default/user defined items
Tools.each((menu.items || '').split(/[ ,]/), function (name) {
const namedMenuItem = createMenuNameItemPair(name, editorMenuItems[name]);
if (namedMenuItem) {
namedMenuItems.push(namedMenuItem);
}
});
// Added though context
if (!isUserDefined) {
Tools.each(editorMenuItems, function (item, name) {
if (item.context === context && !hasItemName(namedMenuItems, name)) {
if (item.separator === 'before') {
namedMenuItems.push(delimiterMenuNamePair());
}
if (item.prependToContext) {
namedMenuItems.unshift(createMenuNameItemPair(name, item));
} else {
namedMenuItems.push(createMenuNameItemPair(name, item));
}
if (item.separator === 'after') {
namedMenuItems.push(delimiterMenuNamePair());
}
}
});
}
menuButton.menu = Arr.map(cleanupMenu(namedMenuItems, removedMenuItems), function (menuItem) {
return menuItem.item;
});
if (!menuButton.menu.length) {
return null;
}
}
return menuButton;
};
示例7: function
const hideAllContextToolbars = function () {
Tools.each(getContextToolbars(), function (toolbar) {
if (toolbar.panel) {
toolbar.panel.hide();
}
});
};
示例8: function
const teardown = function (editor) {
const notifications = [].concat(editor.notificationManager.getNotifications());
Tools.each(notifications, function (notification) {
notification.close();
});
};
示例9: function
const register = function (editor) {
editor.addMenuItem('align', {
text: 'Align',
menu: [
{ text: 'Left', icon: 'alignleft', onclick: FormatUtils.toggleFormat(editor, 'alignleft') },
{ text: 'Center', icon: 'aligncenter', onclick: FormatUtils.toggleFormat(editor, 'aligncenter') },
{ text: 'Right', icon: 'alignright', onclick: FormatUtils.toggleFormat(editor, 'alignright') },
{ text: 'Justify', icon: 'alignjustify', onclick: FormatUtils.toggleFormat(editor, 'alignjustify') }
]
});
Tools.each({
alignleft: ['Align left', 'JustifyLeft'],
aligncenter: ['Align center', 'JustifyCenter'],
alignright: ['Align right', 'JustifyRight'],
alignjustify: ['Justify', 'JustifyFull'],
alignnone: ['No alignment', 'JustifyNone']
}, function (item, name) {
editor.addButton(name, {
active: false,
tooltip: item[0],
cmd: item[1],
onPostRender: FormatUtils.postRenderFormat(editor, name)
});
});
};