@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.js
CHANGED
|
@@ -6587,6 +6587,44 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
|
|
|
6587
6587
|
unit: event.unit,
|
|
6588
6588
|
at: selection
|
|
6589
6589
|
})]]
|
|
6590
|
+
}), defineBehavior({
|
|
6591
|
+
on: "delete",
|
|
6592
|
+
guard: ({
|
|
6593
|
+
snapshot,
|
|
6594
|
+
event
|
|
6595
|
+
}) => {
|
|
6596
|
+
if (event.direction !== "backward")
|
|
6597
|
+
return !1;
|
|
6598
|
+
const previousBlock = getPreviousBlock(snapshot), focusTextBlock = getFocusTextBlock(snapshot);
|
|
6599
|
+
if (!previousBlock || !focusTextBlock || !isAtTheStartOfBlock(focusTextBlock)(snapshot))
|
|
6600
|
+
return !1;
|
|
6601
|
+
const previousBlockEndPoint = getBlockEndPoint({
|
|
6602
|
+
context: snapshot.context,
|
|
6603
|
+
block: previousBlock
|
|
6604
|
+
});
|
|
6605
|
+
return isTextBlock(snapshot.context, previousBlock.node) ? {
|
|
6606
|
+
previousBlockEndPoint,
|
|
6607
|
+
focusTextBlock
|
|
6608
|
+
} : !1;
|
|
6609
|
+
},
|
|
6610
|
+
actions: [(_, {
|
|
6611
|
+
previousBlockEndPoint,
|
|
6612
|
+
focusTextBlock
|
|
6613
|
+
}) => [raise({
|
|
6614
|
+
type: "delete.block",
|
|
6615
|
+
at: focusTextBlock.path
|
|
6616
|
+
}), raise({
|
|
6617
|
+
type: "select",
|
|
6618
|
+
at: {
|
|
6619
|
+
anchor: previousBlockEndPoint,
|
|
6620
|
+
focus: previousBlockEndPoint
|
|
6621
|
+
}
|
|
6622
|
+
}), raise({
|
|
6623
|
+
type: "insert.block",
|
|
6624
|
+
block: focusTextBlock.node,
|
|
6625
|
+
placement: "auto",
|
|
6626
|
+
select: "start"
|
|
6627
|
+
})]]
|
|
6590
6628
|
}), defineBehavior({
|
|
6591
6629
|
on: "delete.forward",
|
|
6592
6630
|
guard: ({
|
|
@@ -6604,6 +6642,30 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
|
|
|
6604
6642
|
unit: event.unit,
|
|
6605
6643
|
at: selection
|
|
6606
6644
|
})]]
|
|
6645
|
+
}), defineBehavior({
|
|
6646
|
+
on: "delete",
|
|
6647
|
+
guard: ({
|
|
6648
|
+
snapshot,
|
|
6649
|
+
event
|
|
6650
|
+
}) => {
|
|
6651
|
+
if (event.direction !== "forward")
|
|
6652
|
+
return !1;
|
|
6653
|
+
const nextBlock = getNextBlock(snapshot), focusTextBlock = getFocusTextBlock(snapshot);
|
|
6654
|
+
return !nextBlock || !focusTextBlock || !isAtTheEndOfBlock(focusTextBlock)(snapshot) || !isTextBlock(snapshot.context, nextBlock.node) ? !1 : {
|
|
6655
|
+
nextBlock
|
|
6656
|
+
};
|
|
6657
|
+
},
|
|
6658
|
+
actions: [(_, {
|
|
6659
|
+
nextBlock
|
|
6660
|
+
}) => [raise({
|
|
6661
|
+
type: "delete.block",
|
|
6662
|
+
at: nextBlock.path
|
|
6663
|
+
}), raise({
|
|
6664
|
+
type: "insert.block",
|
|
6665
|
+
block: nextBlock.node,
|
|
6666
|
+
placement: "auto",
|
|
6667
|
+
select: "none"
|
|
6668
|
+
})]]
|
|
6607
6669
|
}), defineBehavior({
|
|
6608
6670
|
on: "delete.block",
|
|
6609
6671
|
actions: [({
|