@payloadcms/richtext-lexical 3.65.0-canary.7 → 3.65.0-internal.5b33fe0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-CFLUGR3C.js +2 -0
- package/dist/exports/client/Field-CFLUGR3C.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-6NIGQP6A.js +12 -0
- package/dist/exports/client/chunk-6NIGQP6A.js.map +7 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +20 -20
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/index.d.ts +1 -1
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +1 -9
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +4 -2
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +76 -4
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +10 -5
- package/dist/field/Field.js.map +1 -1
- package/dist/field/RichTextViewProvider.d.ts +83 -0
- package/dist/field/RichTextViewProvider.d.ts.map +1 -0
- package/dist/field/RichTextViewProvider.js +87 -0
- package/dist/field/RichTextViewProvider.js.map +1 -0
- package/dist/field/ViewSelector.d.ts +4 -0
- package/dist/field/ViewSelector.d.ts.map +1 -0
- package/dist/field/ViewSelector.js +89 -0
- package/dist/field/ViewSelector.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +1 -0
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +47 -29
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +12 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +12 -3
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +3 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +4 -0
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +12 -2
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +195 -2
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +48 -0
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
- package/dist/types.d.ts +136 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -0
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +6 -1
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +10 -4
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-QUXIGJRC.js +0 -2
- package/dist/exports/client/Field-QUXIGJRC.js.map +0 -7
- package/dist/exports/client/chunk-AFXLIYGL.js +0 -12
- package/dist/exports/client/chunk-AFXLIYGL.js.map +0 -7
|
@@ -12,5 +12,5 @@ export { TextJSXConverter } from '../../features/converters/lexicalToJSX/convert
|
|
|
12
12
|
export { UploadJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/upload.js';
|
|
13
13
|
export { defaultJSXConverters } from '../../features/converters/lexicalToJSX/converter/defaultConverters.js';
|
|
14
14
|
export { convertLexicalNodesToJSX } from '../../features/converters/lexicalToJSX/converter/index.js';
|
|
15
|
-
export type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent, } from '../../features/converters/lexicalToJSX/converter/types.js';
|
|
15
|
+
export type { JSXConverter, JSXConverterArgs, JSXConverters, SerializedLexicalNodeWithParent, } from '../../features/converters/lexicalToJSX/converter/types.js';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exports/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,QAAQ,GACT,MAAM,2DAA2D,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2EAA2E,CAAA;AAClH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wEAAwE,CAAA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,CAAA;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sEAAsE,CAAA;AAExG,OAAO,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAA;AAEtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uEAAuE,CAAA;AAC1G,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAA;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAA;AACpG,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,+BAA+B,GAChC,MAAM,2DAA2D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RichText","BlockquoteJSXConverter","HeadingJSXConverter","HorizontalRuleJSXConverter","LinebreakJSXConverter","LinkJSXConverter","ListJSXConverter","ParagraphJSXConverter","TabJSXConverter","TableJSXConverter","TextJSXConverter","UploadJSXConverter","defaultJSXConverters","convertLexicalNodesToJSX"],"sources":["../../../src/exports/react/index.ts"],"sourcesContent":["export {\n type JSXConvertersFunction,\n RichText,\n} from '../../features/converters/lexicalToJSX/Component/index.js'\nexport { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js'\nexport { HeadingJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/heading.js'\nexport { HorizontalRuleJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/horizontalRule.js'\nexport { LinebreakJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/linebreak.js'\nexport { LinkJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/link.js'\nexport { ListJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/list.js'\nexport { ParagraphJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/paragraph.js'\nexport { TabJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/tab.js'\nexport { TableJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/table.js'\n\nexport { TextJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/text.js'\n\nexport { UploadJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/upload.js'\nexport { defaultJSXConverters } from '../../features/converters/lexicalToJSX/converter/defaultConverters.js'\nexport { convertLexicalNodesToJSX } from '../../features/converters/lexicalToJSX/converter/index.js'\nexport type {\n JSXConverter,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} from '../../features/converters/lexicalToJSX/converter/types.js'\n"],"mappings":"AAAA,SAEEA,QAAQ,QACH;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,eAAe,QAAQ;AAChC,SAASC,iBAAiB,QAAQ;AAElC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,wBAAwB,QAAQ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["RichText","BlockquoteJSXConverter","HeadingJSXConverter","HorizontalRuleJSXConverter","LinebreakJSXConverter","LinkJSXConverter","ListJSXConverter","ParagraphJSXConverter","TabJSXConverter","TableJSXConverter","TextJSXConverter","UploadJSXConverter","defaultJSXConverters","convertLexicalNodesToJSX"],"sources":["../../../src/exports/react/index.ts"],"sourcesContent":["export {\n type JSXConvertersFunction,\n RichText,\n} from '../../features/converters/lexicalToJSX/Component/index.js'\nexport { BlockquoteJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/blockquote.js'\nexport { HeadingJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/heading.js'\nexport { HorizontalRuleJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/horizontalRule.js'\nexport { LinebreakJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/linebreak.js'\nexport { LinkJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/link.js'\nexport { ListJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/list.js'\nexport { ParagraphJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/paragraph.js'\nexport { TabJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/tab.js'\nexport { TableJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/table.js'\n\nexport { TextJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/text.js'\n\nexport { UploadJSXConverter } from '../../features/converters/lexicalToJSX/converter/converters/upload.js'\nexport { defaultJSXConverters } from '../../features/converters/lexicalToJSX/converter/defaultConverters.js'\nexport { convertLexicalNodesToJSX } from '../../features/converters/lexicalToJSX/converter/index.js'\nexport type {\n JSXConverter,\n JSXConverterArgs,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} from '../../features/converters/lexicalToJSX/converter/types.js'\n"],"mappings":"AAAA,SAEEA,QAAQ,QACH;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,eAAe,QAAQ;AAChC,SAASC,iBAAiB,QAAQ;AAElC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,wBAAwB,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAGnE,OAAO,cAAc,CAAA;AAMrB,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAGnE,OAAO,cAAc,CAAA;AAMrB,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA4jB1C,CAAA"}
|
|
@@ -75,19 +75,11 @@ export const BlockComponent = props => {
|
|
|
75
75
|
}
|
|
76
76
|
// Merge current formData values into the cached form state
|
|
77
77
|
// This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits
|
|
78
|
-
|
|
78
|
+
return Object.fromEntries(Object.entries(cachedFormState).map(([fieldName, fieldState]) => [fieldName, fieldName in formData ? {
|
|
79
79
|
...fieldState,
|
|
80
80
|
initialValue: formData[fieldName],
|
|
81
81
|
value: formData[fieldName]
|
|
82
82
|
} : fieldState]));
|
|
83
|
-
// Manually add blockName, as it's not part of cachedFormState
|
|
84
|
-
mergedState.blockName = {
|
|
85
|
-
initialValue: formData.blockName,
|
|
86
|
-
passesCondition: true,
|
|
87
|
-
valid: true,
|
|
88
|
-
value: formData.blockName
|
|
89
|
-
};
|
|
90
|
-
return mergedState;
|
|
91
83
|
});
|
|
92
84
|
const hasMounted = useRef(false);
|
|
93
85
|
const prevCacheBuster = useRef(cacheBuster);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","mergedState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","blockName","passesCondition","valid","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","undefined","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","children","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","filter","Boolean","join","collapsibleStyle","header","_jsxs","pillStyle","admin","path","count","withMessage","_Fragment","onToggle","incomingCollapsedState","blockID","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { type BlockCollapsibleWithErrorProps, BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, className: baseClass, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n const mergedState = Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n\n // Manually add blockName, as it's not part of cachedFormState\n mergedState.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return mergedState\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel ?? undefined,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block ?? undefined,\n )\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={`${baseClass}__container ${baseClass}-${blockType}`}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof CustomLabel !== 'undefined' ? (\n CustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div className={`${baseClass}__block-actions`}>\n {typeof Actions !== 'undefined' ? (\n Actions\n ) : (\n <>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && isEditable ? <RemoveButton /> : null}\n </>\n )}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n ],\n )\n\n const blockID = formData?.id\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n blockType,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\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EAAcA;;;EAItB,GAAG,CACDC,gBAAA,EACAyB,WAAA,EACAvG,WAAA,EACA3B,SAAA,EACAwG,YAAA,EACAf,UAAA,EACAxH,SAAA,EACA6B,MAAA,EACAV,UAAA,EACAO,YAAA,EACA2D,WAAA,EAAavE,MAAA;EACb;EACAoB,YAAA,EACAhC,OAAA,EACAyF,QAAA,EACAxF,SAAA,CACD;EAED,IAAI,CAACkF,WAAA,EAAa;IAChB,oBACEoC,IAAA,CAACe,gBAAA;MAAiBI,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAS,KAAA,CAAC;QAAIxJ,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzB+B,SAAA,EAAU;;;EAIjC;EAEA,OAAO6B,KAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","undefined","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","blockName","passesCondition","valid","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","children","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","filter","Boolean","join","collapsibleStyle","header","_jsxs","pillStyle","admin","path","count","withMessage","_Fragment","onToggle","incomingCollapsedState","blockID","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { type BlockCollapsibleWithErrorProps, BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly className: string\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, className: baseClass, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel ?? undefined,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block ?? undefined,\n )\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={`${baseClass}__container ${baseClass}-${blockType}`}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof CustomLabel !== 'undefined' ? (\n CustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div className={`${baseClass}__block-actions`}>\n {typeof Actions !== 'undefined' ? (\n Actions\n ) : (\n <>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && isEditable ? <RemoveButton /> : null}\n </>\n )}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n ],\n )\n\n const blockID = formData?.id\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields ?? []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n blockType,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAO9B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC/D,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAA8CC,YAAY,QAAQ;AAClE,SAASC,sBAAsB,QAAQ;AAcvC,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,WAAW;IAAEC,SAAA,EAAWC,SAAS;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGL,KAAA;EACjE,MAAMM,SAAA,GAAY1B,gBAAA;EAClB,MAAM;IAAE2B,EAAE;IAAEC,cAAc;IAAEC;EAAU,CAAE,GAAG/B,eAAA;EAC3C,MAAM;IACJgC,UAAA,EAAY;MACVC,sBAAsB;MACtBC,KAAA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ToI,YAAA,EAAcA;;;EAItB,GAAG,CACDC,gBAAA,EACAyB,WAAA,EACA1G,WAAA,EACAvB,SAAA,EACAuG,YAAA,EACAf,UAAA,EACAvH,SAAA,EACA6B,MAAA,EACAV,UAAA,EACAO,YAAA,EACA0D,WAAA,EAAatE,MAAA;EACb;EACAoB,YAAA,EACAhC,OAAA,EACAwF,QAAA,EACAvF,SAAA,CACD;EAED,IAAI,CAACiF,WAAA,EAAa;IAChB,oBACEoC,IAAA,CAACe,gBAAA;MAAiBI,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAS,KAAA,CAAC;QAAIvJ,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzB+B,SAAA,EAAU;;;EAIjC;EAEA,OAAOyB,KAAA;AACT","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { SerializedEditorState } from 'lexical';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js';
|
|
4
3
|
import type { JSXConverters } from '../converter/types.js';
|
|
4
|
+
import { type ConvertLexicalToJSXArgs } from '../converter/index.js';
|
|
5
5
|
export type JSXConvertersFunction<T extends {
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
type?: string;
|
|
@@ -21,23 +21,11 @@ type RichTextProps = {
|
|
|
21
21
|
* Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.
|
|
22
22
|
*/
|
|
23
23
|
converters?: JSXConverters | JSXConvertersFunction;
|
|
24
|
-
/**
|
|
25
|
-
* Serialized editor state to render.
|
|
26
|
-
*/
|
|
27
|
-
data: SerializedEditorState;
|
|
28
24
|
/**
|
|
29
25
|
* If true, removes the container div wrapper.
|
|
30
26
|
*/
|
|
31
27
|
disableContainer?: boolean;
|
|
32
|
-
|
|
33
|
-
* If true, disables indentation globally. If an array, disables for specific node `type` values.
|
|
34
|
-
*/
|
|
35
|
-
disableIndent?: boolean | string[];
|
|
36
|
-
/**
|
|
37
|
-
* If true, disables text alignment globally. If an array, disables for specific node `type` values.
|
|
38
|
-
*/
|
|
39
|
-
disableTextAlign?: boolean | string[];
|
|
40
|
-
};
|
|
28
|
+
} & Pick<ConvertLexicalToJSXArgs, 'data' | 'disableIndent' | 'disableTextAlign' | 'nodeMap'>;
|
|
41
29
|
export declare const RichText: React.FC<RichTextProps>;
|
|
42
30
|
export {};
|
|
43
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAAuB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEzF,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC,GAClD,yBAAyB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC,IAC1D,CAAC,IAAI,EAAE;IAAE,iBAAiB,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAA;CAAE,KAAK,aAAa,CAAC,CAAC,CAAC,CAAA;AAEtF,KAAK,aAAa,GAAG;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,GAAG,qBAAqB,CAAA;IAElD;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAC,CAAA;AAE5F,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0C5C,CAAA"}
|
|
@@ -8,7 +8,8 @@ export const RichText = ({
|
|
|
8
8
|
data: editorState,
|
|
9
9
|
disableContainer,
|
|
10
10
|
disableIndent,
|
|
11
|
-
disableTextAlign
|
|
11
|
+
disableTextAlign,
|
|
12
|
+
nodeMap
|
|
12
13
|
}) => {
|
|
13
14
|
if (!editorState) {
|
|
14
15
|
return null;
|
|
@@ -29,7 +30,8 @@ export const RichText = ({
|
|
|
29
30
|
converters: finalConverters,
|
|
30
31
|
data: editorState,
|
|
31
32
|
disableIndent,
|
|
32
|
-
disableTextAlign
|
|
33
|
+
disableTextAlign,
|
|
34
|
+
nodeMap
|
|
33
35
|
});
|
|
34
36
|
if (disableContainer) {
|
|
35
37
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","finalConverters","defaultConverters","content","Array","isArray","_jsx","_Fragment"],"sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","nodeMap","finalConverters","defaultConverters","content","Array","isArray","_jsx","_Fragment"],"sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"sourcesContent":["import React from 'react'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\nimport type { JSXConverters } from '../converter/types.js'\n\nimport { defaultJSXConverters } from '../converter/defaultConverters.js'\nimport { convertLexicalToJSX, type ConvertLexicalToJSXArgs } from '../converter/index.js'\n\nexport type JSXConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string }>\n | SerializedInlineBlockNode<{ blockName?: null | string }>,\n> = (args: { defaultConverters: JSXConverters<DefaultNodeTypes> }) => JSXConverters<T>\n\ntype RichTextProps = {\n /**\n * Override class names for the container.\n */\n className?: string\n /**\n * Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.\n */\n converters?: JSXConverters | JSXConvertersFunction\n\n /**\n * If true, removes the container div wrapper.\n */\n disableContainer?: boolean\n} & Pick<ConvertLexicalToJSXArgs, 'data' | 'disableIndent' | 'disableTextAlign' | 'nodeMap'>\n\nexport const RichText: React.FC<RichTextProps> = ({\n className,\n converters,\n data: editorState,\n disableContainer,\n disableIndent,\n disableTextAlign,\n nodeMap,\n}) => {\n if (!editorState) {\n return null\n }\n\n let finalConverters: JSXConverters = {}\n if (converters) {\n if (typeof converters === 'function') {\n finalConverters = converters({ defaultConverters: defaultJSXConverters })\n } else {\n finalConverters = converters\n }\n } else {\n finalConverters = defaultJSXConverters\n }\n\n const content =\n editorState &&\n !Array.isArray(editorState) &&\n typeof editorState === 'object' &&\n 'root' in editorState &&\n convertLexicalToJSX({\n converters: finalConverters,\n data: editorState,\n disableIndent,\n disableTextAlign,\n nodeMap,\n })\n\n if (disableContainer) {\n return <>{content}</>\n }\n\n return <div className={className ?? 'payload-richtext'}>{content}</div>\n}\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AASlB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,mBAAmB,QAAsC;AAyBlE,OAAO,MAAMC,QAAA,GAAoCA,CAAC;EAChDC,SAAS;EACTC,UAAU;EACVC,IAAA,EAAMC,WAAW;EACjBC,gBAAgB;EAChBC,aAAa;EACbC,gBAAgB;EAChBC;AAAO,CACR;EACC,IAAI,CAACJ,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAIK,eAAA,GAAiC,CAAC;EACtC,IAAIP,UAAA,EAAY;IACd,IAAI,OAAOA,UAAA,KAAe,YAAY;MACpCO,eAAA,GAAkBP,UAAA,CAAW;QAAEQ,iBAAA,EAAmBZ;MAAqB;IACzE,OAAO;MACLW,eAAA,GAAkBP,UAAA;IACpB;EACF,OAAO;IACLO,eAAA,GAAkBX,oBAAA;EACpB;EAEA,MAAMa,OAAA,GACJP,WAAA,IACA,CAACQ,KAAA,CAAMC,OAAO,CAACT,WAAA,KACf,OAAOA,WAAA,KAAgB,YACvB,UAAUA,WAAA,IACVL,mBAAA,CAAoB;IAClBG,UAAA,EAAYO,eAAA;IACZN,IAAA,EAAMC,WAAA;IACNE,aAAA;IACAC,gBAAA;IACAC;EACF;EAEF,IAAIH,gBAAA,EAAkB;IACpB,oBAAOS,IAAA,CAAAC,SAAA;gBAAGJ;;EACZ;EAEA,oBAAOG,IAAA,CAAC;IAAIb,SAAA,EAAWA,SAAA,IAAa;cAAqBU;;AAC3D","ignoreList":[]}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { LexicalEditorNodeMap } from '../../../../types.js';
|
|
3
4
|
import type { JSXConverters, SerializedLexicalNodeWithParent } from './types.js';
|
|
4
5
|
export type ConvertLexicalToJSXArgs = {
|
|
5
6
|
converters: JSXConverters;
|
|
7
|
+
/**
|
|
8
|
+
* Serialized editor state to render.
|
|
9
|
+
*/
|
|
6
10
|
data: SerializedEditorState;
|
|
11
|
+
/**
|
|
12
|
+
* If true, disables indentation globally. If an array, disables for specific node `type` values.
|
|
13
|
+
*/
|
|
7
14
|
disableIndent?: boolean | string[];
|
|
15
|
+
/**
|
|
16
|
+
* If true, disables text alignment globally. If an array, disables for specific node `type` values.
|
|
17
|
+
*/
|
|
8
18
|
disableTextAlign?: boolean | string[];
|
|
19
|
+
/**
|
|
20
|
+
* You can use the lexical editor node map or view map as converters. NodeMap converters will override converters passed
|
|
21
|
+
* in the `converters` prop. If a LexicalEditorViewMap is provided, the `default` view will be used.
|
|
22
|
+
*/
|
|
23
|
+
nodeMap?: LexicalEditorNodeMap;
|
|
9
24
|
};
|
|
10
|
-
export declare function convertLexicalToJSX({ converters, data, disableIndent, disableTextAlign, }: ConvertLexicalToJSXArgs): React.ReactNode;
|
|
25
|
+
export declare function convertLexicalToJSX({ converters, data, disableIndent, disableTextAlign, nodeMap, }: ConvertLexicalToJSXArgs): React.ReactNode;
|
|
11
26
|
export declare function convertLexicalNodesToJSX({ converters, disableIndent, disableTextAlign, nodes, parent, }: {
|
|
12
27
|
converters: JSXConverters;
|
|
13
28
|
disableIndent?: boolean | string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAgB,aAAa,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,sBAAsB,CAAA;AAC9E,OAAO,KAAK,EAAgB,aAAa,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AA8E9F,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,IAAI,EAAE,qBAAqB,CAAA;IAC3B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,oBAAoB,CAAA;CAC/B,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,OAAO,GACR,EAAE,uBAAuB,GAAG,KAAK,CAAC,SAAS,CAoB3C;AAED,wBAAgB,wBAAwB,CAAC,EACvC,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,MAAM,GACP,EAAE;IACD,UAAU,EAAE,aAAa,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IACrC,KAAK,EAAE,qBAAqB,EAAE,CAAA;IAC9B,MAAM,EAAE,+BAA+B,CAAA;CACxC,GAAG,KAAK,CAAC,SAAS,EAAE,CAmIpB"}
|
|
@@ -1,19 +1,91 @@
|
|
|
1
1
|
/* eslint-disable no-console */import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { hasText } from '../../../../validate/hasText.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a JSX converter from a NodeMapValue
|
|
6
|
+
*/
|
|
7
|
+
function createConverterFromNodeMapValue(viewDef) {
|
|
8
|
+
return args => {
|
|
9
|
+
const converterArgs = {
|
|
10
|
+
...args,
|
|
11
|
+
isEditor: false,
|
|
12
|
+
isJSXConverter: true
|
|
13
|
+
};
|
|
14
|
+
// If Component is provided, use it
|
|
15
|
+
if (viewDef.Component) {
|
|
16
|
+
return viewDef.Component(converterArgs);
|
|
17
|
+
}
|
|
18
|
+
// If html is provided (as a function or string), use it
|
|
19
|
+
// Note: Using span instead of div to avoid forcing block-level semantics
|
|
20
|
+
if (viewDef.html) {
|
|
21
|
+
const htmlContent = typeof viewDef.html === 'function' ? viewDef.html(converterArgs) : viewDef.html;
|
|
22
|
+
return /*#__PURE__*/_jsx("span", {
|
|
23
|
+
dangerouslySetInnerHTML: {
|
|
24
|
+
__html: htmlContent
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts a LexicalEditorNodeMap into JSXConverters
|
|
33
|
+
*/
|
|
34
|
+
function nodeMapToConverters(nodeMap) {
|
|
35
|
+
const converters = {};
|
|
36
|
+
for (const [nodeType, value] of Object.entries(nodeMap)) {
|
|
37
|
+
if (!value || typeof value !== 'object') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
// Handle special keys: blocks, inlineBlocks
|
|
41
|
+
if (nodeType === 'blocks') {
|
|
42
|
+
converters.blocks = {};
|
|
43
|
+
for (const [blockType, _viewDef] of Object.entries(value)) {
|
|
44
|
+
const viewDef = _viewDef;
|
|
45
|
+
if (viewDef.Component || viewDef.html) {
|
|
46
|
+
converters.blocks[blockType] = createConverterFromNodeMapValue(viewDef);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (nodeType === 'inlineBlocks') {
|
|
52
|
+
converters.inlineBlocks = {};
|
|
53
|
+
for (const [blockType, _viewDef] of Object.entries(value)) {
|
|
54
|
+
const viewDef = _viewDef;
|
|
55
|
+
if (viewDef.Component || viewDef.html) {
|
|
56
|
+
converters.inlineBlocks[blockType] = createConverterFromNodeMapValue(viewDef);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
// Handle regular node types
|
|
62
|
+
const viewDef = value;
|
|
63
|
+
if (viewDef.Component || viewDef.html) {
|
|
64
|
+
converters[nodeType] = createConverterFromNodeMapValue(viewDef);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return converters;
|
|
68
|
+
}
|
|
4
69
|
export function convertLexicalToJSX({
|
|
5
70
|
converters,
|
|
6
71
|
data,
|
|
7
72
|
disableIndent,
|
|
8
|
-
disableTextAlign
|
|
73
|
+
disableTextAlign,
|
|
74
|
+
nodeMap
|
|
9
75
|
}) {
|
|
10
76
|
if (hasText(data)) {
|
|
77
|
+
// Merge nodeMap converters with existing converters
|
|
78
|
+
// NodeMap converters override existing converters
|
|
79
|
+
const mergedConverters = nodeMap ? {
|
|
80
|
+
...converters,
|
|
81
|
+
...nodeMapToConverters(nodeMap)
|
|
82
|
+
} : converters;
|
|
11
83
|
return convertLexicalNodesToJSX({
|
|
12
|
-
converters,
|
|
84
|
+
converters: mergedConverters,
|
|
13
85
|
disableIndent,
|
|
14
86
|
disableTextAlign,
|
|
15
|
-
nodes: data
|
|
16
|
-
parent: data
|
|
87
|
+
nodes: data.root.children,
|
|
88
|
+
parent: data.root
|
|
17
89
|
});
|
|
18
90
|
}
|
|
19
91
|
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["jsx","_jsx","Fragment","_Fragment","React","hasText","convertLexicalToJSX","converters","data","disableIndent","disableTextAlign","convertLexicalNodesToJSX","nodes","root","children","parent","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","reactNode","converted","childIndex","nodesToJSX","args","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean"],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\nexport type ConvertLexicalToJSXArgs = {\n converters: JSXConverters\n data: SerializedEditorState\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n}\n\nexport function convertLexicalToJSX({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n}: ConvertLexicalToJSXArgs): React.ReactNode {\n if (hasText(data)) {\n return convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes: data?.root?.children,\n parent: data?.root,\n })\n }\n return <></>\n}\n\nexport function convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes,\n parent,\n}: {\n converters: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent: SerializedLexicalNodeWithParent\n}): React.ReactNode[] {\n const unknownConverter: JSXConverter<any> = converters.unknown as JSXConverter<any>\n\n const jsxArray: React.ReactNode[] = nodes.map((node, i) => {\n let converterForNode: JSXConverter<any> | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[(node as SerializedBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Blocks converter: found ${(node as SerializedBlockNode)?.fields?.blockType} block, but no converter is provided`,\n )\n }\n } else if (node.type === 'inlineBlock') {\n converterForNode =\n converters?.inlineBlocks?.[(node as SerializedInlineBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Inline Blocks converter: found ${(node as SerializedInlineBlockNode)?.fields?.blockType} inline block, but no converter is provided`,\n )\n }\n } else {\n converterForNode = converters[node.type] as JSXConverter<any>\n }\n\n try {\n if (!converterForNode && unknownConverter) {\n converterForNode = unknownConverter\n }\n\n let reactNode: React.ReactNode\n if (converterForNode) {\n const converted =\n typeof converterForNode === 'function'\n ? converterForNode({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n : converterForNode\n reactNode = converted\n } else {\n reactNode = <span key={i}>unknown node</span>\n }\n\n const style: React.CSSProperties = {}\n\n // Check if disableTextAlign is not true and does not include node type\n if (\n !disableTextAlign &&\n (!Array.isArray(disableTextAlign) || !disableTextAlign?.includes(node.type))\n ) {\n if ('format' in node && node.format) {\n switch (node.format) {\n case 'center':\n style.textAlign = 'center'\n break\n case 'end':\n style.textAlign = 'right'\n break\n case 'justify':\n style.textAlign = 'justify'\n break\n case 'left':\n //style.textAlign = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style.textAlign = 'right'\n break\n case 'start':\n style.textAlign = 'left'\n break\n }\n }\n }\n\n if (\n !disableIndent &&\n (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))\n ) {\n if ('indent' in node && node.indent && node.type !== 'listitem') {\n // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n style.paddingInlineStart = `${Number(node.indent) * 40}px`\n }\n }\n\n if (React.isValidElement(reactNode)) {\n // Inject style into reactNode\n if (style.textAlign || style.paddingInlineStart) {\n const newStyle = {\n ...style,\n // @ts-expect-error type better later\n ...(reactNode?.props?.style ?? {}),\n // reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here\n }\n\n return React.cloneElement(reactNode, {\n key: i,\n // @ts-expect-error type better later\n style: newStyle,\n })\n }\n return React.cloneElement(reactNode, {\n key: i,\n })\n }\n\n return reactNode\n } catch (error) {\n console.error('Error converting lexical node to JSX:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean)\n}\n"],"mappings":"AAAA,+BAA6B,SAAAA,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAG7B,OAAOC,KAAA,MAAW;AAKlB,SAASC,OAAO,QAAQ;AASxB,OAAO,SAASC,oBAAoB;EAClCC,UAAU;EACVC,IAAI;EACJC,aAAa;EACbC;AAAgB,CACQ;EACxB,IAAIL,OAAA,CAAQG,IAAA,GAAO;IACjB,OAAOG,wBAAA,CAAyB;MAC9BJ,UAAA;MACAE,aAAA;MACAC,gBAAA;MACAE,KAAA,EAAOJ,IAAA,EAAMK,IAAA,EAAMC,QAAA;MACnBC,MAAA,EAAQP,IAAA,EAAMK;IAChB;EACF;EACA,oBAAOZ,IAAA,CAAAE,SAAA;AACT;AAEA,OAAO,SAASQ,yBAAyB;EACvCJ,UAAU;EACVE,aAAa;EACbC,gBAAgB;EAChBE,KAAK;EACLG;AAAM,CAOP;EACC,MAAMC,gBAAA,GAAsCT,UAAA,CAAWU,OAAO;EAE9D,MAAMC,QAAA,GAA8BN,KAAA,CAAMO,GAAG,CAAC,CAACC,IAAA,EAAMC,CAAA;IACnD,IAAIC,gBAAA;IACJ,IAAIF,IAAA,CAAKG,IAAI,KAAK,SAAS;MACzBD,gBAAA,GAAmBf,UAAA,EAAYiB,MAAA,GAAUJ,IAAA,EAA8BK,MAAA,EAAQC,SAAA,CAAU;MACzF,IAAI,CAACJ,gBAAA,IAAoB,CAACN,gBAAA,EAAkB;QAC1CW,OAAA,CAAQC,KAAK,CACX,qDAAsDR,IAAA,EAA8BK,MAAA,EAAQC,SAAA,sCAA+C;MAE/I;IACF,OAAO,IAAIN,IAAA,CAAKG,IAAI,KAAK,eAAe;MACtCD,gBAAA,GACEf,UAAA,EAAYsB,YAAA,GAAgBT,IAAA,EAAoCK,MAAA,EAAQC,SAAA,CAAU;MACpF,IAAI,CAACJ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B,MAAM,CAACC,OAAA;AACzB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["jsx","_jsx","Fragment","_Fragment","React","hasText","createConverterFromNodeMapValue","viewDef","args","converterArgs","isEditor","isJSXConverter","Component","html","htmlContent","dangerouslySetInnerHTML","__html","nodeMapToConverters","nodeMap","converters","nodeType","value","Object","entries","blocks","blockType","_viewDef","inlineBlocks","convertLexicalToJSX","data","disableIndent","disableTextAlign","mergedConverters","convertLexicalNodesToJSX","nodes","root","children","parent","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","fields","console","error","reactNode","converted","childIndex","nodesToJSX","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean"],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type { LexicalEditorNodeMap, NodeMapValue } from '../../../../types.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\n/**\n * Creates a JSX converter from a NodeMapValue\n */\nfunction createConverterFromNodeMapValue(viewDef: NodeMapValue): JSXConverter {\n return (args) => {\n const converterArgs = {\n ...args,\n isEditor: false as const,\n isJSXConverter: true as const,\n }\n\n // If Component is provided, use it\n if (viewDef.Component) {\n return viewDef.Component(converterArgs)\n }\n\n // If html is provided (as a function or string), use it\n // Note: Using span instead of div to avoid forcing block-level semantics\n if (viewDef.html) {\n const htmlContent =\n typeof viewDef.html === 'function' ? viewDef.html(converterArgs) : viewDef.html\n\n return <span dangerouslySetInnerHTML={{ __html: htmlContent }} />\n }\n\n return null\n }\n}\n\n/**\n * Converts a LexicalEditorNodeMap into JSXConverters\n */\nfunction nodeMapToConverters(nodeMap: LexicalEditorNodeMap): JSXConverters {\n const converters: JSXConverters = {}\n\n for (const [nodeType, value] of Object.entries(nodeMap)) {\n if (!value || typeof value !== 'object') {\n continue\n }\n\n // Handle special keys: blocks, inlineBlocks\n if (nodeType === 'blocks') {\n converters.blocks = {}\n for (const [blockType, _viewDef] of Object.entries(value)) {\n const viewDef = _viewDef as NodeMapValue\n if (viewDef.Component || viewDef.html) {\n converters.blocks[blockType] = createConverterFromNodeMapValue(viewDef)\n }\n }\n continue\n }\n\n if (nodeType === 'inlineBlocks') {\n converters.inlineBlocks = {}\n for (const [blockType, _viewDef] of Object.entries(value)) {\n const viewDef = _viewDef as NodeMapValue\n if (viewDef.Component || viewDef.html) {\n converters.inlineBlocks[blockType] = createConverterFromNodeMapValue(viewDef)\n }\n }\n continue\n }\n\n // Handle regular node types\n const viewDef = value as NodeMapValue\n\n if (viewDef.Component || viewDef.html) {\n converters[nodeType] = createConverterFromNodeMapValue(viewDef)\n }\n }\n\n return converters\n}\n\nexport type ConvertLexicalToJSXArgs = {\n converters: JSXConverters\n /**\n * Serialized editor state to render.\n */\n data: SerializedEditorState\n /**\n * If true, disables indentation globally. If an array, disables for specific node `type` values.\n */\n disableIndent?: boolean | string[]\n /**\n * If true, disables text alignment globally. If an array, disables for specific node `type` values.\n */\n disableTextAlign?: boolean | string[]\n /**\n * You can use the lexical editor node map or view map as converters. NodeMap converters will override converters passed\n * in the `converters` prop. If a LexicalEditorViewMap is provided, the `default` view will be used.\n */\n nodeMap?: LexicalEditorNodeMap\n}\n\nexport function convertLexicalToJSX({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n nodeMap,\n}: ConvertLexicalToJSXArgs): React.ReactNode {\n if (hasText(data)) {\n // Merge nodeMap converters with existing converters\n // NodeMap converters override existing converters\n const mergedConverters = nodeMap\n ? {\n ...converters,\n ...nodeMapToConverters(nodeMap),\n }\n : converters\n\n return convertLexicalNodesToJSX({\n converters: mergedConverters,\n disableIndent,\n disableTextAlign,\n nodes: data.root.children,\n parent: data.root,\n })\n }\n return <></>\n}\n\nexport function convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes,\n parent,\n}: {\n converters: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent: SerializedLexicalNodeWithParent\n}): React.ReactNode[] {\n const unknownConverter: JSXConverter<any> = converters.unknown as JSXConverter<any>\n\n const jsxArray: React.ReactNode[] = nodes.map((node, i) => {\n let converterForNode: JSXConverter<any> | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[(node as SerializedBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Blocks converter: found ${(node as SerializedBlockNode)?.fields?.blockType} block, but no converter is provided`,\n )\n }\n } else if (node.type === 'inlineBlock') {\n converterForNode =\n converters?.inlineBlocks?.[(node as SerializedInlineBlockNode)?.fields?.blockType]\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => JSX converter: Inline Blocks converter: found ${(node as SerializedInlineBlockNode)?.fields?.blockType} inline block, but no converter is provided`,\n )\n }\n } else {\n converterForNode = converters[node.type] as JSXConverter<any>\n }\n\n try {\n if (!converterForNode && unknownConverter) {\n converterForNode = unknownConverter\n }\n\n let reactNode: React.ReactNode\n if (converterForNode) {\n const converted =\n typeof converterForNode === 'function'\n ? converterForNode({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n : converterForNode\n reactNode = converted\n } else {\n reactNode = <span key={i}>unknown node</span>\n }\n\n const style: React.CSSProperties = {}\n\n // Check if disableTextAlign is not true and does not include node type\n if (\n !disableTextAlign &&\n (!Array.isArray(disableTextAlign) || !disableTextAlign?.includes(node.type))\n ) {\n if ('format' in node && node.format) {\n switch (node.format) {\n case 'center':\n style.textAlign = 'center'\n break\n case 'end':\n style.textAlign = 'right'\n break\n case 'justify':\n style.textAlign = 'justify'\n break\n case 'left':\n //style.textAlign = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style.textAlign = 'right'\n break\n case 'start':\n style.textAlign = 'left'\n break\n }\n }\n }\n\n if (\n !disableIndent &&\n (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))\n ) {\n if ('indent' in node && node.indent && node.type !== 'listitem') {\n // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n style.paddingInlineStart = `${Number(node.indent) * 40}px`\n }\n }\n\n if (React.isValidElement(reactNode)) {\n // Inject style into reactNode\n if (style.textAlign || style.paddingInlineStart) {\n const newStyle = {\n ...style,\n // @ts-expect-error type better later\n ...(reactNode?.props?.style ?? {}),\n // reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here\n }\n\n return React.cloneElement(reactNode, {\n key: i,\n // @ts-expect-error type better later\n style: newStyle,\n })\n }\n return React.cloneElement(reactNode, {\n key: i,\n })\n }\n\n return reactNode\n } catch (error) {\n console.error('Error converting lexical node to JSX:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean)\n}\n"],"mappings":"AAAA,+BAA6B,SAAAA,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAG7B,OAAOC,KAAA,MAAW;AAMlB,SAASC,OAAO,QAAQ;AAExB;;;AAGA,SAASC,gCAAgCC,OAAqB;EAC5D,OAAQC,IAAA;IACN,MAAMC,aAAA,GAAgB;MACpB,GAAGD,IAAI;MACPE,QAAA,EAAU;MACVC,cAAA,EAAgB;IAClB;IAEA;IACA,IAAIJ,OAAA,CAAQK,SAAS,EAAE;MACrB,OAAOL,OAAA,CAAQK,SAAS,CAACH,aAAA;IAC3B;IAEA;I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OD,KAAA,EAAO;MACdD,OAAA,CAAQC,KAAK,CAAC,yCAAyCA,KAAA,EAAO,SAASN,IAAA;MACvE,OAAO;IACT;EACF;EAEA,OAAOF,QAAA,CAAS2B,MAAM,CAACC,OAAA;AACzB","ignoreList":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js';
|
|
3
|
-
export type
|
|
3
|
+
export type JSXConverterArgs<TNode extends {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
type?: string;
|
|
6
|
-
} = SerializedLexicalNode> =
|
|
6
|
+
} = SerializedLexicalNode> = {
|
|
7
7
|
childIndex: number;
|
|
8
8
|
converters: JSXConverters;
|
|
9
|
-
node:
|
|
9
|
+
node: TNode;
|
|
10
10
|
nodesToJSX: (args: {
|
|
11
11
|
converters?: JSXConverters;
|
|
12
12
|
disableIndent?: boolean | string[];
|
|
@@ -15,8 +15,12 @@ export type JSXConverter<T extends {
|
|
|
15
15
|
parent?: SerializedLexicalNodeWithParent;
|
|
16
16
|
}) => React.ReactNode[];
|
|
17
17
|
parent: SerializedLexicalNodeWithParent;
|
|
18
|
-
}
|
|
19
|
-
export type
|
|
18
|
+
};
|
|
19
|
+
export type JSXConverter<TNode extends {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
type?: string;
|
|
22
|
+
} = SerializedLexicalNode> = ((args: JSXConverterArgs<TNode>) => React.ReactNode) | React.ReactNode;
|
|
23
|
+
export type JSXConverters<TNodes extends {
|
|
20
24
|
[key: string]: any;
|
|
21
25
|
type?: string;
|
|
22
26
|
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
@@ -30,27 +34,27 @@ export type JSXConverters<T extends {
|
|
|
30
34
|
[blockSlug: string]: JSXConverter<any>;
|
|
31
35
|
} | JSXConverter<any> | undefined;
|
|
32
36
|
} & {
|
|
33
|
-
[nodeType in Exclude<NonNullable<
|
|
37
|
+
[nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: JSXConverter<Extract<TNodes, {
|
|
34
38
|
type: nodeType;
|
|
35
39
|
}>>;
|
|
36
40
|
} & {
|
|
37
41
|
blocks?: {
|
|
38
|
-
[K in Extract<Extract<
|
|
42
|
+
[K in Extract<Extract<TNodes, {
|
|
39
43
|
type: 'block';
|
|
40
44
|
}> extends SerializedBlockNode<infer B> ? B extends {
|
|
41
45
|
blockType: string;
|
|
42
|
-
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<
|
|
46
|
+
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<TNodes, {
|
|
43
47
|
type: 'block';
|
|
44
48
|
}> extends SerializedBlockNode<infer B> ? SerializedBlockNode<Extract<B, {
|
|
45
49
|
blockType: K;
|
|
46
50
|
}>> : SerializedBlockNode>;
|
|
47
51
|
};
|
|
48
52
|
inlineBlocks?: {
|
|
49
|
-
[K in Extract<Extract<
|
|
53
|
+
[K in Extract<Extract<TNodes, {
|
|
50
54
|
type: 'inlineBlock';
|
|
51
55
|
}> extends SerializedInlineBlockNode<infer B> ? B extends {
|
|
52
56
|
blockType: string;
|
|
53
|
-
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<
|
|
57
|
+
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<TNodes, {
|
|
54
58
|
type: 'inlineBlock';
|
|
55
59
|
}> extends SerializedInlineBlockNode<infer B> ? SerializedInlineBlockNode<Extract<B, {
|
|
56
60
|
blockType: K;
|