當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。