@portabletext/editor 3.3.18 → 3.3.19

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.
@@ -1,4 +1,4 @@
1
- import { W as Editor, Xt as EditorEmittedEvent, q as Behavior } from "../_chunks-dts/behavior.types.action.js";
1
+ import { W as Editor, Xt as EditorEmittedEvent, q as Behavior } from "../_chunks-dts/index.js";
2
2
  import React from "react";
3
3
  /**
4
4
  * @beta
@@ -19,7 +19,7 @@ function _temp(unregister) {
19
19
  const EditorRefPlugin = React.forwardRef((_, ref) => {
20
20
  const $ = c(2), editor = useEditor(), portableTextEditorRef = React.useRef(editor);
21
21
  let t0, t1;
22
- return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = () => portableTextEditorRef.current, t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), React.useImperativeHandle(ref, t0, t1), null;
22
+ return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => portableTextEditorRef.current, t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), React.useImperativeHandle(ref, t0, t1), null;
23
23
  });
24
24
  EditorRefPlugin.displayName = "EditorRefPlugin";
25
25
  function EventListenerPlugin(props) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/plugins/plugin.behavior.tsx","../../src/plugins/plugin.editor-ref.tsx","../../src/plugins/plugin.event-listener.tsx"],"sourcesContent":["import {useEffect} from 'react'\nimport type {Behavior} from '../behaviors/behavior.types.behavior'\nimport {useEditor} from '../editor/use-editor'\n\n/**\n * @beta\n */\nexport function BehaviorPlugin(props: {behaviors: Array<Behavior>}) {\n const editor = useEditor()\n\n useEffect(() => {\n const unregisterBehaviors = props.behaviors.map((behavior) =>\n editor.registerBehavior({behavior}),\n )\n\n return () => {\n unregisterBehaviors.forEach((unregister) => {\n unregister()\n })\n }\n }, [editor, props.behaviors])\n\n return null\n}\n","import React from 'react'\nimport type {Editor} from '../editor'\nimport {useEditor} from '../editor/use-editor'\n\n/**\n * @beta\n */\nexport const EditorRefPlugin = React.forwardRef<Editor | null>((_, ref) => {\n const editor = useEditor()\n\n const portableTextEditorRef = React.useRef(editor)\n\n React.useImperativeHandle(ref, () => portableTextEditorRef.current, [])\n\n return null\n})\nEditorRefPlugin.displayName = 'EditorRefPlugin'\n","import {useEffect} from 'react'\nimport type {EditorEmittedEvent} from '../editor/relay-machine'\nimport {useEditor} from '../editor/use-editor'\n\n/**\n * @public\n * Listen for events emitted by the editor. Must be used inside `EditorProvider`. Events available include:\n * - 'blurred'\n * - 'done loading'\n * - 'editable'\n * - 'error'\n * - 'focused'\n * - 'invalid value'\n * - 'loading'\n * - 'mutation'\n * - 'patch'\n * - 'read only'\n * - 'ready'\n * - 'selection'\n * - 'value changed'\n *\n * @example\n * Listen and log events.\n * ```tsx\n * import {EditorProvider} from '@portabletext/editor'\n * import {EventListenerPlugin} from '@portabletext/editor/plugins'\n *\n * function MyComponent() {\n * return (\n * <EditorProvider>\n * <EventListenerPlugin\n * on={(event) => {\n * console.log(event)\n * }\n * } />\n * { ... }\n * </EditorProvider>\n * )\n * }\n * ```\n * @example\n * Handle events when there is a mutation.\n * ```tsx\n * <EventListenerPlugin\n * on={(event) => {\n * if (event.type === 'mutation') {\n * console.log('Value changed:', event.snapshot)\n * }\n * }}\n * />\n * ```\n * @group Components\n */\nexport function EventListenerPlugin(props: {\n on: (event: EditorEmittedEvent) => void\n}) {\n const editor = useEditor()\n\n useEffect(() => {\n const subscription = editor.on('*', props.on)\n\n return () => {\n subscription.unsubscribe()\n }\n }, [editor, props.on])\n\n return null\n}\n"],"names":["BehaviorPlugin","props","$","_c","editor","useEditor","t0","t1","behaviors","unregisterBehaviors","map","behavior","registerBehavior","forEach","_temp","useEffect","unregister","EditorRefPlugin","React","forwardRef","_","ref","portableTextEditorRef","useRef","Symbol","for","current","useImperativeHandle","displayName","EventListenerPlugin","on","subscription","unsubscribe"],"mappings":";;;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hBxB,KAAAA,MAAA;AACR,UAAAyB,eAAqB3B,OAAM0B,GAAI,KAAK7B,MAAK6B,EAAG;AAAC,WAEtC,MAAA;AACLC,mBAAYC,YAAAA;AAAAA,IAAc;AAAA,EAC3B,GACAzB,MAACH,QAAQH,MAAK6B,EAAG,GAAC5B,OAAAE,QAAAF,EAAA,CAAA,IAAAD,MAAA6B,IAAA5B,OAAAI,IAAAJ,OAAAK,OAAAD,KAAAJ,EAAA,CAAA,GAAAK,KAAAL,EAAA,CAAA,IANrBa,UAAUT,IAMPC,EAAkB,GAEd;AAAI;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/plugins/plugin.behavior.tsx","../../src/plugins/plugin.editor-ref.tsx","../../src/plugins/plugin.event-listener.tsx"],"sourcesContent":["import {useEffect} from 'react'\nimport type {Behavior} from '../behaviors/behavior.types.behavior'\nimport {useEditor} from '../editor/use-editor'\n\n/**\n * @beta\n */\nexport function BehaviorPlugin(props: {behaviors: Array<Behavior>}) {\n const editor = useEditor()\n\n useEffect(() => {\n const unregisterBehaviors = props.behaviors.map((behavior) =>\n editor.registerBehavior({behavior}),\n )\n\n return () => {\n unregisterBehaviors.forEach((unregister) => {\n unregister()\n })\n }\n }, [editor, props.behaviors])\n\n return null\n}\n","import React from 'react'\nimport type {Editor} from '../editor'\nimport {useEditor} from '../editor/use-editor'\n\n/**\n * @beta\n */\nexport const EditorRefPlugin = React.forwardRef<Editor | null>((_, ref) => {\n const editor = useEditor()\n\n const portableTextEditorRef = React.useRef(editor)\n\n React.useImperativeHandle(ref, () => portableTextEditorRef.current, [])\n\n return null\n})\nEditorRefPlugin.displayName = 'EditorRefPlugin'\n","import {useEffect} from 'react'\nimport type {EditorEmittedEvent} from '../editor/relay-machine'\nimport {useEditor} from '../editor/use-editor'\n\n/**\n * @public\n * Listen for events emitted by the editor. Must be used inside `EditorProvider`. Events available include:\n * - 'blurred'\n * - 'done loading'\n * - 'editable'\n * - 'error'\n * - 'focused'\n * - 'invalid value'\n * - 'loading'\n * - 'mutation'\n * - 'patch'\n * - 'read only'\n * - 'ready'\n * - 'selection'\n * - 'value changed'\n *\n * @example\n * Listen and log events.\n * ```tsx\n * import {EditorProvider} from '@portabletext/editor'\n * import {EventListenerPlugin} from '@portabletext/editor/plugins'\n *\n * function MyComponent() {\n * return (\n * <EditorProvider>\n * <EventListenerPlugin\n * on={(event) => {\n * console.log(event)\n * }\n * } />\n * { ... }\n * </EditorProvider>\n * )\n * }\n * ```\n * @example\n * Handle events when there is a mutation.\n * ```tsx\n * <EventListenerPlugin\n * on={(event) => {\n * if (event.type === 'mutation') {\n * console.log('Value changed:', event.snapshot)\n * }\n * }}\n * />\n * ```\n * @group Components\n */\nexport function EventListenerPlugin(props: {\n on: (event: EditorEmittedEvent) => void\n}) {\n const editor = useEditor()\n\n useEffect(() => {\n const subscription = editor.on('*', props.on)\n\n return () => {\n subscription.unsubscribe()\n }\n }, [editor, props.on])\n\n return null\n}\n"],"names":["BehaviorPlugin","props","$","_c","editor","useEditor","t0","t1","behaviors","unregisterBehaviors","map","behavior","registerBehavior","forEach","_temp","useEffect","unregister","EditorRefPlugin","React","forwardRef","_","ref","portableTextEditorRef","useRef","Symbol","for","current","useImperativeHandle","displayName","EventListenerPlugin","on","subscription","unsubscribe"],"mappings":";;;AAOO,SAAAA,eAAAC,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GACLC,SAAeC,UAAAA;AAAW,MAAAC,IAAAC;AAAA,SAAAL,SAAAE,UAAAF,EAAA,CAAA,MAAAD,MAAAO,aAEhBF,KAAAA,MAAA;AACR,UAAAG,sBAA4BR,MAAKO,UAAUE,IAAKC,CAAAA,aAC9CP,OAAMQ,iBAAkB;AAAA,MAAAD;AAAAA,IAAAA,CAAU,CACpC;AAAC,WAEM,MAAA;AACLF,0BAAmBI,QAASC,KAE3B;AAAA,IAAC;AAAA,EACH,GACAP,MAACH,QAAQH,MAAKO,SAAU,GAACN,OAAAE,QAAAF,EAAA,CAAA,IAAAD,MAAAO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ectionPoint, nn as KeyedSegment, tn as ChildPath } from "../_chunks-dts/behavior.types.action.js";
1
+ import { B as EditorSelector, F as BlockOffset, dt as EditorSelection, en as BlockPath, ft as EditorSelectionPoint, nn as KeyedSegment, tn as ChildPath } from "../_chunks-dts/index.js";
2
2
  import { PortableTextBlock, PortableTextListBlock, PortableTextObject, PortableTextSpan, PortableTextTextBlock } from "@portabletext/schema";
3
3
  /**
4
4
  * @public
@@ -1,5 +1,5 @@
1
- import { F as BlockOffset, X as EditorContext, dt as EditorSelection, en as BlockPath, ft as EditorSelectionPoint, nn as KeyedSegment, tn as ChildPath } from "../_chunks-dts/behavior.types.action.js";
2
- import * as _portabletext_schema9 from "@portabletext/schema";
1
+ import { F as BlockOffset, X as EditorContext, dt as EditorSelection, en as BlockPath, ft as EditorSelectionPoint, nn as KeyedSegment, tn as ChildPath } from "../_chunks-dts/index.js";
2
+ import * as _portabletext_schema15 from "@portabletext/schema";
3
3
  import { PortableTextBlock, PortableTextTextBlock, isSpan, isTextBlock } from "@portabletext/schema";
4
4
  /**
5
5
  * @public
@@ -142,7 +142,7 @@ declare function mergeTextBlocks({
142
142
  context: Pick<EditorContext, 'keyGenerator' | 'schema'>;
143
143
  targetBlock: PortableTextTextBlock;
144
144
  incomingBlock: PortableTextTextBlock;
145
- }): PortableTextTextBlock<_portabletext_schema9.PortableTextObject | _portabletext_schema9.PortableTextSpan>;
145
+ }): PortableTextTextBlock<_portabletext_schema15.PortableTextObject | _portabletext_schema15.PortableTextSpan>;
146
146
  /**
147
147
  * @public
148
148
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "3.3.18",
3
+ "version": "3.3.19",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",
@@ -72,9 +72,9 @@
72
72
  "slate-react": "^0.120.0",
73
73
  "xstate": "^5.25.0",
74
74
  "@portabletext/keyboard-shortcuts": "^2.1.1",
75
- "@portabletext/block-tools": "^4.1.11",
76
- "@portabletext/schema": "^2.1.0",
77
75
  "@portabletext/markdown": "^1.1.0",
76
+ "@portabletext/schema": "^2.1.0",
77
+ "@portabletext/block-tools": "^4.1.11",
78
78
  "@portabletext/patches": "^2.0.2"
79
79
  },
80
80
  "devDependencies": {
@@ -101,9 +101,9 @@
101
101
  "vite": "^7.1.12",
102
102
  "vitest": "^4.0.14",
103
103
  "vitest-browser-react": "^2.0.2",
104
- "@portabletext/sanity-bridge": "1.2.14",
104
+ "racejar": "2.0.1",
105
105
  "@portabletext/test": "^1.0.3",
106
- "racejar": "2.0.1"
106
+ "@portabletext/sanity-bridge": "1.2.14"
107
107
  },
108
108
  "peerDependencies": {
109
109
  "@portabletext/sanity-bridge": "^1.2.14",