@portabletext/editor 1.3.0 → 1.3.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/lib/index.d.mts +172 -1
- package/lib/index.d.ts +172 -1
- package/lib/index.esm.js +109 -73
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +109 -73
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +109 -73
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/editor/PortableTextEditor.tsx +64 -32
- package/src/editor/components/SlateContainer.tsx +2 -13
- package/src/editor/components/Synchronizer.tsx +25 -28
- package/src/editor/editor-machine.ts +11 -0
- package/src/editor/plugins/createWithPatches.ts +8 -13
- package/src/editor/plugins/createWithUndoRedo.ts +34 -33
- package/src/editor/plugins/index.ts +2 -4
- package/src/index.ts +1 -0
- package/src/types/options.ts +0 -2
package/lib/index.js
CHANGED
|
@@ -2733,16 +2733,16 @@ const debug$h = debugWithName("plugin:withUndoRedo"), debugVerbose$3 = debug$h.e
|
|
|
2733
2733
|
}, getRemotePatches = (editor) => (REMOTE_PATCHES.get(editor) || REMOTE_PATCHES.set(editor, []), REMOTE_PATCHES.get(editor) || []);
|
|
2734
2734
|
function createWithUndoRedo(options) {
|
|
2735
2735
|
const {
|
|
2736
|
+
editorActor,
|
|
2736
2737
|
readOnly,
|
|
2737
|
-
patches$,
|
|
2738
2738
|
blockSchemaType
|
|
2739
2739
|
} = options;
|
|
2740
2740
|
return (editor) => {
|
|
2741
2741
|
let previousSnapshot = fromSlateValue(editor.children, blockSchemaType.name);
|
|
2742
2742
|
const remotePatches = getRemotePatches(editor);
|
|
2743
|
-
|
|
2743
|
+
editor.subscriptions.push(() => {
|
|
2744
2744
|
debug$h("Subscribing to patches");
|
|
2745
|
-
const sub = patches
|
|
2745
|
+
const sub = editorActor.on("patches", ({
|
|
2746
2746
|
patches: patches2,
|
|
2747
2747
|
snapshot
|
|
2748
2748
|
}) => {
|
|
@@ -2982,7 +2982,6 @@ function findOperationTargetBlock(editor, operation) {
|
|
|
2982
2982
|
const debug$g = debugWithName("plugin:withPatches");
|
|
2983
2983
|
function createWithPatches({
|
|
2984
2984
|
editorActor,
|
|
2985
|
-
patches$,
|
|
2986
2985
|
patchFunctions,
|
|
2987
2986
|
readOnly,
|
|
2988
2987
|
schemaTypes
|
|
@@ -3018,11 +3017,11 @@ function createWithPatches({
|
|
|
3018
3017
|
const remotePatches = patches2.filter((p) => p.origin !== "local");
|
|
3019
3018
|
remotePatches.length !== 0 && (bufferedPatches = bufferedPatches.concat(remotePatches), handleBufferedRemotePatches());
|
|
3020
3019
|
};
|
|
3021
|
-
return
|
|
3022
|
-
debug$g("Subscribing to patches
|
|
3023
|
-
const sub = patches
|
|
3020
|
+
return editor.subscriptions.push(() => {
|
|
3021
|
+
debug$g("Subscribing to remote patches");
|
|
3022
|
+
const sub = editorActor.on("patches", handlePatches);
|
|
3024
3023
|
return () => {
|
|
3025
|
-
debug$g("Unsubscribing to patches
|
|
3024
|
+
debug$g("Unsubscribing to remote patches"), sub.unsubscribe();
|
|
3026
3025
|
};
|
|
3027
3026
|
}), editor.apply = (operation) => {
|
|
3028
3027
|
if (readOnly)
|
|
@@ -4511,7 +4510,6 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
4511
4510
|
const e = editor, {
|
|
4512
4511
|
editorActor,
|
|
4513
4512
|
portableTextEditor,
|
|
4514
|
-
patches$,
|
|
4515
4513
|
readOnly,
|
|
4516
4514
|
maxBlocks
|
|
4517
4515
|
} = options, {
|
|
@@ -4527,13 +4525,12 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
4527
4525
|
schemaTypes
|
|
4528
4526
|
}), withEditableAPI = createWithEditableAPI(editorActor, portableTextEditor, schemaTypes), withPatches = createWithPatches({
|
|
4529
4527
|
editorActor,
|
|
4530
|
-
patches$,
|
|
4531
4528
|
patchFunctions: operationToPatches,
|
|
4532
4529
|
readOnly,
|
|
4533
4530
|
schemaTypes
|
|
4534
4531
|
}), withMaxBlocks = createWithMaxBlocks(maxBlocks || -1), withPortableTextLists = createWithPortableTextLists(schemaTypes), withUndoRedo = createWithUndoRedo({
|
|
4532
|
+
editorActor,
|
|
4535
4533
|
readOnly,
|
|
4536
|
-
patches$,
|
|
4537
4534
|
blockSchemaType: schemaTypes.block
|
|
4538
4535
|
}), withPortableTextMarkModel = createWithPortableTextMarkModel(editorActor, schemaTypes), withPortableTextBlockStyle = createWithPortableTextBlockStyle(editorActor, schemaTypes), withPlaceholderBlock = createWithPlaceholderBlock(), withUtils = createWithUtils({
|
|
4539
4536
|
editorActor,
|
|
@@ -4566,15 +4563,14 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
4566
4563
|
};
|
|
4567
4564
|
}, debug$6 = debugWithName("component:PortableTextEditor:SlateContainer");
|
|
4568
4565
|
function SlateContainer(props) {
|
|
4569
|
-
const $ = reactCompilerRuntime.c(
|
|
4566
|
+
const $ = reactCompilerRuntime.c(26), {
|
|
4570
4567
|
editorActor,
|
|
4571
|
-
patches$,
|
|
4572
4568
|
portableTextEditor,
|
|
4573
4569
|
readOnly,
|
|
4574
4570
|
maxBlocks
|
|
4575
4571
|
} = props;
|
|
4576
4572
|
let t0;
|
|
4577
|
-
$[0] !== editorActor || $[1] !== maxBlocks || $[2] !==
|
|
4573
|
+
$[0] !== editorActor || $[1] !== maxBlocks || $[2] !== portableTextEditor || $[3] !== readOnly ? (t0 = () => {
|
|
4578
4574
|
debug$6("Creating new Slate editor instance");
|
|
4579
4575
|
const {
|
|
4580
4576
|
editor,
|
|
@@ -4582,43 +4578,41 @@ function SlateContainer(props) {
|
|
|
4582
4578
|
} = withPlugins(slateReact.withReact(slate.createEditor()), {
|
|
4583
4579
|
editorActor,
|
|
4584
4580
|
maxBlocks,
|
|
4585
|
-
patches$,
|
|
4586
4581
|
portableTextEditor,
|
|
4587
4582
|
readOnly
|
|
4588
4583
|
});
|
|
4589
4584
|
return KEY_TO_VALUE_ELEMENT.set(editor, {}), KEY_TO_SLATE_ELEMENT.set(editor, {}), [editor, _sub];
|
|
4590
|
-
}, $[0] = editorActor, $[1] = maxBlocks, $[2] =
|
|
4585
|
+
}, $[0] = editorActor, $[1] = maxBlocks, $[2] = portableTextEditor, $[3] = readOnly, $[4] = t0) : t0 = $[4];
|
|
4591
4586
|
const [t1] = react.useState(t0), [slateEditor, subscribe] = t1;
|
|
4592
4587
|
let t2, t3;
|
|
4593
|
-
$[
|
|
4588
|
+
$[5] !== subscribe ? (t2 = () => {
|
|
4594
4589
|
const unsubscribe = subscribe();
|
|
4595
4590
|
return () => {
|
|
4596
4591
|
unsubscribe();
|
|
4597
4592
|
};
|
|
4598
|
-
}, t3 = [subscribe], $[
|
|
4593
|
+
}, t3 = [subscribe], $[5] = subscribe, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), react.useEffect(t2, t3);
|
|
4599
4594
|
let t4, t5;
|
|
4600
|
-
$[
|
|
4595
|
+
$[8] !== slateEditor || $[9] !== editorActor || $[10] !== maxBlocks || $[11] !== portableTextEditor || $[12] !== readOnly ? (t4 = () => {
|
|
4601
4596
|
debug$6("Re-initializing plugin chain"), withPlugins(slateEditor, {
|
|
4602
4597
|
editorActor,
|
|
4603
4598
|
maxBlocks,
|
|
4604
|
-
patches$,
|
|
4605
4599
|
portableTextEditor,
|
|
4606
4600
|
readOnly
|
|
4607
4601
|
});
|
|
4608
|
-
}, t5 = [editorActor, portableTextEditor, maxBlocks, readOnly,
|
|
4602
|
+
}, t5 = [editorActor, portableTextEditor, maxBlocks, readOnly, slateEditor], $[8] = slateEditor, $[9] = editorActor, $[10] = maxBlocks, $[11] = portableTextEditor, $[12] = readOnly, $[13] = t4, $[14] = t5) : (t4 = $[13], t5 = $[14]), react.useEffect(t4, t5);
|
|
4609
4603
|
let t6, t7;
|
|
4610
|
-
$[
|
|
4604
|
+
$[15] !== slateEditor ? (t7 = slateEditor.pteCreateTextBlock({
|
|
4611
4605
|
decorators: []
|
|
4612
|
-
}), $[
|
|
4606
|
+
}), $[15] = slateEditor, $[16] = t7) : t7 = $[16];
|
|
4613
4607
|
let t8;
|
|
4614
|
-
$[
|
|
4608
|
+
$[17] !== t7 ? (t8 = [t7], $[17] = t7, $[18] = t8) : t8 = $[18], t6 = t8;
|
|
4615
4609
|
const initialValue = t6;
|
|
4616
4610
|
let t9, t10;
|
|
4617
|
-
$[
|
|
4611
|
+
$[19] !== slateEditor ? (t9 = () => () => {
|
|
4618
4612
|
debug$6("Destroying Slate editor"), slateEditor.destroy();
|
|
4619
|
-
}, t10 = [slateEditor], $[
|
|
4613
|
+
}, t10 = [slateEditor], $[19] = slateEditor, $[20] = t9, $[21] = t10) : (t9 = $[20], t10 = $[21]), react.useEffect(t9, t10);
|
|
4620
4614
|
let t11;
|
|
4621
|
-
return $[
|
|
4615
|
+
return $[22] !== slateEditor || $[23] !== initialValue || $[24] !== props.children ? (t11 = /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, { editor: slateEditor, initialValue, children: props.children }), $[22] = slateEditor, $[23] = initialValue, $[24] = props.children, $[25] = t11) : t11 = $[25], t11;
|
|
4622
4616
|
}
|
|
4623
4617
|
SlateContainer.displayName = "SlateContainer";
|
|
4624
4618
|
const PortableTextEditorReadOnlyContext = react.createContext(!1), usePortableTextEditorReadOnlyStatus = () => {
|
|
@@ -4815,20 +4809,28 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
|
|
|
4815
4809
|
}
|
|
4816
4810
|
const debug$4 = debugWithName("component:PortableTextEditor:Synchronizer"), debugVerbose$1 = debug$4.enabled && !1, FLUSH_PATCHES_THROTTLED_MS = process.env.NODE_ENV === "test" ? 500 : 1e3;
|
|
4817
4811
|
function Synchronizer(props) {
|
|
4818
|
-
const portableTextEditor = usePortableTextEditor(), readOnly = usePortableTextEditorReadOnlyStatus(), {
|
|
4812
|
+
const $ = reactCompilerRuntime.c(35), portableTextEditor = usePortableTextEditor(), readOnly = usePortableTextEditorReadOnlyStatus(), {
|
|
4819
4813
|
editorActor,
|
|
4820
4814
|
getValue,
|
|
4821
4815
|
onChange,
|
|
4822
4816
|
value
|
|
4823
|
-
} = props
|
|
4817
|
+
} = props;
|
|
4818
|
+
let t0;
|
|
4819
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
|
|
4820
|
+
const pendingPatches = react.useRef(t0);
|
|
4821
|
+
let t1;
|
|
4822
|
+
$[1] !== editorActor || $[2] !== portableTextEditor || $[3] !== readOnly ? (t1 = {
|
|
4824
4823
|
editorActor,
|
|
4825
4824
|
portableTextEditor,
|
|
4826
4825
|
readOnly
|
|
4827
|
-
}
|
|
4828
|
-
|
|
4826
|
+
}, $[1] = editorActor, $[2] = portableTextEditor, $[3] = readOnly, $[4] = t1) : t1 = $[4];
|
|
4827
|
+
const syncValue = useSyncValue(t1), slateEditor = slateReact.useSlate();
|
|
4828
|
+
let t2, t3;
|
|
4829
|
+
$[5] !== slateEditor ? (t2 = () => {
|
|
4829
4830
|
IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !1);
|
|
4830
|
-
}, [slateEditor]);
|
|
4831
|
-
|
|
4831
|
+
}, t3 = [slateEditor], $[5] = slateEditor, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), react.useEffect(t2, t3);
|
|
4832
|
+
let t4;
|
|
4833
|
+
$[8] !== getValue || $[9] !== editorActor || $[10] !== slateEditor ? (t4 = () => {
|
|
4832
4834
|
if (pendingPatches.current.length > 0) {
|
|
4833
4835
|
debug$4("Flushing pending patches"), debugVerbose$1 && debug$4(`Patches:
|
|
4834
4836
|
${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
@@ -4840,61 +4842,68 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
|
4840
4842
|
}), pendingPatches.current = [];
|
|
4841
4843
|
}
|
|
4842
4844
|
IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !1);
|
|
4843
|
-
}, [editorActor, slateEditor,
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
}
|
|
4848
|
-
onFlushPendingPatchesThrottled();
|
|
4849
|
-
}, FLUSH_PATCHES_THROTTLED_MS, {
|
|
4850
|
-
leading: !1,
|
|
4851
|
-
trailing: !0
|
|
4852
|
-
}), [onFlushPendingPatches, slateEditor]);
|
|
4853
|
-
react.useEffect(() => () => {
|
|
4845
|
+
}, $[8] = getValue, $[9] = editorActor, $[10] = slateEditor, $[11] = t4) : t4 = $[11];
|
|
4846
|
+
const onFlushPendingPatches = t4;
|
|
4847
|
+
let t5, t6;
|
|
4848
|
+
$[12] !== onFlushPendingPatches ? (t5 = () => () => {
|
|
4854
4849
|
onFlushPendingPatches();
|
|
4855
|
-
}, [onFlushPendingPatches]);
|
|
4856
|
-
|
|
4857
|
-
|
|
4850
|
+
}, t6 = [onFlushPendingPatches], $[12] = onFlushPendingPatches, $[13] = t5, $[14] = t6) : (t5 = $[13], t6 = $[14]), react.useEffect(t5, t6);
|
|
4851
|
+
let t7;
|
|
4852
|
+
$[15] !== onChange ? (t7 = (change) => onChange(change), $[15] = onChange, $[16] = t7) : t7 = $[16];
|
|
4853
|
+
const handleChange = useEffectEvent.useEffectEvent(t7);
|
|
4854
|
+
let t8, t9;
|
|
4855
|
+
$[17] !== slateEditor || $[18] !== onFlushPendingPatches || $[19] !== editorActor || $[20] !== handleChange ? (t8 = () => {
|
|
4856
|
+
const onFlushPendingPatchesThrottled = throttle__default.default(() => {
|
|
4857
|
+
if (slate.Editor.isNormalizing(slateEditor)) {
|
|
4858
|
+
onFlushPendingPatches();
|
|
4859
|
+
return;
|
|
4860
|
+
}
|
|
4861
|
+
onFlushPendingPatchesThrottled();
|
|
4862
|
+
}, FLUSH_PATCHES_THROTTLED_MS, {
|
|
4863
|
+
leading: !1,
|
|
4864
|
+
trailing: !0
|
|
4865
|
+
});
|
|
4858
4866
|
debug$4("Subscribing to editor changes");
|
|
4859
4867
|
const sub = editorActor.on("*", (event) => {
|
|
4860
|
-
switch (event.type) {
|
|
4861
|
-
case "patch":
|
|
4868
|
+
bb18: switch (event.type) {
|
|
4869
|
+
case "patch": {
|
|
4862
4870
|
IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !0), pendingPatches.current.push(event.patch), onFlushPendingPatchesThrottled(), handleChange(event);
|
|
4863
|
-
break;
|
|
4871
|
+
break bb18;
|
|
4872
|
+
}
|
|
4864
4873
|
case "loading": {
|
|
4865
4874
|
handleChange({
|
|
4866
4875
|
type: "loading",
|
|
4867
4876
|
isLoading: !0
|
|
4868
4877
|
});
|
|
4869
|
-
break;
|
|
4878
|
+
break bb18;
|
|
4870
4879
|
}
|
|
4871
4880
|
case "done loading": {
|
|
4872
4881
|
handleChange({
|
|
4873
4882
|
type: "loading",
|
|
4874
4883
|
isLoading: !1
|
|
4875
4884
|
});
|
|
4876
|
-
break;
|
|
4885
|
+
break bb18;
|
|
4877
4886
|
}
|
|
4878
4887
|
case "offline": {
|
|
4879
4888
|
handleChange({
|
|
4880
4889
|
type: "connection",
|
|
4881
4890
|
value: "offline"
|
|
4882
4891
|
});
|
|
4883
|
-
break;
|
|
4892
|
+
break bb18;
|
|
4884
4893
|
}
|
|
4885
4894
|
case "online": {
|
|
4886
4895
|
handleChange({
|
|
4887
4896
|
type: "connection",
|
|
4888
4897
|
value: "online"
|
|
4889
4898
|
});
|
|
4890
|
-
break;
|
|
4899
|
+
break bb18;
|
|
4891
4900
|
}
|
|
4892
4901
|
case "value changed": {
|
|
4893
4902
|
handleChange({
|
|
4894
4903
|
type: "value",
|
|
4895
4904
|
value: event.value
|
|
4896
4905
|
});
|
|
4897
|
-
break;
|
|
4906
|
+
break bb18;
|
|
4898
4907
|
}
|
|
4899
4908
|
case "invalid value": {
|
|
4900
4909
|
handleChange({
|
|
@@ -4902,15 +4911,17 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
|
4902
4911
|
resolution: event.resolution,
|
|
4903
4912
|
value: event.value
|
|
4904
4913
|
});
|
|
4905
|
-
break;
|
|
4914
|
+
break bb18;
|
|
4906
4915
|
}
|
|
4907
4916
|
case "error": {
|
|
4908
4917
|
handleChange({
|
|
4909
4918
|
...event,
|
|
4910
4919
|
level: "warning"
|
|
4911
4920
|
});
|
|
4912
|
-
break;
|
|
4921
|
+
break bb18;
|
|
4913
4922
|
}
|
|
4923
|
+
case "patches":
|
|
4924
|
+
break bb18;
|
|
4914
4925
|
default:
|
|
4915
4926
|
handleChange(event);
|
|
4916
4927
|
}
|
|
@@ -4918,24 +4929,26 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
|
4918
4929
|
return () => {
|
|
4919
4930
|
debug$4("Unsubscribing to changes"), sub.unsubscribe();
|
|
4920
4931
|
};
|
|
4921
|
-
}, [handleChange,
|
|
4922
|
-
|
|
4932
|
+
}, t9 = [editorActor, handleChange, onFlushPendingPatches, slateEditor], $[17] = slateEditor, $[18] = onFlushPendingPatches, $[19] = editorActor, $[20] = handleChange, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), react.useEffect(t8, t9);
|
|
4933
|
+
let t10;
|
|
4934
|
+
$[23] !== syncValue || $[24] !== value ? (t10 = () => {
|
|
4923
4935
|
debug$4("Editor is online, syncing from props.value"), syncValue(value);
|
|
4924
|
-
}, [syncValue, value]);
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4936
|
+
}, $[23] = syncValue, $[24] = value, $[25] = t10) : t10 = $[25];
|
|
4937
|
+
const handleOnline = t10;
|
|
4938
|
+
let t11, t12;
|
|
4939
|
+
$[26] !== editorActor || $[27] !== handleOnline ? (t11 = () => {
|
|
4940
|
+
const subscription = editorActor.on("online", handleOnline);
|
|
4929
4941
|
return () => {
|
|
4930
4942
|
subscription.unsubscribe();
|
|
4931
4943
|
};
|
|
4932
|
-
}, [handleOnline, editorActor,
|
|
4944
|
+
}, t12 = [handleOnline, editorActor], $[26] = editorActor, $[27] = handleOnline, $[28] = t11, $[29] = t12) : (t11 = $[28], t12 = $[29]), react.useEffect(t11, t12);
|
|
4933
4945
|
const isInitialValueFromProps = react.useRef(!0);
|
|
4934
|
-
|
|
4946
|
+
let t13, t14;
|
|
4947
|
+
return $[30] !== syncValue || $[31] !== value || $[32] !== editorActor ? (t13 = () => {
|
|
4935
4948
|
debug$4("Value from props changed, syncing new value"), syncValue(value), isInitialValueFromProps.current && (editorActor.send({
|
|
4936
4949
|
type: "ready"
|
|
4937
4950
|
}), isInitialValueFromProps.current = !1);
|
|
4938
|
-
}, [editorActor, syncValue, value]), null;
|
|
4951
|
+
}, t14 = [editorActor, syncValue, value], $[30] = syncValue, $[31] = value, $[32] = editorActor, $[33] = t13, $[34] = t14) : (t13 = $[33], t14 = $[34]), react.useEffect(t13, t14), null;
|
|
4939
4952
|
}
|
|
4940
4953
|
Synchronizer.displayName = "Synchronizer";
|
|
4941
4954
|
const EditorActorContext = react.createContext({}), insertBreakActionImplementation = ({
|
|
@@ -5430,6 +5443,11 @@ const networkLogic = xstate.fromCallback(({
|
|
|
5430
5443
|
type: "loading"
|
|
5431
5444
|
})
|
|
5432
5445
|
},
|
|
5446
|
+
patches: {
|
|
5447
|
+
actions: xstate.emit(({
|
|
5448
|
+
event
|
|
5449
|
+
}) => event)
|
|
5450
|
+
},
|
|
5433
5451
|
"done loading": {
|
|
5434
5452
|
actions: xstate.emit({
|
|
5435
5453
|
type: "done loading"
|
|
@@ -5578,12 +5596,15 @@ class PortableTextEditor extends react.Component {
|
|
|
5578
5596
|
patches$,
|
|
5579
5597
|
incomingPatches$
|
|
5580
5598
|
} = this.props, _patches$ = incomingPatches$ || patches$, maxBlocks = typeof this.props.maxBlocks > "u" ? void 0 : Number.parseInt(this.props.maxBlocks.toString(), 10) || void 0, readOnly = !!this.props.readOnly;
|
|
5581
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
5582
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5599
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5600
|
+
_patches$ ? /* @__PURE__ */ jsxRuntime.jsx(RoutePatchesObservableToEditorActor, { editorActor: this.editorActor, patches$: _patches$ }) : null,
|
|
5601
|
+
/* @__PURE__ */ jsxRuntime.jsx(EditorActorContext.Provider, { value: this.editorActor, children: /* @__PURE__ */ jsxRuntime.jsx(SlateContainer, { editorActor: this.editorActor, maxBlocks, portableTextEditor: this, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorContext.Provider, { value: this, children: /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorReadOnlyContext.Provider, { value: readOnly, children: /* @__PURE__ */ jsxRuntime.jsxs(PortableTextEditorSelectionProvider, { editorActor: this.editorActor, children: [
|
|
5602
|
+
/* @__PURE__ */ jsxRuntime.jsx(Synchronizer, { editorActor: this.editorActor, getValue: this.getValue, onChange: (change) => {
|
|
5603
|
+
this.props.onChange(change), this.change$.next(change);
|
|
5604
|
+
}, value }),
|
|
5605
|
+
children
|
|
5606
|
+
] }) }) }) }) })
|
|
5607
|
+
] });
|
|
5587
5608
|
}
|
|
5588
5609
|
// Static API methods
|
|
5589
5610
|
static activeAnnotations = (editor) => editor && editor.editable ? editor.editable.activeAnnotations() : [];
|
|
@@ -5635,6 +5656,21 @@ class PortableTextEditor extends react.Component {
|
|
|
5635
5656
|
};
|
|
5636
5657
|
static isSelectionsOverlapping = (editor, selectionA, selectionB) => editor.editable?.isSelectionsOverlapping(selectionA, selectionB);
|
|
5637
5658
|
}
|
|
5659
|
+
function RoutePatchesObservableToEditorActor(props) {
|
|
5660
|
+
const $ = reactCompilerRuntime.c(4);
|
|
5661
|
+
let t0, t1;
|
|
5662
|
+
return $[0] !== props.patches$ || $[1] !== props.editorActor ? (t0 = () => {
|
|
5663
|
+
const subscription = props.patches$.subscribe((payload) => {
|
|
5664
|
+
props.editorActor.send({
|
|
5665
|
+
type: "patches",
|
|
5666
|
+
...payload
|
|
5667
|
+
});
|
|
5668
|
+
});
|
|
5669
|
+
return () => {
|
|
5670
|
+
subscription.unsubscribe();
|
|
5671
|
+
};
|
|
5672
|
+
}, t1 = [props.editorActor, props.patches$], $[0] = props.patches$, $[1] = props.editorActor, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), react.useEffect(t0, t1), null;
|
|
5673
|
+
}
|
|
5638
5674
|
const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (props) => {
|
|
5639
5675
|
const {
|
|
5640
5676
|
editorActor,
|