本文整理汇总了TypeScript中@ephox/katamari.Arr.map方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Arr.map方法的具体用法?TypeScript Arr.map怎么用?TypeScript Arr.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Arr
的用法示例。
在下文中一共展示了Arr.map方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
};
示例2: function
return Chain.mapper(function (viewBlock: any) {
const ranges = Arr.map(paths, function (path) {
const container = Hierarchy.follow(Element.fromDom(viewBlock.get()), path).getOrDie();
const rng = document.createRange();
rng.selectNode(container.dom());
return rng;
});
return TableCellSelection.getCellsFromRanges(ranges);
});
示例3: makeItem
getItems: (value) => {
return Arr.map([
{
text: 'Cat'
},
{
text: 'Dog'
}
], (d) => makeItem(d.text));
}
示例4: function
const getWrapElements = function (rootNode, rng) {
const commonAnchorContainer = Element.fromDom(rng.commonAncestorContainer);
const parents = Parents.parentsAndSelf(commonAnchorContainer, rootNode);
const wrapElements = Arr.filter(parents, function (elm) {
return ElementType.isInline(elm) || ElementType.isHeading(elm);
});
const listWrappers = getFullySelectedListWrappers(parents, rng);
const allWrappers = wrapElements.concat(listWrappers.length ? listWrappers : directListWrappers(commonAnchorContainer));
return Arr.map(allWrappers, Replication.shallow);
};
示例5: Promise
return new Promise((resolve) => {
const filteredItems = Arr.filter([ 'two', 'three' ], (number) => number.indexOf(pattern) !== -1);
resolve(
Arr.map(filteredItems, (number) => ({
value: `${number}`,
text: `${number}`,
icon: '='
}))
);
});
示例6: function
return Chain.mapper(function (viewBlock) {
const ranges = Arr.map(paths, function (path) {
const container = Hierarchy.follow(Element.fromDom(viewBlock.get()), path).getOrDie();
const rng = document.createRange();
rng.selectNode(container.dom());
return rng;
});
return FragmentReader.read(Element.fromDom(viewBlock.get()), ranges);
});
示例7: listsIndentation
const selectionIndentation = (editor: Editor, indentation: Indentation): boolean => {
const lists = Arr.map(Selection.getSelectedListRoots(editor), Element.fromDom);
const dlItems = Arr.map(Selection.getSelectedDlItems(editor), Element.fromDom);
let isHandled = false;
if (lists.length || dlItems.length) {
const bookmark = editor.selection.getBookmark();
listsIndentation(editor, lists, indentation);
dlIndentation(editor, indentation, dlItems);
editor.selection.moveToBookmark(bookmark);
editor.selection.setRng(Range.normalizeRange(editor.selection.getRng()));
editor.nodeChanged();
isHandled = true;
}
return isHandled;
};
示例8: structureItem
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-collection'), arr.has('tox-collection--grid'), arr.not('tox-menu') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: Arr.map([ 'G', 'H' ], (letter) =>
structureItem(Option.none(), Option.some('icon-' + letter))(s, str, arr)
)
}),
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: Arr.map([ 'I' ], (letter) =>
structureItem(Option.none(), Option.some('icon-' + letter))(s, str, arr)
)
})
]
});
})
示例9: function
const pluginLister = function (editor) {
const pluginKeys = getPluginKeys(editor);
const pluginLis = Arr.map(pluginKeys, function (key) {
return '<li>' + maybeUrlize(editor, key) + '</li>';
});
const count = pluginLis.length;
const pluginsString = pluginLis.join('');
return '<p><b>' + I18n.translate(['Plugins installed ({0}):', count ]) + '</b></p>' +
'<ul>' + pluginsString + '</ul>';
};
示例10: cFindInDialog
const sSetValueAndTrigger = (selector, value, events: string[]) => (ui) => {
return Logger.t(`Set ${value} and trigger ${events.join(',')}`, Chain.asStep({}, [
Chain.fromChains([
cFindInDialog(selector)(ui), // get the element
Chain.op(Focus.focus), // fire focusin, required by sizeinput to recalc ratios
cSetValueOn(selector, value)(ui), // change the value
...Arr.map(events, (event) => cFakeEvent(event)), // fire [change, input etc],
Chain.wait(0) // Wait needed as paste event is triggered async
])
]));
};