@payloadcms/richtext-lexical 3.18.0 → 3.19.0-canary.9b65c78

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.
Files changed (70) hide show
  1. package/dist/exports/client/Field-RG3FN6WF.js +2 -0
  2. package/dist/exports/client/Field-RG3FN6WF.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-JPESGV4Q.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-JPESGV4Q.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/chunk-DBWINSQN.js +2 -0
  7. package/dist/exports/client/chunk-DBWINSQN.js.map +7 -0
  8. package/dist/exports/client/chunk-KDV47ZNZ.js +2 -0
  9. package/dist/exports/client/chunk-KDV47ZNZ.js.map +7 -0
  10. package/dist/exports/client/chunk-QP2NYEWJ.js +2 -0
  11. package/dist/exports/client/{chunk-HMZK3GHC.js.map → chunk-QP2NYEWJ.js.map} +4 -4
  12. package/dist/exports/client/component-VJVZFYZJ.js +2 -0
  13. package/dist/exports/client/component-VJVZFYZJ.js.map +7 -0
  14. package/dist/exports/client/componentInline-DTNGYZCL.js +2 -0
  15. package/dist/exports/client/index.js +10 -9
  16. package/dist/exports/client/index.js.map +4 -4
  17. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  18. package/dist/features/blocks/client/componentInline/index.js +6 -42
  19. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  20. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +1 -1
  21. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  22. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -2
  23. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
  24. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js +1 -7
  25. package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
  26. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  27. package/dist/features/relationship/client/components/RelationshipComponent.js +4 -42
  28. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  29. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  30. package/dist/features/upload/client/component/index.js +3 -38
  31. package/dist/features/upload/client/component/index.js.map +1 -1
  32. package/dist/field/bundled.css +1 -1
  33. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  34. package/dist/lexical/LexicalEditor.js +2 -1
  35. package/dist/lexical/LexicalEditor.js.map +1 -1
  36. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts +3 -0
  37. package/dist/lexical/plugins/DecoratorPlugin/index.d.ts.map +1 -0
  38. package/dist/lexical/plugins/DecoratorPlugin/index.js +79 -0
  39. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -0
  40. package/dist/lexical/plugins/InsertParagraphAtEnd/index.d.ts.map +1 -1
  41. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +3 -1
  42. package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
  43. package/dist/lexical/utils/url.d.ts +20 -0
  44. package/dist/lexical/utils/url.d.ts.map +1 -1
  45. package/dist/lexical/utils/url.js +14 -3
  46. package/dist/lexical/utils/url.js.map +1 -1
  47. package/dist/lexical/utils/url.spec.js +32 -0
  48. package/dist/lexical/utils/url.spec.js.map +1 -0
  49. package/package.json +6 -6
  50. package/dist/exports/client/Field-F5XP4HL4.js +0 -2
  51. package/dist/exports/client/Field-F5XP4HL4.js.map +0 -7
  52. package/dist/exports/client/RelationshipComponent-BWAHSMVN.js +0 -2
  53. package/dist/exports/client/RelationshipComponent-BWAHSMVN.js.map +0 -7
  54. package/dist/exports/client/chunk-DIR6RNSY.js +0 -2
  55. package/dist/exports/client/chunk-DIR6RNSY.js.map +0 -7
  56. package/dist/exports/client/chunk-HMZK3GHC.js +0 -2
  57. package/dist/exports/client/chunk-RJTGMBHA.js +0 -3
  58. package/dist/exports/client/chunk-RJTGMBHA.js.map +0 -7
  59. package/dist/exports/client/chunk-TP3JCLAP.js +0 -2
  60. package/dist/exports/client/chunk-TP3JCLAP.js.map +0 -7
  61. package/dist/exports/client/component-53MM7FV7.js +0 -2
  62. package/dist/exports/client/component-53MM7FV7.js.map +0 -7
  63. package/dist/exports/client/component-FU65NQBY.js +0 -2
  64. package/dist/exports/client/component-FU65NQBY.js.map +0 -7
  65. package/dist/exports/client/componentInline-MX6DTKSG.js +0 -2
  66. package/dist/features/horizontalRule/client/component/index.d.ts +0 -10
  67. package/dist/features/horizontalRule/client/component/index.d.ts.map +0 -1
  68. package/dist/features/horizontalRule/client/component/index.js +0 -101
  69. package/dist/features/horizontalRule/client/component/index.js.map +0 -1
  70. /package/dist/exports/client/{componentInline-MX6DTKSG.js.map → componentInline-DTNGYZCL.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,OAAO,sBAAsB,CAAA;AAS7B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC;IACE,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC1D,oBAAoB,EAAE,OAAO,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,cAAc,GAAG,UAAU,CAAC,CA0J5D,CAAA"}
1
+ {"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,OAAO,sBAAsB,CAAA;AAU7B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC;IACE,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC1D,oBAAoB,EAAE,OAAO,CAAA;CAC9B,GAAG,IAAI,CAAC,oBAAoB,EAAE,cAAc,GAAG,UAAU,CAAC,CA2J5D,CAAA"}
@@ -12,6 +12,7 @@ import * as React from 'react';
12
12
  import { useEffect, useState } from 'react';
13
13
  import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
14
14
  import { EditorPlugin } from './EditorPlugin.js';
15
+ import { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js';
15
16
  import { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js';
16
17
  import { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js';
17
18
  import { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js';
@@ -146,7 +147,7 @@ export const LexicalEditor = props => {
146
147
  })
147
148
  }),
148
149
  ErrorBoundary: LexicalErrorBoundary
149
- }), _jsx(InsertParagraphAtEndPlugin, {}), _jsx(TextPlugin, {
150
+ }), _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
150
151
  features: editorConfig.features
151
152
  }), _jsx(OnChangePlugin, {
152
153
  ignoreSelectionChange: true,
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","t4","editorState","editor_0","tags","has","size","t5","features","plugins","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport {\n $createParagraphNode,\n $getRoot,\n BLUR_COMMAND,\n COMMAND_PRIORITY_LOW,\n FOCUS_COMMAND,\n} from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <InsertParagraphAtEndPlugin />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps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ugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","t3","t4","editorState","editor_0","tags","has","size","t5","features","plugins","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport {\n $createParagraphNode,\n $getRoot,\n BLUR_COMMAND,\n COMMAND_PRIORITY_LOW,\n FOCUS_COMMAND,\n} from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n isSmallWidthViewport: boolean\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, isSmallWidthViewport, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable editorConfig={editorConfig} />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAGEC,YAAY,EACZC,oBAAoB,EACpBC,aAAa,QACR;AACP,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAE7B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,sBAAsB,QAAQ;AACvC,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAC3B,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAKTC,KAAA;EAAA,MAAAC,CAAA,GAAAxB,EAAA;EACF;IAAAyB,YAAA;IAAAC,kBAAA;IAAAC,oBAAA;IAAAC;EAAA,IAA6EL,KAAA;EAC7E,MAAAM,mBAAA,GAA4BjB,sBAAA;EAC5B,OAAAkB,MAAA,IAAiB7B,yBAAA;EAEjB,OAAA8B,kBAAA,EAAAC,qBAAA,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AAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA9IxE,SAAAW,OAAAI,QAAA;EAAA,IAoJQnB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfL,IAAA,CAAAtD,YAAA;MAAA6D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import './index.scss';
2
+ export declare function DecoratorPlugin(): null;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,cAAc,CAAA;AAIrB,wBAAgB,eAAe,SAmD9B"}
@@ -0,0 +1,79 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
5
+ import { mergeRegister } from '@lexical/utils';
6
+ import { $createNodeSelection, $getNearestNodeFromDOMNode, $getSelection, $isDecoratorNode, $isNodeSelection, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND } from 'lexical';
7
+ import { useEffect } from 'react';
8
+ // TODO: This should ideally be fixed in Lexical. See
9
+ // https://github.com/facebook/lexical/pull/7072
10
+ export function DecoratorPlugin() {
11
+ const $ = _c(3);
12
+ const [editor] = useLexicalComposerContext();
13
+ const $onDelete = _temp2;
14
+ let t0;
15
+ let t1;
16
+ if ($[0] !== editor) {
17
+ t0 = () => mergeRegister(editor.registerCommand(CLICK_COMMAND, _temp3, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW), editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW));
18
+ t1 = [editor];
19
+ $[0] = editor;
20
+ $[1] = t0;
21
+ $[2] = t1;
22
+ } else {
23
+ t0 = $[1];
24
+ t1 = $[2];
25
+ }
26
+ useEffect(t0, t1);
27
+ return null;
28
+ }
29
+ function _temp3(event_0) {
30
+ document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");
31
+ const decorator = $getDecorator(event_0);
32
+ if (!decorator) {
33
+ return true;
34
+ }
35
+ const {
36
+ decoratorElement,
37
+ decoratorNode
38
+ } = decorator;
39
+ const {
40
+ target
41
+ } = event_0;
42
+ const isInteractive = !(target instanceof HTMLElement) || target.isContentEditable || target.closest("button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]");
43
+ if (isInteractive) {
44
+ $setSelection(null);
45
+ } else {
46
+ const selection_0 = $createNodeSelection();
47
+ selection_0.add(decoratorNode.getKey());
48
+ $setSelection(selection_0);
49
+ decoratorElement.classList.add("decorator-selected");
50
+ }
51
+ return true;
52
+ }
53
+ function _temp2(event) {
54
+ const selection = $getSelection();
55
+ if (!$isNodeSelection(selection)) {
56
+ return false;
57
+ }
58
+ event.preventDefault();
59
+ selection.getNodes().forEach(_temp);
60
+ return true;
61
+ }
62
+ function _temp(node) {
63
+ node.remove();
64
+ }
65
+ function $getDecorator(event) {
66
+ if (!(event.target instanceof Element)) {
67
+ return undefined;
68
+ }
69
+ const decoratorElement = event.target.closest('[data-lexical-decorator="true"]');
70
+ if (!decoratorElement) {
71
+ return undefined;
72
+ }
73
+ const node = $getNearestNodeFromDOMNode(decoratorElement);
74
+ return $isDecoratorNode(node) ? {
75
+ decoratorElement,
76
+ decoratorNode: node
77
+ } : undefined;
78
+ }
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$createNodeSelection","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isNodeSelection","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","event_0","document","querySelector","classList","remove","decorator","$getDecorator","event","decoratorElement","decoratorNode","target","isInteractive","HTMLElement","isContentEditable","closest","selection_0","selection","add","getKey","preventDefault","getNodes","forEach","_temp","node","Element","undefined"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isNodeSelection,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.scss'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecorator(event)\n if (!decorator) {\n return true\n }\n const { decoratorElement, decoratorNode } = decorator\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n const selection = $createNodeSelection()\n selection.add(decoratorNode.getKey())\n $setSelection(selection)\n decoratorElement.classList.add('decorator-selected')\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecorator(\n event: MouseEvent,\n): { decoratorElement: Element; decoratorNode: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof Element)) {\n return undefined\n }\n const decoratorElement = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!decoratorElement) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(decoratorElement)\n return $isDecoratorNode(node) ? { decoratorElement, decoratorNode: node } : undefined\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,QAAQ;AAC9B,SACEC,oBAAoB,EACpBC,0BAA0B,EAC1BC,aAAa,EACbC,gBAAgB,EAChBC,gBAAgB,EAChBC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb;AACP,SAASC,SAAS,QAAQ;AAI1B;AACA;AACA,OAAO,SAAAC,gBAAA;EAAA,MAAAC,CAAA,GAAAf,EAAA;EACL,OAAAgB,MAAA,IAAiBf,yBAAA;EAEjB,MAAAgB,SAAA,GAAAC,MAAA;EAUA,IAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAC,MAAA;IAEUG,EAAA,GAAAA,CAAA,KACDjB,aAAA,CACLc,MAAA,CAAAK,eAAA,CAAAZ,aAAA,EAAAa,MAAA,EAAAZ,oBA0BE,GAEFM,MAAA,CAAAK,eAAA,CAAAT,kBAAA,EAA2CK,SAAA,EAAAP,oBAAW,GACtDM,MAAA,CAAAK,eAAA,CAAAV,qBAAA,EAA8CM,SAAA,EAAAP,oBAAW;IAE1DU,EAAA,I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,gBAAA,GAAmBD,KAAA,CAAMG,MAAM,CAACI,OAAO,CAAC;EAC9C,IAAI,CAACN,gBAAA,EAAkB;IACrB,OAAOiB,SAAA;EACT;EACA,MAAMF,IAAA,GAAO1C,0BAAA,CAA2B2B,gBAAA;EACxC,OAAOzB,gBAAA,CAAiBwC,IAAA,IAAQ;IAAEf,gBAAA;IAAkBC,aAAA,EAAec;EAAK,IAAIE,SAAA;AAC9E","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAuB9C,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,cAAc,CAAA;AAIrB,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EA8B9C,CAAA"}
@@ -1,4 +1,4 @@
1
- /* eslint-disable jsx-a11y/no-static-element-interactions */ /* eslint-disable jsx-a11y/click-events-have-key-events */'use client';
1
+ /* eslint-disable jsx-a11y/click-events-have-key-events */'use client';
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -33,6 +33,8 @@ export const InsertParagraphAtEndPlugin = () => {
33
33
  "aria-label": "Insert Paragraph",
34
34
  className: baseClass,
35
35
  onClick,
36
+ role: "button",
37
+ tabIndex: 0,
36
38
  children: _jsx("div", {
37
39
  className: `${baseClass}-inside`,
38
40
  children: _jsx("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$createParagraphNode","$getRoot","React","useEditorConfigContext","baseClass","InsertParagraphAtEndPlugin","$","editor","editorConfig","admin","hideInsertParagraphAtEnd","t0","update","_temp","onClick","t1","_jsx","className","children","paragraphNode","append","select"],"sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n <div aria-label=\"Insert Paragraph\" className={baseClass} onClick={onClick}>\n <div className={`${baseClass}-inside`}>\n <span>+</span>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA,6DACA,0DACA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAC/C,OAAOC,KAAA,MAAW;AAGlB,SAASC,sBAAsB,QAAQ;AACvC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,0BAAA,GAAuCA,CAAA;EAAA,MAAAC,CAAA,GAAAR,EAAA;EAClD,OAAAS,MAAA,IAAiBR,yBAAA;EACjB;IAAAS;EAAA,IAAyBL,sBAAA;EAAA,IAErBK,YAAA,EAAAC,KAAA,EAAAC,wBAAA;IAAA;EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAC,MAAA;IAIYI,EAAA,GAAAA,CAAA;MACdJ,MAAA,CAAAK,MAAA,CAAAC,KAIA;IAAA;IACFP,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EANA,MAAAQ,OAAA,GAAgBH,EAMhB;EAAA,IAAAI,EAAA;EAAA,IAAAT,CAAA,QAAAQ,OAAA;IAGEC,EAAA,GAAAC,IAAA,CAAC;MAAA,cAAe;MAAAC,SAAA,EAAAb,SAAA;MAAAU,OAAA;MAAAI,QAAA,EACdF,IAAA,CAAC;QAAAC,SAAA,EAAe,GAAAb,SAAA,SAAqB;QAAAc,QAAA,EACnCF,IAAA,CAAC;UAAAE,QAAA,EAAK;QAAA,C;;;;;;;;SAFVH,E;CAMJ;AAvBoD,SAAAF,MAAA;EAU9C,MAAAM,aAAA,GAAsBnB,oBAAA;EACtBC,QAAA,GAAAmB,MAAA,CAAkBD,aAAA;EAClBA,aAAA,CAAAE,MAAA,CAAoB;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$createParagraphNode","$getRoot","React","useEditorConfigContext","baseClass","InsertParagraphAtEndPlugin","$","editor","editorConfig","admin","hideInsertParagraphAtEnd","t0","update","_temp","onClick","t1","_jsx","className","role","tabIndex","children","paragraphNode","append","select"],"sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/click-events-have-key-events */\n'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.scss'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n // TODO: convert to button\n <div\n aria-label=\"Insert Paragraph\"\n className={baseClass}\n onClick={onClick}\n role=\"button\"\n tabIndex={0}\n >\n <div className={`${baseClass}-inside`}>\n <span>+</span>\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA,0DACA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAC/C,OAAOC,KAAA,MAAW;AAGlB,SAASC,sBAAsB,QAAQ;AACvC,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,0BAAA,GAAuCA,CAAA;EAAA,MAAAC,CAAA,GAAAR,EAAA;EAClD,OAAAS,MAAA,IAAiBR,yBAAA;EACjB;IAAAS;EAAA,IAAyBL,sBAAA;EAAA,IAErBK,YAAA,EAAAC,KAAA,EAAAC,wBAAA;IAAA;EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAC,MAAA;IAIYI,EAAA,GAAAA,CAAA;MACdJ,MAAA,CAAAK,MAAA,CAAAC,KAIA;IAAA;IACFP,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAK,EAAA;EAAA;IAAAA,EAAA,GAAAL,CAAA;EAAA;EANA,MAAAQ,OAAA,GAAgBH,EAMhB;EAAA,IAAAI,EAAA;EAAA,IAAAT,CAAA,QAAAQ,OAAA;IAIEC,EAAA,GAAAC,IAAA,CAAC;MAAA,cACY;MAAAC,SAAA,EAAAb,SAAA;MAAAU,OAAA;MAAAI,IAAA,EAGN;MAAAC,QAAA;MAAAC,QAAA,EAGLJ,IAAA,CAAC;QAAAC,SAAA,EAAe,GAAAb,SAAA,SAAqB;QAAAgB,QAAA,EACnCJ,IAAA,CAAC;UAAAI,QAAA,EAAK;QAAA,C;;;;;;;;SARVL,E;CAYJ;AA9BoD,SAAAF,MAAA;EAU9C,MAAAQ,aAAA,GAAsBrB,oBAAA;EACtBC,QAAA,GAAAqB,MAAA,CAAkBD,aAAA;EAClBA,aAAA,CAAAE,MAAA,CAAoB;AAAA","ignoreList":[]}
@@ -1,4 +1,24 @@
1
1
  export declare function sanitizeUrl(url: string): string;
2
+ /**
3
+ * This regex checks for absolute URLs in a string. Tested for the following use cases:
4
+ * - http://example.com
5
+ * - https://example.com
6
+ * - ftp://files.example.com
7
+ * - http://example.com/resource
8
+ * - https://example.com/resource?key=value
9
+ * - http://example.com/resource#anchor
10
+ * - http://www.example.com
11
+ * - https://sub.example.com/path/file
12
+ * - mailto:
13
+ */
14
+ export declare const absoluteRegExp: RegExp;
15
+ /**
16
+ * This regex checks for relative URLs starting with / or anchor links starting with # in a string. Tested for the following use cases:
17
+ * - /privacy-policy
18
+ * - /privacy-policy#primary-terms
19
+ * - #primary-terms
20
+ * */
21
+ export declare const relativeOrAnchorRegExp: RegExp;
2
22
  /**
3
23
  * Prevents unreasonable URLs from being inserted into the editor.
4
24
  * @param url
@@ -1 +1 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAe/C;AAcD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMvD;AAID,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CA+BhD"}
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/lexical/utils/url.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAe/C;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,QACqK,CAAA;AAEhM;;;;;MAKM;AACN,eAAO,MAAM,sBAAsB,QAA6C,CAAA;AAEhF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMvD;AAID,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CA+BhD"}
@@ -8,15 +8,26 @@ export function sanitizeUrl(url) {
8
8
  }
9
9
  return 'https://';
10
10
  }
11
- // Source: https://stackoverflow.com/a/8234912/2013580
12
- const absoluteRegExp = /(?:[A-Za-z]{3,9}:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z\d.-]+)(?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*/;
11
+ /**
12
+ * This regex checks for absolute URLs in a string. Tested for the following use cases:
13
+ * - http://example.com
14
+ * - https://example.com
15
+ * - ftp://files.example.com
16
+ * - http://example.com/resource
17
+ * - https://example.com/resource?key=value
18
+ * - http://example.com/resource#anchor
19
+ * - http://www.example.com
20
+ * - https://sub.example.com/path/file
21
+ * - mailto:
22
+ */
23
+ export const absoluteRegExp = /^(?:[a-zA-Z][a-zA-Z\d+.-]*:(?:\/\/)?(?:[-;:&=+$,\w]+@)?[A-Za-z\d]+(?:\.[A-Za-z\d]+)+|www\.[A-Za-z\d]+(?:\.[A-Za-z\d]+)+|(?:tel|mailto):[\w+.-]+)(?:\/[+~%/\w-]*)?(?:\?[-;&=%\w]*)?(?:#\w+)?$/;
13
24
  /**
14
25
  * This regex checks for relative URLs starting with / or anchor links starting with # in a string. Tested for the following use cases:
15
26
  * - /privacy-policy
16
27
  * - /privacy-policy#primary-terms
17
28
  * - #primary-terms
18
29
  * */
19
- const relativeOrAnchorRegExp = /^[\w\-./]*(?:#\w[\w-]*)?$/;
30
+ export const relativeOrAnchorRegExp = /^(?:\/[\w\-./]*(?:#\w[\w-]*)?|#[\w\-]+)$/;
20
31
  /**
21
32
  * Prevents unreasonable URLs from being inserted into the editor.
22
33
  * @param url
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","names":["sanitizeUrl","url","SAFE_URL_PATTERN","DATA_URL_PATTERN","String","trim","match","absoluteRegExp","relativeOrAnchorRegExp","validateUrlMinimal","includes","validateUrl","test","URL"],"sources":["../../../src/lexical/utils/url.ts"],"sourcesContent":["export function sanitizeUrl(url: string): string {\n /** A pattern that matches safe URLs. */\n const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi\n\n /** A pattern that matches safe data URLs. */\n const DATA_URL_PATTERN =\n /^data:(?:image\\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\\/(?:mpeg|mp4|ogg|webm)|audio\\/(?:mp3|oga|ogg|opus));base64,[a-z\\d+/]+=*$/i\n\n url = String(url).trim()\n\n if (url.match(SAFE_URL_PATTERN) != null || url.match(DATA_URL_PATTERN) != null) {\n return url\n }\n\n return 'https://'\n}\n\n// Source: https://stackoverflow.com/a/8234912/2013580\nconst absoluteRegExp =\n /(?:[A-Za-z]{3,9}:(?:\\/\\/)?(?:[-;:&=+$,\\w]+@)?[A-Za-z\\d.-]+|(?:www.|[-;:&=+$,\\w]+@)[A-Za-z\\d.-]+)(?:\\/[+~%/.\\w-]*)?\\??[-+=&;%@.\\w]*#?\\w*/\n\n/**\n * This regex checks for relative URLs starting with / or anchor links starting with # in a string. Tested for the following use cases:\n * - /privacy-policy\n * - /privacy-policy#primary-terms\n * - #primary-terms\n * */\nconst relativeOrAnchorRegExp = /^[\\w\\-./]*(?:#\\w[\\w-]*)?$/\n\n/**\n * Prevents unreasonable URLs from being inserted into the editor.\n * @param url\n */\nexport function validateUrlMinimal(url: string): boolean {\n if (!url) {\n return false\n }\n\n return !url.includes(' ')\n}\n\n// Do not keep validateUrl function too loose. This is run when pasting in text, to determine if links are in that text and if it should create AutoLinkNodes.\n// This is why we do not allow stuff like anchors here, as we don't want copied anchors to be turned into AutoLinkNodes.\nexport function validateUrl(url: string): boolean {\n // TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.\n // Maybe show a dialog where they user can type the URL before inserting it.\n\n if (!url) {\n return false\n }\n\n if (url === 'https://') {\n return true\n }\n\n // This makes sure URLs starting with www. instead of https are valid too\n if (absoluteRegExp.test(url)) {\n return true\n }\n\n // Check relative or anchor links\n if (relativeOrAnchorRegExp.test(url)) {\n return true\n }\n\n // While this doesn't allow URLs starting with www (which is why we use the regex above), it does properly handle tel: URLs\n try {\n new URL(url)\n return true\n } catch {\n /* empty */\n }\n\n return false\n}\n"],"mappings":"AAAA,OAAO,SAASA,YAAYC,GAAW;EACrC,yCACA,MAAMC,gBAAA,GAAmB;EAEzB;EACA,MAAMC,gBAAA,GACJ;EAEFF,GAAA,GAAMG,MAAA,CAAOH,GAAA,EAAKI,IAAI;EAEtB,IAAIJ,GAAA,CAAIK,KAAK,CAACJ,gBAAA,KAAqB,QAAQD,GAAA,CAAIK,KAAK,CAACH,gBAAA,KAAqB,MAAM;IAC9E,OAAOF,GAAA;EACT;EAEA,OAAO;AACT;AAEA;AACA,MAAMM,cAAA,GACJ;AAEF;;;;;;AAMA,MAAMC,sBAAA,GAAyB;AAE/B;;;;AAIA,OAAO,SAASC,mBAAmBR,GAAW;EAC5C,IAAI,CAACA,GAAA,EAAK;IACR,OAAO;EACT;EAEA,OAAO,CAACA,GAAA,CAAIS,QAAQ,CAAC;AACvB;AAEA;AACA;AACA,OAAO,SAASC,YAAYV,GAAW;EACrC;EACA;EAEA,IAAI,CAACA,GAAA,EAAK;IACR,OAAO;EACT;EAEA,IAAIA,GAAA,KAAQ,YAAY;IACtB,OAAO;EACT;EAEA;EACA,IAAIM,cAAA,CAAeK,IAAI,CAACX,GAAA,GAAM;IAC5B,OAAO;EACT;EAEA;EACA,IAAIO,sBAAA,CAAuBI,IAAI,CAACX,GAAA,GAAM;IACpC,OAAO;EACT;EAEA;EACA,IAAI;IACF,IAAIY,GAAA,CAAIZ,GAAA;IACR,OAAO;EACT,EAAE,MAAM;IACN;EAGF,OAAO;AACT","ignoreList":[]}
1
+ {"version":3,"file":"url.js","names":["sanitizeUrl","url","SAFE_URL_PATTERN","DATA_URL_PATTERN","String","trim","match","absoluteRegExp","relativeOrAnchorRegExp","validateUrlMinimal","includes","validateUrl","test","URL"],"sources":["../../../src/lexical/utils/url.ts"],"sourcesContent":["export function sanitizeUrl(url: string): string {\n /** A pattern that matches safe URLs. */\n const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^&:/?#]*(?:[/?#]|$))/gi\n\n /** A pattern that matches safe data URLs. */\n const DATA_URL_PATTERN =\n /^data:(?:image\\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\\/(?:mpeg|mp4|ogg|webm)|audio\\/(?:mp3|oga|ogg|opus));base64,[a-z\\d+/]+=*$/i\n\n url = String(url).trim()\n\n if (url.match(SAFE_URL_PATTERN) != null || url.match(DATA_URL_PATTERN) != null) {\n return url\n }\n\n return 'https://'\n}\n\n/**\n * This regex checks for absolute URLs in a string. Tested for the following use cases:\n * - http://example.com\n * - https://example.com\n * - ftp://files.example.com\n * - http://example.com/resource\n * - https://example.com/resource?key=value\n * - http://example.com/resource#anchor\n * - http://www.example.com\n * - https://sub.example.com/path/file\n * - mailto:\n */\nexport const absoluteRegExp =\n /^(?:[a-zA-Z][a-zA-Z\\d+.-]*:(?:\\/\\/)?(?:[-;:&=+$,\\w]+@)?[A-Za-z\\d]+(?:\\.[A-Za-z\\d]+)+|www\\.[A-Za-z\\d]+(?:\\.[A-Za-z\\d]+)+|(?:tel|mailto):[\\w+.-]+)(?:\\/[+~%/\\w-]*)?(?:\\?[-;&=%\\w]*)?(?:#\\w+)?$/\n\n/**\n * This regex checks for relative URLs starting with / or anchor links starting with # in a string. Tested for the following use cases:\n * - /privacy-policy\n * - /privacy-policy#primary-terms\n * - #primary-terms\n * */\nexport const relativeOrAnchorRegExp = /^(?:\\/[\\w\\-./]*(?:#\\w[\\w-]*)?|#[\\w\\-]+)$/\n\n/**\n * Prevents unreasonable URLs from being inserted into the editor.\n * @param url\n */\nexport function validateUrlMinimal(url: string): boolean {\n if (!url) {\n return false\n }\n\n return !url.includes(' ')\n}\n\n// Do not keep validateUrl function too loose. This is run when pasting in text, to determine if links are in that text and if it should create AutoLinkNodes.\n// This is why we do not allow stuff like anchors here, as we don't want copied anchors to be turned into AutoLinkNodes.\nexport function validateUrl(url: string): boolean {\n // TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.\n // Maybe show a dialog where they user can type the URL before inserting it.\n\n if (!url) {\n return false\n }\n\n if (url === 'https://') {\n return true\n }\n\n // This makes sure URLs starting with www. instead of https are valid too\n if (absoluteRegExp.test(url)) {\n return true\n }\n\n // Check relative or anchor links\n if (relativeOrAnchorRegExp.test(url)) {\n return true\n }\n\n // While this doesn't allow URLs starting with www (which is why we use the regex above), it does properly handle tel: URLs\n try {\n new URL(url)\n return true\n } catch {\n /* empty */\n }\n\n return false\n}\n"],"mappings":"AAAA,OAAO,SAASA,YAAYC,GAAW;EACrC,yCACA,MAAMC,gBAAA,GAAmB;EAEzB;EACA,MAAMC,gBAAA,GACJ;EAEFF,GAAA,GAAMG,MAAA,CAAOH,GAAA,EAAKI,IAAI;EAEtB,IAAIJ,GAAA,CAAIK,KAAK,CAACJ,gBAAA,KAAqB,QAAQD,GAAA,CAAIK,KAAK,CAACH,gBAAA,KAAqB,MAAM;IAC9E,OAAOF,GAAA;EACT;EAEA,OAAO;AACT;AAEA;;;;;;;;;;;;AAYA,OAAO,MAAMM,cAAA,GACX;AAEF;;;;;;AAMA,OAAO,MAAMC,sBAAA,GAAyB;AAEtC;;;;AAIA,OAAO,SAASC,mBAAmBR,GAAW;EAC5C,IAAI,CAACA,GAAA,EAAK;IACR,OAAO;EACT;EAEA,OAAO,CAACA,GAAA,CAAIS,QAAQ,CAAC;AACvB;AAEA;AACA;AACA,OAAO,SAASC,YAAYV,GAAW;EACrC;EACA;EAEA,IAAI,CAACA,GAAA,EAAK;IACR,OAAO;EACT;EAEA,IAAIA,GAAA,KAAQ,YAAY;IACtB,OAAO;EACT;EAEA;EACA,IAAIM,cAAA,CAAeK,IAAI,CAACX,GAAA,GAAM;IAC5B,OAAO;EACT;EAEA;EACA,IAAIO,sBAAA,CAAuBI,IAAI,CAACX,GAAA,GAAM;IACpC,OAAO;EACT;EAEA;EACA,IAAI;IACF,IAAIY,GAAA,CAAIZ,GAAA;IACR,OAAO;EACT,EAAE,MAAM;IACN;EAGF,OAAO;AACT","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ import { absoluteRegExp, relativeOrAnchorRegExp } from './url.js';
2
+ describe('Lexical URL Regex Matchers', () => {
3
+ describe('relative URLs', () => {
4
+ it('validation for links it should match', async () => {
5
+ const shouldMatch = ['/path/to/resource', '/file-name.html', '/', '/dir/', '/path.with.dots/', '#anchor', '#section-title', '/path#fragment'];
6
+ shouldMatch.forEach(testCase => {
7
+ expect(relativeOrAnchorRegExp.test(testCase)).toBe(true);
8
+ });
9
+ });
10
+ it('validation for links it should not match', async () => {
11
+ const shouldNotMatch = ['match', 'http://example.com', 'relative/path', 'file.html', 'some#fragment', '#', '/#', '/path/with spaces', '', 'ftp://example.com'];
12
+ shouldNotMatch.forEach(testCase => {
13
+ expect(relativeOrAnchorRegExp.test(testCase)).not.toBe(true);
14
+ });
15
+ });
16
+ });
17
+ describe('absolute URLs', () => {
18
+ it('validation for links it should match', async () => {
19
+ const shouldMatch = ['http://example.com', 'https://example.com', 'ftp://files.example.com', 'http://example.com/resource', 'https://example.com/resource?key=value', 'http://example.com/resource#anchor', 'http://www.example.com', 'https://sub.example.com/path/file', 'mailto:email@example.com', 'tel:+1234567890', 'http://user:pass@example.com', 'www.example.com', 'www.example.com/resource', 'www.example.com/resource?query=1', 'www.example.com#fragment'];
20
+ shouldMatch.forEach(testCase => {
21
+ expect(absoluteRegExp.test(testCase)).toBe(true);
22
+ });
23
+ });
24
+ it('validation for links it should not match', async () => {
25
+ const shouldNotMatch = ['/relative/path', '#anchor', 'example.com', '://missing.scheme', 'http://', 'http:/example.com', 'ftp://example .com', 'http://example', 'not-a-url', 'http//example.com', 'https://example.com/ spaces'];
26
+ shouldNotMatch.forEach(testCase => {
27
+ expect(absoluteRegExp.test(testCase)).not.toBe(true);
28
+ });
29
+ });
30
+ });
31
+ });
32
+ //# sourceMappingURL=url.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.spec.js","names":["absoluteRegExp","relativeOrAnchorRegExp","describe","it","shouldMatch","forEach","testCase","expect","test","toBe","shouldNotMatch","not"],"sources":["../../../src/lexical/utils/url.spec.ts"],"sourcesContent":["import { jest } from '@jest/globals'\nimport { absoluteRegExp, relativeOrAnchorRegExp } from './url.js'\n\ndescribe('Lexical URL Regex Matchers', () => {\n describe('relative URLs', () => {\n it('validation for links it should match', async () => {\n const shouldMatch = [\n '/path/to/resource',\n '/file-name.html',\n '/',\n '/dir/',\n '/path.with.dots/',\n '#anchor',\n '#section-title',\n '/path#fragment',\n ]\n\n shouldMatch.forEach((testCase) => {\n expect(relativeOrAnchorRegExp.test(testCase)).toBe(true)\n })\n })\n\n it('validation for links it should not match', async () => {\n const shouldNotMatch = [\n 'match',\n 'http://example.com',\n 'relative/path',\n 'file.html',\n 'some#fragment',\n '#',\n '/#',\n '/path/with spaces',\n '',\n 'ftp://example.com',\n ]\n\n shouldNotMatch.forEach((testCase) => {\n expect(relativeOrAnchorRegExp.test(testCase)).not.toBe(true)\n })\n })\n })\n\n describe('absolute URLs', () => {\n it('validation for links it should match', async () => {\n const shouldMatch = [\n 'http://example.com',\n 'https://example.com',\n 'ftp://files.example.com',\n 'http://example.com/resource',\n 'https://example.com/resource?key=value',\n 'http://example.com/resource#anchor',\n 'http://www.example.com',\n 'https://sub.example.com/path/file',\n 'mailto:email@example.com',\n 'tel:+1234567890',\n 'http://user:pass@example.com',\n 'www.example.com',\n 'www.example.com/resource',\n 'www.example.com/resource?query=1',\n 'www.example.com#fragment',\n ]\n\n shouldMatch.forEach((testCase) => {\n expect(absoluteRegExp.test(testCase)).toBe(true)\n })\n })\n\n it('validation for links it should not match', async () => {\n const shouldNotMatch = [\n '/relative/path',\n '#anchor',\n 'example.com',\n '://missing.scheme',\n 'http://',\n 'http:/example.com',\n 'ftp://example .com',\n 'http://example',\n 'not-a-url',\n 'http//example.com',\n 'https://example.com/ spaces',\n ]\n\n shouldNotMatch.forEach((testCase) => {\n expect(absoluteRegExp.test(testCase)).not.toBe(true)\n })\n })\n })\n})\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,sBAAsB,QAAQ;AAEvDC,QAAA,CAAS,8BAA8B;EACrCA,QAAA,CAAS,iBAAiB;IACxBC,EAAA,CAAG,wCAAwC;MACzC,MAAMC,WAAA,GAAc,CAClB,qBACA,mBACA,KACA,SACA,oBACA,WACA,kBACA,iBACD;MAEDA,WAAA,CAAYC,OAAO,CAAEC,QAAA;QACnBC,MAAA,CAAON,sBAAA,CAAuBO,IAAI,CAACF,QAAA,GAAWG,IAAI,CAAC;MACrD;IACF;IAEAN,EAAA,CAAG,4CAA4C;MAC7C,MAAMO,cAAA,GAAiB,CACrB,SACA,sBACA,iBACA,aACA,iBACA,KACA,MACA,qBACA,IACA,oBACD;MAEDA,cAAA,CAAeL,OAAO,CAAEC,QAAA;QACtBC,MAAA,CAAON,sBAAA,CAAuBO,IAAI,CAACF,QAAA,GAAWK,GAAG,CAACF,IAAI,CAAC;MACzD;IACF;EACF;EAEAP,QAAA,CAAS,iBAAiB;IACxBC,EAAA,CAAG,wCAAwC;MACzC,MAAMC,WAAA,GAAc,CAClB,sBACA,uBACA,2BACA,+BACA,0CACA,sCACA,0BACA,qCACA,4BACA,mBACA,gCACA,mBACA,4BACA,oCACA,2BACD;MAEDA,WAAA,CAAYC,OAAO,CAAEC,QAAA;QACnBC,MAAA,CAAOP,cAAA,CAAeQ,IAAI,CAACF,QAAA,GAAWG,IAAI,CAAC;MAC7C;IACF;IAEAN,EAAA,CAAG,4CAA4C;MAC7C,MAAMO,cAAA,GAAiB,CACrB,kBACA,WACA,eACA,qBACA,WACA,qBACA,sBACA,kBACA,aACA,qBACA,8BACD;MAEDA,cAAA,CAAeL,OAAO,CAAEC,QAAA;QACtBC,MAAA,CAAOP,cAAA,CAAeQ,IAAI,CAACF,QAAA,GAAWK,GAAG,CAACF,IAAI,CAAC;MACjD;IACF;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.18.0",
3
+ "version": "3.19.0-canary.9b65c78",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -352,8 +352,8 @@
352
352
  "react-error-boundary": "4.1.2",
353
353
  "ts-essentials": "10.0.3",
354
354
  "uuid": "10.0.0",
355
- "@payloadcms/translations": "3.18.0",
356
- "@payloadcms/ui": "3.18.0"
355
+ "@payloadcms/translations": "3.19.0-canary.9b65c78",
356
+ "@payloadcms/ui": "3.19.0-canary.9b65c78"
357
357
  },
358
358
  "devDependencies": {
359
359
  "@babel/cli": "7.25.9",
@@ -374,7 +374,7 @@
374
374
  "eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124",
375
375
  "swc-plugin-transform-remove-imports": "2.0.0",
376
376
  "@payloadcms/eslint-config": "3.9.0",
377
- "payload": "3.18.0"
377
+ "payload": "3.19.0-canary.9b65c78"
378
378
  },
379
379
  "peerDependencies": {
380
380
  "@faceless-ui/modal": "3.0.0-beta.2",
@@ -392,8 +392,8 @@
392
392
  "lexical": "0.21.0",
393
393
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
394
394
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
395
- "@payloadcms/next": "3.18.0",
396
- "payload": "3.18.0"
395
+ "@payloadcms/next": "3.19.0-canary.9b65c78",
396
+ "payload": "3.19.0-canary.9b65c78"
397
397
  },
398
398
  "engines": {
399
399
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- "use client";import{c as pe,f as z,g as B,i as ge,j as he,k as ye,l as xe,m as Ee}from"./chunk-7XFF5VOE.js";import{a as fe,b as P}from"./chunk-3LGFOM34.js";import{jsx as D,jsxs as ie}from"react/jsx-runtime";import{FieldDescription as co,FieldError as mo,FieldLabel as uo,RenderCustomComponent as Ze,useEditDepth as fo,useField as po}from"@payloadcms/ui";import{mergeFieldStyles as go}from"@payloadcms/ui/shared";import{useCallback as et,useEffect as ho,useMemo as yo,useState as xo}from"react";import{ErrorBoundary as Eo}from"react-error-boundary";import"./bundled.css";import{jsx as F}from"react/jsx-runtime";import{LexicalComposer as so}from"@lexical/react/LexicalComposer.js";import{useEditDepth as lo}from"@payloadcms/ui";import*as Je from"react";import{useMemo as ao}from"react";import{c as Gt}from"react/compiler-runtime";import{jsx as b,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as Yt}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Vt}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Ut}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as qt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Jt}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Qt,COMMAND_PRIORITY_LOW as Ue,FOCUS_COMMAND as Xt}from"lexical";import*as V from"react";import{useEffect as Zt,useState as eo}from"react";import{jsx as Ce}from"react/jsx-runtime";import"react";var _=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ce(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ce(o.Component,{clientProps:e});import{jsx as ae}from"react/jsx-runtime";import{useLexicalComposerContext as st}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as lt}from"lexical";import*as we from"react";import{useCallback as at,useEffect as Pe,useRef as ct,useState as mt}from"react";import{createPortal as dt}from"react-dom";var K=(t,e,o,n,r=50,m=25)=>{let a=0;if(t&&!t.contains(n)){let{bottom:s,left:c,right:x,top:g}=t.getBoundingClientRect(),l=g+window.scrollY,i=s+window.scrollY;if(o<l-m||o>i+m||e<c-r||e>x+r)return-1;(e<c||e>x)&&(a=e<c?e-c:e-x)}return a};import{$getNodeByKey as X}from"lexical";function W(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let n=o.split(",").pop();return e.y=e.y-Number(n?.replace(")","")),e}function Q(t){let e=(c,x)=>c?parseFloat(window.getComputedStyle(c)[x]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),a=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:a}}import{$getRoot as tt}from"lexical";function $(t){return t.getEditorState().read(()=>tt().getChildrenKeys())}var ot=1,nt=-1,be=0,A={props:null,result:null};function rt(t,e,o=20){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function G(t){let{anchorElem:e,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:m=0,point:{x:a,y:s},startIndex:c=0,useEdgeAsDefault:x=!1}=t;if(o>0&&A.props&&A.result&&A.props.fuzzy===t.fuzzy&&A.props.horizontalOffset===t.horizontalOffset&&A.props.useEdgeAsDefault===t.useEdgeAsDefault&&rt(A.props.point,t.point,o))return A.result;let g=e.getBoundingClientRect(),l=$(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(x){let[u,h]=[n.getElementByKey(l[0]),n.getElementByKey(l[l.length-1])];if(u&&h){let[d,f]=[W(u),W(h)];if(s<d.top?(i.blockElem=u,i.distance=d.top-s,i.blockNode=X(l[0]),i.foundAtIndex=0):s>f.bottom&&(i.distance=s-f.bottom,i.blockNode=X(l[l.length-1]),i.blockElem=h,i.foundAtIndex=l.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=c,y=be;for(;p>=0&&p<l.length;){let u=l[p],h=n.getElementByKey(u);if(h===null)break;let d=new B(a+m,s),f=xe.fromDOMRect(W(h)),{marginBottom:E,marginTop:k}=Q(h),T=f.generateNewRect({bottom:f.bottom+E,left:g.left,right:g.right,top:f.top-k}),{distance:w,isOnBottomSide:S,isOnTopSide:N}=T.distanceFromPoint(d);if(w===0){i.blockElem=h,i.blockNode=X(u),i.foundAtIndex=p,i.distance=w,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&w<i.distance&&(i.blockElem=h,i.blockNode=X(u),i.distance=w,i.foundAtIndex=p);y===be&&(N?y=nt:S?y=ot:y=1/0),p+=y}}),A.props=t,A.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function Z(t,e){return!!t.closest(`.${e}`)}var it=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ne(t){if(!t||it.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function ee(t,e,o,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),a=e.getBoundingClientRect(),s=o.getBoundingClientRect(),c;if(["lexical-block","lexical-upload","lexical-relationship"].some(l=>t.firstElementChild?.classList.contains(l)))c=r.top+8-s.top;else{let l=Ne(t)?parseInt(m.lineHeight,10):0;c=r.top+(l-a.height)/2-s.top}let g=n;e.style.opacity="1",e.style.transform=`translate(${g}px, ${c}px)`}var ut="add-block-menu",te=1/0;function ft(t){return t===0?1/0:te>=0&&te<t?te:Math.floor(t/2)}function pt(t,e,o){let n=e.parentElement,{editorConfig:r}=P(),m=r?.admin?.hideGutter?-24:12,a=ct(null),[s,c]=mt(null);Pe(()=>{function g(l){let i=l.target;if(!z(i))return;let p=K(n,l.pageX,l.pageY,i);if(p===-1){c(null);return}if(Z(i,ut))return;let y=$(t),{blockElem:u,blockNode:h,foundAtIndex:d}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new B(l.x,l.y),returnEmptyParagraphs:!0,startIndex:ft(y.length),useEdgeAsDefault:!1});te=d,u&&h&&(s?.node!==h||s?.elem!==u)&&c({elem:u,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[n,e,t,s]),Pe(()=>{a.current&&s?.node&&ee(s?.elem,a.current,e,m)},[e,s,m]);let x=at(g=>{let l=s;l?.node&&(t.update(()=>{let i=!0;if((l?.node.getType()!=="paragraph"||l.node.getTextContent()!=="")&&(i=!1),!i){let p=lt();l?.node.insertAfter(p),setTimeout(()=>{l={elem:t.getElementByKey(p.getKey()),node:p},c(l)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),l?.node&&"select"in l.node&&typeof l.node.select=="function"&&l.node.select()})},1),setTimeout(()=>{t.dispatchCommand(he,{node:l?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return dt(ae(we.Fragment,{children:ae("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{x(g)},ref:a,type:"button",children:ae("div",{className:o?"icon":""})})}),e)}function Re(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=st();return pt(n,o,n._editable)}import{jsx as oe,jsxs as ht}from"react/jsx-runtime";import{useLexicalComposerContext as yt}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Se}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as ve,$getNodeByKey as xt}from"lexical";import*as Be from"react";import{useEffect as ce,useRef as ne,useState as Ae}from"react";import{createPortal as Et}from"react-dom";var Te=0,gt=-24;var H=0;function ke(t,e,o,n,r,m,a,s,c,x=!1){let{height:g,top:l}=n.getBoundingClientRect(),{top:i,width:p}=a.getBoundingClientRect(),{marginBottom:y,marginTop:u}=Q(n),h=l,d=m>=l+g/2+window.scrollY,f=!1;if(r?.elem)if(n!==r?.elem)(d&&r?.elem&&r?.elem===n.nextElementSibling||!d&&r?.elem&&r?.elem===n.previousElementSibling)&&(H++,H<200&&(f=!0));else{H++;let w=r?.boundingBox?.y,S=n.getBoundingClientRect().y;(d===r?.isBelow&&w===S||H<200)&&(f=!1)}if(f)return{isBelow:d,willStayInSamePosition:f};x?h+=g/2:d?h+=g+y/2:h-=u/2;let E=0;x||(d?E=-Te:E=Te);let k=h-i+E,T=gt-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${T}px, calc(${k}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?d?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),H=0,{isBelow:d,willStayInSamePosition:f}}var Ct="draggable-block-menu",Ie="application/x-lexical-drag-block",U=1/0;function Le(t){return t===0?1/0:U>=0&&U<t?U:Math.floor(t/2)}function bt(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Me(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Nt(t,e,o){let n=e.parentElement,r=ne(null),m=ne(null),a=ne(null),s=ne(!1),[c,x]=Ae(null),[g,l]=Ae(null),{editorConfig:i}=P(),p=i?.admin?.hideGutter?-44:-8;ce(()=>{function h(d){let f=d.target;if(!z(f))return;let E=K(n,d.pageX,d.pageY,f);if(E===-1){x(null);return}if(Z(f,Ct))return;let k=$(t),{blockElem:T,foundAtIndex:w,isFoundNodeEmptyParagraph:S}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(d.x,d.y),startIndex:Le(k.length),useEdgeAsDefault:!1,verbose:!1});U=w,!(!T&&!S)&&c!==T&&x(T)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[n,e,t,c]),ce(()=>{r.current&&ee(c,r.current,e,p)},[e,c,p]),ce(()=>{function h(f){if(!s.current)return!1;let[E]=Se(f);if(E)return!1;let{pageY:k,target:T}=f;if(!z(T))return!1;let w=K(n,f.pageX,f.pageY,T,100,50),S=$(t),{blockElem:N,foundAtIndex:j,isFoundNodeEmptyParagraph:L}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-w,point:new B(f.x,f.y),startIndex:Le(S.length),useEdgeAsDefault:!0,verbose:!0});U=j;let O=m.current;if(N===null||O===null)return!1;if(c!==N){let{isBelow:v,willStayInSamePosition:M}=ke(i?.admin?.hideGutter?"0px":"3rem",p+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),O,N,g,k,e,f,a,L);f.preventDefault(),M||l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:v})}else g?.elem&&(Me(O,g.elem),l({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function d(f){if(!s.current)return!1;let[E]=Se(f);if(E)return!1;let{dataTransfer:k,pageY:T,target:w}=f,S=k?.getData(Ie)||"";return t.update(()=>{let N=xt(S);if(!N||!z(w))return!1;let j=K(n,f.pageX,f.pageY,w,100,50),{blockElem:L,isFoundNodeEmptyParagraph:O}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-j,point:new B(f.x,f.y),useEdgeAsDefault:!0});if(!L)return!1;let v=ve(L);if(!v)return!1;if(v===N)return!0;let{height:M,top:se}=W(L),J=T>=se+M/2+window.scrollY;O?(v.insertBefore(N),v.remove()):J?v.insertAfter(N):v.insertBefore(N),c!==null&&x(null),document.querySelectorAll(".lexical-block-highlighter").forEach(R=>{R.remove()});let le=t.getElementByKey(N.getKey());setTimeout(()=>{let R=le?.getBoundingClientRect();if(!R)return;let C=document.createElement("div");C.className="lexical-block-highlighter",C.style.backgroundColor="var(--theme-elevation-1000",C.style.transition="opacity 0.5s ease-in-out",C.style.zIndex="1",C.style.pointerEvents="none",C.style.boxSizing="border-box",C.style.borderRadius="4px",C.style.position="absolute",document.body.appendChild(C),C.style.opacity="0.1",C.style.height=`${R.height+8}px`,C.style.width=`${R.width+8}px`,C.style.top=`${R.top+window.scrollY-4}px`,C.style.left=`${R.left-4}px`,setTimeout(()=>{C.style.opacity="0",setTimeout(()=>{C.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",d)}},[n,p,e,t,g,c,i?.admin?.hideGutter]);function y(h){let d=h.dataTransfer;if(!d||!c)return;bt(d,c);let f="";t.update(()=>{let E=ve(c);E&&(f=E.getKey())}),s.current=!0,d.setData(Ie,f)}function u(){s.current=!1,g?.elem&&Me(m.current,g?.elem)}return Et(ht(Be.Fragment,{children:[oe("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:u,onDragStart:y,ref:r,children:oe("div",{className:o?"icon":""})}),oe("div",{className:"draggable-block-target-line",ref:m}),oe("div",{className:"debug-highlight",ref:a})]}),e)}function Fe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=yt();return Nt(n,o,n._editable)}import{c as Pt}from"react/compiler-runtime";import{jsx as me}from"react/jsx-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Rt,$getRoot as Tt}from"lexical";import"react";var De="insert-paragraph-at-end",Oe=()=>{let t=Pt(4),[e]=wt(),{editorConfig:o}=P();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;t[0]!==e?(n=()=>{e.update(kt)},t[0]=e,t[1]=n):n=t[1];let r=n,m;return t[2]!==r?(m=me("div",{"aria-label":"Insert Paragraph",className:De,onClick:r,children:me("div",{className:`${De}-inside`,children:me("span",{children:"+"})})}),t[2]=r,t[3]=m):m=t[3],m};function kt(){let t=Rt();Tt().append(t),t.select()}import{c as St}from"react/compiler-runtime";import{useLexicalComposerContext as vt}from"@lexical/react/LexicalComposerContext";import*as _e from"react";var $e=()=>{let t=St(4),{editorConfig:e}=P(),[o]=vt(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>pe(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=n,t[3]=r):(n=t[2],r=t[3]),_e.useEffect(n,r),null};import{jsx as Y,jsxs as je}from"react/jsx-runtime";import{useLexicalComposerContext as It}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as ze}from"@payloadcms/ui";import{useCallback as Lt,useMemo as Mt,useState as Bt}from"react";import"react";import*as Ke from"react-dom";import{c as At}from"react/compiler-runtime";import"react";function He(t,e){let o=At(4),{maxLength:n,minLength:r}=e,m=n===void 0?75:n,a=r===void 0?1:r,s;return o[0]!==m||o[1]!==a||o[2]!==t?(s=c=>{let{query:x}=c,g="[^"+t+ge+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+m+"}))$").exec(x);if(i!==null){let p=i[1],y=i[3];if(y.length>=a)return{leadOffset:i.index+p.length,matchingString:y,replaceableString:i[2]}}return null},o[0]=m,o[1]=a,o[2]=t,o[3]=s):s=o[3],s}var I="slash-menu-popup";function Ft({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:m,schemaPath:a}}=P(),{i18n:s}=ze(),c=`${I}__item ${I}__item-${e.key}`;t&&(c+=` ${I}__item--selected`);let x=e.key;return e.label&&(x=typeof e.label=="function"?e.label({featureClientSchemaMap:m,i18n:s,schemaPath:a}):e.label),x.length>25&&(x=x.substring(0,25)+"..."),je("button",{"aria-selected":t,className:c,id:I+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&Y(e.Icon,{}),Y("span",{className:`${I}__item-text`,children:x})]},e.key)}function We({anchorElem:t=document.body}){let[e]=It(),[o,n]=Bt(null),{editorConfig:r}=P(),{i18n:m}=ze(),{fieldProps:{featureClientSchemaMap:a,schemaPath:s}}=P(),c=He("/",{minLength:0}),x=Lt(()=>{let l=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let p=i({editor:e,queryString:o});l=l.concat(p)}return l},[e,o,r?.features]),g=Mt(()=>{let l=[];for(let i of r?.features.slashMenu.groups??[])l.push(i);if(o){l=l.map(p=>{let y=p.items.filter(u=>{let h=u.key;return u.label&&(h=typeof u.label=="function"?u.label({featureClientSchemaMap:a,i18n:m,schemaPath:s}):u.label),new RegExp(o,"gi").exec(h)?!0:u.keywords!=null?u.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return y.length?{...p,items:y}:null}),l=l.filter(p=>p!=null);let i=x();for(let p of i){let y=l.find(u=>u.key===p.key);y?l=l.filter(u=>u.key!==p.key):y={...p,items:[]},y?.items?.length&&(y.items=y.items.concat(y.items)),l.push(y)}}return l},[o,r?.features.slashMenu.groups,x,a,m,s]);return Y(ye,{anchorElem:t,groups:g,menuRenderFn:(l,{selectedItemKey:i,selectItemAndCleanUp:p,setSelectedItemKey:y})=>l.current&&g.length?Ke.createPortal(Y("div",{className:I,children:g.map(u=>{let h=u.key;return u.label&&a&&(h=typeof u.label=="function"?u.label({featureClientSchemaMap:a,i18n:m,schemaPath:s}):u.label),je("div",{className:`${I}__group ${I}__group-${u.key}`,children:[Y("div",{className:`${I}__group-title`,children:h}),u.items.map((d,f)=>Y(Ft,{index:f,isSelected:i===d.key,item:d,onClick:()=>{y(d.key),p(d)},onMouseEnter:()=>{y(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},u.key)})}),l.current):null,onQueryChange:n,triggerFn:c})}import{c as Dt}from"react/compiler-runtime";import{useLexicalComposerContext as Ot}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as _t,TextNode as $t}from"lexical";import{useEffect as Ht}from"react";function Ge(t){let e=Dt(6),{features:o}=t,[n]=Ot(),r;e[0]!==n||e[1]!==o.enabledFormats?(r=()=>{let a=jt(o.enabledFormats);if(a.length!==0)return n.registerNodeTransform($t,s=>{a.forEach(c=>{s.hasFormat(c)&&s.toggleFormat(c)})})},e[0]=n,e[1]=o.enabledFormats,e[2]=r):r=e[2];let m;return e[3]!==n||e[4]!==o?(m=[n,o],e[3]=n,e[4]=o,e[5]=m):m=e[5],Ht(r,m),null}function jt(t){let e=Object.keys(_t),o=new Set(t);return e.filter(n=>!o.has(n))}import{c as zt}from"react/compiler-runtime";import{jsx as Ye}from"react/jsx-runtime";import{ContentEditable as Kt}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Wt}from"@payloadcms/ui";import"react";function Ve(t){let e=zt(7),{className:o,editorConfig:n}=t,{t:r}=Wt(),m;if(e[0]!==o||e[1]!==n?.admin?.placeholder||e[2]!==r){let a;e[4]!==n?.admin?.placeholder||e[5]!==r?(a=n?.admin?.placeholder??r("lexical:general:placeholder"),e[4]=n?.admin?.placeholder,e[5]=r,e[6]=a):a=e[6],m=Ye(Kt,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ye("p",{className:"editor-placeholder",children:a})}),e[0]=o,e[1]=n?.admin?.placeholder,e[2]=r,e[3]=m}else m=e[3];return m}var qe=t=>{let e=Gt(19),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:m}=t,a=P(),[s]=Yt(),[c,x]=eo(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=u=>{u!==null&&x(u)},e[0]=g):g=e[0];let l=g,i,p;e[1]!==s||e[2]!==a?(i=()=>{if(!a?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}a?.parentEditor?.uuid&&a.parentEditor?.registerChild(a.uuid,a);let u=()=>{a.focusEditor(a)},h=()=>{a.blurEditor(a)},d=s.registerCommand(Xt,()=>(u(),!0),Ue),f=s.registerCommand(Qt,()=>(h(),!0),Ue);return()=>{d(),f(),a.parentEditor?.unregisterChild?.(a.uuid)}},p=[s,a],e[1]=s,e[2]=a,e[3]=i,e[4]=p):(i=e[3],p=e[4]),Zt(i,p);let y;if(e[5]!==s||e[6]!==o||e[7]!==n||e[8]!==c||e[9]!==r||e[10]!==m){let u;e[12]!==m?(u=(d,f,E)=>{(!E.has("focus")||E.size>1)&&m?.(d,f,E)},e[12]=m,e[13]=u):u=e[13];let h;e[14]!==s||e[15]!==o.features.plugins||e[16]!==c||e[17]!==r?(h=c&&q(V.Fragment,{children:[!r&&s.isEditable()&&q(V.Fragment,{children:[b(Fe,{anchorElem:c}),b(Re,{anchorElem:c})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&r))return b(_,{anchorElem:c,clientProps:d.clientProps,plugin:d},d.key)}),s.isEditable()&&b(V.Fragment,{children:b(We,{anchorElem:c})})]}),e[14]=s,e[15]=o.features.plugins,e[16]=c,e[17]=r,e[18]=h):h=e[18],y=q(V.Fragment,{children:[o.features.plugins?.map(to),q("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(oo),b(Jt,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:l,children:b(Ve,{editorConfig:o})})}),ErrorBoundary:Vt}),b(Oe,{}),b(Ge,{features:o.features}),b(qt,{ignoreSelectionChange:!0,onChange:u}),h,s.isEditable()&&q(V.Fragment,{children:[b(Ut,{}),o?.features?.markdownTransformers?.length>0&&b($e,{})]}),o.features.plugins?.map(no),o.features.plugins?.map(ro)]}),o.features.plugins?.map(io)]}),e[5]=s,e[6]=o,e[7]=n,e[8]=c,e[9]=r,e[10]=m,e[11]=y}else y=e[11];return y};function to(t){if(t.position==="aboveContainer")return b(_,{clientProps:t.clientProps,plugin:t},t.key)}function oo(t){if(t.position==="top")return b(_,{clientProps:t.clientProps,plugin:t},t.key)}function no(t){if(t.position==="normal")return b(_,{clientProps:t.clientProps,plugin:t},t.key)}function ro(t){if(t.position==="bottom")return b(_,{clientProps:t.clientProps,plugin:t},t.key)}function io(t){if(t.position==="belowContainer")return b(_,{clientProps:t.clientProps,plugin:t},t.key)}var Qe=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?F(o,{children:F(Qe,{providers:e.slice(1),children:t})}):F(o,{children:t})},Xe=t=>{let{composerKey:e,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:m,readOnly:a,value:s}=t,c=P(),x=lo(),g=Je.useRef(null),l=ao(()=>{if(s&&typeof s!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(s));if(s&&Array.isArray(s)&&!("root"in s))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(s&&"jsonContent"in s)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:a!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Ee({editorConfig:o}),onError:i=>{throw i},theme:o.lexical.theme}},[o]);return l?F(so,{initialConfig:l,children:F(fe,{editorConfig:o,editorContainerRef:g,fieldProps:n,parentContext:c?.editDepth===x?c:void 0,children:F(Qe,{providers:o.features.providers,children:F(qe,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:r,onChange:m})})})},e+l.editable):F("p",{children:"Loading..."})};var re="rich-text-lexical",Co=t=>{let{editorConfig:e,field:o,field:{name:n,admin:{className:r,description:m,readOnly:a}={},label:s,localized:c,required:x},path:g,readOnly:l,validate:i}=t,p=l||a,y=g??n,u=fo(),h=et((R,C)=>typeof i=="function"?i(R,{...C,required:x}):!0,[i,x]),{customComponents:{AfterInput:d,BeforeInput:f,Description:E,Error:k,Label:T}={},formInitializing:w,formProcessing:S,initialValue:N,setValue:j,showError:L,value:O}=po({path:y,validate:h}),v=p||S||w,[M,se]=xo(!1);ho(()=>{let R=()=>{let C=window.matchMedia("(max-width: 768px)").matches;C!==M&&se(C)};return R(),window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R)}},[M]);let de=[re,"field-type",r,L&&"error",v&&`${re}--read-only`,e?.admin?.hideGutter!==!0&&!M?`${re}--show-gutter`:null].filter(Boolean).join(" "),J=`${y}.${u}`,ue=et(R=>{j(R.toJSON())},[j]),le=yo(()=>go(o),[o]);return ie("div",{className:de,style:le,children:[D(Ze,{CustomComponent:k,Fallback:D(mo,{path:y,showError:L})}),T||D(uo,{label:s,localized:c,path:y,required:x}),ie("div",{className:`${re}__wrap`,children:[ie(Eo,{fallbackRender:bo,onReset:()=>{},children:[f,D(Xe,{composerKey:J,editorConfig:e,fieldProps:t,isSmallWidthViewport:M,onChange:ue,readOnly:v,value:O},JSON.stringify({initialValue:N,path:y})),d]}),E,D(Ze,{CustomComponent:E,Fallback:D(co,{description:m,path:y})})]})]},J)};function bo({error:t}){return ie("div",{className:"errorBoundary",role:"alert",children:[D("p",{children:"Something went wrong:"}),D("pre",{style:{color:"red"},children:t.message})]})}var zr=Co;export{zr as RichText};
2
- //# sourceMappingURL=Field-F5XP4HL4.js.map