@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.js CHANGED
@@ -10114,25 +10114,6 @@ function createActors(config) {
10114
10114
  syncActor
10115
10115
  };
10116
10116
  }
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
10117
  function eventToChange(event) {
10137
10118
  switch (event.type) {
10138
10119
  case "blurred":
@@ -10178,7 +10159,7 @@ function eventToChange(event) {
10178
10159
  return event;
10179
10160
  }
10180
10161
  }
10181
- const debug$2 = debugWithName("component:PortableTextEditor");
10162
+ const RelayActorContext = createContext({}), debug$2 = debugWithName("component:PortableTextEditor");
10182
10163
  class PortableTextEditor extends Component {
10183
10164
  static displayName = "PortableTextEditor";
10184
10165
  /**
@@ -11739,7 +11720,7 @@ function useConstant(factory) {
11739
11720
  }), ref.current.constant;
11740
11721
  }
11741
11722
  function EditorProvider(props) {
11742
- const $ = c(32);
11723
+ const $ = c(28);
11743
11724
  let t0;
11744
11725
  $[0] !== props.initialConfig ? (t0 = () => {
11745
11726
  const internalEditor = createInternalEditor(props.initialConfig), portableTextEditor = new PortableTextEditor({
@@ -11755,37 +11736,32 @@ function EditorProvider(props) {
11755
11736
  portableTextEditor: portableTextEditor_0
11756
11737
  } = useConstant(t0);
11757
11738
  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 = () => {
11739
+ $[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
11740
  const unsubscribers = [];
11760
11741
  for (const subscription of internalEditor_0.subscriptions)
11761
11742
  unsubscribers.push(subscription());
11762
- return internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.mutationActor.start(), internalEditor_0.actors.relayActor.start(), internalEditor_0.actors.syncActor.start(), () => {
11743
+ const relayActorSubscription = internalEditor_0.actors.relayActor.on("*", (event) => {
11744
+ const change = eventToChange(event);
11745
+ change && portableTextEditor_0.change$.next(change);
11746
+ });
11747
+ 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
11748
  for (const unsubscribe of unsubscribers)
11764
11749
  unsubscribe();
11765
11750
  stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.relayActor), stopActor(internalEditor_0.actors.syncActor);
11766
11751
  };
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 = $[7];
11752
+ }, $[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
11753
  let t2;
11769
- $[8] !== internalEditor_0 ? (t2 = [internalEditor_0], $[8] = internalEditor_0, $[9] = t2) : t2 = $[9], useEffect(t1, t2);
11754
+ $[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
11755
  let t3;
11771
- $[10] !== portableTextEditor_0.change$ ? (t3 = (change) => {
11772
- portableTextEditor_0.change$.next(change);
11773
- }, $[10] = portableTextEditor_0.change$, $[11] = t3) : t3 = $[11];
11756
+ $[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
11757
  let t4;
11775
- $[12] !== internalEditor_0.actors.relayActor || $[13] !== t3 ? (t4 = /* @__PURE__ */ jsx(RouteEventsToChanges, { relayActor: internalEditor_0.actors.relayActor, onChange: t3 }), $[12] = internalEditor_0.actors.relayActor, $[13] = t3, $[14] = t4) : t4 = $[14];
11758
+ $[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
11759
  let t5;
11777
- $[15] !== portableTextEditor_0 || $[16] !== props.children ? (t5 = /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: props.children }), $[15] = portableTextEditor_0, $[16] = props.children, $[17] = t5) : t5 = $[17];
11760
+ $[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
11761
  let t6;
11779
- $[18] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[19] !== internalEditor_0.editor._internal.slateEditor.instance || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsx(Slate, { editor: internalEditor_0.editor._internal.slateEditor.instance, initialValue: internalEditor_0.editor._internal.slateEditor.initialValue, children: t5 }), $[18] = internalEditor_0.editor._internal.slateEditor.initialValue, $[19] = internalEditor_0.editor._internal.slateEditor.instance, $[20] = t5, $[21] = t6) : t6 = $[21];
11762
+ $[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
11763
  let t7;
11781
- $[22] !== internalEditor_0.actors.relayActor || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t6 }), $[22] = internalEditor_0.actors.relayActor, $[23] = t6, $[24] = t7) : t7 = $[24];
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;
11764
+ 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
11765
  }
11790
11766
  function defineSchema(definition) {
11791
11767
  return definition;