How to use the prosemirror-state.AllSelection function in prosemirror-state

To help you get started, we’ve selected a few prosemirror-state 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 guardian / prosemirror-noting / src / js / utils / StateUtils.js View on Github external
export const notesFromDoc = (doc, markType, min = false, max = false) => {
  const notes = {};

  const { from, to } = new AllSelection(doc);

  const _min = min === false ? from : min;
  const _max = max === false ? to : max;

  doc.nodesBetween(_min, _max, (node, start) => {
    const end = start + node.nodeSize;
    const mark = markType.isInSet(node.marks);

    if (mark) {
      const { id, meta } = mark.attrs;

      notes[id] = notes[id] || {
        id,
        meta, // this should be the same across all notes so just set it here
        nodes: [],
        start: Infinity,
github ProseMirror / prosemirror-commands / src / commands.js View on Github external
export function selectAll(state, dispatch) {
  if (dispatch) dispatch(state.tr.setSelection(new AllSelection(state.doc)))
  return true
}
github guardian / prosemirror-invisibles / src / js / index.js View on Github external
init: (_, state) => {
        const { from, to } = new AllSelection(state.doc);
        return addDecosBetween(from, to, state.doc, DecorationSet.empty);
      },
      apply: (tr, prevDecos, _, state) =>
github ifiokjr / remirror / packages / jest-remirror / src / transactions.ts View on Github external
export const dispatchAllSelection = ({ view }: TestEditorViewParams) => {
  const { tr, doc } = view.state;
  view.dispatch(tr.setSelection(new AllSelection(doc)));
};
github ifiokjr / remirror / packages / jest-prosemirror / src / jest-prosemirror-nodes.ts View on Github external
export const initSelection = (
  taggedDoc: TaggedProsemirrorNode,
) => {
  const { cursor, node, start, end, anchor, all, gap } = taggedDoc.tag;
  if (all) {
    return new AllSelection(taggedDoc);
  }

  if (node) {
    return new NodeSelection(taggedDoc.resolve(node));
  }

  if (cursor) {
    return new TextSelection(taggedDoc.resolve(cursor));
  }

  if (gap) {
    const $pos = taggedDoc.resolve(gap);
    return new GapCursor($pos, $pos);
  }

  if (start) {
github ifiokjr / remirror / packages / jest-prosemirror / src / jest-prosemirror-editor.ts View on Github external
export const dispatchAllSelection = ({
  view,
}: TestEditorViewParams) => {
  const { tr, doc } = view.state;
  view.dispatch(tr.setSelection(new AllSelection(doc)));
};