@portabletext/editor 1.57.4 → 1.58.0

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/lib/index.cjs CHANGED
@@ -3290,7 +3290,16 @@ const addAnnotationOperationImplementation = ({
3290
3290
  context,
3291
3291
  operation
3292
3292
  }) => {
3293
- const anchorBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(operation.at.anchor), focusBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(operation.at.focus), anchorBlockPath = anchorBlockKey !== void 0 ? getBlockPath({
3293
+ const anchorBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(operation.at.anchor), focusBlockKey = util_sliceBlocks.getBlockKeyFromSelectionPoint(operation.at.focus), endBlockKey = operation.at.backward ? anchorBlockKey : focusBlockKey, endOffset = operation.at.backward ? operation.at.focus.offset : operation.at.anchor.offset;
3294
+ if (!endBlockKey)
3295
+ throw new Error("Failed to get end block key");
3296
+ const endBlockIndex = operation.editor.blockIndexMap.get(endBlockKey);
3297
+ if (endBlockIndex === void 0)
3298
+ throw new Error("Failed to get end block index");
3299
+ const endBlock = operation.editor.value.at(endBlockIndex);
3300
+ if (!endBlock)
3301
+ throw new Error("Failed to get end block");
3302
+ const anchorBlockPath = anchorBlockKey !== void 0 ? getBlockPath({
3294
3303
  editor: operation.editor,
3295
3304
  _key: anchorBlockKey
3296
3305
  }) : void 0, focusBlockPath = focusBlockKey !== void 0 ? getBlockPath({
@@ -3313,10 +3322,12 @@ const addAnnotationOperationImplementation = ({
3313
3322
  });
3314
3323
  if (!range)
3315
3324
  throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(operation.at)}`);
3325
+ const hanging = util_sliceBlocks.isTextBlock(context, endBlock) && endOffset === 0;
3316
3326
  operation.editor.delete({
3317
3327
  at: range,
3318
3328
  reverse: operation.direction === "backward",
3319
- unit: operation.unit
3329
+ unit: operation.unit,
3330
+ hanging
3320
3331
  });
3321
3332
  }, insertInlineObjectOperationImplementation = ({
3322
3333
  context,