当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Arr.map方法代码示例

本文整理汇总了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;
};
开发者ID:abstask,项目名称:tinymce,代码行数:56,代码来源:Menubar.ts

示例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);
    });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:10,代码来源:TableCellSelectionTest.ts

示例3: makeItem

 getItems: (value) => {
   return Arr.map([
     {
       text: 'Cat'
     },
     {
       text: 'Dog'
     }
   ], (d) => makeItem(d.text));
 }
开发者ID:tinymce,项目名称:tinymce,代码行数:10,代码来源:DialogComponentsDemo.ts

示例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);
};
开发者ID:howardjing,项目名称:tinymce,代码行数:10,代码来源:FragmentReader.ts

示例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: '='
     }))
   );
 });
开发者ID:tinymce,项目名称:tinymce,代码行数:10,代码来源:AutocompleterTest.ts

示例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);
    });
开发者ID:abstask,项目名称:tinymce,代码行数:10,代码来源:FragmentReaderTest.ts

示例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;
};
开发者ID:tinymce,项目名称:tinymce,代码行数:19,代码来源:Indendation.ts

示例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)
         )
       })
     ]
   });
 })
开发者ID:tinymce,项目名称:tinymce,代码行数:19,代码来源:OxideCollectionComponentTest.ts

示例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>';
};
开发者ID:abstask,项目名称:tinymce,代码行数:11,代码来源:PluginsTab.ts

示例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
    ])
  ]));
};
开发者ID:tinymce,项目名称:tinymce,代码行数:11,代码来源:Utils.ts


注:本文中的@ephox/katamari.Arr.map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。