@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
|
@@ -5,7 +5,7 @@ import { withReact, ReactEditor, Slate } from "slate-react";
|
|
|
5
5
|
import { c } from "react-compiler-runtime";
|
|
6
6
|
import debug$f from "debug";
|
|
7
7
|
import isEqual from "lodash/isEqual.js";
|
|
8
|
-
import { Element, Text, Editor, Operation, Transforms,
|
|
8
|
+
import { Element, Text, Editor, Path, Operation, Transforms, Node, Range, Point, createEditor } from "slate";
|
|
9
9
|
import { setup, stateIn, fromCallback, assign, enqueueActions, emit, assertEvent, and, not, createActor } from "xstate";
|
|
10
10
|
import { unset, set, setIfMissing, insert, diffMatchPatch as diffMatchPatch$1, applyAll } from "@portabletext/patches";
|
|
11
11
|
import flatten from "lodash/flatten.js";
|
|
@@ -3794,10 +3794,6 @@ const decoratorAddActionImplementation = ({
|
|
|
3794
3794
|
action
|
|
3795
3795
|
}) => {
|
|
3796
3796
|
action.editor.deleteForward(action.unit);
|
|
3797
|
-
}, effectActionImplementation = ({
|
|
3798
|
-
action
|
|
3799
|
-
}) => {
|
|
3800
|
-
action.effect();
|
|
3801
3797
|
}, insertInlineObjectActionImplementation = ({
|
|
3802
3798
|
context,
|
|
3803
3799
|
action
|
|
@@ -4087,7 +4083,6 @@ const moveBackwardActionImplementation = ({
|
|
|
4087
4083
|
"insert.inline object": insertInlineObjectActionImplementation,
|
|
4088
4084
|
"insert.span": insertSpanActionImplementation,
|
|
4089
4085
|
"insert.text": insertTextActionImplementation,
|
|
4090
|
-
effect: effectActionImplementation,
|
|
4091
4086
|
"move.backward": moveBackwardActionImplementation,
|
|
4092
4087
|
"move.block": moveBlockActionImplementation,
|
|
4093
4088
|
"move.forward": moveForwardActionImplementation,
|
|
@@ -4168,13 +4163,6 @@ function performAction({
|
|
|
4168
4163
|
});
|
|
4169
4164
|
break;
|
|
4170
4165
|
}
|
|
4171
|
-
case "effect": {
|
|
4172
|
-
behaviorActionImplementations.effect({
|
|
4173
|
-
context,
|
|
4174
|
-
action
|
|
4175
|
-
});
|
|
4176
|
-
break;
|
|
4177
|
-
}
|
|
4178
4166
|
case "history.redo": {
|
|
4179
4167
|
behaviorActionImplementations["history.redo"]({
|
|
4180
4168
|
context,
|
|
@@ -7442,25 +7430,27 @@ function performEvent({
|
|
|
7442
7430
|
if (shouldRun) {
|
|
7443
7431
|
defaultBehaviorOverwritten = !0;
|
|
7444
7432
|
for (const actionSet of eventBehavior.actions) {
|
|
7445
|
-
const actionsSnapshot = getSnapshot()
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7433
|
+
const actionsSnapshot = getSnapshot();
|
|
7434
|
+
let actions = [];
|
|
7435
|
+
try {
|
|
7436
|
+
actions = actionSet({
|
|
7437
|
+
snapshot: actionsSnapshot,
|
|
7438
|
+
event
|
|
7439
|
+
}, shouldRun);
|
|
7440
|
+
} catch (error) {
|
|
7441
|
+
console.error(new Error(`Evaluating actions for "${event.type}" failed due to: ${error.message}`));
|
|
7442
|
+
}
|
|
7449
7443
|
if (actions.length !== 0) {
|
|
7450
7444
|
if (actions.some((action) => action.type === "execute")) {
|
|
7451
7445
|
withUndoStep(editor, () => {
|
|
7452
7446
|
for (const action of actions) {
|
|
7453
7447
|
if (action.type === "effect") {
|
|
7454
|
-
nativeEventPrevented = !0
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
}
|
|
7459
|
-
|
|
7460
|
-
...action,
|
|
7461
|
-
editor
|
|
7462
|
-
}
|
|
7463
|
-
});
|
|
7448
|
+
nativeEventPrevented = !0;
|
|
7449
|
+
try {
|
|
7450
|
+
action.effect();
|
|
7451
|
+
} catch (error) {
|
|
7452
|
+
console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
|
|
7453
|
+
}
|
|
7464
7454
|
continue;
|
|
7465
7455
|
}
|
|
7466
7456
|
if (action.type === "forward") {
|
|
@@ -7509,16 +7499,12 @@ function performEvent({
|
|
|
7509
7499
|
}
|
|
7510
7500
|
for (const action of actions) {
|
|
7511
7501
|
if (action.type === "effect") {
|
|
7512
|
-
nativeEventPrevented = !0
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
}
|
|
7517
|
-
|
|
7518
|
-
...action,
|
|
7519
|
-
editor
|
|
7520
|
-
}
|
|
7521
|
-
});
|
|
7502
|
+
nativeEventPrevented = !0;
|
|
7503
|
+
try {
|
|
7504
|
+
action.effect();
|
|
7505
|
+
} catch (error) {
|
|
7506
|
+
console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
|
|
7507
|
+
}
|
|
7522
7508
|
continue;
|
|
7523
7509
|
}
|
|
7524
7510
|
if (action.type === "forward") {
|
|
@@ -7718,27 +7704,32 @@ const editorMachine = setup({
|
|
|
7718
7704
|
event,
|
|
7719
7705
|
self: self2
|
|
7720
7706
|
}) => {
|
|
7721
|
-
assertEvent(event, ["behavior event"])
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
schema: context.schema,
|
|
7729
|
-
getSnapshot: () => createEditorSnapshot({
|
|
7730
|
-
converters: [...context.converters],
|
|
7707
|
+
assertEvent(event, ["behavior event"]);
|
|
7708
|
+
try {
|
|
7709
|
+
performEvent({
|
|
7710
|
+
mode: "raise",
|
|
7711
|
+
behaviors: [...context.behaviors.values()],
|
|
7712
|
+
remainingEventBehaviors: [...context.behaviors.values()],
|
|
7713
|
+
event: event.behaviorEvent,
|
|
7731
7714
|
editor: event.editor,
|
|
7732
7715
|
keyGenerator: context.keyGenerator,
|
|
7733
|
-
readOnly: self2.getSnapshot().matches({
|
|
7734
|
-
"edit mode": "read only"
|
|
7735
|
-
}),
|
|
7736
7716
|
schema: context.schema,
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7717
|
+
getSnapshot: () => createEditorSnapshot({
|
|
7718
|
+
converters: [...context.converters],
|
|
7719
|
+
editor: event.editor,
|
|
7720
|
+
keyGenerator: context.keyGenerator,
|
|
7721
|
+
readOnly: self2.getSnapshot().matches({
|
|
7722
|
+
"edit mode": "read only"
|
|
7723
|
+
}),
|
|
7724
|
+
schema: context.schema,
|
|
7725
|
+
hasTag: (tag) => self2.getSnapshot().hasTag(tag),
|
|
7726
|
+
internalDrag: context.internalDrag
|
|
7727
|
+
}),
|
|
7728
|
+
nativeEvent: event.nativeEvent
|
|
7729
|
+
});
|
|
7730
|
+
} catch (error) {
|
|
7731
|
+
console.error(new Error(`Raising "${event.behaviorEvent.type}" failed due to: ${error.message}`));
|
|
7732
|
+
}
|
|
7742
7733
|
}
|
|
7743
7734
|
},
|
|
7744
7735
|
guards: {
|