@portabletext/editor 2.9.1 → 2.10.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/selector.is-selecting-entire-blocks.cjs +9 -1
- package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs +1 -0
- package/lib/_chunks-cjs/util.merge-text-blocks.cjs.map +1 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs +6 -1
- package/lib/_chunks-cjs/util.slice-blocks.cjs.map +1 -1
- package/lib/_chunks-dts/behavior.types.action.d.cts +141 -131
- package/lib/_chunks-dts/behavior.types.action.d.ts +71 -61
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +9 -1
- package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +1 -0
- package/lib/_chunks-es/util.merge-text-blocks.js.map +1 -1
- package/lib/_chunks-es/util.slice-blocks.js +6 -1
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.cjs +419 -309
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +422 -312
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.ts +2 -2
- package/package.json +8 -8
- package/src/behaviors/behavior.abstract.insert.ts +109 -24
- package/src/behaviors/behavior.abstract.split.ts +1 -0
- package/src/behaviors/behavior.perform-event.ts +84 -118
- package/src/behaviors/behavior.types.event.ts +9 -1
- package/src/converters/converter.portable-text.ts +1 -0
- package/src/converters/converter.text-html.ts +1 -0
- package/src/converters/converter.text-plain.ts +1 -0
- package/src/editor/Editable.tsx +1 -0
- package/src/editor/editor-selector.ts +10 -1
- package/src/editor/plugins/create-with-event-listeners.ts +13 -14
- package/src/editor/sync-machine.ts +9 -0
- package/src/editor/with-performing-behavior-operation.ts +21 -0
- package/src/editor/without-normalizing-conditional.ts +13 -0
- package/src/internal-utils/parse-blocks.test.ts +14 -14
- package/src/internal-utils/parse-blocks.ts +9 -2
- package/src/internal-utils/slate-utils.test.tsx +119 -0
- package/src/internal-utils/slate-utils.ts +14 -1
- package/src/internal-utils/text-marks.ts +1 -1
- package/src/internal-utils/values.ts +1 -55
- package/src/operations/behavior.operation.block.set.ts +18 -36
- package/src/operations/behavior.operation.block.unset.ts +8 -2
- package/src/operations/behavior.operation.insert.block.ts +4 -1
- package/src/operations/behavior.operation.insert.child.ts +95 -0
- package/src/operations/behavior.operations.ts +140 -128
- package/src/selectors/selector.get-mark-state.ts +19 -5
- package/src/selectors/selector.get-trimmed-selection.test.ts +1 -0
- package/src/types/block-with-optional-key.ts +13 -1
- package/src/utils/util.merge-text-blocks.ts +1 -1
- package/src/utils/util.slice-blocks.ts +3 -3
- package/src/utils/util.slice-text-block.test.ts +54 -28
- package/src/editor/with-applying-behavior-operations.ts +0 -18
package/lib/index.cjs
CHANGED
|
@@ -156,7 +156,14 @@ function getFocusSpan({
|
|
|
156
156
|
if (!editor.selection)
|
|
157
157
|
return [void 0, void 0];
|
|
158
158
|
try {
|
|
159
|
-
const [
|
|
159
|
+
const [focusBlock] = getFocusBlock({
|
|
160
|
+
editor
|
|
161
|
+
});
|
|
162
|
+
if (!focusBlock)
|
|
163
|
+
return [void 0, void 0];
|
|
164
|
+
if (!editor.isTextBlock(focusBlock))
|
|
165
|
+
return [void 0, void 0];
|
|
166
|
+
const [node, path] = slate.Editor.node(editor, editor.selection.focus.path.slice(0, 2));
|
|
160
167
|
if (editor.isTextSpan(node))
|
|
161
168
|
return [node, path];
|
|
162
169
|
} catch {
|
|
@@ -1082,6 +1089,11 @@ function getEditorSnapshot({
|
|
|
1082
1089
|
editorActorSnapshot,
|
|
1083
1090
|
slateEditorInstance
|
|
1084
1091
|
}) {
|
|
1092
|
+
const selection = slateEditorInstance.selection ? slateRangeToSelection({
|
|
1093
|
+
schema: editorActorSnapshot.context.schema,
|
|
1094
|
+
editor: slateEditorInstance,
|
|
1095
|
+
range: slateEditorInstance.selection
|
|
1096
|
+
}) : null;
|
|
1085
1097
|
return {
|
|
1086
1098
|
blockIndexMap: slateEditorInstance.blockIndexMap,
|
|
1087
1099
|
context: {
|
|
@@ -1091,7 +1103,7 @@ function getEditorSnapshot({
|
|
|
1091
1103
|
"edit mode": "read only"
|
|
1092
1104
|
}),
|
|
1093
1105
|
schema: editorActorSnapshot.context.schema,
|
|
1094
|
-
selection
|
|
1106
|
+
selection,
|
|
1095
1107
|
value: slateEditorInstance.value
|
|
1096
1108
|
},
|
|
1097
1109
|
decoratorState: slateEditorInstance.decoratorState
|
|
@@ -1919,6 +1931,7 @@ const RelayActorContext = React.createContext({}), debug$d = debugWithName("comp
|
|
|
1919
1931
|
},
|
|
1920
1932
|
blocks: result_1.insert,
|
|
1921
1933
|
options: {
|
|
1934
|
+
removeUnusedMarkDefs: !0,
|
|
1922
1935
|
validateFields: !1
|
|
1923
1936
|
}
|
|
1924
1937
|
}),
|
|
@@ -2387,6 +2400,7 @@ const converterJson = {
|
|
|
2387
2400
|
context: snapshot.context,
|
|
2388
2401
|
block,
|
|
2389
2402
|
options: {
|
|
2403
|
+
removeUnusedMarkDefs: !0,
|
|
2390
2404
|
validateFields: !1
|
|
2391
2405
|
}
|
|
2392
2406
|
});
|
|
@@ -2449,6 +2463,7 @@ function createConverterTextHtml(legacySchema) {
|
|
|
2449
2463
|
context: snapshot.context,
|
|
2450
2464
|
block,
|
|
2451
2465
|
options: {
|
|
2466
|
+
removeUnusedMarkDefs: !0,
|
|
2452
2467
|
validateFields: !1
|
|
2453
2468
|
}
|
|
2454
2469
|
});
|
|
@@ -2496,6 +2511,7 @@ function createConverterTextPlain(legacySchema) {
|
|
|
2496
2511
|
context: snapshot.context,
|
|
2497
2512
|
block,
|
|
2498
2513
|
options: {
|
|
2514
|
+
removeUnusedMarkDefs: !0,
|
|
2499
2515
|
validateFields: !1
|
|
2500
2516
|
}
|
|
2501
2517
|
});
|
|
@@ -2601,46 +2617,6 @@ function createPlaceholderBlock(context) {
|
|
|
2601
2617
|
}]
|
|
2602
2618
|
};
|
|
2603
2619
|
}
|
|
2604
|
-
const insertTextOperationImplementation = ({
|
|
2605
|
-
context,
|
|
2606
|
-
operation
|
|
2607
|
-
}) => {
|
|
2608
|
-
const snapshot = {
|
|
2609
|
-
blockIndexMap: operation.editor.blockIndexMap,
|
|
2610
|
-
context: {
|
|
2611
|
-
value: operation.editor.value,
|
|
2612
|
-
selection: operation.editor.selection ? slateRangeToSelection({
|
|
2613
|
-
schema: context.schema,
|
|
2614
|
-
editor: operation.editor,
|
|
2615
|
-
range: operation.editor.selection
|
|
2616
|
-
}) : null,
|
|
2617
|
-
schema: context.schema,
|
|
2618
|
-
keyGenerator: context.keyGenerator,
|
|
2619
|
-
converters: [],
|
|
2620
|
-
readOnly: !1
|
|
2621
|
-
},
|
|
2622
|
-
decoratorState: operation.editor.decoratorState
|
|
2623
|
-
}, markState = selector_isSelectingEntireBlocks.getMarkState(snapshot), activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot), activeAnnotations = selector_isSelectingEntireBlocks.getActiveAnnotationsMarks(snapshot), [focusSpan] = getFocusSpan({
|
|
2624
|
-
editor: operation.editor
|
|
2625
|
-
});
|
|
2626
|
-
if (!focusSpan) {
|
|
2627
|
-
slate.Transforms.insertText(operation.editor, operation.text);
|
|
2628
|
-
return;
|
|
2629
|
-
}
|
|
2630
|
-
if (markState && markState.state === "unchanged") {
|
|
2631
|
-
const markStateDecorators = (markState.marks ?? []).filter((mark) => context.schema.decorators.map((decorator) => decorator.name).includes(mark));
|
|
2632
|
-
if (markStateDecorators.length === activeDecorators.length && markStateDecorators.every((mark) => activeDecorators.includes(mark))) {
|
|
2633
|
-
slate.Transforms.insertText(operation.editor, operation.text);
|
|
2634
|
-
return;
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
|
-
slate.Transforms.insertNodes(operation.editor, {
|
|
2638
|
-
_type: focusSpan._type,
|
|
2639
|
-
_key: context.keyGenerator(),
|
|
2640
|
-
text: operation.text,
|
|
2641
|
-
marks: [...activeDecorators, ...activeAnnotations]
|
|
2642
|
-
}), slateDom.EDITOR_TO_PENDING_SELECTION.set(operation.editor, operation.editor.selection), operation.editor.decoratorState = {};
|
|
2643
|
-
};
|
|
2644
2620
|
function getPreviousSpan({
|
|
2645
2621
|
editor,
|
|
2646
2622
|
blockPath,
|
|
@@ -4067,55 +4043,35 @@ const addAnnotationOperationImplementation = ({
|
|
|
4067
4043
|
context,
|
|
4068
4044
|
operation
|
|
4069
4045
|
}) => {
|
|
4070
|
-
const
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
selection: {
|
|
4075
|
-
anchor: {
|
|
4076
|
-
path: operation.at,
|
|
4077
|
-
offset: 0
|
|
4078
|
-
},
|
|
4079
|
-
focus: {
|
|
4080
|
-
path: operation.at,
|
|
4081
|
-
offset: 0
|
|
4082
|
-
}
|
|
4083
|
-
}
|
|
4084
|
-
},
|
|
4085
|
-
blockIndexMap: operation.editor.blockIndexMap
|
|
4086
|
-
});
|
|
4087
|
-
if (!location)
|
|
4088
|
-
throw new Error(`Unable to convert ${JSON.stringify(operation.at)} into a Slate Range`);
|
|
4089
|
-
const block = slate.Editor.node(operation.editor, location, {
|
|
4090
|
-
depth: 1
|
|
4091
|
-
})?.[0];
|
|
4046
|
+
const blockIndex = operation.editor.blockIndexMap.get(operation.at[0]._key);
|
|
4047
|
+
if (blockIndex === void 0)
|
|
4048
|
+
throw new Error(`Unable to find block index for block at ${JSON.stringify(operation.at)}`);
|
|
4049
|
+
const block = operation.editor.value.at(blockIndex);
|
|
4092
4050
|
if (!block)
|
|
4093
4051
|
throw new Error(`Unable to find block at ${JSON.stringify(operation.at)}`);
|
|
4094
|
-
const parsedBlock = fromSlateValue([block], context.schema.block.name, KEY_TO_VALUE_ELEMENT.get(operation.editor)).at(0);
|
|
4095
|
-
if (!parsedBlock)
|
|
4096
|
-
throw new Error(`Unable to parse block at ${JSON.stringify(operation.at)}`);
|
|
4097
4052
|
const {
|
|
4098
4053
|
_type,
|
|
4099
4054
|
...filteredProps
|
|
4100
|
-
} = operation.props, updatedBlock =
|
|
4055
|
+
} = operation.props, updatedBlock = {
|
|
4056
|
+
...block,
|
|
4057
|
+
...filteredProps
|
|
4058
|
+
}, parsedBlock = util_sliceBlocks.parseBlock({
|
|
4101
4059
|
context,
|
|
4102
|
-
block:
|
|
4103
|
-
...parsedBlock,
|
|
4104
|
-
...filteredProps
|
|
4105
|
-
},
|
|
4060
|
+
block: updatedBlock,
|
|
4106
4061
|
options: {
|
|
4062
|
+
removeUnusedMarkDefs: !1,
|
|
4107
4063
|
validateFields: !0
|
|
4108
4064
|
}
|
|
4109
4065
|
});
|
|
4110
|
-
if (!
|
|
4066
|
+
if (!parsedBlock)
|
|
4111
4067
|
throw new Error(`Unable to update block at ${JSON.stringify(operation.at)}`);
|
|
4112
|
-
const slateBlock = toSlateValue([
|
|
4068
|
+
const slateBlock = toSlateValue([parsedBlock], {
|
|
4113
4069
|
schemaTypes: context.schema
|
|
4114
4070
|
})?.at(0);
|
|
4115
4071
|
if (!slateBlock)
|
|
4116
4072
|
throw new Error("Unable to convert block to Slate value");
|
|
4117
4073
|
slate.Transforms.setNodes(operation.editor, slateBlock, {
|
|
4118
|
-
at:
|
|
4074
|
+
at: [blockIndex]
|
|
4119
4075
|
});
|
|
4120
4076
|
}, blockUnsetOperationImplementation = ({
|
|
4121
4077
|
context,
|
|
@@ -4153,6 +4109,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
4153
4109
|
context,
|
|
4154
4110
|
block: omit__default.default(parsedBlock, propsToRemove),
|
|
4155
4111
|
options: {
|
|
4112
|
+
removeUnusedMarkDefs: !0,
|
|
4156
4113
|
validateFields: !0
|
|
4157
4114
|
}
|
|
4158
4115
|
});
|
|
@@ -4170,6 +4127,7 @@ const addAnnotationOperationImplementation = ({
|
|
|
4170
4127
|
context,
|
|
4171
4128
|
block: omit__default.default(parsedBlock, operation.props.filter((prop) => prop !== "_type")),
|
|
4172
4129
|
options: {
|
|
4130
|
+
removeUnusedMarkDefs: !0,
|
|
4173
4131
|
validateFields: !0
|
|
4174
4132
|
}
|
|
4175
4133
|
});
|
|
@@ -4558,6 +4516,7 @@ const insertBlockOperationImplementation = ({
|
|
|
4558
4516
|
block: operation.block,
|
|
4559
4517
|
context,
|
|
4560
4518
|
options: {
|
|
4519
|
+
removeUnusedMarkDefs: !0,
|
|
4561
4520
|
validateFields: !0
|
|
4562
4521
|
}
|
|
4563
4522
|
});
|
|
@@ -4768,7 +4727,115 @@ function insertBlock({
|
|
|
4768
4727
|
}
|
|
4769
4728
|
}
|
|
4770
4729
|
}
|
|
4771
|
-
const
|
|
4730
|
+
const insertChildOperationImplementation = ({
|
|
4731
|
+
context,
|
|
4732
|
+
operation
|
|
4733
|
+
}) => {
|
|
4734
|
+
const focus = operation.editor.selection?.focus, focusBlockIndex = focus?.path.at(0), focusChildIndex = focus?.path.at(1);
|
|
4735
|
+
if (focusBlockIndex === void 0 || focusChildIndex === void 0)
|
|
4736
|
+
throw new Error("Unable to insert child without a focus");
|
|
4737
|
+
const [focusBlock, focusBlockPath] = getFocusBlock({
|
|
4738
|
+
editor: operation.editor
|
|
4739
|
+
});
|
|
4740
|
+
if (!focus || !focusBlock || !focusBlockPath)
|
|
4741
|
+
throw new Error("Unable to insert child without a focus block");
|
|
4742
|
+
if (!schema.isTextBlock(context, focusBlock))
|
|
4743
|
+
throw new Error("Unable to insert child into a non-text block");
|
|
4744
|
+
const markDefs = focusBlock.markDefs ?? [], markDefKeyMap = /* @__PURE__ */ new Map();
|
|
4745
|
+
for (const markDef of markDefs)
|
|
4746
|
+
markDefKeyMap.set(markDef._key, markDef._key);
|
|
4747
|
+
const span = util_sliceBlocks.parseSpan({
|
|
4748
|
+
span: operation.child,
|
|
4749
|
+
context,
|
|
4750
|
+
markDefKeyMap,
|
|
4751
|
+
options: {
|
|
4752
|
+
validateFields: !0
|
|
4753
|
+
}
|
|
4754
|
+
});
|
|
4755
|
+
if (span) {
|
|
4756
|
+
const [focusSpan] = getFocusSpan({
|
|
4757
|
+
editor: operation.editor
|
|
4758
|
+
});
|
|
4759
|
+
focusSpan ? slate.Transforms.insertNodes(operation.editor, span, {
|
|
4760
|
+
at: focus,
|
|
4761
|
+
select: !0
|
|
4762
|
+
}) : slate.Transforms.insertNodes(operation.editor, span, {
|
|
4763
|
+
at: [focusBlockIndex, focusChildIndex + 1],
|
|
4764
|
+
select: !0
|
|
4765
|
+
});
|
|
4766
|
+
return;
|
|
4767
|
+
}
|
|
4768
|
+
const inlineObject = util_sliceBlocks.parseInlineObject({
|
|
4769
|
+
inlineObject: operation.child,
|
|
4770
|
+
context,
|
|
4771
|
+
options: {
|
|
4772
|
+
validateFields: !0
|
|
4773
|
+
}
|
|
4774
|
+
});
|
|
4775
|
+
if (inlineObject) {
|
|
4776
|
+
const {
|
|
4777
|
+
_key,
|
|
4778
|
+
_type,
|
|
4779
|
+
...rest
|
|
4780
|
+
} = inlineObject;
|
|
4781
|
+
slate.Transforms.insertNodes(operation.editor, {
|
|
4782
|
+
_key,
|
|
4783
|
+
_type,
|
|
4784
|
+
children: [{
|
|
4785
|
+
_key: VOID_CHILD_KEY,
|
|
4786
|
+
_type: "span",
|
|
4787
|
+
text: "",
|
|
4788
|
+
marks: []
|
|
4789
|
+
}],
|
|
4790
|
+
value: rest,
|
|
4791
|
+
__inline: !0
|
|
4792
|
+
}, {
|
|
4793
|
+
at: [focusBlockIndex, focusChildIndex + 1],
|
|
4794
|
+
select: !0
|
|
4795
|
+
});
|
|
4796
|
+
return;
|
|
4797
|
+
}
|
|
4798
|
+
throw new Error("Unable to parse child");
|
|
4799
|
+
}, insertTextOperationImplementation = ({
|
|
4800
|
+
context,
|
|
4801
|
+
operation
|
|
4802
|
+
}) => {
|
|
4803
|
+
const snapshot = {
|
|
4804
|
+
blockIndexMap: operation.editor.blockIndexMap,
|
|
4805
|
+
context: {
|
|
4806
|
+
value: operation.editor.value,
|
|
4807
|
+
selection: operation.editor.selection ? slateRangeToSelection({
|
|
4808
|
+
schema: context.schema,
|
|
4809
|
+
editor: operation.editor,
|
|
4810
|
+
range: operation.editor.selection
|
|
4811
|
+
}) : null,
|
|
4812
|
+
schema: context.schema,
|
|
4813
|
+
keyGenerator: context.keyGenerator,
|
|
4814
|
+
converters: [],
|
|
4815
|
+
readOnly: !1
|
|
4816
|
+
},
|
|
4817
|
+
decoratorState: operation.editor.decoratorState
|
|
4818
|
+
}, markState = selector_isSelectingEntireBlocks.getMarkState(snapshot), activeDecorators = selector_isSelectingEntireBlocks.getActiveDecorators(snapshot), activeAnnotations = selector_isSelectingEntireBlocks.getActiveAnnotationsMarks(snapshot), [focusSpan] = getFocusSpan({
|
|
4819
|
+
editor: operation.editor
|
|
4820
|
+
});
|
|
4821
|
+
if (!focusSpan) {
|
|
4822
|
+
slate.Transforms.insertText(operation.editor, operation.text);
|
|
4823
|
+
return;
|
|
4824
|
+
}
|
|
4825
|
+
if (markState && markState.state === "unchanged") {
|
|
4826
|
+
const markStateDecorators = (markState.marks ?? []).filter((mark) => context.schema.decorators.map((decorator) => decorator.name).includes(mark));
|
|
4827
|
+
if (markStateDecorators.length === activeDecorators.length && markStateDecorators.every((mark) => activeDecorators.includes(mark))) {
|
|
4828
|
+
slate.Transforms.insertText(operation.editor, operation.text);
|
|
4829
|
+
return;
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
slate.Transforms.insertNodes(operation.editor, {
|
|
4833
|
+
_type: focusSpan._type,
|
|
4834
|
+
_key: context.keyGenerator(),
|
|
4835
|
+
text: operation.text,
|
|
4836
|
+
marks: [...activeDecorators, ...activeAnnotations]
|
|
4837
|
+
}), slateDom.EDITOR_TO_PENDING_SELECTION.set(operation.editor, operation.editor.selection), operation.editor.decoratorState = {};
|
|
4838
|
+
}, moveBackwardOperationImplementation = ({
|
|
4772
4839
|
operation
|
|
4773
4840
|
}) => {
|
|
4774
4841
|
slate.Transforms.move(operation.editor, {
|
|
@@ -4833,6 +4900,7 @@ const moveBackwardOperationImplementation = ({
|
|
|
4833
4900
|
"history.redo": historyRedoOperationImplementation,
|
|
4834
4901
|
"history.undo": historyUndoOperationImplementation,
|
|
4835
4902
|
"insert.block": insertBlockOperationImplementation,
|
|
4903
|
+
"insert.child": insertChildOperationImplementation,
|
|
4836
4904
|
"insert.text": insertTextOperationImplementation,
|
|
4837
4905
|
"move.backward": moveBackwardOperationImplementation,
|
|
4838
4906
|
"move.block": moveBlockOperationImplementation,
|
|
@@ -4843,141 +4911,148 @@ function performOperation({
|
|
|
4843
4911
|
context,
|
|
4844
4912
|
operation
|
|
4845
4913
|
}) {
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4914
|
+
slate.Editor.withoutNormalizing(operation.editor, () => {
|
|
4915
|
+
try {
|
|
4916
|
+
switch (operation.type) {
|
|
4917
|
+
case "annotation.add": {
|
|
4918
|
+
behaviorOperationImplementations["annotation.add"]({
|
|
4919
|
+
context,
|
|
4920
|
+
operation
|
|
4921
|
+
});
|
|
4922
|
+
break;
|
|
4923
|
+
}
|
|
4924
|
+
case "annotation.remove": {
|
|
4925
|
+
behaviorOperationImplementations["annotation.remove"]({
|
|
4926
|
+
context,
|
|
4927
|
+
operation
|
|
4928
|
+
});
|
|
4929
|
+
break;
|
|
4930
|
+
}
|
|
4931
|
+
case "block.set": {
|
|
4932
|
+
behaviorOperationImplementations["block.set"]({
|
|
4933
|
+
context,
|
|
4934
|
+
operation
|
|
4935
|
+
});
|
|
4936
|
+
break;
|
|
4937
|
+
}
|
|
4938
|
+
case "block.unset": {
|
|
4939
|
+
behaviorOperationImplementations["block.unset"]({
|
|
4940
|
+
context,
|
|
4941
|
+
operation
|
|
4942
|
+
});
|
|
4943
|
+
break;
|
|
4944
|
+
}
|
|
4945
|
+
case "child.set": {
|
|
4946
|
+
behaviorOperationImplementations["child.set"]({
|
|
4947
|
+
context,
|
|
4948
|
+
operation
|
|
4949
|
+
});
|
|
4950
|
+
break;
|
|
4951
|
+
}
|
|
4952
|
+
case "child.unset": {
|
|
4953
|
+
behaviorOperationImplementations["child.unset"]({
|
|
4954
|
+
context,
|
|
4955
|
+
operation
|
|
4956
|
+
});
|
|
4957
|
+
break;
|
|
4958
|
+
}
|
|
4959
|
+
case "decorator.add": {
|
|
4960
|
+
behaviorOperationImplementations["decorator.add"]({
|
|
4961
|
+
context,
|
|
4962
|
+
operation
|
|
4963
|
+
});
|
|
4964
|
+
break;
|
|
4965
|
+
}
|
|
4966
|
+
case "decorator.remove": {
|
|
4967
|
+
behaviorOperationImplementations["decorator.remove"]({
|
|
4968
|
+
context,
|
|
4969
|
+
operation
|
|
4970
|
+
});
|
|
4971
|
+
break;
|
|
4972
|
+
}
|
|
4973
|
+
case "delete": {
|
|
4974
|
+
behaviorOperationImplementations.delete({
|
|
4975
|
+
context,
|
|
4976
|
+
operation
|
|
4977
|
+
});
|
|
4978
|
+
break;
|
|
4979
|
+
}
|
|
4980
|
+
case "history.redo": {
|
|
4981
|
+
behaviorOperationImplementations["history.redo"]({
|
|
4982
|
+
context,
|
|
4983
|
+
operation
|
|
4984
|
+
});
|
|
4985
|
+
break;
|
|
4986
|
+
}
|
|
4987
|
+
case "history.undo": {
|
|
4988
|
+
behaviorOperationImplementations["history.undo"]({
|
|
4989
|
+
context,
|
|
4990
|
+
operation
|
|
4991
|
+
});
|
|
4992
|
+
break;
|
|
4993
|
+
}
|
|
4994
|
+
case "insert.block": {
|
|
4995
|
+
behaviorOperationImplementations["insert.block"]({
|
|
4996
|
+
context,
|
|
4997
|
+
operation
|
|
4998
|
+
});
|
|
4999
|
+
break;
|
|
5000
|
+
}
|
|
5001
|
+
case "insert.child": {
|
|
5002
|
+
behaviorOperationImplementations["insert.child"]({
|
|
5003
|
+
context,
|
|
5004
|
+
operation
|
|
5005
|
+
});
|
|
5006
|
+
break;
|
|
5007
|
+
}
|
|
5008
|
+
case "insert.text": {
|
|
5009
|
+
behaviorOperationImplementations["insert.text"]({
|
|
5010
|
+
context,
|
|
5011
|
+
operation
|
|
5012
|
+
});
|
|
5013
|
+
break;
|
|
5014
|
+
}
|
|
5015
|
+
case "move.backward": {
|
|
5016
|
+
behaviorOperationImplementations["move.backward"]({
|
|
5017
|
+
context,
|
|
5018
|
+
operation
|
|
5019
|
+
});
|
|
5020
|
+
break;
|
|
5021
|
+
}
|
|
5022
|
+
case "move.block": {
|
|
5023
|
+
behaviorOperationImplementations["move.block"]({
|
|
5024
|
+
context,
|
|
5025
|
+
operation
|
|
5026
|
+
});
|
|
5027
|
+
break;
|
|
5028
|
+
}
|
|
5029
|
+
case "move.forward": {
|
|
5030
|
+
behaviorOperationImplementations["move.forward"]({
|
|
5031
|
+
context,
|
|
5032
|
+
operation
|
|
5033
|
+
});
|
|
5034
|
+
break;
|
|
5035
|
+
}
|
|
5036
|
+
default: {
|
|
5037
|
+
behaviorOperationImplementations.select({
|
|
5038
|
+
context,
|
|
5039
|
+
operation
|
|
5040
|
+
});
|
|
5041
|
+
break;
|
|
5042
|
+
}
|
|
4966
5043
|
}
|
|
5044
|
+
} catch (error) {
|
|
5045
|
+
console.error(new Error(`Executing "${operation.type}" failed due to: ${error.message}`));
|
|
4967
5046
|
}
|
|
4968
|
-
}
|
|
4969
|
-
console.error(new Error(`Executing "${operation.type}" failed due to: ${error.message}`));
|
|
4970
|
-
}
|
|
4971
|
-
}
|
|
4972
|
-
const CURRENT_OPERATION_ID = /* @__PURE__ */ new WeakMap();
|
|
4973
|
-
function withApplyingBehaviorOperations(editor, fn) {
|
|
4974
|
-
CURRENT_OPERATION_ID.set(editor, util_sliceBlocks.defaultKeyGenerator()), slate.Editor.withoutNormalizing(editor, fn), CURRENT_OPERATION_ID.set(editor, void 0);
|
|
5047
|
+
});
|
|
4975
5048
|
}
|
|
4976
|
-
|
|
4977
|
-
|
|
5049
|
+
const IS_PERFORMING_OPERATION = /* @__PURE__ */ new WeakMap();
|
|
5050
|
+
function withPerformingBehaviorOperation(editor, fn) {
|
|
5051
|
+
const prev = IS_PERFORMING_OPERATION.get(editor);
|
|
5052
|
+
IS_PERFORMING_OPERATION.set(editor, !0), fn(), IS_PERFORMING_OPERATION.set(editor, prev);
|
|
4978
5053
|
}
|
|
4979
|
-
function
|
|
4980
|
-
return
|
|
5054
|
+
function isPerformingBehaviorOperation(editor) {
|
|
5055
|
+
return IS_PERFORMING_OPERATION.get(editor) ?? !1;
|
|
4981
5056
|
}
|
|
4982
5057
|
function createWithEventListeners(editorActor) {
|
|
4983
5058
|
return function(editor) {
|
|
@@ -4988,7 +5063,7 @@ function createWithEventListeners(editorActor) {
|
|
|
4988
5063
|
select
|
|
4989
5064
|
} = editor;
|
|
4990
5065
|
return editor.delete = (options) => {
|
|
4991
|
-
if (
|
|
5066
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
4992
5067
|
editorDelete(options);
|
|
4993
5068
|
return;
|
|
4994
5069
|
}
|
|
@@ -5017,7 +5092,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5017
5092
|
editor
|
|
5018
5093
|
});
|
|
5019
5094
|
}, editor.deleteBackward = (unit) => {
|
|
5020
|
-
if (
|
|
5095
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5021
5096
|
console.error("Unexpected call to .deleteBackward(...)");
|
|
5022
5097
|
return;
|
|
5023
5098
|
}
|
|
@@ -5030,7 +5105,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5030
5105
|
editor
|
|
5031
5106
|
});
|
|
5032
5107
|
}, editor.deleteForward = (unit) => {
|
|
5033
|
-
if (
|
|
5108
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5034
5109
|
console.error("Unexpected call to .deleteForward(...)");
|
|
5035
5110
|
return;
|
|
5036
5111
|
}
|
|
@@ -5043,7 +5118,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5043
5118
|
editor
|
|
5044
5119
|
});
|
|
5045
5120
|
}, editor.insertBreak = () => {
|
|
5046
|
-
if (
|
|
5121
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5047
5122
|
console.error("Unexpected call to .insertBreak(...)");
|
|
5048
5123
|
return;
|
|
5049
5124
|
}
|
|
@@ -5055,7 +5130,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5055
5130
|
editor
|
|
5056
5131
|
});
|
|
5057
5132
|
}, editor.insertData = (dataTransfer) => {
|
|
5058
|
-
if (
|
|
5133
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5059
5134
|
console.error("Unexpected call to .insertData(...)");
|
|
5060
5135
|
return;
|
|
5061
5136
|
}
|
|
@@ -5070,13 +5145,14 @@ function createWithEventListeners(editorActor) {
|
|
|
5070
5145
|
editor
|
|
5071
5146
|
});
|
|
5072
5147
|
}, editor.insertSoftBreak = () => {
|
|
5073
|
-
if (
|
|
5074
|
-
|
|
5148
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5149
|
+
performOperation({
|
|
5075
5150
|
context: {
|
|
5076
5151
|
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
|
|
5077
5152
|
schema: editorActor.getSnapshot().context.schema
|
|
5078
5153
|
},
|
|
5079
5154
|
operation: {
|
|
5155
|
+
type: "insert.text",
|
|
5080
5156
|
text: `
|
|
5081
5157
|
`,
|
|
5082
5158
|
editor
|
|
@@ -5092,13 +5168,14 @@ function createWithEventListeners(editorActor) {
|
|
|
5092
5168
|
editor
|
|
5093
5169
|
});
|
|
5094
5170
|
}, editor.insertText = (text) => {
|
|
5095
|
-
if (
|
|
5096
|
-
|
|
5171
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5172
|
+
performOperation({
|
|
5097
5173
|
context: {
|
|
5098
5174
|
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
|
|
5099
5175
|
schema: editorActor.getSnapshot().context.schema
|
|
5100
5176
|
},
|
|
5101
5177
|
operation: {
|
|
5178
|
+
type: "insert.text",
|
|
5102
5179
|
text,
|
|
5103
5180
|
editor
|
|
5104
5181
|
}
|
|
@@ -5114,7 +5191,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5114
5191
|
editor
|
|
5115
5192
|
});
|
|
5116
5193
|
}, editor.redo = () => {
|
|
5117
|
-
if (
|
|
5194
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5118
5195
|
performOperation({
|
|
5119
5196
|
context: {
|
|
5120
5197
|
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
|
|
@@ -5135,7 +5212,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5135
5212
|
editor
|
|
5136
5213
|
});
|
|
5137
5214
|
}, editor.select = (location) => {
|
|
5138
|
-
if (
|
|
5215
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5139
5216
|
select(location);
|
|
5140
5217
|
return;
|
|
5141
5218
|
}
|
|
@@ -5155,7 +5232,7 @@ function createWithEventListeners(editorActor) {
|
|
|
5155
5232
|
}, editor.setFragmentData = () => {
|
|
5156
5233
|
console.error("Unexpected call to .setFragmentData(...)");
|
|
5157
5234
|
}, editor.undo = () => {
|
|
5158
|
-
if (
|
|
5235
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5159
5236
|
performOperation({
|
|
5160
5237
|
context: {
|
|
5161
5238
|
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
|
|
@@ -7705,7 +7782,11 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
7705
7782
|
}, coreBehaviorsConfig = [...coreAnnotationBehaviors, coreDecoratorBehaviors.strongShortcut, coreDecoratorBehaviors.emShortcut, coreDecoratorBehaviors.underlineShortcut, coreDecoratorBehaviors.codeShortcut, ...coreDndBehaviors, coreBlockObjectBehaviors.clickingAboveLonelyBlockObject, coreBlockObjectBehaviors.clickingBelowLonelyBlockObject, coreBlockObjectBehaviors.arrowDownOnLonelyBlockObject, coreBlockObjectBehaviors.arrowUpOnLonelyBlockObject, coreBlockObjectBehaviors.breakingBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockAfterBlockObject, coreBlockObjectBehaviors.deletingEmptyTextBlockBeforeBlockObject, coreListBehaviors.clearListOnBackspace, coreListBehaviors.unindentListOnBackspace, coreListBehaviors.mergeTextIntoListOnDelete, coreListBehaviors.mergeTextIntoListOnBackspace, coreListBehaviors.deletingListFromStart, coreListBehaviors.clearListOnEnter, coreListBehaviors.indentListOnTab, coreListBehaviors.unindentListOnShiftTab, coreListBehaviors.inheritListLevel, coreListBehaviors.inheritListItem, coreListBehaviors.inheritListProperties, coreInsertBreakBehaviors.breakingAtTheEndOfTextBlock, coreInsertBreakBehaviors.breakingAtTheStartOfTextBlock, coreInsertBreakBehaviors.breakingEntireDocument, coreInsertBreakBehaviors.breakingEntireBlocks, coreInsertBreakBehaviors.breakingInlineObject].map((behavior) => ({
|
|
7706
7783
|
behavior,
|
|
7707
7784
|
priority: corePriority
|
|
7708
|
-
}))
|
|
7785
|
+
}));
|
|
7786
|
+
function withoutNormalizingConditional(editor, predicate, fn) {
|
|
7787
|
+
predicate() ? slate.Editor.withoutNormalizing(editor, fn) : fn();
|
|
7788
|
+
}
|
|
7789
|
+
const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
7709
7790
|
on: "annotation.set",
|
|
7710
7791
|
guard: ({
|
|
7711
7792
|
snapshot,
|
|
@@ -8487,21 +8568,63 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
8487
8568
|
type: "split"
|
|
8488
8569
|
})]]
|
|
8489
8570
|
}), behaviors_index.defineBehavior({
|
|
8490
|
-
on: "insert.
|
|
8571
|
+
on: "insert.child",
|
|
8572
|
+
guard: ({
|
|
8573
|
+
snapshot
|
|
8574
|
+
}) => {
|
|
8575
|
+
const lastBlock = selector_isSelectingEntireBlocks.getLastBlock(snapshot);
|
|
8576
|
+
return !lastBlock || snapshot.context.selection ? !1 : {
|
|
8577
|
+
lastBlockEndPoint: util_isSelectionCollapsed.getBlockEndPoint({
|
|
8578
|
+
context: snapshot.context,
|
|
8579
|
+
block: lastBlock
|
|
8580
|
+
})
|
|
8581
|
+
};
|
|
8582
|
+
},
|
|
8583
|
+
actions: [({
|
|
8584
|
+
event
|
|
8585
|
+
}, {
|
|
8586
|
+
lastBlockEndPoint
|
|
8587
|
+
}) => [behaviors_index.raise({
|
|
8588
|
+
type: "select",
|
|
8589
|
+
at: {
|
|
8590
|
+
anchor: lastBlockEndPoint,
|
|
8591
|
+
focus: lastBlockEndPoint
|
|
8592
|
+
}
|
|
8593
|
+
}), behaviors_index.raise(event)]]
|
|
8594
|
+
}), behaviors_index.defineBehavior({
|
|
8595
|
+
on: "insert.child",
|
|
8596
|
+
guard: ({
|
|
8597
|
+
snapshot
|
|
8598
|
+
}) => {
|
|
8599
|
+
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
8600
|
+
return snapshot.context.selection && !focusTextBlock;
|
|
8601
|
+
},
|
|
8491
8602
|
actions: [({
|
|
8492
8603
|
snapshot,
|
|
8493
8604
|
event
|
|
8494
|
-
}) => [behaviors_index.
|
|
8605
|
+
}) => [behaviors_index.raise({
|
|
8495
8606
|
type: "insert.block",
|
|
8496
8607
|
block: {
|
|
8497
8608
|
_type: snapshot.context.schema.block.name,
|
|
8498
8609
|
children: [{
|
|
8499
|
-
_type:
|
|
8500
|
-
|
|
8610
|
+
_type: snapshot.context.schema.span.name,
|
|
8611
|
+
text: "",
|
|
8612
|
+
marks: []
|
|
8501
8613
|
}]
|
|
8502
8614
|
},
|
|
8503
8615
|
placement: "auto",
|
|
8504
8616
|
select: "end"
|
|
8617
|
+
}), behaviors_index.raise(event)]]
|
|
8618
|
+
}), behaviors_index.defineBehavior({
|
|
8619
|
+
on: "insert.inline object",
|
|
8620
|
+
actions: [({
|
|
8621
|
+
event
|
|
8622
|
+
}) => [behaviors_index.raise({
|
|
8623
|
+
type: "insert.child",
|
|
8624
|
+
child: {
|
|
8625
|
+
_type: event.inlineObject.name,
|
|
8626
|
+
...event.inlineObject.value
|
|
8627
|
+
}
|
|
8505
8628
|
})]]
|
|
8506
8629
|
}), behaviors_index.defineBehavior({
|
|
8507
8630
|
on: "insert.soft break",
|
|
@@ -8513,33 +8636,59 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
8513
8636
|
}), behaviors_index.defineBehavior({
|
|
8514
8637
|
on: "insert.span",
|
|
8515
8638
|
guard: ({
|
|
8516
|
-
snapshot
|
|
8517
|
-
|
|
8518
|
-
}) => ({
|
|
8519
|
-
markDefs: event.annotations?.map((annotation) => ({
|
|
8520
|
-
_type: annotation.name,
|
|
8521
|
-
_key: snapshot.context.keyGenerator(),
|
|
8522
|
-
...annotation.value
|
|
8523
|
-
})) ?? []
|
|
8524
|
-
}),
|
|
8639
|
+
snapshot
|
|
8640
|
+
}) => !selector_isSelectionExpanded.getFocusTextBlock(snapshot),
|
|
8525
8641
|
actions: [({
|
|
8526
8642
|
snapshot,
|
|
8527
8643
|
event
|
|
8528
|
-
}
|
|
8529
|
-
markDefs
|
|
8530
|
-
}) => [behaviors_index.execute({
|
|
8644
|
+
}) => [behaviors_index.raise({
|
|
8531
8645
|
type: "insert.block",
|
|
8532
8646
|
block: {
|
|
8533
8647
|
_type: snapshot.context.schema.block.name,
|
|
8534
8648
|
children: [{
|
|
8535
8649
|
_type: snapshot.context.schema.span.name,
|
|
8536
|
-
text:
|
|
8537
|
-
marks: [
|
|
8538
|
-
}]
|
|
8539
|
-
markDefs
|
|
8650
|
+
text: "",
|
|
8651
|
+
marks: []
|
|
8652
|
+
}]
|
|
8540
8653
|
},
|
|
8541
8654
|
placement: "auto",
|
|
8542
8655
|
select: "end"
|
|
8656
|
+
}), behaviors_index.raise(event)]]
|
|
8657
|
+
}), behaviors_index.defineBehavior({
|
|
8658
|
+
on: "insert.span",
|
|
8659
|
+
guard: ({
|
|
8660
|
+
snapshot,
|
|
8661
|
+
event
|
|
8662
|
+
}) => {
|
|
8663
|
+
const focusTextBlock = selector_isSelectionExpanded.getFocusTextBlock(snapshot);
|
|
8664
|
+
return {
|
|
8665
|
+
markDefs: event.annotations?.map((annotation) => ({
|
|
8666
|
+
_type: annotation.name,
|
|
8667
|
+
_key: snapshot.context.keyGenerator(),
|
|
8668
|
+
...annotation.value
|
|
8669
|
+
})) ?? [],
|
|
8670
|
+
focusTextBlock
|
|
8671
|
+
};
|
|
8672
|
+
},
|
|
8673
|
+
actions: [({
|
|
8674
|
+
snapshot,
|
|
8675
|
+
event
|
|
8676
|
+
}, {
|
|
8677
|
+
markDefs,
|
|
8678
|
+
focusTextBlock
|
|
8679
|
+
}) => [...focusTextBlock ? [behaviors_index.raise({
|
|
8680
|
+
type: "block.set",
|
|
8681
|
+
at: focusTextBlock.path,
|
|
8682
|
+
props: {
|
|
8683
|
+
markDefs: [...focusTextBlock.node.markDefs ?? [], ...markDefs]
|
|
8684
|
+
}
|
|
8685
|
+
})] : [], behaviors_index.raise({
|
|
8686
|
+
type: "insert.child",
|
|
8687
|
+
child: {
|
|
8688
|
+
_type: snapshot.context.schema.span.name,
|
|
8689
|
+
text: event.text,
|
|
8690
|
+
marks: [...event.decorators ?? [], ...markDefs.map((markDef) => markDef._key)]
|
|
8691
|
+
}
|
|
8543
8692
|
})]]
|
|
8544
8693
|
})], abstractKeyboardBehaviors = [
|
|
8545
8694
|
/**
|
|
@@ -9017,6 +9166,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = behaviors_index.defineBehavior
|
|
|
9017
9166
|
}),
|
|
9018
9167
|
context: snapshot.context,
|
|
9019
9168
|
options: {
|
|
9169
|
+
removeUnusedMarkDefs: !0,
|
|
9020
9170
|
validateFields: !1
|
|
9021
9171
|
}
|
|
9022
9172
|
});
|
|
@@ -9224,7 +9374,7 @@ function performEvent({
|
|
|
9224
9374
|
return listenedNamespace !== void 0 && eventNamespace !== void 0 && listenedNamespace === eventNamespace || listenedNamespace !== void 0 && eventNamespace === void 0 && listenedNamespace === event.type ? !0 : behavior.on === event.type;
|
|
9225
9375
|
});
|
|
9226
9376
|
if (eventBehaviors.length === 0 && isSyntheticBehaviorEvent(event)) {
|
|
9227
|
-
nativeEvent?.preventDefault(), mode === "send" && clearUndoStep(editor),
|
|
9377
|
+
nativeEvent?.preventDefault(), mode === "send" && clearUndoStep(editor), withPerformingBehaviorOperation(editor, () => {
|
|
9228
9378
|
debug$6(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
|
|
9229
9379
|
context: {
|
|
9230
9380
|
keyGenerator,
|
|
@@ -9266,67 +9416,13 @@ function performEvent({
|
|
|
9266
9416
|
} catch (error) {
|
|
9267
9417
|
console.error(new Error(`Evaluating actions for "${event.type}" failed due to: ${error.message}`));
|
|
9268
9418
|
}
|
|
9269
|
-
if (actions.length
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
send: sendBack
|
|
9277
|
-
});
|
|
9278
|
-
} catch (error) {
|
|
9279
|
-
console.error(new Error(`Executing effect as a result of "${event.type}" failed due to: ${error.message}`));
|
|
9280
|
-
}
|
|
9281
|
-
continue;
|
|
9282
|
-
}
|
|
9283
|
-
if (action.type === "forward") {
|
|
9284
|
-
const remainingEventBehaviors2 = eventBehaviors.slice(eventBehaviorIndex + 1);
|
|
9285
|
-
performEvent({
|
|
9286
|
-
mode: "forward",
|
|
9287
|
-
behaviors,
|
|
9288
|
-
remainingEventBehaviors: remainingEventBehaviors2,
|
|
9289
|
-
event: action.event,
|
|
9290
|
-
editor,
|
|
9291
|
-
keyGenerator,
|
|
9292
|
-
schema: schema2,
|
|
9293
|
-
getSnapshot,
|
|
9294
|
-
nativeEvent,
|
|
9295
|
-
sendBack
|
|
9296
|
-
});
|
|
9297
|
-
continue;
|
|
9298
|
-
}
|
|
9299
|
-
if (action.type === "raise") {
|
|
9300
|
-
performEvent({
|
|
9301
|
-
mode: "raise",
|
|
9302
|
-
behaviors,
|
|
9303
|
-
remainingEventBehaviors: behaviors,
|
|
9304
|
-
event: action.event,
|
|
9305
|
-
editor,
|
|
9306
|
-
keyGenerator,
|
|
9307
|
-
schema: schema2,
|
|
9308
|
-
getSnapshot,
|
|
9309
|
-
nativeEvent,
|
|
9310
|
-
sendBack
|
|
9311
|
-
});
|
|
9312
|
-
continue;
|
|
9313
|
-
}
|
|
9314
|
-
performEvent({
|
|
9315
|
-
mode: "execute",
|
|
9316
|
-
behaviors,
|
|
9317
|
-
remainingEventBehaviors: [],
|
|
9318
|
-
event: action.event,
|
|
9319
|
-
editor,
|
|
9320
|
-
keyGenerator,
|
|
9321
|
-
schema: schema2,
|
|
9322
|
-
getSnapshot,
|
|
9323
|
-
nativeEvent: void 0,
|
|
9324
|
-
sendBack
|
|
9325
|
-
});
|
|
9326
|
-
}
|
|
9327
|
-
clearUndoStep(editor);
|
|
9328
|
-
continue;
|
|
9329
|
-
}
|
|
9419
|
+
if (actions.length === 0)
|
|
9420
|
+
continue;
|
|
9421
|
+
nativeEventPrevented = actions.some((action) => action.type === "raise" || action.type === "execute") || !actions.some((action) => action.type === "forward");
|
|
9422
|
+
let undoStepCreated = !1;
|
|
9423
|
+
actions.some((action) => action.type === "execute") && (createUndoStep(editor), undoStepCreated = !0);
|
|
9424
|
+
const actionTypes = actions.map((action) => action.type), uniqueActionTypes = new Set(actionTypes), raiseGroup = actionTypes.length > 1 && uniqueActionTypes.size === 1 && uniqueActionTypes.has("raise"), executeGroup = actionTypes.length > 1 && uniqueActionTypes.size === 1 && uniqueActionTypes.has("execute");
|
|
9425
|
+
withoutNormalizingConditional(editor, () => raiseGroup || executeGroup, () => {
|
|
9330
9426
|
for (const action of actions) {
|
|
9331
9427
|
if (action.type === "effect") {
|
|
9332
9428
|
try {
|
|
@@ -9341,7 +9437,7 @@ function performEvent({
|
|
|
9341
9437
|
if (action.type === "forward") {
|
|
9342
9438
|
const remainingEventBehaviors2 = eventBehaviors.slice(eventBehaviorIndex + 1);
|
|
9343
9439
|
performEvent({
|
|
9344
|
-
mode: "forward",
|
|
9440
|
+
mode: mode === "execute" ? "execute" : "forward",
|
|
9345
9441
|
behaviors,
|
|
9346
9442
|
remainingEventBehaviors: remainingEventBehaviors2,
|
|
9347
9443
|
event: action.event,
|
|
@@ -9356,7 +9452,7 @@ function performEvent({
|
|
|
9356
9452
|
}
|
|
9357
9453
|
if (action.type === "raise") {
|
|
9358
9454
|
performEvent({
|
|
9359
|
-
mode: "raise",
|
|
9455
|
+
mode: mode === "execute" ? "execute" : "raise",
|
|
9360
9456
|
behaviors,
|
|
9361
9457
|
remainingEventBehaviors: mode === "execute" ? remainingEventBehaviors : behaviors,
|
|
9362
9458
|
event: action.event,
|
|
@@ -9369,14 +9465,25 @@ function performEvent({
|
|
|
9369
9465
|
});
|
|
9370
9466
|
continue;
|
|
9371
9467
|
}
|
|
9372
|
-
|
|
9468
|
+
performEvent({
|
|
9469
|
+
mode: "execute",
|
|
9470
|
+
behaviors,
|
|
9471
|
+
remainingEventBehaviors: [],
|
|
9472
|
+
event: action.event,
|
|
9473
|
+
editor,
|
|
9474
|
+
keyGenerator,
|
|
9475
|
+
schema: schema2,
|
|
9476
|
+
getSnapshot,
|
|
9477
|
+
nativeEvent: void 0,
|
|
9478
|
+
sendBack
|
|
9479
|
+
});
|
|
9373
9480
|
}
|
|
9374
|
-
}
|
|
9481
|
+
}), undoStepCreated && clearUndoStep(editor);
|
|
9375
9482
|
}
|
|
9376
9483
|
break;
|
|
9377
9484
|
}
|
|
9378
9485
|
}
|
|
9379
|
-
!defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), mode === "send" && clearUndoStep(editor),
|
|
9486
|
+
!defaultBehaviorOverwritten && isSyntheticBehaviorEvent(event) ? (nativeEvent?.preventDefault(), mode === "send" && clearUndoStep(editor), withPerformingBehaviorOperation(editor, () => {
|
|
9380
9487
|
debug$6(`(execute:${eventCategory(event)})`, JSON.stringify(event, null, 2)), performOperation({
|
|
9381
9488
|
context: {
|
|
9382
9489
|
keyGenerator,
|
|
@@ -11316,7 +11423,8 @@ async function updateValue({
|
|
|
11316
11423
|
slateEditor,
|
|
11317
11424
|
value
|
|
11318
11425
|
});
|
|
11319
|
-
isChanged = blockChanged || isChanged, isValid = isValid && blockValid
|
|
11426
|
+
if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !isValid)
|
|
11427
|
+
break;
|
|
11320
11428
|
}
|
|
11321
11429
|
resolve();
|
|
11322
11430
|
})();
|
|
@@ -11345,7 +11453,9 @@ async function updateValue({
|
|
|
11345
11453
|
slateEditor,
|
|
11346
11454
|
value
|
|
11347
11455
|
});
|
|
11348
|
-
isChanged = blockChanged || isChanged, isValid = isValid && blockValid,
|
|
11456
|
+
if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !blockValid)
|
|
11457
|
+
break;
|
|
11458
|
+
index++;
|
|
11349
11459
|
}
|
|
11350
11460
|
});
|
|
11351
11461
|
});
|