@tiptap/core 2.0.0-beta.173 → 2.0.0-beta.174

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.
@@ -508,21 +508,20 @@ function resolveFocusPosition(doc, position = null) {
508
508
  if (!position) {
509
509
  return null;
510
510
  }
511
+ const selectionAtStart = Selection.atStart(doc);
512
+ const selectionAtEnd = Selection.atEnd(doc);
511
513
  if (position === 'start' || position === true) {
512
- return Selection.atStart(doc);
514
+ return selectionAtStart;
513
515
  }
514
516
  if (position === 'end') {
515
- return Selection.atEnd(doc);
517
+ return selectionAtEnd;
516
518
  }
519
+ const minPos = selectionAtStart.from;
520
+ const maxPos = selectionAtEnd.to;
517
521
  if (position === 'all') {
518
- return TextSelection.create(doc, 0, doc.content.size);
519
- }
520
- // Check if `position` is in bounds of the doc if `position` is a number.
521
- const minPos = Selection.atStart(doc).from;
522
- const maxPos = Selection.atEnd(doc).to;
523
- const resolvedFrom = minMax(position, minPos, maxPos);
524
- const resolvedEnd = minMax(position, minPos, maxPos);
525
- return TextSelection.create(doc, resolvedFrom, resolvedEnd);
522
+ return TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos));
523
+ }
524
+ return TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos));
526
525
  }
527
526
 
528
527
  const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
@@ -1194,7 +1193,7 @@ const setTextSelection = position => ({ tr, dispatch }) => {
1194
1193
  ? { from: position, to: position }
1195
1194
  : position;
1196
1195
  const minPos = TextSelection.atStart(doc).from;
1197
- const maxPos = doc.content.size;
1196
+ const maxPos = TextSelection.atEnd(doc).to;
1198
1197
  const resolvedFrom = minMax(from, minPos, maxPos);
1199
1198
  const resolvedEnd = minMax(to, minPos, maxPos);
1200
1199
  const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd);