How to use the prosemirror-state.Selection.atStart 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 ProseMirror / prosemirror-view / test / view.js View on Github external
function selFor(doc) {
  let a = doc.tag.a
  if (a != null) {
    let $a = doc.resolve(a)
    if ($a.parent.inlineContent) return new TextSelection($a, doc.tag.b != null ? doc.resolve(doc.tag.b) : undefined)
    else return new NodeSelection($a)
  }
  return Selection.atStart(doc)
}
github guardian / prosemirror-noting / test / prosemirror-noter-plugin.spec.js View on Github external
const selFor = initDoc => {
  const { a } = initDoc.tag;
  if (a !== null) {
    const $a = initDoc.resolve(a);
    if ($a.parent.inlineContent) {
      const { b } = initDoc.tag;
      const $b = b ? initDoc.resolve(b) : undefined;
      return new TextSelection($a, $b);
    } else {
      return new NodeSelection($a);
    }
  }
  return Selection.atStart(doc);
};
github ProseMirror / prosemirror-commands / test / test-commands.js View on Github external
function selFor(doc) {
  let a = doc.tag.a
  if (a != null) {
    let $a = doc.resolve(a)
    if ($a.parent.inlineContent) return new TextSelection($a, doc.tag.b != null ? doc.resolve(doc.tag.b) : undefined)
    else return new NodeSelection($a)
  }
  return Selection.atStart(doc)
}
github ifiokjr / remirror / @remirror / core-utils / src / prosemirror-utils.ts View on Github external
export const findNodeAtStartOfDoc = (doc: ProsemirrorNode) =>
  findNodeAtPosition(PMSelection.atStart(doc).$from);
github nib-edit / Nib / packages / core / src / plugins / common / keymaps.js View on Github external
"Mod-a": (state, dispatch) => {
    const textSelection = new TextSelection(
      Selection.atStart(state.doc).$anchor,
      Selection.atEnd(state.doc).$head
    );
    dispatch(state.tr.setSelection(textSelection));
    return true;
  }
});
github ifiokjr / remirror / packages / jest-prosemirror / src / jest-prosemirror-nodes.ts View on Github external
export const selectionFor = (
  taggedDoc: TaggedProsemirrorNode,
): Selection => {
  return initSelection(taggedDoc) ?? Selection.atStart(taggedDoc);
};
github pubpub / pubpub-editor / src / utils / index.js View on Github external
export const importDocJson = (editorView, docJson) => {
	const doc = Node.fromJSON(editorView.state.schema, docJson);
	const tr = editorView.state.tr;
	tr.setSelection(Selection.atStart(editorView.state.doc));
	tr.replaceSelection(new Slice(doc.content, 0, 0));
	editorView.dispatch(tr);
	return doc;
};