@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.
- package/lib/_chunks-cjs/editor-provider.cjs +54 -58
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/editor-provider.js +55 -59
- 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 +54 -34
- 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,
|
|
@@ -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
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
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()
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
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
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
}
|
|
7430
|
-
|
|
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
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
}
|
|
7488
|
-
|
|
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"])
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
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
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
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: {
|