@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.d.cts
CHANGED
|
@@ -7195,6 +7195,8 @@ declare interface PortableTextSlateEditor extends ReactEditor {
|
|
|
7195
7195
|
|
|
7196
7196
|
export {PortableTextSpan}
|
|
7197
7197
|
|
|
7198
|
+
export {PortableTextTextBlock}
|
|
7199
|
+
|
|
7198
7200
|
/**
|
|
7199
7201
|
* A range decoration is a UI affordance that wraps a given selection range in the editor
|
|
7200
7202
|
* with a custom component. This can be used to highlight search results,
|
package/lib/index.d.ts
CHANGED
|
@@ -7195,6 +7195,8 @@ declare interface PortableTextSlateEditor extends ReactEditor {
|
|
|
7195
7195
|
|
|
7196
7196
|
export {PortableTextSpan}
|
|
7197
7197
|
|
|
7198
|
+
export {PortableTextTextBlock}
|
|
7199
|
+
|
|
7198
7200
|
/**
|
|
7199
7201
|
* A range decoration is a UI affordance that wraps a given selection range in the editor
|
|
7200
7202
|
* with a custom component. This can be used to highlight search results,
|
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,
|