@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.
@@ -260,14 +260,24 @@ function isEqualToEmptyEditor(children, schemaTypes) {
260
260
  function getFocusBlock({
261
261
  editor
262
262
  }) {
263
- return editor.selection ? Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [void 0, void 0] : [void 0, void 0];
263
+ if (!editor.selection)
264
+ return [void 0, void 0];
265
+ try {
266
+ return Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [void 0, void 0];
267
+ } catch {
268
+ return [void 0, void 0];
269
+ }
264
270
  }
265
271
  function getPointBlock({
266
272
  editor,
267
273
  point
268
274
  }) {
269
- const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
270
- return block ? [block, point.path] : [void 0, void 0];
275
+ try {
276
+ const [block] = Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
277
+ return block ? [block, point.path] : [void 0, void 0];
278
+ } catch {
279
+ return [void 0, void 0];
280
+ }
271
281
  }
272
282
  function getFocusChild({
273
283
  editor
@@ -277,8 +287,12 @@ function getFocusChild({
277
287
  }), childIndex = editor.selection?.focus.path.at(1);
278
288
  if (!focusBlock || !focusBlockPath || childIndex === void 0)
279
289
  return [void 0, void 0];
280
- const focusChild = Node.child(focusBlock, childIndex);
281
- return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
290
+ try {
291
+ const focusChild = Node.child(focusBlock, childIndex);
292
+ return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
293
+ } catch {
294
+ return [void 0, void 0];
295
+ }
282
296
  }
283
297
  function getPointChild({
284
298
  editor,
@@ -301,13 +315,21 @@ function getFirstBlock({
301
315
  editor
302
316
  }) {
303
317
  const firstBlockPath = Editor.start(editor, []).path.at(0);
304
- return firstBlockPath !== void 0 ? Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
318
+ try {
319
+ return firstBlockPath !== void 0 ? Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
320
+ } catch {
321
+ return [void 0, void 0];
322
+ }
305
323
  }
306
324
  function getLastBlock({
307
325
  editor
308
326
  }) {
309
327
  const lastBlockPath = Editor.end(editor, []).path.at(0);
310
- return lastBlockPath !== void 0 ? Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
328
+ try {
329
+ return lastBlockPath !== void 0 ? Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
330
+ } catch {
331
+ return [void 0, void 0];
332
+ }
311
333
  }
312
334
  function getNodeBlock({
313
335
  editor,