@payloadcms/richtext-lexical 3.59.0-internal.cb85185 → 3.59.0-internal.cf8cc72
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.
- package/dist/exports/client/Field-EHRBYNHO.js +2 -0
- package/dist/exports/client/Field-EHRBYNHO.js.map +7 -0
- package/dist/exports/client/RelationshipComponent-APF3CN47.js +2 -0
- package/dist/exports/client/RelationshipComponent-APF3CN47.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-TLQLXR6Q.js → chunk-2Y72RT72.js} +2 -2
- package/dist/exports/client/chunk-3BY5IZJD.js +2 -0
- package/dist/exports/client/chunk-3BY5IZJD.js.map +7 -0
- package/dist/exports/client/chunk-CYLMY5ZJ.js +2 -0
- package/dist/exports/client/chunk-CYLMY5ZJ.js.map +7 -0
- package/dist/exports/client/component-VDJI45F2.js +2 -0
- package/dist/exports/client/component-VDJI45F2.js.map +7 -0
- package/dist/exports/client/componentInline-7TPI7ZBC.js +2 -0
- package/dist/exports/client/index.d.ts +0 -3
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -35
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/align/server/i18n.d.ts.map +1 -1
- package/dist/features/align/server/i18n.js +6 -0
- package/dist/features/align/server/i18n.js.map +1 -1
- package/dist/features/blockquote/server/i18n.d.ts.map +1 -1
- package/dist/features/blockquote/server/i18n.js +3 -0
- package/dist/features/blockquote/server/i18n.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.d.ts +27 -52
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +51 -48
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +9 -2
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +25 -7
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +56 -71
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +11 -13
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +0 -5
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +17 -0
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdownTransformer.js +144 -0
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/server/i18n.d.ts.map +1 -1
- package/dist/features/blocks/server/i18n.js +47 -38
- package/dist/features/blocks/server/i18n.js.map +1 -1
- package/dist/features/blocks/server/index.js +1 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/{markdown/markdownTransformer.js → markdownTransformer.js} +48 -6
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +3 -5
- package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/heading/server/i18n.d.ts.map +1 -1
- package/dist/features/heading/server/i18n.js +3 -0
- package/dist/features/heading/server/i18n.js.map +1 -1
- package/dist/features/horizontalRule/server/i18n.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/i18n.js +3 -0
- package/dist/features/horizontalRule/server/i18n.js.map +1 -1
- package/dist/features/indent/server/i18n.d.ts.map +1 -1
- package/dist/features/indent/server/i18n.js +4 -0
- package/dist/features/indent/server/i18n.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +1 -3
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/server/i18n.d.ts.map +1 -1
- package/dist/features/link/server/i18n.js +4 -0
- package/dist/features/link/server/i18n.js.map +1 -1
- package/dist/features/lists/checklist/server/i18n.d.ts.map +1 -1
- package/dist/features/lists/checklist/server/i18n.js +3 -0
- package/dist/features/lists/checklist/server/i18n.js.map +1 -1
- package/dist/features/lists/orderedList/server/i18n.d.ts.map +1 -1
- package/dist/features/lists/orderedList/server/i18n.js +3 -0
- package/dist/features/lists/orderedList/server/i18n.js.map +1 -1
- package/dist/features/lists/unorderedList/server/i18n.d.ts.map +1 -1
- package/dist/features/lists/unorderedList/server/i18n.js +3 -0
- package/dist/features/lists/unorderedList/server/i18n.js.map +1 -1
- package/dist/features/paragraph/server/i18n.d.ts.map +1 -1
- package/dist/features/paragraph/server/i18n.js +4 -0
- package/dist/features/paragraph/server/i18n.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +9 -5
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/server/i18n.d.ts.map +1 -1
- package/dist/features/relationship/server/i18n.js +3 -0
- package/dist/features/relationship/server/i18n.js.map +1 -1
- package/dist/features/textState/i18n.d.ts.map +1 -1
- package/dist/features/textState/i18n.js +3 -0
- package/dist/features/textState/i18n.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -7
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.d.ts.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -3
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +5 -6
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/server/i18n.d.ts.map +1 -1
- package/dist/features/upload/server/i18n.js +3 -0
- package/dist/features/upload/server/i18n.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +0 -2
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +8 -10
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +15 -10
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +0 -1
- package/dist/utilities/buildInitialState.d.ts.map +1 -1
- package/dist/utilities/buildInitialState.js +0 -1
- package/dist/utilities/buildInitialState.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +3 -7
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-RQHCQRLV.js +0 -2
- package/dist/exports/client/Field-RQHCQRLV.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js +0 -2
- package/dist/exports/client/RelationshipComponent-TSIENULZ.js.map +0 -7
- package/dist/exports/client/chunk-BQCXN3B4.js +0 -2
- package/dist/exports/client/chunk-BQCXN3B4.js.map +0 -7
- package/dist/exports/client/chunk-XNERFY6G.js +0 -2
- package/dist/exports/client/chunk-XNERFY6G.js.map +0 -7
- package/dist/exports/client/component-CYFKY3IL.js +0 -2
- package/dist/exports/client/component-CYFKY3IL.js.map +0 -7
- package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +0 -6
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +0 -24
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +0 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +0 -6
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +0 -20
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +0 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +0 -12
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +0 -348
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +0 -5
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +0 -156
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +0 -61
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +0 -99
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +0 -4
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +0 -17
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +0 -4
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +0 -26
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts +0 -7
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converter.js +0 -46
- package/dist/features/blocks/premade/CodeBlock/converter.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +0 -2
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/converterClient.js +0 -4
- package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +0 -7
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +0 -1
- package/dist/features/blocks/premade/CodeBlock/index.js +0 -52
- package/dist/features/blocks/premade/CodeBlock/index.js.map +0 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +0 -6
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +0 -27
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +0 -1
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +0 -7
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +0 -22
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +0 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +0 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +0 -15
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +0 -1
- package/dist/lexical/ui/icons/Collapse/index.d.ts +0 -3
- package/dist/lexical/ui/icons/Collapse/index.d.ts.map +0 -1
- package/dist/lexical/ui/icons/Collapse/index.js +0 -18
- package/dist/lexical/ui/icons/Collapse/index.js.map +0 -1
- /package/dist/exports/client/{chunk-TLQLXR6Q.js.map → chunk-2Y72RT72.js.map} +0 -0
- /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-7TPI7ZBC.js.map} +0 -0
- /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.d.ts → linesFromMatchToContentAndPropsString.d.ts} +0 -0
- /package/dist/features/blocks/server/{markdown/linesFromMatchToContentAndPropsString.js → linesFromMatchToContentAndPropsString.js} +0 -0
|
@@ -7,7 +7,6 @@ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js';
|
|
|
7
7
|
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js';
|
|
8
8
|
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js';
|
|
9
9
|
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js';
|
|
10
|
-
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
11
10
|
import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
|
|
12
11
|
import * as React from 'react';
|
|
13
12
|
import { useEffect, useState } from 'react';
|
|
@@ -33,7 +32,6 @@ export const LexicalEditor = props => {
|
|
|
33
32
|
} = props;
|
|
34
33
|
const editorConfigContext = useEditorConfigContext();
|
|
35
34
|
const [editor] = useLexicalComposerContext();
|
|
36
|
-
const isEditable = useLexicalEditable();
|
|
37
35
|
const [floatingAnchorElem, setFloatingAnchorElem] = useState(null);
|
|
38
36
|
let t0;
|
|
39
37
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -89,7 +87,7 @@ export const LexicalEditor = props => {
|
|
|
89
87
|
}
|
|
90
88
|
useEffect(t1, t2);
|
|
91
89
|
let t3;
|
|
92
|
-
if ($[5] !==
|
|
90
|
+
if ($[5] !== editor || $[6] !== editorConfig || $[7] !== editorContainerRef || $[8] !== floatingAnchorElem || $[9] !== isSmallWidthViewport || $[10] !== onChange) {
|
|
93
91
|
let t4;
|
|
94
92
|
if ($[12] !== onChange) {
|
|
95
93
|
t4 = (editorState, editor_0, tags) => {
|
|
@@ -126,7 +124,7 @@ export const LexicalEditor = props => {
|
|
|
126
124
|
ignoreSelectionChange: true,
|
|
127
125
|
onChange: t4
|
|
128
126
|
}), floatingAnchorElem && _jsxs(React.Fragment, {
|
|
129
|
-
children: [!isSmallWidthViewport && isEditable && _jsxs(React.Fragment, {
|
|
127
|
+
children: [!isSmallWidthViewport && editor.isEditable() && _jsxs(React.Fragment, {
|
|
130
128
|
children: [editorConfig.admin?.hideDraggableBlockElement ? null : _jsx(DraggableBlockPlugin, {
|
|
131
129
|
anchorElem: floatingAnchorElem
|
|
132
130
|
}), editorConfig.admin?.hideAddBlockButton ? null : _jsx(AddBlockHandlePlugin, {
|
|
@@ -140,20 +138,20 @@ export const LexicalEditor = props => {
|
|
|
140
138
|
plugin: plugin_1
|
|
141
139
|
}, plugin_1.key);
|
|
142
140
|
}
|
|
143
|
-
}), isEditable && _jsx(React.Fragment, {
|
|
141
|
+
}), editor.isEditable() && _jsx(React.Fragment, {
|
|
144
142
|
children: _jsx(SlashMenuPlugin, {
|
|
145
143
|
anchorElem: floatingAnchorElem
|
|
146
144
|
})
|
|
147
145
|
})]
|
|
148
|
-
}), isEditable && _jsxs(React.Fragment, {
|
|
146
|
+
}), editor.isEditable() && _jsxs(React.Fragment, {
|
|
149
147
|
children: [_jsx(HistoryPlugin, {}), editorConfig?.features?.markdownTransformers?.length > 0 && _jsx(MarkdownShortcutPlugin, {})]
|
|
150
148
|
}), editorConfig.features.plugins?.map(_temp3), editorConfig.features.plugins?.map(_temp4)]
|
|
151
149
|
}), editorConfig.features.plugins?.map(_temp5)]
|
|
152
150
|
});
|
|
153
|
-
$[5] =
|
|
154
|
-
$[6] =
|
|
155
|
-
$[7] =
|
|
156
|
-
$[8] =
|
|
151
|
+
$[5] = editor;
|
|
152
|
+
$[6] = editorConfig;
|
|
153
|
+
$[7] = editorContainerRef;
|
|
154
|
+
$[8] = floatingAnchorElem;
|
|
157
155
|
$[9] = isSmallWidthViewport;
|
|
158
156
|
$[10] = onChange;
|
|
159
157
|
$[11] = t3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","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","isEditable","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","_jsxs","Fragment","children","features","plugins","map","_temp","className","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","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 { useLexicalEditable } from '@lexical/react/useLexicalEditable'\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 './LexicalEditor.scss'\nimport { EditorPlugin } from './EditorPlugin.js'\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 const isEditable = useLexicalEditable()\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 && isEditable && (\n <React.Fragment>\n {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\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 {isEditable && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {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,kBAAkB,QAAQ;AACnC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,YAAY,QAAQ;AAC7B,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,GAAA3B,EAAA;EACF;IAAA4B,YAAA;IAAAC,kBAAA;IAAAC,oBAAA;IAAAC;EAAA,IAA6EL,KAAA;EAC7E,MAAAM,mBAAA,GAA4BnB,sBAAA;EAC5B,OAAAoB,MAAA,IAAiBhC,yBAAA;EACjB,MAAAiC,UAAA,GAAmB5B,kBAAA;EAEnB,OAAA6B,kBAAA,EAAAC,qBAAA,IAAoDxB,QAAA,KAAgC;EAAA,IAAAyB,EAAA;EAAA,IAAAV,CAAA,QAA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A,CAAA5D,YAAA;MAAAuE,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","_jsxs","Fragment","children","features","plugins","map","_temp","className","ref","_temp2","_jsx","contentEditable","ignoreSelectionChange","isEditable","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","plugin_1","plugin","position","desktopOnly","clientProps","key","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 {editorConfig.admin?.hideDraggableBlockElement ? null : (\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n )}\n {editorConfig.admin?.hideAddBlockButton ? null : (\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n )}\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,eA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CAAA3D,YAAA;MAAAuE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AAjExE,SAAAG,OAAAI,QAAA;EAAA,IA2IUX,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBV,IAAA,CAAA3D,YAAA;MAAAuE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AA7IxE,SAAAI,OAAAI,QAAA;EAAA,IAkJUZ,QAAA,CAAAC,QAAA,KAAoB;IAAA,OAEpBV,IAAA,CAAA3D,YAAA;MAAAuE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA;AApJxE,SAAAK,OAAAI,QAAA;EAAA,IA0JQb,QAAA,CAAAC,QAAA,KAAoB;IAAA,OACfV,IAAA,CAAA3D,YAAA;MAAAuE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAcjC,CAAA"}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export const CodeBlockIcon = () => /*#__PURE__*/
|
|
5
|
+
export const CodeBlockIcon = () => /*#__PURE__*/_jsxs("svg", {
|
|
6
|
+
"aria-hidden": "true",
|
|
7
|
+
className: "icon",
|
|
6
8
|
fill: "none",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
focusable: "false",
|
|
10
|
+
height: "20",
|
|
11
|
+
viewBox: "0 0 20 20",
|
|
12
|
+
width: "20",
|
|
10
13
|
xmlns: "http://www.w3.org/2000/svg",
|
|
11
|
-
children: /*#__PURE__*/_jsx("path", {
|
|
12
|
-
d: "
|
|
13
|
-
stroke: "currentColor"
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
children: [/*#__PURE__*/_jsx("path", {
|
|
15
|
+
d: "M7.76465 6L3.76465 10L7.76465 14",
|
|
16
|
+
stroke: "currentColor"
|
|
17
|
+
}), /*#__PURE__*/_jsx("path", {
|
|
18
|
+
d: "M12.2354 6L16.2354 10L12.2354 14",
|
|
19
|
+
stroke: "currentColor"
|
|
20
|
+
})]
|
|
16
21
|
});
|
|
17
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","CodeBlockIcon","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","CodeBlockIcon","_jsxs","className","fill","focusable","height","viewBox","width","xmlns","_jsx","d","stroke"],"sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nexport const CodeBlockIcon: React.FC = () => (\n <svg\n aria-hidden=\"true\"\n className=\"icon\"\n fill=\"none\"\n focusable=\"false\"\n height=\"20\"\n viewBox=\"0 0 20 20\"\n width=\"20\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M7.76465 6L3.76465 10L7.76465 14\" stroke=\"currentColor\" />\n <path d=\"M12.2354 6L16.2354 10L12.2354 14\" stroke=\"currentColor\" />\n </svg>\n)\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,aAAA,GAA0BA,CAAA,kBACrCC,KAAA,CAAC;EACC,eAAY;EACZC,SAAA,EAAU;EACVC,IAAA,EAAK;EACLC,SAAA,EAAU;EACVC,MAAA,EAAO;EACPC,OAAA,EAAQ;EACRC,KAAA,EAAM;EACNC,KAAA,EAAM;0BAENC,IAAA,CAAC;IAAKC,CAAA,EAAE;IAAmCC,MAAA,EAAO;mBAClDF,IAAA,CAAC;IAAKC,CAAA,EAAE;IAAmCC,MAAA,EAAO","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,
|
|
1
|
+
{"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA2D1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","
|
|
1
|
+
{"version":3,"file":"buildInitialState.js","names":["fieldSchemasToFormState","buildInitialState","context","initialState","initialStateFromArgs","nodeData","node","children","type","blockNode","id","fields","schemaFieldsPath","lexicalFieldSchemaPath","blockType","formStateResult","clientFieldSchemaMap","collectionSlug","data","documentData","fieldSchemaMap","get","initialBlockData","operation","permissions","preferences","renderAllFields","renderFieldFn","req","schemaPath","formState","currentFieldPreferences","field","name","collapsedArray","collapsed","Array","isArray","includes"],"sources":["../../src/utilities/buildInitialState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type {\n ClientFieldSchemaMap,\n DocumentPreferences,\n FieldSchemaMap,\n FormState,\n Operation,\n PayloadRequest,\n RichTextField,\n SanitizedFieldPermissions,\n} from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { SerializedBlockNode } from '../nodeTypes.js'\n\nexport type InitialLexicalFormState = {\n [nodeID: string]: {\n [key: string]: any\n formState?: FormState\n }\n}\n\ntype Props = {\n context: {\n clientFieldSchemaMap: ClientFieldSchemaMap\n collectionSlug: string\n documentData?: any\n field: RichTextField\n fieldSchemaMap: FieldSchemaMap\n id?: number | string\n lexicalFieldSchemaPath: string\n operation: Operation\n permissions?: SanitizedFieldPermissions\n preferences: DocumentPreferences\n renderFieldFn: any\n req: PayloadRequest\n }\n initialState?: InitialLexicalFormState\n nodeData: SerializedLexicalNode[]\n}\n\nexport async function buildInitialState({\n context,\n initialState: initialStateFromArgs,\n nodeData,\n}: Props): Promise<InitialLexicalFormState> {\n let initialState: InitialLexicalFormState = initialStateFromArgs ?? {}\n for (const node of nodeData) {\n if ('children' in node) {\n initialState = await buildInitialState({\n context,\n initialState,\n nodeData: node.children as SerializedLexicalNode[],\n })\n }\n\n if (node.type === 'block' || node.type === 'inlineBlock') {\n const blockNode = node as SerializedBlockNode\n const id = blockNode?.fields?.id\n if (!id) {\n continue\n }\n\n const schemaFieldsPath =\n node.type === 'block'\n ? `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockNode.fields.blockType}.fields`\n : `${context.lexicalFieldSchemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockNode.fields.blockType}.fields`\n\n // Build form state for the block\n\n const formStateResult = await fieldSchemasToFormState({\n id: context.id,\n clientFieldSchemaMap: context.clientFieldSchemaMap,\n collectionSlug: context.collectionSlug,\n data: blockNode.fields,\n documentData: context.documentData,\n fields: (context.fieldSchemaMap.get(schemaFieldsPath) as any)?.fields,\n fieldSchemaMap: context.fieldSchemaMap,\n initialBlockData: blockNode.fields,\n operation: context.operation as any, // TODO: Type\n permissions: true,\n preferences: context.preferences,\n renderAllFields: true, // If this function runs, the parent lexical field is being re-rendered => thus we can assume all its sub-fields need to be re-rendered\n renderFieldFn: context.renderFieldFn,\n req: context.req,\n schemaPath: schemaFieldsPath,\n })\n\n if (!initialState[id]) {\n initialState[id] = {}\n }\n\n initialState[id].formState = formStateResult\n\n if (node.type === 'block') {\n const currentFieldPreferences = context.preferences?.fields?.[context.field.name]\n const collapsedArray = currentFieldPreferences?.collapsed\n if (Array.isArray(collapsedArray) && collapsedArray.includes(id)) {\n initialState[id].collapsed = true\n }\n }\n }\n }\n return initialState\n}\n"],"mappings":"AAYA,SAASA,uBAAuB,QAAQ;AA8BxC,OAAO,eAAeC,kBAAkB;EACtCC,OAAO;EACPC,YAAA,EAAcC,oBAAoB;EAClCC;AAAQ,CACF;EACN,IAAIF,YAAA,GAAwCC,oBAAA,IAAwB,CAAC;EACrE,KAAK,MAAME,IAAA,IAAQD,QAAA,EAAU;IAC3B,IAAI,cAAcC,IAAA,EAAM;MACtBH,YAAA,GAAe,MAAMF,iBAAA,CAAkB;QACrCC,OAAA;QACAC,YAAA;QACAE,QAAA,EAAUC,IAAA,CAAKC;MACjB;IACF;IAEA,IAAID,IAAA,CAAKE,IAAI,KAAK,WAAWF,IAAA,CAAKE,IAAI,KAAK,eAAe;MACxD,MAAMC,SAAA,GAAYH,IAA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W,EAAEd,MAAA,GAAST,OAAA,CAAQ8B,KAAK,CAACC,IAAI,CAAC;QACjF,MAAMC,cAAA,GAAiBH,uBAAA,EAAyBI,SAAA;QAChD,IAAIC,KAAA,CAAMC,OAAO,CAACH,cAAA,KAAmBA,cAAA,CAAeI,QAAQ,CAAC5B,EAAA,GAAK;UAChEP,YAAY,CAACO,EAAA,CAAG,CAACyB,SAAS,GAAG;QAC/B;MACF;IACF;EACF;EACA,OAAOhC,YAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DrawerContent.d.ts","sourceRoot":"","sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAGvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,aAAa,CAAC,CA8IzF,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { useLexicalEditable } from '@lexical/react/useLexicalEditable';
|
|
5
4
|
import { Form, FormSubmit, RenderFields, useDocumentForm, useDocumentInfo, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
6
5
|
import { abortAndIgnore } from '@payloadcms/ui/shared';
|
|
7
6
|
import { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared';
|
|
@@ -29,7 +28,6 @@ export const DrawerContent = ({
|
|
|
29
28
|
const {
|
|
30
29
|
fields: parentDocumentFields
|
|
31
30
|
} = useDocumentForm();
|
|
32
|
-
const isEditable = useLexicalEditable();
|
|
33
31
|
const onChangeAbortControllerRef = useRef(new AbortController());
|
|
34
32
|
const [initialState, setInitialState] = useState(false);
|
|
35
33
|
const {
|
|
@@ -60,7 +58,6 @@ export const DrawerContent = ({
|
|
|
60
58
|
globalSlug,
|
|
61
59
|
initialBlockData: data,
|
|
62
60
|
operation: 'update',
|
|
63
|
-
readOnly: !isEditable,
|
|
64
61
|
renderAllFields: true,
|
|
65
62
|
schemaPath: schemaFieldsPath,
|
|
66
63
|
signal: controller.signal
|
|
@@ -71,7 +68,7 @@ export const DrawerContent = ({
|
|
|
71
68
|
return () => {
|
|
72
69
|
abortAndIgnore(controller);
|
|
73
70
|
};
|
|
74
|
-
}, [schemaFieldsPath, id, data, getFormState, collectionSlug,
|
|
71
|
+
}, [schemaFieldsPath, id, data, getFormState, collectionSlug, globalSlug, getDocPreferences, parentDocumentFields]);
|
|
75
72
|
const onChange = useCallback(async ({
|
|
76
73
|
formState: prevFormState
|
|
77
74
|
}) => {
|
|
@@ -92,7 +89,6 @@ export const DrawerContent = ({
|
|
|
92
89
|
globalSlug,
|
|
93
90
|
initialBlockFormState: prevFormState,
|
|
94
91
|
operation: 'update',
|
|
95
|
-
readOnly: !isEditable,
|
|
96
92
|
schemaPath: schemaFieldsPath,
|
|
97
93
|
signal: controller_0.signal
|
|
98
94
|
});
|
|
@@ -100,7 +96,7 @@ export const DrawerContent = ({
|
|
|
100
96
|
return prevFormState;
|
|
101
97
|
}
|
|
102
98
|
return state_0;
|
|
103
|
-
}, [getFormState, id,
|
|
99
|
+
}, [getFormState, id, collectionSlug, getDocPreferences, parentDocumentFields, globalSlug, schemaFieldsPath]);
|
|
104
100
|
// cleanup effect
|
|
105
101
|
useEffect(() => {
|
|
106
102
|
return () => {
|
|
@@ -127,7 +123,7 @@ export const DrawerContent = ({
|
|
|
127
123
|
|
|
128
124
|
parentSchemaPath: schemaFieldsPath,
|
|
129
125
|
permissions: true,
|
|
130
|
-
readOnly:
|
|
126
|
+
readOnly: false
|
|
131
127
|
}), /*#__PURE__*/_jsx(FormSubmit, {
|
|
132
128
|
children: t('fields:saveChanges')
|
|
133
129
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerContent.js","names":["
|
|
1
|
+
{"version":3,"file":"DrawerContent.js","names":["Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","readOnly"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={false}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SACEA,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,QAAQ;AAC3D,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAChE,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAAiFA,CAAC;EAC7FC,IAAI;EACJC,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBC,wBAAwB;EACxBC,UAAU;EACVC;AAAgB,CACjB;EACC,MAAM;IAAEC;EAAC,CAAE,GAAGnB,cAAA;EACd,MAAM;IAAEoB,EAAE;IAAEC,cAAc;IAAEC,iBAAiB;IAAEC;EAAU,CAAE,GAAGzB,eAAA;EAC9D,MAAM;IAAE0B,MAAA,EAAQC;EAAoB,CAAE,GAAG5B,eAAA;EAEzC,MAAM6B,0BAAA,GAA6BpB,MAAA,CAAO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IAAUA,MAAA,GAAS,EAAE;MAC3CgC,WAAW;MACXC,eAAA,EAAgB;MAChBC,UAAA,EAAW,GAAG;MAAA;;MACdC,gBAAA,EAAkB1B,gBAAA;MAClB2B,WAAA,EAAa;MACbC,QAAA,EAAU;qBAEZN,IAAA,CAAC5D,UAAA;gBAAYwB,CAAA,CAAE;;;AAGrB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/
|
|
2
|
-
import { createTagRegexes } from '../../features/blocks/server/
|
|
1
|
+
import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js';
|
|
2
|
+
import { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js';
|
|
3
3
|
/**
|
|
4
4
|
* Helpful utility for parsing out all matching top-level JSX tags in a given string.
|
|
5
5
|
* This will collect them in a list, that contains the content of the JSX tag and the props string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","line","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/
|
|
1
|
+
{"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","line","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js'\nimport { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js'\n\n/**\n * Helpful utility for parsing out all matching top-level JSX tags in a given string.\n * This will collect them in a list, that contains the content of the JSX tag and the props string.\n *\n * While this is not used within payload, this can be used for certain payload blocks that need to\n * be serializable and deserializable to and from JSX.\n *\n * @example:\n *\n * Say you have Steps block that contains a steps array. Its JSX representation may look like this:\n *\n * <Steps>\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n * </Steps>\n *\n * In this case, the Steps block would have the following content as its children string:\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n *\n * It could then use this function to collect all the top-level JSX tags (= the steps):\n *\n * collectTopLevelJSXInLines(children.split('\\n'), 'Step')\n *\n * This will return:\n *\n * [\n * {\n * content: '<h1>Step 1</h1>',\n * propsString: 'title=\"Step1\"',\n * },\n * {\n * content: '<h1>Step 2</h1>',\n * propsString: 'title=\"Step2\"',\n * },\n * ]\n *\n * You can then map this data to construct the data for this blocks array field.\n */\nexport function collectTopLevelJSXInLines(\n lines: Array<string>,\n jsxToMatch: string,\n): {\n content: string\n propsString: string\n}[] {\n const finds: {\n content: string\n propsString: string\n }[] = []\n const regex = createTagRegexes(jsxToMatch)\n\n const linesLength = lines.length\n\n for (let i = 0; i < linesLength; i++) {\n const line = lines[i]!\n const startMatch = line.match(regex.regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n const { content, endLineIndex, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines,\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: i,\n startMatch,\n })\n\n finds.push({\n content,\n propsString,\n })\n\n i = endLineIndex\n continue\n }\n\n return finds\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,OAAO,SAASC,0BACdC,KAAoB,EACpBC,UAAkB;EAKlB,MAAMC,KAAA,GAGA,EAAE;EACR,MAAMC,KAAA,GAAQL,gBAAA,CAAiBG,UAAA;EAE/B,MAAMG,WAAA,GAAcJ,KAAA,CAAMK,MAAM;EAEhC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIF,WAAA,EAAaE,CAAA,IAAK;IACpC,MAAMC,IAAA,GAAOP,KAAK,CAACM,CAAA,CAAE;IACrB,MAAME,UAAA,GAAaD,IAAA,CAAKE,KAAK,CAACN,KAAA,CAAMO,WAAW;IAC/C,IAAI,CAACF,UAAA,EAAY;MACf,UAAS;IACX;IAEA,MAAM;MAAEG,OAAO;MAAEC,YAAY;MAAEC;IAAW,CAAE,GAAGhB,qCAAA,CAAsC;MACnFiB,aAAA,EAAe;MACfd,KAAA;MACAe,cAAA,EAAgBZ,KAAA,CAAMa,SAAS;MAC/BC,cAAA,EAAgBX,CAAA;MAChBE;IACF;IAEAN,KAAA,CAAMgB,IAAI,CAAC;MACTP,OAAA;MACAE;IACF;IAEAP,CAAA,GAAIM,YAAA;IACJ;EACF;EAEA,OAAOV,KAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.59.0-internal.
|
|
3
|
+
"version": "3.59.0-internal.cf8cc72",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -373,8 +373,8 @@
|
|
|
373
373
|
"react-error-boundary": "4.1.2",
|
|
374
374
|
"ts-essentials": "10.0.3",
|
|
375
375
|
"uuid": "10.0.0",
|
|
376
|
-
"@payloadcms/translations": "3.59.0-internal.
|
|
377
|
-
"@payloadcms/ui": "3.59.0-internal.
|
|
376
|
+
"@payloadcms/translations": "3.59.0-internal.cf8cc72",
|
|
377
|
+
"@payloadcms/ui": "3.59.0-internal.cf8cc72"
|
|
378
378
|
},
|
|
379
379
|
"devDependencies": {
|
|
380
380
|
"@babel/cli": "7.27.2",
|
|
@@ -394,15 +394,15 @@
|
|
|
394
394
|
"esbuild-sass-plugin": "3.3.1",
|
|
395
395
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
396
396
|
"@payloadcms/eslint-config": "3.28.0",
|
|
397
|
-
"payload": "3.59.0-internal.
|
|
397
|
+
"payload": "3.59.0-internal.cf8cc72"
|
|
398
398
|
},
|
|
399
399
|
"peerDependencies": {
|
|
400
400
|
"@faceless-ui/modal": "3.0.0",
|
|
401
401
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
402
402
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
403
403
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
404
|
-
"@payloadcms/next": "3.59.0-internal.
|
|
405
|
-
"payload": "3.59.0-internal.
|
|
404
|
+
"@payloadcms/next": "3.59.0-internal.cf8cc72",
|
|
405
|
+
"payload": "3.59.0-internal.cf8cc72"
|
|
406
406
|
},
|
|
407
407
|
"engines": {
|
|
408
408
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use client";import{a as ke,e as we,f as _,h as ve,i as Te,j as De,k as Le,l as Me}from"./chunk-TLQLXR6Q.js";import{a as Re,b as R}from"./chunk-BZZVLW4U.js";import{jsx as F,jsxs as ge}from"react/jsx-runtime";import{FieldDescription as En,FieldError as Cn,FieldLabel as bn,RenderCustomComponent as Et,useEditDepth as Nn,useEffectEvent as Pn,useField as Sn}from"@payloadcms/ui";import{mergeFieldStyles as Rn}from"@payloadcms/ui/shared";import{dequal as kn}from"dequal/lite";import Ct,{useCallback as bt,useEffect as Nt,useMemo as wn,useState as Pt}from"react";import{ErrorBoundary as vn}from"react-error-boundary";import"./bundled.css";import{jsx as O}from"react/jsx-runtime";import{LexicalComposer as hn}from"@lexical/react/LexicalComposer.js";import{useEditDepth as yn}from"@payloadcms/ui";import*as ht from"react";import{useMemo as xn}from"react";import{c as Zo}from"react/compiler-runtime";import{jsx as C,jsxs as te}from"react/jsx-runtime";import{useLexicalComposerContext as en}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as tn}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as on}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as nn}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as rn}from"@lexical/react/LexicalRichTextPlugin.js";import{useLexicalEditable as sn}from"@lexical/react/useLexicalEditable";import{BLUR_COMMAND as ln,COMMAND_PRIORITY_LOW as pt,FOCUS_COMMAND as an}from"lexical";import*as q from"react";import{useEffect as cn,useState as un}from"react";import{jsx as Ae}from"react/jsx-runtime";import"react";var $=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&Ae(o.Component,{anchorElem:t,clientProps:e}):o.Component&&Ae(o.Component,{clientProps:e});import{c as kt}from"react/compiler-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext";import{$findMatchingParent as ne,mergeRegister as vt}from"@lexical/utils";import{$createNodeSelection as Tt,$getEditor as X,$getNearestNodeFromDOMNode as Dt,$getSelection as re,$isDecoratorNode as K,$isElementNode as xe,$isLineBreakNode as Lt,$isNodeSelection as ie,$isRangeSelection as Be,$isRootOrShadowRoot as Mt,$isTextNode as At,$setSelection as Ie,CLICK_COMMAND as Bt,COMMAND_PRIORITY_LOW as W,KEY_ARROW_DOWN_COMMAND as It,KEY_ARROW_UP_COMMAND as _t,KEY_BACKSPACE_COMMAND as Ot,KEY_DELETE_COMMAND as Ft,SELECTION_CHANGE_COMMAND as $t}from"lexical";import{useEffect as Kt}from"react";function _e(){let t=kt(3),[e]=wt(),o=Gt,n,r;return t[0]!==e?(n=()=>vt(e.registerCommand(Bt,Vt,W),e.registerCommand(Ft,o,W),e.registerCommand(Ot,o,W),e.registerCommand($t,Yt,W),e.registerCommand(_t,zt,W),e.registerCommand(It,Ht,W)),r=[e],t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),Kt(n,r),null}function Ht(t){let e=re();if(ie(e)){t.preventDefault();let s=e.getNodes()[0]?.getNextSibling();if(K(s)){let m=X().getElementByKey(s.getKey());return m&&Z({element:m,node:s}),!0}if(!xe(s))return!0;let a=s.getFirstDescendant()??s;return a&&(ne(a,se)?.selectEnd(),t.preventDefault()),!0}if(!Be(e))return!1;let n=(e.isBackward()?e.anchor:e.focus).getNode(),r=ne(n,jt),c=r?.getNextSibling();if(!r||c!==Oe(r))return!1;if(K(c)){let s=X().getElementByKey(c.getKey());if(s)return Z({element:s,node:c}),t.preventDefault(),!0}return!1}function jt(t){return Oe(t)!==null}function zt(t){let e=re();if(ie(e)){let s=e.getNodes()[0]?.getPreviousSibling();if(K(s)){let m=X().getElementByKey(s.getKey());return m?(Z({element:m,node:s}),t.preventDefault(),!0):!1}if(!xe(s))return!1;let a=s.getLastDescendant()??s;return a?(ne(a,se)?.selectStart(),t.preventDefault(),!0):!1}if(!Be(e))return!1;let n=(e.isBackward()?e.anchor:e.focus).getNode(),r=ne(n,Wt),c=r?.getPreviousSibling();if(!r||c!==Fe(r))return!1;if(K(c)){let s=X().getElementByKey(c.getKey());if(s)return Z({element:s,node:c}),t.preventDefault(),!0}return!1}function Wt(t){return Fe(t)!==null}function Yt(){let t=Jt();return document.querySelector(".decorator-selected")?.classList.remove("decorator-selected"),t?(t.element?.classList.add("decorator-selected"),!0):!1}function Vt(t){document.querySelector(".decorator-selected")?.classList.remove("decorator-selected");let e=qt(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 Gt(t){let e=re();return ie(e)?(t.preventDefault(),e.getNodes().forEach(Ut),!0):!1}function Ut(t){t.remove()}function qt(t){if(!(t.target instanceof HTMLElement))return;let e=t.target.closest('[data-lexical-decorator="true"]');if(!(e instanceof HTMLElement))return;let o=Dt(e);return K(o)?{element:e,node:o}:void 0}function Jt(){let t=re();if(!ie(t))return;let e=t.getNodes();if(e.length!==1)return;let o=e[0];return K(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(K(t)&&!t.isInline())return!0;if(!xe(t)||Mt(t))return!1;let e=t.getFirstChild(),o=e===null||Lt(e)||At(e)||e.isInline();return!t.isInline()&&t.canBeEmpty()!==!1&&o}function Oe(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 oo}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as no,isHTMLElement as ro}from"lexical";import*as je from"react";import{useCallback as io,useEffect as He,useRef as so,useState as lo}from"react";import{createPortal as ao}from"react-dom";var Y=(t,e,o,n,r=50,c=25)=>{let s=0;if(t&&!t.contains(n)){let{bottom:a,left:u,right:m,top:y}=t.getBoundingClientRect(),i=y+window.scrollY,l=a+window.scrollY;if(o<i-c||o>l+c||e<u-r||e>m+r)return-1;(e<u||e>m)&&(s=e<u?e-u:e-m)}return s};import{$getNodeByKey as ae}from"lexical";function V(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 le(t){let e=(u,m)=>u?parseFloat(window.getComputedStyle(u)[m]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),c=e(t.nextElementSibling,"marginTop"),s=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),c),marginTop:s}}import{$getRoot as Qt}from"lexical";function H(t){return t.getEditorState().read(()=>Qt().getChildrenKeys())}var Xt=1,Zt=-1,$e=0,A={props:null,result:null};function eo(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:c=0,point:{x:s,y:a},startIndex:u=0,useEdgeAsDefault:m=!1}=t;if(o>0&&A.props&&A.result&&A.props.fuzzy===t.fuzzy&&A.props.horizontalOffset===t.horizontalOffset&&A.props.useEdgeAsDefault===t.useEdgeAsDefault&&eo(A.props.point,t.point,o))return A.result;let y=e.getBoundingClientRect(),i=H(n),l={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(m){let g=n.getElementByKey(i[0]),f=n.getElementByKey(i[i.length-1]);if(g&&f){let[d,p]=[V(g),V(f)];if(a<d.top?(l.blockElem=g,l.distance=d.top-a,l.blockNode=ae(i[0]),l.foundAtIndex=0):a>p.bottom&&(l.distance=a-p.bottom,l.blockNode=ae(i[i.length-1]),l.blockElem=f,l.foundAtIndex=i.length-1),l?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let h=u,x=$e;for(;h>=0&&h<i.length;){let g=i[h],f=n.getElementByKey(g);if(f===null)break;let d=new _(s+c,a),p=Le.fromDOMRect(V(f)),{marginBottom:E,marginTop:w}=le(f),S=p.generateNewRect({bottom:p.bottom+E,left:y.left,right:y.right,top:p.top-w}),{distance:b,isOnBottomSide:k,isOnTopSide:N}=S.distanceFromPoint(d);if(b===0){l.blockElem=f,l.blockNode=ae(g),l.foundAtIndex=h,l.distance=b,l.blockNode&&l.blockNode.getType()==="paragraph"&&l.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(l.blockElem=null,l.blockNode=null),l.isFoundNodeEmptyParagraph=!0);break}else r&&b<l.distance&&(l.blockElem=f,l.blockNode=ae(g),l.distance=b,l.foundAtIndex=h);x===$e&&(N?x=Zt:k?x=Xt:x=1/0),h+=x}}),A.props=t,A.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 to=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function Ke(t){if(!t||to.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 ue(t,e,o,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),c=window.getComputedStyle(t),s=e.getBoundingClientRect(),a=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(i=>t.firstElementChild?.classList.contains(i)))u=r.top+8-a.top;else{let i=Ke(t)?parseInt(c.lineHeight,10):0;u=r.top+(i-s.height)/2-a.top}let y=n;e.style.opacity="1",e.style.transform=`translate(${y}px, ${u}px)`}var co="add-block-menu",de=1/0;function uo(t){return t===0?1/0:de>=0&&de<t?de:Math.floor(t/2)}function mo(t,e,o){let n=e.parentElement,{editorConfig:r}=R(),c=r?.admin?.hideGutter?-24:12,s=so(null),[a,u]=lo(null);He(()=>{function y(i){let l=i.target;if(!ro(l))return;let h=Y(n,i.pageX,i.pageY,l);if(h===-1){u(null);return}if(ce(l,co))return;let x=H(t),{blockElem:g,blockNode:f,foundAtIndex:d}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-h,point:new _(i.x,i.y),returnEmptyParagraphs:!0,startIndex:uo(x.length),useEdgeAsDefault:!1});de=d,g&&f&&(a?.node!==f||a?.elem!==g)&&u({elem:g,node:f})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,e,t,a]),He(()=>{s.current&&a?.node&&ue(a?.elem,s.current,e,c)},[e,a,c]);let m=io(y=>{let i=a;i?.node&&(t.update(()=>{let l=!0;if((i?.node.getType()!=="paragraph"||i.node.getTextContent()!=="")&&(l=!1),!l){let h=no();i?.node.insertAfter(h),setTimeout(()=>{i={elem:t.getElementByKey(h.getKey()),node:h},u(i)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),i?.node&&"select"in i.node&&typeof i.node.select=="function"&&i.node.select()})},1),setTimeout(()=>{t.dispatchCommand(Te,{node:i?.node})},2),y.stopPropagation(),y.preventDefault())},[t,a]);return ao(Ee(je.Fragment,{children:Ee("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{m(y)},ref:s,type:"button",children:Ee("div",{className:o?"icon":""})})}),e)}function ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=oo();return mo(n,o,n._editable)}import{jsx as me,jsxs as po}from"react/jsx-runtime";import{useLexicalComposerContext as go}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Ve}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as Ge,$getNodeByKey as ho,isHTMLElement as Ce}from"lexical";import*as Xe from"react";import{useEffect as be,useRef as fe,useState as Ue}from"react";import{createPortal as yo}from"react-dom";var We=0,fo=-24;var j=0;function Ye(t,e,o,n,r,c,s,a,u,m=!1){let{height:y,top:i}=n.getBoundingClientRect(),{top:l,width:h}=s.getBoundingClientRect(),{marginBottom:x,marginTop:g}=le(n),f=i,d=c>=i+y/2+window.scrollY,p=!1;if(r?.elem)if(n!==r?.elem)(d&&r?.elem&&r?.elem===n.nextElementSibling||!d&&r?.elem&&r?.elem===n.previousElementSibling)&&(j++,j<200&&(p=!0));else{j++;let b=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(d===r?.isBelow&&b===k||j<200)&&(p=!1)}if(p)return{isBelow:d,willStayInSamePosition:p};m?f+=y/2:d?f+=y+x/2:f-=g/2;let E=0;m||(d?E=-We:E=We);let w=f-l+E,S=fo-e;return o.style.width=`calc(${h}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${S}px, calc(${w}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="")),j=0,{isBelow:d,willStayInSamePosition:p}}var xo="draggable-block-menu",qe="application/x-lexical-drag-block",ee=1/0;function Je(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function Eo(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Qe(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Co(t,e,o){let n=e.parentElement,r=fe(null),c=fe(null),s=fe(null),a=fe(!1),[u,m]=Ue(null),[y,i]=Ue(null),{editorConfig:l}=R(),h=l?.admin?.hideGutter?-44:-8;be(()=>{function f(d){let p=d.target;if(!Ce(p))return;let E=Y(n,d.pageX,d.pageY,p);if(E===-1){m(null);return}if(ce(p,xo))return;let w=H(t),{blockElem:S,foundAtIndex:b,isFoundNodeEmptyParagraph:k}=G({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new _(d.x,d.y),startIndex:Je(w.length),useEdgeAsDefault:!1,verbose:!1});ee=b,!(!S&&!k)&&u!==S&&m(S)}return document?.addEventListener("mousemove",f),()=>{document?.removeEventListener("mousemove",f)}},[n,e,t,u]),be(()=>{r.current&&ue(u,r.current,e,h)},[e,u,h]),be(()=>{function f(p){if(!a.current)return!1;let[E]=Ve(p);if(E)return!1;let{pageY:w,target:S}=p;if(!Ce(S))return!1;let b=Y(n,p.pageX,p.pageY,S,100,50),k=H(t),{blockElem:N,foundAtIndex:L,isFoundNodeEmptyParagraph:I}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-b,point:new _(p.x,p.y),startIndex:Je(k.length),useEdgeAsDefault:!0,verbose:!0});ee=L;let v=c.current;if(N===null||v===null)return!1;if(u!==N){let{isBelow:T,willStayInSamePosition:J}=Ye(l?.admin?.hideGutter?"0px":"3rem",h+(l?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),v,N,y,w,e,p,s,I);p.preventDefault(),J||i({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:T})}else y?.elem&&(Qe(v,y.elem),i({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function d(p){if(!a.current)return!1;let[E]=Ve(p);if(E)return!1;let{dataTransfer:w,pageY:S,target:b}=p,k=w?.getData(qe)||"";return t.update(()=>{let N=ho(k);if(!N||!Ce(b))return!1;let L=Y(n,p.pageX,p.pageY,b,100,50),{blockElem:I,isFoundNodeEmptyParagraph:v}=G({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-L,point:new _(p.x,p.y),useEdgeAsDefault:!0});if(!I)return!1;let T=Ge(I);if(!T)return!1;if(T===N)return!0;let{height:J,top:he}=V(I),z=S>=he+J/2+window.scrollY;v?(T.insertBefore(N),T.remove()):z?T.insertAfter(N):T.insertBefore(N),u!==null&&m(null),document.querySelectorAll(".lexical-block-highlighter").forEach(D=>{D.remove()});let oe=t.getElementByKey(N.getKey());setTimeout(()=>{let D=oe?.getBoundingClientRect();if(!D)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=`${D.height+8}px`,P.style.width=`${D.width+8}px`,P.style.top=`${D.top+window.scrollY-4}px`,P.style.left=`${D.left-4}px`,setTimeout(()=>{P.style.opacity="0",setTimeout(()=>{P.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",f),document.addEventListener("drop",d),()=>{document.removeEventListener("dragover",f),document.removeEventListener("drop",d)}},[n,h,e,t,y,u,l?.admin?.hideGutter]);function x(f){let d=f.dataTransfer;if(!d||!u)return;Eo(d,u);let p="";t.update(()=>{let E=Ge(u);E&&(p=E.getKey())}),a.current=!0,d.setData(qe,p)}function g(){a.current=!1,y?.elem&&Qe(c.current,y?.elem)}return yo(po(Xe.Fragment,{children:[me("button",{"aria-label":"Drag to move",className:"icon draggable-block-menu",draggable:!0,onDragEnd:g,onDragStart:x,ref:r,type:"button",children:me("div",{className:o?"icon":""})}),me("div",{className:"draggable-block-target-line",ref:c}),me("div",{className:"debug-highlight",ref:s})]}),e)}function Ze(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=go();return Co(n,o,n._editable)}import{c as bo}from"react/compiler-runtime";import{jsx as Ne}from"react/jsx-runtime";import{useLexicalComposerContext as No}from"@lexical/react/LexicalComposerContext";import{$createParagraphNode as Po,$getRoot as So}from"lexical";import"react";var et="insert-paragraph-at-end",tt=()=>{let t=bo(2),[e]=No(),{editorConfig:o}=R();if(o?.admin?.hideInsertParagraphAtEnd)return null;let n;return t[0]!==e?(n=Ne("div",{"aria-label":"Insert Paragraph",className:et,onClick:()=>{e.update(Ro)},role:"button",tabIndex:0,children:Ne("div",{className:`${et}-inside`,children:Ne("span",{children:"+"})})}),t[0]=e,t[1]=n):n=t[1],n};function Ro(){let t=Po();So().append(t),t.select()}import{c as ko}from"react/compiler-runtime";import{useLexicalComposerContext as wo}from"@lexical/react/LexicalComposerContext";import*as ot from"react";var nt=()=>{let t=ko(4),{editorConfig:e}=R(),[o]=wo(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>ke(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]),ot.useEffect(n,r),null};import{useLexicalComposerContext as vo}from"@lexical/react/LexicalComposerContext";import{$getSelection as To,$isRangeSelection as Do,RootNode as Lo}from"lexical";import{useEffect as Mo}from"react";function rt(){let[t]=vo();return Mo(()=>t.registerNodeTransform(Lo,e=>{let o=To();if(Do(o)){let n=o.anchor.getNode(),r=o.focus.getNode();(!n.isAttached()||!r.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{useLexicalComposerContext as Ao}from"@lexical/react/LexicalComposerContext";import{$getSelection as Bo,COMMAND_PRIORITY_LOW as Io,SELECT_ALL_COMMAND as _o}from"lexical";import{useEffect as Oo}from"react";function it(){let[t]=Ao();return Oo(()=>t.registerCommand(_o,()=>{if(Bo())return!1;let o=document.activeElement;return o instanceof HTMLInputElement&&o.select(),!0},Io),[t]),null}import{jsx as U,jsxs as lt}from"react/jsx-runtime";import{useLexicalComposerContext as $o}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as at}from"@payloadcms/ui";import{useCallback as Ko,useMemo as Ho,useState as jo}from"react";import"react";import*as ct from"react-dom";import{c as Fo}from"react/compiler-runtime";import"react";function st(t,e){let o=Fo(4),{maxLength:n,minLength:r}=e,c=n===void 0?75:n,s=r===void 0?1:r,a;return o[0]!==c||o[1]!==s||o[2]!==t?(a=u=>{let{query:m}=u,y="[^"+t+ve+"\\s]",l=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+c+"}))$").exec(m);if(l!==null){let h=l[1],x=l[3];if(x.length>=s)return{leadOffset:l.index+h.length,matchingString:x,replaceableString:l[2]}}return null},o[0]=c,o[1]=s,o[2]=t,o[3]=a):a=o[3],a}var B="slash-menu-popup";function zo({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:c,schemaPath:s}}=R(),{i18n:a}=at(),u=`${B}__item ${B}__item-${e.key}`;t&&(u+=` ${B}__item--selected`);let m=e.key;return e.label&&(m=typeof e.label=="function"?e.label({featureClientSchemaMap:c,i18n:a,schemaPath:s}):e.label),m.length>25&&(m=m.substring(0,25)+"..."),lt("button",{"aria-selected":t,className:u,id:B+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&U(e.Icon,{}),U("span",{className:`${B}__item-text`,children:m})]},e.key)}function ut({anchorElem:t=document.body}){let[e]=$o(),[o,n]=jo(null),{editorConfig:r}=R(),{i18n:c}=at(),{fieldProps:{featureClientSchemaMap:s,schemaPath:a}}=R(),u=st("/",{minLength:0}),m=Ko(()=>{let i=[];for(let l of r.features.slashMenu.dynamicGroups)if(o){let h=l({editor:e,queryString:o});i=i.concat(h)}return i},[e,o,r?.features]),y=Ho(()=>{let i=[];for(let l of r?.features.slashMenu.groups??[])i.push(l);if(o){i=i.map(h=>{let x=h.items.filter(g=>{let f=g.key;return g.label&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:s,i18n:c,schemaPath:a}):g.label),new RegExp(o,"gi").exec(f)?!0:g.keywords!=null?g.keywords.some(d=>new RegExp(o,"gi").exec(d)):!1});return x.length?{...h,items:x}:null}),i=i.filter(h=>h!=null);let l=m();for(let h of l){let x=i.find(g=>g.key===h.key);x?i=i.filter(g=>g.key!==h.key):x={...h,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),i.push(x)}}return i},[o,r?.features.slashMenu.groups,m,s,c,a]);return U(De,{anchorElem:t,groups:y,menuRenderFn:(i,{selectedItemKey:l,selectItemAndCleanUp:h,setSelectedItemKey:x})=>i.current&&y.length?ct.createPortal(U("div",{className:B,children:y.map(g=>{let f=g.key;return g.label&&s&&(f=typeof g.label=="function"?g.label({featureClientSchemaMap:s,i18n:c,schemaPath:a}):g.label),lt("div",{className:`${B}__group ${B}__group-${g.key}`,children:[U("div",{className:`${B}__group-title`,children:f}),g.items.map((d,p)=>U(zo,{index:p,isSelected:l===d.key,item:d,onClick:()=>{x(d.key),h(d)},onMouseEnter:()=>{x(d.key)},ref:E=>{d.ref={current:E}}},d.key))]},g.key)})}),i.current):null,onQueryChange:n,triggerFn:u})}import{c as Wo}from"react/compiler-runtime";import{useLexicalComposerContext as Yo}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as Vo,TextNode as Go}from"lexical";import{useEffect as Uo}from"react";function dt(t){let e=Wo(6),{features:o}=t,[n]=Yo(),r;e[0]!==n||e[1]!==o.enabledFormats?(r=()=>{let s=qo(o.enabledFormats);if(s.length!==0)return n.registerNodeTransform(Go,a=>{s.forEach(u=>{a.hasFormat(u)&&a.toggleFormat(u)})})},e[0]=n,e[1]=o.enabledFormats,e[2]=r):r=e[2];let c;return e[3]!==n||e[4]!==o?(c=[n,o],e[3]=n,e[4]=o,e[5]=c):c=e[5],Uo(r,c),null}function qo(t){let e=Object.keys(Vo),o=new Set(t);return e.filter(n=>!o.has(n))}import{c as Jo}from"react/compiler-runtime";import{jsx as mt}from"react/jsx-runtime";import{ContentEditable as Qo}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Xo}from"@payloadcms/ui";import"react";function ft(t){let e=Jo(4),{className:o,editorConfig:n}=t,{t:r}=Xo(),c;return e[0]!==o||e[1]!==n?.admin?.placeholder||e[2]!==r?(c=mt(Qo,{"aria-placeholder":r("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:mt("p",{className:"editor-placeholder",children:n?.admin?.placeholder??r("lexical:general:placeholder")})}),e[0]=o,e[1]=n?.admin?.placeholder,e[2]=r,e[3]=c):c=e[3],c}var gt=t=>{let e=Zo(14),{editorConfig:o,editorContainerRef:n,isSmallWidthViewport:r,onChange:c}=t,s=R(),[a]=en(),u=sn(),[m,y]=un(null),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=f=>{f!==null&&y(f)},e[0]=i):i=e[0];let l=i,h,x;e[1]!==a||e[2]!==s?(h=()=>{if(!s?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}s?.parentEditor?.uuid&&s.parentEditor?.registerChild(s.uuid,s);let f=()=>{s.focusEditor(s)},d=()=>{s.blurEditor(s)},p=a.registerCommand(an,()=>(f(),!0),pt),E=a.registerCommand(ln,()=>(d(),!0),pt);return()=>{p(),E(),s.parentEditor?.unregisterChild?.(s.uuid)}},x=[a,s],e[1]=a,e[2]=s,e[3]=h,e[4]=x):(h=e[3],x=e[4]),cn(h,x);let g;if(e[5]!==o||e[6]!==n||e[7]!==m||e[8]!==u||e[9]!==r||e[10]!==c){let f;e[12]!==c?(f=(d,p,E)=>{(!E.has("focus")||E.size>1)&&c?.(d,p,E)},e[12]=c,e[13]=f):f=e[13],g=te(q.Fragment,{children:[o.features.plugins?.map(dn),te("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(mn),C(rn,{contentEditable:C("div",{className:"editor-scroller",children:C("div",{className:"editor",ref:l,children:C(ft,{editorConfig:o})})}),ErrorBoundary:tn}),C(rt,{}),C(tt,{}),C(_e,{}),C(dt,{features:o.features}),C(it,{}),C(nn,{ignoreSelectionChange:!0,onChange:f}),m&&te(q.Fragment,{children:[!r&&u&&te(q.Fragment,{children:[o.admin?.hideDraggableBlockElement?null:C(Ze,{anchorElem:m}),o.admin?.hideAddBlockButton?null:C(ze,{anchorElem:m})]}),o.features.plugins?.map(d=>{if(d.position==="floatingAnchorElem"&&!(d.desktopOnly===!0&&r))return C($,{anchorElem:m,clientProps:d.clientProps,plugin:d},d.key)}),u&&C(q.Fragment,{children:C(ut,{anchorElem:m})})]}),u&&te(q.Fragment,{children:[C(on,{}),o?.features?.markdownTransformers?.length>0&&C(nt,{})]}),o.features.plugins?.map(fn),o.features.plugins?.map(pn)]}),o.features.plugins?.map(gn)]}),e[5]=o,e[6]=n,e[7]=m,e[8]=u,e[9]=r,e[10]=c,e[11]=g}else g=e[11];return g};function dn(t){if(t.position==="aboveContainer")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function mn(t){if(t.position==="top")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function fn(t){if(t.position==="normal")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function pn(t){if(t.position==="bottom")return C($,{clientProps:t.clientProps,plugin:t},t.key)}function gn(t){if(t.position==="belowContainer")return C($,{clientProps:t.clientProps,plugin:t},t.key)}var yt=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?O(o,{children:O(yt,{providers:e.slice(1),children:t})}):O(o,{children:t})},xt=t=>{let{composerKey:e,editorConfig:o,fieldProps:n,isSmallWidthViewport:r,onChange:c,readOnly:s,value:a}=t,u=R(),m=yn(),y=ht.useRef(null),i=xn(()=>{if(a&&typeof a!="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(a));if(a&&Array.isArray(a)&&!("root"in a))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(a&&"jsonContent"in a)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:s!==!0,editorState:a!=null?JSON.stringify(a):void 0,namespace:o.lexical.namespace,nodes:Me({editorConfig:o}),onError:l=>{throw l},theme:o.lexical.theme}},[o]);return i?O(hn,{initialConfig:i,children:O(Re,{editorConfig:o,editorContainerRef:y,fieldProps:n,parentContext:u?.editDepth===m?u:void 0,children:O(yt,{providers:o.features.providers,children:O(gt,{editorConfig:o,editorContainerRef:y,isSmallWidthViewport:r,onChange:c})})})},e+i.editable):O("p",{children:"Loading..."})};var pe="rich-text-lexical",Tn=t=>{let{editorConfig:e,field:o,field:{admin:{className:n,description:r,readOnly:c}={},label:s,localized:a,required:u},path:m,readOnly:y,validate:i}=t,l=y||c,h=Nn(),x=bt((M,Q)=>typeof i=="function"?i(M,{...Q,required:u}):!0,[i,u]),{customComponents:{AfterInput:g,BeforeInput:f,Description:d,Error:p,Label:E}={},disabled:w,initialValue:S,path:b,setValue:k,showError:N,value:L}=Sn({potentiallyStalePath:m,validate:x}),I=l||w,[v,T]=Pt(!1),[J,he]=Pt(),ye=Ct.useRef(S),z=Ct.useRef(L);Nt(()=>{let M=()=>{let Q=window.matchMedia("(max-width: 768px)").matches;Q!==v&&T(Q)};return M(),window.addEventListener("resize",M),()=>{window.removeEventListener("resize",M)}},[v]);let Pe=[pe,"field-type",n,N&&"error",I&&`${pe}--read-only`,e?.admin?.hideGutter!==!0&&!v?`${pe}--show-gutter`:null].filter(Boolean).join(" "),oe=`${b}.${h}`,D=we(),P=bt(M=>{D(()=>{let Se=M.toJSON();z.current=Se,k(Se)})},[k,D]),St=wn(()=>Rn(o),[o]),Rt=Pn(M=>{z.current!==L&&!kn(JSON.parse(JSON.stringify(z.current)),L)&&(ye.current=M,z.current=L,he(new Date))});return Nt(()=>{Object.is(S,ye.current)||Rt(S)},[S]),ge("div",{className:Pe,style:St,children:[F(Et,{CustomComponent:p,Fallback:F(Cn,{path:b,showError:N})}),E||F(bn,{label:s,localized:a,path:b,required:u}),ge("div",{className:`${pe}__wrap`,children:[ge(vn,{fallbackRender:Dn,onReset:()=>{},children:[f,F(xt,{composerKey:oe,editorConfig:e,fieldProps:t,isSmallWidthViewport:v,onChange:P,readOnly:I,value:L},JSON.stringify({path:b,rerenderProviderKey:J})),g]}),F(Et,{CustomComponent:d,Fallback:F(En,{description:r,path:b})})]})]},oe)};function Dn({error:t}){return ge("div",{className:"errorBoundary",role:"alert",children:[F("p",{children:"Something went wrong:"}),F("pre",{style:{color:"red"},children:t.message})]})}var fs=Tn;export{fs as RichText};
|
|
2
|
-
//# sourceMappingURL=Field-RQHCQRLV.js.map
|