@payloadcms/richtext-lexical 3.41.0-canary.0 → 3.41.0-canary.1

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":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,OAAO,sBAAsB,CAAA;AAW7B,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,CA4J5D,CAAA"}
1
+ {"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,OAAO,sBAAsB,CAAA;AAY7B,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,CA6J5D,CAAA"}
@@ -18,6 +18,7 @@ import { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/ind
18
18
  import { InsertParagraphAtEndPlugin } from './plugins/InsertParagraphAtEnd/index.js';
19
19
  import { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js';
20
20
  import { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js';
21
+ import { SelectAllPlugin } from './plugins/SelectAllPlugin/index.js';
21
22
  import { SlashMenuPlugin } from './plugins/SlashMenu/index.js';
22
23
  import { TextPlugin } from './plugins/TextPlugin/index.js';
23
24
  import { LexicalContentEditable } from './ui/ContentEditable.js';
@@ -150,7 +151,7 @@ export const LexicalEditor = props => {
150
151
  ErrorBoundary: LexicalErrorBoundary
151
152
  }), _jsx(NormalizeSelectionPlugin, {}), _jsx(InsertParagraphAtEndPlugin, {}), _jsx(DecoratorPlugin, {}), _jsx(TextPlugin, {
152
153
  features: editorConfig.features
153
- }), _jsx(OnChangePlugin, {
154
+ }), _jsx(SelectAllPlugin, {}), _jsx(OnChangePlugin, {
154
155
  ignoreSelectionChange: true,
155
156
  onChange: t4
156
157
  }), t5, editor.isEditable() && _jsxs(React.Fragment, {
@@ -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","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","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 { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } 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 { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/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 <NormalizeSelectionPlugin />\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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;;;;;SA7FHjC,E;CAoGJ;AA3JI,SAAAuB,MAAAL,MAAA;EAAA,IAyDQA,MAAA,CAAAC,QAAA,KAAoB;IAAA,OACfL,IAAA,CAAAvD,YAAA;MAAA8D,WAAA,EAA2BH,MAAA,CAAAG,WAAA;MAAAH;IAAA,GAAyBA,MAAA,CAAAI,GAAU;EAAA;AAAA;AA1D3E,SAAAI,OAAAQ,QAAA;EAAA,IA+DUhB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBL,IAAA,CAAAvD,YAAA;MAAA8D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAjExE,SAAAS,OAAAI,QAAA;EAAA,IAsIUjB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBL,IAAA,CAAAvD,YAAA;MAAA8D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAxIxE,SAAAU,OAAAI,QAAA;EAAA,IA6IUlB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBL,IAAA,CAAAvD,YAAA;MAAA8D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA/IxE,SAAAW,OAAAI,QAAA;EAAA,IAqJQnB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfL,IAAA,CAAAvD,YAAA;MAAA8D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
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","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","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 { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } 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 { NormalizeSelectionPlugin } from './plugins/NormalizeSelection/index.js'\nimport { SelectAllPlugin } from './plugins/SelectAllPlugin/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 <NormalizeSelectionPlugin />\n <InsertParagraphAtEndPlugin />\n <DecoratorPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\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,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,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,wBAAwB,QAAQ;AACzC,SAASC,eAAe,QAAQ;AAChC,SAASC,eAAe,QAAQ;AAChC,SAASC,UAAU,QAAQ;AAC3B,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAKTC,KAAA;EAAA,MAAAC,CAAA,GAAA1B,EAAA;EACF;IAAA2B,YAAA;IAAAC,kBAAA;IAAAC,oBAAA;IAAAC;EAAA,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MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAzIxE,SAAAU,OAAAI,QAAA;EAAA,IA8IUlB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBL,IAAA,CAAAxD,YAAA;MAAA+D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAhJxE,SAAAW,OAAAI,QAAA;EAAA,IAsJQnB,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfL,IAAA,CAAAxD,YAAA;MAAA+D,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Allows to select inputs with `ctrl+a` or `cmd+a`.
3
+ * Required because Lexical preventDefault the event.
4
+ * see: https://github.com/payloadcms/payload/issues/6871
5
+ */
6
+ export declare function SelectAllPlugin(): null;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/SelectAllPlugin/index.tsx"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,SAsB9B"}
@@ -0,0 +1,26 @@
1
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
2
+ import { $getSelection, COMMAND_PRIORITY_LOW, SELECT_ALL_COMMAND } from 'lexical';
3
+ import { useEffect } from 'react';
4
+ /**
5
+ * Allows to select inputs with `ctrl+a` or `cmd+a`.
6
+ * Required because Lexical preventDefault the event.
7
+ * see: https://github.com/payloadcms/payload/issues/6871
8
+ */
9
+ export function SelectAllPlugin() {
10
+ const [editor] = useLexicalComposerContext();
11
+ useEffect(() => {
12
+ return editor.registerCommand(SELECT_ALL_COMMAND, () => {
13
+ const selection = $getSelection();
14
+ if (selection) {
15
+ return false;
16
+ }
17
+ const activeElement = document.activeElement;
18
+ if (activeElement instanceof HTMLInputElement) {
19
+ activeElement.select();
20
+ }
21
+ return true;
22
+ }, COMMAND_PRIORITY_LOW);
23
+ }, [editor]);
24
+ return null;
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["useLexicalComposerContext","$getSelection","COMMAND_PRIORITY_LOW","SELECT_ALL_COMMAND","useEffect","SelectAllPlugin","editor","registerCommand","selection","activeElement","document","HTMLInputElement","select"],"sources":["../../../../src/lexical/plugins/SelectAllPlugin/index.tsx"],"sourcesContent":["import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $getSelection, COMMAND_PRIORITY_LOW, SELECT_ALL_COMMAND } from 'lexical'\nimport { useEffect } from 'react'\n\n/**\n * Allows to select inputs with `ctrl+a` or `cmd+a`.\n * Required because Lexical preventDefault the event.\n * see: https://github.com/payloadcms/payload/issues/6871\n */\nexport function SelectAllPlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand(\n SELECT_ALL_COMMAND,\n () => {\n const selection = $getSelection()\n if (selection) {\n return false\n }\n const activeElement = document.activeElement\n if (activeElement instanceof HTMLInputElement) {\n activeElement.select()\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n }, [editor])\n\n return null\n}\n"],"mappings":"AAAA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,EAAEC,oBAAoB,EAAEC,kBAAkB,QAAQ;AACxE,SAASC,SAAS,QAAQ;AAE1B;;;;;AAKA,OAAO,SAASC,gBAAA;EACd,MAAM,CAACC,MAAA,CAAO,GAAGN,yBAAA;EAEjBI,SAAA,CAAU;IACR,OAAOE,MAAA,CAAOC,eAAe,CAC3BJ,kBAAA,EACA;MACE,MAAMK,SAAA,GAAYP,aAAA;MAClB,IAAIO,SAAA,EAAW;QACb,OAAO;MACT;MACA,MAAMC,aAAA,GAAgBC,QAAA,CAASD,aAAa;MAC5C,IAAIA,aAAA,YAAyBE,gBAAA,EAAkB;QAC7CF,aAAA,CAAcG,MAAM;MACtB;MACA,OAAO;IACT,GACAV,oBAAA;EAEJ,GAAG,CAACI,MAAA,CAAO;EAEX,OAAO;AACT","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.41.0-canary.0",
3
+ "version": "3.41.0-canary.1",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -365,8 +365,8 @@
365
365
  "react-error-boundary": "4.1.2",
366
366
  "ts-essentials": "10.0.3",
367
367
  "uuid": "10.0.0",
368
- "@payloadcms/translations": "3.41.0-canary.0",
369
- "@payloadcms/ui": "3.41.0-canary.0"
368
+ "@payloadcms/translations": "3.41.0-canary.1",
369
+ "@payloadcms/ui": "3.41.0-canary.1"
370
370
  },
371
371
  "devDependencies": {
372
372
  "@babel/cli": "7.26.4",
@@ -386,15 +386,15 @@
386
386
  "esbuild-sass-plugin": "3.3.1",
387
387
  "swc-plugin-transform-remove-imports": "3.1.0",
388
388
  "@payloadcms/eslint-config": "3.28.0",
389
- "payload": "3.41.0-canary.0"
389
+ "payload": "3.41.0-canary.1"
390
390
  },
391
391
  "peerDependencies": {
392
392
  "@faceless-ui/modal": "3.0.0-beta.2",
393
393
  "@faceless-ui/scroll-info": "2.0.0",
394
394
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
395
395
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
396
- "@payloadcms/next": "3.41.0-canary.0",
397
- "payload": "3.41.0-canary.0"
396
+ "@payloadcms/next": "3.41.0-canary.1",
397
+ "payload": "3.41.0-canary.1"
398
398
  },
399
399
  "engines": {
400
400
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- "use client";import{b as Re,e as _,g as we,h as Te,i as ve,j as De,k as Me}from"./chunk-DOZWITPU.js";import{a as ke,b as k}from"./chunk-BZZVLW4U.js";import{jsx as O,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as fn,FieldError as mn,FieldLabel as pn,RenderCustomComponent as yt,useEditDepth as gn,useEffectEvent as hn,useField as yn}from"@payloadcms/ui";import{mergeFieldStyles as xn}from"@payloadcms/ui/shared";import xt,{useCallback as Et,useEffect as bt,useMemo as En,useRef as bn,useState as Ct}from"react";import{ErrorBoundary as Cn}from"react-error-boundary";import"./bundled.css";import{jsx as F}from"react/jsx-runtime";import{LexicalComposer as cn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as dn}from"@payloadcms/ui";import*as pt from"react";import{useMemo as un}from"react";import{c as Go}from"react/compiler-runtime";import{jsx as b,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as Uo}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as qo}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as Jo}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as Qo}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Xo}from"@lexical/react/LexicalRichTextPlugin.js";import{BLUR_COMMAND as Zo,COMMAND_PRIORITY_LOW as ft,FOCUS_COMMAND as en}from"lexical";import*as J from"react";import{useEffect as tn,useState as on}from"react";import{jsx as Le}from"react/jsx-runtime";import"react";var K=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Le(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Le(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as Rt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as wt}from"@lexical/utils";import{$createNodeSelection as Tt,$getEditor as X,$getNearestNodeFromDOMNode as vt,$getSelection as re,$isDecoratorNode as H,$isElementNode as xe,$isLineBreakNode as Dt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Mt,$isTextNode as Lt,$setSelection as Ie,CLICK_COMMAND as Bt,COMMAND_PRIORITY_LOW as Y,KEY_ARROW_DOWN_COMMAND as It,KEY_ARROW_UP_COMMAND as At,KEY_BACKSPACE_COMMAND as _t,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as Ot}from"lexical";import{useEffect as $t}from"react";function Ae(){let t=kt(3),[e]=Rt(),o=Vt,r,n;return t[0]!==e?(r=()=>wt(e.registerCommand(Bt,Yt,Y),e.registerCommand(Ft,o,Y),e.registerCommand(_t,o,Y),e.registerCommand(Ot,Wt,Y),e.registerCommand(At,jt,Y),e.registerCommand(It,Kt,Y)),n=[e],t[0]=e,t[1]=r,t[2]=n):(r=t[1],n=t[2]),$t(r,n),null}function Kt(t){let e=re();if(ie(e)){t.preventDefault();let i=e.getNodes()[0]?.getNextSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y&&Z({element:y,node:i}),!0}if(!xe(i))return!0;let s=i.getFirstDescendant()??i;return s&&(ne(s,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,Ht),c=n?.getNextSibling();if(!n||c!==_e(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function Ht(t){return _e(t)!==null}function jt(t){let e=re();if(ie(e)){let i=e.getNodes()[0]?.getPreviousSibling();if(H(i)){let y=X().getElementByKey(i.getKey());return y?(Z({element:y,node:i}),t.preventDefault(),!0):!1}if(!xe(i))return!1;let s=i.getLastDescendant()??i;return s?(ne(s,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let r=(e.isBackward()?e.anchor:e.focus).getNode(),n=ne(r,zt),c=n?.getPreviousSibling();if(!n||c!==Fe(n))return!1;if(H(c)){let i=X().getElementByKey(c.getKey());if(i)return Z({element:i,node:c}),t.preventDefault(),!0}return!1}function zt(t){return Fe(t)!==null}function Wt(){let t=qt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Yt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=Ut(t);if(!e)return!0;let{target:o}=t;return!(o instanceof HTMLElement)||o.isContentEditable||o.closest('button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role="button"]')?Ie(null):Z(e),!0}function Vt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Gt),!0):!1}function Gt(t){t.remove()}function Ut(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=vt(e);return H(o)?{element:e,node:o}:void 0}function qt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return H(o)?{decorator:o,element:X().getElementByKey(o.getKey())}:void 0}function Z({element:t,node:e}){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let o=Tt();o.add(e.getKey()),Ie(o),t.scrollIntoView({behavior:"smooth",block:"nearest"}),t.classList.add("decorator-selected")}function se(t){if(H(t)&&!t.isInline())return!0;if(!xe(t)||Mt(t))return!1;let e=t.getFirstChild(),o=e===null||Dt(e)||Lt(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function _e(t){let e=t.getNextSibling();for(;e!==null;){if(se(e))return e;e=e.getNextSibling()}return null}function Fe(t){let e=t.getPreviousSibling();for(;e!==null;){if(se(e))return e;e=e.getPreviousSibling()}return null}import{jsx as Ee}from"react/jsx-runtime";import{useLexicalComposerContext as to}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as oo,isHTMLElement as no}from"lexical";import*as He from"react";import{useCallback as ro,useEffect as Ke,useRef as io,useState as so}from"react";import{createPortal as lo}from"react-dom";var V=(t,e,o,r,n=50,c=25)=>{let i=0;if(t&&!t.contains(r)){let{bottom:s,left:d,right:y,top:g}=t.getBoundingClientRect(),a=g+window.scrollY,l=s+window.scrollY;if(o<a-c||o>l+c||e<d-n||e>y+n)return-1;(e<d||e>y)&&(i=e<d?e-d:e-y)}return i};import{$getNodeByKey as ae}from"lexical";function G(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let r=o.split(",").pop();return e.y=e.y-Number(r?.replace(")","")),e}function le(t){let e=(d,y)=>d?parseFloat(window.getComputedStyle(d)[y]):0,{marginBottom:o,marginTop:r}=window.getComputedStyle(t),n=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),i=Math.max(parseFloat(r),n);return{marginBottom:Math.max(parseFloat(o),c),marginTop:i}}import{$getRoot as Jt}from"lexical";function j(t){return t.getEditorState().read(()=>Jt().getChildrenKeys())}var Qt=1,Xt=-1,Oe=0,B={props:null,result:null};function Zt(t,e,o=20){let r=t.x-e.x,n=t.y-e.y;return r*r+n*n<=o*o}function U(t){let{anchorElem:e,cache_threshold:o=20,editor:r,fuzzy:n=!1,horizontalOffset:c=0,point:{x:i,y:s},startIndex:d=0,useEdgeAsDefault:y=!1}=t;if(o>0&&B.props&&B.result&&B.props.fuzzy===t.fuzzy&&B.props.horizontalOffset===t.horizontalOffset&&B.props.useEdgeAsDefault===t.useEdgeAsDefault&&Zt(B.props.point,t.point,o))return B.result;let g=e.getBoundingClientRect(),a=j(r),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return r.getEditorState().read(()=>{if(y){let f=r.getElementByKey(a[0]),h=r.getElementByKey(a[a.length-1]);if(f&&h){let[u,m]=[G(f),G(h)];if(s<u.top?(l.blockElem=f,l.distance=u.top-s,l.blockNode=ae(a[0]),l.foundAtIndex=0):s>m.bottom&&(l.distance=s-m.bottom,l.blockNode=ae(a[a.length-1]),l.blockElem=h,l.foundAtIndex=a.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let p=d,x=Oe;for(;p>=0&&p<a.length;){let f=a[p],h=r.getElementByKey(f);if(h===null)break;let u=new _(i+c,s),m=De.fromDOMRect(G(h)),{marginBottom:E,marginTop:w}=le(h),S=m.generateNewRect({bottom:m.bottom+E,left:g.left,right:g.right,top:m.top-w}),{distance:C,isOnBottomSide:R,isOnTopSide:N}=S.distanceFromPoint(u);if(C===0){l.blockElem=h,l.blockNode=ae(f),l.foundAtIndex=p,l.distance=C,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!n&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else n&&C<l.distance&&(l.blockElem=h,l.blockNode=ae(f),l.distance=C,l.foundAtIndex=p);x===Oe&&(N?x=Xt:R?x=Qt:x=1/0),p+=x}}),B.props=t,B.result={blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph},{blockElem:l.blockElem,blockNode:l.blockNode,foundAtIndex:l.foundAtIndex,isFoundNodeEmptyParagraph:l.isFoundNodeEmptyParagraph}}function ce(t,e){return!!t.closest(`.${e}`)}var eo=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function $e(t){if(!t||eo.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 de(t,e,o,r=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let n=t.getBoundingClientRect(),c=window.getComputedStyle(t),i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),d;if(["lexical-block","lexical-upload","lexical-relationship"].some(a=>t.firstElementChild?.classList.contains(a)))d=n.top+8-s.top;else{let a=$e(t)?parseInt(c.lineHeight,10):0;d=n.top+(a-i.height)/2-s.top}let g=r;e.style.opacity="1",e.style.transform=`translate(${g}px, ${d}px)`}var ao="add-block-menu",ue=1/0;function co(t){return t===0?1/0:ue>=0&&ue<t?ue:Math.floor(t/2)}function uo(t,e,o){let r=e.parentElement,{editorConfig:n}=k(),c=n?.admin?.hideGutter?-24:12,i=io(null),[s,d]=so(null);Ke(()=>{function g(a){let l=a.target;if(!no(l))return;let p=V(r,a.pageX,a.pageY,l);if(p===-1){d(null);return}if(ce(l,ao))return;let x=j(t),{blockElem:f,blockNode:h,foundAtIndex:u}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-p,point:new _(a.x,a.y),returnEmptyParagraphs:!0,startIndex:co(x.length),useEdgeAsDefault:!1});ue=u,f&&h&&(s?.node!==h||s?.elem!==f)&&d({elem:f,node:h})}return document?.addEventListener("mousemove",g),()=>{document?.removeEventListener("mousemove",g)}},[r,e,t,s]),Ke(()=>{i.current&&s?.node&&de(s?.elem,i.current,e,c)},[e,s,c]);let y=ro(g=>{let a=s;a?.node&&(t.update(()=>{let l=!0;if((a?.node.getType()!=="paragraph"||a.node.getTextContent()!=="")&&(l=!1),!l){let p=oo();a?.node.insertAfter(p),setTimeout(()=>{a={elem:t.getElementByKey(p.getKey()),node:p},d(a)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),a?.node&&"select"in a.node&&typeof a.node.select=="function"&&a.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:a?.node})},2),g.stopPropagation(),g.preventDefault())},[t,s]);return lo(Ee(He.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:g=>{y(g)},ref:i,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function je(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=to();return uo(r,o,r._editable)}import{jsx as fe,jsxs as mo}from"react/jsx-runtime";import{useLexicalComposerContext as po}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ye}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ve,$getNodeByKey as go,isHTMLElement as be}from"lexical";import*as Qe from"react";import{useEffect as Ce,useRef as me,useState as Ge}from"react";import{createPortal as ho}from"react-dom";var ze=0,fo=-24;var z=0;function We(t,e,o,r,n,c,i,s,d,y=!1){let{height:g,top:a}=r.getBoundingClientRect(),{top:l,width:p}=i.getBoundingClientRect(),{marginBottom:x,marginTop:f}=le(r),h=a,u=c>=a+g/2+window.scrollY,m=!1;if(n?.elem)if(r!==n?.elem)(u&&n?.elem&&n?.elem===r.nextElementSibling||!u&&n?.elem&&n?.elem===r.previousElementSibling)&&(z++,z<200&&(m=!0));else{z++;let C=n?.boundingBox?.y,R=r.getBoundingClientRect().y;(u===n?.isBelow&&C===R||z<200)&&(m=!1)}if(m)return{isBelow:u,willStayInSamePosition:m};y?h+=g/2:u?h+=g+x/2:h-=f/2;let E=0;y||(u?E=-ze:E=ze);let w=h-l+E,S=fo-e;return o.style.width=`calc(${p}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}px - 2px))`,n?.elem&&(n.elem.style.opacity="",n?.elem===r?u?n.elem.style.marginTop="":n.elem.style.marginBottom="":(n.elem.style.marginBottom="",n.elem.style.marginTop="")),z=0,{isBelow:u,willStayInSamePosition:m}}var yo="draggable-block-menu",Ue="application/x-lexical-drag-block",ee=1/0;function qe(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function xo(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Je(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Eo(t,e,o){let r=e.parentElement,n=me(null),c=me(null),i=me(null),s=me(!1),[d,y]=Ge(null),[g,a]=Ge(null),{editorConfig:l}=k(),p=l?.admin?.hideGutter?-44:-8;Ce(()=>{function h(u){let m=u.target;if(!be(m))return;let E=V(r,u.pageX,u.pageY,m);if(E===-1){y(null);return}if(ce(m,yo))return;let w=j(t),{blockElem:S,foundAtIndex:C,isFoundNodeEmptyParagraph:R}=U({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(u.x,u.y),startIndex:qe(w.length),useEdgeAsDefault:!1,verbose:!1});ee=C,!(!S&&!R)&&d!==S&&y(S)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[r,e,t,d]),Ce(()=>{n.current&&de(d,n.current,e,p)},[e,d,p]),Ce(()=>{function h(m){if(!s.current)return!1;let[E]=Ye(m);if(E)return!1;let{pageY:w,target:S}=m;if(!be(S))return!1;let C=V(r,m.pageX,m.pageY,S,100,50),R=j(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:A}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new _(m.x,m.y),startIndex:qe(R.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let v=c.current;if(N===null||v===null)return!1;if(d!==N){let{isBelow:D,willStayInSamePosition:Q}=We(l?.admin?.hideGutter?"0px":"3rem",p+(l?.admin?.hideGutter?n?.current?.getBoundingClientRect()?.width??0:-(n?.current?.getBoundingClientRect()?.width??0)),v,N,g,w,e,m,i,A);m.preventDefault(),Q||a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:D})}else g?.elem&&(Je(v,g.elem),a({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function u(m){if(!s.current)return!1;let[E]=Ye(m);if(E)return!1;let{dataTransfer:w,pageY:S,target:C}=m,R=w?.getData(Ue)||"";return t.update(()=>{let N=go(R);if(!N||!be(C))return!1;let L=V(r,m.pageX,m.pageY,C,100,50),{blockElem:A,isFoundNodeEmptyParagraph:v}=U({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new _(m.x,m.y),useEdgeAsDefault:!0});if(!A)return!1;let D=Ve(A);if(!D)return!1;if(D===N)return!0;let{height:Q,top:he}=G(A),W=S>=he+Q/2+window.scrollY;v?(D.insertBefore(N),D.remove()):W?D.insertAfter(N):D.insertBefore(N),d!==null&&y(null),document.querySelectorAll(".lexical-block-highlighter").forEach(T=>{T.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let T=oe?.getBoundingClientRect();if(!T)return;let P=document.createElement("div");P.className="lexical-block-highlighter",P.style.backgroundColor="var(--theme-elevation-1000",P.style.transition="opacity 0.5s ease-in-out",P.style.zIndex="1",P.style.pointerEvents="none",P.style.boxSizing="border-box",P.style.borderRadius="4px",P.style.position="absolute",document.body.appendChild(P),P.style.opacity="0.1",P.style.height=`${T.height+8}px`,P.style.width=`${T.width+8}px`,P.style.top=`${T.top+window.scrollY-4}px`,P.style.left=`${T.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",u),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",u)}},[r,p,e,t,g,d,l?.admin?.hideGutter]);function x(h){let u=h.dataTransfer;if(!u||!d)return;xo(u,d);let m="";t.update(()=>{let E=Ve(d);E&&(m=E.getKey())}),s.current=!0,u.setData(Ue,m)}function f(){s.current=!1,g?.elem&&Je(c.current,g?.elem)}return ho(mo(Qe.Fragment,{children:[fe("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:f,onDragStart:x,ref:n,children:fe("div",{className:o?"icon":""})}),fe("div",{className:"draggable-block-target-line",ref:c}),fe("div",{className:"debug-highlight",ref:i})]}),e)}function Xe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[r]=po();return Eo(r,o,r._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as Co}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as No,$getRoot as Po}from"lexical";import"react";var Ze="insert-paragraph-at-end",et=()=>{let t=bo(4),[e]=Co(),{editorConfig:o}=k();if(o?.admin?.hideInsertParagraphAtEnd)return null;let r;t[0]!==e?(r=()=>{e.update(So)},t[0]=e,t[1]=r):r=t[1];let n=r,c;return t[2]!==n?(c=Ne("div",{"aria-label":"Insert Paragraph",className:Ze,onClick:n,role:"button",tabIndex:0,children:Ne("div",{className:`${Ze}-inside`,children:Ne("span",{children:"+"})})}),t[2]=n,t[3]=c):c=t[3],c};function So(){let t=No();Po().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as Ro}from"@lexical/react/LexicalComposerContext";import*as tt from"react";var ot=()=>{let t=ko(4),{editorConfig:e}=k(),[o]=Ro(),r,n;return t[0]!==o||t[1]!==e.features.markdownTransformers?(r=()=>Re(o,e.features.markdownTransformers??[]),n=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=r,t[3]=n):(r=t[2],n=t[3]),tt.useEffect(r,n),null};import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as vo,RootNode as Do}from"lexical";import{useEffect as Mo}from"react";function nt(){let[t]=wo();return Mo(()=>t.registerNodeTransform(Do,e=>{let o=To();if(vo(o)){let r=o.anchor.getNode(),n=o.focus.getNode();(!r.isAttached()||!n.isAttached())&&(e.selectEnd(),console.warn("updateEditor: selection has been moved to the end of the editor because the previously selected nodes have been removed and selection wasn't moved to another node. Ensure selection changes after removing/replacing a selected node."))}return!1}),[t]),null}import{jsx as q,jsxs as it}from"react/jsx-runtime";import{useLexicalComposerContext as Bo}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as st}from"@payloadcms/ui";import{useCallback as Io,useMemo as Ao,useState as _o}from"react";import"react";import*as lt from"react-dom";import{c as Lo}from"react/compiler-runtime";import"react";function rt(t,e){let o=Lo(4),{maxLength:r,minLength:n}=e,c=r===void 0?75:r,i=n===void 0?1:n,s;return o[0]!==c||o[1]!==i||o[2]!==t?(s=d=>{let{query:y}=d,g="[^"+t+we+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+g+"){0,"+c+"}))$").exec(y);if(l!==null){let p=l[1],x=l[3];if(x.length>=i)return{leadOffset:l.index+p.length,matchingString:x,replaceableString:l[2]}}return null},o[0]=c,o[1]=i,o[2]=t,o[3]=s):s=o[3],s}var I="slash-menu-popup";function Fo({isSelected:t,item:e,onClick:o,onMouseEnter:r,ref:n}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:i}}=k(),{i18n:s}=st(),d=`${I}__item ${I}__item-${e.key}`;t&&(d+=` ${I}__item--selected`);let y=e.key;return e.label&&(y=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:s,schemaPath:i}):e.label),y.length>25&&(y=y.substring(0,25)+"..."),it("button",{"aria-selected":t,className:d,id:I+"__item-"+e.key,onClick:o,onMouseEnter:r,ref:n,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&q(e.Icon,{}),q("span",{className:`${I}__item-text`,children:y})]},e.key)}function at({anchorElem:t=document.body}){let[e]=Bo(),[o,r]=_o(null),{editorConfig:n}=k(),{i18n:c}=st(),{fieldProps:{featureClientSchemaMap:i,schemaPath:s}}=k(),d=rt("/",{minLength:0}),y=Io(()=>{let a=[];for(let l of n.features.slashMenu.dynamicGroups)if(o){let p=l({editor:e,queryString:o});a=a.concat(p)}return a},[e,o,n?.features]),g=Ao(()=>{let a=[];for(let l of n?.features.slashMenu.groups??[])a.push(l);if(o){a=a.map(p=>{let x=p.items.filter(f=>{let h=f.key;return f.label&&(h=typeof f.label=="function"?f.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):f.label),new RegExp(o,"gi").exec(h)?!0:f.keywords!=null?f.keywords.some(u=>new RegExp(o,"gi").exec(u)):!1});return x.length?{...p,items:x}:null}),a=a.filter(p=>p!=null);let l=y();for(let p of l){let x=a.find(f=>f.key===p.key);x?a=a.filter(f=>f.key!==p.key):x={...p,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),a.push(x)}}return a},[o,n?.features.slashMenu.groups,y,i,c,s]);return q(ve,{anchorElem:t,groups:g,menuRenderFn:(a,{selectedItemKey:l,selectItemAndCleanUp:p,setSelectedItemKey:x})=>a.current&&g.length?lt.createPortal(q("div",{className:I,children:g.map(f=>{let h=f.key;return f.label&&i&&(h=typeof f.label=="function"?f.label({featureClientSchemaMap:i,i18n:c,schemaPath:s}):f.label),it("div",{className:`${I}__group ${I}__group-${f.key}`,children:[q("div",{className:`${I}__group-title`,children:h}),f.items.map((u,m)=>q(Fo,{index:m,isSelected:l===u.key,item:u,onClick:()=>{x(u.key),p(u)},onMouseEnter:()=>{x(u.key)},ref:E=>{u.ref={current:E}}},u.key))]},f.key)})}),a.current):null,onQueryChange:r,triggerFn:d})}import{c as Oo}from"react/compiler-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Ko,TextNode as Ho}from"lexical";import{useEffect as jo}from"react";function ct(t){let e=Oo(6),{features:o}=t,[r]=$o(),n;e[0]!==r||e[1]!==o.enabledFormats?(n=()=>{let i=zo(o.enabledFormats);if(i.length!==0)return r.registerNodeTransform(Ho,s=>{i.forEach(d=>{s.hasFormat(d)&&s.toggleFormat(d)})})},e[0]=r,e[1]=o.enabledFormats,e[2]=n):n=e[2];let c;return e[3]!==r||e[4]!==o?(c=[r,o],e[3]=r,e[4]=o,e[5]=c):c=e[5],jo(n,c),null}function zo(t){let e=Object.keys(Ko),o=new Set(t);return e.filter(r=>!o.has(r))}import{c as Wo}from"react/compiler-runtime";import{jsx as dt}from"react/jsx-runtime";import{ContentEditable as Yo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Vo}from"@payloadcms/ui";import"react";function ut(t){let e=Wo(7),{className:o,editorConfig:r}=t,{t:n}=Vo(),c;if(e[0]!==o||e[1]!==r?.admin?.placeholder||e[2]!==n){let i;e[4]!==r?.admin?.placeholder||e[5]!==n?(i=r?.admin?.placeholder??n("lexical:general:placeholder"),e[4]=r?.admin?.placeholder,e[5]=n,e[6]=i):i=e[6],c=dt(Yo,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:dt("p",{className:"editor-placeholder",children:i})}),e[0]=o,e[1]=r?.admin?.placeholder,e[2]=n,e[3]=c}else c=e[3];return c}var mt=t=>{let e=Go(19),{editorConfig:o,editorContainerRef:r,isSmallWidthViewport:n,onChange:c}=t,i=k(),[s]=Uo(),[d,y]=on(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=f=>{f!==null&&y(f)},e[0]=g):g=e[0];let a=g,l,p;e[1]!==s||e[2]!==i?(l=()=>{if(!i?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}i?.parentEditor?.uuid&&i.parentEditor?.registerChild(i.uuid,i);let f=()=>{i.focusEditor(i)},h=()=>{i.blurEditor(i)},u=s.registerCommand(en,()=>(f(),!0),ft),m=s.registerCommand(Zo,()=>(h(),!0),ft);return()=>{u(),m(),i.parentEditor?.unregisterChild?.(i.uuid)}},p=[s,i],e[1]=s,e[2]=i,e[3]=l,e[4]=p):(l=e[3],p=e[4]),tn(l,p);let x;if(e[5]!==s||e[6]!==o||e[7]!==r||e[8]!==d||e[9]!==n||e[10]!==c){let f;e[12]!==c?(f=(u,m,E)=>{(!E.has("focus")||E.size>1)&&c?.(u,m,E)},e[12]=c,e[13]=f):f=e[13];let h;e[14]!==s||e[15]!==o.features.plugins||e[16]!==d||e[17]!==n?(h=d&&te(J.Fragment,{children:[!n&&s.isEditable()&&te(J.Fragment,{children:[b(Xe,{anchorElem:d}),b(je,{anchorElem:d})]}),o.features.plugins?.map(u=>{if(u.position==="floatingAnchorElem"&&!(u.desktopOnly===!0&&n))return b(K,{anchorElem:d,clientProps:u.clientProps,plugin:u},u.key)}),s.isEditable()&&b(J.Fragment,{children:b(at,{anchorElem:d})})]}),e[14]=s,e[15]=o.features.plugins,e[16]=d,e[17]=n,e[18]=h):h=e[18],x=te(J.Fragment,{children:[o.features.plugins?.map(nn),te("div",{className:"editor-container",ref:r,children:[o.features.plugins?.map(rn),b(Xo,{contentEditable:b("div",{className:"editor-scroller",children:b("div",{className:"editor",ref:a,children:b(ut,{editorConfig:o})})}),ErrorBoundary:qo}),b(nt,{}),b(et,{}),b(Ae,{}),b(ct,{features:o.features}),b(Qo,{ignoreSelectionChange:!0,onChange:f}),h,s.isEditable()&&te(J.Fragment,{children:[b(Jo,{}),o?.features?.markdownTransformers?.length>0&&b(ot,{})]}),o.features.plugins?.map(sn),o.features.plugins?.map(ln)]}),o.features.plugins?.map(an)]}),e[5]=s,e[6]=o,e[7]=r,e[8]=d,e[9]=n,e[10]=c,e[11]=x}else x=e[11];return x};function nn(t){if(t.position==="aboveContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function rn(t){if(t.position==="top")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function sn(t){if(t.position==="normal")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function ln(t){if(t.position==="bottom")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}function an(t){if(t.position==="belowContainer")return b(K,{clientProps:t.clientProps,plugin:t},t.key)}var gt=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?F(o,{children:F(gt,{providers:e.slice(1),children:t})}):F(o,{children:t})},ht=t=>{let{composerKey:e,editorConfig:o,fieldProps:r,isSmallWidthViewport:n,onChange:c,readOnly:i,value:s}=t,d=k(),y=dn(),g=pt.useRef(null),a=un(()=>{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:i!==!0,editorState:s!=null?JSON.stringify(s):void 0,namespace:o.lexical.namespace,nodes:Me({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o]);return a?F(cn,{initialConfig:a,children:F(ke,{editorConfig:o,editorContainerRef:g,fieldProps:r,parentContext:d?.editDepth===y?d:void 0,children:F(gt,{providers:o.features.providers,children:F(mt,{editorConfig:o,editorContainerRef:g,isSmallWidthViewport:n,onChange:c})})})},e+a.editable):F("p",{children:"Loading..."})};var pe="rich-text-lexical",Nn=t=>{let{editorConfig:e,field:o,field:{admin:{className:r,description:n,readOnly:c}={},label:i,localized:s,required:d},path:y,readOnly:g,validate:a}=t,l=g||c,p=gn(),x=Et((M,$)=>typeof a=="function"?a(M,{...$,required:d}):!0,[a,d]),{customComponents:{AfterInput:f,BeforeInput:h,Description:u,Error:m,Label:E}={},disabled:w,initialValue:S,path:C,setValue:R,showError:N,value:L}=yn({potentiallyStalePath:y,validate:x}),A=l||w,[v,D]=Ct(!1),[Q,he]=Ct(),ye=xt.useRef(S),W=xt.useRef(L);bt(()=>{let M=()=>{let $=window.matchMedia("(max-width: 768px)").matches;$!==v&&D($)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let Pe=[pe,"field-type",r,N&&"error",A&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${C}.${p}`,T=bn(void 0),P=Et(M=>{let $=St=>{let Se=St.toJSON();W.current=Se,R(Se)};typeof window.requestIdleCallback=="function"?(typeof window.cancelIdleCallback=="function"&&T.current&&cancelIdleCallback(T.current),T.current=requestIdleCallback(()=>$(M),{timeout:500})):$(M)},[R]),Nt=En(()=>xn(o),[o]),Pt=hn(M=>{W.current!==L&&JSON.stringify(W.current)!==JSON.stringify(L)&&(ye.current=M,W.current=L,he(new Date))});return bt(()=>{Object.is(S,ye.current)||Pt(S)},[S]),ge("div",{className:Pe,style:Nt,children:[O(yt,{CustomComponent:m,Fallback:O(mn,{path:C,showError:N})}),E||O(pn,{label:i,localized:s,path:C,required:d}),ge("div",{className:`${pe}__wrap`,children:[ge(Cn,{fallbackRender:Pn,onReset:()=>{},children:[h,O(ht,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:A,value:L},JSON.stringify({path:C,rerenderProviderKey:Q})),f]}),u,O(yt,{CustomComponent:u,Fallback:O(fn,{description:n,path:C})})]})]},oe)};function Pn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[O("p",{children:"Something went wrong:"}),O("pre",{style:{color:"red"},children:t.message})]})}var Xi=Nn;export{Xi as RichText};
2
- //# sourceMappingURL=Field-DGC4DDYL.js.map