How to use the @remirror/core-utils.selectionEmpty function in @remirror/core-utils

To help you get started, we’ve selected a few @remirror/core-utils 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 / packages / prosemirror-suggest / src / suggest-utils.ts View on Github external
}

  // Exited a suggestion
  if (isExit(compare)) {
    return findExitReason({ $pos, match: compare.prev, state });
  }

  if (isChange(compare)) {
    return { change: createMatchWithReason({ match: compare.next, reason: ChangeReason.Text }) };
  }

  if (isMove(compare)) {
    return {
      change: createMatchWithReason({
        match: compare.next,
        reason: selectionEmpty(state) ? ChangeReason.Move : ChangeReason.SelectionInside,
      }),
    };
  }

  return value;
};
github ifiokjr / remirror / packages / prosemirror-suggest / src / suggest-utils.ts View on Github external
const findExitReason = ({
  match,
  state,
  $pos,
}: SuggestStateMatchParams & EditorStateParams & ResolvedPosParams) => {
  const { selection } = state;
  const updatedPrev = recheckMatch({ match, state });

  // Exit created a split
  if (!updatedPrev || updatedPrev.queryText.full !== match.queryText.full) {
    return createInsertReason({ prev: match, next: updatedPrev, state });
  }

  // Exit caused by a selection
  if (!selectionEmpty(state) && (selection.from <= match.range.from || selection.to >= match.range.end)) {
    return { exit: createMatchWithReason({ match, reason: ExitReason.SelectionOutside }) };
  }

  // Exit happened at the end of previous suggestion
  if ($pos.pos > match.range.end) {
    return { exit: createMatchWithReason({ match, reason: ExitReason.MoveEnd }) };
  }

  // Exit happened at the start of previous suggestion
  if ($pos.pos <= match.range.from) {
    return { exit: createMatchWithReason({ match, reason: ExitReason.MoveStart }) };
  }

  return {};
};