@portabletext/editor 1.47.14 → 1.48.0
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/behavior.core.cjs +8 -9
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/editor-provider.cjs +171 -115
- package/lib/_chunks-cjs/editor-provider.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +8 -9
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/editor-provider.js +172 -116
- package/lib/_chunks-es/editor-provider.js.map +1 -1
- package/lib/behaviors/index.cjs +11 -11
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +11 -8
- package/lib/behaviors/index.d.ts +11 -8
- package/lib/behaviors/index.js +12 -12
- package/lib/behaviors/index.js.map +1 -1
- package/lib/index.cjs +4 -4
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +6 -4
- package/lib/index.d.ts +6 -4
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.cjs +7 -11
- package/lib/plugins/index.cjs.map +1 -1
- package/lib/plugins/index.d.cts +4 -3
- package/lib/plugins/index.d.ts +4 -3
- package/lib/plugins/index.js +8 -12
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.cts +4 -3
- package/lib/selectors/index.d.ts +4 -3
- package/lib/utils/index.d.cts +4 -3
- package/lib/utils/index.d.ts +4 -3
- package/package.json +3 -3
- package/src/behavior-actions/behavior.actions.ts +0 -9
- package/src/behaviors/behavior.core.dnd.ts +1 -1
- package/src/behaviors/behavior.default.ts +3 -3
- package/src/behaviors/behavior.emoji-picker.ts +7 -9
- package/src/behaviors/behavior.perform-event.ts +143 -76
- package/src/behaviors/behavior.types.action.ts +14 -11
- package/src/behaviors/index.ts +1 -1
- package/src/editor/components/Element.tsx +3 -5
- package/src/editor/editor-context.tsx +7 -0
- package/src/editor/editor-machine.ts +1 -0
- package/src/editor/editor-provider.tsx +1 -3
- package/src/editor/plugins/createWithUndoRedo.ts +8 -11
- package/src/editor/with-applying-behavior-actions.ts +9 -11
- package/src/internal-utils/global-scope.ts +19 -0
- package/src/internal-utils/globally-scoped-context.ts +39 -0
- package/src/plugins/plugin.decorator-shortcut.ts +3 -2
- package/src/plugins/plugin.one-line.tsx +3 -3
- package/src/behavior-actions/behavior.action.noop.ts +0 -5
|
@@ -5,7 +5,7 @@ import { withReact, ReactEditor, Slate } from "slate-react";
|
|
|
5
5
|
import { c } from "react-compiler-runtime";
|
|
6
6
|
import debug$g from "debug";
|
|
7
7
|
import isEqual from "lodash/isEqual.js";
|
|
8
|
-
import { Element, Text, Editor,
|
|
8
|
+
import { Element, Text, Editor, Operation, Transforms, Path, 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 { isPortableTextTextBlock, isKeySegment, isPortableTextSpan as isPortableTextSpan$1, isPortableTextListBlock, defineType, defineField } from "@sanity/types";
|
|
@@ -1336,19 +1336,19 @@ function getCurrentActionId(editor) {
|
|
|
1336
1336
|
function isApplyingBehaviorActions(editor) {
|
|
1337
1337
|
return getCurrentActionId(editor) !== void 0;
|
|
1338
1338
|
}
|
|
1339
|
-
const
|
|
1340
|
-
function
|
|
1341
|
-
const current =
|
|
1339
|
+
const CURRENT_UNDO_STEP = /* @__PURE__ */ new WeakMap();
|
|
1340
|
+
function withUndoStep(editor, fn) {
|
|
1341
|
+
const current = CURRENT_UNDO_STEP.get(editor);
|
|
1342
1342
|
if (current) {
|
|
1343
1343
|
fn();
|
|
1344
1344
|
return;
|
|
1345
1345
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
}), fn(),
|
|
1346
|
+
CURRENT_UNDO_STEP.set(editor, current ?? {
|
|
1347
|
+
undoStepId: defaultKeyGenerator()
|
|
1348
|
+
}), fn(), CURRENT_UNDO_STEP.set(editor, void 0);
|
|
1349
1349
|
}
|
|
1350
|
-
function
|
|
1351
|
-
return
|
|
1350
|
+
function getCurrentUndoStepId(editor) {
|
|
1351
|
+
return CURRENT_UNDO_STEP.get(editor)?.undoStepId;
|
|
1352
1352
|
}
|
|
1353
1353
|
const debug$f = debugWithName("plugin:withUndoRedo"), SAVING = /* @__PURE__ */ new WeakMap(), REMOTE_PATCHES = /* @__PURE__ */ new WeakMap(), UNDO_STEP_LIMIT = 1e3, isSaving = (editor) => {
|
|
1354
1354
|
const state = SAVING.get(editor);
|
|
@@ -1361,7 +1361,7 @@ function createWithUndoRedo(options) {
|
|
|
1361
1361
|
return (editor) => {
|
|
1362
1362
|
let previousSnapshot = fromSlateValue(editor.children, editorActor.getSnapshot().context.schema.block.name);
|
|
1363
1363
|
const remotePatches = getRemotePatches(editor);
|
|
1364
|
-
let
|
|
1364
|
+
let previousUndoStepId = getCurrentUndoStepId(editor);
|
|
1365
1365
|
options.subscriptions.push(() => {
|
|
1366
1366
|
debug$f("Subscribing to patches");
|
|
1367
1367
|
const sub = editorActor.on("patches", ({
|
|
@@ -1417,10 +1417,10 @@ function createWithUndoRedo(options) {
|
|
|
1417
1417
|
history
|
|
1418
1418
|
} = editor, {
|
|
1419
1419
|
undos
|
|
1420
|
-
} = history, step = undos[undos.length - 1], lastOp = step && step.operations && step.operations[step.operations.length - 1], overwrite = shouldOverwrite(op, lastOp), save = isSaving(editor),
|
|
1421
|
-
let merge =
|
|
1420
|
+
} = history, step = undos[undos.length - 1], lastOp = step && step.operations && step.operations[step.operations.length - 1], overwrite = shouldOverwrite(op, lastOp), save = isSaving(editor), currentUndoStepId = getCurrentUndoStepId(editor);
|
|
1421
|
+
let merge = currentUndoStepId !== void 0 && previousUndoStepId === void 0 ? !1 : currentUndoStepId !== void 0 && previousUndoStepId !== void 0 ? currentUndoStepId === previousUndoStepId : !0;
|
|
1422
1422
|
if (save) {
|
|
1423
|
-
if (step ? operations.length === 0 && (merge =
|
|
1423
|
+
if (step ? operations.length === 0 && (merge = currentUndoStepId === void 0 && previousUndoStepId === void 0 ? shouldMerge(op, lastOp) || overwrite : merge) : merge = !1, step && merge)
|
|
1424
1424
|
step.operations.push(op);
|
|
1425
1425
|
else {
|
|
1426
1426
|
const newStep = {
|
|
@@ -1433,7 +1433,7 @@ function createWithUndoRedo(options) {
|
|
|
1433
1433
|
undos.shift();
|
|
1434
1434
|
shouldClear(op) && (history.redos = []);
|
|
1435
1435
|
}
|
|
1436
|
-
|
|
1436
|
+
previousUndoStepId = currentUndoStepId, apply2(op);
|
|
1437
1437
|
}, editor;
|
|
1438
1438
|
};
|
|
1439
1439
|
}
|
|
@@ -4037,7 +4037,6 @@ const moveBackwardActionImplementation = ({
|
|
|
4037
4037
|
unit: "character",
|
|
4038
4038
|
distance: action.distance
|
|
4039
4039
|
});
|
|
4040
|
-
}, noopActionImplementation = () => {
|
|
4041
4040
|
}, selectActionImplementation = ({
|
|
4042
4041
|
action
|
|
4043
4042
|
}) => {
|
|
@@ -4064,7 +4063,6 @@ const moveBackwardActionImplementation = ({
|
|
|
4064
4063
|
"move.backward": moveBackwardActionImplementation,
|
|
4065
4064
|
"move.block": moveBlockActionImplementation,
|
|
4066
4065
|
"move.forward": moveForwardActionImplementation,
|
|
4067
|
-
noop: noopActionImplementation,
|
|
4068
4066
|
select: selectActionImplementation
|
|
4069
4067
|
};
|
|
4070
4068
|
function performAction({
|
|
@@ -4212,8 +4210,6 @@ function performAction({
|
|
|
4212
4210
|
});
|
|
4213
4211
|
break;
|
|
4214
4212
|
}
|
|
4215
|
-
case "noop":
|
|
4216
|
-
break;
|
|
4217
4213
|
default: {
|
|
4218
4214
|
behaviorActionImplementations.select({
|
|
4219
4215
|
context,
|
|
@@ -5798,7 +5794,20 @@ function createInternalEditor(editorActor) {
|
|
|
5798
5794
|
}
|
|
5799
5795
|
};
|
|
5800
5796
|
}
|
|
5801
|
-
const EditorActorContext = createContext({})
|
|
5797
|
+
const EditorActorContext = createContext({});
|
|
5798
|
+
function getGlobalScope() {
|
|
5799
|
+
if (typeof globalThis < "u") return globalThis;
|
|
5800
|
+
if (typeof window < "u") return window;
|
|
5801
|
+
if (typeof self < "u") return self;
|
|
5802
|
+
if (typeof global < "u") return global;
|
|
5803
|
+
throw new Error("@portabletext/editor: could not locate global scope");
|
|
5804
|
+
}
|
|
5805
|
+
const globalScope = getGlobalScope();
|
|
5806
|
+
function createGloballyScopedContext(key, defaultValue) {
|
|
5807
|
+
const symbol = Symbol.for(key);
|
|
5808
|
+
return typeof document > "u" ? createContext(defaultValue) : (globalScope[symbol] = globalScope[symbol] ?? createContext(defaultValue), globalScope[symbol]);
|
|
5809
|
+
}
|
|
5810
|
+
const EditorContext = createGloballyScopedContext("@portabletext/editor/context/editor", null), abstractAnnotationBehaviors = [defineBehavior({
|
|
5802
5811
|
on: "annotation.toggle",
|
|
5803
5812
|
guard: ({
|
|
5804
5813
|
snapshot,
|
|
@@ -6380,9 +6389,7 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
6380
6389
|
const focusSpan = getFocusSpan(snapshot), selectionCollapsed = isSelectionCollapsed(snapshot);
|
|
6381
6390
|
return focusSpan && selectionCollapsed;
|
|
6382
6391
|
},
|
|
6383
|
-
actions: [
|
|
6384
|
-
type: "noop"
|
|
6385
|
-
}]]
|
|
6392
|
+
actions: []
|
|
6386
6393
|
}),
|
|
6387
6394
|
defineBehavior({
|
|
6388
6395
|
on: "clipboard.copy",
|
|
@@ -6401,9 +6408,7 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
6401
6408
|
const focusSpan = getFocusSpan(snapshot), selectionCollapsed = isSelectionCollapsed(snapshot);
|
|
6402
6409
|
return focusSpan && selectionCollapsed;
|
|
6403
6410
|
},
|
|
6404
|
-
actions: [
|
|
6405
|
-
type: "noop"
|
|
6406
|
-
}]]
|
|
6411
|
+
actions: []
|
|
6407
6412
|
}),
|
|
6408
6413
|
defineBehavior({
|
|
6409
6414
|
on: "clipboard.cut",
|
|
@@ -6470,9 +6475,7 @@ const EditorActorContext = createContext({}), abstractAnnotationBehaviors = [def
|
|
|
6470
6475
|
}
|
|
6471
6476
|
}) : !1;
|
|
6472
6477
|
},
|
|
6473
|
-
actions: [
|
|
6474
|
-
type: "noop"
|
|
6475
|
-
}]]
|
|
6478
|
+
actions: []
|
|
6476
6479
|
}),
|
|
6477
6480
|
defineBehavior({
|
|
6478
6481
|
on: "drag.drop",
|
|
@@ -6678,6 +6681,7 @@ function eventCategory(event) {
|
|
|
6678
6681
|
function performEvent({
|
|
6679
6682
|
mode,
|
|
6680
6683
|
behaviors,
|
|
6684
|
+
remainingEventBehaviors,
|
|
6681
6685
|
event,
|
|
6682
6686
|
editor,
|
|
6683
6687
|
keyGenerator,
|
|
@@ -6685,11 +6689,11 @@ function performEvent({
|
|
|
6685
6689
|
getSnapshot,
|
|
6686
6690
|
nativeEvent
|
|
6687
6691
|
}) {
|
|
6688
|
-
debug$2(`(${
|
|
6692
|
+
debug$2(`(${mode}:${eventCategory(event)})`, JSON.stringify(event, null, 2));
|
|
6689
6693
|
const defaultAction = isCustomBehaviorEvent(event) || isNativeBehaviorEvent(event) || isAbstractBehaviorEvent(event) ? void 0 : {
|
|
6690
6694
|
...event,
|
|
6691
6695
|
editor
|
|
6692
|
-
}, eventBehaviors =
|
|
6696
|
+
}, eventBehaviors = [...remainingEventBehaviors, ...defaultBehaviors].filter((behavior) => {
|
|
6693
6697
|
if (behavior.on === "*")
|
|
6694
6698
|
return !0;
|
|
6695
6699
|
const [listenedNamespace] = behavior.on.includes("*") && behavior.on.includes(".") ? behavior.on.split(".") : [void 0], [eventNamespace] = event.type.includes(".") ? event.type.split(".") : [void 0];
|
|
@@ -6714,115 +6718,167 @@ function performEvent({
|
|
|
6714
6718
|
return;
|
|
6715
6719
|
}
|
|
6716
6720
|
const guardSnapshot = getSnapshot();
|
|
6717
|
-
let
|
|
6721
|
+
let nativeEventPrevented = !1, defaultBehaviorOverwritten = !1, eventBehaviorIndex = -1;
|
|
6718
6722
|
for (const eventBehavior of eventBehaviors) {
|
|
6723
|
+
eventBehaviorIndex++;
|
|
6719
6724
|
const shouldRun = eventBehavior.guard === void 0 || eventBehavior.guard({
|
|
6720
6725
|
snapshot: guardSnapshot,
|
|
6721
6726
|
event
|
|
6722
6727
|
});
|
|
6723
6728
|
if (shouldRun) {
|
|
6729
|
+
defaultBehaviorOverwritten = !0;
|
|
6724
6730
|
for (const actionSet of eventBehavior.actions) {
|
|
6725
6731
|
const actionsSnapshot = getSnapshot(), actions = actionSet({
|
|
6726
6732
|
snapshot: actionsSnapshot,
|
|
6727
6733
|
event
|
|
6728
6734
|
}, shouldRun);
|
|
6729
|
-
actions.length !== 0
|
|
6735
|
+
if (actions.length !== 0) {
|
|
6736
|
+
if (actions.some((action) => action.type === "execute")) {
|
|
6737
|
+
nativeEventPrevented = !0, withUndoStep(editor, () => {
|
|
6738
|
+
for (const action of actions) {
|
|
6739
|
+
if (action.type === "effect") {
|
|
6740
|
+
performAction({
|
|
6741
|
+
context: {
|
|
6742
|
+
keyGenerator,
|
|
6743
|
+
schema
|
|
6744
|
+
},
|
|
6745
|
+
action: {
|
|
6746
|
+
...action,
|
|
6747
|
+
editor
|
|
6748
|
+
}
|
|
6749
|
+
});
|
|
6750
|
+
continue;
|
|
6751
|
+
}
|
|
6752
|
+
if (action.type === "forward") {
|
|
6753
|
+
const remainingEventBehaviors2 = eventBehaviors.slice(eventBehaviorIndex + 1);
|
|
6754
|
+
performEvent({
|
|
6755
|
+
mode: "forward",
|
|
6756
|
+
behaviors,
|
|
6757
|
+
remainingEventBehaviors: remainingEventBehaviors2,
|
|
6758
|
+
event: action.event,
|
|
6759
|
+
editor,
|
|
6760
|
+
keyGenerator,
|
|
6761
|
+
schema,
|
|
6762
|
+
getSnapshot,
|
|
6763
|
+
nativeEvent
|
|
6764
|
+
});
|
|
6765
|
+
continue;
|
|
6766
|
+
}
|
|
6767
|
+
if (action.type === "raise") {
|
|
6768
|
+
performEvent({
|
|
6769
|
+
mode: "raise",
|
|
6770
|
+
behaviors,
|
|
6771
|
+
remainingEventBehaviors: behaviors,
|
|
6772
|
+
event: action.event,
|
|
6773
|
+
editor,
|
|
6774
|
+
keyGenerator,
|
|
6775
|
+
schema,
|
|
6776
|
+
getSnapshot,
|
|
6777
|
+
nativeEvent
|
|
6778
|
+
});
|
|
6779
|
+
continue;
|
|
6780
|
+
}
|
|
6781
|
+
if (isAbstractBehaviorEvent(action.event))
|
|
6782
|
+
performEvent({
|
|
6783
|
+
mode: "execute",
|
|
6784
|
+
behaviors,
|
|
6785
|
+
remainingEventBehaviors: behaviors,
|
|
6786
|
+
event: action.event,
|
|
6787
|
+
editor,
|
|
6788
|
+
keyGenerator,
|
|
6789
|
+
schema,
|
|
6790
|
+
getSnapshot,
|
|
6791
|
+
nativeEvent: void 0
|
|
6792
|
+
});
|
|
6793
|
+
else {
|
|
6794
|
+
const internalAction = {
|
|
6795
|
+
...action.event,
|
|
6796
|
+
editor
|
|
6797
|
+
};
|
|
6798
|
+
let actionFailed = !1;
|
|
6799
|
+
if (withApplyingBehaviorActions(editor, () => {
|
|
6800
|
+
try {
|
|
6801
|
+
performAction({
|
|
6802
|
+
context: {
|
|
6803
|
+
keyGenerator,
|
|
6804
|
+
schema
|
|
6805
|
+
},
|
|
6806
|
+
action: internalAction
|
|
6807
|
+
});
|
|
6808
|
+
} catch (error) {
|
|
6809
|
+
console.error(new Error(`Performing action "${action.event.type}" as a result of "${event.type}" failed due to: ${error.message}`)), actionFailed = !0;
|
|
6810
|
+
}
|
|
6811
|
+
}), actionFailed)
|
|
6812
|
+
break;
|
|
6813
|
+
editor.onChange();
|
|
6814
|
+
}
|
|
6815
|
+
}
|
|
6816
|
+
});
|
|
6817
|
+
continue;
|
|
6818
|
+
}
|
|
6730
6819
|
for (const action of actions) {
|
|
6731
|
-
if (action.type === "
|
|
6820
|
+
if (action.type === "effect") {
|
|
6821
|
+
performAction({
|
|
6822
|
+
context: {
|
|
6823
|
+
keyGenerator,
|
|
6824
|
+
schema
|
|
6825
|
+
},
|
|
6826
|
+
action: {
|
|
6827
|
+
...action,
|
|
6828
|
+
editor
|
|
6829
|
+
}
|
|
6830
|
+
});
|
|
6831
|
+
continue;
|
|
6832
|
+
}
|
|
6833
|
+
if (action.type === "forward") {
|
|
6834
|
+
const remainingEventBehaviors2 = eventBehaviors.slice(eventBehaviorIndex + 1);
|
|
6732
6835
|
performEvent({
|
|
6733
|
-
mode,
|
|
6734
|
-
behaviors
|
|
6836
|
+
mode: "forward",
|
|
6837
|
+
behaviors,
|
|
6838
|
+
remainingEventBehaviors: remainingEventBehaviors2,
|
|
6735
6839
|
event: action.event,
|
|
6736
6840
|
editor,
|
|
6737
6841
|
keyGenerator,
|
|
6738
6842
|
schema,
|
|
6739
6843
|
getSnapshot,
|
|
6740
|
-
nativeEvent
|
|
6844
|
+
nativeEvent
|
|
6741
6845
|
});
|
|
6742
6846
|
continue;
|
|
6743
6847
|
}
|
|
6744
|
-
if (action.type === "
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
else {
|
|
6757
|
-
const internalAction2 = {
|
|
6758
|
-
...action.event,
|
|
6759
|
-
editor
|
|
6760
|
-
};
|
|
6761
|
-
let actionFailed2 = !1;
|
|
6762
|
-
if (withApplyingBehaviorActions(editor, () => {
|
|
6763
|
-
try {
|
|
6764
|
-
performAction({
|
|
6765
|
-
context: {
|
|
6766
|
-
keyGenerator,
|
|
6767
|
-
schema
|
|
6768
|
-
},
|
|
6769
|
-
action: internalAction2
|
|
6770
|
-
});
|
|
6771
|
-
} catch (error) {
|
|
6772
|
-
console.error(new Error(`Performing action "${action.event.type}" as a result of "${event.type}" failed due to: ${error.message}`)), actionFailed2 = !0;
|
|
6773
|
-
}
|
|
6774
|
-
}), actionFailed2)
|
|
6775
|
-
break;
|
|
6776
|
-
editor.onChange();
|
|
6777
|
-
}
|
|
6848
|
+
if (action.type === "raise") {
|
|
6849
|
+
nativeEventPrevented = !0, performEvent({
|
|
6850
|
+
mode: "raise",
|
|
6851
|
+
behaviors,
|
|
6852
|
+
remainingEventBehaviors: behaviors,
|
|
6853
|
+
event: action.event,
|
|
6854
|
+
editor,
|
|
6855
|
+
keyGenerator,
|
|
6856
|
+
schema,
|
|
6857
|
+
getSnapshot,
|
|
6858
|
+
nativeEvent
|
|
6859
|
+
});
|
|
6778
6860
|
continue;
|
|
6779
6861
|
}
|
|
6780
|
-
|
|
6781
|
-
...action,
|
|
6782
|
-
editor
|
|
6783
|
-
};
|
|
6784
|
-
let actionFailed = !1;
|
|
6785
|
-
if (withApplyingBehaviorActions(editor, () => {
|
|
6786
|
-
try {
|
|
6787
|
-
performAction({
|
|
6788
|
-
context: {
|
|
6789
|
-
keyGenerator,
|
|
6790
|
-
schema
|
|
6791
|
-
},
|
|
6792
|
-
action: internalAction
|
|
6793
|
-
});
|
|
6794
|
-
} catch (error) {
|
|
6795
|
-
console.error(new Error(`Performing action "${internalAction.type}" as a result of "${event.type}" failed due to: ${error.message}`)), actionFailed = !0;
|
|
6796
|
-
}
|
|
6797
|
-
}), actionFailed)
|
|
6798
|
-
break;
|
|
6799
|
-
editor.onChange();
|
|
6862
|
+
action.type === "execute" && console.error("Unexpected action type: `execute`");
|
|
6800
6863
|
}
|
|
6801
|
-
}
|
|
6802
|
-
}
|
|
6803
|
-
if (behaviorOverwritten) {
|
|
6804
|
-
nativeEvent?.preventDefault();
|
|
6805
|
-
break;
|
|
6864
|
+
}
|
|
6806
6865
|
}
|
|
6866
|
+
break;
|
|
6807
6867
|
}
|
|
6808
6868
|
}
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
console.error(new Error(`Performing action "${defaultAction.type}" as a result of "${event.type}" failed due to: ${error.message}`));
|
|
6823
|
-
}
|
|
6824
|
-
}), editor.onChange();
|
|
6825
|
-
}
|
|
6869
|
+
!defaultBehaviorOverwritten && defaultAction ? (nativeEvent?.preventDefault(), withApplyingBehaviorActions(editor, () => {
|
|
6870
|
+
try {
|
|
6871
|
+
performAction({
|
|
6872
|
+
context: {
|
|
6873
|
+
keyGenerator,
|
|
6874
|
+
schema
|
|
6875
|
+
},
|
|
6876
|
+
action: defaultAction
|
|
6877
|
+
});
|
|
6878
|
+
} catch (error) {
|
|
6879
|
+
console.error(new Error(`Performing action "${defaultAction.type}" as a result of "${event.type}" failed due to: ${error.message}`));
|
|
6880
|
+
}
|
|
6881
|
+
}), editor.onChange()) : nativeEventPrevented && nativeEvent?.preventDefault();
|
|
6826
6882
|
}
|
|
6827
6883
|
function createEditorSnapshot({
|
|
6828
6884
|
converters,
|
|
@@ -6955,11 +7011,12 @@ const editorMachine = setup({
|
|
|
6955
7011
|
"handle behavior event": ({
|
|
6956
7012
|
context,
|
|
6957
7013
|
event,
|
|
6958
|
-
self
|
|
7014
|
+
self: self2
|
|
6959
7015
|
}) => {
|
|
6960
7016
|
assertEvent(event, ["behavior event"]), performEvent({
|
|
6961
7017
|
mode: "raise",
|
|
6962
7018
|
behaviors: [...context.behaviors.values()],
|
|
7019
|
+
remainingEventBehaviors: [...context.behaviors.values()],
|
|
6963
7020
|
event: event.behaviorEvent,
|
|
6964
7021
|
editor: event.editor,
|
|
6965
7022
|
keyGenerator: context.keyGenerator,
|
|
@@ -6968,11 +7025,11 @@ const editorMachine = setup({
|
|
|
6968
7025
|
converters: [...context.converters],
|
|
6969
7026
|
editor: event.editor,
|
|
6970
7027
|
keyGenerator: context.keyGenerator,
|
|
6971
|
-
readOnly:
|
|
7028
|
+
readOnly: self2.getSnapshot().matches({
|
|
6972
7029
|
"edit mode": "read only"
|
|
6973
7030
|
}),
|
|
6974
7031
|
schema: context.schema,
|
|
6975
|
-
hasTag: (tag) =>
|
|
7032
|
+
hasTag: (tag) => self2.getSnapshot().hasTag(tag),
|
|
6976
7033
|
internalDrag: context.internalDrag
|
|
6977
7034
|
}),
|
|
6978
7035
|
nativeEvent: event.nativeEvent
|
|
@@ -7849,7 +7906,6 @@ function RouteEventsToChanges(props) {
|
|
|
7849
7906
|
let t2;
|
|
7850
7907
|
return $[5] !== props.editorActor ? (t2 = [props.editorActor], $[5] = props.editorActor, $[6] = t2) : t2 = $[6], useEffect(t1, t2), null;
|
|
7851
7908
|
}
|
|
7852
|
-
const EditorContext = React.createContext(void 0);
|
|
7853
7909
|
function EditorProvider(props) {
|
|
7854
7910
|
const editorActor = useActorRef(editorMachine, {
|
|
7855
7911
|
input: editorConfigToMachineInput(props.initialConfig)
|