@payloadcms/richtext-lexical 3.68.0-internal-debug.2eb12b9 → 3.68.0-internal-debug.185cc5f
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/features/blocks/client/component/index.js +1 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js +1 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js +1 -0
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.js +1 -0
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +1 -0
- package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +1 -0
- package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js +1 -0
- package/dist/features/experimental_table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/horizontalRule/client/plugin/index.js +1 -0
- package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js +3 -0
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js +1 -0
- package/dist/features/link/client/plugins/floatingLinkEditor/index.js.map +1 -1
- package/dist/features/link/server/baseFields.js +1 -0
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js +1 -0
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js +1 -0
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/Component.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +1 -0
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +1 -0
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +1 -0
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +1 -0
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +1 -0
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/upload/client/component/index.js +1 -0
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/component/pending/index.js +1 -0
- package/dist/features/upload/client/component/pending/index.js.map +1 -1
- package/dist/field/Diff/converters/listitem/index.js +1 -0
- package/dist/field/Diff/converters/listitem/index.js.map +1 -1
- package/dist/field/Diff/converters/relationship/index.js +1 -0
- package/dist/field/Diff/converters/relationship/index.js.map +1 -1
- package/dist/field/Diff/converters/unknown/index.js +1 -0
- package/dist/field/Diff/converters/unknown/index.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.js +1 -0
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/Diff/index.js +1 -0
- package/dist/field/Diff/index.js.map +1 -1
- package/dist/field/Field.js +2 -0
- package/dist/field/Field.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.js +1 -0
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js +1 -0
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js +1 -0
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +2 -0
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +2 -0
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +1 -0
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +1 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +1 -0
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +2 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +2 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +2 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +2 -0
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +2 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/package.json +7 -7
package/dist/field/Diff/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc';
|
|
3
|
+
import './index.scss';
|
|
3
4
|
import '../bundled.css';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\nimport '../bundled.css'\n\nimport React from 'react'\n\nimport type { HTMLConvertersFunctionAsync } from '../../features/converters/lexicalToHtml/async/types.js'\n\nimport { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js'\nimport { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js'\nimport { LinkDiffHTMLConverterAsync } from './converters/link.js'\nimport { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js'\nimport { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js'\nimport { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js'\nimport { UploadDiffHTMLConverterAsync } from './converters/upload/index.js'\n\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const {\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n req,\n versionValue: valueTo,\n } = args\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({}),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n, req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n, req }),\n ...UnknownDiffHTMLConverterAsync({ i18n, req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req,\n })\n const fromHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueFrom as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const toHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueTo as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const { From, To } = getHTMLDiffComponents({\n // Ensure empty paragraph is displayed for empty rich text fields - otherwise, toHTML may be displayed in the wrong column\n fromHTML: fromHTML?.length ? fromHTML : '<p></p>',\n toHTML: toHTML?.length ? toHTML : '<p></p>',\n })\n\n return (\n <FieldDiffContainer\n className={baseClass}\n From={From}\n i18n={i18n}\n label={{\n label: field.label,\n locale,\n }}\n nestingLevel={nestingLevel}\n To={To}\n />\n )\n}\n"],"names":["FieldDiffContainer","getHTMLDiffComponents","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","baseClass","LexicalDiffComponent","args","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","req","versionValue","valueTo","converters","defaultConverters","payloadPopulateFn","currentDepth","depth","fromHTML","data","disableContainer","populate","toHTML","From","To","length","className","label"],"mappings":";AAGA,SAASA,kBAAkB,EAAEC,qBAAqB,QAAQ,qBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\nimport '../bundled.css'\n\nimport React from 'react'\n\nimport type { HTMLConvertersFunctionAsync } from '../../features/converters/lexicalToHtml/async/types.js'\n\nimport { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js'\nimport { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js'\nimport { LinkDiffHTMLConverterAsync } from './converters/link.js'\nimport { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js'\nimport { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js'\nimport { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js'\nimport { UploadDiffHTMLConverterAsync } from './converters/upload/index.js'\n\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const {\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n req,\n versionValue: valueTo,\n } = args\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({}),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n, req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n, req }),\n ...UnknownDiffHTMLConverterAsync({ i18n, req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req,\n })\n const fromHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueFrom as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const toHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueTo as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const { From, To } = getHTMLDiffComponents({\n // Ensure empty paragraph is displayed for empty rich text fields - otherwise, toHTML may be displayed in the wrong column\n fromHTML: fromHTML?.length ? fromHTML : '<p></p>',\n toHTML: toHTML?.length ? toHTML : '<p></p>',\n })\n\n return (\n <FieldDiffContainer\n className={baseClass}\n From={From}\n i18n={i18n}\n label={{\n label: field.label,\n locale,\n }}\n nestingLevel={nestingLevel}\n To={To}\n />\n )\n}\n"],"names":["FieldDiffContainer","getHTMLDiffComponents","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","baseClass","LexicalDiffComponent","args","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","req","versionValue","valueTo","converters","defaultConverters","payloadPopulateFn","currentDepth","depth","fromHTML","data","disableContainer","populate","toHTML","From","To","length","className","label"],"mappings":";AAGA,SAASA,kBAAkB,EAAEC,qBAAqB,QAAQ,qBAAoB;AAE9E,OAAO,eAAc;AACrB,OAAO,iBAAgB;AAEvB,OAAOC,WAAW,QAAO;AAIzB,SAASC,yBAAyB,QAAQ,yDAAwD;AAClG,SAASC,oBAAoB,QAAQ,2DAA0D;AAC/F,SAASC,0BAA0B,QAAQ,uBAAsB;AACjE,SAASC,8BAA8B,QAAQ,iCAAgC;AAC/E,SAASC,kCAAkC,QAAQ,qCAAoC;AACvF,SAASC,6BAA6B,QAAQ,gCAA+B;AAC7E,SAASC,4BAA4B,QAAQ,+BAA8B;AAE3E,MAAMC,YAAY;AAElB,OAAO,MAAMC,uBAAyD,OAAOC;IAC3E,MAAM,EACJC,iBAAiBC,SAAS,EAC1BC,KAAK,EACLC,IAAI,EACJC,MAAM,EACNC,YAAY,EACZC,GAAG,EACHC,cAAcC,OAAO,EACtB,GAAGT;IAEJ,MAAMU,aAA0C,CAAC,EAAEC,iBAAiB,EAAE,GAAM,CAAA;YAC1E,GAAGA,iBAAiB;YACpB,GAAGlB,2BAA2B,CAAC,EAAE;YACjC,GAAGC,8BAA8B;YACjC,GAAGG,6BAA6B;gBAAEO;gBAAMG;YAAI,EAAE;YAC9C,GAAGZ,mCAAmC;gBAAES;gBAAMG;YAAI,EAAE;YACpD,GAAGX,8BAA8B;gBAAEQ;gBAAMG;YAAI,EAAE;QACjD,CAAA;IAEA,MAAMK,oBAAoB,MAAMpB,qBAAqB;QACnDqB,cAAc;QACdC,OAAO;QACPP;IACF;IACA,MAAMQ,WAAW,MAAMxB,0BAA0B;QAC/CmB;QACAM,MAAMd;QACNe,kBAAkB;QAClBC,UAAUN;IACZ;IAEA,MAAMO,SAAS,MAAM5B,0BAA0B;QAC7CmB;QACAM,MAAMP;QACNQ,kBAAkB;QAClBC,UAAUN;IACZ;IAEA,MAAM,EAAEQ,IAAI,EAAEC,EAAE,EAAE,GAAGhC,sBAAsB;QACzC,0HAA0H;QAC1H0B,UAAUA,UAAUO,SAASP,WAAW;QACxCI,QAAQA,QAAQG,SAASH,SAAS;IACpC;IAEA,qBACE,KAAC/B;QACCmC,WAAWzB;QACXsB,MAAMA;QACNhB,MAAMA;QACNoB,OAAO;YACLA,OAAOrB,MAAMqB,KAAK;YAClBnB;QACF;QACAC,cAAcA;QACde,IAAIA;;AAGV,EAAC"}
|
package/dist/field/Field.js
CHANGED
|
@@ -5,7 +5,9 @@ import { mergeFieldStyles } from '@payloadcms/ui/shared';
|
|
|
5
5
|
import { dequal } from 'dequal/lite';
|
|
6
6
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
7
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
|
+
import '../lexical/theme/EditorTheme.scss';
|
|
8
9
|
import './bundled.css';
|
|
10
|
+
import './index.scss';
|
|
9
11
|
import { LexicalProvider } from '../lexical/LexicalProvider.js';
|
|
10
12
|
import { useRunDeprioritized } from '../utilities/useRunDeprioritized.js';
|
|
11
13
|
const baseClass = 'rich-text-lexical';
|
package/dist/field/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n BulkUploadProvider,\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(\n prevValueRef.current != null\n ? JSON.parse(JSON.stringify(prevValueRef.current))\n : prevValueRef.current,\n value,\n )\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n {/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer\n is rendered in the correct depth (not displayed *behind* the current drawer)*/}\n <BulkUploadProvider drawerSlugPrefix={path}>\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n </BulkUploadProvider>\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"names":["BulkUploadProvider","FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","div","style","CustomComponent","Fallback","fallbackRender","onReset","drawerSlugPrefix","composerKey","fieldProps","onChange","error","role","p","pre","color","message","RichText"],"mappings":"AAAA;;AAGA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH,iBAAgB;AACvB,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,MAAM,QAAQ,cAAa;AAEpC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,SAASC,aAAa,QAAQ,uBAAsB;AAKpD,OAAO,gBAAe;AAKtB,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,mBAAmB,QAAQ,sCAAqC;AAEzE,MAAMC,YAA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E;QACtE,qDAAqD;QACrD,IAAI,CAACyE,OAAOC,EAAE,CAACtC,cAAcQ,oBAAoBsB,OAAO,GAAG;YACzDE,yBAAyBhC;QAC3B;IACF,GAAG;QAACA;KAAa;IAEjB,qBACE,MAACuC;QAAI/D,WAAW0C;QAAiCsB,OAAOT;;0BACtD,KAAC3E;gBACCqF,iBAAiB7C;gBACjB8C,wBAAU,KAACxF;oBAAW6B,MAAMA;oBAAMmB,WAAWA;;;YAE9CL,uBAAS,KAAC1C;gBAAWyB,OAAOA;gBAAOC,WAAWA;gBAAWE,MAAMA;gBAAMD,UAAUA;;0BAChF,MAACyD;gBAAI/D,WAAW,GAAGN,UAAU,MAAM,CAAC;;kCAClC,MAACH;wBAAc4E,gBAAgBA;wBAAgBC,SAAS,KAAO;;4BAC5DlD;4BACA;sFAC2E,iBAC5E,KAAC1C;gCAAmB6F,kBAAkB9D;0CACpC,cAAA,KAACf;oCACC8E,aAAavB;oCACblD,cAAcA;oCACd0E,YAAY3E;oCACZgC,sBAAsBA;oCAC8B,0QAA0Q;oCAC9T4C,UAAUvB;oCACV/C,UAAUoB;oCACVR,OAAOA;mCAHF2C,KAAKE,SAAS,CAAC;oCAAEpD;oCAAMuB;gCAAoB;;4BAMnDb;;;kCAEH,KAACrC;wBACCqF,iBAAiB9C;wBACjB+C,wBAAU,KAACzF;4BAAiBwB,aAAaA;4BAAaM,MAAMA;;;;;;OA3BpCwC;AAgClC;AAEA,SAASoB,eAAe,EAAEM,KAAK,EAAoB;IACjD,8EAA8E;IAE9E,qBACE,MAACV;QAAI/D,WAAU;QAAgB0E,MAAK;;0BAClC,KAACC;0BAAE;;0BACH,KAACC;gBAAIZ,OAAO;oBAAEa,OAAO;gBAAM;0BAAIJ,MAAMK,OAAO;;;;AAGlD;AAEA,OAAO,MAAMC,WAAqCpF,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n BulkUploadProvider,\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(\n prevValueRef.current != null\n ? JSON.parse(JSON.stringify(prevValueRef.current))\n : prevValueRef.current,\n value,\n )\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n {/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer\n is rendered in the correct depth (not displayed *behind* the current drawer)*/}\n <BulkUploadProvider drawerSlugPrefix={path}>\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n </BulkUploadProvider>\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"names":["BulkUploadProvider","FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","div","style","CustomComponent","Fallback","fallbackRender","onReset","drawerSlugPrefix","composerKey","fieldProps","onChange","error","role","p","pre","color","message","RichText"],"mappings":"AAAA;;AAGA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH,iBAAgB;AACvB,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,MAAM,QAAQ,cAAa;AAEpC,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACxE,SAASC,aAAa,QAAQ,uBAAsB;AAIpD,OAAO,oCAAmC;AAC1C,OAAO,gBAAe;AACtB,OAAO,eAAc;AAIrB,SAASC,eAAe,QAAQ,gCAA+B;AAC/D,SAASC,mBAAmB,QAAQ,sCAAqC;AAEzE,MAAMC,YAAY;AAElB,MAAMC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D;QACrD,IAAI,CAACyE,OAAOC,EAAE,CAACtC,cAAcQ,oBAAoBsB,OAAO,GAAG;YACzDE,yBAAyBhC;QAC3B;IACF,GAAG;QAACA;KAAa;IAEjB,qBACE,MAACuC;QAAI/D,WAAW0C;QAAiCsB,OAAOT;;0BACtD,KAAC3E;gBACCqF,iBAAiB7C;gBACjB8C,wBAAU,KAACxF;oBAAW6B,MAAMA;oBAAMmB,WAAWA;;;YAE9CL,uBAAS,KAAC1C;gBAAWyB,OAAOA;gBAAOC,WAAWA;gBAAWE,MAAMA;gBAAMD,UAAUA;;0BAChF,MAACyD;gBAAI/D,WAAW,GAAGN,UAAU,MAAM,CAAC;;kCAClC,MAACH;wBAAc4E,gBAAgBA;wBAAgBC,SAAS,KAAO;;4BAC5DlD;4BACA;sFAC2E,iBAC5E,KAAC1C;gCAAmB6F,kBAAkB9D;0CACpC,cAAA,KAACf;oCACC8E,aAAavB;oCACblD,cAAcA;oCACd0E,YAAY3E;oCACZgC,sBAAsBA;oCAC8B,0QAA0Q;oCAC9T4C,UAAUvB;oCACV/C,UAAUoB;oCACVR,OAAOA;mCAHF2C,KAAKE,SAAS,CAAC;oCAAEpD;oCAAMuB;gCAAoB;;4BAMnDb;;;kCAEH,KAACrC;wBACCqF,iBAAiB9C;wBACjB+C,wBAAU,KAACzF;4BAAiBwB,aAAaA;4BAAaM,MAAMA;;;;;;OA3BpCwC;AAgClC;AAEA,SAASoB,eAAe,EAAEM,KAAK,EAAoB;IACjD,8EAA8E;IAE9E,qBACE,MAACV;QAAI/D,WAAU;QAAgB0E,MAAK;;0BAClC,KAACC;0BAAE;;0BACH,KAACC;gBAAIZ,OAAO;oBAAEa,OAAO;gBAAM;0BAAIJ,MAAMK,OAAO;;;;AAGlD;AAEA,OAAO,MAAMC,WAAqCpF,kBAAiB"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { GenericLanguages, GenericTranslationsObject } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport {\n afterChangeTraverseFields,\n afterReadTraverseFields,\n beforeChangeTraverseFields,\n beforeValidateTraverseFields,\n checkDependencies,\n deepMergeSimple,\n type RichTextAdapter,\n withNullableJSONSchemaType,\n} from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { AdapterProps, LexicalEditorProps, LexicalRichTextAdapterProvider } from './types.js'\n\nimport { i18n } from './i18n.js'\nimport { defaultEditorFeatures } from './lexical/config/server/default.js'\nimport { populateLexicalPopulationPromises } from './populateGraphQL/populateLexicalPopulationPromises.js'\nimport { featuresInputToEditorConfig } from './utilities/editorConfigFactory.js'\nimport { getGenerateImportMap } from './utilities/generateImportMap.js'\nimport { getGenerateSchemaMap } from './utilities/generateSchemaMap.js'\nimport { getDefaultSanitizedEditorConfig } from './utilities/getDefaultSanitizedEditorConfig.js'\nimport { recurseNodeTree } from './utilities/recurseNodeTree.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nlet checkedDependencies = false\n\nexport const lexicalTargetVersion = '0.35.0'\n\nexport function lexicalEditor(args?: LexicalEditorProps): LexicalRichTextAdapterProvider {\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&\n !checkedDependencies\n ) {\n checkedDependencies = true\n void checkDependencies({\n dependencyGroups: [\n {\n name: 'lexical',\n dependencies: [\n 'lexical',\n '@lexical/headless',\n '@lexical/link',\n '@lexical/list',\n '@lexical/mark',\n '@lexical/react',\n '@lexical/rich-text',\n '@lexical/selection',\n '@lexical/utils',\n ],\n targetVersion: lexicalTargetVersion,\n },\n ],\n })\n }\n return async ({ config, isRoot, parentIsLocalized }) => {\n let features: FeatureProviderServer<unknown, unknown, unknown>[] = []\n let resolvedFeatureMap: ResolvedServerFeatureMap\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!args || (!args.features && !args.lexical)) {\n finalSanitizedEditorConfig = await getDefaultSanitizedEditorConfig({\n config,\n parentIsLocalized,\n })\n\n features = defaultEditorFeatures\n\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n const result = await featuresInputToEditorConfig({\n config,\n features: args?.features,\n isRoot,\n lexical: args?.lexical,\n parentIsLocalized,\n })\n finalSanitizedEditorConfig = result.sanitizedConfig\n features = result.features\n resolvedFeatureMap = result.resolvedFeatureMap\n }\n\n const featureI18n: Partial<GenericLanguages> = finalSanitizedEditorConfig.features.i18n\n for (const _lang in i18n) {\n const lang = _lang as keyof typeof i18n\n const lexicalI18nForLang = ((featureI18n[lang] ??= {}).lexical ??=\n {}) as GenericTranslationsObject\n\n lexicalI18nForLang.general = i18n[lang] ?? {}\n }\n\n config.i18n.translations = deepMergeSimple(config.i18n.translations, featureI18n)\n\n return {\n CellComponent: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell',\n DiffComponent: '@payloadcms/richtext-lexical/rsc#LexicalDiffComponent',\n editorConfig: finalSanitizedEditorConfig,\n features,\n FieldComponent: {\n path: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalField',\n serverProps: {\n admin: args?.admin,\n // SanitizedEditorConfig is manually passed by `renderField` in `fieldSchemasToFormState/renderField.tsx`\n // in order to reduce the size of the field schema\n },\n },\n generateImportMap: getGenerateImportMap({\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.graphQLPopulationPromises?.size) {\n populateLexicalPopulationPromises({\n context,\n currentDepth: currentDepth ?? 0,\n depth,\n draft,\n editorPopulationPromises: finalSanitizedEditorConfig.features.graphQLPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: {\n afterChange: [\n async (args) => {\n const {\n collection,\n context: _context,\n data,\n field,\n global,\n indexPath,\n operation,\n originalDoc,\n parentIsLocalized,\n path,\n previousDoc,\n previousValue,\n req,\n schemaPath,\n } = args\n\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.afterChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterChange) {\n value = await hook(args)\n }\n }\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.afterChange?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n // TO-DO: We should not use context, as it is intended for external use only\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const previousNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n recurseNodeTree({\n nodeIDMap: previousNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const afterChangeHooks = finalSanitizedEditorConfig.features.nodeHooks?.afterChange\n const afterChangeHooksForNode = afterChangeHooks?.get(node.type)\n if (afterChangeHooksForNode) {\n for (const hook of afterChangeHooksForNode) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(afterChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n\n previousNode: previousNodeIDMap[id]!,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n\n const nodeSiblingDoc = subFieldDataFn({ node: originalNodeIDMap[id]!, req }) ?? {}\n const nodePreviousSiblingDoc =\n subFieldDataFn({ node: previousNodeIDMap[id]!, req }) ?? {}\n\n if (subFields?.length) {\n await afterChangeTraverseFields({\n blockData: nodeSiblingData,\n collection,\n context,\n data: data ?? {},\n doc: originalDoc,\n fields: subFields,\n global,\n operation,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n previousDoc,\n previousSiblingDoc: { ...nodePreviousSiblingDoc },\n req,\n siblingData: nodeSiblingData || {},\n siblingDoc: { ...nodeSiblingDoc },\n })\n }\n }\n }\n return value\n },\n ],\n afterRead: [\n /**\n * afterRead hooks do not receive the originalNode. Thus, they can run on all nodes, not just nodes with an ID.\n */\n async (args) => {\n const {\n collection,\n context: context,\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n indexPath,\n locale,\n originalDoc,\n overrideAccess,\n parentIsLocalized,\n path,\n populate,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n triggerAccessControl,\n triggerHooks,\n } = args\n\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.afterRead?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterRead) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.afterRead?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n const flattenedNodes: SerializedLexicalNode[] = []\n\n recurseNodeTree({\n flattenedNodes,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n for (let node of flattenedNodes) {\n const afterReadHooks = finalSanitizedEditorConfig.features.nodeHooks?.afterRead\n const afterReadHooksForNode = afterReadHooks?.get(node.type)\n if (afterReadHooksForNode) {\n for (const hook of afterReadHooksForNode) {\n node = await hook({\n context,\n currentDepth: currentDepth!,\n depth: depth!,\n draft: draft!,\n fallbackLocale: fallbackLocale!,\n fieldPromises: fieldPromises!,\n findMany: findMany!,\n flattenLocales: flattenLocales!,\n locale: locale!,\n node,\n overrideAccess: overrideAccess!,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n populateArg: populate,\n populationPromises: populationPromises!,\n req,\n showHiddenFields: showHiddenFields!,\n triggerAccessControl: triggerAccessControl!,\n triggerHooks: triggerHooks!,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n\n if (subFields?.length) {\n afterReadTraverseFields({\n blockData: nodeSiblingData,\n collection,\n context,\n currentDepth: currentDepth!,\n depth: depth!,\n doc: originalDoc,\n draft: draft!,\n fallbackLocale: fallbackLocale!,\n fieldPromises: fieldPromises!,\n fields: subFields,\n findMany: findMany!,\n flattenLocales: flattenLocales!,\n global,\n locale: locale!,\n overrideAccess: overrideAccess!,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n populate,\n populationPromises: populationPromises!,\n req,\n showHiddenFields: showHiddenFields!,\n siblingDoc: nodeSiblingData,\n triggerAccessControl,\n triggerHooks,\n })\n }\n }\n }\n\n return value\n },\n ],\n beforeChange: [\n async (args) => {\n const {\n collection,\n context: _context,\n data,\n docWithLocales,\n errors,\n field,\n fieldLabelPath,\n global,\n indexPath,\n mergeLocaleActions,\n operation,\n originalDoc,\n overrideAccess,\n parentIsLocalized,\n path,\n previousValue,\n req,\n schemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n } = args\n\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeChange) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.beforeChange?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n\n // TO-DO: We should not use context, as it is intended for external use only\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n const previousNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const originalNodeWithLocalesIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n recurseNodeTree({\n nodeIDMap: previousNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n if (field.name && siblingDocWithLocales?.[field.name]) {\n recurseNodeTree({\n nodeIDMap: originalNodeWithLocalesIDMap,\n nodes:\n (siblingDocWithLocales[field.name] as SerializedEditorState)?.root?.children ??\n [],\n })\n }\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeChangeHooks = finalSanitizedEditorConfig.features.nodeHooks?.beforeChange\n const beforeChangeHooksForNode = beforeChangeHooks?.get(node.type)\n if (beforeChangeHooksForNode) {\n for (const hook of beforeChangeHooksForNode) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n errors: errors!,\n mergeLocaleActions: mergeLocaleActions!,\n node,\n operation: operation!,\n originalNode: originalNodeIDMap[id],\n originalNodeWithLocales: originalNodeWithLocalesIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n previousNode: previousNodeIDMap[id]!,\n req,\n skipValidation: skipValidation!,\n })\n }\n }\n\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n const nodeSiblingDocWithLocales =\n subFieldDataFn({\n node: originalNodeWithLocalesIDMap[id]!,\n req,\n }) ?? {}\n const nodePreviousSiblingDoc =\n subFieldDataFn({ node: previousNodeIDMap[id]!, req }) ?? {}\n\n if (subFields?.length) {\n await beforeChangeTraverseFields({\n id,\n blockData: nodeSiblingData,\n collection,\n context,\n data: data ?? {},\n doc: originalDoc ?? {},\n docWithLocales: docWithLocales ?? {},\n errors: errors!,\n fieldLabelPath,\n fields: subFields,\n global,\n mergeLocaleActions: mergeLocaleActions!,\n operation: operation!,\n overrideAccess,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n req,\n siblingData: nodeSiblingData,\n siblingDoc: nodePreviousSiblingDoc,\n siblingDocWithLocales: nodeSiblingDocWithLocales ?? {},\n skipValidation,\n })\n }\n }\n }\n\n /**\n * within the beforeChange hook, id's may be re-generated.\n * Example:\n * 1. Seed data contains IDs for block feature blocks.\n * 2. Those are used in beforeValidate\n * 3. in beforeChange, those IDs are regenerated, because you cannot provide IDs during document creation. See baseIDField beforeChange hook for reasoning\n * 4. Thus, in order for all post-beforeChange hooks to receive the correct ID, we need to update the originalNodeIDMap with the new ID's, by regenerating the nodeIDMap.\n * The reason this is not generated for every hook, is to save on performance. We know we only really have to generate it in beforeValidate, which is the first hook,\n * and in beforeChange, which is where modifications to the provided IDs can occur.\n */\n const newOriginalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const previousOriginalValue = siblingData[field.name!]\n\n recurseNodeTree({\n nodeIDMap: newOriginalNodeIDMap,\n nodes: (previousOriginalValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!context.internal.richText) {\n context.internal.richText = {}\n }\n context.internal.richText[path.join('.')] = {\n originalNodeIDMap: newOriginalNodeIDMap,\n }\n\n return value\n },\n ],\n beforeValidate: [\n async (args) => {\n const {\n collection,\n context,\n data,\n field,\n global,\n indexPath,\n operation,\n originalDoc,\n overrideAccess,\n parentIsLocalized,\n path,\n previousValue,\n req,\n schemaPath,\n } = args\n\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeValidate?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeValidate) {\n value = await hook(args)\n }\n }\n\n // return value if there are NO hooks\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.beforeValidate?.size &&\n !finalSanitizedEditorConfig.features.nodeHooks?.afterChange?.size &&\n !finalSanitizedEditorConfig.features.nodeHooks?.beforeChange?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n\n /**\n * beforeValidate is the first field hook which runs. This is where we can create the node map, which can then be used in the other hooks.\n *\n */\n\n /**\n * flattenedNodes contains all nodes in the editor, in the order they appear in the editor. They will be used for the following hooks:\n * - afterRead\n *\n * The other hooks require nodes to have IDs, which is why those are ran only from the nodeIDMap. They require IDs because they have both doc/siblingDoc and data/siblingData, and\n * thus require a reliable way to match new node data to old node data. Given that node positions can change in between hooks, this is only reliably possible for nodes which are saved with\n * an ID.\n */\n //const flattenedNodes: SerializedLexicalNode[] = []\n\n /**\n * Only nodes with id's (so, nodes with hooks added to them) will be added to the nodeIDMap. They will be used for the following hooks:\n * - afterChange\n * - beforeChange\n * - beforeValidate\n *\n * Other hooks are handled by the flattenedNodes. All nodes in the nodeIDMap are part of flattenedNodes.\n */\n\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap: originalNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!(context as any).internal.richText) {\n ;(context as any).internal.richText = {}\n }\n ;(context as any).internal.richText[path.join('.')] = {\n originalNodeIDMap,\n }\n\n /**\n * Now that the maps for all hooks are set up, we can run the validate hook\n */\n if (!finalSanitizedEditorConfig.features.nodeHooks?.beforeValidate?.size) {\n return value\n }\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n recurseNodeTree({\n //flattenedNodes,\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeValidateHooks =\n finalSanitizedEditorConfig.features.nodeHooks.beforeValidate\n const beforeValidateHooksForNode = beforeValidateHooks?.get(node.type)\n if (beforeValidateHooksForNode) {\n for (const hook of beforeValidateHooksForNode) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeValidate) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n overrideAccess: overrideAccess!,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n\n const nodeSiblingDoc = subFieldDataFn({ node: originalNodeIDMap[id]!, req }) ?? {}\n\n if (subFields?.length) {\n await beforeValidateTraverseFields({\n id,\n blockData: nodeSiblingData,\n collection,\n context,\n data,\n doc: originalDoc,\n fields: subFields,\n global,\n operation,\n overrideAccess: overrideAccess!,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n req,\n siblingData: nodeSiblingData,\n siblingDoc: nodeSiblingDoc,\n })\n }\n }\n }\n\n return value\n },\n ],\n },\n outputSchema: ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let outputSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n tsType: 'any',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes\n .modifyOutputSchemas) {\n outputSchema = modifyOutputSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: outputSchema,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return outputSchema\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n }\n}\n\nexport { AlignFeature } from './features/align/server/index.js'\nexport { BlockquoteFeature } from './features/blockquote/server/index.js'\nexport { CodeBlock } from './features/blocks/premade/CodeBlock/index.js'\nexport { BlocksFeature, type BlocksFeatureProps } from './features/blocks/server/index.js'\nexport {\n $createServerBlockNode,\n $isServerBlockNode,\n type BlockFields,\n ServerBlockNode,\n} from './features/blocks/server/nodes/BlocksNode.js'\n\nexport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n type InlineBlockFields,\n ServerInlineBlockNode,\n} from './features/blocks/server/nodes/InlineBlocksNode.js'\n\nexport { convertHTMLToLexical } from './features/converters/htmlToLexical/index.js'\n\nexport { lexicalHTMLField } from './features/converters/lexicalToHtml/async/field/index.js'\nexport { LinebreakHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/linebreak.js'\n\nexport { ParagraphHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.js'\n\nexport { TabHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/tab.js'\nexport { TextHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/text.js'\nexport { defaultHTMLConverters } from './features/converters/lexicalToHtml_deprecated/converter/defaultConverters.js'\n\nexport {\n convertLexicalNodesToHTML,\n convertLexicalToHTML,\n} from './features/converters/lexicalToHtml_deprecated/converter/index.js'\nexport type { HTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/types.js'\nexport {\n consolidateHTMLConverters,\n lexicalHTML,\n} from './features/converters/lexicalToHtml_deprecated/field/index.js'\nexport {\n HTMLConverterFeature,\n type HTMLConverterFeatureProps,\n} from './features/converters/lexicalToHtml_deprecated/index.js'\nexport { convertLexicalToMarkdown } from './features/converters/lexicalToMarkdown/index.js'\nexport { convertMarkdownToLexical } from './features/converters/markdownToLexical/index.js'\nexport { getPayloadPopulateFn } from './features/converters/utilities/payloadPopulateFn.js'\n\nexport { getRestPopulateFn } from './features/converters/utilities/restPopulateFn.js'\nexport { DebugJsxConverterFeature } from './features/debug/jsxConverter/server/index.js'\nexport { TestRecorderFeature } from './features/debug/testRecorder/server/index.js'\nexport { TreeViewFeature } from './features/debug/treeView/server/index.js'\nexport { EXPERIMENTAL_TableFeature } from './features/experimental_table/server/index.js'\nexport { BoldFeature } from './features/format/bold/feature.server.js'\nexport { InlineCodeFeature } from './features/format/inlineCode/feature.server.js'\n\nexport { ItalicFeature } from './features/format/italic/feature.server.js'\nexport { StrikethroughFeature } from './features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './features/format/underline/feature.server.js'\nexport { HeadingFeature, type HeadingFeatureProps } from './features/heading/server/index.js'\nexport { HorizontalRuleFeature } from './features/horizontalRule/server/index.js'\n\nexport { IndentFeature } from './features/indent/server/index.js'\nexport {\n $createAutoLinkNode,\n $isAutoLinkNode,\n AutoLinkNode,\n} from './features/link/nodes/AutoLinkNode.js'\nexport { $createLinkNode, $isLinkNode, LinkNode } from './features/link/nodes/LinkNode.js'\n\nexport type { LinkFields } from './features/link/nodes/types.js'\nexport { LinkFeature, type LinkFeatureServerProps } from './features/link/server/index.js'\n\nexport { ChecklistFeature } from './features/lists/checklist/server/index.js'\nexport { OrderedListFeature } from './features/lists/orderedList/server/index.js'\n\nexport { UnorderedListFeature } from './features/lists/unorderedList/server/index.js'\nexport type {\n SlateNode,\n SlateNodeConverter,\n} from './features/migrations/slateToLexical/converter/types.js'\nexport { ParagraphFeature } from './features/paragraph/server/index.js'\n\nexport {\n RelationshipFeature,\n type RelationshipFeatureProps,\n} from './features/relationship/server/index.js'\n\nexport {\n type RelationshipData,\n RelationshipServerNode,\n} from './features/relationship/server/nodes/RelationshipNode.js'\nexport { defaultColors } from './features/textState/defaultColors.js'\nexport { TextStateFeature } from './features/textState/feature.server.js'\n\nexport { FixedToolbarFeature } from './features/toolbars/fixed/server/index.js'\n\nexport { InlineToolbarFeature } from './features/toolbars/inline/server/index.js'\nexport type { ToolbarGroup, ToolbarGroupItem } from './features/toolbars/types.js'\nexport type {\n BaseClientFeatureProps,\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n PluginComponent,\n PluginComponentWithAnchor,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n} from './features/typesClient.js'\n\nexport type {\n AfterChangeNodeHook,\n AfterChangeNodeHookArgs,\n AfterReadNodeHook,\n AfterReadNodeHookArgs,\n BaseNodeHookArgs,\n BeforeChangeNodeHook,\n BeforeChangeNodeHookArgs,\n BeforeValidateNodeHook,\n BeforeValidateNodeHookArgs,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n NodeWithHooks,\n PopulationPromise,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './features/typesServer.js'\n\nexport { createNode } from './features/typeUtilities.js' // Only useful in feature.server.ts\n\nexport { UploadFeature } from './features/upload/server/index.js'\nexport type { UploadFeatureProps } from './features/upload/server/index.js'\n\nexport { type UploadData, UploadServerNode } from './features/upload/server/nodes/UploadNode.js'\nexport type { EditorConfigContextType } from './lexical/config/client/EditorConfigProvider.js'\n\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n} from './lexical/config/server/default.js'\nexport { loadFeatures, sortFeaturesForOptimalLoading } from './lexical/config/server/loader.js'\n\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './lexical/config/types.js'\nexport type { AdapterProps }\n\nexport { getEnabledNodes, getEnabledNodesFromServerNodes } from './lexical/nodes/index.js'\n\nexport type {\n SlashMenuGroup,\n SlashMenuItem,\n} from './lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NodeFormat,\n NON_BREAKING_SPACE,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './lexical/utils/nodeFormat.js'\n\nexport { sanitizeUrl, validateUrl } from './lexical/utils/url.js'\n\nexport type * from './nodeTypes.js'\n\nexport { $convertFromMarkdownString } from './packages/@lexical/markdown/index.js'\nexport { defaultRichTextValue } from './populateGraphQL/defaultValue.js'\nexport { populate } from './populateGraphQL/populate.js'\n\nexport type { LexicalEditorProps, LexicalFieldAdminProps, LexicalRichTextAdapter } from './types.js'\n\nexport { buildDefaultEditorState, buildEditorState } from './utilities/buildEditorState.js'\nexport { createServerFeature } from './utilities/createServerFeature.js'\n\nexport { editorConfigFactory } from './utilities/editorConfigFactory.js'\nexport type { FieldsDrawerProps } from './utilities/fieldsDrawer/Drawer.js'\n\nexport { extractPropsFromJSXPropsString } from './utilities/jsx/extractPropsFromJSXPropsString.js'\n\nexport {\n extractFrontmatter,\n frontmatterToObject,\n objectToFrontmatter,\n propsToJSXString,\n} from './utilities/jsx/jsx.js'\nexport { upgradeLexicalData } from './utilities/upgradeLexicalData/index.js'\n"],"names":["afterChangeTraverseFields","afterReadTraverseFields","beforeChangeTraverseFields","beforeValidateTraverseFields","checkDependencies","deepMergeSimple","withNullableJSONSchemaType","i18n","defaultEditorFeatures","populateLexicalPopulationPromises","featuresInputToEditorConfig","getGenerateImportMap","getGenerateSchemaMap","getDefaultSanitizedEditorConfig","recurseNodeTree","richTextValidateHOC","checkedDependencies","lexicalTargetVersion","lexicalEditor","args","process","env","NODE_ENV","PAYLOAD_DISABLE_DEPENDENCY_CHECKER","dependencyGroups","name","dependencies","targetVersion","config","isRoot","parentIsLocalized","features","resolvedFeatureMap","finalSanitizedEditorConfig","lexical","result","sanitizedConfig","featureI18n","_lang","lang","lexicalI18nForLang","general","translations","CellComponent","DiffComponent","editorConfig","FieldComponent","path","serverProps","admin","generateImportMap","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","size","editorPopulationPromises","hooks","afterChange","collection","_context","data","global","indexPath","operation","originalDoc","previousDoc","previousValue","schemaPath","value","length","hook","nodeHooks","getSubFields","nodeIDMap","previousNodeIDMap","originalNodeIDMap","internal","richText","join","Object","keys","nodes","root","children","id","node","entries","afterChangeHooks","afterChangeHooksForNode","get","type","console","warn","originalNode","parentRichTextFieldPath","parentRichTextFieldSchemaPath","previousNode","subFieldFn","subFieldDataFn","getSubFieldsData","subFields","nodeSiblingData","nodeSiblingDoc","nodePreviousSiblingDoc","blockData","doc","fields","parentIndexPath","localized","parentPath","parentSchemaPath","previousSiblingDoc","siblingData","afterRead","fallbackLocale","locale","populate","triggerAccessControl","triggerHooks","flattenedNodes","afterReadHooks","afterReadHooksForNode","populateArg","beforeChange","docWithLocales","errors","fieldLabelPath","mergeLocaleActions","siblingDocWithLocales","skipValidation","originalNodeWithLocalesIDMap","beforeChangeHooks","beforeChangeHooksForNode","originalNodeWithLocales","nodeSiblingDocWithLocales","newOriginalNodeIDMap","previousOriginalValue","beforeValidate","beforeValidateHooks","beforeValidateHooksForNode","outputSchema","collectionIDFieldTypes","interfaceNameDefinitions","isRequired","properties","additionalProperties","items","tsType","version","required","direction","oneOf","enum","format","indent","modifyOutputSchema","generatedTypes","modifyOutputSchemas","currentSchema","validate","AlignFeature","BlockquoteFeature","CodeBlock","BlocksFeature","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","convertHTMLToLexical","lexicalHTMLField","LinebreakHTMLConverter","ParagraphHTMLConverter","TabHTMLConverter","TextHTMLConverter","defaultHTMLConverters","convertLexicalNodesToHTML","convertLexicalToHTML","consolidateHTMLConverters","lexicalHTML","HTMLConverterFeature","convertLexicalToMarkdown","convertMarkdownToLexical","getPayloadPopulateFn","getRestPopulateFn","DebugJsxConverterFeature","TestRecorderFeature","TreeViewFeature","EXPERIMENTAL_TableFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$createLinkNode","$isLinkNode","LinkNode","LinkFeature","ChecklistFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","RelationshipServerNode","defaultColors","TextStateFeature","FixedToolbarFeature","InlineToolbarFeature","createNode","UploadFeature","UploadServerNode","defaultEditorConfig","defaultEditorLexicalConfig","loadFeatures","sortFeaturesForOptimalLoading","sanitizeServerEditorConfig","sanitizeServerFeatures","getEnabledNodes","getEnabledNodesFromServerNodes","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NodeFormat","NON_BREAKING_SPACE","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","sanitizeUrl","validateUrl","$convertFromMarkdownString","defaultRichTextValue","buildDefaultEditorState","buildEditorState","createServerFeature","editorConfigFactory","extractPropsFromJSXPropsString","extractFrontmatter","frontmatterToObject","objectToFrontmatter","propsToJSXString","upgradeLexicalData"],"mappings":"AAIA,SACEA,yBAAyB,EACzBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,iBAAiB,EACjBC,eAAe,EAEfC,0BAA0B,QACrB,UAAS;AAMhB,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,qBAAqB,QAAQ,qCAAoC;AAC1E,SAASC,iCAAiC,QAAQ,yDAAwD;AAC1G,SAASC,2BAA2B,QAAQ,qCAAoC;AAChF,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,+BAA+B,QAAQ,iDAAgD;AAChG,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,mBAAmB,QAAQ,sBAAqB;AAEzD,IAAIC,sBAAsB;AAE1B,OAAO,MAAMC,uBAAuB,SAAQ;AAE5C,OAAO,SAASC,cAAcC,IAAyB;IACrD,IACEC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzBF,QAAQC,GAAG,CAACE,kCAAkC,KAAK,UACnD,CAACP,qBACD;QACAA,sBAAsB;QACtB,KAAKZ,kBAAkB;YACrBoB,kBAAkB;gBAChB;oBACEC,MAAM;oBACNC,cAAc;wBACZ;wBACA;wBACA;wBACA;wBACA;wBACA;wBACA;wBACA;wBACA;qBACD;oBACDC,eAAeV;gBACjB;aACD;QACH;IACF;IACA,OAAO,OAAO,EAAEW,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAE;QACjD,IAAIC,WAA+D,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Q,qCAAoC;AAGxE,SAASC,8BAA8B,QAAQ,oDAAmD;AAElG,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,QACX,yBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,0CAAyC"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { GenericLanguages, GenericTranslationsObject } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport {\n afterChangeTraverseFields,\n afterReadTraverseFields,\n beforeChangeTraverseFields,\n beforeValidateTraverseFields,\n checkDependencies,\n deepMergeSimple,\n type RichTextAdapter,\n withNullableJSONSchemaType,\n} from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { AdapterProps, LexicalEditorProps, LexicalRichTextAdapterProvider } from './types.js'\n\nimport { i18n } from './i18n.js'\nimport { defaultEditorFeatures } from './lexical/config/server/default.js'\nimport { populateLexicalPopulationPromises } from './populateGraphQL/populateLexicalPopulationPromises.js'\nimport { featuresInputToEditorConfig } from './utilities/editorConfigFactory.js'\nimport { getGenerateImportMap } from './utilities/generateImportMap.js'\nimport { getGenerateSchemaMap } from './utilities/generateSchemaMap.js'\nimport { getDefaultSanitizedEditorConfig } from './utilities/getDefaultSanitizedEditorConfig.js'\nimport { recurseNodeTree } from './utilities/recurseNodeTree.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nlet checkedDependencies = false\n\nexport const lexicalTargetVersion = '0.35.0'\n\nexport function lexicalEditor(args?: LexicalEditorProps): LexicalRichTextAdapterProvider {\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true' &&\n !checkedDependencies\n ) {\n checkedDependencies = true\n void checkDependencies({\n dependencyGroups: [\n {\n name: 'lexical',\n dependencies: [\n 'lexical',\n '@lexical/headless',\n '@lexical/link',\n '@lexical/list',\n '@lexical/mark',\n '@lexical/react',\n '@lexical/rich-text',\n '@lexical/selection',\n '@lexical/utils',\n ],\n targetVersion: lexicalTargetVersion,\n },\n ],\n })\n }\n return async ({ config, isRoot, parentIsLocalized }) => {\n let features: FeatureProviderServer<unknown, unknown, unknown>[] = []\n let resolvedFeatureMap: ResolvedServerFeatureMap\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!args || (!args.features && !args.lexical)) {\n finalSanitizedEditorConfig = await getDefaultSanitizedEditorConfig({\n config,\n parentIsLocalized,\n })\n\n features = defaultEditorFeatures\n\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n const result = await featuresInputToEditorConfig({\n config,\n features: args?.features,\n isRoot,\n lexical: args?.lexical,\n parentIsLocalized,\n })\n finalSanitizedEditorConfig = result.sanitizedConfig\n features = result.features\n resolvedFeatureMap = result.resolvedFeatureMap\n }\n\n const featureI18n: Partial<GenericLanguages> = finalSanitizedEditorConfig.features.i18n\n for (const _lang in i18n) {\n const lang = _lang as keyof typeof i18n\n const lexicalI18nForLang = ((featureI18n[lang] ??= {}).lexical ??=\n {}) as GenericTranslationsObject\n\n lexicalI18nForLang.general = i18n[lang] ?? {}\n }\n\n config.i18n.translations = deepMergeSimple(config.i18n.translations, featureI18n)\n\n return {\n CellComponent: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell',\n DiffComponent: '@payloadcms/richtext-lexical/rsc#LexicalDiffComponent',\n editorConfig: finalSanitizedEditorConfig,\n features,\n FieldComponent: {\n path: '@payloadcms/richtext-lexical/rsc#RscEntryLexicalField',\n serverProps: {\n admin: args?.admin,\n // SanitizedEditorConfig is manually passed by `renderField` in `fieldSchemasToFormState/renderField.tsx`\n // in order to reduce the size of the field schema\n },\n },\n generateImportMap: getGenerateImportMap({\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.graphQLPopulationPromises?.size) {\n populateLexicalPopulationPromises({\n context,\n currentDepth: currentDepth ?? 0,\n depth,\n draft,\n editorPopulationPromises: finalSanitizedEditorConfig.features.graphQLPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n parentIsLocalized,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: {\n afterChange: [\n async (args) => {\n const {\n collection,\n context: _context,\n data,\n field,\n global,\n indexPath,\n operation,\n originalDoc,\n parentIsLocalized,\n path,\n previousDoc,\n previousValue,\n req,\n schemaPath,\n } = args\n\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.afterChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterChange) {\n value = await hook(args)\n }\n }\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.afterChange?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n // TO-DO: We should not use context, as it is intended for external use only\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const previousNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n recurseNodeTree({\n nodeIDMap: previousNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const afterChangeHooks = finalSanitizedEditorConfig.features.nodeHooks?.afterChange\n const afterChangeHooksForNode = afterChangeHooks?.get(node.type)\n if (afterChangeHooksForNode) {\n for (const hook of afterChangeHooksForNode) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(afterChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n\n previousNode: previousNodeIDMap[id]!,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n\n const nodeSiblingDoc = subFieldDataFn({ node: originalNodeIDMap[id]!, req }) ?? {}\n const nodePreviousSiblingDoc =\n subFieldDataFn({ node: previousNodeIDMap[id]!, req }) ?? {}\n\n if (subFields?.length) {\n await afterChangeTraverseFields({\n blockData: nodeSiblingData,\n collection,\n context,\n data: data ?? {},\n doc: originalDoc,\n fields: subFields,\n global,\n operation,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n previousDoc,\n previousSiblingDoc: { ...nodePreviousSiblingDoc },\n req,\n siblingData: nodeSiblingData || {},\n siblingDoc: { ...nodeSiblingDoc },\n })\n }\n }\n }\n return value\n },\n ],\n afterRead: [\n /**\n * afterRead hooks do not receive the originalNode. Thus, they can run on all nodes, not just nodes with an ID.\n */\n async (args) => {\n const {\n collection,\n context: context,\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n indexPath,\n locale,\n originalDoc,\n overrideAccess,\n parentIsLocalized,\n path,\n populate,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n triggerAccessControl,\n triggerHooks,\n } = args\n\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.afterRead?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterRead) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.afterRead?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n const flattenedNodes: SerializedLexicalNode[] = []\n\n recurseNodeTree({\n flattenedNodes,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n for (let node of flattenedNodes) {\n const afterReadHooks = finalSanitizedEditorConfig.features.nodeHooks?.afterRead\n const afterReadHooksForNode = afterReadHooks?.get(node.type)\n if (afterReadHooksForNode) {\n for (const hook of afterReadHooksForNode) {\n node = await hook({\n context,\n currentDepth: currentDepth!,\n depth: depth!,\n draft: draft!,\n fallbackLocale: fallbackLocale!,\n fieldPromises: fieldPromises!,\n findMany: findMany!,\n flattenLocales: flattenLocales!,\n locale: locale!,\n node,\n overrideAccess: overrideAccess!,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n populateArg: populate,\n populationPromises: populationPromises!,\n req,\n showHiddenFields: showHiddenFields!,\n triggerAccessControl: triggerAccessControl!,\n triggerHooks: triggerHooks!,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n\n if (subFields?.length) {\n afterReadTraverseFields({\n blockData: nodeSiblingData,\n collection,\n context,\n currentDepth: currentDepth!,\n depth: depth!,\n doc: originalDoc,\n draft: draft!,\n fallbackLocale: fallbackLocale!,\n fieldPromises: fieldPromises!,\n fields: subFields,\n findMany: findMany!,\n flattenLocales: flattenLocales!,\n global,\n locale: locale!,\n overrideAccess: overrideAccess!,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n populate,\n populationPromises: populationPromises!,\n req,\n showHiddenFields: showHiddenFields!,\n siblingDoc: nodeSiblingData,\n triggerAccessControl,\n triggerHooks,\n })\n }\n }\n }\n\n return value\n },\n ],\n beforeChange: [\n async (args) => {\n const {\n collection,\n context: _context,\n data,\n docWithLocales,\n errors,\n field,\n fieldLabelPath,\n global,\n indexPath,\n mergeLocaleActions,\n operation,\n originalDoc,\n overrideAccess,\n parentIsLocalized,\n path,\n previousValue,\n req,\n schemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n } = args\n\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeChange) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.beforeChange?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n\n // TO-DO: We should not use context, as it is intended for external use only\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n const previousNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const originalNodeWithLocalesIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n recurseNodeTree({\n nodeIDMap: previousNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n if (field.name && siblingDocWithLocales?.[field.name]) {\n recurseNodeTree({\n nodeIDMap: originalNodeWithLocalesIDMap,\n nodes:\n (siblingDocWithLocales[field.name] as SerializedEditorState)?.root?.children ??\n [],\n })\n }\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeChangeHooks = finalSanitizedEditorConfig.features.nodeHooks?.beforeChange\n const beforeChangeHooksForNode = beforeChangeHooks?.get(node.type)\n if (beforeChangeHooksForNode) {\n for (const hook of beforeChangeHooksForNode) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n errors: errors!,\n mergeLocaleActions: mergeLocaleActions!,\n node,\n operation: operation!,\n originalNode: originalNodeIDMap[id],\n originalNodeWithLocales: originalNodeWithLocalesIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n previousNode: previousNodeIDMap[id]!,\n req,\n skipValidation: skipValidation!,\n })\n }\n }\n\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n const nodeSiblingDocWithLocales =\n subFieldDataFn({\n node: originalNodeWithLocalesIDMap[id]!,\n req,\n }) ?? {}\n const nodePreviousSiblingDoc =\n subFieldDataFn({ node: previousNodeIDMap[id]!, req }) ?? {}\n\n if (subFields?.length) {\n await beforeChangeTraverseFields({\n id,\n blockData: nodeSiblingData,\n collection,\n context,\n data: data ?? {},\n doc: originalDoc ?? {},\n docWithLocales: docWithLocales ?? {},\n errors: errors!,\n fieldLabelPath,\n fields: subFields,\n global,\n mergeLocaleActions: mergeLocaleActions!,\n operation: operation!,\n overrideAccess,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n req,\n siblingData: nodeSiblingData,\n siblingDoc: nodePreviousSiblingDoc,\n siblingDocWithLocales: nodeSiblingDocWithLocales ?? {},\n skipValidation,\n })\n }\n }\n }\n\n /**\n * within the beforeChange hook, id's may be re-generated.\n * Example:\n * 1. Seed data contains IDs for block feature blocks.\n * 2. Those are used in beforeValidate\n * 3. in beforeChange, those IDs are regenerated, because you cannot provide IDs during document creation. See baseIDField beforeChange hook for reasoning\n * 4. Thus, in order for all post-beforeChange hooks to receive the correct ID, we need to update the originalNodeIDMap with the new ID's, by regenerating the nodeIDMap.\n * The reason this is not generated for every hook, is to save on performance. We know we only really have to generate it in beforeValidate, which is the first hook,\n * and in beforeChange, which is where modifications to the provided IDs can occur.\n */\n const newOriginalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const previousOriginalValue = siblingData[field.name!]\n\n recurseNodeTree({\n nodeIDMap: newOriginalNodeIDMap,\n nodes: (previousOriginalValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!context.internal.richText) {\n context.internal.richText = {}\n }\n context.internal.richText[path.join('.')] = {\n originalNodeIDMap: newOriginalNodeIDMap,\n }\n\n return value\n },\n ],\n beforeValidate: [\n async (args) => {\n const {\n collection,\n context,\n data,\n field,\n global,\n indexPath,\n operation,\n originalDoc,\n overrideAccess,\n parentIsLocalized,\n path,\n previousValue,\n req,\n schemaPath,\n } = args\n\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeValidate?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeValidate) {\n value = await hook(args)\n }\n }\n\n // return value if there are NO hooks\n if (\n !finalSanitizedEditorConfig.features.nodeHooks?.beforeValidate?.size &&\n !finalSanitizedEditorConfig.features.nodeHooks?.afterChange?.size &&\n !finalSanitizedEditorConfig.features.nodeHooks?.beforeChange?.size &&\n !finalSanitizedEditorConfig.features.getSubFields?.size\n ) {\n return value\n }\n\n /**\n * beforeValidate is the first field hook which runs. This is where we can create the node map, which can then be used in the other hooks.\n *\n */\n\n /**\n * flattenedNodes contains all nodes in the editor, in the order they appear in the editor. They will be used for the following hooks:\n * - afterRead\n *\n * The other hooks require nodes to have IDs, which is why those are ran only from the nodeIDMap. They require IDs because they have both doc/siblingDoc and data/siblingData, and\n * thus require a reliable way to match new node data to old node data. Given that node positions can change in between hooks, this is only reliably possible for nodes which are saved with\n * an ID.\n */\n //const flattenedNodes: SerializedLexicalNode[] = []\n\n /**\n * Only nodes with id's (so, nodes with hooks added to them) will be added to the nodeIDMap. They will be used for the following hooks:\n * - afterChange\n * - beforeChange\n * - beforeValidate\n *\n * Other hooks are handled by the flattenedNodes. All nodes in the nodeIDMap are part of flattenedNodes.\n */\n\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap: originalNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!(context as any).internal.richText) {\n ;(context as any).internal.richText = {}\n }\n ;(context as any).internal.richText[path.join('.')] = {\n originalNodeIDMap,\n }\n\n /**\n * Now that the maps for all hooks are set up, we can run the validate hook\n */\n if (!finalSanitizedEditorConfig.features.nodeHooks?.beforeValidate?.size) {\n return value\n }\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n recurseNodeTree({\n //flattenedNodes,\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeValidateHooks =\n finalSanitizedEditorConfig.features.nodeHooks.beforeValidate\n const beforeValidateHooksForNode = beforeValidateHooks?.get(node.type)\n if (beforeValidateHooksForNode) {\n for (const hook of beforeValidateHooksForNode) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeValidate) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n overrideAccess: overrideAccess!,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields?.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData?.get(\n node.type,\n )\n\n if (subFieldFn && subFieldDataFn) {\n const subFields = subFieldFn({ node, req })\n const nodeSiblingData = subFieldDataFn({ node, req }) ?? {}\n\n const nodeSiblingDoc = subFieldDataFn({ node: originalNodeIDMap[id]!, req }) ?? {}\n\n if (subFields?.length) {\n await beforeValidateTraverseFields({\n id,\n blockData: nodeSiblingData,\n collection,\n context,\n data,\n doc: originalDoc,\n fields: subFields,\n global,\n operation,\n overrideAccess: overrideAccess!,\n parentIndexPath: indexPath.join('-'),\n parentIsLocalized: parentIsLocalized || field.localized || false,\n parentPath: path.join('.'),\n parentSchemaPath: schemaPath.join('.'),\n req,\n siblingData: nodeSiblingData,\n siblingDoc: nodeSiblingDoc,\n })\n }\n }\n }\n\n return value\n },\n ],\n },\n outputSchema: ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let outputSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n tsType: 'any',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes\n .modifyOutputSchemas) {\n outputSchema = modifyOutputSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: outputSchema,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return outputSchema\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n }\n}\n\nexport { AlignFeature } from './features/align/server/index.js'\nexport { BlockquoteFeature } from './features/blockquote/server/index.js'\nexport { CodeBlock } from './features/blocks/premade/CodeBlock/index.js'\nexport { BlocksFeature, type BlocksFeatureProps } from './features/blocks/server/index.js'\nexport {\n $createServerBlockNode,\n $isServerBlockNode,\n type BlockFields,\n ServerBlockNode,\n} from './features/blocks/server/nodes/BlocksNode.js'\n\nexport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n type InlineBlockFields,\n ServerInlineBlockNode,\n} from './features/blocks/server/nodes/InlineBlocksNode.js'\n\nexport { convertHTMLToLexical } from './features/converters/htmlToLexical/index.js'\n\nexport { lexicalHTMLField } from './features/converters/lexicalToHtml/async/field/index.js'\nexport { LinebreakHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/linebreak.js'\n\nexport { ParagraphHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.js'\n\nexport { TabHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/tab.js'\nexport { TextHTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/converters/text.js'\nexport { defaultHTMLConverters } from './features/converters/lexicalToHtml_deprecated/converter/defaultConverters.js'\n\nexport {\n convertLexicalNodesToHTML,\n convertLexicalToHTML,\n} from './features/converters/lexicalToHtml_deprecated/converter/index.js'\nexport type { HTMLConverter } from './features/converters/lexicalToHtml_deprecated/converter/types.js'\nexport {\n consolidateHTMLConverters,\n lexicalHTML,\n} from './features/converters/lexicalToHtml_deprecated/field/index.js'\nexport {\n HTMLConverterFeature,\n type HTMLConverterFeatureProps,\n} from './features/converters/lexicalToHtml_deprecated/index.js'\nexport { convertLexicalToMarkdown } from './features/converters/lexicalToMarkdown/index.js'\nexport { convertMarkdownToLexical } from './features/converters/markdownToLexical/index.js'\nexport { getPayloadPopulateFn } from './features/converters/utilities/payloadPopulateFn.js'\n\nexport { getRestPopulateFn } from './features/converters/utilities/restPopulateFn.js'\nexport { DebugJsxConverterFeature } from './features/debug/jsxConverter/server/index.js'\nexport { TestRecorderFeature } from './features/debug/testRecorder/server/index.js'\nexport { TreeViewFeature } from './features/debug/treeView/server/index.js'\nexport { EXPERIMENTAL_TableFeature } from './features/experimental_table/server/index.js'\nexport { BoldFeature } from './features/format/bold/feature.server.js'\nexport { InlineCodeFeature } from './features/format/inlineCode/feature.server.js'\n\nexport { ItalicFeature } from './features/format/italic/feature.server.js'\nexport { StrikethroughFeature } from './features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './features/format/underline/feature.server.js'\nexport { HeadingFeature, type HeadingFeatureProps } from './features/heading/server/index.js'\nexport { HorizontalRuleFeature } from './features/horizontalRule/server/index.js'\n\nexport { IndentFeature } from './features/indent/server/index.js'\nexport {\n $createAutoLinkNode,\n $isAutoLinkNode,\n AutoLinkNode,\n} from './features/link/nodes/AutoLinkNode.js'\nexport { $createLinkNode, $isLinkNode, LinkNode } from './features/link/nodes/LinkNode.js'\n\nexport type { LinkFields } from './features/link/nodes/types.js'\nexport { LinkFeature, type LinkFeatureServerProps } from './features/link/server/index.js'\n\nexport { ChecklistFeature } from './features/lists/checklist/server/index.js'\nexport { OrderedListFeature } from './features/lists/orderedList/server/index.js'\n\nexport { UnorderedListFeature } from './features/lists/unorderedList/server/index.js'\nexport type {\n SlateNode,\n SlateNodeConverter,\n} from './features/migrations/slateToLexical/converter/types.js'\nexport { ParagraphFeature } from './features/paragraph/server/index.js'\n\nexport {\n RelationshipFeature,\n type RelationshipFeatureProps,\n} from './features/relationship/server/index.js'\n\nexport {\n type RelationshipData,\n RelationshipServerNode,\n} from './features/relationship/server/nodes/RelationshipNode.js'\nexport { defaultColors } from './features/textState/defaultColors.js'\nexport { TextStateFeature } from './features/textState/feature.server.js'\n\nexport { FixedToolbarFeature } from './features/toolbars/fixed/server/index.js'\n\nexport { InlineToolbarFeature } from './features/toolbars/inline/server/index.js'\nexport type { ToolbarGroup, ToolbarGroupItem } from './features/toolbars/types.js'\nexport type {\n BaseClientFeatureProps,\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n PluginComponent,\n PluginComponentWithAnchor,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n} from './features/typesClient.js'\n\nexport type {\n AfterChangeNodeHook,\n AfterChangeNodeHookArgs,\n AfterReadNodeHook,\n AfterReadNodeHookArgs,\n BaseNodeHookArgs,\n BeforeChangeNodeHook,\n BeforeChangeNodeHookArgs,\n BeforeValidateNodeHook,\n BeforeValidateNodeHookArgs,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n NodeWithHooks,\n PopulationPromise,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './features/typesServer.js'\n\nexport { createNode } from './features/typeUtilities.js' // Only useful in feature.server.ts\n\nexport { UploadFeature } from './features/upload/server/index.js'\nexport type { UploadFeatureProps } from './features/upload/server/index.js'\n\nexport { type UploadData, UploadServerNode } from './features/upload/server/nodes/UploadNode.js'\nexport type { EditorConfigContextType } from './lexical/config/client/EditorConfigProvider.js'\n\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n} from './lexical/config/server/default.js'\nexport { loadFeatures, sortFeaturesForOptimalLoading } from './lexical/config/server/loader.js'\n\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './lexical/config/types.js'\nexport type { AdapterProps }\n\nexport { getEnabledNodes, getEnabledNodesFromServerNodes } from './lexical/nodes/index.js'\n\nexport type {\n SlashMenuGroup,\n SlashMenuItem,\n} from './lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NodeFormat,\n NON_BREAKING_SPACE,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './lexical/utils/nodeFormat.js'\n\nexport { sanitizeUrl, validateUrl } from './lexical/utils/url.js'\n\nexport type * from './nodeTypes.js'\n\nexport { $convertFromMarkdownString } from './packages/@lexical/markdown/index.js'\nexport { defaultRichTextValue } from './populateGraphQL/defaultValue.js'\nexport { populate } from './populateGraphQL/populate.js'\n\nexport type { LexicalEditorProps, LexicalFieldAdminProps, LexicalRichTextAdapter } from './types.js'\n\nexport { buildDefaultEditorState, buildEditorState } from './utilities/buildEditorState.js'\nexport { createServerFeature } from './utilities/createServerFeature.js'\n\nexport { editorConfigFactory } from './utilities/editorConfigFactory.js'\nexport type { FieldsDrawerProps } from './utilities/fieldsDrawer/Drawer.js'\n\nexport { extractPropsFromJSXPropsString } from './utilities/jsx/extractPropsFromJSXPropsString.js'\n\nexport {\n extractFrontmatter,\n frontmatterToObject,\n objectToFrontmatter,\n propsToJSXString,\n} from './utilities/jsx/jsx.js'\nexport { upgradeLexicalData } from './utilities/upgradeLexicalData/index.js'\n"],"names":["afterChangeTraverseFields","afterReadTraverseFields","beforeChangeTraverseFields","beforeValidateTraverseFields","checkDependencies","deepMergeSimple","withNullableJSONSchemaType","i18n","defaultEditorFeatures","populateLexicalPopulationPromises","featuresInputToEditorConfig","getGenerateImportMap","getGenerateSchemaMap","getDefaultSanitizedEditorConfig","recurseNodeTree","richTextValidateHOC","checkedDependencies","lexicalTargetVersion","lexicalEditor","args","process","env","NODE_ENV","PAYLOAD_DISABLE_DEPENDENCY_CHECKER","dependencyGroups","name","dependencies","targetVersion","config","isRoot","parentIsLocalized","features","resolvedFeatureMap","finalSanitizedEditorConfig","lexical","result","sanitizedConfig","featureI18n","_lang","lang","lexicalI18nForLang","general","translations","CellComponent","DiffComponent","editorConfig","FieldComponent","path","serverProps","admin","generateImportMap","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","size","editorPopulationPromises","hooks","afterChange","collection","_context","data","global","indexPath","operation","originalDoc","previousDoc","previousValue","schemaPath","value","length","hook","nodeHooks","getSubFields","nodeIDMap","previousNodeIDMap","originalNodeIDMap","internal","richText","join","Object","keys","nodes","root","children","id","node","entries","afterChangeHooks","afterChangeHooksForNode","get","type","console","warn","originalNode","parentRichTextFieldPath","parentRichTextFieldSchemaPath","previousNode","subFieldFn","subFieldDataFn","getSubFieldsData","subFields","nodeSiblingData","nodeSiblingDoc","nodePreviousSiblingDoc","blockData","doc","fields","parentIndexPath","localized","parentPath","parentSchemaPath","previousSiblingDoc","siblingData","afterRead","fallbackLocale","locale","populate","triggerAccessControl","triggerHooks","flattenedNodes","afterReadHooks","afterReadHooksForNode","populateArg","beforeChange","docWithLocales","errors","fieldLabelPath","mergeLocaleActions","siblingDocWithLocales","skipValidation","originalNodeWithLocalesIDMap","beforeChangeHooks","beforeChangeHooksForNode","originalNodeWithLocales","nodeSiblingDocWithLocales","newOriginalNodeIDMap","previousOriginalValue","beforeValidate","beforeValidateHooks","beforeValidateHooksForNode","outputSchema","collectionIDFieldTypes","interfaceNameDefinitions","isRequired","properties","additionalProperties","items","tsType","version","required","direction","oneOf","enum","format","indent","modifyOutputSchema","generatedTypes","modifyOutputSchemas","currentSchema","validate","AlignFeature","BlockquoteFeature","CodeBlock","BlocksFeature","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","convertHTMLToLexical","lexicalHTMLField","LinebreakHTMLConverter","ParagraphHTMLConverter","TabHTMLConverter","TextHTMLConverter","defaultHTMLConverters","convertLexicalNodesToHTML","convertLexicalToHTML","consolidateHTMLConverters","lexicalHTML","HTMLConverterFeature","convertLexicalToMarkdown","convertMarkdownToLexical","getPayloadPopulateFn","getRestPopulateFn","DebugJsxConverterFeature","TestRecorderFeature","TreeViewFeature","EXPERIMENTAL_TableFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$createLinkNode","$isLinkNode","LinkNode","LinkFeature","ChecklistFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","RelationshipServerNode","defaultColors","TextStateFeature","FixedToolbarFeature","InlineToolbarFeature","createNode","UploadFeature","UploadServerNode","defaultEditorConfig","defaultEditorLexicalConfig","loadFeatures","sortFeaturesForOptimalLoading","sanitizeServerEditorConfig","sanitizeServerFeatures","getEnabledNodes","getEnabledNodesFromServerNodes","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NodeFormat","NON_BREAKING_SPACE","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","sanitizeUrl","validateUrl","$convertFromMarkdownString","defaultRichTextValue","buildDefaultEditorState","buildEditorState","createServerFeature","editorConfigFactory","extractPropsFromJSXPropsString","extractFrontmatter","frontmatterToObject","objectToFrontmatter","propsToJSXString","upgradeLexicalData"],"mappings":"AAIA,SACEA,yBAAyB,EACzBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,iBAAiB,EACjBC,eAAe,EAEfC,0BAA0B,QACrB,UAAS;AAMhB,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,qBAAqB,QAAQ,qCAAoC;AAC1E,SAASC,iCAAiC,QAAQ,yDAAwD;AAC1G,SAASC,2BAA2B,QAAQ,qCAAoC;AAChF,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,oBAAoB,QAAQ,mCAAkC;AACvE,SAASC,+BAA+B,QAAQ,iDAAgD;AAChG,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,mBAAmB,QAAQ,sBAAqB;AAEzD,IAAIC,sBAAsB;AAE1B,OAAO,MAAMC,uBAAuB,SAAQ;AAE5C,OAAO,SAASC,cAAcC,IAAyB;IACrD,IACEC,QAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzBF,QAAQC,GAAG,CAACE,kCAAkC,KAAK,UACnD,CAACP,qBACD;QACAA,sBAAsB;QACtB,KAAKZ,kBAAkB;YACrBoB,kBAAkB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,SAASC,0BAA0B,QAAQ,wCAAuC;AAClF,SAASC,oBAAoB,QAAQ,oCAAmC;AACxE,SAAS/H,QAAQ,QAAQ,gCAA+B;AAIxD,SAASgI,uBAAuB,EAAEC,gBAAgB,QAAQ,kCAAiC;AAC3F,SAASC,mBAAmB,QAAQ,qCAAoC;AAExE,SAASC,mBAAmB,QAAQ,qCAAoC;AAGxE,SAASC,8BAA8B,QAAQ,oDAAmD;AAElG,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,QACX,yBAAwB;AAC/B,SAASC,kBAAkB,QAAQ,0CAAyC"}
|
|
@@ -10,6 +10,7 @@ import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
|
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { useEffect, useState } from 'react';
|
|
12
12
|
import { useEditorConfigContext } from './config/client/EditorConfigProvider.js';
|
|
13
|
+
import './LexicalEditor.scss';
|
|
13
14
|
import { EditorPlugin } from './EditorPlugin.js';
|
|
14
15
|
import { ClipboardPlugin } from './plugins/ClipboardPlugin/index.js';
|
|
15
16
|
import { DecoratorPlugin } from './plugins/DecoratorPlugin/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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 { ClipboardPlugin } from './plugins/ClipboardPlugin/index.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 {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n {isEditable && (\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 )}\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"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","Fragment","features","plugins","map","plugin","position","clientProps","key","div","className","ref","contentEditable","ErrorBoundary","ignoreSelectionChange","editorState","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","desktopOnly","markdownTransformers","length"],"mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,yCAAwC;AAC7E,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ,UAAS;AAC3E,YAAYC,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,sBAAsB,QAAQ,0CAAyC;AAEhF,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,0BAA0B,QAAQ,0CAAyC;AACpF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,UAAU,QAAQ,gCAA+B;AAC1D,SAASC,sBAAsB,QAAQ,0BAAyB;AAEhE,OAAO,MAAMC,gBAKT,CAACC;IACH,MAAM,EAAEC,YAAY,EAAEC,kBAAkB,EAAEC,oBAAoB,EAAEC,QAAQ,EAAE,GAAGJ;IAC7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BACC,MAACxB,MAAM0C,QAAQ;;0CACb,KAACjD;4BACAyB,cAAcyB,UAAUsB,sBAAsBC,SAAS,mBAAK,KAACxD;;;oBAGjEQ,aAAayB,QAAQ,CAACC,OAAO,EAAEC,IAAI,CAACC;wBACnC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;4BAChC,qBACE,KAAC3C;gCAAa4C,aAAaF,OAAOE,WAAW;gCAAmBF,QAAQA;+BAApBA,OAAOG,GAAG;wBAElE;oBACF;oBACC/B,aAAayB,QAAQ,CAACC,OAAO,EAAEC,IAAI,CAACC;wBACnC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;4BAChC,qBACE,KAAC3C;gCAAa4C,aAAaF,OAAOE,WAAW;gCAAmBF,QAAQA;+BAApBA,OAAOG,GAAG;wBAElE;oBACF;;;YAED/B,aAAayB,QAAQ,CAACC,OAAO,EAAEC,IAAI,CAACC;gBACnC,IAAIA,OAAOC,QAAQ,KAAK,kBAAkB;oBACxC,qBAAO,KAAC3C;wBAAa4C,aAAaF,OAAOE,WAAW;wBAAmBF,QAAQA;uBAApBA,OAAOG,GAAG;gBACvE;YACF;;;AAGN,EAAC"}
|
|
1
|
+
{"version":3,"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 { ClipboardPlugin } from './plugins/ClipboardPlugin/index.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 {isEditable && <InsertParagraphAtEndPlugin />}\n <DecoratorPlugin />\n <ClipboardPlugin />\n <TextPlugin features={editorConfig.features} />\n <SelectAllPlugin />\n {isEditable && (\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 )}\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"],"names":["useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","useLexicalEditable","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","ClipboardPlugin","DecoratorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","InsertParagraphAtEndPlugin","MarkdownShortcutPlugin","NormalizeSelectionPlugin","SelectAllPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","editorConfig","editorContainerRef","isSmallWidthViewport","onChange","editorConfigContext","editor","isEditable","floatingAnchorElem","setFloatingAnchorElem","onRef","_floatingAnchorElem","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","Fragment","features","plugins","map","plugin","position","clientProps","key","div","className","ref","contentEditable","ErrorBoundary","ignoreSelectionChange","editorState","tags","has","size","admin","hideDraggableBlockElement","anchorElem","hideAddBlockButton","desktopOnly","markdownTransformers","length"],"mappings":"AAAA;;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,QAAQ,yCAAwC;AAC7E,SAASC,aAAa,QAAQ,yCAAwC;AACtE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ,UAAS;AAC3E,YAAYC,WAAW,QAAO;AAC9B,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAI3C,SAASC,sBAAsB,QAAQ,0CAAyC;AAChF,OAAO,uBAAsB;AAC7B,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,oBAAoB,QAAQ,kDAAiD;AACtF,SAASC,0BAA0B,QAAQ,0CAAyC;AACpF,SAASC,sBAAsB,QAAQ,sCAAqC;AAC5E,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,UAAU,QAAQ,gCAA+B;AAC1D,SAASC,sBAAsB,QAAQ,0BAAyB;AAEhE,OAAO,MAAMC,gBAKT,CAACC;IACH,MAAM,EAAEC,YAAY,EAAEC,kBAAkB,EAAEC,oBAAoB,EAAEC,QAAQ,EAAE,GAAGJ;IAC7E,MAAMK,sBAAsBnB;IAC5B,MAAM,CA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AACjD;4BACAyB,cAAcyB,UAAUsB,sBAAsBC,SAAS,mBAAK,KAACxD;;;oBAGjEQ,aAAayB,QAAQ,CAACC,OAAO,EAAEC,IAAI,CAACC;wBACnC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;4BAChC,qBACE,KAAC3C;gCAAa4C,aAAaF,OAAOE,WAAW;gCAAmBF,QAAQA;+BAApBA,OAAOG,GAAG;wBAElE;oBACF;oBACC/B,aAAayB,QAAQ,CAACC,OAAO,EAAEC,IAAI,CAACC;wBACnC,IAAIA,OAAOC,QAAQ,KAAK,UAAU;4BAChC,qBACE,KAAC3C;gCAAa4C,aAAaF,OAAOE,WAAW;gCAAmBF,QAAQA;+BAApBA,OAAOG,GAAG;wBAElE;oBACF;;;YAED/B,aAAayB,QAAQ,CAACC,OAAO,EAAEC,IAAI,CAACC;gBACnC,IAAIA,OAAOC,QAAQ,KAAK,kBAAkB;oBACxC,qBAAO,KAAC3C;wBAAa4C,aAAaF,OAAOE,WAAW;wBAAmBF,QAAQA;uBAApBA,OAAOG,GAAG;gBACvE;YACF;;;AAGN,EAAC"}
|
|
@@ -3,6 +3,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
|
|
|
3
3
|
import { $findMatchingParent, mergeRegister } from '@lexical/utils';
|
|
4
4
|
import { $createNodeSelection, $getEditor, $getNearestNodeFromDOMNode, $getSelection, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, $setSelection, CLICK_COMMAND, COMMAND_PRIORITY_LOW, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, SELECTION_CHANGE_COMMAND } from 'lexical';
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
|
+
import './index.scss';
|
|
6
7
|
// TODO: This should ideally be fixed in Lexical. See
|
|
7
8
|
// https://github.com/facebook/lexical/pull/7072
|
|
8
9
|
export function DecoratorPlugin() {
|