@portabletext/editor 1.48.11 → 1.48.13

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.
@@ -3770,10 +3770,6 @@ const decoratorAddActionImplementation = ({
3770
3770
  action
3771
3771
  }) => {
3772
3772
  action.editor.deleteForward(action.unit);
3773
- }, effectActionImplementation = ({
3774
- action
3775
- }) => {
3776
- action.effect();
3777
3773
  }, insertInlineObjectActionImplementation = ({
3778
3774
  context,
3779
3775
  action
@@ -4063,7 +4059,6 @@ const moveBackwardActionImplementation = ({
4063
4059
  "insert.inline object": insertInlineObjectActionImplementation,
4064
4060
  "insert.span": insertSpanActionImplementation,
4065
4061
  "insert.text": insertTextActionImplementation,
4066
- effect: effectActionImplementation,
4067
4062
  "move.backward": moveBackwardActionImplementation,
4068
4063
  "move.block": moveBlockActionImplementation,
4069
4064
  "move.forward": moveForwardActionImplementation,
@@ -4144,13 +4139,6 @@ function performAction({
4144
4139
  });
4145
4140
  break;
4146
4141
  }
4147
- case "effect": {
4148
- behaviorActionImplementations.effect({
4149
- context,
4150
- action
4151
- });
4152
- break;
4153
- }
4154
4142
  case "history.redo": {
4155
4143
  behaviorActionImplementations["history.redo"]({
4156
4144
  context,
@@ -7406,32 +7394,39 @@ function performEvent({
7406
7394
  let nativeEventPrevented = !1, defaultBehaviorOverwritten = !1, eventBehaviorIndex = -1;
7407
7395
  for (const eventBehavior of eventBehaviors) {
7408
7396
  eventBehaviorIndex++;
7409
- const shouldRun = eventBehavior.guard === void 0 || eventBehavior.guard({
7410
- snapshot: guardSnapshot,
7411
- event
7412
- });
7397
+ let shouldRun = !1;
7398
+ try {
7399
+ shouldRun = eventBehavior.guard === void 0 || eventBehavior.guard({
7400
+ snapshot: guardSnapshot,
7401
+ event
7402
+ });
7403
+ } catch (error) {
7404
+ console.error(new Error(`Evaluating guard for "${event.type}" failed due to: ${error.message}`));
7405
+ }
7413
7406
  if (shouldRun) {
7414
7407
  defaultBehaviorOverwritten = !0;
7415
7408
  for (const actionSet of eventBehavior.actions) {
7416
- const actionsSnapshot = getSnapshot(), actions = actionSet({
7417
- snapshot: actionsSnapshot,
7418
- event
7419
- }, shouldRun);
7409
+ const actionsSnapshot = getSnapshot();
7410
+ let actions = [];
7411
+ try {
7412
+ actions = actionSet({
7413
+ snapshot: actionsSnapshot,
7414
+ event
7415
+ }, shouldRun);
7416
+ } catch (error) {
7417
+ console.error(new Error(`Evaluating actions for "${event.type}" failed due to: ${error.message}`));
7418
+ }
7420
7419
  if (actions.length !== 0) {
7421
7420
  if (actions.some((action) => action.type === "execute")) {
7422
7421
  withUndoStep(editor, () => {
7423
7422
  for (const action of actions) {
7424
7423
  if (action.type === "effect") {
7425
- nativeEventPrevented = !0, performAction({
7426
- context: {
7427
- keyGenerator,
7428
- schema: schema2
7429
- },
7430
- action: {
7431
- ...action,
7432
- editor
7433
- }
7434
- });
7424
+ nativeEventPrevented = !0;
7425
+ try {
7426
+ action.effect();
7427
+ } catch (error) {
7428
+ console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
7429
+ }
7435
7430
  continue;
7436
7431
  }
7437
7432
  if (action.type === "forward") {
@@ -7480,16 +7475,12 @@ function performEvent({
7480
7475
  }
7481
7476
  for (const action of actions) {
7482
7477
  if (action.type === "effect") {
7483
- nativeEventPrevented = !0, performAction({
7484
- context: {
7485
- keyGenerator,
7486
- schema: schema2
7487
- },
7488
- action: {
7489
- ...action,
7490
- editor
7491
- }
7492
- });
7478
+ nativeEventPrevented = !0;
7479
+ try {
7480
+ action.effect();
7481
+ } catch (error) {
7482
+ console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
7483
+ }
7493
7484
  continue;
7494
7485
  }
7495
7486
  if (action.type === "forward") {
@@ -7689,27 +7680,32 @@ const editorMachine = xstate.setup({
7689
7680
  event,
7690
7681
  self: self2
7691
7682
  }) => {
7692
- xstate.assertEvent(event, ["behavior event"]), performEvent({
7693
- mode: "raise",
7694
- behaviors: [...context.behaviors.values()],
7695
- remainingEventBehaviors: [...context.behaviors.values()],
7696
- event: event.behaviorEvent,
7697
- editor: event.editor,
7698
- keyGenerator: context.keyGenerator,
7699
- schema: context.schema,
7700
- getSnapshot: () => createEditorSnapshot({
7701
- converters: [...context.converters],
7683
+ xstate.assertEvent(event, ["behavior event"]);
7684
+ try {
7685
+ performEvent({
7686
+ mode: "raise",
7687
+ behaviors: [...context.behaviors.values()],
7688
+ remainingEventBehaviors: [...context.behaviors.values()],
7689
+ event: event.behaviorEvent,
7702
7690
  editor: event.editor,
7703
7691
  keyGenerator: context.keyGenerator,
7704
- readOnly: self2.getSnapshot().matches({
7705
- "edit mode": "read only"
7706
- }),
7707
7692
  schema: context.schema,
7708
- hasTag: (tag) => self2.getSnapshot().hasTag(tag),
7709
- internalDrag: context.internalDrag
7710
- }),
7711
- nativeEvent: event.nativeEvent
7712
- });
7693
+ getSnapshot: () => createEditorSnapshot({
7694
+ converters: [...context.converters],
7695
+ editor: event.editor,
7696
+ keyGenerator: context.keyGenerator,
7697
+ readOnly: self2.getSnapshot().matches({
7698
+ "edit mode": "read only"
7699
+ }),
7700
+ schema: context.schema,
7701
+ hasTag: (tag) => self2.getSnapshot().hasTag(tag),
7702
+ internalDrag: context.internalDrag
7703
+ }),
7704
+ nativeEvent: event.nativeEvent
7705
+ });
7706
+ } catch (error) {
7707
+ console.error(new Error(`Raising "${event.behaviorEvent.type}" failed due to: ${error.message}`));
7708
+ }
7713
7709
  }
7714
7710
  },
7715
7711
  guards: {