@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.
- package/dist/tiptap-core.cjs.js +11 -14
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +11 -14
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +11 -14
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/setTextSelection.ts +2 -2
- package/src/extensions/keymap.ts +0 -2
- package/src/helpers/resolveFocusPosition.ts +18 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/core",
|
|
3
3
|
"description": "headless rich text editor",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.175",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"directory": "packages/core"
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "90e719c711dbccae6a7333956d543fb93789f3d3"
|
|
49
49
|
}
|
|
@@ -19,8 +19,8 @@ export const setTextSelection: RawCommands['setTextSelection'] = position => ({
|
|
|
19
19
|
const { from, to } = typeof position === 'number'
|
|
20
20
|
? { from: position, to: position }
|
|
21
21
|
: position
|
|
22
|
-
const minPos =
|
|
23
|
-
const maxPos =
|
|
22
|
+
const minPos = TextSelection.atStart(doc).from
|
|
23
|
+
const maxPos = TextSelection.atEnd(doc).to
|
|
24
24
|
const resolvedFrom = minMax(from, minPos, maxPos)
|
|
25
25
|
const resolvedEnd = minMax(to, minPos, maxPos)
|
|
26
26
|
const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
package/src/extensions/keymap.ts
CHANGED
|
@@ -12,23 +12,31 @@ export function resolveFocusPosition(
|
|
|
12
12
|
return null
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const selectionAtStart = Selection.atStart(doc)
|
|
16
|
+
const selectionAtEnd = Selection.atEnd(doc)
|
|
17
|
+
|
|
15
18
|
if (position === 'start' || position === true) {
|
|
16
|
-
return
|
|
19
|
+
return selectionAtStart
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
if (position === 'end') {
|
|
20
|
-
return
|
|
23
|
+
return selectionAtEnd
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
const minPos = selectionAtStart.from
|
|
27
|
+
const maxPos = selectionAtEnd.to
|
|
28
|
+
|
|
23
29
|
if (position === 'all') {
|
|
24
|
-
return TextSelection.create(
|
|
30
|
+
return TextSelection.create(
|
|
31
|
+
doc,
|
|
32
|
+
minMax(0, minPos, maxPos),
|
|
33
|
+
minMax(doc.content.size, minPos, maxPos),
|
|
34
|
+
)
|
|
25
35
|
}
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return TextSelection.create(doc, resolvedFrom, resolvedEnd)
|
|
37
|
+
return TextSelection.create(
|
|
38
|
+
doc,
|
|
39
|
+
minMax(position, minPos, maxPos),
|
|
40
|
+
minMax(position, minPos, maxPos),
|
|
41
|
+
)
|
|
34
42
|
}
|