@portabletext/editor 2.14.0 → 2.14.1
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/README.md +44 -0
- package/lib/_chunks-dts/behavior.types.action.d.cts +113 -128
- package/lib/_chunks-dts/behavior.types.action.d.ts +122 -137
- package/lib/index.cjs +145 -138
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +145 -138
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/behaviors/behavior.abstract.insert.ts +19 -0
- package/src/editor/editor-machine.ts +37 -44
- package/src/editor/editor-provider.tsx +4 -0
- package/src/editor/plugins/createWithObjectKeys.ts +19 -15
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +60 -53
- package/src/editor/plugins/createWithSchemaTypes.ts +18 -15
- package/src/editor/plugins/createWithUndoRedo.ts +3 -1
- package/src/editor/with-normalizing-node.ts +14 -0
package/lib/index.cjs
CHANGED
|
@@ -2890,6 +2890,14 @@ function getNextSpan({
|
|
|
2890
2890
|
}
|
|
2891
2891
|
return nextSpan;
|
|
2892
2892
|
}
|
|
2893
|
+
const IS_NORMALIZING_NODE = /* @__PURE__ */ new WeakMap();
|
|
2894
|
+
function withNormalizeNode(editor, fn) {
|
|
2895
|
+
const prev = IS_NORMALIZING_NODE.get(editor);
|
|
2896
|
+
IS_NORMALIZING_NODE.set(editor, !0), fn(), IS_NORMALIZING_NODE.set(editor, prev);
|
|
2897
|
+
}
|
|
2898
|
+
function isNormalizingNode(editor) {
|
|
2899
|
+
return IS_NORMALIZING_NODE.get(editor) ?? !1;
|
|
2900
|
+
}
|
|
2893
2901
|
function withRemoteChanges(editor, fn) {
|
|
2894
2902
|
const prev = isChangingRemotely(editor) || !1;
|
|
2895
2903
|
IS_PROCESSING_REMOTE_CHANGES.set(editor, !0), fn(), IS_PROCESSING_REMOTE_CHANGES.set(editor, prev);
|
|
@@ -2932,53 +2940,45 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
2932
2940
|
for (const [child, childPath] of children) {
|
|
2933
2941
|
const nextNode = node.children[childPath[1] + 1];
|
|
2934
2942
|
if (editor.isTextSpan(child) && editor.isTextSpan(nextNode) && child.marks?.every((mark) => nextNode.marks?.includes(mark)) && nextNode.marks?.every((mark) => child.marks?.includes(mark))) {
|
|
2935
|
-
debug$c("Merging spans", JSON.stringify(child, null, 2), JSON.stringify(nextNode, null, 2)),
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
}), editorActor.send({
|
|
2941
|
-
type: "done normalizing"
|
|
2943
|
+
debug$c("Merging spans", JSON.stringify(child, null, 2), JSON.stringify(nextNode, null, 2)), withNormalizeNode(editor, () => {
|
|
2944
|
+
slate.Transforms.mergeNodes(editor, {
|
|
2945
|
+
at: [childPath[0], childPath[1] + 1],
|
|
2946
|
+
voids: !0
|
|
2947
|
+
});
|
|
2942
2948
|
});
|
|
2943
2949
|
return;
|
|
2944
2950
|
}
|
|
2945
2951
|
}
|
|
2946
2952
|
}
|
|
2947
2953
|
if (editor.isTextBlock(node) && !Array.isArray(node.markDefs)) {
|
|
2948
|
-
debug$c("Adding .markDefs to block node"),
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
}), editorActor.send({
|
|
2955
|
-
type: "done normalizing"
|
|
2954
|
+
debug$c("Adding .markDefs to block node"), withNormalizeNode(editor, () => {
|
|
2955
|
+
slate.Transforms.setNodes(editor, {
|
|
2956
|
+
markDefs: []
|
|
2957
|
+
}, {
|
|
2958
|
+
at: path
|
|
2959
|
+
});
|
|
2956
2960
|
});
|
|
2957
2961
|
return;
|
|
2958
2962
|
}
|
|
2959
2963
|
if (editor.isTextSpan(node) && !Array.isArray(node.marks)) {
|
|
2960
|
-
debug$c("Adding .marks to span node"),
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
}), editorActor.send({
|
|
2967
|
-
type: "done normalizing"
|
|
2964
|
+
debug$c("Adding .marks to span node"), withNormalizeNode(editor, () => {
|
|
2965
|
+
slate.Transforms.setNodes(editor, {
|
|
2966
|
+
marks: []
|
|
2967
|
+
}, {
|
|
2968
|
+
at: path
|
|
2969
|
+
});
|
|
2968
2970
|
});
|
|
2969
2971
|
return;
|
|
2970
2972
|
}
|
|
2971
2973
|
if (editor.isTextSpan(node)) {
|
|
2972
2974
|
const blockPath = slate.Path.parent(path), [block] = slate.Editor.node(editor, blockPath), decorators2 = editorActor.getSnapshot().context.schema.decorators.map((decorator) => decorator.name), annotations = node.marks?.filter((mark) => !decorators2.includes(mark));
|
|
2973
2975
|
if (editor.isTextBlock(block) && node.text === "" && annotations && annotations.length > 0) {
|
|
2974
|
-
debug$c("Removing annotations from empty span node"),
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
}), editorActor.send({
|
|
2981
|
-
type: "done normalizing"
|
|
2976
|
+
debug$c("Removing annotations from empty span node"), withNormalizeNode(editor, () => {
|
|
2977
|
+
slate.Transforms.setNodes(editor, {
|
|
2978
|
+
marks: node.marks?.filter((mark) => decorators2.includes(mark))
|
|
2979
|
+
}, {
|
|
2980
|
+
at: path
|
|
2981
|
+
});
|
|
2982
2982
|
});
|
|
2983
2983
|
return;
|
|
2984
2984
|
}
|
|
@@ -2989,14 +2989,12 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
2989
2989
|
if (editor.isTextSpan(child)) {
|
|
2990
2990
|
const marks = child.marks ?? [], orphanedAnnotations = marks.filter((mark) => !decorators2.includes(mark) && !node.markDefs?.find((def) => def._key === mark));
|
|
2991
2991
|
if (orphanedAnnotations.length > 0) {
|
|
2992
|
-
debug$c("Removing orphaned annotations from span node"),
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
}), editorActor.send({
|
|
2999
|
-
type: "done normalizing"
|
|
2992
|
+
debug$c("Removing orphaned annotations from span node"), withNormalizeNode(editor, () => {
|
|
2993
|
+
slate.Transforms.setNodes(editor, {
|
|
2994
|
+
marks: marks.filter((mark) => !orphanedAnnotations.includes(mark))
|
|
2995
|
+
}, {
|
|
2996
|
+
at: childPath
|
|
2997
|
+
});
|
|
3000
2998
|
});
|
|
3001
2999
|
return;
|
|
3002
3000
|
}
|
|
@@ -3007,14 +3005,12 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
3007
3005
|
if (editor.isTextBlock(block)) {
|
|
3008
3006
|
const decorators2 = editorActor.getSnapshot().context.schema.decorators.map((decorator) => decorator.name), marks = node.marks ?? [], orphanedAnnotations = marks.filter((mark) => !decorators2.includes(mark) && !block.markDefs?.find((def) => def._key === mark));
|
|
3009
3007
|
if (orphanedAnnotations.length > 0) {
|
|
3010
|
-
debug$c("Removing orphaned annotations from span node"),
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
}), editorActor.send({
|
|
3017
|
-
type: "done normalizing"
|
|
3008
|
+
debug$c("Removing orphaned annotations from span node"), withNormalizeNode(editor, () => {
|
|
3009
|
+
slate.Transforms.setNodes(editor, {
|
|
3010
|
+
marks: marks.filter((mark) => !orphanedAnnotations.includes(mark))
|
|
3011
|
+
}, {
|
|
3012
|
+
at: path
|
|
3013
|
+
});
|
|
3018
3014
|
});
|
|
3019
3015
|
return;
|
|
3020
3016
|
}
|
|
@@ -3025,14 +3021,12 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
3025
3021
|
for (const markDef of markDefs)
|
|
3026
3022
|
markDefKeys.has(markDef._key) || (markDefKeys.add(markDef._key), newMarkDefs.push(markDef));
|
|
3027
3023
|
if (markDefs.length !== newMarkDefs.length) {
|
|
3028
|
-
debug$c("Removing duplicate markDefs"),
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
}), editorActor.send({
|
|
3035
|
-
type: "done normalizing"
|
|
3024
|
+
debug$c("Removing duplicate markDefs"), withNormalizeNode(editor, () => {
|
|
3025
|
+
slate.Transforms.setNodes(editor, {
|
|
3026
|
+
markDefs: newMarkDefs
|
|
3027
|
+
}, {
|
|
3028
|
+
at: path
|
|
3029
|
+
});
|
|
3036
3030
|
});
|
|
3037
3031
|
return;
|
|
3038
3032
|
}
|
|
@@ -3040,19 +3034,19 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
3040
3034
|
if (editor.isTextBlock(node) && !editor.operations.some((op) => op.type === "merge_node" && "markDefs" in op.properties && op.path.length === 1)) {
|
|
3041
3035
|
const newMarkDefs = (node.markDefs || []).filter((def) => node.children.find((child) => slate.Text.isText(child) && Array.isArray(child.marks) && child.marks.includes(def._key)));
|
|
3042
3036
|
if (node.markDefs && !isEqual__default.default(newMarkDefs, node.markDefs)) {
|
|
3043
|
-
debug$c("Removing markDef not in use"),
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
}), editorActor.send({
|
|
3050
|
-
type: "done normalizing"
|
|
3037
|
+
debug$c("Removing markDef not in use"), withNormalizeNode(editor, () => {
|
|
3038
|
+
slate.Transforms.setNodes(editor, {
|
|
3039
|
+
markDefs: newMarkDefs
|
|
3040
|
+
}, {
|
|
3041
|
+
at: path
|
|
3042
|
+
});
|
|
3051
3043
|
});
|
|
3052
3044
|
return;
|
|
3053
3045
|
}
|
|
3054
3046
|
}
|
|
3055
|
-
|
|
3047
|
+
withNormalizeNode(editor, () => {
|
|
3048
|
+
normalizeNode(nodeEntry);
|
|
3049
|
+
});
|
|
3056
3050
|
}, editor.apply = (op) => {
|
|
3057
3051
|
if (isChangingRemotely(editor)) {
|
|
3058
3052
|
apply2(op);
|
|
@@ -3908,7 +3902,7 @@ function createWithUndoRedo(options) {
|
|
|
3908
3902
|
} = editor, {
|
|
3909
3903
|
undos
|
|
3910
3904
|
} = 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);
|
|
3911
|
-
let merge = currentUndoStepId === previousUndoStepId;
|
|
3905
|
+
let merge = currentUndoStepId === previousUndoStepId || isNormalizingNode(editor);
|
|
3912
3906
|
if (save) {
|
|
3913
3907
|
if (step ? operations.length === 0 && (merge = currentUndoStepId === void 0 && previousUndoStepId === void 0 ? shouldMerge(op, lastOp) || overwrite : merge) : merge = !1, step && merge)
|
|
3914
3908
|
step.operations.push(op);
|
|
@@ -5522,32 +5516,30 @@ function createWithObjectKeys(editorActor) {
|
|
|
5522
5516
|
const [node, path] = entry;
|
|
5523
5517
|
if (slate.Element.isElement(node) && node._type === editorActor.getSnapshot().context.schema.block.name) {
|
|
5524
5518
|
if (!node._key) {
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
}), editorActor.send({
|
|
5532
|
-
type: "done normalizing"
|
|
5519
|
+
withNormalizeNode(editor, () => {
|
|
5520
|
+
slate.Transforms.setNodes(editor, {
|
|
5521
|
+
_key: editorActor.getSnapshot().context.keyGenerator()
|
|
5522
|
+
}, {
|
|
5523
|
+
at: path
|
|
5524
|
+
});
|
|
5533
5525
|
});
|
|
5534
5526
|
return;
|
|
5535
5527
|
}
|
|
5536
5528
|
for (const [child, childPath] of slate.Node.children(editor, path))
|
|
5537
5529
|
if (!child._key) {
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
}), editorActor.send({
|
|
5545
|
-
type: "done normalizing"
|
|
5530
|
+
withNormalizeNode(editor, () => {
|
|
5531
|
+
slate.Transforms.setNodes(editor, {
|
|
5532
|
+
_key: editorActor.getSnapshot().context.keyGenerator()
|
|
5533
|
+
}, {
|
|
5534
|
+
at: childPath
|
|
5535
|
+
});
|
|
5546
5536
|
});
|
|
5547
5537
|
return;
|
|
5548
5538
|
}
|
|
5549
5539
|
}
|
|
5550
|
-
|
|
5540
|
+
withNormalizeNode(editor, () => {
|
|
5541
|
+
normalizeNode(entry);
|
|
5542
|
+
});
|
|
5551
5543
|
}, editor;
|
|
5552
5544
|
};
|
|
5553
5545
|
}
|
|
@@ -6267,34 +6259,32 @@ function createWithSchemaTypes({
|
|
|
6267
6259
|
if (node._type === void 0 && path.length === 2) {
|
|
6268
6260
|
debug$8("Setting span type on text node without a type");
|
|
6269
6261
|
const span = node, key = span._key || editorActor.getSnapshot().context.keyGenerator();
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
}), editorActor.send({
|
|
6279
|
-
type: "done normalizing"
|
|
6262
|
+
withNormalizeNode(editor, () => {
|
|
6263
|
+
slate.Transforms.setNodes(editor, {
|
|
6264
|
+
...span,
|
|
6265
|
+
_type: editorActor.getSnapshot().context.schema.span.name,
|
|
6266
|
+
_key: key
|
|
6267
|
+
}, {
|
|
6268
|
+
at: path
|
|
6269
|
+
});
|
|
6280
6270
|
});
|
|
6281
6271
|
return;
|
|
6282
6272
|
}
|
|
6283
6273
|
if (node._key === void 0 && (path.length === 1 || path.length === 2)) {
|
|
6284
6274
|
debug$8("Setting missing key on child node without a key");
|
|
6285
6275
|
const key = editorActor.getSnapshot().context.keyGenerator();
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
}), editorActor.send({
|
|
6293
|
-
type: "done normalizing"
|
|
6276
|
+
withNormalizeNode(editor, () => {
|
|
6277
|
+
slate.Transforms.setNodes(editor, {
|
|
6278
|
+
_key: key
|
|
6279
|
+
}, {
|
|
6280
|
+
at: path
|
|
6281
|
+
});
|
|
6294
6282
|
});
|
|
6295
6283
|
return;
|
|
6296
6284
|
}
|
|
6297
|
-
|
|
6285
|
+
withNormalizeNode(editor, () => {
|
|
6286
|
+
normalizeNode(entry);
|
|
6287
|
+
});
|
|
6298
6288
|
}, editor;
|
|
6299
6289
|
};
|
|
6300
6290
|
}
|
|
@@ -8889,6 +8879,24 @@ const abstractAnnotationBehaviors = [behaviors_index.defineBehavior({
|
|
|
8889
8879
|
marks: [...event.decorators ?? [], ...markDefs.map((markDef) => markDef._key)]
|
|
8890
8880
|
}
|
|
8891
8881
|
})]]
|
|
8882
|
+
}), behaviors_index.defineBehavior({
|
|
8883
|
+
on: "insert.text",
|
|
8884
|
+
guard: ({
|
|
8885
|
+
snapshot
|
|
8886
|
+
}) => {
|
|
8887
|
+
const selection = snapshot.context.selection;
|
|
8888
|
+
return !selection || util_isEmptyTextBlock.isSelectionCollapsed(selection) ? !1 : {
|
|
8889
|
+
selection
|
|
8890
|
+
};
|
|
8891
|
+
},
|
|
8892
|
+
actions: [({
|
|
8893
|
+
event
|
|
8894
|
+
}, {
|
|
8895
|
+
selection
|
|
8896
|
+
}) => [behaviors_index.raise({
|
|
8897
|
+
type: "delete",
|
|
8898
|
+
at: selection
|
|
8899
|
+
}), behaviors_index.raise(event)]]
|
|
8892
8900
|
})], shiftLeft = keyboardShortcuts.createKeyboardShortcut({
|
|
8893
8901
|
default: [{
|
|
8894
8902
|
key: "ArrowLeft",
|
|
@@ -9930,6 +9938,12 @@ const editorMachine = xstate.setup({
|
|
|
9930
9938
|
event
|
|
9931
9939
|
}) => (xstate.assertEvent(event, "remove behavior"), context.behaviors.delete(event.behaviorConfig), /* @__PURE__ */ new Set([...context.behaviors]))
|
|
9932
9940
|
}),
|
|
9941
|
+
"add slate editor to context": xstate.assign({
|
|
9942
|
+
slateEditor: ({
|
|
9943
|
+
context,
|
|
9944
|
+
event
|
|
9945
|
+
}) => event.type === "add slate editor" ? event.editor : context.slateEditor
|
|
9946
|
+
}),
|
|
9933
9947
|
"emit patch event": xstate.emit(({
|
|
9934
9948
|
event
|
|
9935
9949
|
}) => (xstate.assertEvent(event, "internal.patch"), event)),
|
|
@@ -10052,7 +10066,10 @@ const editorMachine = xstate.setup({
|
|
|
10052
10066
|
guards: {
|
|
10053
10067
|
"slate is busy": ({
|
|
10054
10068
|
context
|
|
10055
|
-
}) => context.slateEditor ? context.slateEditor.operations.length > 0 : !1
|
|
10069
|
+
}) => context.slateEditor ? context.slateEditor.operations.length > 0 : !1,
|
|
10070
|
+
"slate is normalizing node": ({
|
|
10071
|
+
context
|
|
10072
|
+
}) => context.slateEditor ? isNormalizingNode(context.slateEditor) : !1
|
|
10056
10073
|
}
|
|
10057
10074
|
}).createMachine({
|
|
10058
10075
|
id: "editor",
|
|
@@ -10086,6 +10103,9 @@ const editorMachine = xstate.setup({
|
|
|
10086
10103
|
}) => event.maxBlocks
|
|
10087
10104
|
})
|
|
10088
10105
|
},
|
|
10106
|
+
"add slate editor": {
|
|
10107
|
+
actions: "add slate editor to context"
|
|
10108
|
+
},
|
|
10089
10109
|
"update selection": {
|
|
10090
10110
|
actions: [xstate.assign({
|
|
10091
10111
|
selection: ({
|
|
@@ -10353,36 +10373,20 @@ const editorMachine = xstate.setup({
|
|
|
10353
10373
|
debug$5("exit: setup->set up->writing->pristine->idle");
|
|
10354
10374
|
}],
|
|
10355
10375
|
on: {
|
|
10356
|
-
|
|
10357
|
-
|
|
10358
|
-
|
|
10359
|
-
|
|
10376
|
+
"internal.patch": [{
|
|
10377
|
+
guard: "slate is normalizing node",
|
|
10378
|
+
actions: "defer event"
|
|
10379
|
+
}, {
|
|
10360
10380
|
actions: "defer event",
|
|
10361
10381
|
target: "#editor.setup.set up.writing.dirty"
|
|
10362
|
-
},
|
|
10363
|
-
mutation: {
|
|
10382
|
+
}],
|
|
10383
|
+
mutation: [{
|
|
10384
|
+
guard: "slate is normalizing node",
|
|
10385
|
+
actions: "defer event"
|
|
10386
|
+
}, {
|
|
10364
10387
|
actions: "defer event",
|
|
10365
10388
|
target: "#editor.setup.set up.writing.dirty"
|
|
10366
|
-
}
|
|
10367
|
-
}
|
|
10368
|
-
},
|
|
10369
|
-
normalizing: {
|
|
10370
|
-
entry: [() => {
|
|
10371
|
-
debug$5("entry: setup->set up->writing->pristine->normalizing");
|
|
10372
|
-
}],
|
|
10373
|
-
exit: [() => {
|
|
10374
|
-
debug$5("exit: setup->set up->writing->pristine->normalizing");
|
|
10375
|
-
}],
|
|
10376
|
-
on: {
|
|
10377
|
-
"done normalizing": {
|
|
10378
|
-
target: "idle"
|
|
10379
|
-
},
|
|
10380
|
-
"internal.patch": {
|
|
10381
|
-
actions: "defer event"
|
|
10382
|
-
},
|
|
10383
|
-
mutation: {
|
|
10384
|
-
actions: "defer event"
|
|
10385
|
-
}
|
|
10389
|
+
}]
|
|
10386
10390
|
}
|
|
10387
10391
|
}
|
|
10388
10392
|
}
|
|
@@ -12642,7 +12646,7 @@ function RoutePatchesObservableToEditorActor(props) {
|
|
|
12642
12646
|
}, t1 = [props.editorActor, props.patches$], $[0] = props.editorActor, $[1] = props.patches$, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), React.useEffect(t0, t1), null;
|
|
12643
12647
|
}
|
|
12644
12648
|
function EditorProvider(props) {
|
|
12645
|
-
const $ = reactCompilerRuntime.c(
|
|
12649
|
+
const $ = reactCompilerRuntime.c(29);
|
|
12646
12650
|
let t0;
|
|
12647
12651
|
$[0] !== props.initialConfig ? (t0 = () => {
|
|
12648
12652
|
const internalEditor = createInternalEditor(props.initialConfig), portableTextEditor = new PortableTextEditor({
|
|
@@ -12658,7 +12662,7 @@ function EditorProvider(props) {
|
|
|
12658
12662
|
portableTextEditor: portableTextEditor_0
|
|
12659
12663
|
} = t1;
|
|
12660
12664
|
let t2;
|
|
12661
|
-
$[2] !== internalEditor_0.actors.editorActor || $[3] !== internalEditor_0.actors.mutationActor || $[4] !== internalEditor_0.actors.relayActor || $[5] !== internalEditor_0.actors.syncActor || $[6] !== internalEditor_0.
|
|
12665
|
+
$[2] !== internalEditor_0.actors.editorActor || $[3] !== internalEditor_0.actors.mutationActor || $[4] !== internalEditor_0.actors.relayActor || $[5] !== internalEditor_0.actors.syncActor || $[6] !== internalEditor_0.editor._internal.slateEditor.instance || $[7] !== internalEditor_0.subscriptions || $[8] !== portableTextEditor_0 ? (t2 = () => {
|
|
12662
12666
|
const unsubscribers = [];
|
|
12663
12667
|
for (const subscription of internalEditor_0.subscriptions)
|
|
12664
12668
|
unsubscribers.push(subscription());
|
|
@@ -12666,24 +12670,27 @@ function EditorProvider(props) {
|
|
|
12666
12670
|
const change = eventToChange(event);
|
|
12667
12671
|
change && portableTextEditor_0.change$.next(change);
|
|
12668
12672
|
});
|
|
12669
|
-
return unsubscribers.push(relayActorSubscription.unsubscribe), internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.
|
|
12673
|
+
return unsubscribers.push(relayActorSubscription.unsubscribe), internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.editorActor.send({
|
|
12674
|
+
type: "add slate editor",
|
|
12675
|
+
editor: internalEditor_0.editor._internal.slateEditor.instance
|
|
12676
|
+
}), internalEditor_0.actors.mutationActor.start(), internalEditor_0.actors.relayActor.start(), internalEditor_0.actors.syncActor.start(), () => {
|
|
12670
12677
|
for (const unsubscribe of unsubscribers)
|
|
12671
12678
|
unsubscribe();
|
|
12672
12679
|
stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.relayActor), stopActor(internalEditor_0.actors.syncActor);
|
|
12673
12680
|
};
|
|
12674
|
-
}, $[2] = internalEditor_0.actors.editorActor, $[3] = internalEditor_0.actors.mutationActor, $[4] = internalEditor_0.actors.relayActor, $[5] = internalEditor_0.actors.syncActor, $[6] = internalEditor_0.
|
|
12681
|
+
}, $[2] = internalEditor_0.actors.editorActor, $[3] = internalEditor_0.actors.mutationActor, $[4] = internalEditor_0.actors.relayActor, $[5] = internalEditor_0.actors.syncActor, $[6] = internalEditor_0.editor._internal.slateEditor.instance, $[7] = internalEditor_0.subscriptions, $[8] = portableTextEditor_0, $[9] = t2) : t2 = $[9];
|
|
12675
12682
|
let t3;
|
|
12676
|
-
$[
|
|
12683
|
+
$[10] !== internalEditor_0 || $[11] !== portableTextEditor_0 ? (t3 = [internalEditor_0, portableTextEditor_0], $[10] = internalEditor_0, $[11] = portableTextEditor_0, $[12] = t3) : t3 = $[12], React.useEffect(t2, t3);
|
|
12677
12684
|
let t4;
|
|
12678
|
-
$[
|
|
12685
|
+
$[13] !== portableTextEditor_0 || $[14] !== props.children ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: props.children }), $[13] = portableTextEditor_0, $[14] = props.children, $[15] = t4) : t4 = $[15];
|
|
12679
12686
|
let t5;
|
|
12680
|
-
$[
|
|
12687
|
+
$[16] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[17] !== internalEditor_0.editor._internal.slateEditor.instance || $[18] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, { editor: internalEditor_0.editor._internal.slateEditor.instance, initialValue: internalEditor_0.editor._internal.slateEditor.initialValue, children: t4 }), $[16] = internalEditor_0.editor._internal.slateEditor.initialValue, $[17] = internalEditor_0.editor._internal.slateEditor.instance, $[18] = t4, $[19] = t5) : t5 = $[19];
|
|
12681
12688
|
let t6;
|
|
12682
|
-
$[
|
|
12689
|
+
$[20] !== internalEditor_0.actors.relayActor || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t5 }), $[20] = internalEditor_0.actors.relayActor, $[21] = t5, $[22] = t6) : t6 = $[22];
|
|
12683
12690
|
let t7;
|
|
12684
|
-
$[
|
|
12691
|
+
$[23] !== internalEditor_0.actors.editorActor || $[24] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t6 }), $[23] = internalEditor_0.actors.editorActor, $[24] = t6, $[25] = t7) : t7 = $[25];
|
|
12685
12692
|
let t8;
|
|
12686
|
-
return $[
|
|
12693
|
+
return $[26] !== internalEditor_0.editor || $[27] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(useEditor.EditorContext.Provider, { value: internalEditor_0.editor, children: t7 }), $[26] = internalEditor_0.editor, $[27] = t7, $[28] = t8) : t8 = $[28], t8;
|
|
12687
12694
|
}
|
|
12688
12695
|
const usePortableTextEditorSelection = () => {
|
|
12689
12696
|
const $ = reactCompilerRuntime.c(3), editorActor = React.useContext(EditorActorContext), [selection, setSelection] = React.useState(null);
|