@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.esm.js
CHANGED
|
@@ -2752,16 +2752,16 @@ const debug$h = debugWithName("plugin:withUndoRedo"), debugVerbose$3 = debug$h.e
|
|
|
2752
2752
|
}, getRemotePatches = (editor) => (REMOTE_PATCHES.get(editor) || REMOTE_PATCHES.set(editor, []), REMOTE_PATCHES.get(editor) || []);
|
|
2753
2753
|
function createWithUndoRedo(options) {
|
|
2754
2754
|
const {
|
|
2755
|
+
editorActor,
|
|
2755
2756
|
readOnly,
|
|
2756
|
-
patches$,
|
|
2757
2757
|
blockSchemaType
|
|
2758
2758
|
} = options;
|
|
2759
2759
|
return (editor) => {
|
|
2760
2760
|
let previousSnapshot = fromSlateValue(editor.children, blockSchemaType.name);
|
|
2761
2761
|
const remotePatches = getRemotePatches(editor);
|
|
2762
|
-
|
|
2762
|
+
editor.subscriptions.push(() => {
|
|
2763
2763
|
debug$h("Subscribing to patches");
|
|
2764
|
-
const sub = patches
|
|
2764
|
+
const sub = editorActor.on("patches", ({
|
|
2765
2765
|
patches,
|
|
2766
2766
|
snapshot
|
|
2767
2767
|
}) => {
|
|
@@ -3001,7 +3001,6 @@ function findOperationTargetBlock(editor, operation) {
|
|
|
3001
3001
|
const debug$g = debugWithName("plugin:withPatches");
|
|
3002
3002
|
function createWithPatches({
|
|
3003
3003
|
editorActor,
|
|
3004
|
-
patches$,
|
|
3005
3004
|
patchFunctions,
|
|
3006
3005
|
readOnly,
|
|
3007
3006
|
schemaTypes
|
|
@@ -3037,11 +3036,11 @@ function createWithPatches({
|
|
|
3037
3036
|
const remotePatches = patches.filter((p) => p.origin !== "local");
|
|
3038
3037
|
remotePatches.length !== 0 && (bufferedPatches = bufferedPatches.concat(remotePatches), handleBufferedRemotePatches());
|
|
3039
3038
|
};
|
|
3040
|
-
return
|
|
3041
|
-
debug$g("Subscribing to patches
|
|
3042
|
-
const sub = patches
|
|
3039
|
+
return editor.subscriptions.push(() => {
|
|
3040
|
+
debug$g("Subscribing to remote patches");
|
|
3041
|
+
const sub = editorActor.on("patches", handlePatches);
|
|
3043
3042
|
return () => {
|
|
3044
|
-
debug$g("Unsubscribing to patches
|
|
3043
|
+
debug$g("Unsubscribing to remote patches"), sub.unsubscribe();
|
|
3045
3044
|
};
|
|
3046
3045
|
}), editor.apply = (operation) => {
|
|
3047
3046
|
if (readOnly)
|
|
@@ -4530,7 +4529,6 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
4530
4529
|
const e = editor, {
|
|
4531
4530
|
editorActor,
|
|
4532
4531
|
portableTextEditor,
|
|
4533
|
-
patches$,
|
|
4534
4532
|
readOnly,
|
|
4535
4533
|
maxBlocks
|
|
4536
4534
|
} = options, {
|
|
@@ -4546,13 +4544,12 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
4546
4544
|
schemaTypes
|
|
4547
4545
|
}), withEditableAPI = createWithEditableAPI(editorActor, portableTextEditor, schemaTypes), withPatches = createWithPatches({
|
|
4548
4546
|
editorActor,
|
|
4549
|
-
patches$,
|
|
4550
4547
|
patchFunctions: operationToPatches,
|
|
4551
4548
|
readOnly,
|
|
4552
4549
|
schemaTypes
|
|
4553
4550
|
}), withMaxBlocks = createWithMaxBlocks(maxBlocks || -1), withPortableTextLists = createWithPortableTextLists(schemaTypes), withUndoRedo = createWithUndoRedo({
|
|
4551
|
+
editorActor,
|
|
4554
4552
|
readOnly,
|
|
4555
|
-
patches$,
|
|
4556
4553
|
blockSchemaType: schemaTypes.block
|
|
4557
4554
|
}), withPortableTextMarkModel = createWithPortableTextMarkModel(editorActor, schemaTypes), withPortableTextBlockStyle = createWithPortableTextBlockStyle(editorActor, schemaTypes), withPlaceholderBlock = createWithPlaceholderBlock(), withUtils = createWithUtils({
|
|
4558
4555
|
editorActor,
|
|
@@ -4585,15 +4582,14 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
4585
4582
|
};
|
|
4586
4583
|
}, debug$6 = debugWithName("component:PortableTextEditor:SlateContainer");
|
|
4587
4584
|
function SlateContainer(props) {
|
|
4588
|
-
const $ = c(
|
|
4585
|
+
const $ = c(26), {
|
|
4589
4586
|
editorActor,
|
|
4590
|
-
patches$,
|
|
4591
4587
|
portableTextEditor,
|
|
4592
4588
|
readOnly,
|
|
4593
4589
|
maxBlocks
|
|
4594
4590
|
} = props;
|
|
4595
4591
|
let t0;
|
|
4596
|
-
$[0] !== editorActor || $[1] !== maxBlocks || $[2] !==
|
|
4592
|
+
$[0] !== editorActor || $[1] !== maxBlocks || $[2] !== portableTextEditor || $[3] !== readOnly ? (t0 = () => {
|
|
4597
4593
|
debug$6("Creating new Slate editor instance");
|
|
4598
4594
|
const {
|
|
4599
4595
|
editor,
|
|
@@ -4601,43 +4597,41 @@ function SlateContainer(props) {
|
|
|
4601
4597
|
} = withPlugins(withReact(createEditor()), {
|
|
4602
4598
|
editorActor,
|
|
4603
4599
|
maxBlocks,
|
|
4604
|
-
patches$,
|
|
4605
4600
|
portableTextEditor,
|
|
4606
4601
|
readOnly
|
|
4607
4602
|
});
|
|
4608
4603
|
return KEY_TO_VALUE_ELEMENT.set(editor, {}), KEY_TO_SLATE_ELEMENT.set(editor, {}), [editor, _sub];
|
|
4609
|
-
}, $[0] = editorActor, $[1] = maxBlocks, $[2] =
|
|
4604
|
+
}, $[0] = editorActor, $[1] = maxBlocks, $[2] = portableTextEditor, $[3] = readOnly, $[4] = t0) : t0 = $[4];
|
|
4610
4605
|
const [t1] = useState(t0), [slateEditor, subscribe] = t1;
|
|
4611
4606
|
let t2, t3;
|
|
4612
|
-
$[
|
|
4607
|
+
$[5] !== subscribe ? (t2 = () => {
|
|
4613
4608
|
const unsubscribe = subscribe();
|
|
4614
4609
|
return () => {
|
|
4615
4610
|
unsubscribe();
|
|
4616
4611
|
};
|
|
4617
|
-
}, t3 = [subscribe], $[
|
|
4612
|
+
}, t3 = [subscribe], $[5] = subscribe, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), useEffect(t2, t3);
|
|
4618
4613
|
let t4, t5;
|
|
4619
|
-
$[
|
|
4614
|
+
$[8] !== slateEditor || $[9] !== editorActor || $[10] !== maxBlocks || $[11] !== portableTextEditor || $[12] !== readOnly ? (t4 = () => {
|
|
4620
4615
|
debug$6("Re-initializing plugin chain"), withPlugins(slateEditor, {
|
|
4621
4616
|
editorActor,
|
|
4622
4617
|
maxBlocks,
|
|
4623
|
-
patches$,
|
|
4624
4618
|
portableTextEditor,
|
|
4625
4619
|
readOnly
|
|
4626
4620
|
});
|
|
4627
|
-
}, t5 = [editorActor, portableTextEditor, maxBlocks, readOnly,
|
|
4621
|
+
}, t5 = [editorActor, portableTextEditor, maxBlocks, readOnly, slateEditor], $[8] = slateEditor, $[9] = editorActor, $[10] = maxBlocks, $[11] = portableTextEditor, $[12] = readOnly, $[13] = t4, $[14] = t5) : (t4 = $[13], t5 = $[14]), useEffect(t4, t5);
|
|
4628
4622
|
let t6, t7;
|
|
4629
|
-
$[
|
|
4623
|
+
$[15] !== slateEditor ? (t7 = slateEditor.pteCreateTextBlock({
|
|
4630
4624
|
decorators: []
|
|
4631
|
-
}), $[
|
|
4625
|
+
}), $[15] = slateEditor, $[16] = t7) : t7 = $[16];
|
|
4632
4626
|
let t8;
|
|
4633
|
-
$[
|
|
4627
|
+
$[17] !== t7 ? (t8 = [t7], $[17] = t7, $[18] = t8) : t8 = $[18], t6 = t8;
|
|
4634
4628
|
const initialValue = t6;
|
|
4635
4629
|
let t9, t10;
|
|
4636
|
-
$[
|
|
4630
|
+
$[19] !== slateEditor ? (t9 = () => () => {
|
|
4637
4631
|
debug$6("Destroying Slate editor"), slateEditor.destroy();
|
|
4638
|
-
}, t10 = [slateEditor], $[
|
|
4632
|
+
}, t10 = [slateEditor], $[19] = slateEditor, $[20] = t9, $[21] = t10) : (t9 = $[20], t10 = $[21]), useEffect(t9, t10);
|
|
4639
4633
|
let t11;
|
|
4640
|
-
return $[
|
|
4634
|
+
return $[22] !== slateEditor || $[23] !== initialValue || $[24] !== props.children ? (t11 = /* @__PURE__ */ jsx(Slate, { editor: slateEditor, initialValue, children: props.children }), $[22] = slateEditor, $[23] = initialValue, $[24] = props.children, $[25] = t11) : t11 = $[25], t11;
|
|
4641
4635
|
}
|
|
4642
4636
|
SlateContainer.displayName = "SlateContainer";
|
|
4643
4637
|
const PortableTextEditorReadOnlyContext = createContext(!1), usePortableTextEditorReadOnlyStatus = () => {
|
|
@@ -4834,20 +4828,28 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
|
|
|
4834
4828
|
}
|
|
4835
4829
|
const debug$4 = debugWithName("component:PortableTextEditor:Synchronizer"), debugVerbose$1 = debug$4.enabled && !1, FLUSH_PATCHES_THROTTLED_MS = process.env.NODE_ENV === "test" ? 500 : 1e3;
|
|
4836
4830
|
function Synchronizer(props) {
|
|
4837
|
-
const portableTextEditor = usePortableTextEditor(), readOnly = usePortableTextEditorReadOnlyStatus(), {
|
|
4831
|
+
const $ = c(35), portableTextEditor = usePortableTextEditor(), readOnly = usePortableTextEditorReadOnlyStatus(), {
|
|
4838
4832
|
editorActor,
|
|
4839
4833
|
getValue,
|
|
4840
4834
|
onChange,
|
|
4841
4835
|
value
|
|
4842
|
-
} = props
|
|
4836
|
+
} = props;
|
|
4837
|
+
let t0;
|
|
4838
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
|
|
4839
|
+
const pendingPatches = useRef(t0);
|
|
4840
|
+
let t1;
|
|
4841
|
+
$[1] !== editorActor || $[2] !== portableTextEditor || $[3] !== readOnly ? (t1 = {
|
|
4843
4842
|
editorActor,
|
|
4844
4843
|
portableTextEditor,
|
|
4845
4844
|
readOnly
|
|
4846
|
-
}
|
|
4847
|
-
|
|
4845
|
+
}, $[1] = editorActor, $[2] = portableTextEditor, $[3] = readOnly, $[4] = t1) : t1 = $[4];
|
|
4846
|
+
const syncValue = useSyncValue(t1), slateEditor = useSlate();
|
|
4847
|
+
let t2, t3;
|
|
4848
|
+
$[5] !== slateEditor ? (t2 = () => {
|
|
4848
4849
|
IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !1);
|
|
4849
|
-
}, [slateEditor]);
|
|
4850
|
-
|
|
4850
|
+
}, t3 = [slateEditor], $[5] = slateEditor, $[6] = t2, $[7] = t3) : (t2 = $[6], t3 = $[7]), useEffect(t2, t3);
|
|
4851
|
+
let t4;
|
|
4852
|
+
$[8] !== getValue || $[9] !== editorActor || $[10] !== slateEditor ? (t4 = () => {
|
|
4851
4853
|
if (pendingPatches.current.length > 0) {
|
|
4852
4854
|
debug$4("Flushing pending patches"), debugVerbose$1 && debug$4(`Patches:
|
|
4853
4855
|
${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
@@ -4859,61 +4861,68 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
|
4859
4861
|
}), pendingPatches.current = [];
|
|
4860
4862
|
}
|
|
4861
4863
|
IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !1);
|
|
4862
|
-
}, [editorActor, slateEditor,
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
}
|
|
4867
|
-
onFlushPendingPatchesThrottled();
|
|
4868
|
-
}, FLUSH_PATCHES_THROTTLED_MS, {
|
|
4869
|
-
leading: !1,
|
|
4870
|
-
trailing: !0
|
|
4871
|
-
}), [onFlushPendingPatches, slateEditor]);
|
|
4872
|
-
useEffect(() => () => {
|
|
4864
|
+
}, $[8] = getValue, $[9] = editorActor, $[10] = slateEditor, $[11] = t4) : t4 = $[11];
|
|
4865
|
+
const onFlushPendingPatches = t4;
|
|
4866
|
+
let t5, t6;
|
|
4867
|
+
$[12] !== onFlushPendingPatches ? (t5 = () => () => {
|
|
4873
4868
|
onFlushPendingPatches();
|
|
4874
|
-
}, [onFlushPendingPatches]);
|
|
4875
|
-
|
|
4876
|
-
|
|
4869
|
+
}, t6 = [onFlushPendingPatches], $[12] = onFlushPendingPatches, $[13] = t5, $[14] = t6) : (t5 = $[13], t6 = $[14]), useEffect(t5, t6);
|
|
4870
|
+
let t7;
|
|
4871
|
+
$[15] !== onChange ? (t7 = (change) => onChange(change), $[15] = onChange, $[16] = t7) : t7 = $[16];
|
|
4872
|
+
const handleChange = useEffectEvent(t7);
|
|
4873
|
+
let t8, t9;
|
|
4874
|
+
$[17] !== slateEditor || $[18] !== onFlushPendingPatches || $[19] !== editorActor || $[20] !== handleChange ? (t8 = () => {
|
|
4875
|
+
const onFlushPendingPatchesThrottled = throttle(() => {
|
|
4876
|
+
if (Editor.isNormalizing(slateEditor)) {
|
|
4877
|
+
onFlushPendingPatches();
|
|
4878
|
+
return;
|
|
4879
|
+
}
|
|
4880
|
+
onFlushPendingPatchesThrottled();
|
|
4881
|
+
}, FLUSH_PATCHES_THROTTLED_MS, {
|
|
4882
|
+
leading: !1,
|
|
4883
|
+
trailing: !0
|
|
4884
|
+
});
|
|
4877
4885
|
debug$4("Subscribing to editor changes");
|
|
4878
4886
|
const sub = editorActor.on("*", (event) => {
|
|
4879
|
-
switch (event.type) {
|
|
4880
|
-
case "patch":
|
|
4887
|
+
bb18: switch (event.type) {
|
|
4888
|
+
case "patch": {
|
|
4881
4889
|
IS_PROCESSING_LOCAL_CHANGES.set(slateEditor, !0), pendingPatches.current.push(event.patch), onFlushPendingPatchesThrottled(), handleChange(event);
|
|
4882
|
-
break;
|
|
4890
|
+
break bb18;
|
|
4891
|
+
}
|
|
4883
4892
|
case "loading": {
|
|
4884
4893
|
handleChange({
|
|
4885
4894
|
type: "loading",
|
|
4886
4895
|
isLoading: !0
|
|
4887
4896
|
});
|
|
4888
|
-
break;
|
|
4897
|
+
break bb18;
|
|
4889
4898
|
}
|
|
4890
4899
|
case "done loading": {
|
|
4891
4900
|
handleChange({
|
|
4892
4901
|
type: "loading",
|
|
4893
4902
|
isLoading: !1
|
|
4894
4903
|
});
|
|
4895
|
-
break;
|
|
4904
|
+
break bb18;
|
|
4896
4905
|
}
|
|
4897
4906
|
case "offline": {
|
|
4898
4907
|
handleChange({
|
|
4899
4908
|
type: "connection",
|
|
4900
4909
|
value: "offline"
|
|
4901
4910
|
});
|
|
4902
|
-
break;
|
|
4911
|
+
break bb18;
|
|
4903
4912
|
}
|
|
4904
4913
|
case "online": {
|
|
4905
4914
|
handleChange({
|
|
4906
4915
|
type: "connection",
|
|
4907
4916
|
value: "online"
|
|
4908
4917
|
});
|
|
4909
|
-
break;
|
|
4918
|
+
break bb18;
|
|
4910
4919
|
}
|
|
4911
4920
|
case "value changed": {
|
|
4912
4921
|
handleChange({
|
|
4913
4922
|
type: "value",
|
|
4914
4923
|
value: event.value
|
|
4915
4924
|
});
|
|
4916
|
-
break;
|
|
4925
|
+
break bb18;
|
|
4917
4926
|
}
|
|
4918
4927
|
case "invalid value": {
|
|
4919
4928
|
handleChange({
|
|
@@ -4921,15 +4930,17 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
|
4921
4930
|
resolution: event.resolution,
|
|
4922
4931
|
value: event.value
|
|
4923
4932
|
});
|
|
4924
|
-
break;
|
|
4933
|
+
break bb18;
|
|
4925
4934
|
}
|
|
4926
4935
|
case "error": {
|
|
4927
4936
|
handleChange({
|
|
4928
4937
|
...event,
|
|
4929
4938
|
level: "warning"
|
|
4930
4939
|
});
|
|
4931
|
-
break;
|
|
4940
|
+
break bb18;
|
|
4932
4941
|
}
|
|
4942
|
+
case "patches":
|
|
4943
|
+
break bb18;
|
|
4933
4944
|
default:
|
|
4934
4945
|
handleChange(event);
|
|
4935
4946
|
}
|
|
@@ -4937,24 +4948,26 @@ ${JSON.stringify(pendingPatches.current, null, 2)}`);
|
|
|
4937
4948
|
return () => {
|
|
4938
4949
|
debug$4("Unsubscribing to changes"), sub.unsubscribe();
|
|
4939
4950
|
};
|
|
4940
|
-
}, [handleChange,
|
|
4941
|
-
|
|
4951
|
+
}, t9 = [editorActor, handleChange, onFlushPendingPatches, slateEditor], $[17] = slateEditor, $[18] = onFlushPendingPatches, $[19] = editorActor, $[20] = handleChange, $[21] = t8, $[22] = t9) : (t8 = $[21], t9 = $[22]), useEffect(t8, t9);
|
|
4952
|
+
let t10;
|
|
4953
|
+
$[23] !== syncValue || $[24] !== value ? (t10 = () => {
|
|
4942
4954
|
debug$4("Editor is online, syncing from props.value"), syncValue(value);
|
|
4943
|
-
}, [syncValue, value]);
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4955
|
+
}, $[23] = syncValue, $[24] = value, $[25] = t10) : t10 = $[25];
|
|
4956
|
+
const handleOnline = t10;
|
|
4957
|
+
let t11, t12;
|
|
4958
|
+
$[26] !== editorActor || $[27] !== handleOnline ? (t11 = () => {
|
|
4959
|
+
const subscription = editorActor.on("online", handleOnline);
|
|
4948
4960
|
return () => {
|
|
4949
4961
|
subscription.unsubscribe();
|
|
4950
4962
|
};
|
|
4951
|
-
}, [handleOnline, editorActor,
|
|
4963
|
+
}, t12 = [handleOnline, editorActor], $[26] = editorActor, $[27] = handleOnline, $[28] = t11, $[29] = t12) : (t11 = $[28], t12 = $[29]), useEffect(t11, t12);
|
|
4952
4964
|
const isInitialValueFromProps = useRef(!0);
|
|
4953
|
-
|
|
4965
|
+
let t13, t14;
|
|
4966
|
+
return $[30] !== syncValue || $[31] !== value || $[32] !== editorActor ? (t13 = () => {
|
|
4954
4967
|
debug$4("Value from props changed, syncing new value"), syncValue(value), isInitialValueFromProps.current && (editorActor.send({
|
|
4955
4968
|
type: "ready"
|
|
4956
4969
|
}), isInitialValueFromProps.current = !1);
|
|
4957
|
-
}, [editorActor, syncValue, value]), null;
|
|
4970
|
+
}, t14 = [editorActor, syncValue, value], $[30] = syncValue, $[31] = value, $[32] = editorActor, $[33] = t13, $[34] = t14) : (t13 = $[33], t14 = $[34]), useEffect(t13, t14), null;
|
|
4958
4971
|
}
|
|
4959
4972
|
Synchronizer.displayName = "Synchronizer";
|
|
4960
4973
|
const EditorActorContext = createContext({}), insertBreakActionImplementation = ({
|
|
@@ -5449,6 +5462,11 @@ const networkLogic = fromCallback(({
|
|
|
5449
5462
|
type: "loading"
|
|
5450
5463
|
})
|
|
5451
5464
|
},
|
|
5465
|
+
patches: {
|
|
5466
|
+
actions: emit(({
|
|
5467
|
+
event
|
|
5468
|
+
}) => event)
|
|
5469
|
+
},
|
|
5452
5470
|
"done loading": {
|
|
5453
5471
|
actions: emit({
|
|
5454
5472
|
type: "done loading"
|
|
@@ -5597,12 +5615,15 @@ class PortableTextEditor extends Component {
|
|
|
5597
5615
|
patches$,
|
|
5598
5616
|
incomingPatches$
|
|
5599
5617
|
} = 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;
|
|
5600
|
-
return /* @__PURE__ */
|
|
5601
|
-
/* @__PURE__ */ jsx(
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5618
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5619
|
+
_patches$ ? /* @__PURE__ */ jsx(RoutePatchesObservableToEditorActor, { editorActor: this.editorActor, patches$: _patches$ }) : null,
|
|
5620
|
+
/* @__PURE__ */ jsx(EditorActorContext.Provider, { value: this.editorActor, children: /* @__PURE__ */ jsx(SlateContainer, { editorActor: this.editorActor, maxBlocks, portableTextEditor: this, readOnly, children: /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: this, children: /* @__PURE__ */ jsx(PortableTextEditorReadOnlyContext.Provider, { value: readOnly, children: /* @__PURE__ */ jsxs(PortableTextEditorSelectionProvider, { editorActor: this.editorActor, children: [
|
|
5621
|
+
/* @__PURE__ */ jsx(Synchronizer, { editorActor: this.editorActor, getValue: this.getValue, onChange: (change) => {
|
|
5622
|
+
this.props.onChange(change), this.change$.next(change);
|
|
5623
|
+
}, value }),
|
|
5624
|
+
children
|
|
5625
|
+
] }) }) }) }) })
|
|
5626
|
+
] });
|
|
5606
5627
|
}
|
|
5607
5628
|
// Static API methods
|
|
5608
5629
|
static activeAnnotations = (editor) => editor && editor.editable ? editor.editable.activeAnnotations() : [];
|
|
@@ -5654,6 +5675,21 @@ class PortableTextEditor extends Component {
|
|
|
5654
5675
|
};
|
|
5655
5676
|
static isSelectionsOverlapping = (editor, selectionA, selectionB) => editor.editable?.isSelectionsOverlapping(selectionA, selectionB);
|
|
5656
5677
|
}
|
|
5678
|
+
function RoutePatchesObservableToEditorActor(props) {
|
|
5679
|
+
const $ = c(4);
|
|
5680
|
+
let t0, t1;
|
|
5681
|
+
return $[0] !== props.patches$ || $[1] !== props.editorActor ? (t0 = () => {
|
|
5682
|
+
const subscription = props.patches$.subscribe((payload) => {
|
|
5683
|
+
props.editorActor.send({
|
|
5684
|
+
type: "patches",
|
|
5685
|
+
...payload
|
|
5686
|
+
});
|
|
5687
|
+
});
|
|
5688
|
+
return () => {
|
|
5689
|
+
subscription.unsubscribe();
|
|
5690
|
+
};
|
|
5691
|
+
}, t1 = [props.editorActor, props.patches$], $[0] = props.patches$, $[1] = props.editorActor, $[2] = t0, $[3] = t1) : (t0 = $[2], t1 = $[3]), useEffect(t0, t1), null;
|
|
5692
|
+
}
|
|
5657
5693
|
const debug$1 = debugWithName("components:Leaf"), EMPTY_MARKS = [], Leaf = (props) => {
|
|
5658
5694
|
const {
|
|
5659
5695
|
editorActor,
|