@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.js CHANGED
@@ -8716,7 +8716,15 @@ const abstractAnnotationBehaviors = [defineBehavior({
8716
8716
  marks: [...event.decorators ?? [], ...markDefs.map((markDef) => markDef._key)]
8717
8717
  }
8718
8718
  })]]
8719
- })], abstractKeyboardBehaviors = [
8719
+ })], shiftLeft = createKeyboardShortcut({
8720
+ default: [{
8721
+ key: "ArrowLeft",
8722
+ shift: !0,
8723
+ meta: !1,
8724
+ ctrl: !1,
8725
+ alt: !1
8726
+ }]
8727
+ }), abstractKeyboardBehaviors = [
8720
8728
  /**
8721
8729
  * Allow raising an `insert.break` event when pressing Enter on an inline
8722
8730
  * object.
@@ -8768,6 +8776,58 @@ const abstractAnnotationBehaviors = [defineBehavior({
8768
8776
  actions: [() => [raise({
8769
8777
  type: "history.redo"
8770
8778
  })]]
8779
+ }),
8780
+ /**
8781
+ * Fix edge case where Shift+ArrowLeft didn't reduce a selection hanging
8782
+ * onto an empty text block.
8783
+ */
8784
+ defineBehavior({
8785
+ on: "keyboard.keydown",
8786
+ guard: ({
8787
+ snapshot,
8788
+ event
8789
+ }) => {
8790
+ if (!snapshot.context.selection || !shiftLeft.guard(event.originEvent))
8791
+ return !1;
8792
+ const focusBlock = getFocusBlock$1(snapshot);
8793
+ if (!focusBlock)
8794
+ return !1;
8795
+ const previousBlock = getPreviousBlock({
8796
+ ...snapshot,
8797
+ context: {
8798
+ ...snapshot.context,
8799
+ selection: {
8800
+ anchor: {
8801
+ path: focusBlock.path,
8802
+ offset: 0
8803
+ },
8804
+ focus: {
8805
+ path: focusBlock.path,
8806
+ offset: 0
8807
+ }
8808
+ }
8809
+ }
8810
+ });
8811
+ return previousBlock && isTextBlock(snapshot.context, focusBlock.node) && snapshot.context.selection.focus.offset === 0 && isEmptyTextBlock(snapshot.context, focusBlock.node) ? {
8812
+ previousBlock,
8813
+ selection: snapshot.context.selection
8814
+ } : !1;
8815
+ },
8816
+ actions: [({
8817
+ snapshot
8818
+ }, {
8819
+ previousBlock,
8820
+ selection
8821
+ }) => [raise({
8822
+ type: "select",
8823
+ at: {
8824
+ anchor: selection.anchor,
8825
+ focus: getBlockEndPoint({
8826
+ context: snapshot.context,
8827
+ block: previousBlock
8828
+ })
8829
+ }
8830
+ })]]
8771
8831
  })
8772
8832
  ], abstractListItemBehaviors = [defineBehavior({
8773
8833
  on: "list item.add",
@@ -9429,7 +9489,7 @@ function performEvent({
9429
9489
  console.error(new Error(`Evaluating guard for "${event.type}" failed due to: ${error.message}`));
9430
9490
  }
9431
9491
  if (shouldRun) {
9432
- defaultBehaviorOverwritten = !0;
9492
+ defaultBehaviorOverwritten = !0, eventBehavior.actions.length === 0 && (nativeEventPrevented = !0);
9433
9493
  for (const actionSet of eventBehavior.actions) {
9434
9494
  const actionsSnapshot = getSnapshot();
9435
9495
  let actions = [];