@portabletext/editor 2.1.1 → 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.
@@ -4,7 +4,7 @@ import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDe
4
4
  import * as xstate227 from "xstate";
5
5
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
6
6
  import { BaseRange, Descendant, Operation } from "slate";
7
- import * as react20 from "react";
7
+ import * as react22 from "react";
8
8
  import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
9
9
  import * as xstate_guards12 from "xstate/guards";
10
10
  import { Observable, Subject } from "rxjs";
@@ -352,7 +352,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
352
352
  componentDidUpdate(prevProps: PortableTextEditorProps): void;
353
353
  componentWillUnmount(): void;
354
354
  setEditable: (editable: EditableAPI) => void;
355
- render(): react20.JSX.Element;
355
+ render(): react22.JSX.Element;
356
356
  /**
357
357
  * @deprecated
358
358
  * Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
@@ -747,7 +747,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
747
747
  * ```
748
748
  * @group Components
749
749
  */
750
- declare const PortableTextEditable: react20.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react20.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
750
+ declare const PortableTextEditable: react22.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react22.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
751
751
  type DecoratedRange = BaseRange & {
752
752
  rangeDecoration: RangeDecoration;
753
753
  };
@@ -1476,7 +1476,7 @@ declare const editorMachine: xstate227.StateMachine<{
1476
1476
  initialValue?: Array<PortableTextBlock>;
1477
1477
  }, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
1478
1478
  type: "blurred";
1479
- event: react20.FocusEvent<HTMLDivElement, Element>;
1479
+ event: react22.FocusEvent<HTMLDivElement, Element>;
1480
1480
  } | {
1481
1481
  type: "done loading";
1482
1482
  } | {
@@ -1488,7 +1488,7 @@ declare const editorMachine: xstate227.StateMachine<{
1488
1488
  data: unknown;
1489
1489
  } | {
1490
1490
  type: "focused";
1491
- event: react20.FocusEvent<HTMLDivElement, Element>;
1491
+ event: react22.FocusEvent<HTMLDivElement, Element>;
1492
1492
  } | {
1493
1493
  type: "invalid value";
1494
1494
  resolution: InvalidValueResolution | null;
@@ -2135,7 +2135,7 @@ declare const editorMachine: xstate227.StateMachine<{
2135
2135
  type: "drop";
2136
2136
  }, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
2137
2137
  type: "blurred";
2138
- event: react20.FocusEvent<HTMLDivElement, Element>;
2138
+ event: react22.FocusEvent<HTMLDivElement, Element>;
2139
2139
  } | {
2140
2140
  type: "done loading";
2141
2141
  } | {
@@ -2147,7 +2147,7 @@ declare const editorMachine: xstate227.StateMachine<{
2147
2147
  data: unknown;
2148
2148
  } | {
2149
2149
  type: "focused";
2150
- event: react20.FocusEvent<HTMLDivElement, Element>;
2150
+ event: react22.FocusEvent<HTMLDivElement, Element>;
2151
2151
  } | {
2152
2152
  type: "invalid value";
2153
2153
  resolution: InvalidValueResolution | null;
@@ -3018,7 +3018,7 @@ declare const editorMachine: xstate227.StateMachine<{
3018
3018
  type: "drop";
3019
3019
  }, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
3020
3020
  type: "blurred";
3021
- event: react20.FocusEvent<HTMLDivElement, Element>;
3021
+ event: react22.FocusEvent<HTMLDivElement, Element>;
3022
3022
  } | {
3023
3023
  type: "done loading";
3024
3024
  } | {
@@ -3030,7 +3030,7 @@ declare const editorMachine: xstate227.StateMachine<{
3030
3030
  data: unknown;
3031
3031
  } | {
3032
3032
  type: "focused";
3033
- event: react20.FocusEvent<HTMLDivElement, Element>;
3033
+ event: react22.FocusEvent<HTMLDivElement, Element>;
3034
3034
  } | {
3035
3035
  type: "invalid value";
3036
3036
  resolution: InvalidValueResolution | null;
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(32);
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
- return internalEditor_0.actors.editorActor.start(), internalEditor_0.actors.mutationActor.start(), internalEditor_0.actors.relayActor.start(), internalEditor_0.actors.syncActor.start(), () => {
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 = $[7];
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
- $[8] !== internalEditor_0 ? (t2 = [internalEditor_0], $[8] = internalEditor_0, $[9] = t2) : t2 = $[9], React.useEffect(t1, t2);
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
- $[10] !== portableTextEditor_0.change$ ? (t3 = (change) => {
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
- $[12] !== internalEditor_0.actors.relayActor || $[13] !== t3 ? (t4 = /* @__PURE__ */ jsxRuntime.jsx(RouteEventsToChanges, { relayActor: internalEditor_0.actors.relayActor, onChange: t3 }), $[12] = internalEditor_0.actors.relayActor, $[13] = t3, $[14] = t4) : t4 = $[14];
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
- $[15] !== portableTextEditor_0 || $[16] !== props.children ? (t5 = /* @__PURE__ */ jsxRuntime.jsx(PortableTextEditorContext.Provider, { value: portableTextEditor_0, children: props.children }), $[15] = portableTextEditor_0, $[16] = props.children, $[17] = t5) : t5 = $[17];
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
- $[18] !== internalEditor_0.editor._internal.slateEditor.initialValue || $[19] !== internalEditor_0.editor._internal.slateEditor.instance || $[20] !== t5 ? (t6 = /* @__PURE__ */ jsxRuntime.jsx(slateReact.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];
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
- $[22] !== internalEditor_0.actors.relayActor || $[23] !== t6 ? (t7 = /* @__PURE__ */ jsxRuntime.jsx(RelayActorContext.Provider, { value: internalEditor_0.actors.relayActor, children: t6 }), $[22] = internalEditor_0.actors.relayActor, $[23] = t6, $[24] = t7) : t7 = $[24];
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;