@portabletext/editor 2.1.1 → 2.1.3
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-dts/behavior.types.action.d.cts +9 -9
- package/lib/index.cjs +20 -43
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +20 -43
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/package.json +7 -7
- package/src/behaviors/behavior.abstract.list-item.ts +10 -2
- 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.js
CHANGED
|
@@ -6787,10 +6787,11 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
|
|
|
6787
6787
|
], abstractListItemBehaviors = [defineBehavior({
|
|
6788
6788
|
on: "list item.add",
|
|
6789
6789
|
guard: ({
|
|
6790
|
-
snapshot
|
|
6791
|
-
|
|
6790
|
+
snapshot,
|
|
6791
|
+
event
|
|
6792
|
+
}) => snapshot.context.schema.lists.some((list) => list.name === event.listItem) ? {
|
|
6792
6793
|
selectedTextBlocks: getSelectedTextBlocks(snapshot)
|
|
6793
|
-
}
|
|
6794
|
+
} : !1,
|
|
6794
6795
|
actions: [({
|
|
6795
6796
|
event
|
|
6796
6797
|
}, {
|
|
@@ -6799,7 +6800,7 @@ const MAX_LIST_LEVEL = 10, clearListOnBackspace = defineBehavior({
|
|
|
6799
6800
|
type: "block.set",
|
|
6800
6801
|
at: block.path,
|
|
6801
6802
|
props: {
|
|
6802
|
-
level: 1,
|
|
6803
|
+
level: block.node.level ?? 1,
|
|
6803
6804
|
listItem: event.listItem
|
|
6804
6805
|
}
|
|
6805
6806
|
}))]
|
|
@@ -10114,25 +10115,6 @@ function createActors(config) {
|
|
|
10114
10115
|
syncActor
|
|
10115
10116
|
};
|
|
10116
10117
|
}
|
|
10117
|
-
const RelayActorContext = createContext({});
|
|
10118
|
-
function RouteEventsToChanges(props) {
|
|
10119
|
-
const $ = c(7);
|
|
10120
|
-
let t0;
|
|
10121
|
-
$[0] !== props ? (t0 = (change) => props.onChange(change), $[0] = props, $[1] = t0) : t0 = $[1];
|
|
10122
|
-
const handleChange = useEffectEvent(t0);
|
|
10123
|
-
let t1;
|
|
10124
|
-
$[2] !== handleChange || $[3] !== props.relayActor ? (t1 = () => {
|
|
10125
|
-
const sub = props.relayActor.on("*", (event) => {
|
|
10126
|
-
const change_0 = eventToChange(event);
|
|
10127
|
-
change_0 && handleChange(change_0);
|
|
10128
|
-
});
|
|
10129
|
-
return () => {
|
|
10130
|
-
sub.unsubscribe();
|
|
10131
|
-
};
|
|
10132
|
-
}, $[2] = handleChange, $[3] = props.relayActor, $[4] = t1) : t1 = $[4];
|
|
10133
|
-
let t2;
|
|
10134
|
-
return $[5] !== props.relayActor ? (t2 = [props.relayActor], $[5] = props.relayActor, $[6] = t2) : t2 = $[6], useEffect(t1, t2), null;
|
|
10135
|
-
}
|
|
10136
10118
|
function eventToChange(event) {
|
|
10137
10119
|
switch (event.type) {
|
|
10138
10120
|
case "blurred":
|
|
@@ -10178,7 +10160,7 @@ function eventToChange(event) {
|
|
|
10178
10160
|
return event;
|
|
10179
10161
|
}
|
|
10180
10162
|
}
|
|
10181
|
-
const debug$2 = debugWithName("component:PortableTextEditor");
|
|
10163
|
+
const RelayActorContext = createContext({}), debug$2 = debugWithName("component:PortableTextEditor");
|
|
10182
10164
|
class PortableTextEditor extends Component {
|
|
10183
10165
|
static displayName = "PortableTextEditor";
|
|
10184
10166
|
/**
|
|
@@ -11739,7 +11721,7 @@ function useConstant(factory) {
|
|
|
11739
11721
|
}), ref.current.constant;
|
|
11740
11722
|
}
|
|
11741
11723
|
function EditorProvider(props) {
|
|
11742
|
-
const $ = c(
|
|
11724
|
+
const $ = c(28);
|
|
11743
11725
|
let t0;
|
|
11744
11726
|
$[0] !== props.initialConfig ? (t0 = () => {
|
|
11745
11727
|
const internalEditor = createInternalEditor(props.initialConfig), portableTextEditor = new PortableTextEditor({
|
|
@@ -11755,37 +11737,32 @@ function EditorProvider(props) {
|
|
|
11755
11737
|
portableTextEditor: portableTextEditor_0
|
|
11756
11738
|
} = useConstant(t0);
|
|
11757
11739
|
let t1;
|
|
11758
|
-
$[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 = () => {
|
|
11740
|
+
$[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 = () => {
|
|
11759
11741
|
const unsubscribers = [];
|
|
11760
11742
|
for (const subscription of internalEditor_0.subscriptions)
|
|
11761
11743
|
unsubscribers.push(subscription());
|
|
11762
|
-
|
|
11744
|
+
const relayActorSubscription = internalEditor_0.actors.relayActor.on("*", (event) => {
|
|
11745
|
+
const change = eventToChange(event);
|
|
11746
|
+
change && portableTextEditor_0.change$.next(change);
|
|
11747
|
+
});
|
|
11748
|
+
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(), () => {
|
|
11763
11749
|
for (const unsubscribe of unsubscribers)
|
|
11764
11750
|
unsubscribe();
|
|
11765
11751
|
stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.relayActor), stopActor(internalEditor_0.actors.syncActor);
|
|
11766
11752
|
};
|
|
11767
|
-
}, $[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 = $[
|
|
11753
|
+
}, $[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];
|
|
11768
11754
|
let t2;
|
|
11769
|
-
$[
|
|
11755
|
+
$[9] !== internalEditor_0 || $[10] !== portableTextEditor_0 ? (t2 = [internalEditor_0, portableTextEditor_0], $[9] = internalEditor_0, $[10] = portableTextEditor_0, $[11] = t2) : t2 = $[11], useEffect(t1, t2);
|
|
11770
11756
|
let t3;
|
|
11771
|
-
$[
|
|
11772
|
-
portableTextEditor_0.change$.next(change);
|
|
11773
|
-
}, $[10] = portableTextEditor_0.change$, $[11] = t3) : t3 = $[11];
|
|
11757
|
+
$[12] !== portableTextEditor_0 || $[13] !== props.children ? (t3 = /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: props.children }), $[12] = portableTextEditor_0, $[13] = props.children, $[14] = t3) : t3 = $[14];
|
|
11774
11758
|
let t4;
|
|
11775
|
-
$[
|
|
11759
|
+
$[15] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[16] !== internalEditor_0.editor._internal.slateEditor.instance || $[17] !== t3 ? (t4 = /* @__PURE__ */ jsx(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];
|
|
11776
11760
|
let t5;
|
|
11777
|
-
$[
|
|
11761
|
+
$[19] !== internalEditor_0.actors.relayActor || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t4 }), $[19] = internalEditor_0.actors.relayActor, $[20] = t4, $[21] = t5) : t5 = $[21];
|
|
11778
11762
|
let t6;
|
|
11779
|
-
$[
|
|
11763
|
+
$[22] !== internalEditor_0.actors.editorActor || $[23] !== t5 ? (t6 = /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t5 }), $[22] = internalEditor_0.actors.editorActor, $[23] = t5, $[24] = t6) : t6 = $[24];
|
|
11780
11764
|
let t7;
|
|
11781
|
-
$[
|
|
11782
|
-
let t8;
|
|
11783
|
-
$[25] !== internalEditor_0.actors.editorActor || $[26] !== t7 ? (t8 = /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t7 }), $[25] = internalEditor_0.actors.editorActor, $[26] = t7, $[27] = t8) : t8 = $[27];
|
|
11784
|
-
let t9;
|
|
11785
|
-
return $[28] !== internalEditor_0.editor || $[29] !== t4 || $[30] !== t8 ? (t9 = /* @__PURE__ */ jsxs(EditorContext.Provider, { value: internalEditor_0.editor, children: [
|
|
11786
|
-
t4,
|
|
11787
|
-
t8
|
|
11788
|
-
] }), $[28] = internalEditor_0.editor, $[29] = t4, $[30] = t8, $[31] = t9) : t9 = $[31], t9;
|
|
11765
|
+
return $[25] !== internalEditor_0.editor || $[26] !== t6 ? (t7 = /* @__PURE__ */ jsx(EditorContext.Provider, { value: internalEditor_0.editor, children: t6 }), $[25] = internalEditor_0.editor, $[26] = t6, $[27] = t7) : t7 = $[27], t7;
|
|
11789
11766
|
}
|
|
11790
11767
|
function defineSchema(definition) {
|
|
11791
11768
|
return definition;
|