How to use the tinymce/core/api/util/Tools.grep function in tinymce

To help you get started, we’ve selected a few tinymce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / core / Selection.ts View on Github external
const findSubLists = function (parentList) {
  return Tools.grep(parentList.querySelectorAll('ol,ul,dl'), function (elm: Node) {
    return NodeType.isListNode(elm);
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / searchreplace / main / ts / core / Actions.ts View on Github external
const replace = function (editor: Editor, currentSearchState: Cell, text: string, forward?: boolean, all?: boolean) {
  const searchState = currentSearchState.get();
  const currentIndex = searchState.index;
  let i, nodes, node, matchIndex, currentMatchIndex, nextIndex = currentIndex;

  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 === searchState.index) {
      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) {
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / core / Selection.ts View on Github external
const getSelectedListItems = function (editor) {
  const selectedBlocks = editor.selection.getSelectedBlocks();
  return Tools.grep(findParentListItemsNodes(editor, selectedBlocks), function (block) {
    return NodeType.isListItemNode(block);
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / lists / main / ts / core / Selection.ts View on Github external
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: Node) {
      return NodeType.isListNode(elm) && parentList !== elm;
    });
  }
};
github tinymce / tinymce / modules / tinymce / src / plugins / importcss / main / ts / core / ImportCss.ts View on Github external
const getGroupsBySelector = function (groups: Group[], selector: string): Group[] {
  return Tools.grep(groups, function (group) {
    return !group.filter || group.filter(selector);
  });
};
github tinymce / tinymce / modules / tinymce / src / plugins / link / main / ts / core / Utils.ts View on Github external
const hasLinks = (elements: HTMLAnchorElement[]) => {
  return Tools.grep(elements, isLink).length > 0;
};