Example #1
0
const insertFormatNodesIntoCaretContainer = function (formatNodes, caretContainer) {
  const innerMostFormatNode = Arr.foldr(formatNodes, function (parentNode, formatNode) {
    return appendNode(parentNode, formatNode.cloneNode(false));
  }, caretContainer);

  return appendNode(innerMostFormatNode, innerMostFormatNode.ownerDocument.createTextNode(ZWSP));
};
Example #2
0
const expand = function (items) {
  return Arr.foldr(items, function (acc, item) {
    const newData = getFromItem(item);
    return {
      menus: Merger.deepMerge(acc.menus, newData.menus),
      items: [ newData.item ].concat(acc.items),
      expansions: Merger.deepMerge(acc.expansions, newData.expansions)
    };
  }, {
    menus: { },
    expansions: { },
    items: [ ]
  });
};
Example #3
0
const expand = (items: string | Array<string | SingleMenuItemApi>, menuItems: MenuItemRegistry) => {
  const realItems = unwrapReferences(Type.isString(items) ? items.split(' ') : items, menuItems);
  return Arr.foldr(realItems, (acc, item) => {
    const itemWithValue = generateValueIfRequired(item);
    const newData = getFromItem(itemWithValue, menuItems);
    return {
      menus: Merger.deepMerge(acc.menus, newData.menus),
      items: [ newData.item ].concat(acc.items),
      expansions: Merger.deepMerge(acc.expansions, newData.expansions)
    };
  }, {
    menus: { },
    expansions: { },
    items: [ ]
  });
};