@portabletext/editor 2.12.0 → 2.12.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 CHANGED
@@ -8687,7 +8687,15 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8687
8687
  marks: [...event.decorators ?? [], ...markDefs.map((markDef) => markDef._key)]
8688
8688
  }
8689
8689
  })]]
8690
- })], abstractKeyboardBehaviors = [
8690
+ })], shiftLeft = keyboardShortcuts.createKeyboardShortcut({
8691
+ default: [{
8692
+ key: "ArrowLeft",
8693
+ shift: !0,
8694
+ meta: !1,
8695
+ ctrl: !1,
8696
+ alt: !1
8697
+ }]
8698
+ }), abstractKeyboardBehaviors = [
8691
8699
  /**
8692
8700
  * Allow raising an `insert.break` event when pressing Enter on an inline
8693
8701
  * object.
@@ -8739,6 +8747,58 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
8739
8747
  actions: [() => [behaviors_index.raise({
8740
8748
  type: "history.redo"
8741
8749
  })]]
8750
+ }),
8751
+ /**
8752
+ * Fix edge case where Shift+ArrowLeft didn't reduce a selection hanging
8753
+ * onto an empty text block.
8754
+ */
8755
+ behaviors_index.defineBehavior({
8756
+ on: "keyboard.keydown",
8757
+ guard: ({
8758
+ snapshot,
8759
+ event
8760
+ }) => {
8761
+ if (!snapshot.context.selection || !shiftLeft.guard(event.originEvent))
8762
+ return !1;
8763
+ const focusBlock = selector_isSelectionExpanded.getFocusBlock(snapshot);
8764
+ if (!focusBlock)
8765
+ return !1;
8766
+ const previousBlock = selector_isSelectingEntireBlocks.getPreviousBlock({
8767
+ ...snapshot,
8768
+ context: {
8769
+ ...snapshot.context,
8770
+ selection: {
8771
+ anchor: {
8772
+ path: focusBlock.path,
8773
+ offset: 0
8774
+ },
8775
+ focus: {
8776
+ path: focusBlock.path,
8777
+ offset: 0
8778
+ }
8779
+ }
8780
+ }
8781
+ });
8782
+ return previousBlock && schema.isTextBlock(snapshot.context, focusBlock.node) && snapshot.context.selection.focus.offset === 0 && util_isSelectionCollapsed.isEmptyTextBlock(snapshot.context, focusBlock.node) ? {
8783
+ previousBlock,
8784
+ selection: snapshot.context.selection
8785
+ } : !1;
8786
+ },
8787
+ actions: [({
8788
+ snapshot
8789
+ }, {
8790
+ previousBlock,
8791
+ selection
8792
+ }) => [behaviors_index.raise({
8793
+ type: "select",
8794
+ at: {
8795
+ anchor: selection.anchor,
8796
+ focus: util_isSelectionCollapsed.getBlockEndPoint({
8797
+ context: snapshot.context,
8798
+ block: previousBlock
8799
+ })
8800
+ }
8801
+ })]]
8742
8802
  })
8743
8803
  ], abstractListItemBehaviors = [behaviors_index.defineBehavior({
8744
8804
  on: "list item.add",
@@ -9400,7 +9460,7 @@ function performEvent({
9400
9460
  console.error(new Error(`Evaluating guard for "${event.type}" failed due to: ${error.message}`));
9401
9461
  }
9402
9462
  if (shouldRun) {
9403
- defaultBehaviorOverwritten = !0;
9463
+ defaultBehaviorOverwritten = !0, eventBehavior.actions.length === 0 && (nativeEventPrevented = !0);
9404
9464
  for (const actionSet of eventBehavior.actions) {
9405
9465
  const actionsSnapshot = getSnapshot();
9406
9466
  let actions = [];