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


TypeScript Tools.grep函数代码示例

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

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

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

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

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

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

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

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

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

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


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