@portabletext/editor 2.1.0 → 2.1.2
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.cjs +15 -39
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +15 -39
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.cts +2 -2
- package/package.json +13 -13
- package/src/editor/PortableTextEditor.tsx +1 -1
- package/src/editor/editor-provider.tsx +14 -8
- package/src/editor/event-to-change.tsx +45 -0
- package/src/plugins/plugin.internal.change-ref.tsx +19 -0
- package/src/editor/route-events-to-changes.tsx +0 -75
package/lib/index.cjs
CHANGED
|
@@ -10084,25 +10084,6 @@ function createActors(config) {
|
|
|
10084
10084
|
syncActor
|
|
10085
10085
|
};
|
|
10086
10086
|
}
|
|
10087
|
-
const RelayActorContext = React.createContext({});
|
|
10088
|
-
function RouteEventsToChanges(props) {
|
|
10089
|
-
const $ = reactCompilerRuntime.c(7);
|
|
10090
|
-
let t0;
|
|
10091
|
-
$[0] !== props ? (t0 = (change) => props.onChange(change), $[0] = props, $[1] = t0) : t0 = $[1];
|
|
10092
|
-
const handleChange = useEffectEvent.useEffectEvent(t0);
|
|
10093
|
-
let t1;
|
|
10094
|
-
$[2] !== handleChange || $[3] !== props.relayActor ? (t1 = () => {
|
|
10095
|
-
const sub = props.relayActor.on("*", (event) => {
|
|
10096
|
-
const change_0 = eventToChange(event);
|
|
10097
|
-
change_0 && handleChange(change_0);
|
|
10098
|
-
});
|
|
10099
|
-
return () => {
|
|
10100
|
-
sub.unsubscribe();
|
|
10101
|
-
};
|
|
10102
|
-
}, $[2] = handleChange, $[3] = props.relayActor, $[4] = t1) : t1 = $[4];
|
|
10103
|
-
let t2;
|
|
10104
|
-
return $[5] !== props.relayActor ? (t2 = [props.relayActor], $[5] = props.relayActor, $[6] = t2) : t2 = $[6], React.useEffect(t1, t2), null;
|
|
10105
|
-
}
|
|
10106
10087
|
function eventToChange(event) {
|
|
10107
10088
|
switch (event.type) {
|
|
10108
10089
|
case "blurred":
|
|
@@ -10148,7 +10129,7 @@ function eventToChange(event) {
|
|
|
10148
10129
|
return event;
|
|
10149
10130
|
}
|
|
10150
10131
|
}
|
|
10151
|
-
const debug$2 = debugWithName("component:PortableTextEditor");
|
|
10132
|
+
const RelayActorContext = React.createContext({}), debug$2 = debugWithName("component:PortableTextEditor");
|
|
10152
10133
|
class PortableTextEditor extends React.Component {
|
|
10153
10134
|
static displayName = "PortableTextEditor";
|
|
10154
10135
|
/**
|
|
@@ -11709,7 +11690,7 @@ function useConstant(factory) {
|
|
|
11709
11690
|
}), ref.current.constant;
|
|
11710
11691
|
}
|
|
11711
11692
|
function EditorProvider(props) {
|
|
11712
|
-
const $ = reactCompilerRuntime.c(
|
|
11693
|
+
const $ = reactCompilerRuntime.c(28);
|
|
11713
11694
|
let t0;
|
|
11714
11695
|
$[0] !== props.initialConfig ? (t0 = () => {
|
|
11715
11696
|
const internalEditor = createInternalEditor(props.initialConfig), portableTextEditor = new PortableTextEditor({
|
|
@@ -11725,37 +11706,32 @@ function EditorProvider(props) {
|
|
|
11725
11706
|
portableTextEditor: portableTextEditor_0
|
|
11726
11707
|
} = useConstant(t0);
|
|
11727
11708
|
let t1;
|
|
11728
|
-
$[2] !== internalEditor_0.actors.editorActor || $[3] !== internalEditor_0.actors.mutationActor || $[4] !== internalEditor_0.actors.relayActor || $[5] !== internalEditor_0.actors.syncActor || $[6] !== internalEditor_0.subscriptions ? (t1 = () => {
|
|
11709
|
+
$[2] !== internalEditor_0.actors.editorActor || $[3] !== internalEditor_0.actors.mutationActor || $[4] !== internalEditor_0.actors.relayActor || $[5] !== internalEditor_0.actors.syncActor || $[6] !== internalEditor_0.subscriptions || $[7] !== portableTextEditor_0 ? (t1 = () => {
|
|
11729
11710
|
const unsubscribers = [];
|
|
11730
11711
|
for (const subscription of internalEditor_0.subscriptions)
|
|
11731
11712
|
unsubscribers.push(subscription());
|
|
11732
|
-
|
|
11713
|
+
const relayActorSubscription = internalEditor_0.actors.relayActor.on("*", (event) => {
|
|
11714
|
+
const change = eventToChange(event);
|
|
11715
|
+
change && portableTextEditor_0.change$.next(change);
|
|
11716
|
+
});
|
|
11717
|
+
return unsubscribers.push(relayActorSubscription.unsubscribe), internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.mutationActor.start(), internalEditor_0.actors.relayActor.start(), internalEditor_0.actors.syncActor.start(), () => {
|
|
11733
11718
|
for (const unsubscribe of unsubscribers)
|
|
11734
11719
|
unsubscribe();
|
|
11735
11720
|
stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.relayActor), stopActor(internalEditor_0.actors.syncActor);
|
|
11736
11721
|
};
|
|
11737
|
-
}, $[2] = internalEditor_0.actors.editorActor, $[3] = internalEditor_0.actors.mutationActor, $[4] = internalEditor_0.actors.relayActor, $[5] = internalEditor_0.actors.syncActor, $[6] = internalEditor_0.subscriptions, $[7] = t1) : t1 = $[
|
|
11722
|
+
}, $[2] = internalEditor_0.actors.editorActor, $[3] = internalEditor_0.actors.mutationActor, $[4] = internalEditor_0.actors.relayActor, $[5] = internalEditor_0.actors.syncActor, $[6] = internalEditor_0.subscriptions, $[7] = portableTextEditor_0, $[8] = t1) : t1 = $[8];
|
|
11738
11723
|
let t2;
|
|
11739
|
-
$[
|
|
11724
|
+
$[9] !== internalEditor_0 || $[10] !== portableTextEditor_0 ? (t2 = [internalEditor_0, portableTextEditor_0], $[9] = internalEditor_0, $[10] = portableTextEditor_0, $[11] = t2) : t2 = $[11], React.useEffect(t1, t2);
|
|
11740
11725
|
let t3;
|
|
11741
|
-
$[
|
|
11742
|
-
portableTextEditor_0.change$.next(change);
|
|
11743
|
-
}, $[10] = portableTextEditor_0.change$, $[11] = t3) : t3 = $[11];
|
|
11726
|
+
$[12] !== portableTextEditor_0 || $[13] !== props.children ? (t3 = /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: props.children }), $[12] = portableTextEditor_0, $[13] = props.children, $[14] = t3) : t3 = $[14];
|
|
11744
11727
|
let t4;
|
|
11745
|
-
$[
|
|
11728
|
+
$[15] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[16] !== internalEditor_0.editor._internal.slateEditor.instance || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(slateReact.Slate, { editor: internalEditor_0.editor._internal.slateEditor.instance, initialValue: internalEditor_0.editor._internal.slateEditor.initialValue, children: t3 }), $[15] = internalEditor_0.editor._internal.slateEditor.initialValue, $[16] = internalEditor_0.editor._internal.slateEditor.instance, $[17] = t3, $[18] = t4) : t4 = $[18];
|
|
11746
11729
|
let t5;
|
|
11747
|
-
$[
|
|
11730
|
+
$[19] !== internalEditor_0.actors.relayActor || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t4 }), $[19] = internalEditor_0.actors.relayActor, $[20] = t4, $[21] = t5) : t5 = $[21];
|
|
11748
11731
|
let t6;
|
|
11749
|
-
$[
|
|
11732
|
+
$[22] !== internalEditor_0.actors.editorActor || $[23] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t5 }), $[22] = internalEditor_0.actors.editorActor, $[23] = t5, $[24] = t6) : t6 = $[24];
|
|
11750
11733
|
let t7;
|
|
11751
|
-
$[
|
|
11752
|
-
let t8;
|
|
11753
|
-
$[25] !== internalEditor_0.actors.editorActor || $[26] !== t7 ? (t8 = /* @__PURE__ */ jsxRuntime.jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t7 }), $[25] = internalEditor_0.actors.editorActor, $[26] = t7, $[27] = t8) : t8 = $[27];
|
|
11754
|
-
let t9;
|
|
11755
|
-
return $[28] !== internalEditor_0.editor || $[29] !== t4 || $[30] !== t8 ? (t9 = /* @__PURE__ */ jsxRuntime.jsxs(useEditor.EditorContext.Provider, { value: internalEditor_0.editor, children: [
|
|
11756
|
-
t4,
|
|
11757
|
-
t8
|
|
11758
|
-
] }), $[28] = internalEditor_0.editor, $[29] = t4, $[30] = t8, $[31] = t9) : t9 = $[31], t9;
|
|
11734
|
+
return $[25] !== internalEditor_0.editor || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(useEditor.EditorContext.Provider, { value: internalEditor_0.editor, children: t6 }), $[25] = internalEditor_0.editor, $[26] = t6, $[27] = t7) : t7 = $[27], t7;
|
|
11759
11735
|
}
|
|
11760
11736
|
function defineSchema(definition) {
|
|
11761
11737
|
return definition;
|