本文整理汇总了TypeScript中tinymce/core/api/util/Tools.grep函数的典型用法代码示例。如果您正苦于以下问题:TypeScript grep函数的具体用法?TypeScript grep怎么用?TypeScript grep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了grep函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const create = function (editor: Editor, toolbars: ContextToolbar[]) {
const items = createToolbars(editor, toolbars).concat([
Toolbar.create(editor, 'text', Settings.getTextSelectionToolbarItems(editor)),
Toolbar.create(editor, 'insert', Settings.getInsertToolbarItems(editor)),
Forms.createQuickLinkForm(editor, hide)
]);
return Factory.create({
type: 'floatpanel',
role: 'dialog',
classes: 'tinymce tinymce-inline arrow',
ariaLabel: 'Inline toolbar',
layout: 'flex',
direction: 'column',
align: 'stretch',
autohide: false,
autofix: true,
fixed: true,
border: 1,
items: Tools.grep(items, hasToolbarItems),
oncancel () {
editor.focus();
}
});
};
示例2: function
suite.asyncTest('Do not reload language pack if it was already loaded or registered manually.', function (_, done) {
const langCode = 'mce_lang';
const langUrl = 'http://example.com/language/' + langCode + '.js';
EditorManager.addI18n(langCode, {
from: 'to'
});
viewBlock.update('<textarea></textarea>');
EditorManager.init({
selector: 'textarea',
skin_url: '/project/js/tinymce/skins/lightgray',
language: langCode,
language_url: langUrl,
init_instance_callback (ed) {
const scripts = Tools.grep(document.getElementsByTagName('script'), function (script) {
return script.src === langUrl;
});
LegacyUnit.equal(scripts.length, 0);
teardown(done);
}
});
});
示例3: function
const filterByQuery = function (term, menuItems) {
const lowerCaseTerm = term.toLowerCase();
const result = Tools.grep(menuItems, function (item) {
return item.title.toLowerCase().indexOf(lowerCaseTerm) !== -1;
});
return result.length === 1 && result[0].title === term ? [] : result;
};
示例4: function
const filter = function (files) {
const accept = self.settings.accept;
if (typeof accept !== 'string') {
return files;
}
const re = new RegExp('(' + accept.split(/\s*,\s*/).join('|') + ')$', 'i');
return Tools.grep(files, function (file) {
return re.test(file.name);
});
};
示例5: function
const getSelectedSubLists = function (editor) {
const parentList = getParentList(editor);
const selectedBlocks = editor.selection.getSelectedBlocks();
if (isParentListSelected(parentList, selectedBlocks)) {
return findSubLists(parentList);
} else {
return Tools.grep(selectedBlocks, function (elm) {
return NodeType.isListNode(elm) && parentList !== elm;
});
}
};
示例6: function
return function () {
const hidePanels = Tools.grep(panels, function (panel) {
return panel.settings.name !== targetPanel;
});
Tools.each(hidePanels, function (panel) {
panel.hide();
});
targetPanel.show();
targetPanel.focus();
};
示例7: function
const getSelectedAnchors = function (editor) {
let startElm, endElm, rootElm, anchorElms, selection, dom, rng;
selection = editor.selection;
dom = editor.dom;
rng = selection.getRng();
startElm = getParentAnchorOrSelf(dom, RangeUtils.getNode(rng.startContainer, rng.startOffset));
endElm = RangeUtils.getNode(rng.endContainer, rng.endOffset);
rootElm = editor.getBody();
anchorElms = Tools.grep(getSelectedElements(rootElm, startElm, endElm), isLink);
return anchorElms;
};
示例8: function
const removeList = function (editor) {
const bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
const root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
let listItems = Selection.getSelectedListItems(editor);
const emptyListItems = Tools.grep(listItems, function (li) {
return editor.dom.isEmpty(li);
});
listItems = Tools.grep(listItems, function (li) {
return !editor.dom.isEmpty(li);
});
Tools.each(emptyListItems, function (li) {
if (NodeType.isEmpty(editor.dom, li)) {
Outdent.outdent(editor, li);
return;
}
});
Tools.each(listItems, function (li) {
let node, rootList;
if (li.parentNode === editor.getBody()) {
return;
}
for (node = li; node && node !== root; node = node.parentNode) {
if (NodeType.isListNode(node)) {
rootList = node;
}
}
SplitList.splitList(editor, rootList, li);
NormalizeLists.normalizeLists(editor.dom, rootList.parentNode);
});
editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
};
示例9: function
const replace = function (editor, currentIndexState, text, forward?, all?) {
let i, nodes, node, matchIndex, currentMatchIndex, nextIndex = currentIndexState.get(), hasMore;
forward = forward !== false;
node = editor.getBody();
nodes = Tools.grep(Tools.toArray(node.getElementsByTagName('span')), isMatchSpan);
for (i = 0; i < nodes.length; i++) {
const nodeIndex = getElmIndex(nodes[i]);
matchIndex = currentMatchIndex = parseInt(nodeIndex, 10);
if (all || matchIndex === currentIndexState.get()) {
if (text.length) {
nodes[i].firstChild.nodeValue = text;
unwrap(nodes[i]);
} else {
removeNode(editor.dom, nodes[i]);
}
while (nodes[++i]) {
matchIndex = parseInt(getElmIndex(nodes[i]), 10);
if (matchIndex === currentMatchIndex) {
removeNode(editor.dom, nodes[i]);
} else {
i--;
break;
}
}
if (forward) {
nextIndex--;
}
} else if (currentMatchIndex > currentIndexState.get()) {
nodes[i].setAttribute('data-mce-index', currentMatchIndex - 1);
}
}
currentIndexState.set(nextIndex);
if (forward) {
hasMore = hasNext(editor, currentIndexState);
next(editor, currentIndexState);
} else {
hasMore = hasPrev(editor, currentIndexState);
prev(editor, currentIndexState);
}
return !all && hasMore;
};
示例10: getCells
return Logger.t('Assert Table Selection', Step.sync(() => {
editor.setContent(tableHtml);
const table = editor.$('table')[0];
const cells = getCells(table);
const startTd = Tools.grep(cells, function (elm) {
return elm.innerHTML === selectCells[0];
})[0];
const endTd = Tools.grep(cells, function (elm) {
return elm.innerHTML === selectCells[1];
})[0];
selectRangeXY(table, startTd, endTd);
let selection = getSelectedCells(table);
selection = Tools.map(selection, function (elm) {
return elm.innerHTML;
});
LegacyUnit.deepEqual(selection, cellContents);
}));