@portabletext/editor 1.44.3 → 1.44.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "1.44.3",
3
+ "version": "1.44.4",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -12,12 +12,16 @@ export function getFocusBlock({
12
12
  return [undefined, undefined]
13
13
  }
14
14
 
15
- return (
16
- Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [
17
- undefined,
18
- undefined,
19
- ]
20
- )
15
+ try {
16
+ return (
17
+ Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [
18
+ undefined,
19
+ undefined,
20
+ ]
21
+ )
22
+ } catch {
23
+ return [undefined, undefined]
24
+ }
21
25
  }
22
26
 
23
27
  function getPointBlock({
@@ -27,11 +31,15 @@ function getPointBlock({
27
31
  editor: PortableTextSlateEditor
28
32
  point: Point
29
33
  }): [node: Node, path: Path] | [undefined, undefined] {
30
- const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [
31
- undefined,
32
- undefined,
33
- ]
34
- return block ? [block, point.path] : [undefined, undefined]
34
+ try {
35
+ const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [
36
+ undefined,
37
+ undefined,
38
+ ]
39
+ return block ? [block, point.path] : [undefined, undefined]
40
+ } catch {
41
+ return [undefined, undefined]
42
+ }
35
43
  }
36
44
 
37
45
  export function getFocusChild({
@@ -46,11 +54,15 @@ export function getFocusChild({
46
54
  return [undefined, undefined]
47
55
  }
48
56
 
49
- const focusChild = Node.child(focusBlock, childIndex)
57
+ try {
58
+ const focusChild = Node.child(focusBlock, childIndex)
50
59
 
51
- return focusChild
52
- ? [focusChild, [...focusBlockPath, childIndex]]
53
- : [undefined, undefined]
60
+ return focusChild
61
+ ? [focusChild, [...focusBlockPath, childIndex]]
62
+ : [undefined, undefined]
63
+ } catch {
64
+ return [undefined, undefined]
65
+ }
54
66
  }
55
67
 
56
68
  function getPointChild({
@@ -86,9 +98,13 @@ export function getFirstBlock({
86
98
  const firstPoint = Editor.start(editor, [])
87
99
  const firstBlockPath = firstPoint.path.at(0)
88
100
 
89
- return firstBlockPath !== undefined
90
- ? (Editor.node(editor, [firstBlockPath]) ?? [undefined, undefined])
91
- : [undefined, undefined]
101
+ try {
102
+ return firstBlockPath !== undefined
103
+ ? (Editor.node(editor, [firstBlockPath]) ?? [undefined, undefined])
104
+ : [undefined, undefined]
105
+ } catch {
106
+ return [undefined, undefined]
107
+ }
92
108
  }
93
109
 
94
110
  export function getLastBlock({
@@ -98,9 +114,14 @@ export function getLastBlock({
98
114
  }): [node: Node, path: Path] | [undefined, undefined] {
99
115
  const lastPoint = Editor.end(editor, [])
100
116
  const lastBlockPath = lastPoint.path.at(0)
101
- return lastBlockPath !== undefined
102
- ? (Editor.node(editor, [lastBlockPath]) ?? [undefined, undefined])
103
- : [undefined, undefined]
117
+
118
+ try {
119
+ return lastBlockPath !== undefined
120
+ ? (Editor.node(editor, [lastBlockPath]) ?? [undefined, undefined])
121
+ : [undefined, undefined]
122
+ } catch {
123
+ return [undefined, undefined]
124
+ }
104
125
  }
105
126
 
106
127
  export function getNodeBlock({