@tiptap/core 2.0.0-beta.172 → 2.0.0-beta.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -512,21 +512,20 @@ function resolveFocusPosition(doc, position = null) {
512
512
  if (!position) {
513
513
  return null;
514
514
  }
515
+ const selectionAtStart = prosemirrorState.Selection.atStart(doc);
516
+ const selectionAtEnd = prosemirrorState.Selection.atEnd(doc);
515
517
  if (position === 'start' || position === true) {
516
- return prosemirrorState.Selection.atStart(doc);
518
+ return selectionAtStart;
517
519
  }
518
520
  if (position === 'end') {
519
- return prosemirrorState.Selection.atEnd(doc);
521
+ return selectionAtEnd;
520
522
  }
523
+ const minPos = selectionAtStart.from;
524
+ const maxPos = selectionAtEnd.to;
521
525
  if (position === 'all') {
522
- return prosemirrorState.TextSelection.create(doc, 0, doc.content.size);
523
- }
524
- // Check if `position` is in bounds of the doc if `position` is a number.
525
- const minPos = prosemirrorState.Selection.atStart(doc).from;
526
- const maxPos = prosemirrorState.Selection.atEnd(doc).to;
527
- const resolvedFrom = minMax(position, minPos, maxPos);
528
- const resolvedEnd = minMax(position, minPos, maxPos);
529
- return prosemirrorState.TextSelection.create(doc, resolvedFrom, resolvedEnd);
526
+ return prosemirrorState.TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos));
527
+ }
528
+ return prosemirrorState.TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos));
530
529
  }
531
530
 
532
531
  const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
@@ -1197,8 +1196,8 @@ const setTextSelection = position => ({ tr, dispatch }) => {
1197
1196
  const { from, to } = typeof position === 'number'
1198
1197
  ? { from: position, to: position }
1199
1198
  : position;
1200
- const minPos = 0;
1201
- const maxPos = tr.doc.content.size;
1199
+ const minPos = prosemirrorState.TextSelection.atStart(doc).from;
1200
+ const maxPos = prosemirrorState.TextSelection.atEnd(doc).to;
1202
1201
  const resolvedFrom = minMax(from, minPos, maxPos);
1203
1202
  const resolvedEnd = minMax(to, minPos, maxPos);
1204
1203
  const selection = prosemirrorState.TextSelection.create(doc, resolvedFrom, resolvedEnd);
@@ -2103,8 +2102,6 @@ const Keymap = Extension.create({
2103
2102
  };
2104
2103
  const pcKeymap = {
2105
2104
  ...baseKeymap,
2106
- Home: () => this.editor.commands.selectTextblockStart(),
2107
- End: () => this.editor.commands.selectTextblockEnd(),
2108
2105
  };
2109
2106
  const macKeymap = {
2110
2107
  ...baseKeymap,