@portabletext/editor 1.44.3 → 1.44.5

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.
@@ -234,14 +234,24 @@ function isEqualToEmptyEditor(children, schemaTypes) {
234
234
  function getFocusBlock({
235
235
  editor
236
236
  }) {
237
- return editor.selection ? slate.Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [void 0, void 0] : [void 0, void 0];
237
+ if (!editor.selection)
238
+ return [void 0, void 0];
239
+ try {
240
+ return slate.Editor.node(editor, editor.selection.focus.path.slice(0, 1)) ?? [void 0, void 0];
241
+ } catch {
242
+ return [void 0, void 0];
243
+ }
238
244
  }
239
245
  function getPointBlock({
240
246
  editor,
241
247
  point
242
248
  }) {
243
- const [block] = slate.Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
244
- return block ? [block, point.path] : [void 0, void 0];
249
+ try {
250
+ const [block] = slate.Editor.node(editor, point.path.slice(0, 1)) ?? [void 0, void 0];
251
+ return block ? [block, point.path] : [void 0, void 0];
252
+ } catch {
253
+ return [void 0, void 0];
254
+ }
245
255
  }
246
256
  function getFocusChild({
247
257
  editor
@@ -251,8 +261,12 @@ function getFocusChild({
251
261
  }), childIndex = editor.selection?.focus.path.at(1);
252
262
  if (!focusBlock || !focusBlockPath || childIndex === void 0)
253
263
  return [void 0, void 0];
254
- const focusChild = slate.Node.child(focusBlock, childIndex);
255
- return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
264
+ try {
265
+ const focusChild = slate.Node.child(focusBlock, childIndex);
266
+ return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
267
+ } catch {
268
+ return [void 0, void 0];
269
+ }
256
270
  }
257
271
  function getPointChild({
258
272
  editor,
@@ -275,13 +289,21 @@ function getFirstBlock({
275
289
  editor
276
290
  }) {
277
291
  const firstBlockPath = slate.Editor.start(editor, []).path.at(0);
278
- return firstBlockPath !== void 0 ? slate.Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
292
+ try {
293
+ return firstBlockPath !== void 0 ? slate.Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
294
+ } catch {
295
+ return [void 0, void 0];
296
+ }
279
297
  }
280
298
  function getLastBlock({
281
299
  editor
282
300
  }) {
283
301
  const lastBlockPath = slate.Editor.end(editor, []).path.at(0);
284
- return lastBlockPath !== void 0 ? slate.Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
302
+ try {
303
+ return lastBlockPath !== void 0 ? slate.Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
304
+ } catch {
305
+ return [void 0, void 0];
306
+ }
285
307
  }
286
308
  function getNodeBlock({
287
309
  editor,