@portabletext/editor 2.6.10-canary.0 → 2.7.0

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
@@ -1,5 +1,5 @@
1
1
  import { c } from "react-compiler-runtime";
2
- import React, { useEffect, createContext, useContext, useState, useRef, Component, useMemo, startTransition, useCallback, forwardRef } from "react";
2
+ import { useEffect, createContext, useContext, useState, useRef, Component, useMemo, startTransition, useCallback, forwardRef } from "react";
3
3
  import { useEditor, EditorContext } from "./_chunks-es/use-editor.js";
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useSelector, useActorRef } from "@xstate/react";
@@ -12059,12 +12059,6 @@ function _temp4(o) {
12059
12059
  function _temp5(error) {
12060
12060
  return console.warn(error), error;
12061
12061
  }
12062
- function useConstant(factory) {
12063
- const ref = React.useRef(null);
12064
- return ref.current || (ref.current = {
12065
- constant: factory()
12066
- }), ref.current.constant;
12067
- }
12068
12062
  function EditorProvider(props) {
12069
12063
  const $ = c(28);
12070
12064
  let t0;
@@ -12077,12 +12071,12 @@ function EditorProvider(props) {
12077
12071
  portableTextEditor
12078
12072
  };
12079
12073
  }, $[0] = props.initialConfig, $[1] = t0) : t0 = $[1];
12080
- const {
12074
+ const [t1] = useState(t0), {
12081
12075
  internalEditor: internalEditor_0,
12082
12076
  portableTextEditor: portableTextEditor_0
12083
- } = useConstant(t0);
12084
- let t1;
12085
- $[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 = () => {
12077
+ } = t1;
12078
+ let t2;
12079
+ $[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 ? (t2 = () => {
12086
12080
  const unsubscribers = [];
12087
12081
  for (const subscription of internalEditor_0.subscriptions)
12088
12082
  unsubscribers.push(subscription());
@@ -12095,19 +12089,19 @@ function EditorProvider(props) {
12095
12089
  unsubscribe();
12096
12090
  stopActor(internalEditor_0.actors.editorActor), stopActor(internalEditor_0.actors.mutationActor), stopActor(internalEditor_0.actors.relayActor), stopActor(internalEditor_0.actors.syncActor);
12097
12091
  };
12098
- }, $[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];
12099
- let t2;
12100
- $[9] !== internalEditor_0 || $[10] !== portableTextEditor_0 ? (t2 = [internalEditor_0, portableTextEditor_0], $[9] = internalEditor_0, $[10] = portableTextEditor_0, $[11] = t2) : t2 = $[11], useEffect(t1, t2);
12092
+ }, $[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] = t2) : t2 = $[8];
12101
12093
  let t3;
12102
- $[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];
12094
+ $[9] !== internalEditor_0 || $[10] !== portableTextEditor_0 ? (t3 = [internalEditor_0, portableTextEditor_0], $[9] = internalEditor_0, $[10] = portableTextEditor_0, $[11] = t3) : t3 = $[11], useEffect(t2, t3);
12103
12095
  let t4;
12104
- $[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];
12096
+ $[12] !== portableTextEditor_0 || $[13] !== props.children ? (t4 = /* @__PURE__ */ jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: props.children }), $[12] = portableTextEditor_0, $[13] = props.children, $[14] = t4) : t4 = $[14];
12105
12097
  let t5;
12106
- $[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];
12098
+ $[15] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[16] !== internalEditor_0.editor._internal.slateEditor.instance || $[17] !== t4 ? (t5 = /* @__PURE__ */ jsx(Slate, { editor: internalEditor_0.editor._internal.slateEditor.instance, initialValue: internalEditor_0.editor._internal.slateEditor.initialValue, children: t4 }), $[15] = internalEditor_0.editor._internal.slateEditor.initialValue, $[16] = internalEditor_0.editor._internal.slateEditor.instance, $[17] = t4, $[18] = t5) : t5 = $[18];
12107
12099
  let t6;
12108
- $[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];
12100
+ $[19] !== internalEditor_0.actors.relayActor || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t5 }), $[19] = internalEditor_0.actors.relayActor, $[20] = t5, $[21] = t6) : t6 = $[21];
12109
12101
  let t7;
12110
- 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;
12102
+ $[22] !== internalEditor_0.actors.editorActor || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsx(EditorActorContext.Provider, { value: internalEditor_0.actors.editorActor, children: t6 }), $[22] = internalEditor_0.actors.editorActor, $[23] = t6, $[24] = t7) : t7 = $[24];
12103
+ let t8;
12104
+ return $[25] !== internalEditor_0.editor || $[26] !== t7 ? (t8 = /* @__PURE__ */ jsx(EditorContext.Provider, { value: internalEditor_0.editor, children: t7 }), $[25] = internalEditor_0.editor, $[26] = t7, $[27] = t8) : t8 = $[27], t8;
12111
12105
  }
12112
12106
  const usePortableTextEditorSelection = () => {
12113
12107
  const $ = c(3), editorActor = useContext(EditorActorContext), [selection, setSelection2] = useState(null);