@portabletext/editor 2.0.0 → 2.1.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.js CHANGED
@@ -6105,15 +6105,25 @@ const coreDndBehaviors = [
6105
6105
  breakingEntireDocument,
6106
6106
  breakingEntireBlocks,
6107
6107
  breakingInlineObject
6108
- }, MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
6108
+ };
6109
+ function isAtTheBeginningOfBlock({
6110
+ context,
6111
+ block
6112
+ }) {
6113
+ return !isTextBlock(context, block) || !context.selection || !isSelectionCollapsed(context.selection) ? !1 : getChildKeyFromSelectionPoint(context.selection.focus) === block.children[0]._key && context.selection.focus.offset === 0;
6114
+ }
6115
+ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
6109
6116
  on: "delete.backward",
6110
6117
  guard: ({
6111
6118
  snapshot
6112
6119
  }) => {
6113
- const selectionCollapsed = isSelectionCollapsed$1(snapshot), focusTextBlock = getFocusTextBlock(snapshot), focusSpan = getFocusSpan$1(snapshot);
6114
- return !selectionCollapsed || !focusTextBlock || !focusSpan ? !1 : focusTextBlock.node.children[0]._key === focusSpan.node._key && snapshot.context.selection?.focus.offset === 0 && focusTextBlock.node.level === 1 ? {
6120
+ const focusTextBlock = getFocusTextBlock(snapshot);
6121
+ return !focusTextBlock || focusTextBlock.node.level !== 1 || !isAtTheBeginningOfBlock({
6122
+ context: snapshot.context,
6123
+ block: focusTextBlock.node
6124
+ }) ? !1 : {
6115
6125
  focusTextBlock
6116
- } : !1;
6126
+ };
6117
6127
  },
6118
6128
  actions: [(_, {
6119
6129
  focusTextBlock
@@ -6171,7 +6181,10 @@ const coreDndBehaviors = [
6171
6181
  snapshot
6172
6182
  }) => {
6173
6183
  const focusTextBlock = getFocusTextBlock(snapshot), previousBlock = getPreviousBlock(snapshot);
6174
- if (!focusTextBlock || !previousBlock || !isListBlock(snapshot.context, previousBlock.node) || !isEmptyTextBlock(snapshot.context, previousBlock.node))
6184
+ if (!focusTextBlock || !previousBlock || !isAtTheBeginningOfBlock({
6185
+ context: snapshot.context,
6186
+ block: focusTextBlock.node
6187
+ }) || !isListBlock(snapshot.context, previousBlock.node) || !isEmptyTextBlock(snapshot.context, previousBlock.node))
6175
6188
  return !1;
6176
6189
  const previousBlockEndPoint = getBlockEndPoint({
6177
6190
  context: snapshot.context,
@@ -11071,10 +11084,12 @@ const slateOperationCallback = ({
11071
11084
  return !1;
11072
11085
  const existingRangeDecorations = context.slateEditor.decoratedRanges.map((decoratedRange) => ({
11073
11086
  anchor: decoratedRange.rangeDecoration.selection?.anchor,
11074
- focus: decoratedRange.rangeDecoration.selection?.focus
11087
+ focus: decoratedRange.rangeDecoration.selection?.focus,
11088
+ payload: decoratedRange.rangeDecoration.payload
11075
11089
  })), newRangeDecorations = event.rangeDecorations.map((rangeDecoration) => ({
11076
11090
  anchor: rangeDecoration.selection?.anchor,
11077
- focus: rangeDecoration.selection?.focus
11091
+ focus: rangeDecoration.selection?.focus,
11092
+ payload: rangeDecoration.payload
11078
11093
  }));
11079
11094
  return !isEqual(existingRangeDecorations, newRangeDecorations);
11080
11095
  },