@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/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.172",
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": "88ef8eabb054a475b878a1fdb78ba80e6470961a"
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 = 0
23
- const maxPos = tr.doc.content.size
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)
@@ -60,8 +60,6 @@ export const Keymap = Extension.create({
60
60
 
61
61
  const pcKeymap = {
62
62
  ...baseKeymap,
63
- Home: () => this.editor.commands.selectTextblockStart(),
64
- End: () => this.editor.commands.selectTextblockEnd(),
65
63
  }
66
64
 
67
65
  const macKeymap = {
@@ -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 Selection.atStart(doc)
19
+ return selectionAtStart
17
20
  }
18
21
 
19
22
  if (position === 'end') {
20
- return Selection.atEnd(doc)
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(doc, 0, doc.content.size)
30
+ return TextSelection.create(
31
+ doc,
32
+ minMax(0, minPos, maxPos),
33
+ minMax(doc.content.size, minPos, maxPos),
34
+ )
25
35
  }
26
36
 
27
- // Check if `position` is in bounds of the doc if `position` is a number.
28
- const minPos = Selection.atStart(doc).from
29
- const maxPos = Selection.atEnd(doc).to
30
- const resolvedFrom = minMax(position, minPos, maxPos)
31
- const resolvedEnd = minMax(position, minPos, maxPos)
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
  }