@portabletext/editor 1.24.0 → 1.26.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 +283 -64
- package/lib/_chunks-cjs/behavior.core.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.get-text-before.cjs +8 -8
- package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs +412 -0
- package/lib/_chunks-cjs/selector.is-at-the-start-of-block.cjs.map +1 -0
- package/lib/_chunks-cjs/util.is-empty-text-block.cjs +2 -2
- package/lib/_chunks-cjs/util.is-empty-text-block.cjs.map +1 -1
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs +46 -0
- package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +1 -0
- package/lib/_chunks-cjs/util.reverse-selection.cjs +0 -16
- package/lib/_chunks-cjs/util.reverse-selection.cjs.map +1 -1
- package/lib/_chunks-es/behavior.core.js +259 -40
- package/lib/_chunks-es/behavior.core.js.map +1 -1
- package/lib/_chunks-es/selector.get-text-before.js +2 -2
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js +414 -0
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -0
- package/lib/_chunks-es/util.is-empty-text-block.js +1 -1
- package/lib/_chunks-es/util.is-equal-selection-points.js +47 -0
- package/lib/_chunks-es/util.is-equal-selection-points.js.map +1 -0
- package/lib/_chunks-es/util.reverse-selection.js +0 -16
- package/lib/_chunks-es/util.reverse-selection.js.map +1 -1
- package/lib/behaviors/index.cjs +27 -27
- package/lib/behaviors/index.cjs.map +1 -1
- package/lib/behaviors/index.d.cts +2208 -171
- package/lib/behaviors/index.d.ts +2208 -171
- package/lib/behaviors/index.js +1 -1
- package/lib/index.cjs +306 -298
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +10499 -521
- package/lib/index.d.ts +10499 -521
- package/lib/index.js +302 -294
- package/lib/index.js.map +1 -1
- package/lib/selectors/index.cjs +26 -171
- package/lib/selectors/index.cjs.map +1 -1
- package/lib/selectors/index.d.cts +16 -0
- package/lib/selectors/index.d.ts +16 -0
- package/lib/selectors/index.js +5 -151
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.cjs +5 -3
- package/lib/utils/index.cjs.map +1 -1
- package/lib/utils/index.d.cts +19 -0
- package/lib/utils/index.d.ts +19 -0
- package/lib/utils/index.js +4 -2
- package/package.json +6 -6
- package/src/behavior-actions/behavior.action-utils.insert-block.ts +3 -3
- package/src/behavior-actions/behavior.action.block.set.ts +23 -0
- package/src/behavior-actions/behavior.action.block.unset.ts +21 -0
- package/src/behavior-actions/behavior.action.insert-break.ts +2 -69
- package/src/behavior-actions/behavior.action.insert.block.ts +29 -0
- package/src/behavior-actions/behavior.actions.ts +116 -96
- package/src/behaviors/behavior.core.annotations.ts +29 -0
- package/src/behaviors/behavior.core.block-objects.ts +13 -13
- package/src/behaviors/behavior.core.decorators.ts +19 -0
- package/src/behaviors/behavior.core.insert-break.ts +122 -0
- package/src/behaviors/behavior.core.lists.ts +57 -23
- package/src/behaviors/behavior.core.style.ts +19 -0
- package/src/behaviors/behavior.core.ts +18 -2
- package/src/behaviors/behavior.types.ts +103 -88
- package/src/converters/converter.json.ts +4 -4
- package/src/converters/converter.portable-text.deserialize.test.ts +1 -1
- package/src/converters/converter.portable-text.ts +4 -4
- package/src/converters/converter.text-html.deserialize.test.ts +1 -1
- package/src/converters/converter.text-html.serialize.test.ts +1 -1
- package/src/converters/converter.text-html.ts +4 -4
- package/src/converters/converter.text-plain.test.ts +1 -1
- package/src/converters/converter.text-plain.ts +3 -3
- package/src/converters/{converter.ts → converter.types.ts} +6 -0
- package/src/editor/create-editor.ts +50 -7
- package/src/editor/editor-machine.ts +46 -3
- package/src/editor/editor-snapshot.ts +1 -1
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +2 -2
- package/src/editor/plugins/create-with-event-listeners.ts +41 -106
- package/src/selectors/index.ts +2 -0
- package/src/selectors/selector.is-at-the-end-of-block.ts +22 -0
- package/src/selectors/selector.is-at-the-start-of-block.ts +25 -0
- package/src/selectors/selector.is-selection-collapsed.ts +6 -2
- package/src/utils/index.ts +2 -0
- package/src/utils/util.get-block-end-point.ts +34 -0
- package/src/utils/util.is-equal-selection-points.ts +13 -0
- package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs +0 -231
- package/lib/_chunks-cjs/selector.is-selection-collapsed.cjs.map +0 -1
- package/lib/_chunks-cjs/util.is-keyed-segment.cjs +0 -6
- package/lib/_chunks-cjs/util.is-keyed-segment.cjs.map +0 -1
- package/lib/_chunks-es/selector.is-selection-collapsed.js +0 -232
- package/lib/_chunks-es/selector.is-selection-collapsed.js.map +0 -1
- package/lib/_chunks-es/util.is-keyed-segment.js +0 -7
- package/lib/_chunks-es/util.is-keyed-segment.js.map +0 -1
- /package/src/converters/{converters.ts → converters.core.ts} +0 -0
package/lib/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
-
var schema = require("@sanity/schema"), types = require("@sanity/types"), startCase = require("lodash.startcase"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), React = require("react"), slate = require("slate"), slateReact = require("slate-react"), debug$j = require("debug"), reactCompilerRuntime = require("react-compiler-runtime"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), useEffectEvent = require("use-effect-event"), xstate = require("xstate"), patches = require("@portabletext/patches"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"),
|
|
3
|
+
var schema = require("@sanity/schema"), types = require("@sanity/types"), startCase = require("lodash.startcase"), jsxRuntime = require("react/jsx-runtime"), react = require("@xstate/react"), isEqual = require("lodash/isEqual.js"), noop = require("lodash/noop.js"), React = require("react"), slate = require("slate"), slateReact = require("slate-react"), debug$j = require("debug"), reactCompilerRuntime = require("react-compiler-runtime"), uniq = require("lodash/uniq.js"), rxjs = require("rxjs"), useEffectEvent = require("use-effect-event"), xstate = require("xstate"), patches = require("@portabletext/patches"), flatten = require("lodash/flatten.js"), isPlainObject = require("lodash/isPlainObject.js"), util_sliceBlocks = require("./_chunks-cjs/util.slice-blocks.cjs"), blockTools = require("@portabletext/block-tools"), toHtml = require("@portabletext/to-html"), get = require("lodash/get.js"), isUndefined = require("lodash/isUndefined.js"), omitBy = require("lodash/omitBy.js"), selector_isAtTheStartOfBlock = require("./_chunks-cjs/selector.is-at-the-start-of-block.cjs"), util_isEmptyTextBlock = require("./_chunks-cjs/util.is-empty-text-block.cjs"), behavior_core = require("./_chunks-cjs/behavior.core.cjs"), getRandomValues = require("get-random-values-esm");
|
|
4
4
|
function _interopDefaultCompat(e) {
|
|
5
5
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
6
|
}
|
|
@@ -2501,6 +2501,7 @@ function _temp(s) {
|
|
|
2501
2501
|
}
|
|
2502
2502
|
Synchronizer.displayName = "Synchronizer";
|
|
2503
2503
|
const converterJson = {
|
|
2504
|
+
mimeType: "application/json",
|
|
2504
2505
|
serialize: ({
|
|
2505
2506
|
context,
|
|
2506
2507
|
event
|
|
@@ -2536,8 +2537,7 @@ const converterJson = {
|
|
|
2536
2537
|
mimeType: "application/json",
|
|
2537
2538
|
reason: "No application/x-portable-text Converter found"
|
|
2538
2539
|
};
|
|
2539
|
-
}
|
|
2540
|
-
mimeType: "application/json"
|
|
2540
|
+
}
|
|
2541
2541
|
};
|
|
2542
2542
|
function isTypedObject(object) {
|
|
2543
2543
|
return isRecord(object) && typeof object._type == "string";
|
|
@@ -2599,6 +2599,7 @@ function parseBlock({
|
|
|
2599
2599
|
return context.schema.lists.find((list) => list.value === block.listItem) || (delete parsedBlock.listItem, delete parsedBlock.level), parsedBlock;
|
|
2600
2600
|
}
|
|
2601
2601
|
const converterPortableText = {
|
|
2602
|
+
mimeType: "application/x-portable-text",
|
|
2602
2603
|
serialize: ({
|
|
2603
2604
|
context,
|
|
2604
2605
|
event
|
|
@@ -2648,9 +2649,9 @@ const converterPortableText = {
|
|
|
2648
2649
|
data: parsedBlocks,
|
|
2649
2650
|
mimeType: "application/x-portable-text"
|
|
2650
2651
|
};
|
|
2651
|
-
}
|
|
2652
|
-
mimeType: "application/x-portable-text"
|
|
2652
|
+
}
|
|
2653
2653
|
}, converterTextHtml = {
|
|
2654
|
+
mimeType: "text/html",
|
|
2654
2655
|
serialize: ({
|
|
2655
2656
|
context,
|
|
2656
2657
|
event
|
|
@@ -2695,8 +2696,7 @@ const converterPortableText = {
|
|
|
2695
2696
|
unstable_whitespaceOnPasteMode: context.schema.block.options.unstable_whitespaceOnPasteMode
|
|
2696
2697
|
}),
|
|
2697
2698
|
mimeType: "text/html"
|
|
2698
|
-
})
|
|
2699
|
-
mimeType: "text/html"
|
|
2699
|
+
})
|
|
2700
2700
|
}, converterTextPlain = {
|
|
2701
2701
|
mimeType: "text/plain",
|
|
2702
2702
|
serialize: ({
|
|
@@ -2981,123 +2981,57 @@ function createWithEventListeners(editorActor, subscriptions) {
|
|
|
2981
2981
|
subscriptions.push(() => {
|
|
2982
2982
|
const subscription = editorActor.on("*", (event) => {
|
|
2983
2983
|
switch (event.type) {
|
|
2984
|
-
case "
|
|
2985
|
-
editorActor.send({
|
|
2986
|
-
type: "behavior event",
|
|
2987
|
-
behaviorEvent: {
|
|
2988
|
-
type: "annotation.add",
|
|
2989
|
-
annotation: event.annotation
|
|
2990
|
-
},
|
|
2991
|
-
editor
|
|
2992
|
-
});
|
|
2993
|
-
break;
|
|
2994
|
-
}
|
|
2995
|
-
case "annotation.remove": {
|
|
2996
|
-
editorActor.send({
|
|
2997
|
-
type: "behavior event",
|
|
2998
|
-
behaviorEvent: {
|
|
2999
|
-
type: "annotation.remove",
|
|
3000
|
-
annotation: event.annotation
|
|
3001
|
-
},
|
|
3002
|
-
editor
|
|
3003
|
-
});
|
|
3004
|
-
break;
|
|
3005
|
-
}
|
|
3006
|
-
case "blur": {
|
|
3007
|
-
editorActor.send({
|
|
3008
|
-
type: "behavior event",
|
|
3009
|
-
behaviorEvent: {
|
|
3010
|
-
type: "blur"
|
|
3011
|
-
},
|
|
3012
|
-
editor
|
|
3013
|
-
});
|
|
3014
|
-
break;
|
|
3015
|
-
}
|
|
3016
|
-
case "custom.*": {
|
|
2984
|
+
case "custom.*":
|
|
3017
2985
|
editorActor.send({
|
|
3018
2986
|
type: "custom behavior event",
|
|
3019
2987
|
behaviorEvent: event.event,
|
|
3020
2988
|
editor
|
|
3021
2989
|
});
|
|
3022
2990
|
break;
|
|
3023
|
-
|
|
3024
|
-
case "
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
case "
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
case "
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
case "
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
type: "insert.inline object",
|
|
3062
|
-
inlineObject: event.inlineObject
|
|
3063
|
-
},
|
|
3064
|
-
editor
|
|
3065
|
-
});
|
|
3066
|
-
break;
|
|
3067
|
-
}
|
|
3068
|
-
case "list item.toggle": {
|
|
2991
|
+
case "annotation.add":
|
|
2992
|
+
case "annotation.remove":
|
|
2993
|
+
case "annotation.toggle":
|
|
2994
|
+
case "block.set":
|
|
2995
|
+
case "block.unset":
|
|
2996
|
+
case "blur":
|
|
2997
|
+
case "data transfer.set":
|
|
2998
|
+
case "decorator.add":
|
|
2999
|
+
case "decorator.remove":
|
|
3000
|
+
case "decorator.toggle":
|
|
3001
|
+
case "delete.backward":
|
|
3002
|
+
case "delete.block":
|
|
3003
|
+
case "delete.forward":
|
|
3004
|
+
case "delete.text":
|
|
3005
|
+
case "deserialization.failure":
|
|
3006
|
+
case "deserialization.success":
|
|
3007
|
+
case "focus":
|
|
3008
|
+
case "insert.block":
|
|
3009
|
+
case "insert.block object":
|
|
3010
|
+
case "insert.inline object":
|
|
3011
|
+
case "insert.span":
|
|
3012
|
+
case "insert.text block":
|
|
3013
|
+
case "list item.add":
|
|
3014
|
+
case "list item.remove":
|
|
3015
|
+
case "list item.toggle":
|
|
3016
|
+
case "move.block":
|
|
3017
|
+
case "move.block down":
|
|
3018
|
+
case "move.block up":
|
|
3019
|
+
case "select":
|
|
3020
|
+
case "select.next block":
|
|
3021
|
+
case "select.previous block":
|
|
3022
|
+
case "serialization.failure":
|
|
3023
|
+
case "serialization.success":
|
|
3024
|
+
case "style.add":
|
|
3025
|
+
case "style.remove":
|
|
3026
|
+
case "style.toggle":
|
|
3027
|
+
case "text block.set":
|
|
3028
|
+
case "text block.unset":
|
|
3069
3029
|
editorActor.send({
|
|
3070
3030
|
type: "behavior event",
|
|
3071
|
-
behaviorEvent:
|
|
3072
|
-
type: "list item.toggle",
|
|
3073
|
-
listItem: event.listItem
|
|
3074
|
-
},
|
|
3031
|
+
behaviorEvent: event,
|
|
3075
3032
|
editor
|
|
3076
3033
|
});
|
|
3077
3034
|
break;
|
|
3078
|
-
}
|
|
3079
|
-
case "select": {
|
|
3080
|
-
editorActor.send({
|
|
3081
|
-
type: "behavior event",
|
|
3082
|
-
behaviorEvent: {
|
|
3083
|
-
type: "select",
|
|
3084
|
-
selection: event.selection
|
|
3085
|
-
},
|
|
3086
|
-
editor
|
|
3087
|
-
});
|
|
3088
|
-
break;
|
|
3089
|
-
}
|
|
3090
|
-
case "style.toggle": {
|
|
3091
|
-
editorActor.send({
|
|
3092
|
-
type: "behavior event",
|
|
3093
|
-
behaviorEvent: {
|
|
3094
|
-
type: "style.toggle",
|
|
3095
|
-
style: event.style
|
|
3096
|
-
},
|
|
3097
|
-
editor
|
|
3098
|
-
});
|
|
3099
|
-
break;
|
|
3100
|
-
}
|
|
3101
3035
|
}
|
|
3102
3036
|
});
|
|
3103
3037
|
return () => {
|
|
@@ -4500,7 +4434,7 @@ const toggleListItemActionImplementation = ({
|
|
|
4500
4434
|
}) => {
|
|
4501
4435
|
if (!action.editor.selection)
|
|
4502
4436
|
return;
|
|
4503
|
-
const guards =
|
|
4437
|
+
const guards = selector_isAtTheStartOfBlock.createGuards(context), selectedBlocks = [...slate.Editor.nodes(action.editor, {
|
|
4504
4438
|
at: action.editor.selection,
|
|
4505
4439
|
match: (node) => guards.isListBlock(node)
|
|
4506
4440
|
})];
|
|
@@ -4514,7 +4448,7 @@ const toggleListItemActionImplementation = ({
|
|
|
4514
4448
|
}) => {
|
|
4515
4449
|
if (!action.editor.selection)
|
|
4516
4450
|
return;
|
|
4517
|
-
const guards =
|
|
4451
|
+
const guards = selector_isAtTheStartOfBlock.createGuards(context), selectedBlocks = [...slate.Editor.nodes(action.editor, {
|
|
4518
4452
|
at: action.editor.selection,
|
|
4519
4453
|
match: (node) => guards.isTextBlock(node)
|
|
4520
4454
|
})];
|
|
@@ -4564,7 +4498,7 @@ const toggleStyleActionImplementation = ({
|
|
|
4564
4498
|
}) => {
|
|
4565
4499
|
if (!action.editor.selection)
|
|
4566
4500
|
return;
|
|
4567
|
-
const defaultStyle = context.schema.styles[0].value, guards =
|
|
4501
|
+
const defaultStyle = context.schema.styles[0].value, guards = selector_isAtTheStartOfBlock.createGuards(context), selectedBlocks = [...slate.Editor.nodes(action.editor, {
|
|
4568
4502
|
at: action.editor.selection,
|
|
4569
4503
|
match: (node) => guards.isTextBlock(node)
|
|
4570
4504
|
})];
|
|
@@ -4580,7 +4514,7 @@ const toggleStyleActionImplementation = ({
|
|
|
4580
4514
|
}) => {
|
|
4581
4515
|
if (!action.editor.selection)
|
|
4582
4516
|
return;
|
|
4583
|
-
const guards =
|
|
4517
|
+
const guards = selector_isAtTheStartOfBlock.createGuards(context), selectedBlocks = [...slate.Editor.nodes(action.editor, {
|
|
4584
4518
|
at: action.editor.selection,
|
|
4585
4519
|
match: (node) => guards.isTextBlock(node)
|
|
4586
4520
|
})];
|
|
@@ -5121,10 +5055,9 @@ function insertBlock({
|
|
|
5121
5055
|
});
|
|
5122
5056
|
} else placement === "before" ? slate.Transforms.insertNodes(editor, block, {
|
|
5123
5057
|
at: focusBlockPath
|
|
5124
|
-
}) : slate.Editor.insertNode(editor, block)
|
|
5125
|
-
focusBlock && isEqualToEmptyEditor([focusBlock], schema2) && slate.Transforms.removeNodes(editor, {
|
|
5058
|
+
}) : (slate.Editor.insertNode(editor, block), focusBlock && isEqualToEmptyEditor([focusBlock], schema2) && slate.Transforms.removeNodes(editor, {
|
|
5126
5059
|
at: focusBlockPath
|
|
5127
|
-
});
|
|
5060
|
+
}));
|
|
5128
5061
|
} else {
|
|
5129
5062
|
const lastBlock = Array.from(slate.Editor.nodes(editor, {
|
|
5130
5063
|
match: (n) => !slate.Editor.isEditor(n),
|
|
@@ -5136,7 +5069,47 @@ function insertBlock({
|
|
|
5136
5069
|
});
|
|
5137
5070
|
}
|
|
5138
5071
|
}
|
|
5139
|
-
const
|
|
5072
|
+
const blockSetBehaviorActionImplementation = ({
|
|
5073
|
+
action
|
|
5074
|
+
}) => {
|
|
5075
|
+
const location = toSlateRange({
|
|
5076
|
+
anchor: {
|
|
5077
|
+
path: action.at,
|
|
5078
|
+
offset: 0
|
|
5079
|
+
},
|
|
5080
|
+
focus: {
|
|
5081
|
+
path: action.at,
|
|
5082
|
+
offset: 0
|
|
5083
|
+
}
|
|
5084
|
+
}, action.editor);
|
|
5085
|
+
if (!location)
|
|
5086
|
+
return;
|
|
5087
|
+
const {
|
|
5088
|
+
at,
|
|
5089
|
+
editor,
|
|
5090
|
+
type,
|
|
5091
|
+
...payload
|
|
5092
|
+
} = action;
|
|
5093
|
+
slate.Transforms.setNodes(action.editor, payload, {
|
|
5094
|
+
at: location
|
|
5095
|
+
});
|
|
5096
|
+
}, blockUnsetBehaviorActionImplementation = ({
|
|
5097
|
+
action
|
|
5098
|
+
}) => {
|
|
5099
|
+
const location = toSlateRange({
|
|
5100
|
+
anchor: {
|
|
5101
|
+
path: action.at,
|
|
5102
|
+
offset: 0
|
|
5103
|
+
},
|
|
5104
|
+
focus: {
|
|
5105
|
+
path: action.at,
|
|
5106
|
+
offset: 0
|
|
5107
|
+
}
|
|
5108
|
+
}, action.editor);
|
|
5109
|
+
location && slate.Transforms.unsetNodes(action.editor, action.props, {
|
|
5110
|
+
at: location
|
|
5111
|
+
});
|
|
5112
|
+
}, dataTransferSetActionImplementation = ({
|
|
5140
5113
|
action
|
|
5141
5114
|
}) => {
|
|
5142
5115
|
action.dataTransfer.setData(action.mimeType, action.data);
|
|
@@ -5193,96 +5166,54 @@ const dataTransferSetActionImplementation = ({
|
|
|
5193
5166
|
const keyGenerator = context.keyGenerator, schema2 = context.schema, editor = action.editor;
|
|
5194
5167
|
if (!editor.selection)
|
|
5195
5168
|
return;
|
|
5196
|
-
const
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
offset: 0
|
|
5209
|
-
});
|
|
5210
|
-
if (atTheEndOfBlock && slate.Range.isCollapsed(editor.selection)) {
|
|
5211
|
-
slate.Editor.insertNode(editor, editor.pteCreateTextBlock({
|
|
5212
|
-
decorators: [],
|
|
5213
|
-
listItem: focusBlock.listItem,
|
|
5214
|
-
level: focusBlock.level
|
|
5215
|
-
}));
|
|
5216
|
-
return;
|
|
5217
|
-
}
|
|
5218
|
-
if (atTheStartOfBlock && slate.Range.isCollapsed(editor.selection)) {
|
|
5219
|
-
slate.Editor.insertNode(editor, editor.pteCreateTextBlock({
|
|
5220
|
-
decorators: focusAnnotations.length === 0 ? focusDecorators : [],
|
|
5221
|
-
listItem: focusBlock.listItem,
|
|
5222
|
-
level: focusBlock.level
|
|
5223
|
-
}));
|
|
5224
|
-
const [nextBlockPath] = slate.Path.next(focusBlockPath);
|
|
5225
|
-
slate.Transforms.select(editor, {
|
|
5169
|
+
const anchorBlockPath = editor.selection.anchor.path.slice(0, 1), focusBlockPath = editor.selection.focus.path.slice(0, 1), focusBlock = slate.Node.descendant(editor, focusBlockPath);
|
|
5170
|
+
if (editor.isTextBlock(focusBlock) && anchorBlockPath[0] === focusBlockPath[0]) {
|
|
5171
|
+
slate.Editor.withoutNormalizing(editor, () => {
|
|
5172
|
+
if (!editor.selection)
|
|
5173
|
+
return;
|
|
5174
|
+
slate.Transforms.splitNodes(editor, {
|
|
5175
|
+
at: editor.selection
|
|
5176
|
+
});
|
|
5177
|
+
const [nextNode, nextNodePath] = slate.Editor.node(editor, slate.Path.next(focusBlockPath), {
|
|
5178
|
+
depth: 1
|
|
5179
|
+
});
|
|
5180
|
+
if (slate.Transforms.setSelection(editor, {
|
|
5226
5181
|
anchor: {
|
|
5227
|
-
path: [
|
|
5182
|
+
path: [...nextNodePath, 0],
|
|
5228
5183
|
offset: 0
|
|
5229
5184
|
},
|
|
5230
5185
|
focus: {
|
|
5231
|
-
path: [
|
|
5186
|
+
path: [...nextNodePath, 0],
|
|
5232
5187
|
offset: 0
|
|
5233
5188
|
}
|
|
5234
|
-
})
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
const [nextNode, nextNodePath] = slate.Editor.node(editor, slate.Path.next(focusBlockPath), {
|
|
5246
|
-
depth: 1
|
|
5247
|
-
});
|
|
5248
|
-
if (slate.Transforms.setSelection(editor, {
|
|
5249
|
-
anchor: {
|
|
5250
|
-
path: [...nextNodePath, 0],
|
|
5251
|
-
offset: 0
|
|
5252
|
-
},
|
|
5253
|
-
focus: {
|
|
5254
|
-
path: [...nextNodePath, 0],
|
|
5255
|
-
offset: 0
|
|
5256
|
-
}
|
|
5257
|
-
}), editor.isTextBlock(nextNode) && nextNode.markDefs && nextNode.markDefs.length > 0) {
|
|
5258
|
-
const newMarkDefKeys = /* @__PURE__ */ new Map(), prevNodeSpans = Array.from(slate.Node.children(editor, focusBlockPath)).map((entry) => entry[0]).filter((node) => editor.isTextSpan(node)), children = slate.Node.children(editor, nextNodePath);
|
|
5259
|
-
for (const [child, childPath] of children) {
|
|
5260
|
-
if (!editor.isTextSpan(child))
|
|
5261
|
-
continue;
|
|
5262
|
-
const marks = child.marks ?? [];
|
|
5263
|
-
for (const mark of marks)
|
|
5264
|
-
schema2.decorators.some((decorator) => decorator.value === mark) || prevNodeSpans.some((prevNodeSpan) => prevNodeSpan.marks?.includes(mark)) && !newMarkDefKeys.has(mark) && newMarkDefKeys.set(mark, keyGenerator());
|
|
5265
|
-
const newMarks = marks.map((mark) => newMarkDefKeys.get(mark) ?? mark);
|
|
5266
|
-
isEqual__default.default(marks, newMarks) || slate.Transforms.setNodes(editor, {
|
|
5267
|
-
marks: newMarks
|
|
5268
|
-
}, {
|
|
5269
|
-
at: childPath
|
|
5270
|
-
});
|
|
5271
|
-
}
|
|
5272
|
-
const newMarkDefs = nextNode.markDefs.map((markDef) => ({
|
|
5273
|
-
...markDef,
|
|
5274
|
-
_key: newMarkDefKeys.get(markDef._key) ?? markDef._key
|
|
5275
|
-
}));
|
|
5276
|
-
isEqual__default.default(nextNode.markDefs, newMarkDefs) || slate.Transforms.setNodes(editor, {
|
|
5277
|
-
markDefs: newMarkDefs
|
|
5189
|
+
}), editor.isTextBlock(nextNode) && nextNode.markDefs && nextNode.markDefs.length > 0) {
|
|
5190
|
+
const newMarkDefKeys = /* @__PURE__ */ new Map(), prevNodeSpans = Array.from(slate.Node.children(editor, focusBlockPath)).map((entry) => entry[0]).filter((node) => editor.isTextSpan(node)), children = slate.Node.children(editor, nextNodePath);
|
|
5191
|
+
for (const [child, childPath] of children) {
|
|
5192
|
+
if (!editor.isTextSpan(child))
|
|
5193
|
+
continue;
|
|
5194
|
+
const marks = child.marks ?? [];
|
|
5195
|
+
for (const mark of marks)
|
|
5196
|
+
schema2.decorators.some((decorator) => decorator.value === mark) || prevNodeSpans.some((prevNodeSpan) => prevNodeSpan.marks?.includes(mark)) && !newMarkDefKeys.has(mark) && newMarkDefKeys.set(mark, keyGenerator());
|
|
5197
|
+
const newMarks = marks.map((mark) => newMarkDefKeys.get(mark) ?? mark);
|
|
5198
|
+
isEqual__default.default(marks, newMarks) || slate.Transforms.setNodes(editor, {
|
|
5199
|
+
marks: newMarks
|
|
5278
5200
|
}, {
|
|
5279
|
-
at:
|
|
5280
|
-
match: (node) => editor.isTextBlock(node)
|
|
5201
|
+
at: childPath
|
|
5281
5202
|
});
|
|
5282
5203
|
}
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5204
|
+
const newMarkDefs = nextNode.markDefs.map((markDef) => ({
|
|
5205
|
+
...markDef,
|
|
5206
|
+
_key: newMarkDefKeys.get(markDef._key) ?? markDef._key
|
|
5207
|
+
}));
|
|
5208
|
+
isEqual__default.default(nextNode.markDefs, newMarkDefs) || slate.Transforms.setNodes(editor, {
|
|
5209
|
+
markDefs: newMarkDefs
|
|
5210
|
+
}, {
|
|
5211
|
+
at: nextNodePath,
|
|
5212
|
+
match: (node) => editor.isTextBlock(node)
|
|
5213
|
+
});
|
|
5214
|
+
}
|
|
5215
|
+
}), editor.onChange();
|
|
5216
|
+
return;
|
|
5286
5217
|
}
|
|
5287
5218
|
slate.Transforms.splitNodes(editor, {
|
|
5288
5219
|
always: !0
|
|
@@ -5363,6 +5294,27 @@ const dataTransferSetActionImplementation = ({
|
|
|
5363
5294
|
text: action.text,
|
|
5364
5295
|
marks: [...annotations?.map((annotation) => annotation._key) ?? [], ...action.decorators ?? []]
|
|
5365
5296
|
});
|
|
5297
|
+
}, insertBlockActionImplementation = ({
|
|
5298
|
+
context,
|
|
5299
|
+
action
|
|
5300
|
+
}) => {
|
|
5301
|
+
const parsedBlock = parseBlock({
|
|
5302
|
+
block: action.block,
|
|
5303
|
+
context
|
|
5304
|
+
});
|
|
5305
|
+
if (!parsedBlock)
|
|
5306
|
+
throw new Error(`Failed to parse block ${JSON.stringify(action.block)}`);
|
|
5307
|
+
const fragment = toSlateValue([parsedBlock], {
|
|
5308
|
+
schemaTypes: context.schema
|
|
5309
|
+
})[0];
|
|
5310
|
+
if (!fragment)
|
|
5311
|
+
throw new Error(`Failed to convert block to Slate fragment ${JSON.stringify(parsedBlock)}`);
|
|
5312
|
+
insertBlock({
|
|
5313
|
+
block: fragment,
|
|
5314
|
+
placement: action.placement,
|
|
5315
|
+
editor: action.editor,
|
|
5316
|
+
schema: context.schema
|
|
5317
|
+
});
|
|
5366
5318
|
}, textBlockSetActionImplementation = ({
|
|
5367
5319
|
action
|
|
5368
5320
|
}) => {
|
|
@@ -5409,6 +5361,8 @@ const dataTransferSetActionImplementation = ({
|
|
|
5409
5361
|
"annotation.add": addAnnotationActionImplementation,
|
|
5410
5362
|
"annotation.remove": removeAnnotationActionImplementation,
|
|
5411
5363
|
"annotation.toggle": toggleAnnotationActionImplementation,
|
|
5364
|
+
"block.set": blockSetBehaviorActionImplementation,
|
|
5365
|
+
"block.unset": blockUnsetBehaviorActionImplementation,
|
|
5412
5366
|
blur: ({
|
|
5413
5367
|
action
|
|
5414
5368
|
}) => {
|
|
@@ -5499,6 +5453,7 @@ const dataTransferSetActionImplementation = ({
|
|
|
5499
5453
|
}
|
|
5500
5454
|
});
|
|
5501
5455
|
},
|
|
5456
|
+
"insert.block": insertBlockActionImplementation,
|
|
5502
5457
|
"insert.blocks": insertBlocksActionImplementation,
|
|
5503
5458
|
"insert.block object": insertBlockObjectActionImplementation,
|
|
5504
5459
|
"insert.break": insertBreakActionImplementation,
|
|
@@ -5639,302 +5594,316 @@ function performAction({
|
|
|
5639
5594
|
action
|
|
5640
5595
|
}) {
|
|
5641
5596
|
switch (action.type) {
|
|
5642
|
-
case "
|
|
5643
|
-
|
|
5597
|
+
case "noop":
|
|
5598
|
+
break;
|
|
5599
|
+
case "effect": {
|
|
5600
|
+
behaviorActionImplementations.effect({
|
|
5644
5601
|
context,
|
|
5645
5602
|
action
|
|
5646
5603
|
});
|
|
5647
5604
|
break;
|
|
5648
5605
|
}
|
|
5649
|
-
|
|
5650
|
-
|
|
5606
|
+
default:
|
|
5607
|
+
performDefaultAction({
|
|
5608
|
+
context,
|
|
5609
|
+
action
|
|
5610
|
+
});
|
|
5611
|
+
}
|
|
5612
|
+
}
|
|
5613
|
+
function performDefaultAction({
|
|
5614
|
+
context,
|
|
5615
|
+
action
|
|
5616
|
+
}) {
|
|
5617
|
+
switch (action.type) {
|
|
5618
|
+
case "annotation.add": {
|
|
5619
|
+
behaviorActionImplementations["annotation.add"]({
|
|
5651
5620
|
context,
|
|
5652
5621
|
action
|
|
5653
5622
|
});
|
|
5654
5623
|
break;
|
|
5655
5624
|
}
|
|
5656
|
-
case "
|
|
5657
|
-
behaviorActionImplementations["
|
|
5625
|
+
case "annotation.remove": {
|
|
5626
|
+
behaviorActionImplementations["annotation.remove"]({
|
|
5658
5627
|
context,
|
|
5659
5628
|
action
|
|
5660
5629
|
});
|
|
5661
5630
|
break;
|
|
5662
5631
|
}
|
|
5663
|
-
case "
|
|
5664
|
-
behaviorActionImplementations["
|
|
5632
|
+
case "annotation.toggle": {
|
|
5633
|
+
behaviorActionImplementations["annotation.toggle"]({
|
|
5665
5634
|
context,
|
|
5666
5635
|
action
|
|
5667
5636
|
});
|
|
5668
5637
|
break;
|
|
5669
5638
|
}
|
|
5670
|
-
case "
|
|
5671
|
-
behaviorActionImplementations["
|
|
5639
|
+
case "block.set": {
|
|
5640
|
+
behaviorActionImplementations["block.set"]({
|
|
5672
5641
|
context,
|
|
5673
5642
|
action
|
|
5674
5643
|
});
|
|
5675
5644
|
break;
|
|
5676
5645
|
}
|
|
5677
|
-
case "
|
|
5678
|
-
behaviorActionImplementations["
|
|
5646
|
+
case "block.unset": {
|
|
5647
|
+
behaviorActionImplementations["block.unset"]({
|
|
5679
5648
|
context,
|
|
5680
5649
|
action
|
|
5681
5650
|
});
|
|
5682
5651
|
break;
|
|
5683
5652
|
}
|
|
5684
|
-
case "
|
|
5685
|
-
behaviorActionImplementations
|
|
5653
|
+
case "blur": {
|
|
5654
|
+
behaviorActionImplementations.blur({
|
|
5686
5655
|
context,
|
|
5687
5656
|
action
|
|
5688
5657
|
});
|
|
5689
5658
|
break;
|
|
5690
5659
|
}
|
|
5691
|
-
case "
|
|
5692
|
-
behaviorActionImplementations["
|
|
5660
|
+
case "data transfer.set": {
|
|
5661
|
+
behaviorActionImplementations["data transfer.set"]({
|
|
5693
5662
|
context,
|
|
5694
5663
|
action
|
|
5695
5664
|
});
|
|
5696
5665
|
break;
|
|
5697
5666
|
}
|
|
5698
|
-
case "
|
|
5699
|
-
behaviorActionImplementations["
|
|
5667
|
+
case "decorator.add": {
|
|
5668
|
+
behaviorActionImplementations["decorator.add"]({
|
|
5700
5669
|
context,
|
|
5701
5670
|
action
|
|
5702
5671
|
});
|
|
5703
5672
|
break;
|
|
5704
5673
|
}
|
|
5705
|
-
case "
|
|
5706
|
-
behaviorActionImplementations["
|
|
5674
|
+
case "decorator.remove": {
|
|
5675
|
+
behaviorActionImplementations["decorator.remove"]({
|
|
5707
5676
|
context,
|
|
5708
5677
|
action
|
|
5709
5678
|
});
|
|
5710
5679
|
break;
|
|
5711
5680
|
}
|
|
5712
|
-
case "
|
|
5713
|
-
behaviorActionImplementations["
|
|
5681
|
+
case "decorator.toggle": {
|
|
5682
|
+
behaviorActionImplementations["decorator.toggle"]({
|
|
5714
5683
|
context,
|
|
5715
5684
|
action
|
|
5716
5685
|
});
|
|
5717
5686
|
break;
|
|
5718
5687
|
}
|
|
5719
|
-
case "
|
|
5720
|
-
behaviorActionImplementations["
|
|
5688
|
+
case "delete.backward": {
|
|
5689
|
+
behaviorActionImplementations["delete.backward"]({
|
|
5721
5690
|
context,
|
|
5722
5691
|
action
|
|
5723
5692
|
});
|
|
5724
5693
|
break;
|
|
5725
5694
|
}
|
|
5726
|
-
case "
|
|
5695
|
+
case "delete.block": {
|
|
5696
|
+
behaviorActionImplementations["delete.block"]({
|
|
5697
|
+
context,
|
|
5698
|
+
action
|
|
5699
|
+
});
|
|
5727
5700
|
break;
|
|
5728
|
-
|
|
5729
|
-
|
|
5701
|
+
}
|
|
5702
|
+
case "delete.forward": {
|
|
5703
|
+
behaviorActionImplementations["delete.forward"]({
|
|
5730
5704
|
context,
|
|
5731
5705
|
action
|
|
5732
5706
|
});
|
|
5733
5707
|
break;
|
|
5734
5708
|
}
|
|
5735
|
-
case "
|
|
5736
|
-
behaviorActionImplementations.
|
|
5709
|
+
case "delete.text": {
|
|
5710
|
+
behaviorActionImplementations["delete.text"]({
|
|
5737
5711
|
context,
|
|
5738
5712
|
action
|
|
5739
5713
|
});
|
|
5740
5714
|
break;
|
|
5741
5715
|
}
|
|
5742
|
-
case "
|
|
5743
|
-
behaviorActionImplementations["
|
|
5716
|
+
case "deserialization.failure": {
|
|
5717
|
+
behaviorActionImplementations["deserialization.failure"]({
|
|
5744
5718
|
context,
|
|
5745
5719
|
action
|
|
5746
5720
|
});
|
|
5747
5721
|
break;
|
|
5748
5722
|
}
|
|
5749
|
-
case "
|
|
5750
|
-
behaviorActionImplementations["
|
|
5723
|
+
case "deserialization.success": {
|
|
5724
|
+
behaviorActionImplementations["deserialization.success"]({
|
|
5751
5725
|
context,
|
|
5752
5726
|
action
|
|
5753
5727
|
});
|
|
5754
5728
|
break;
|
|
5755
5729
|
}
|
|
5756
|
-
case "
|
|
5757
|
-
behaviorActionImplementations
|
|
5730
|
+
case "focus": {
|
|
5731
|
+
behaviorActionImplementations.focus({
|
|
5758
5732
|
context,
|
|
5759
5733
|
action
|
|
5760
5734
|
});
|
|
5761
5735
|
break;
|
|
5762
5736
|
}
|
|
5763
|
-
case "
|
|
5764
|
-
behaviorActionImplementations["
|
|
5737
|
+
case "insert.block": {
|
|
5738
|
+
behaviorActionImplementations["insert.block"]({
|
|
5765
5739
|
context,
|
|
5766
5740
|
action
|
|
5767
5741
|
});
|
|
5768
5742
|
break;
|
|
5769
5743
|
}
|
|
5770
|
-
case "
|
|
5771
|
-
behaviorActionImplementations["
|
|
5744
|
+
case "insert.blocks": {
|
|
5745
|
+
behaviorActionImplementations["insert.blocks"]({
|
|
5772
5746
|
context,
|
|
5773
5747
|
action
|
|
5774
5748
|
});
|
|
5775
5749
|
break;
|
|
5776
5750
|
}
|
|
5777
|
-
case "
|
|
5778
|
-
behaviorActionImplementations["
|
|
5751
|
+
case "insert.block object": {
|
|
5752
|
+
behaviorActionImplementations["insert.block object"]({
|
|
5779
5753
|
context,
|
|
5780
5754
|
action
|
|
5781
5755
|
});
|
|
5782
5756
|
break;
|
|
5783
5757
|
}
|
|
5784
|
-
|
|
5785
|
-
|
|
5758
|
+
case "insert.inline object": {
|
|
5759
|
+
behaviorActionImplementations["insert.inline object"]({
|
|
5786
5760
|
context,
|
|
5787
5761
|
action
|
|
5788
5762
|
});
|
|
5789
|
-
|
|
5790
|
-
}
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
action
|
|
5794
|
-
}) {
|
|
5795
|
-
switch (action.type) {
|
|
5796
|
-
case "annotation.add": {
|
|
5797
|
-
behaviorActionImplementations["annotation.add"]({
|
|
5763
|
+
break;
|
|
5764
|
+
}
|
|
5765
|
+
case "insert.break": {
|
|
5766
|
+
behaviorActionImplementations["insert.break"]({
|
|
5798
5767
|
context,
|
|
5799
5768
|
action
|
|
5800
5769
|
});
|
|
5801
5770
|
break;
|
|
5802
5771
|
}
|
|
5803
|
-
case "
|
|
5804
|
-
behaviorActionImplementations["
|
|
5772
|
+
case "insert.soft break": {
|
|
5773
|
+
behaviorActionImplementations["insert.soft break"]({
|
|
5805
5774
|
context,
|
|
5806
5775
|
action
|
|
5807
5776
|
});
|
|
5808
5777
|
break;
|
|
5809
5778
|
}
|
|
5810
|
-
case "
|
|
5811
|
-
behaviorActionImplementations.
|
|
5779
|
+
case "insert.span": {
|
|
5780
|
+
behaviorActionImplementations["insert.span"]({
|
|
5812
5781
|
context,
|
|
5813
5782
|
action
|
|
5814
5783
|
});
|
|
5815
5784
|
break;
|
|
5816
5785
|
}
|
|
5817
|
-
case "
|
|
5818
|
-
behaviorActionImplementations["
|
|
5786
|
+
case "insert.text": {
|
|
5787
|
+
behaviorActionImplementations["insert.text"]({
|
|
5819
5788
|
context,
|
|
5820
5789
|
action
|
|
5821
5790
|
});
|
|
5822
5791
|
break;
|
|
5823
5792
|
}
|
|
5824
|
-
case "
|
|
5825
|
-
behaviorActionImplementations["
|
|
5793
|
+
case "insert.text block": {
|
|
5794
|
+
behaviorActionImplementations["insert.text block"]({
|
|
5826
5795
|
context,
|
|
5827
5796
|
action
|
|
5828
5797
|
});
|
|
5829
5798
|
break;
|
|
5830
5799
|
}
|
|
5831
|
-
case "
|
|
5832
|
-
behaviorActionImplementations["
|
|
5800
|
+
case "list item.add": {
|
|
5801
|
+
behaviorActionImplementations["list item.add"]({
|
|
5833
5802
|
context,
|
|
5834
5803
|
action
|
|
5835
5804
|
});
|
|
5836
5805
|
break;
|
|
5837
5806
|
}
|
|
5838
|
-
case "
|
|
5839
|
-
behaviorActionImplementations["
|
|
5807
|
+
case "list item.remove": {
|
|
5808
|
+
behaviorActionImplementations["list item.remove"]({
|
|
5840
5809
|
context,
|
|
5841
5810
|
action
|
|
5842
5811
|
});
|
|
5843
5812
|
break;
|
|
5844
5813
|
}
|
|
5845
|
-
case "
|
|
5846
|
-
behaviorActionImplementations["
|
|
5814
|
+
case "list item.toggle": {
|
|
5815
|
+
behaviorActionImplementations["list item.toggle"]({
|
|
5847
5816
|
context,
|
|
5848
5817
|
action
|
|
5849
5818
|
});
|
|
5850
5819
|
break;
|
|
5851
5820
|
}
|
|
5852
|
-
case "
|
|
5853
|
-
behaviorActionImplementations["
|
|
5821
|
+
case "move.block": {
|
|
5822
|
+
behaviorActionImplementations["move.block"]({
|
|
5854
5823
|
context,
|
|
5855
5824
|
action
|
|
5856
5825
|
});
|
|
5857
5826
|
break;
|
|
5858
5827
|
}
|
|
5859
|
-
case "
|
|
5860
|
-
behaviorActionImplementations.
|
|
5828
|
+
case "move.block down": {
|
|
5829
|
+
behaviorActionImplementations["move.block down"]({
|
|
5861
5830
|
context,
|
|
5862
5831
|
action
|
|
5863
5832
|
});
|
|
5864
5833
|
break;
|
|
5865
5834
|
}
|
|
5866
|
-
case "
|
|
5867
|
-
behaviorActionImplementations["
|
|
5835
|
+
case "move.block up": {
|
|
5836
|
+
behaviorActionImplementations["move.block up"]({
|
|
5868
5837
|
context,
|
|
5869
5838
|
action
|
|
5870
5839
|
});
|
|
5871
5840
|
break;
|
|
5872
5841
|
}
|
|
5873
|
-
case "
|
|
5874
|
-
behaviorActionImplementations
|
|
5842
|
+
case "select": {
|
|
5843
|
+
behaviorActionImplementations.select({
|
|
5875
5844
|
context,
|
|
5876
5845
|
action
|
|
5877
5846
|
});
|
|
5878
5847
|
break;
|
|
5879
5848
|
}
|
|
5880
|
-
case "
|
|
5881
|
-
behaviorActionImplementations["
|
|
5849
|
+
case "select.previous block": {
|
|
5850
|
+
behaviorActionImplementations["select.previous block"]({
|
|
5882
5851
|
context,
|
|
5883
5852
|
action
|
|
5884
5853
|
});
|
|
5885
5854
|
break;
|
|
5886
5855
|
}
|
|
5887
|
-
case "
|
|
5888
|
-
behaviorActionImplementations["
|
|
5856
|
+
case "select.next block": {
|
|
5857
|
+
behaviorActionImplementations["select.next block"]({
|
|
5889
5858
|
context,
|
|
5890
5859
|
action
|
|
5891
5860
|
});
|
|
5892
5861
|
break;
|
|
5893
5862
|
}
|
|
5894
|
-
case "
|
|
5895
|
-
behaviorActionImplementations["
|
|
5863
|
+
case "serialization.failure": {
|
|
5864
|
+
behaviorActionImplementations["serialization.failure"]({
|
|
5896
5865
|
context,
|
|
5897
5866
|
action
|
|
5898
5867
|
});
|
|
5899
5868
|
break;
|
|
5900
5869
|
}
|
|
5901
|
-
case "
|
|
5902
|
-
behaviorActionImplementations["
|
|
5870
|
+
case "serialization.success": {
|
|
5871
|
+
behaviorActionImplementations["serialization.success"]({
|
|
5903
5872
|
context,
|
|
5904
5873
|
action
|
|
5905
5874
|
});
|
|
5906
5875
|
break;
|
|
5907
5876
|
}
|
|
5908
|
-
case "
|
|
5909
|
-
behaviorActionImplementations["
|
|
5877
|
+
case "style.add": {
|
|
5878
|
+
behaviorActionImplementations["style.add"]({
|
|
5910
5879
|
context,
|
|
5911
5880
|
action
|
|
5912
5881
|
});
|
|
5913
5882
|
break;
|
|
5914
5883
|
}
|
|
5915
|
-
case "
|
|
5916
|
-
behaviorActionImplementations.
|
|
5884
|
+
case "style.remove": {
|
|
5885
|
+
behaviorActionImplementations["style.remove"]({
|
|
5917
5886
|
context,
|
|
5918
5887
|
action
|
|
5919
5888
|
});
|
|
5920
5889
|
break;
|
|
5921
5890
|
}
|
|
5922
|
-
case "
|
|
5923
|
-
behaviorActionImplementations["
|
|
5891
|
+
case "style.toggle": {
|
|
5892
|
+
behaviorActionImplementations["style.toggle"]({
|
|
5924
5893
|
context,
|
|
5925
5894
|
action
|
|
5926
5895
|
});
|
|
5927
5896
|
break;
|
|
5928
5897
|
}
|
|
5929
|
-
case "
|
|
5930
|
-
behaviorActionImplementations["
|
|
5898
|
+
case "text block.set": {
|
|
5899
|
+
behaviorActionImplementations["text block.set"]({
|
|
5931
5900
|
context,
|
|
5932
5901
|
action
|
|
5933
5902
|
});
|
|
5934
5903
|
break;
|
|
5935
5904
|
}
|
|
5936
5905
|
default:
|
|
5937
|
-
behaviorActionImplementations["
|
|
5906
|
+
behaviorActionImplementations["text block.unset"]({
|
|
5938
5907
|
context,
|
|
5939
5908
|
action
|
|
5940
5909
|
});
|
|
@@ -6318,6 +6287,11 @@ const editorMachine = xstate.setup({
|
|
|
6318
6287
|
event
|
|
6319
6288
|
}) => event)
|
|
6320
6289
|
},
|
|
6290
|
+
"block.*": {
|
|
6291
|
+
actions: xstate.emit(({
|
|
6292
|
+
event
|
|
6293
|
+
}) => event)
|
|
6294
|
+
},
|
|
6321
6295
|
blur: {
|
|
6322
6296
|
actions: xstate.emit(({
|
|
6323
6297
|
event
|
|
@@ -6336,6 +6310,11 @@ const editorMachine = xstate.setup({
|
|
|
6336
6310
|
event
|
|
6337
6311
|
}) => event)
|
|
6338
6312
|
},
|
|
6313
|
+
"delete.*": {
|
|
6314
|
+
actions: xstate.emit(({
|
|
6315
|
+
event
|
|
6316
|
+
}) => event)
|
|
6317
|
+
},
|
|
6339
6318
|
focus: {
|
|
6340
6319
|
actions: xstate.emit(({
|
|
6341
6320
|
event
|
|
@@ -6351,15 +6330,30 @@ const editorMachine = xstate.setup({
|
|
|
6351
6330
|
event
|
|
6352
6331
|
}) => event)
|
|
6353
6332
|
},
|
|
6333
|
+
"move.*": {
|
|
6334
|
+
actions: xstate.emit(({
|
|
6335
|
+
event
|
|
6336
|
+
}) => event)
|
|
6337
|
+
},
|
|
6354
6338
|
select: {
|
|
6355
6339
|
actions: xstate.emit(({
|
|
6356
6340
|
event
|
|
6357
6341
|
}) => event)
|
|
6358
6342
|
},
|
|
6343
|
+
"select.*": {
|
|
6344
|
+
actions: xstate.emit(({
|
|
6345
|
+
event
|
|
6346
|
+
}) => event)
|
|
6347
|
+
},
|
|
6359
6348
|
"style.*": {
|
|
6360
6349
|
actions: xstate.emit(({
|
|
6361
6350
|
event
|
|
6362
6351
|
}) => event)
|
|
6352
|
+
},
|
|
6353
|
+
"text block.*": {
|
|
6354
|
+
actions: xstate.emit(({
|
|
6355
|
+
event
|
|
6356
|
+
}) => event)
|
|
6363
6357
|
}
|
|
6364
6358
|
}
|
|
6365
6359
|
}
|
|
@@ -6540,11 +6534,25 @@ function createEditorFromActor(editorActor) {
|
|
|
6540
6534
|
send: (event) => {
|
|
6541
6535
|
editorActor.send(event);
|
|
6542
6536
|
},
|
|
6543
|
-
on: (event, listener) => editorActor.on(
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6537
|
+
on: (event, listener) => editorActor.on(event, (event2) => {
|
|
6538
|
+
switch (event2.type) {
|
|
6539
|
+
case "blurred":
|
|
6540
|
+
case "done loading":
|
|
6541
|
+
case "editable":
|
|
6542
|
+
case "error":
|
|
6543
|
+
case "focused":
|
|
6544
|
+
case "invalid value":
|
|
6545
|
+
case "loading":
|
|
6546
|
+
case "mutation":
|
|
6547
|
+
case "patch":
|
|
6548
|
+
case "read only":
|
|
6549
|
+
case "ready":
|
|
6550
|
+
case "selection":
|
|
6551
|
+
case "value changed":
|
|
6552
|
+
listener(event2);
|
|
6553
|
+
break;
|
|
6554
|
+
}
|
|
6555
|
+
}),
|
|
6548
6556
|
_internal: {
|
|
6549
6557
|
editable,
|
|
6550
6558
|
editorActor,
|