@portabletext/editor 7.3.2 → 7.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/plugins/plugin.behavior.tsx","../../src/plugins/plugin.node.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 *\n * Plugin component that registers a list of `Behavior`s with the editor.\n *\n * Stabilize the `behaviors` array (a module-level constant or `useMemo`)\n * to avoid a full unregister/re-register cycle on every parent render: a\n * new array reference per render triggers the registration effect to\n * re-run.\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 {useEffect} from 'react'\nimport {useEditor} from '../editor/use-editor'\nimport type {RegistrableNode} from '../renderers/renderer.types'\n\n/**\n * @alpha\n *\n * Plugin component that registers a list of nodes (containers, text\n * blocks, spans, block objects, inline objects) with the editor. Each\n * node is the result of a `defineX` factory.\n *\n * Stabilize the `nodes` array (a module-level constant or `useMemo`)\n * to avoid a full unregister/re-register cycle on every parent\n * render: a new array reference per render triggers the registration\n * effect to re-run.\n */\nexport function NodePlugin(props: {nodes: Array<RegistrableNode>}) {\n const editor = useEditor()\n\n useEffect(() => {\n const unregisterNodes = props.nodes.map((node) =>\n editor.registerNode({node}),\n )\n\n return () => {\n unregisterNodes.forEach((unregister) => {\n unregister()\n })\n }\n }, [editor, props.nodes])\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","NodePlugin","nodes","unregisterNodes","node","registerNode","EditorRefPlugin","React","forwardRef","_","ref","portableTextEditorRef","useRef","Symbol","for","current","useImperativeHandle","displayName","EventListenerPlugin","on","subscription","unsubscribe"],"mappings":";;;AAcO,SAAAA,eAAAC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kBAAkBC,MAAMC,WAA0B,CAAAC,GAAAC,QAAA;AAAA,QAAAxB,IAAAC,EAAA,CAAA,GAC7DC,SAAeC,aAEfsB,wBAA8BJ,MAAKK,OAAQxB,MAAM;AAAC,MAAAE,IAAAC;AAAA,SAAAL,EAAA,CAAA,MAAA2B,uBAAAC,IAAA,2BAAA,KAEnBxB,KAAAA,MAAMqB,sBAAqBI,SAAUxB,KAAA,CAAA,GAAEL,OAAAI,IAAAJ,OAAAK,OAAAD,KAAAJ,EAAA,CAAA,GAAAK,KAAAL,EAAA,CAAA,IAAtEqB,MAAKS,oBAAqBN,KAAKpB,IAAqCC,EAAE,GAE/D;AAAI,CACZ;AACDe,gBAAgBW,cAAc;ACqCvB,SAAAC,oBAAAjC,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,SAAeC,UAAAA;AAAW,MAAAC,IAAAC;AAAA,SAAAL,SAAAE,UAAAF,EAAA,CAAA,MAAAD,MAAAkC,MAEhB7B,KAAAA,MAAA;AACR,UAAA8B,eAAqBhC,OAAM+B,GAAI,KAAKlC,MAAKkC,EAAG;AAAC,WAEtC,MAAA;AACLC,mBAAYC,YAAAA;AAAAA,IAAc;AAAA,EAC3B,GACA9B,MAACH,QAAQH,MAAKkC,EAAG,GAACjC,OAAAE,QAAAF,EAAA,CAAA,IAAAD,MAAAkC,IAAAjC,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.node.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 *\n * Plugin component that registers a list of `Behavior`s with the editor.\n *\n * Stabilize the `behaviors` array (a module-level constant or `useMemo`)\n * to avoid a full unregister/re-register cycle on every parent render: a\n * new array reference per render triggers the registration effect to\n * re-run.\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 {useEffect} from 'react'\nimport {useEditor} from '../editor/use-editor'\nimport type {RegistrableNode} from '../renderers/renderer.types'\n\n/**\n * @alpha\n *\n * Plugin component that registers a list of nodes (containers, text\n * blocks, spans, block objects, inline objects) with the editor. Each\n * node is the result of a `defineX` factory.\n *\n * Stabilize the `nodes` array (a module-level constant or `useMemo`)\n * to avoid a full unregister/re-register cycle on every parent\n * render: a new array reference per render triggers the registration\n * effect to re-run.\n */\nexport function NodePlugin(props: {nodes: Array<RegistrableNode>}) {\n const editor = useEditor()\n\n useEffect(() => {\n const unregisterNodes = props.nodes.map((node) =>\n editor.registerNode({node}),\n )\n\n return () => {\n unregisterNodes.forEach((unregister) => {\n unregister()\n })\n }\n }, [editor, props.nodes])\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'\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","NodePlugin","nodes","unregisterNodes","node","registerNode","EditorRefPlugin","React","forwardRef","_","ref","portableTextEditorRef","useRef","Symbol","for","current","useImperativeHandle","displayName","EventListenerPlugin","on","subscription","unsubscribe"],"mappings":";;;AAcO,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,OAE3B;AAAA,IAAC;AAAA,EACH,GACAP,MAACH,QAAQH,MAAKO,SAAU,GAACN,OAAAE,QAAAF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EAAE,GAE/D;AAAI,CACZ;AACDe,gBAAgBW,cAAc;ACqCvB,SAAAC,oBAAAjC,OAAA;AAAA,QAAAC,IAAAC,EAAA,CAAA,GAGLC,SAAeC,UAAAA;AAAW,MAAAC,IAAAC;AAAA,SAAAL,SAAAE,UAAAF,EAAA,CAAA,MAAAD,MAAAkC,MAEhB7B,KAAAA,MAAA;AACR,UAAA8B,eAAqBhC,OAAM+B,GAAI,KAAKlC,MAAKkC,EAAG;AAAC,WAEtC,MAAA;AACLC,mBAAYC,YAAAA;AAAAA,IAAc;AAAA,EAC3B,GACA9B,MAACH,QAAQH,MAAKkC,EAAG,GAACjC,OAAAE,QAAAF,EAAA,CAAA,IAAAD,MAAAkC,IAAAjC,OAAAI,IAAAJ,OAAAK,OAAAD,KAAAJ,EAAA,CAAA,GAAAK,KAAAL,EAAA,CAAA,IANrBa,UAAUT,IAMPC,EAAkB,GAEd;AAAI;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portabletext/editor",
3
- "version": "7.3.2",
3
+ "version": "7.3.3",
4
4
  "description": "Portable Text Editor made in React",
5
5
  "keywords": [
6
6
  "sanity",