@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.
- package/dist/tiptap-core.cjs.js +10 -11
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +10 -11
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +10 -11
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/setTextSelection.ts +1 -1
- package/src/helpers/resolveFocusPosition.ts +18 -10
package/dist/tiptap-core.esm.js
CHANGED
|
@@ -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
|
|
514
|
+
return selectionAtStart;
|
|
513
515
|
}
|
|
514
516
|
if (position === 'end') {
|
|
515
|
-
return
|
|
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
|
-
|
|
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.
|
|
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);
|