@portabletext/editor 2.0.0 → 2.1.1
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 +22 -7
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +22 -7
- package/lib/index.js.map +1 -1
- package/package.json +18 -18
- package/src/behaviors/behavior.core.lists.ts +22 -9
- package/src/editor/__tests__/RangeDecorations.test.tsx +60 -0
- package/src/editor/range-decorations-machine.ts +2 -0
- package/src/utils/util.at-the-beginning-of-block.ts +32 -0
package/lib/index.cjs
CHANGED
|
@@ -6075,15 +6075,25 @@ const coreDndBehaviors = [
|
|
|
6075
6075
|
breakingEntireDocument,
|
|
6076
6076
|
breakingEntireBlocks,
|
|
6077
6077
|
breakingInlineObject
|
|
6078
|
-
}
|
|
6078
|
+
};
|
|
6079
|
+
function isAtTheBeginningOfBlock({
|
|
6080
|
+
context,
|
|
6081
|
+
block
|
|
6082
|
+
}) {
|
|
6083
|
+
return !util_sliceBlocks.isTextBlock(context, block) || !context.selection || !util_isSelectionCollapsed.isSelectionCollapsed(context.selection) ? !1 : util_sliceBlocks.getChildKeyFromSelectionPoint(context.selection.focus) === block.children[0]._key && context.selection.focus.offset === 0;
|
|
6084
|
+
}
|
|
6085
|
+
const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior({
|
|
6079
6086
|
on: "delete.backward",
|
|
6080
6087
|
guard: ({
|
|
6081
6088
|
snapshot
|
|
6082
6089
|
}) => {
|
|
6083
|
-
const
|
|
6084
|
-
return !
|
|
6090
|
+
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
6091
|
+
return !focusTextBlock || focusTextBlock.node.level !== 1 || !isAtTheBeginningOfBlock({
|
|
6092
|
+
context: snapshot.context,
|
|
6093
|
+
block: focusTextBlock.node
|
|
6094
|
+
}) ? !1 : {
|
|
6085
6095
|
focusTextBlock
|
|
6086
|
-
}
|
|
6096
|
+
};
|
|
6087
6097
|
},
|
|
6088
6098
|
actions: [(_, {
|
|
6089
6099
|
focusTextBlock
|
|
@@ -6141,7 +6151,10 @@ const coreDndBehaviors = [
|
|
|
6141
6151
|
snapshot
|
|
6142
6152
|
}) => {
|
|
6143
6153
|
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot), previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock(snapshot);
|
|
6144
|
-
if (!focusTextBlock || !previousBlock || !
|
|
6154
|
+
if (!focusTextBlock || !previousBlock || !isAtTheBeginningOfBlock({
|
|
6155
|
+
context: snapshot.context,
|
|
6156
|
+
block: focusTextBlock.node
|
|
6157
|
+
}) || !util_sliceBlocks.isListBlock(snapshot.context, previousBlock.node) || !util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, previousBlock.node))
|
|
6145
6158
|
return !1;
|
|
6146
6159
|
const previousBlockEndPoint = util_isSelectionCollapsed.getBlockEndPoint({
|
|
6147
6160
|
context: snapshot.context,
|
|
@@ -11041,10 +11054,12 @@ const slateOperationCallback = ({
|
|
|
11041
11054
|
return !1;
|
|
11042
11055
|
const existingRangeDecorations = context.slateEditor.decoratedRanges.map((decoratedRange) => ({
|
|
11043
11056
|
anchor: decoratedRange.rangeDecoration.selection?.anchor,
|
|
11044
|
-
focus: decoratedRange.rangeDecoration.selection?.focus
|
|
11057
|
+
focus: decoratedRange.rangeDecoration.selection?.focus,
|
|
11058
|
+
payload: decoratedRange.rangeDecoration.payload
|
|
11045
11059
|
})), newRangeDecorations = event.rangeDecorations.map((rangeDecoration) => ({
|
|
11046
11060
|
anchor: rangeDecoration.selection?.anchor,
|
|
11047
|
-
focus: rangeDecoration.selection?.focus
|
|
11061
|
+
focus: rangeDecoration.selection?.focus,
|
|
11062
|
+
payload: rangeDecoration.payload
|
|
11048
11063
|
}));
|
|
11049
11064
|
return !isEqual__default.default(existingRangeDecorations, newRangeDecorations);
|
|
11050
11065
|
},
|