@portabletext/editor 2.2.0 → 2.3.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 +62 -0
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +62 -0
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/package.json +3 -3
- package/src/behaviors/behavior.abstract.delete.ts +91 -1
package/lib/index.cjs
CHANGED
|
@@ -6558,6 +6558,44 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6558
6558
|
unit: event.unit,
|
|
6559
6559
|
at: selection
|
|
6560
6560
|
})]]
|
|
6561
|
+
}), behaviors_index.defineBehavior({
|
|
6562
|
+
on: "delete",
|
|
6563
|
+
guard: ({
|
|
6564
|
+
snapshot,
|
|
6565
|
+
event
|
|
6566
|
+
}) => {
|
|
6567
|
+
if (event.direction !== "backward")
|
|
6568
|
+
return !1;
|
|
6569
|
+
const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
6570
|
+
if (!previousBlock || !focusTextBlock || !selector_isSelectingEntireBlocks.isAtTheStartOfBlock(focusTextBlock)(snapshot))
|
|
6571
|
+
return !1;
|
|
6572
|
+
const previousBlockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
|
|
6573
|
+
context: snapshot.context,
|
|
6574
|
+
block: previousBlock
|
|
6575
|
+
});
|
|
6576
|
+
return util_sliceBlocks.isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
6577
|
+
previousBlockEndPoint,
|
|
6578
|
+
focusTextBlock
|
|
6579
|
+
} : !1;
|
|
6580
|
+
},
|
|
6581
|
+
actions: [(_, {
|
|
6582
|
+
previousBlockEndPoint,
|
|
6583
|
+
focusTextBlock
|
|
6584
|
+
}) => [behaviors_index.raise({
|
|
6585
|
+
type: "delete.block",
|
|
6586
|
+
at: focusTextBlock.path
|
|
6587
|
+
}), behaviors_index.raise({
|
|
6588
|
+
type: "select",
|
|
6589
|
+
at: {
|
|
6590
|
+
anchor: previousBlockEndPoint,
|
|
6591
|
+
focus: previousBlockEndPoint
|
|
6592
|
+
}
|
|
6593
|
+
}), behaviors_index.raise({
|
|
6594
|
+
type: "insert.block",
|
|
6595
|
+
block: focusTextBlock.node,
|
|
6596
|
+
placement: "auto",
|
|
6597
|
+
select: "start"
|
|
6598
|
+
})]]
|
|
6561
6599
|
}), behaviors_index.defineBehavior({
|
|
6562
6600
|
on: "delete.forward",
|
|
6563
6601
|
guard: ({
|
|
@@ -6575,6 +6613,30 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
6575
6613
|
unit: event.unit,
|
|
6576
6614
|
at: selection
|
|
6577
6615
|
})]]
|
|
6616
|
+
}), behaviors_index.defineBehavior({
|
|
6617
|
+
on: "delete",
|
|
6618
|
+
guard: ({
|
|
6619
|
+
snapshot,
|
|
6620
|
+
event
|
|
6621
|
+
}) => {
|
|
6622
|
+
if (event.direction !== "forward")
|
|
6623
|
+
return !1;
|
|
6624
|
+
const nextBlock = selector_isSelectingEntireBlocks.getNextBlock(snapshot), focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
6625
|
+
return !nextBlock || !focusTextBlock || !selector_isSelectingEntireBlocks.isAtTheEndOfBlock(focusTextBlock)(snapshot) || !util_sliceBlocks.isTextBlock(snapshot.context, nextBlock.node) ? !1 : {
|
|
6626
|
+
nextBlock
|
|
6627
|
+
};
|
|
6628
|
+
},
|
|
6629
|
+
actions: [(_, {
|
|
6630
|
+
nextBlock
|
|
6631
|
+
}) => [behaviors_index.raise({
|
|
6632
|
+
type: "delete.block",
|
|
6633
|
+
at: nextBlock.path
|
|
6634
|
+
}), behaviors_index.raise({
|
|
6635
|
+
type: "insert.block",
|
|
6636
|
+
block: nextBlock.node,
|
|
6637
|
+
placement: "auto",
|
|
6638
|
+
select: "none"
|
|
6639
|
+
})]]
|
|
6578
6640
|
}), behaviors_index.defineBehavior({
|
|
6579
6641
|
on: "delete.block",
|
|
6580
6642
|
actions: [({
|