@portabletext/editor 1.48.12 → 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.
- package/lib/_chunks-cjs/editor-provider.cjs +45 -54
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +46 -55
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.js.map +1 -1
- package/package.json +6 -6
- package/src/behavior-actions/behavior.actions.ts +0 -9
- package/src/behaviors/behavior.perform-event.ts +38 -28
- package/src/behaviors/behavior.types.action.ts +5 -4
- package/src/editor/editor-machine.ts +28 -20
- package/src/behavior-actions/behavior.action.effect.ts +0 -7
|
@@ -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,
|
|
@@ -7418,25 +7406,27 @@ function performEvent({
|
|
|
7418
7406
|
if (shouldRun) {
|
|
7419
7407
|
defaultBehaviorOverwritten = !0;
|
|
7420
7408
|
for (const actionSet of eventBehavior.actions) {
|
|
7421
|
-
const actionsSnapshot = getSnapshot()
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
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
|
+
}
|
|
7425
7419
|
if (actions.length !== 0) {
|
|
7426
7420
|
if (actions.some((action) => action.type === "execute")) {
|
|
7427
7421
|
withUndoStep(editor, () => {
|
|
7428
7422
|
for (const action of actions) {
|
|
7429
7423
|
if (action.type === "effect") {
|
|
7430
|
-
nativeEventPrevented = !0
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
}
|
|
7435
|
-
|
|
7436
|
-
...action,
|
|
7437
|
-
editor
|
|
7438
|
-
}
|
|
7439
|
-
});
|
|
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
|
+
}
|
|
7440
7430
|
continue;
|
|
7441
7431
|
}
|
|
7442
7432
|
if (action.type === "forward") {
|
|
@@ -7485,16 +7475,12 @@ function performEvent({
|
|
|
7485
7475
|
}
|
|
7486
7476
|
for (const action of actions) {
|
|
7487
7477
|
if (action.type === "effect") {
|
|
7488
|
-
nativeEventPrevented = !0
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
}
|
|
7493
|
-
|
|
7494
|
-
...action,
|
|
7495
|
-
editor
|
|
7496
|
-
}
|
|
7497
|
-
});
|
|
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
|
+
}
|
|
7498
7484
|
continue;
|
|
7499
7485
|
}
|
|
7500
7486
|
if (action.type === "forward") {
|
|
@@ -7694,27 +7680,32 @@ const editorMachine = xstate.setup({
|
|
|
7694
7680
|
event,
|
|
7695
7681
|
self: self2
|
|
7696
7682
|
}) => {
|
|
7697
|
-
xstate.assertEvent(event, ["behavior event"])
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
schema: context.schema,
|
|
7705
|
-
getSnapshot: () => createEditorSnapshot({
|
|
7706
|
-
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,
|
|
7707
7690
|
editor: event.editor,
|
|
7708
7691
|
keyGenerator: context.keyGenerator,
|
|
7709
|
-
readOnly: self2.getSnapshot().matches({
|
|
7710
|
-
"edit mode": "read only"
|
|
7711
|
-
}),
|
|
7712
7692
|
schema: context.schema,
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
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
|
+
}
|
|
7718
7709
|
}
|
|
7719
7710
|
},
|
|
7720
7711
|
guards: {
|