How to use the @remirror/core.nodeNameMatchesList function in @remirror/core

To help you get started, we’ve selected a few @remirror/core 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 ifiokjr / remirror / @remirror / core-extensions / src / extensions / node-cursor.ts View on Github external
export const findSpecialNodeBefore = ($pos: ResolvedPos, tr: Transaction, matchers: NodeMatch[]) => {
  if (nodeNameMatchesList($pos.nodeBefore, matchers)) {
    return $pos.pos - 1;
  }

  if ($pos.pos === 0) {
    return;
  }

  const { parentOffset } = $pos;

  if (parentOffset === 0) {
    const { nodeBefore } = tr.doc.resolve($pos.pos - 1);
    if (nodeBefore && nodeNameMatchesList(nodeBefore.firstChild, matchers)) {
      return $pos.pos - 2;
    }
  }

  return;
};
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / node-cursor.ts View on Github external
export const findSpecialNodeBefore = ($pos: ResolvedPos, tr: Transaction, matchers: NodeMatch[]) => {
  if (nodeNameMatchesList($pos.nodeBefore, matchers)) {
    return $pos.pos - 1;
  }

  if ($pos.pos === 0) {
    return;
  }

  const { parentOffset } = $pos;

  if (parentOffset === 0) {
    const { nodeBefore } = tr.doc.resolve($pos.pos - 1);
    if (nodeBefore && nodeNameMatchesList(nodeBefore.firstChild, matchers)) {
      return $pos.pos - 2;
    }
  }
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / node-cursor.ts View on Github external
export const findSpecialNodeAfter = ($pos: ResolvedPos, tr: Transaction, matchers: NodeMatch[]) => {
  if (nodeNameMatchesList($pos.nodeAfter, matchers)) {
    return $pos.pos + 1;
  }

  const { parentOffset, parent } = $pos;
  const docSize = tr.doc.nodeSize - 2;

  if (parentOffset === parent.content.size && $pos.pos + 1 < docSize - 2) {
    const { nodeAfter } = tr.doc.resolve($pos.pos + 1);
    if (nodeAfter && nodeNameMatchesList(nodeAfter.firstChild, matchers)) {
      return $pos.pos + 2;
    }
  }

  return;
};
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / composition / plugin.ts View on Github external
tr.doc.resolve(tr.mapping.map($from.pos - $from.nodeBefore.nodeSize)),
    );
    tr.setSelection(newSelection);
    dispatch(tr);
    pluginState.endDelete(newSelection);
    return true;
  }

  /**
   * This block caters for highlighting the defined nodes when a selection has been made
   */
  if (
    isTextSelection(selection) &&
    selection.$cursor === null &&
    $from.nodeAfter &&
    nodeNameMatchesList($from.nodeBefore, ensureNodeDeletion)
  ) {
    event.preventDefault();
    dispatch(state.tr.deleteSelection());
    return true;
  }
  return false;
};
github ifiokjr / remirror / @remirror / core-extensions / src / extensions / node-cursor.ts View on Github external
export const findSpecialNodeAfter = ($pos: ResolvedPos, tr: Transaction, matchers: NodeMatch[]) => {
  if (nodeNameMatchesList($pos.nodeAfter, matchers)) {
    return $pos.pos + 1;
  }

  const { parentOffset, parent } = $pos;
  const docSize = tr.doc.nodeSize - 2;

  if (parentOffset === parent.content.size && $pos.pos + 1 < docSize - 2) {
    const { nodeAfter } = tr.doc.resolve($pos.pos + 1);
    if (nodeAfter && nodeNameMatchesList(nodeAfter.firstChild, matchers)) {
      return $pos.pos + 2;
    }
  }

  return;
};