@payloadcms/richtext-lexical 3.71.0-internal.cbf546e → 3.71.0-internal.ef75fa0
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-2A2VQXKP.js +2 -0
- package/dist/exports/client/Field-2A2VQXKP.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-AFXLIYGL.js +12 -0
- package/dist/exports/client/chunk-AFXLIYGL.js.map +7 -0
- package/dist/exports/client/index.d.ts +0 -1
- 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/converters/lexicalToJSX/Component/index.d.ts +14 -2
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +2 -4
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +1 -16
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +4 -76
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +10 -14
- 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 +6 -11
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +0 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +29 -47
- 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 +0 -12
- 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 +1 -3
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +1 -2
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +3 -12
- 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 +2 -3
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +0 -4
- 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 +2 -12
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +2 -195
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/types.d.ts +2 -152
- 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 +0 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +1 -6
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +4 -10
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +6 -11
- package/dist/exports/client/Field-YM44WOON.js +0 -2
- package/dist/exports/client/Field-YM44WOON.js.map +0 -7
- package/dist/exports/client/chunk-6NIGQP6A.js +0 -12
- package/dist/exports/client/chunk-6NIGQP6A.js.map +0 -7
- package/dist/exports/client/internal-client.d.ts +0 -3
- package/dist/exports/client/internal-client.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.d.ts +0 -83
- package/dist/field/RichTextViewProvider.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.js +0 -87
- package/dist/field/RichTextViewProvider.js.map +0 -1
- package/dist/field/ViewSelector.d.ts +0 -4
- package/dist/field/ViewSelector.d.ts.map +0 -1
- package/dist/field/ViewSelector.js +0 -89
- package/dist/field/ViewSelector.js.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +0 -2
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +0 -48
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.js","names":["deepMerge","sanitizeClientFeatures","features","sanitized","enabledFeatures","enabledFormats","markdownTransformers","nodes","plugins","providers","slashMenu","dynamicGroups","groups","toolbarFixed","toolbarInline","customGroups","forEach","feature","key","sanitizedClientFeatureProps","size","length","concat","enableFormats","push","node","plugin","i","clientProps","Component","position","group","foundGroup","find","sanitizedGroup","items","filter","optionGroup","transformer","allNodes","allTransformers","Object","keys","map","customConfig","sort","a","b","order","sanitizeClientEditorConfig","resolvedClientFeatureMap","lexical","admin","view","resolvedFeatureMap"],"sources":["../../../../src/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport { deepMerge } from 'payload/shared'\n\nimport type { ToolbarGroup } from '../../../features/toolbars/types.js'\nimport type {\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n} from '../../../features/typesClient.js'\nimport type { LexicalFieldAdminClientProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n enabledFormats: [],\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n providers: [],\n slashMenu: {\n dynamicGroups: [],\n groups: [],\n },\n toolbarFixed: {\n groups: [],\n },\n toolbarInline: {\n groups: [],\n },\n }\n\n // Allow customization of groups for toolbarFixed\n let customGroups: Record<string, Partial<ToolbarGroup>> = {}\n features.forEach((feature) => {\n if (feature.key === 'toolbarFixed' && feature.sanitizedClientFeatureProps?.customGroups) {\n customGroups = {\n ...customGroups,\n ...feature.sanitizedClientFeatureProps.customGroups,\n }\n }\n })\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.providers?.length) {\n sanitized.providers = sanitized.providers.concat(feature.providers)\n }\n\n if (feature.enableFormats?.length) {\n sanitized.enabledFormats.push(...feature.enableFormats)\n }\n\n if (feature.nodes?.length) {\n // Important: do not use concat\n for (const node of feature.nodes) {\n sanitized.nodes.push(node)\n }\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins?.push({\n clientProps: feature.sanitizedClientFeatureProps,\n Component: plugin.Component as any, // Appeases strict: true\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.toolbarInline?.groups?.length) {\n for (const group of feature.toolbarInline.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarInline.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarInline.groups = sanitized.toolbarInline.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarInline?.groups.push(foundGroup)\n }\n }\n\n if (feature.toolbarFixed?.groups?.length) {\n for (const group of feature.toolbarFixed.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarFixed.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarFixed.groups = sanitized.toolbarFixed.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarFixed?.groups.push(foundGroup)\n }\n }\n\n if (feature.slashMenu?.groups) {\n if (feature.slashMenu.dynamicGroups?.length) {\n sanitized.slashMenu.dynamicGroups = sanitized.slashMenu.dynamicGroups.concat(\n feature.slashMenu.dynamicGroups,\n )\n }\n\n for (const optionGroup of feature.slashMenu.groups) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groups.find((group) => group.key === optionGroup.key)\n if (!group) {\n group = {\n ...optionGroup,\n items: [],\n }\n } else {\n sanitized.slashMenu.groups = sanitized.slashMenu.groups.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.items?.length) {\n group.items = group.items.concat(optionGroup.items)\n }\n sanitized.slashMenu.groups.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n // Important: do not use concat\n for (const transformer of feature.markdownTransformers) {\n if (typeof transformer === 'function') {\n sanitized.markdownTransformers.push(\n transformer({\n allNodes: sanitized.nodes,\n allTransformers: sanitized.markdownTransformers,\n }),\n )\n } else {\n sanitized.markdownTransformers.push(transformer)\n }\n }\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Apply custom group configurations to toolbarFixed groups\n if (Object.keys(customGroups).length > 0) {\n sanitized.toolbarFixed.groups = sanitized.toolbarFixed.groups.map((group) => {\n const customConfig = customGroups[group.key]\n if (customConfig) {\n return deepMerge(group, customConfig)\n }\n return group\n })\n }\n\n // Sort sanitized.toolbarInline.groups by order property\n sanitized.toolbarInline.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n // Sort sanitized.toolbarFixed.groups by order property\n sanitized.toolbarFixed.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.toolbarInline.groups.[group].entries by order property\n for (const group of sanitized.toolbarInline.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n // Sort sanitized.toolbarFixed.groups.[group].entries by order property\n for (const group of sanitized.toolbarFixed.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n lexical?: LexicalEditorConfig,\n admin?: LexicalFieldAdminClientProps,\n view?: string,\n): SanitizedClientEditorConfig {\n return {\n admin,\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical: lexical!,\n resolvedFeatureMap: resolvedClientFeatureMap,\n view,\n }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,SAAS,QAAQ;AAU1B,OAAO,MAAMC,sBAAA,GACXC,QAAA;EAEA,MAAMC,SAAA,GAAqC;IACzCC,eAAA,EAAiB,EAAE;IACnBC,cAAA,EAAgB,EAAE;IAClBC,oBAAA,EAAsB,EAAE;IACxBC,KAAA,EAAO,EAAE;IACTC,OAAA,EAAS,EAAE;IACXC,SAAA,EAAW,EAAE;IACbC,SAAA,EAAW;MACTC,aAAA,EAAe,EAAE;MACjBC,MAAA,EAAQ;IACV;IACAC,YAAA,EAAc;MACZD,MAAA,EAAQ;IACV;IACAE,aAAA,EAA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AAEA,OAAO,SAAS8C,2BACdC,wBAAkD,EAClDC,OAA6B,EAC7BC,KAAoC,EACpCC,IAAa;EAEb,OAAO;IACLD,KAAA;IACAlD,QAAA,EAAUD,sBAAA,CAAuBiD,wBAAA;IACjCC,OAAA,EAASA,OAAA;IACTG,kBAAA,EAAoBJ,wBAAA;IACpBG;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"sanitize.js","names":["deepMerge","sanitizeClientFeatures","features","sanitized","enabledFeatures","enabledFormats","markdownTransformers","nodes","plugins","providers","slashMenu","dynamicGroups","groups","toolbarFixed","toolbarInline","customGroups","forEach","feature","key","sanitizedClientFeatureProps","size","length","concat","enableFormats","push","node","plugin","i","clientProps","Component","position","group","foundGroup","find","sanitizedGroup","items","filter","optionGroup","transformer","allNodes","allTransformers","Object","keys","map","customConfig","sort","a","b","order","sanitizeClientEditorConfig","resolvedClientFeatureMap","lexical","admin","resolvedFeatureMap"],"sources":["../../../../src/lexical/config/client/sanitize.ts"],"sourcesContent":["'use client'\n\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport { deepMerge } from 'payload/shared'\n\nimport type { ToolbarGroup } from '../../../features/toolbars/types.js'\nimport type {\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n} from '../../../features/typesClient.js'\nimport type { LexicalFieldAdminClientProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\nexport const sanitizeClientFeatures = (\n features: ResolvedClientFeatureMap,\n): SanitizedClientFeatures => {\n const sanitized: SanitizedClientFeatures = {\n enabledFeatures: [],\n enabledFormats: [],\n markdownTransformers: [],\n nodes: [],\n plugins: [],\n providers: [],\n slashMenu: {\n dynamicGroups: [],\n groups: [],\n },\n toolbarFixed: {\n groups: [],\n },\n toolbarInline: {\n groups: [],\n },\n }\n\n // Allow customization of groups for toolbarFixed\n let customGroups: Record<string, Partial<ToolbarGroup>> = {}\n features.forEach((feature) => {\n if (feature.key === 'toolbarFixed' && feature.sanitizedClientFeatureProps?.customGroups) {\n customGroups = {\n ...customGroups,\n ...feature.sanitizedClientFeatureProps.customGroups,\n }\n }\n })\n\n if (!features?.size) {\n return sanitized\n }\n\n features.forEach((feature) => {\n if (feature.providers?.length) {\n sanitized.providers = sanitized.providers.concat(feature.providers)\n }\n\n if (feature.enableFormats?.length) {\n sanitized.enabledFormats.push(...feature.enableFormats)\n }\n\n if (feature.nodes?.length) {\n // Important: do not use concat\n for (const node of feature.nodes) {\n sanitized.nodes.push(node)\n }\n }\n if (feature.plugins?.length) {\n feature.plugins.forEach((plugin, i) => {\n sanitized.plugins?.push({\n clientProps: feature.sanitizedClientFeatureProps,\n Component: plugin.Component as any, // Appeases strict: true\n key: feature.key + i,\n position: plugin.position,\n })\n })\n }\n\n if (feature.toolbarInline?.groups?.length) {\n for (const group of feature.toolbarInline.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarInline.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarInline.groups = sanitized.toolbarInline.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarInline?.groups.push(foundGroup)\n }\n }\n\n if (feature.toolbarFixed?.groups?.length) {\n for (const group of feature.toolbarFixed.groups) {\n // 1. find the group with the same key or create new one\n let foundGroup = sanitized.toolbarFixed.groups.find(\n (sanitizedGroup) => sanitizedGroup.key === group.key,\n )\n if (!foundGroup) {\n foundGroup = {\n ...group,\n items: [],\n }\n } else {\n sanitized.toolbarFixed.groups = sanitized.toolbarFixed.groups.filter(\n (sanitizedGroup) => sanitizedGroup.key !== group.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.items?.length) {\n foundGroup.items = foundGroup.items.concat(group.items)\n }\n sanitized.toolbarFixed?.groups.push(foundGroup)\n }\n }\n\n if (feature.slashMenu?.groups) {\n if (feature.slashMenu.dynamicGroups?.length) {\n sanitized.slashMenu.dynamicGroups = sanitized.slashMenu.dynamicGroups.concat(\n feature.slashMenu.dynamicGroups,\n )\n }\n\n for (const optionGroup of feature.slashMenu.groups) {\n // 1. find the group with the same name or create new one\n let group = sanitized.slashMenu.groups.find((group) => group.key === optionGroup.key)\n if (!group) {\n group = {\n ...optionGroup,\n items: [],\n }\n } else {\n sanitized.slashMenu.groups = sanitized.slashMenu.groups.filter(\n (group) => group.key !== optionGroup.key,\n )\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (optionGroup?.items?.length) {\n group.items = group.items.concat(optionGroup.items)\n }\n sanitized.slashMenu.groups.push(group)\n }\n }\n\n if (feature.markdownTransformers?.length) {\n // Important: do not use concat\n for (const transformer of feature.markdownTransformers) {\n if (typeof transformer === 'function') {\n sanitized.markdownTransformers.push(\n transformer({\n allNodes: sanitized.nodes,\n allTransformers: sanitized.markdownTransformers,\n }),\n )\n } else {\n sanitized.markdownTransformers.push(transformer)\n }\n }\n }\n sanitized.enabledFeatures.push(feature.key)\n })\n\n // Apply custom group configurations to toolbarFixed groups\n if (Object.keys(customGroups).length > 0) {\n sanitized.toolbarFixed.groups = sanitized.toolbarFixed.groups.map((group) => {\n const customConfig = customGroups[group.key]\n if (customConfig) {\n return deepMerge(group, customConfig)\n }\n return group\n })\n }\n\n // Sort sanitized.toolbarInline.groups by order property\n sanitized.toolbarInline.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n // Sort sanitized.toolbarFixed.groups by order property\n sanitized.toolbarFixed.groups.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n\n // Sort sanitized.toolbarInline.groups.[group].entries by order property\n for (const group of sanitized.toolbarInline.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n // Sort sanitized.toolbarFixed.groups.[group].entries by order property\n for (const group of sanitized.toolbarFixed.groups) {\n group.items.sort((a, b) => {\n if (a.order && b.order) {\n return a.order - b.order\n } else if (a.order) {\n return -1\n } else if (b.order) {\n return 1\n } else {\n return 0\n }\n })\n }\n\n return sanitized\n}\n\nexport function sanitizeClientEditorConfig(\n resolvedClientFeatureMap: ResolvedClientFeatureMap,\n lexical?: LexicalEditorConfig,\n admin?: LexicalFieldAdminClientProps,\n): SanitizedClientEditorConfig {\n return {\n admin,\n features: sanitizeClientFeatures(resolvedClientFeatureMap),\n lexical: lexical!,\n resolvedFeatureMap: resolvedClientFeatureMap,\n }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,SAAS,QAAQ;AAU1B,OAAO,MAAMC,sBAAA,GACXC,QAAA;EAEA,MAAMC,SAAA,GAAqC;IACzCC,eAAA,EAAiB,EAAE;IACnBC,cAAA,EAAgB,EAAE;IAClBC,oBAAA,EAAsB,EAAE;IACxBC,KAAA,EAAO,EAAE;IACTC,OAAA,EAAS,EAAE;IACXC,SAAA,EAAW,EAAE;IACbC,SAAA,EAAW;MACTC,aAAA,EAAe,EAAE;MACjBC,MAAA,EAAQ;IACV;IACAC,YAAA,EAAc;MACZD,MAAA,EAAQ;IACV;IACAE,aAAA,EAAe;MACbF,MAAA,EAAQ;IACV;EACF;EAEA;EACA,IAAIG,YAAA,GAAsD,CAAC;EAC3Db,QAAA,CAASc,OAAO,CAAEC,OAAA;IAChB,IAAIA,OAAA,CAAQC,GAAG,KAAK,kBAAkBD,OAAA,CAAQE,2BAA2B,EAAEJ,YAAA,EAAc;MACvFA,YAAA,GAAe;QACb,GAAGA,YAAY;QACf,GAAGE,OAAA,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|
|
20
20
|
features: SanitizedClientFeatures;
|
|
21
21
|
lexical: LexicalEditorConfig;
|
|
22
22
|
resolvedFeatureMap: ResolvedClientFeatureMap;
|
|
23
|
-
/**
|
|
24
|
-
* To identify what view this editor config was created for.
|
|
25
|
-
*/
|
|
26
|
-
view?: string;
|
|
27
23
|
};
|
|
28
24
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lexical/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAElE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;IAChD,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAA;IACxC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;IAC3C,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,CAAC,EAAE,4BAA4B,CAAA;IACpC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lexical/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElE,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAElE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;IAChD,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAA;IACxC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;IAC3C,OAAO,CAAC,EAAE,mBAAmB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,CAAC,EAAE,4BAA4B,CAAA;IACpC,QAAQ,EAAE,uBAAuB,CAAA;IACjC,OAAO,EAAE,mBAAmB,CAAA;IAC5B,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type {\n FeatureProviderClient,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n} from '../../features/typesClient.js'\nimport type {\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n} from '../../features/typesServer.js'\nimport type { LexicalFieldAdminClientProps } from '../../types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<any, any, any>[]\n lexical?: LexicalEditorConfig | undefined // If undefined, the default lexical editor config will be used. This can be undefined so that we do not send the default lexical editor config to the client.\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig | undefined // If undefined, the default lexical editor config will be used. This can be undefined so that we do not send the default lexical editor config to the client.\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<any, any>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n admin?: LexicalFieldAdminClientProps\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/lexical/config/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig } from 'lexical'\n\nimport type {\n FeatureProviderClient,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n} from '../../features/typesClient.js'\nimport type {\n FeatureProviderServer,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n} from '../../features/typesServer.js'\nimport type { LexicalFieldAdminClientProps } from '../../types.js'\n\nexport type ServerEditorConfig = {\n features: FeatureProviderServer<any, any, any>[]\n lexical?: LexicalEditorConfig | undefined // If undefined, the default lexical editor config will be used. This can be undefined so that we do not send the default lexical editor config to the client.\n}\n\nexport type SanitizedServerEditorConfig = {\n features: SanitizedServerFeatures\n lexical: LexicalEditorConfig | undefined // If undefined, the default lexical editor config will be used. This can be undefined so that we do not send the default lexical editor config to the client.\n resolvedFeatureMap: ResolvedServerFeatureMap\n}\n\nexport type ClientEditorConfig = {\n features: FeatureProviderClient<any, any>[]\n lexical?: LexicalEditorConfig\n}\n\nexport type SanitizedClientEditorConfig = {\n admin?: LexicalFieldAdminClientProps\n features: SanitizedClientFeatures\n lexical: LexicalEditorConfig\n resolvedFeatureMap: ResolvedClientFeatureMap\n}\n"],"mappings":"AA8BA","ignoreList":[]}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import type { Klass,
|
|
1
|
+
import type { Klass, LexicalNode, LexicalNodeReplacement } from 'lexical';
|
|
2
2
|
import type { NodeWithHooks } from '../../features/typesServer.js';
|
|
3
|
-
import type { LexicalEditorNodeMap } from '../../types.js';
|
|
4
3
|
import type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js';
|
|
5
|
-
|
|
6
|
-
* Register view definitions for an editor
|
|
7
|
-
*/
|
|
8
|
-
export declare function registerEditorNodeViews(editor: LexicalEditor, nodeViews: LexicalEditorNodeMap): void;
|
|
9
|
-
/**
|
|
10
|
-
* Clear all view overrides for an editor (restores default rendering)
|
|
11
|
-
*/
|
|
12
|
-
export declare function clearEditorNodeViews(editor: LexicalEditor): void;
|
|
13
|
-
export declare function getEnabledNodes({ editorConfig, nodeViews, }: {
|
|
4
|
+
export declare function getEnabledNodes({ editorConfig, }: {
|
|
14
5
|
editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig;
|
|
15
|
-
nodeViews?: LexicalEditorNodeMap;
|
|
16
6
|
}): Array<Klass<LexicalNode> | LexicalNodeReplacement>;
|
|
17
7
|
export declare function getEnabledNodesFromServerNodes({ nodes, }: {
|
|
18
8
|
nodes: Array<Klass<LexicalNode> | LexicalNodeReplacement> | Array<NodeWithHooks>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lexical/nodes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lexical/nodes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,KAAK,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAElG,wBAAgB,eAAe,CAAC,EAC9B,YAAY,GACb,EAAE;IACD,YAAY,EAAE,2BAA2B,GAAG,2BAA2B,CAAA;CACxE,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,sBAAsB,CAAC,CAIrD;AAED,wBAAgB,8BAA8B,CAAC,EAC7C,KAAK,GACN,EAAE;IACD,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,sBAAsB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAA;CACjF,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,sBAAsB,CAAC,CAOrD"}
|
|
@@ -1,202 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
// Store view definitions for each editor and node type
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
const editorNodeViews = new WeakMap();
|
|
5
|
-
/**
|
|
6
|
-
* Register view definitions for an editor
|
|
7
|
-
*/
|
|
8
|
-
export function registerEditorNodeViews(editor, nodeViews) {
|
|
9
|
-
if (!editorNodeViews.has(editor)) {
|
|
10
|
-
editorNodeViews.set(editor, new Map());
|
|
11
|
-
}
|
|
12
|
-
const editorViews = editorNodeViews.get(editor);
|
|
13
|
-
// Register each node type's view
|
|
14
|
-
for (const [nodeType, value] of Object.entries(nodeViews)) {
|
|
15
|
-
if (!value || typeof value !== 'object') {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
// Handle blocks specially - store each block type with key 'block:blockType'
|
|
19
|
-
if (nodeType === 'blocks') {
|
|
20
|
-
for (const [blockType, viewDef] of Object.entries(
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
value)) {
|
|
23
|
-
editorViews.set(`block:${blockType}`, viewDef);
|
|
24
|
-
}
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
// Handle inlineBlocks specially - store each block type with key 'inlineBlock:blockType'
|
|
28
|
-
if (nodeType === 'inlineBlocks') {
|
|
29
|
-
for (const [blockType, viewDef] of Object.entries(
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
value)) {
|
|
32
|
-
editorViews.set(`inlineBlock:${blockType}`, viewDef);
|
|
33
|
-
}
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
// Regular node types
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
editorViews.set(nodeType, value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Clear all view overrides for an editor (restores default rendering)
|
|
43
|
-
*/
|
|
44
|
-
export function clearEditorNodeViews(editor) {
|
|
45
|
-
editorNodeViews.delete(editor);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get the view definition for a specific editor and node
|
|
49
|
-
*/
|
|
50
|
-
function getEditorNodeView(editor, nodeType,
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
node) {
|
|
53
|
-
const editorViews = editorNodeViews.get(editor);
|
|
54
|
-
// For block nodes, look up by blockType
|
|
55
|
-
if (nodeType === 'block' && node?.['__fields']?.blockType) {
|
|
56
|
-
const blockType = node['__fields'].blockType;
|
|
57
|
-
return editorViews?.get(`block:${blockType}`);
|
|
58
|
-
}
|
|
59
|
-
// For inlineBlock nodes, look up by blockType
|
|
60
|
-
if (nodeType === 'inlineBlock' && node?.['__fields']?.blockType) {
|
|
61
|
-
const blockType = node['__fields'].blockType;
|
|
62
|
-
return editorViews?.get(`inlineBlock:${blockType}`);
|
|
63
|
-
}
|
|
64
|
-
// Regular node types
|
|
65
|
-
return editorViews?.get(nodeType);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Apply view overrides to a specific node type by modifying its prototype
|
|
69
|
-
* Uses WeakMap to check per-editor at runtime
|
|
70
|
-
*/
|
|
71
|
-
function applyNodeOverride({
|
|
72
|
-
node,
|
|
73
|
-
nodeType
|
|
74
|
-
}) {
|
|
75
|
-
if (!('getType' in node) || node.getType() !== nodeType) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
-
const NodeClass = node;
|
|
80
|
-
// Store original methods if not already stored
|
|
81
|
-
if (!NodeClass.prototype._originalDecorate) {
|
|
82
|
-
NodeClass.prototype._originalDecorate = NodeClass.prototype.decorate;
|
|
83
|
-
}
|
|
84
|
-
if (!NodeClass.prototype._originalCreateDOM) {
|
|
85
|
-
NodeClass.prototype._originalCreateDOM = NodeClass.prototype.createDOM;
|
|
86
|
-
}
|
|
87
|
-
// Override decorate method (for DecoratorNodes)
|
|
88
|
-
if (NodeClass.prototype.decorate && !NodeClass.prototype._decorateOverridden) {
|
|
89
|
-
NodeClass.prototype._decorateOverridden = true;
|
|
90
|
-
const hasCreateDOM = !!NodeClass.prototype.createDOM;
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
|
-
NodeClass.prototype.decorate = function (editor, config) {
|
|
93
|
-
const viewDef = getEditorNodeView(editor, nodeType, this);
|
|
94
|
-
if (viewDef) {
|
|
95
|
-
// Priority 1: If Component is provided, use it
|
|
96
|
-
if (viewDef.Component) {
|
|
97
|
-
return viewDef.Component({
|
|
98
|
-
config,
|
|
99
|
-
editor,
|
|
100
|
-
isEditor: true,
|
|
101
|
-
isJSXConverter: false,
|
|
102
|
-
node: this
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
// Priority 2: If custom createDOM is provided, use html in decorate
|
|
106
|
-
if (viewDef.createDOM && viewDef.html) {
|
|
107
|
-
const htmlContent = typeof viewDef.html === 'function' ? viewDef.html({
|
|
108
|
-
config,
|
|
109
|
-
editor,
|
|
110
|
-
isEditor: true,
|
|
111
|
-
isJSXConverter: false,
|
|
112
|
-
node: this
|
|
113
|
-
}) : viewDef.html;
|
|
114
|
-
return React.createElement('span', {
|
|
115
|
-
dangerouslySetInnerHTML: {
|
|
116
|
-
__html: htmlContent
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
// Priority 3: If only html is provided (no custom createDOM),
|
|
121
|
-
// createDOM will handle it, so decorate returns empty fragment
|
|
122
|
-
if (viewDef.html && hasCreateDOM && !viewDef.createDOM) {
|
|
123
|
-
return React.createElement(React.Fragment);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Otherwise use original
|
|
127
|
-
return NodeClass.prototype._originalDecorate.call(this, editor, config);
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
// Override createDOM method (for ElementNodes)
|
|
131
|
-
if (NodeClass.prototype.createDOM && !NodeClass.prototype._createDOMOverridden) {
|
|
132
|
-
NodeClass.prototype._createDOMOverridden = true;
|
|
133
|
-
NodeClass.prototype.createDOM = function (config, editor) {
|
|
134
|
-
const viewDef = getEditorNodeView(editor, nodeType, this);
|
|
135
|
-
if (viewDef) {
|
|
136
|
-
// If createDOM is provided, use it
|
|
137
|
-
if (viewDef.createDOM) {
|
|
138
|
-
return viewDef.createDOM({
|
|
139
|
-
config,
|
|
140
|
-
editor,
|
|
141
|
-
node: this
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
// If html is provided (as a function or string), create element from it
|
|
145
|
-
if (viewDef.html) {
|
|
146
|
-
const htmlContent = typeof viewDef.html === 'function' ? viewDef.html({
|
|
147
|
-
config,
|
|
148
|
-
editor,
|
|
149
|
-
isEditor: true,
|
|
150
|
-
isJSXConverter: false,
|
|
151
|
-
node: this
|
|
152
|
-
}) : viewDef.html;
|
|
153
|
-
const tempDiv = document.createElement('div');
|
|
154
|
-
tempDiv.innerHTML = htmlContent;
|
|
155
|
-
return tempDiv.firstElementChild || tempDiv;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// Otherwise use original
|
|
159
|
-
return NodeClass.prototype._originalCreateDOM.call(this, config, editor);
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
1
|
export function getEnabledNodes({
|
|
164
|
-
editorConfig
|
|
165
|
-
nodeViews
|
|
2
|
+
editorConfig
|
|
166
3
|
}) {
|
|
167
|
-
|
|
4
|
+
return getEnabledNodesFromServerNodes({
|
|
168
5
|
nodes: editorConfig.features.nodes
|
|
169
6
|
});
|
|
170
|
-
if (nodeViews) {
|
|
171
|
-
// Apply node overrides by modifying prototypes (once globally)
|
|
172
|
-
// The overrides check per-editor at runtime using WeakMap
|
|
173
|
-
const nodeTypesToOverride = new Set();
|
|
174
|
-
for (const [key, value] of Object.entries(nodeViews)) {
|
|
175
|
-
if (!value || typeof value !== 'object') {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
// If 'blocks' key exists with content, we need to override 'block' nodes
|
|
179
|
-
if (key === 'blocks' && Object.keys(value).length > 0) {
|
|
180
|
-
nodeTypesToOverride.add('block');
|
|
181
|
-
} else if (key === 'inlineBlocks' && Object.keys(value).length > 0) {
|
|
182
|
-
nodeTypesToOverride.add('inlineBlock');
|
|
183
|
-
} else {
|
|
184
|
-
nodeTypesToOverride.add(key);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
for (const node of nodes) {
|
|
188
|
-
if ('getType' in node) {
|
|
189
|
-
const nodeType = node.getType();
|
|
190
|
-
if (nodeTypesToOverride.has(nodeType)) {
|
|
191
|
-
applyNodeOverride({
|
|
192
|
-
node,
|
|
193
|
-
nodeType
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return nodes;
|
|
200
7
|
}
|
|
201
8
|
export function getEnabledNodesFromServerNodes({
|
|
202
9
|
nodes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","editorNodeViews","WeakMap","registerEditorNodeViews","editor","nodeViews","has","set","Map","editorViews","get","nodeType","value","Object","entries","blockType","viewDef","clearEditorNodeViews","delete","getEditorNodeView","node","applyNodeOverride","getType","NodeClass","prototype","_originalDecorate","decorate","_originalCreateDOM","createDOM","_decorateOverridden","hasCreateDOM","config","Component","isEditor","isJSXConverter","html","htmlContent","createElement","dangerouslySetInnerHTML","__html","Fragment","call","_createDOMOverridden","tempDiv","document","innerHTML","firstElementChild","getEnabledNodes","editorConfig","nodes","getEnabledNodesFromServerNodes","features","nodeTypesToOverride","Set","key","keys","length","add","map"],"sources":["../../../src/lexical/nodes/index.ts"],"sourcesContent":["import type {\n EditorConfig,\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n} from 'lexical'\n\nimport React from 'react'\n\nimport type { NodeWithHooks } from '../../features/typesServer.js'\nimport type { LexicalEditorNodeMap, NodeMapValue } from '../../types.js'\nimport type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js'\n\n// Store view definitions for each editor and node type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst editorNodeViews = new WeakMap<LexicalEditor, Map<string, NodeMapValue<any>>>()\n\n/**\n * Register view definitions for an editor\n */\nexport function registerEditorNodeViews(\n editor: LexicalEditor,\n nodeViews: LexicalEditorNodeMap,\n): void {\n if (!editorNodeViews.has(editor)) {\n editorNodeViews.set(editor, new Map())\n }\n const editorViews = editorNodeViews.get(editor)!\n\n // Register each node type's view\n for (const [nodeType, value] of Object.entries(nodeViews)) {\n if (!value || typeof value !== 'object') {\n continue\n }\n\n // Handle blocks specially - store each block type with key 'block:blockType'\n if (nodeType === 'blocks') {\n for (const [blockType, viewDef] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value as Record<string, NodeMapValue<any>>,\n )) {\n editorViews.set(`block:${blockType}`, viewDef)\n }\n continue\n }\n\n // Handle inlineBlocks specially - store each block type with key 'inlineBlock:blockType'\n if (nodeType === 'inlineBlocks') {\n for (const [blockType, viewDef] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value as Record<string, NodeMapValue<any>>,\n )) {\n editorViews.set(`inlineBlock:${blockType}`, viewDef)\n }\n continue\n }\n\n // Regular node types\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n editorViews.set(nodeType, value as NodeMapValue<any>)\n }\n}\n\n/**\n * Clear all view overrides for an editor (restores default rendering)\n */\nexport function clearEditorNodeViews(editor: LexicalEditor): void {\n editorNodeViews.delete(editor)\n}\n\n/**\n * Get the view definition for a specific editor and node\n */\nfunction getEditorNodeView(\n editor: LexicalEditor,\n nodeType: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n node?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): NodeMapValue<any> | undefined {\n const editorViews = editorNodeViews.get(editor)\n\n // For block nodes, look up by blockType\n if (nodeType === 'block' && node?.['__fields']?.blockType) {\n const blockType = node['__fields'].blockType\n return editorViews?.get(`block:${blockType}`)\n }\n\n // For inlineBlock nodes, look up by blockType\n if (nodeType === 'inlineBlock' && node?.['__fields']?.blockType) {\n const blockType = node['__fields'].blockType\n return editorViews?.get(`inlineBlock:${blockType}`)\n }\n\n // Regular node types\n return editorViews?.get(nodeType)\n}\n\n/**\n * Apply view overrides to a specific node type by modifying its prototype\n * Uses WeakMap to check per-editor at runtime\n */\nfunction applyNodeOverride({\n node,\n nodeType,\n}: {\n node: Klass<LexicalNode>\n nodeType: string\n}): void {\n if (!('getType' in node) || node.getType() !== nodeType) {\n return\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const NodeClass = node as any\n\n // Store original methods if not already stored\n if (!NodeClass.prototype._originalDecorate) {\n NodeClass.prototype._originalDecorate = NodeClass.prototype.decorate\n }\n if (!NodeClass.prototype._originalCreateDOM) {\n NodeClass.prototype._originalCreateDOM = NodeClass.prototype.createDOM\n }\n\n // Override decorate method (for DecoratorNodes)\n if (NodeClass.prototype.decorate && !NodeClass.prototype._decorateOverridden) {\n NodeClass.prototype._decorateOverridden = true\n const hasCreateDOM = !!NodeClass.prototype.createDOM\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n NodeClass.prototype.decorate = function (editor: LexicalEditor, config: EditorConfig): any {\n const viewDef = getEditorNodeView(editor, nodeType, this)\n\n if (viewDef) {\n // Priority 1: If Component is provided, use it\n if (viewDef.Component) {\n return viewDef.Component({\n config,\n editor,\n isEditor: true,\n isJSXConverter: false,\n node: this,\n })\n }\n\n // Priority 2: If custom createDOM is provided, use html in decorate\n if (viewDef.createDOM && viewDef.html) {\n const htmlContent =\n typeof viewDef.html === 'function'\n ? viewDef.html({ config, editor, isEditor: true, isJSXConverter: false, node: this })\n : viewDef.html\n return React.createElement('span', {\n dangerouslySetInnerHTML: { __html: htmlContent },\n })\n }\n\n // Priority 3: If only html is provided (no custom createDOM),\n // createDOM will handle it, so decorate returns empty fragment\n if (viewDef.html && hasCreateDOM && !viewDef.createDOM) {\n return React.createElement(React.Fragment)\n }\n }\n\n // Otherwise use original\n return NodeClass.prototype._originalDecorate.call(this, editor, config)\n }\n }\n\n // Override createDOM method (for ElementNodes)\n if (NodeClass.prototype.createDOM && !NodeClass.prototype._createDOMOverridden) {\n NodeClass.prototype._createDOMOverridden = true\n NodeClass.prototype.createDOM = function (\n config: EditorConfig,\n editor: LexicalEditor,\n ): HTMLElement {\n const viewDef = getEditorNodeView(editor, nodeType, this)\n\n if (viewDef) {\n // If createDOM is provided, use it\n if (viewDef.createDOM) {\n return viewDef.createDOM({ config, editor, node: this })\n }\n\n // If html is provided (as a function or string), create element from it\n if (viewDef.html) {\n const htmlContent =\n typeof viewDef.html === 'function'\n ? viewDef.html({ config, editor, isEditor: true, isJSXConverter: false, node: this })\n : viewDef.html\n const tempDiv = document.createElement('div')\n tempDiv.innerHTML = htmlContent\n return (tempDiv.firstElementChild as HTMLElement) || tempDiv\n }\n }\n\n // Otherwise use original\n return NodeClass.prototype._originalCreateDOM.call(this, config, editor)\n }\n }\n}\n\nexport function getEnabledNodes({\n editorConfig,\n nodeViews,\n}: {\n editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig\n nodeViews?: LexicalEditorNodeMap\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n const nodes = getEnabledNodesFromServerNodes({\n nodes: editorConfig.features.nodes,\n })\n\n if (nodeViews) {\n // Apply node overrides by modifying prototypes (once globally)\n // The overrides check per-editor at runtime using WeakMap\n const nodeTypesToOverride = new Set<string>()\n\n for (const [key, value] of Object.entries(nodeViews)) {\n if (!value || typeof value !== 'object') {\n continue\n }\n\n // If 'blocks' key exists with content, we need to override 'block' nodes\n if (key === 'blocks' && Object.keys(value).length > 0) {\n nodeTypesToOverride.add('block')\n }\n // If 'inlineBlocks' key exists with content, we need to override 'inlineBlock' nodes\n else if (key === 'inlineBlocks' && Object.keys(value).length > 0) {\n nodeTypesToOverride.add('inlineBlock')\n }\n // Regular node types\n else {\n nodeTypesToOverride.add(key)\n }\n }\n\n for (const node of nodes) {\n if ('getType' in node) {\n const nodeType = node.getType()\n\n if (nodeTypesToOverride.has(nodeType)) {\n applyNodeOverride({ node, nodeType })\n }\n }\n }\n }\n\n return nodes\n}\n\nexport function getEnabledNodesFromServerNodes({\n nodes,\n}: {\n nodes: Array<Klass<LexicalNode> | LexicalNodeReplacement> | Array<NodeWithHooks>\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return nodes.map((node) => {\n if ('node' in node) {\n return node.node\n }\n return node\n })\n}\n"],"mappings":"AAQA,OAAOA,KAAA,MAAW;AAMlB;AACA;AACA,MAAMC,eAAA,GAAkB,IAAIC,OAAA;AAE5B;;;AAGA,OAAO,S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CAAC3C,KAAA,EAAO4C,MAAM,GAAG,GAAG;QAChEJ,mBAAA,CAAoBK,GAAG,CAAC;MAC1B,OAEK;QACHL,mBAAA,CAAoBK,GAAG,CAACH,GAAA;MAC1B;IACF;IAEA,KAAK,MAAMlC,IAAA,IAAQ6B,KAAA,EAAO;MACxB,IAAI,aAAa7B,IAAA,EAAM;QACrB,MAAMT,QAAA,GAAWS,IAAA,CAAKE,OAAO;QAE7B,IAAI8B,mBAAA,CAAoB9C,GAAG,CAACK,QAAA,GAAW;UACrCU,iBAAA,CAAkB;YAAED,IAAA;YAAMT;UAAS;QACrC;MACF;IACF;EACF;EAEA,OAAOsC,KAAA;AACT;AAEA,OAAO,SAASC,+BAA+B;EAC7CD;AAAK,CAGN;EACC,OAAOA,KAAA,CAAMS,GAAG,CAAEtC,IAAA;IAChB,IAAI,UAAUA,IAAA,EAAM;MAClB,OAAOA,IAAA,CAAKA,IAAI;IAClB;IACA,OAAOA,IAAA;EACT;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["getEnabledNodes","editorConfig","getEnabledNodesFromServerNodes","nodes","features","map","node"],"sources":["../../../src/lexical/nodes/index.ts"],"sourcesContent":["import type { Klass, LexicalNode, LexicalNodeReplacement } from 'lexical'\n\nimport type { NodeWithHooks } from '../../features/typesServer.js'\nimport type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js'\n\nexport function getEnabledNodes({\n editorConfig,\n}: {\n editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return getEnabledNodesFromServerNodes({\n nodes: editorConfig.features.nodes,\n })\n}\n\nexport function getEnabledNodesFromServerNodes({\n nodes,\n}: {\n nodes: Array<Klass<LexicalNode> | LexicalNodeReplacement> | Array<NodeWithHooks>\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return nodes.map((node) => {\n if ('node' in node) {\n return node.node\n }\n return node\n })\n}\n"],"mappings":"AAKA,OAAO,SAASA,gBAAgB;EAC9BC;AAAY,CAGb;EACC,OAAOC,8BAAA,CAA+B;IACpCC,KAAA,EAAOF,YAAA,CAAaG,QAAQ,CAACD;EAC/B;AACF;AAEA,OAAO,SAASD,+BAA+B;EAC7CC;AAAK,CAGN;EACC,OAAOA,KAAA,CAAME,GAAG,CAAEC,IAAA;IAChB,IAAI,UAAUA,IAAA,EAAM;MAClB,OAAOA,IAAA,CAAKA,IAAI;IAClB;IACA,OAAOA,IAAA;EACT;AACF","ignoreList":[]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ClientField, DefaultServerCellComponentProps, LabelFunction,
|
|
3
|
-
import type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js';
|
|
1
|
+
import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical';
|
|
2
|
+
import type { ClientField, DefaultServerCellComponentProps, LabelFunction, RichTextAdapter, RichTextField, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
|
|
4
3
|
import type { BaseClientFeatureProps, FeatureProviderProviderClient } from './features/typesClient.js';
|
|
5
4
|
import type { FeatureProviderServer } from './features/typesServer.js';
|
|
6
5
|
import type { SanitizedServerEditorConfig } from './lexical/config/types.js';
|
|
7
|
-
import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from './nodeTypes.js';
|
|
8
6
|
import type { InitialLexicalFormState } from './utilities/buildInitialState.js';
|
|
9
7
|
export type LexicalFieldAdminProps = {
|
|
10
8
|
/**
|
|
@@ -58,156 +56,10 @@ export type FeaturesInput = (({ defaultFeatures, rootFeatures, }: {
|
|
|
58
56
|
*/
|
|
59
57
|
rootFeatures: FeatureProviderServer<any, any, any>[];
|
|
60
58
|
}) => FeatureProviderServer<any, any, any>[]) | FeatureProviderServer<any, any, any>[];
|
|
61
|
-
type WithinEditorArgs = {
|
|
62
|
-
config: EditorConfig;
|
|
63
|
-
editor: LexicalEditor;
|
|
64
|
-
node: LexicalNode;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
*
|
|
68
|
-
* @experimental - This API is experimental and may change in a minor release.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export type NodeMapValue<TNode extends {
|
|
72
|
-
[key: string]: any;
|
|
73
|
-
type?: string;
|
|
74
|
-
} = SerializedLexicalNode> = {
|
|
75
|
-
/**
|
|
76
|
-
* Provide a react component to render the node.
|
|
77
|
-
*
|
|
78
|
-
* **JSX Converter:** Always works. Takes priority over `html`.
|
|
79
|
-
*
|
|
80
|
-
* **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.
|
|
81
|
-
*/
|
|
82
|
-
Component?: (args: ({
|
|
83
|
-
isEditor: false;
|
|
84
|
-
isJSXConverter: true;
|
|
85
|
-
} & JSXConverterArgs<TNode>) | ({
|
|
86
|
-
isEditor: true;
|
|
87
|
-
isJSXConverter: false;
|
|
88
|
-
node: {
|
|
89
|
-
_originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode;
|
|
90
|
-
} & DecoratorNode<React.ReactNode>;
|
|
91
|
-
} & Omit<WithinEditorArgs, 'node'>)) => React.ReactNode;
|
|
92
|
-
/**
|
|
93
|
-
* Provide a function to create the DOM element for the node.
|
|
94
|
-
*
|
|
95
|
-
* **JSX Converter:** Not used (only `Component` and `html` work).
|
|
96
|
-
*
|
|
97
|
-
* **Lexical Editor:** Always works (renders in `createDOM` method).
|
|
98
|
-
* - For ElementNodes: This is the standard way to customize rendering.
|
|
99
|
-
* - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.
|
|
100
|
-
*/
|
|
101
|
-
createDOM?: (args: WithinEditorArgs) => HTMLElement;
|
|
102
|
-
/**
|
|
103
|
-
* Provide HTML string or function to render the node.
|
|
104
|
-
*
|
|
105
|
-
* **JSX Converter:** Always works (ignored if `Component` is provided).
|
|
106
|
-
*
|
|
107
|
-
* **Lexical Editor behavior depends on node type:**
|
|
108
|
-
*
|
|
109
|
-
* - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.
|
|
110
|
-
*
|
|
111
|
-
* - **DecoratorNodes (have both `createDOM` and `decorate`):**
|
|
112
|
-
* - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`
|
|
113
|
-
* - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`
|
|
114
|
-
* - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content
|
|
115
|
-
* - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)
|
|
116
|
-
*/
|
|
117
|
-
html?: (args: ({
|
|
118
|
-
isEditor: false;
|
|
119
|
-
isJSXConverter: true;
|
|
120
|
-
} & JSXConverterArgs<TNode>) | ({
|
|
121
|
-
isEditor: true;
|
|
122
|
-
isJSXConverter: false;
|
|
123
|
-
} & WithinEditorArgs)) => string;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* @experimental - This API is experimental and may change in a minor release.
|
|
127
|
-
* @internal
|
|
128
|
-
*/
|
|
129
|
-
export type LexicalEditorNodeMap<TNodes extends {
|
|
130
|
-
[key: string]: any;
|
|
131
|
-
type?: string;
|
|
132
|
-
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
133
|
-
blockName?: null | string;
|
|
134
|
-
blockType: string;
|
|
135
|
-
}> | SerializedInlineBlockNode<{
|
|
136
|
-
blockName?: null | string;
|
|
137
|
-
blockType: string;
|
|
138
|
-
}>> = {
|
|
139
|
-
[key: string]: {
|
|
140
|
-
[blockSlug: string]: NodeMapValue<any>;
|
|
141
|
-
} | NodeMapValue<any> | undefined;
|
|
142
|
-
} & {
|
|
143
|
-
[nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<Extract<TNodes, {
|
|
144
|
-
type: nodeType;
|
|
145
|
-
}>>;
|
|
146
|
-
} & {
|
|
147
|
-
blocks?: {
|
|
148
|
-
[K in Extract<Extract<TNodes, {
|
|
149
|
-
type: 'block';
|
|
150
|
-
}> extends SerializedBlockNode<infer B> ? B extends {
|
|
151
|
-
blockType: string;
|
|
152
|
-
} ? B['blockType'] : never : never, string>]?: NodeMapValue<Extract<TNodes, {
|
|
153
|
-
type: 'block';
|
|
154
|
-
}> extends SerializedBlockNode<infer B> ? SerializedBlockNode<Extract<B, {
|
|
155
|
-
blockType: K;
|
|
156
|
-
}>> : SerializedBlockNode>;
|
|
157
|
-
};
|
|
158
|
-
inlineBlocks?: {
|
|
159
|
-
[K in Extract<Extract<TNodes, {
|
|
160
|
-
type: 'inlineBlock';
|
|
161
|
-
}> extends SerializedInlineBlockNode<infer B> ? B extends {
|
|
162
|
-
blockType: string;
|
|
163
|
-
} ? B['blockType'] : never : never, string>]?: NodeMapValue<Extract<TNodes, {
|
|
164
|
-
type: 'inlineBlock';
|
|
165
|
-
}> extends SerializedInlineBlockNode<infer B> ? SerializedInlineBlockNode<Extract<B, {
|
|
166
|
-
blockType: K;
|
|
167
|
-
}>> : SerializedInlineBlockNode>;
|
|
168
|
-
};
|
|
169
|
-
unknown?: NodeMapValue<SerializedLexicalNode>;
|
|
170
|
-
};
|
|
171
|
-
/**
|
|
172
|
-
* A map of views, which can be used to render the editor in different ways.
|
|
173
|
-
*
|
|
174
|
-
* In order to override the default view, you can add a `default` key to the map.
|
|
175
|
-
*
|
|
176
|
-
* @experimental - This API is experimental and may change in a minor release.
|
|
177
|
-
* @internal
|
|
178
|
-
*/
|
|
179
|
-
export type LexicalEditorViewMap<TNodes extends {
|
|
180
|
-
[key: string]: any;
|
|
181
|
-
type?: string;
|
|
182
|
-
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
183
|
-
blockName?: null | string;
|
|
184
|
-
blockType: string;
|
|
185
|
-
}> | SerializedInlineBlockNode<{
|
|
186
|
-
blockName?: null | string;
|
|
187
|
-
blockType: string;
|
|
188
|
-
}>> = {
|
|
189
|
-
[viewKey: string]: {
|
|
190
|
-
admin?: LexicalFieldAdminClientProps;
|
|
191
|
-
lexical?: LexicalEditorConfig;
|
|
192
|
-
nodes: LexicalEditorNodeMap<TNodes>;
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function
|
|
197
|
-
*/
|
|
198
59
|
export type LexicalEditorProps = {
|
|
199
60
|
admin?: LexicalFieldAdminProps;
|
|
200
61
|
features?: FeaturesInput;
|
|
201
62
|
lexical?: LexicalEditorConfig;
|
|
202
|
-
/**
|
|
203
|
-
* A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.
|
|
204
|
-
*
|
|
205
|
-
* In order to override the default view, you can add a `default` key to the map.
|
|
206
|
-
*
|
|
207
|
-
* @experimental - This API is experimental and may change in a minor release.
|
|
208
|
-
* @internal
|
|
209
|
-
*/
|
|
210
|
-
views?: PayloadComponent;
|
|
211
63
|
};
|
|
212
64
|
export type LexicalRichTextAdapter = {
|
|
213
65
|
editorConfig: SanitizedServerEditorConfig;
|
|
@@ -244,7 +96,6 @@ export type LexicalRichTextFieldProps = {
|
|
|
244
96
|
featureClientSchemaMap: FeatureClientSchemaMap;
|
|
245
97
|
initialLexicalFormState: InitialLexicalFormState;
|
|
246
98
|
lexicalEditorConfig: LexicalEditorConfig | undefined;
|
|
247
|
-
views?: LexicalEditorViewMap;
|
|
248
99
|
} & Pick<ServerFieldBase, 'permissions'> & RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>;
|
|
249
100
|
export type LexicalRichTextCellProps = DefaultServerCellComponentProps<RichTextFieldClient<SerializedEditorState, AdapterProps, object>, SerializedEditorState>;
|
|
250
101
|
export type AdapterProps = {
|
|
@@ -255,5 +106,4 @@ export type GeneratedFeatureProviderComponent = {
|
|
|
255
106
|
clientFeatureProps: BaseClientFeatureProps<object>;
|
|
256
107
|
};
|
|
257
108
|
export type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>;
|
|
258
|
-
export {};
|
|
259
109
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAA;AAE/E,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAA;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;OAEG;IACH,WAAW,CAAC,EAAE,aAAa,GAAG,WAAW,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,IAAI,CAAC,sBA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A4B,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,CAAC,EAAE,4BAA4B,CAAA;IAEpC,cAAc,EAAE;QACd,CAAC,UAAU,EAAE,MAAM,GAAG;YACpB,kBAAkB,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;YAChE,qBAAqB,CAAC,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAChE,CAAA;KACF,CAAA;IACD;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,uBAAuB,EAAE,uBAAuB,CAAA;IAChD,mBAAmB,EAAE,mBAAmB,GAAG,SAAS,CAAA;CACrD,GAAG,IAAI,CAAC,eAAe,EAAE,aAAa,CAAC,GACtC,wBAAwB,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;AAEvE,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,CACpE,mBAAmB,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,EAChE,qBAAqB,CACtB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,aAAa,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n DecoratorNode,\n EditorConfig,\n LexicalEditor,\n EditorConfig as LexicalEditorConfig,\n LexicalNode,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n PayloadComponent,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js'\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\ntype WithinEditorArgs = {\n config: EditorConfig\n editor: LexicalEditor\n node: LexicalNode\n}\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapValue<\n TNode extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> = {\n /**\n * Provide a react component to render the node.\n *\n * **JSX Converter:** Always works. Takes priority over `html`.\n *\n * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.\n */\n Component?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n node: {\n _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode\n } & DecoratorNode<React.ReactNode>\n } & Omit<WithinEditorArgs, 'node'>),\n ) => React.ReactNode\n /**\n * Provide a function to create the DOM element for the node.\n *\n * **JSX Converter:** Not used (only `Component` and `html` work).\n *\n * **Lexical Editor:** Always works (renders in `createDOM` method).\n * - For ElementNodes: This is the standard way to customize rendering.\n * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.\n */\n createDOM?: (args: WithinEditorArgs) => HTMLElement\n /**\n * Provide HTML string or function to render the node.\n *\n * **JSX Converter:** Always works (ignored if `Component` is provided).\n *\n * **Lexical Editor behavior depends on node type:**\n *\n * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.\n *\n * - **DecoratorNodes (have both `createDOM` and `decorate`):**\n * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`\n * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`\n * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content\n * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)\n */\n html?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => string\n}\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: NodeMapValue<any>\n }\n | NodeMapValue<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: NodeMapValue<SerializedLexicalNode>\n}\n\n/**\n * A map of views, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorViewMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n lexical?: LexicalEditorConfig\n nodes: LexicalEditorNodeMap<TNodes>\n }\n}\n\n/**\n * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function\n */\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n /**\n * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\n views?: PayloadComponent\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n views?: LexicalEditorViewMap\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAmUA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAoJA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CA+CtC,CAAA"}
|