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; };
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); });
getItems: (value) => { return Arr.map([ { text: 'Cat' }, { text: 'Dog' } ], (d) => makeItem(d.text)); }
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); };
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: '=' })) ); });
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); });
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; };
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) ) }) ] }); })
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>'; };
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 ]) ])); };