@portabletext/editor 1.57.4 → 1.57.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.
- package/lib/index.cjs +13 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +13 -2
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
- package/src/operations/behavior.operation.delete.ts +24 -0
package/lib/index.js
CHANGED
|
@@ -3320,7 +3320,16 @@ const addAnnotationOperationImplementation = ({
|
|
|
3320
3320
|
context,
|
|
3321
3321
|
operation
|
|
3322
3322
|
}) => {
|
|
3323
|
-
const anchorBlockKey = getBlockKeyFromSelectionPoint(operation.at.anchor), focusBlockKey = getBlockKeyFromSelectionPoint(operation.at.focus),
|
|
3323
|
+
const anchorBlockKey = getBlockKeyFromSelectionPoint(operation.at.anchor), focusBlockKey = getBlockKeyFromSelectionPoint(operation.at.focus), endBlockKey = operation.at.backward ? anchorBlockKey : focusBlockKey, endOffset = operation.at.backward ? operation.at.focus.offset : operation.at.anchor.offset;
|
|
3324
|
+
if (!endBlockKey)
|
|
3325
|
+
throw new Error("Failed to get end block key");
|
|
3326
|
+
const endBlockIndex = operation.editor.blockIndexMap.get(endBlockKey);
|
|
3327
|
+
if (endBlockIndex === void 0)
|
|
3328
|
+
throw new Error("Failed to get end block index");
|
|
3329
|
+
const endBlock = operation.editor.value.at(endBlockIndex);
|
|
3330
|
+
if (!endBlock)
|
|
3331
|
+
throw new Error("Failed to get end block");
|
|
3332
|
+
const anchorBlockPath = anchorBlockKey !== void 0 ? getBlockPath({
|
|
3324
3333
|
editor: operation.editor,
|
|
3325
3334
|
_key: anchorBlockKey
|
|
3326
3335
|
}) : void 0, focusBlockPath = focusBlockKey !== void 0 ? getBlockPath({
|
|
@@ -3343,10 +3352,12 @@ const addAnnotationOperationImplementation = ({
|
|
|
3343
3352
|
});
|
|
3344
3353
|
if (!range)
|
|
3345
3354
|
throw new Error(`Failed to get Slate Range for selection ${JSON.stringify(operation.at)}`);
|
|
3355
|
+
const hanging = isTextBlock(context, endBlock) && endOffset === 0;
|
|
3346
3356
|
operation.editor.delete({
|
|
3347
3357
|
at: range,
|
|
3348
3358
|
reverse: operation.direction === "backward",
|
|
3349
|
-
unit: operation.unit
|
|
3359
|
+
unit: operation.unit,
|
|
3360
|
+
hanging
|
|
3350
3361
|
});
|
|
3351
3362
|
}, insertInlineObjectOperationImplementation = ({
|
|
3352
3363
|
context,
|