@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 +13 -2
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +13 -2
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +29 -1
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +22 -0
- package/lib/selectors/index.d.ts +22 -0
- package/lib/selectors/index.js +32 -4
- package/lib/selectors/index.js.map +1 -1
- package/package.json +5 -5
- package/src/editor/editor-dom.ts +0 -56
- package/src/index.ts +1 -0
- package/src/operations/behavior.operation.delete.ts +24 -0
- package/src/selectors/index.ts +3 -1
- package/src/selectors/selector.get-selection-end-child.ts +33 -0
- package/src/selectors/selector.get-selection-start-child.ts +33 -0
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),
|
|
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,
|