@portabletext/editor 1.40.4 → 1.41.1

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.
@@ -331,14 +331,17 @@ function getFocusChild({
331
331
  const focusChild = slate.Node.child(focusBlock, childIndex);
332
332
  return focusChild ? [focusChild, [...focusBlockPath, childIndex]] : [void 0, void 0];
333
333
  }
334
+ function getFirstBlock({
335
+ editor
336
+ }) {
337
+ const firstBlockPath = slate.Editor.start(editor, []).path.at(0);
338
+ return firstBlockPath !== void 0 ? slate.Editor.node(editor, [firstBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
339
+ }
334
340
  function getLastBlock({
335
341
  editor
336
342
  }) {
337
- return Array.from(slate.Editor.nodes(editor, {
338
- match: (n) => !slate.Editor.isEditor(n),
339
- at: [],
340
- reverse: !0
341
- })).at(0) ?? [void 0, void 0];
343
+ const lastBlockPath = slate.Editor.end(editor, []).path.at(0);
344
+ return lastBlockPath !== void 0 ? slate.Editor.node(editor, [lastBlockPath]) ?? [void 0, void 0] : [void 0, void 0];
342
345
  }
343
346
  function getNodeBlock({
344
347
  editor,
@@ -2591,7 +2594,7 @@ const converterJson = {
2591
2594
  data: util_sliceBlocks.sliceBlocks({
2592
2595
  blocks: snapshot.context.value,
2593
2596
  selection
2594
- }).map((block) => types.isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : "").join("") : "").filter((block) => block !== "").join(`
2597
+ }).map((block) => types.isPortableTextTextBlock(block) ? block.children.map((child) => child._type === snapshot.context.schema.span.name ? child.text : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.inlineObjects.find((inlineObjectType) => inlineObjectType.name === child._type)?.title ?? "Object"}]` : "").join("") : snapshot.beta.hasTag("dragging internally") ? `[${snapshot.context.schema.blockObjects.find((blockObjectType) => blockObjectType.name === block._type)?.title ?? "Object"}]` : "").filter((block) => block !== "").join(`
2595
2598
 
2596
2599
  `),
2597
2600
  mimeType: "text/plain",
@@ -7704,6 +7707,8 @@ exports.defaultKeyGenerator = defaultKeyGenerator;
7704
7707
  exports.defineSchema = defineSchema;
7705
7708
  exports.fromSlateValue = fromSlateValue;
7706
7709
  exports.getEditorSnapshot = getEditorSnapshot;
7710
+ exports.getFirstBlock = getFirstBlock;
7711
+ exports.getLastBlock = getLastBlock;
7707
7712
  exports.getNodeBlock = getNodeBlock;
7708
7713
  exports.isEqualToEmptyEditor = isEqualToEmptyEditor;
7709
7714
  exports.moveRangeByOperation = moveRangeByOperation;