@payloadcms/richtext-lexical 3.0.0-beta.90 → 3.0.0-beta.92

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.
Files changed (90) hide show
  1. package/dist/exports/client/Field-SUWHJ4HF.js +2 -0
  2. package/dist/exports/client/Field-SUWHJ4HF.js.map +7 -0
  3. package/dist/exports/client/RelationshipComponent-EZORSGUZ.js +2 -0
  4. package/dist/exports/client/RelationshipComponent-EZORSGUZ.js.map +7 -0
  5. package/dist/exports/client/bundled.css +1 -1
  6. package/dist/exports/client/{chunk-NI6Z4GBD.js → chunk-OLSILJA6.js} +1 -1
  7. package/dist/exports/client/{chunk-NI6Z4GBD.js.map → chunk-OLSILJA6.js.map} +1 -1
  8. package/dist/exports/client/{chunk-G5DTIOPI.js → chunk-TD7O23AB.js} +2 -2
  9. package/dist/exports/client/{chunk-G5DTIOPI.js.map → chunk-TD7O23AB.js.map} +2 -2
  10. package/dist/exports/client/{chunk-LGUXX2QH.js → chunk-UJDWBQ2K.js} +2 -2
  11. package/dist/exports/client/{chunk-LGUXX2QH.js.map → chunk-UJDWBQ2K.js.map} +2 -2
  12. package/dist/exports/client/{chunk-OKMIHD2R.js → chunk-YL453UOS.js} +2 -2
  13. package/dist/exports/client/chunk-YSI2QILQ.js +2 -0
  14. package/dist/exports/client/{chunk-TO2W7Q2G.js.map → chunk-YSI2QILQ.js.map} +2 -2
  15. package/dist/exports/client/component-2YLEVOFH.js +2 -0
  16. package/dist/exports/client/component-2YLEVOFH.js.map +7 -0
  17. package/dist/exports/client/{component-LCAAX56T.js → component-7RAP75FW.js} +2 -2
  18. package/dist/exports/client/{componentInline-72VZAAHP.js → componentInline-YSHGRL2J.js} +2 -2
  19. package/dist/exports/client/index.js +12 -12
  20. package/dist/exports/client/index.js.map +3 -3
  21. package/dist/features/debug/testRecorder/client/plugin/index.js +187 -363
  22. package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
  23. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +234 -470
  24. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  25. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js +3 -16
  26. package/dist/features/experimental_table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
  27. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js +59 -123
  28. package/dist/features/experimental_table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
  29. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  30. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +5 -3
  31. package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  32. package/dist/features/link/server/baseFields.d.ts.map +1 -1
  33. package/dist/features/link/server/baseFields.js +12 -2
  34. package/dist/features/link/server/baseFields.js.map +1 -1
  35. package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js +1 -1
  36. package/dist/features/migrations/slateToLexical/converter/converters/link/converter.js.map +1 -1
  37. package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
  38. package/dist/features/relationship/client/components/RelationshipComponent.js +8 -5
  39. package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
  40. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +6 -4
  41. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  42. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  43. package/dist/features/toolbars/inline/client/Toolbar/index.js +53 -94
  44. package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
  45. package/dist/features/upload/client/component/index.d.ts.map +1 -1
  46. package/dist/features/upload/client/component/index.js +3 -0
  47. package/dist/features/upload/client/component/index.js.map +1 -1
  48. package/dist/features/upload/server/nodes/UploadNode.d.ts +9 -7
  49. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  50. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  51. package/dist/field/bundled.css +1 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +8 -19
  54. package/dist/index.js.map +1 -1
  55. package/dist/lexical/config/client/EditorConfigProvider.js +1 -1
  56. package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
  57. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +71 -109
  58. package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
  59. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js +96 -135
  60. package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
  61. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  62. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +114 -139
  63. package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  64. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
  65. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +7 -25
  66. package/dist/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  67. package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
  68. package/dist/lexical/plugins/handles/utils/setHandlePosition.js +4 -6
  69. package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
  70. package/dist/lexical/ui/icons/Caret/index.svg +2 -2
  71. package/dist/lexical/utils/setFloatingElemPosition.js +1 -1
  72. package/dist/lexical/utils/setFloatingElemPosition.js.map +1 -1
  73. package/dist/lexical/utils/url.d.ts +5 -0
  74. package/dist/lexical/utils/url.d.ts.map +1 -1
  75. package/dist/lexical/utils/url.js +7 -0
  76. package/dist/lexical/utils/url.js.map +1 -1
  77. package/dist/utilities/migrateSlateToLexical/index.d.ts.map +1 -1
  78. package/dist/utilities/migrateSlateToLexical/index.js +16 -1
  79. package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
  80. package/package.json +13 -13
  81. package/dist/exports/client/Field-63NGLPJB.js +0 -2
  82. package/dist/exports/client/Field-63NGLPJB.js.map +0 -7
  83. package/dist/exports/client/RelationshipComponent-3QWBV4GT.js +0 -2
  84. package/dist/exports/client/RelationshipComponent-3QWBV4GT.js.map +0 -7
  85. package/dist/exports/client/chunk-TO2W7Q2G.js +0 -2
  86. package/dist/exports/client/component-3OFD6Q4Z.js +0 -2
  87. package/dist/exports/client/component-3OFD6Q4Z.js.map +0 -7
  88. /package/dist/exports/client/{chunk-OKMIHD2R.js.map → chunk-YL453UOS.js.map} +0 -0
  89. /package/dist/exports/client/{component-LCAAX56T.js.map → component-7RAP75FW.js.map} +0 -0
  90. /package/dist/exports/client/{componentInline-72VZAAHP.js.map → componentInline-YSHGRL2J.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAElB,8BAA8B,EAC/B,MAAM,YAAY,CAAA;AAoBnB,wBAAgB,aAAa,CAAC,KAAK,CAAC,EAAE,kBAAkB,GAAG,8BAA8B,CAuxBxF;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC1F,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,8CAA8C,CAAA;AAE/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AACrG,OAAO,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAErG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,2DAA2D,CAA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AAkB,EAClB,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEjE,mBAAmB,gBAAgB,CAAA;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AAExE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAE3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,4 @@
1
- import { fileURLToPath } from 'node:url';
2
- import path from 'path';
3
- import { afterChangeTraverseFields, afterReadTraverseFields, beforeChangeTraverseFields, beforeValidateTraverseFields, deepCopyObject, deepCopyObjectSimple, getDependencies, withNullableJSONSchemaType } from 'payload';
1
+ import { afterChangeTraverseFields, afterReadTraverseFields, beforeChangeTraverseFields, beforeValidateTraverseFields, checkDependencies, deepCopyObject, deepCopyObjectSimple, withNullableJSONSchemaType } from 'payload';
4
2
  import { i18n } from './i18n.js';
5
3
  import { defaultEditorConfig, defaultEditorFeatures } from './lexical/config/server/default.js';
6
4
  import { loadFeatures } from './lexical/config/server/loader.js';
@@ -11,28 +9,19 @@ import { getGenerateSchemaMap } from './utilities/generateSchemaMap.js';
11
9
  import { recurseNodeTree } from './utilities/recurseNodeTree.js';
12
10
  import { richTextValidateHOC } from './validate/index.js';
13
11
  let defaultSanitizedServerEditorConfig = null;
14
- const filename = fileURLToPath(import.meta.url);
15
- const dirname = path.dirname(filename);
16
12
  export function lexicalEditor(props) {
17
13
  return async ({
18
14
  config,
19
15
  isRoot
20
16
  }) => {
21
17
  if (process.env.NODE_ENV !== 'production' && process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true') {
22
- const resolvedDependencies = await getDependencies(dirname, ['lexical', '@lexical/headless', '@lexical/link', '@lexical/list', '@lexical/mark', '@lexical/markdown', '@lexical/react', '@lexical/rich-text', '@lexical/selection', '@lexical/utils']);
23
- // Go through each resolved dependency. If any dependency has a mismatching version, throw an error
24
- const foundVersions = {};
25
- for (const [_pkg, {
26
- version
27
- }] of resolvedDependencies.resolved) {
28
- if (!Object.keys(foundVersions).includes(version)) {
29
- foundVersions[version] = _pkg;
30
- }
31
- }
32
- if (Object.keys(foundVersions).length > 1) {
33
- const formattedVersionsWithPackageNameString = Object.entries(foundVersions).map(([version, pkg]) => `${pkg}@${version}`).join(', ');
34
- throw new Error(`Mismatching lexical dependency versions found: ${formattedVersionsWithPackageNameString}. All lexical and @lexical/* packages must have the same version. This is an error with your set-up, caused by you, not a bug in payload. Please go to your package.json and ensure all lexical and @lexical/* packages have the same version.`);
35
- }
18
+ await checkDependencies({
19
+ dependencyGroups: [{
20
+ name: 'lexical',
21
+ dependencies: ['lexical', '@lexical/headless', '@lexical/link', '@lexical/list', '@lexical/mark', '@lexical/markdown', '@lexical/react', '@lexical/rich-text', '@lexical/selection', '@lexical/utils'],
22
+ targetVersionDependency: 'lexical'
23
+ }]
24
+ });
36
25
  }
37
26
  let features = [];
38
27
  let resolvedFeatureMap;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fileURLToPath","path","afterChangeTraverseFields","afterReadTraverseFields","beforeChangeTraverseFields","beforeValidateTraverseFields","deepCopyObject","deepCopyObjectSimple","getDependencies","withNullableJSONSchemaType","i18n","defaultEditorConfig","defaultEditorFeatures","loadFeatures","sanitizeServerEditorConfig","sanitizeServerFeatures","populateLexicalPopulationPromises","getGenerateImportMap","getGenerateSchemaMap","recurseNodeTree","richTextValidateHOC","defaultSanitizedServerEditorConfig","filename","import","meta","url","dirname","lexicalEditor","props","config","isRoot","process","env","NODE_ENV","PAYLOAD_DISABLE_DEPENDENCY_CHECKER","resolvedDependencies","foundVersions","_pkg","version","resolved","Object","keys","includes","length","formattedVersionsWithPackageNameString","entries","map","pkg","join","Error","features","resolvedFeatureMap","finalSanitizedEditorConfig","lexical","rootEditor","editor","rootEditorFeatures","defaultFeatures","rootFeatures","unSanitizedEditorConfig","featureI18n","lang","general","CellComponent","clientProps","admin","lexicalEditorConfig","FieldComponent","editorConfig","generateComponentMap","serverProps","generateImportMap","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","size","editorPopulationPromises","hooks","afterChange","args","collection","_context","global","operation","schemaPath","value","hook","nodeHooks","getSubFields","nodeIDMap","originalNodeIDMap","internal","richText","nodes","root","children","id","node","afterChangeHooks","has","type","get","console","warn","originalNode","parentRichTextFieldPath","parentRichTextFieldSchemaPath","subFieldFn","subFieldDataFn","getSubFieldsData","subFields","data","originalData","doc","fields","previousDoc","previousSiblingDoc","siblingData","afterRead","fallbackLocale","locale","triggerAccessControl","triggerHooks","flattenedNodes","afterReadHooks","beforeChange","duplicate","errors","mergeLocaleActions","siblingDocWithLocales","skipValidation","originalNodeWithLocalesIDMap","name","beforeChangeHooks","originalNodeWithLocales","originalDataWithLocales","docWithLocales","newOriginalNodeIDMap","previousValue","beforeValidate","beforeValidateHooks","outputSchema","collectionIDFieldTypes","interfaceNameDefinitions","isRequired","properties","additionalProperties","items","required","direction","oneOf","enum","format","indent","modifyOutputSchema","generatedTypes","modifyOutputSchemas","currentSchema","validate","AlignFeature","BlockquoteFeature","BlocksFeature","LinebreakHTMLConverter","ParagraphHTMLConverter","TextHTMLConverter","defaultHTMLConverters","convertLexicalNodesToHTML","convertLexicalToHTML","consolidateHTMLConverters","lexicalHTML","HTMLConverterFeature","TestRecorderFeature","TreeViewFeature","EXPERIMENTAL_TableFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","AutoLinkNode","LinkNode","LinkFeature","ChecklistFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","RelationshipServerNode","FixedToolbarFeature","InlineToolbarFeature","createNode","UploadFeature","UploadServerNode","defaultEditorLexicalConfig","sortFeaturesForOptimalLoading","getEnabledNodes","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NON_BREAKING_SPACE","NodeFormat","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","sanitizeUrl","validateUrl","defaultRichTextValue","createServerFeature","upgradeLexicalData"],"sources":["../src/index.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type {\n EditorConfig as LexicalEditorConfig,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\n\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nimport {\n afterChangeTraverseFields,\n afterReadTraverseFields,\n beforeChangeTraverseFields,\n beforeValidateTraverseFields,\n deepCopyObject,\n deepCopyObjectSimple,\n getDependencies,\n withNullableJSONSchemaType,\n} from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n AdapterProps,\n LexicalEditorProps,\n LexicalRichTextAdapter,\n LexicalRichTextAdapterProvider,\n} from './types.js'\n\nimport { i18n } from './i18n.js'\nimport { defaultEditorConfig, defaultEditorFeatures } from './lexical/config/server/default.js'\nimport { loadFeatures } from './lexical/config/server/loader.js'\nimport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\nimport { populateLexicalPopulationPromises } from './populateGraphQL/populateLexicalPopulationPromises.js'\nimport { getGenerateImportMap } from './utilities/generateImportMap.js'\nimport { getGenerateSchemaMap } from './utilities/generateSchemaMap.js'\nimport { recurseNodeTree } from './utilities/recurseNodeTree.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nlet defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig = null\n\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\nexport function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapterProvider {\n return async ({ config, isRoot }) => {\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true'\n ) {\n const resolvedDependencies = await getDependencies(dirname, [\n 'lexical',\n '@lexical/headless',\n '@lexical/link',\n '@lexical/list',\n '@lexical/mark',\n '@lexical/markdown',\n '@lexical/react',\n '@lexical/rich-text',\n '@lexical/selection',\n '@lexical/utils',\n ])\n\n // Go through each resolved dependency. If any dependency has a mismatching version, throw an error\n const foundVersions: {\n [version: string]: string\n } = {}\n for (const [_pkg, { version }] of resolvedDependencies.resolved) {\n if (!Object.keys(foundVersions).includes(version)) {\n foundVersions[version] = _pkg\n }\n }\n if (Object.keys(foundVersions).length > 1) {\n const formattedVersionsWithPackageNameString = Object.entries(foundVersions)\n .map(([version, pkg]) => `${pkg}@${version}`)\n .join(', ')\n\n throw new Error(\n `Mismatching lexical dependency versions found: ${formattedVersionsWithPackageNameString}. All lexical and @lexical/* packages must have the same version. This is an error with your set-up, caused by you, not a bug in payload. Please go to your package.json and ensure all lexical and @lexical/* packages have the same version.`,\n )\n }\n }\n\n let features: FeatureProviderServer<any, any, any>[] = []\n let resolvedFeatureMap: ResolvedServerFeatureMap\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!props || (!props.features && !props.lexical)) {\n if (!defaultSanitizedServerEditorConfig) {\n defaultSanitizedServerEditorConfig = await sanitizeServerEditorConfig(\n defaultEditorConfig,\n config,\n )\n features = deepCopyObject(defaultEditorFeatures)\n }\n\n finalSanitizedEditorConfig = deepCopyObject(defaultSanitizedServerEditorConfig)\n\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n const rootEditor = config.editor\n let rootEditorFeatures: FeatureProviderServer<unknown, unknown, unknown>[] = []\n if (typeof rootEditor === 'object' && 'features' in rootEditor) {\n rootEditorFeatures = (rootEditor as LexicalRichTextAdapter).features\n }\n\n features =\n props.features && typeof props.features === 'function'\n ? props.features({\n defaultFeatures: deepCopyObject(defaultEditorFeatures),\n rootFeatures: rootEditorFeatures,\n })\n : (props.features as FeatureProviderServer<unknown, unknown, unknown>[])\n if (!features) {\n features = deepCopyObject(defaultEditorFeatures)\n }\n\n const lexical: LexicalEditorConfig =\n props.lexical ?? deepCopyObjectSimple(defaultEditorConfig.lexical)\n\n resolvedFeatureMap = await loadFeatures({\n config,\n isRoot,\n unSanitizedEditorConfig: {\n features,\n lexical,\n },\n })\n\n finalSanitizedEditorConfig = {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical,\n resolvedFeatureMap,\n }\n }\n\n const featureI18n = finalSanitizedEditorConfig.features.i18n\n for (const lang in i18n) {\n if (!featureI18n[lang]) {\n featureI18n[lang] = {\n lexical: {},\n }\n }\n\n featureI18n[lang].lexical.general = i18n[lang]\n }\n\n return {\n CellComponent: {\n clientProps: {\n admin: props?.admin,\n lexicalEditorConfig: finalSanitizedEditorConfig.lexical,\n },\n path: '@payloadcms/richtext-lexical/client#RichTextCell',\n },\n FieldComponent: {\n clientProps: {\n admin: props?.admin,\n lexicalEditorConfig: finalSanitizedEditorConfig.lexical,\n },\n path: '@payloadcms/richtext-lexical/client#RichTextField',\n },\n editorConfig: finalSanitizedEditorConfig,\n features,\n generateComponentMap: {\n path: '@payloadcms/richtext-lexical/generateComponentMap#getGenerateComponentMap',\n serverProps: {\n resolvedFeatureMap,\n },\n },\n generateImportMap: getGenerateImportMap({\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.graphQLPopulationPromises?.size) {\n populateLexicalPopulationPromises({\n context,\n currentDepth: currentDepth ?? 0,\n depth,\n draft,\n editorPopulationPromises: finalSanitizedEditorConfig.features.graphQLPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: {\n afterChange: [\n async (args) => {\n const { collection, context: _context, global, operation, path, req, schemaPath } = args\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.afterChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterChange) {\n value = await hook(args)\n }\n }\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.afterChange.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const afterChangeHooks = finalSanitizedEditorConfig.features.nodeHooks.afterChange\n if (afterChangeHooks?.has(node.type)) {\n for (const hook of afterChangeHooks.get(node.type)) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(afterChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n const originalData = subFieldDataFn({ node: originalNodeIDMap[id], req }) ?? {}\n\n if (subFields?.length) {\n await afterChangeTraverseFields({\n collection,\n context,\n data: originalData,\n doc: data,\n fields: subFields,\n global,\n operation,\n path,\n previousDoc: data,\n previousSiblingDoc: { ...data },\n req,\n schemaPath,\n siblingData: originalData || {},\n siblingDoc: { ...data },\n })\n }\n }\n }\n return value\n },\n ],\n afterRead: [\n /**\n * afterRead hooks do not receive the originalNode. Thus, they can run on all nodes, not just nodes with an ID.\n */\n async (args) => {\n const {\n collection,\n context: context,\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n triggerAccessControl,\n triggerHooks,\n } = args\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.afterRead?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterRead) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.afterRead.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n const flattenedNodes: SerializedLexicalNode[] = []\n\n recurseNodeTree({\n flattenedNodes,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n for (let node of flattenedNodes) {\n const afterReadHooks = finalSanitizedEditorConfig.features.nodeHooks.afterRead\n if (afterReadHooks?.has(node.type)) {\n for (const hook of afterReadHooks.get(node.type)) {\n node = await hook({\n context,\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n fieldPromises,\n findMany,\n flattenLocales,\n locale,\n node,\n overrideAccess,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n populationPromises,\n req,\n showHiddenFields,\n triggerAccessControl,\n triggerHooks,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n\n if (subFields?.length) {\n afterReadTraverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc: data,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: subFields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n siblingDoc: data,\n triggerAccessControl,\n triggerHooks,\n })\n }\n }\n }\n\n return value\n },\n ],\n beforeChange: [\n async (args) => {\n const {\n collection,\n context: _context,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n path,\n req,\n schemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n } = args\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeChange) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.beforeChange.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n const originalNodeWithLocalesIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (siblingDocWithLocales?.[field.name]) {\n recurseNodeTree({\n nodeIDMap: originalNodeWithLocalesIDMap,\n nodes:\n (siblingDocWithLocales[field.name] as SerializedEditorState)?.root?.children ??\n [],\n })\n }\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeChangeHooks = finalSanitizedEditorConfig.features.nodeHooks.beforeChange\n if (beforeChangeHooks?.has(node.type)) {\n for (const hook of beforeChangeHooks.get(node.type)) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n duplicate,\n errors,\n mergeLocaleActions,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n originalNodeWithLocales: originalNodeWithLocalesIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n skipValidation,\n })\n }\n }\n\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n const originalData = subFieldDataFn({ node: originalNodeIDMap[id], req }) ?? {}\n const originalDataWithLocales =\n subFieldDataFn({\n node: originalNodeWithLocalesIDMap[id],\n req,\n }) ?? {}\n\n if (subFields?.length) {\n await beforeChangeTraverseFields({\n id,\n collection,\n context,\n data,\n doc: originalData,\n docWithLocales: originalDataWithLocales ?? {},\n duplicate,\n errors,\n fields: subFields,\n global,\n mergeLocaleActions,\n operation,\n path,\n req,\n schemaPath,\n siblingData: data,\n siblingDoc: originalData,\n siblingDocWithLocales: originalDataWithLocales ?? {},\n skipValidation,\n })\n }\n }\n }\n\n /**\n * within the beforeChange hook, id's may be re-generated.\n * Example:\n * 1. Seed data contains IDs for block feature blocks.\n * 2. Those are used in beforeValidate\n * 3. in beforeChange, those IDs are regenerated, because you cannot provide IDs during document creation. See baseIDField beforeChange hook for reasoning\n * 4. Thus, in order for all post-beforeChange hooks to receive the correct ID, we need to update the originalNodeIDMap with the new ID's, by regenerating the nodeIDMap.\n * The reason this is not generated for every hook, is to save on performance. We know we only really have to generate it in beforeValidate, which is the first hook,\n * and in beforeChange, which is where modifications to the provided IDs can occur.\n */\n const newOriginalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const previousValue = siblingData[field.name]\n\n recurseNodeTree({\n nodeIDMap: newOriginalNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!context.internal.richText) {\n context.internal.richText = {}\n }\n context.internal.richText[path.join('.')] = {\n originalNodeIDMap: newOriginalNodeIDMap,\n }\n\n return value\n },\n ],\n beforeValidate: [\n async (args) => {\n const {\n collection,\n context,\n global,\n operation,\n overrideAccess,\n path,\n previousValue,\n req,\n schemaPath,\n } = args\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeValidate?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeValidate) {\n value = await hook(args)\n }\n }\n\n // return value if there are NO hooks\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.beforeValidate.size &&\n !finalSanitizedEditorConfig.features.nodeHooks.afterChange.size &&\n !finalSanitizedEditorConfig.features.nodeHooks.beforeChange.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n\n /**\n * beforeValidate is the first field hook which runs. This is where we can create the node map, which can then be used in the other hooks.\n *\n */\n\n /**\n * flattenedNodes contains all nodes in the editor, in the order they appear in the editor. They will be used for the following hooks:\n * - afterRead\n *\n * The other hooks require nodes to have IDs, which is why those are ran only from the nodeIDMap. They require IDs because they have both doc/siblingDoc and data/siblingData, and\n * thus require a reliable way to match new node data to old node data. Given that node positions can change in between hooks, this is only reliably possible for nodes which are saved with\n * an ID.\n */\n //const flattenedNodes: SerializedLexicalNode[] = []\n\n /**\n * Only nodes with id's (so, nodes with hooks added to them) will be added to the nodeIDMap. They will be used for the following hooks:\n * - afterChange\n * - beforeChange\n * - beforeValidate\n * - beforeDuplicate\n *\n * Other hooks are handled by the flattenedNodes. All nodes in the nodeIDMap are part of flattenedNodes.\n */\n\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap: originalNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!(context as any).internal.richText) {\n ;(context as any).internal.richText = {}\n }\n ;(context as any).internal.richText[path.join('.')] = {\n originalNodeIDMap,\n }\n\n /**\n * Now that the maps for all hooks are set up, we can run the validate hook\n */\n if (!finalSanitizedEditorConfig.features.nodeHooks.beforeValidate.size) {\n return value\n }\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n recurseNodeTree({\n //flattenedNodes,\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeValidateHooks =\n finalSanitizedEditorConfig.features.nodeHooks.beforeValidate\n if (beforeValidateHooks?.has(node.type)) {\n for (const hook of beforeValidateHooks.get(node.type)) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeValidate) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n overrideAccess,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n const originalData = subFieldDataFn({ node: originalNodeIDMap[id], req }) ?? {}\n\n if (subFields?.length) {\n await beforeValidateTraverseFields({\n id,\n collection,\n context,\n data,\n doc: originalData,\n fields: subFields,\n global,\n operation,\n overrideAccess,\n path,\n req,\n schemaPath,\n siblingData: data,\n siblingDoc: originalData,\n })\n }\n }\n }\n\n return value\n },\n ],\n },\n i18n: featureI18n,\n outputSchema: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let outputSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes\n .modifyOutputSchemas) {\n outputSchema = modifyOutputSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: outputSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return outputSchema\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n }\n}\n\nexport { AlignFeature } from './features/align/server/index.js'\nexport { BlockquoteFeature } from './features/blockquote/server/index.js'\nexport { BlocksFeature, type BlocksFeatureProps } from './features/blocks/server/index.js'\nexport { type BlockFields } from './features/blocks/server/nodes/BlocksNode.js'\n\nexport { LinebreakHTMLConverter } from './features/converters/html/converter/converters/linebreak.js'\nexport { ParagraphHTMLConverter } from './features/converters/html/converter/converters/paragraph.js'\n\nexport { TextHTMLConverter } from './features/converters/html/converter/converters/text.js'\nexport { defaultHTMLConverters } from './features/converters/html/converter/defaultConverters.js'\nexport {\n convertLexicalNodesToHTML,\n convertLexicalToHTML,\n} from './features/converters/html/converter/index.js'\n\nexport type { HTMLConverter } from './features/converters/html/converter/types.js'\nexport { consolidateHTMLConverters, lexicalHTML } from './features/converters/html/field/index.js'\nexport {\n HTMLConverterFeature,\n type HTMLConverterFeatureProps,\n} from './features/converters/html/index.js'\nexport { TestRecorderFeature } from './features/debug/testRecorder/server/index.js'\nexport { TreeViewFeature } from './features/debug/treeView/server/index.js'\nexport { EXPERIMENTAL_TableFeature } from './features/experimental_table/server/index.js'\nexport { BoldFeature } from './features/format/bold/feature.server.js'\nexport { InlineCodeFeature } from './features/format/inlineCode/feature.server.js'\nexport { ItalicFeature } from './features/format/italic/feature.server.js'\n\nexport { StrikethroughFeature } from './features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './features/format/underline/feature.server.js'\nexport { HeadingFeature, type HeadingFeatureProps } from './features/heading/server/index.js'\nexport { HorizontalRuleFeature } from './features/horizontalRule/server/index.js'\nexport { IndentFeature } from './features/indent/server/index.js'\n\nexport { AutoLinkNode } from './features/link/nodes/AutoLinkNode.js'\n\nexport { LinkNode } from './features/link/nodes/LinkNode.js'\nexport type { LinkFields } from './features/link/nodes/types.js'\nexport { LinkFeature, type LinkFeatureServerProps } from './features/link/server/index.js'\nexport { ChecklistFeature } from './features/lists/checklist/server/index.js'\nexport { OrderedListFeature } from './features/lists/orderedList/server/index.js'\nexport { UnorderedListFeature } from './features/lists/unorderedList/server/index.js'\n\nexport type {\n SlateNode,\n SlateNodeConverter,\n} from './features/migrations/slateToLexical/converter/types.js'\n\nexport { ParagraphFeature } from './features/paragraph/server/index.js'\nexport {\n RelationshipFeature,\n type RelationshipFeatureProps,\n} from './features/relationship/server/index.js'\nexport {\n type RelationshipData,\n RelationshipServerNode,\n} from './features/relationship/server/nodes/RelationshipNode.js'\n\nexport { FixedToolbarFeature } from './features/toolbars/fixed/server/index.js'\nexport { InlineToolbarFeature } from './features/toolbars/inline/server/index.js'\n\nexport type { ToolbarGroup, ToolbarGroupItem } from './features/toolbars/types.js'\nexport { createNode } from './features/typeUtilities.js' // Only useful in feature.server.ts\nexport type {\n ClientComponentProps,\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n PluginComponent,\n PluginComponentWithAnchor,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n} from './features/typesClient.js'\n\nexport type {\n AfterChangeNodeHook,\n AfterChangeNodeHookArgs,\n AfterReadNodeHook,\n AfterReadNodeHookArgs,\n BaseNodeHookArgs,\n BeforeChangeNodeHook,\n BeforeChangeNodeHookArgs,\n BeforeValidateNodeHook,\n BeforeValidateNodeHookArgs,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n NodeWithHooks,\n PopulationPromise,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './features/typesServer.js'\n\nexport { UploadFeature } from './features/upload/server/feature.server.js'\n\nexport type { UploadFeatureProps } from './features/upload/server/feature.server.js'\nexport { type UploadData, UploadServerNode } from './features/upload/server/nodes/UploadNode.js'\n\nexport type { EditorConfigContextType } from './lexical/config/client/EditorConfigProvider.js'\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n} from './lexical/config/server/default.js'\n\nexport { loadFeatures, sortFeaturesForOptimalLoading } from './lexical/config/server/loader.js'\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\n\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './lexical/config/types.js'\nexport { getEnabledNodes } from './lexical/nodes/index.js'\nexport type { AdapterProps }\n\nexport type {\n SlashMenuGroup,\n SlashMenuItem,\n} from './lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\n\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NON_BREAKING_SPACE,\n NodeFormat,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './lexical/utils/nodeFormat.js'\nexport { sanitizeUrl, validateUrl } from './lexical/utils/url.js'\n\nexport type * from './nodeTypes.js'\n\nexport { defaultRichTextValue } from './populateGraphQL/defaultValue.js'\n\nexport type { LexicalEditorProps, LexicalRichTextAdapter } from './types.js'\nexport { createServerFeature } from './utilities/createServerFeature.js'\nexport type { FieldsDrawerProps } from './utilities/fieldsDrawer/Drawer.js'\n\nexport { upgradeLexicalData } from './utilities/upgradeLexicalData/index.js'\n"],"mappings":"AAOA,SAASA,aAAa,QAAQ;AAC9B,OAAOC,IAAA,MAAU;AACjB,SACEC,yBAAyB,EACzBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,cAAc,EACdC,oBAAoB,EACpBC,eAAe,EACfC,0BAA0B,QACr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;AACjC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,oBAAoB,QAAQ;AAOrC,SAASC,gBAAgB,QAAQ;AACjC,SACEC,mBAAmB,QAEd;AACP,SAEEC,sBAAsB,QACjB;AAEP,SAASC,mBAAmB,QAAQ;AACpC,SAASC,oBAAoB,QAAQ;AAGrC,SAASC,UAAU,QAAQ,8BAA6B,CAAC;AAqCzD,SAASC,aAAa,QAAQ;AAG9B,SAA0BC,gBAAgB,QAAQ;AAGlD,SACEtM,mBAAmB,EACnBC,qBAAqB,EACrBsM,0BAA0B,QACrB;AAEP,SAASrM,YAAY,EAAEsM,6BAA6B,QAAQ;AAC5D,SACErM,0BAA0B,EAC1BC,sBAAsB,QACjB;AAQP,SAASqM,eAAe,QAAQ;AAQhC,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,SAAS,EACTC,kBAAkB,EAClBC,UAAU,EACVC,SAAS,EACTC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ;AACP,SAASC,WAAW,EAAEC,WAAW,QAAQ;AAIzC,SAASC,oBAAoB,QAAQ;AAGrC,SAASC,mBAAmB,QAAQ;AAGpC,SAASC,kBAAkB,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["afterChangeTraverseFields","afterReadTraverseFields","beforeChangeTraverseFields","beforeValidateTraverseFields","checkDependencies","deepCopyObject","deepCopyObjectSimple","withNullableJSONSchemaType","i18n","defaultEditorConfig","defaultEditorFeatures","loadFeatures","sanitizeServerEditorConfig","sanitizeServerFeatures","populateLexicalPopulationPromises","getGenerateImportMap","getGenerateSchemaMap","recurseNodeTree","richTextValidateHOC","defaultSanitizedServerEditorConfig","lexicalEditor","props","config","isRoot","process","env","NODE_ENV","PAYLOAD_DISABLE_DEPENDENCY_CHECKER","dependencyGroups","name","dependencies","targetVersionDependency","features","resolvedFeatureMap","finalSanitizedEditorConfig","lexical","rootEditor","editor","rootEditorFeatures","defaultFeatures","rootFeatures","unSanitizedEditorConfig","featureI18n","lang","general","CellComponent","clientProps","admin","lexicalEditorConfig","path","FieldComponent","editorConfig","generateComponentMap","serverProps","generateImportMap","generateSchemaMap","graphQLPopulationPromises","context","currentDepth","depth","draft","field","fieldPromises","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","size","editorPopulationPromises","hooks","afterChange","args","collection","_context","global","operation","schemaPath","value","length","hook","nodeHooks","getSubFields","nodeIDMap","originalNodeIDMap","internal","richText","join","Object","keys","nodes","root","children","id","node","entries","afterChangeHooks","has","type","get","console","warn","originalNode","parentRichTextFieldPath","parentRichTextFieldSchemaPath","subFieldFn","subFieldDataFn","getSubFieldsData","subFields","data","originalData","doc","fields","previousDoc","previousSiblingDoc","siblingData","afterRead","fallbackLocale","locale","triggerAccessControl","triggerHooks","flattenedNodes","afterReadHooks","beforeChange","duplicate","errors","mergeLocaleActions","siblingDocWithLocales","skipValidation","originalNodeWithLocalesIDMap","beforeChangeHooks","originalNodeWithLocales","originalDataWithLocales","docWithLocales","newOriginalNodeIDMap","previousValue","beforeValidate","beforeValidateHooks","outputSchema","collectionIDFieldTypes","interfaceNameDefinitions","isRequired","properties","additionalProperties","items","version","required","direction","oneOf","enum","format","indent","modifyOutputSchema","generatedTypes","modifyOutputSchemas","currentSchema","validate","AlignFeature","BlockquoteFeature","BlocksFeature","LinebreakHTMLConverter","ParagraphHTMLConverter","TextHTMLConverter","defaultHTMLConverters","convertLexicalNodesToHTML","convertLexicalToHTML","consolidateHTMLConverters","lexicalHTML","HTMLConverterFeature","TestRecorderFeature","TreeViewFeature","EXPERIMENTAL_TableFeature","BoldFeature","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","HorizontalRuleFeature","IndentFeature","AutoLinkNode","LinkNode","LinkFeature","ChecklistFeature","OrderedListFeature","UnorderedListFeature","ParagraphFeature","RelationshipFeature","RelationshipServerNode","FixedToolbarFeature","InlineToolbarFeature","createNode","UploadFeature","UploadServerNode","defaultEditorLexicalConfig","sortFeaturesForOptimalLoading","getEnabledNodes","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NON_BREAKING_SPACE","NodeFormat","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","sanitizeUrl","validateUrl","defaultRichTextValue","createServerFeature","upgradeLexicalData"],"sources":["../src/index.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type {\n EditorConfig as LexicalEditorConfig,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\n\nimport {\n afterChangeTraverseFields,\n afterReadTraverseFields,\n beforeChangeTraverseFields,\n beforeValidateTraverseFields,\n checkDependencies,\n deepCopyObject,\n deepCopyObjectSimple,\n withNullableJSONSchemaType,\n} from 'payload'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n AdapterProps,\n LexicalEditorProps,\n LexicalRichTextAdapter,\n LexicalRichTextAdapterProvider,\n} from './types.js'\n\nimport { i18n } from './i18n.js'\nimport { defaultEditorConfig, defaultEditorFeatures } from './lexical/config/server/default.js'\nimport { loadFeatures } from './lexical/config/server/loader.js'\nimport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\nimport { populateLexicalPopulationPromises } from './populateGraphQL/populateLexicalPopulationPromises.js'\nimport { getGenerateImportMap } from './utilities/generateImportMap.js'\nimport { getGenerateSchemaMap } from './utilities/generateSchemaMap.js'\nimport { recurseNodeTree } from './utilities/recurseNodeTree.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nlet defaultSanitizedServerEditorConfig: SanitizedServerEditorConfig = null\n\nexport function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapterProvider {\n return async ({ config, isRoot }) => {\n if (\n process.env.NODE_ENV !== 'production' &&\n process.env.PAYLOAD_DISABLE_DEPENDENCY_CHECKER !== 'true'\n ) {\n await checkDependencies({\n dependencyGroups: [\n {\n name: 'lexical',\n dependencies: [\n 'lexical',\n '@lexical/headless',\n '@lexical/link',\n '@lexical/list',\n '@lexical/mark',\n '@lexical/markdown',\n '@lexical/react',\n '@lexical/rich-text',\n '@lexical/selection',\n '@lexical/utils',\n ],\n targetVersionDependency: 'lexical',\n },\n ],\n })\n }\n\n let features: FeatureProviderServer<any, any, any>[] = []\n let resolvedFeatureMap: ResolvedServerFeatureMap\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!props || (!props.features && !props.lexical)) {\n if (!defaultSanitizedServerEditorConfig) {\n defaultSanitizedServerEditorConfig = await sanitizeServerEditorConfig(\n defaultEditorConfig,\n config,\n )\n features = deepCopyObject(defaultEditorFeatures)\n }\n\n finalSanitizedEditorConfig = deepCopyObject(defaultSanitizedServerEditorConfig)\n\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n const rootEditor = config.editor\n let rootEditorFeatures: FeatureProviderServer<unknown, unknown, unknown>[] = []\n if (typeof rootEditor === 'object' && 'features' in rootEditor) {\n rootEditorFeatures = (rootEditor as LexicalRichTextAdapter).features\n }\n\n features =\n props.features && typeof props.features === 'function'\n ? props.features({\n defaultFeatures: deepCopyObject(defaultEditorFeatures),\n rootFeatures: rootEditorFeatures,\n })\n : (props.features as FeatureProviderServer<unknown, unknown, unknown>[])\n if (!features) {\n features = deepCopyObject(defaultEditorFeatures)\n }\n\n const lexical: LexicalEditorConfig =\n props.lexical ?? deepCopyObjectSimple(defaultEditorConfig.lexical)\n\n resolvedFeatureMap = await loadFeatures({\n config,\n isRoot,\n unSanitizedEditorConfig: {\n features,\n lexical,\n },\n })\n\n finalSanitizedEditorConfig = {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical,\n resolvedFeatureMap,\n }\n }\n\n const featureI18n = finalSanitizedEditorConfig.features.i18n\n for (const lang in i18n) {\n if (!featureI18n[lang]) {\n featureI18n[lang] = {\n lexical: {},\n }\n }\n\n featureI18n[lang].lexical.general = i18n[lang]\n }\n\n return {\n CellComponent: {\n clientProps: {\n admin: props?.admin,\n lexicalEditorConfig: finalSanitizedEditorConfig.lexical,\n },\n path: '@payloadcms/richtext-lexical/client#RichTextCell',\n },\n FieldComponent: {\n clientProps: {\n admin: props?.admin,\n lexicalEditorConfig: finalSanitizedEditorConfig.lexical,\n },\n path: '@payloadcms/richtext-lexical/client#RichTextField',\n },\n editorConfig: finalSanitizedEditorConfig,\n features,\n generateComponentMap: {\n path: '@payloadcms/richtext-lexical/generateComponentMap#getGenerateComponentMap',\n serverProps: {\n resolvedFeatureMap,\n },\n },\n generateImportMap: getGenerateImportMap({\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n graphQLPopulationPromises({\n context,\n currentDepth,\n depth,\n draft,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.graphQLPopulationPromises?.size) {\n populateLexicalPopulationPromises({\n context,\n currentDepth: currentDepth ?? 0,\n depth,\n draft,\n editorPopulationPromises: finalSanitizedEditorConfig.features.graphQLPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n },\n hooks: {\n afterChange: [\n async (args) => {\n const { collection, context: _context, global, operation, path, req, schemaPath } = args\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.afterChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterChange) {\n value = await hook(args)\n }\n }\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.afterChange.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const afterChangeHooks = finalSanitizedEditorConfig.features.nodeHooks.afterChange\n if (afterChangeHooks?.has(node.type)) {\n for (const hook of afterChangeHooks.get(node.type)) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(afterChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n const originalData = subFieldDataFn({ node: originalNodeIDMap[id], req }) ?? {}\n\n if (subFields?.length) {\n await afterChangeTraverseFields({\n collection,\n context,\n data: originalData,\n doc: data,\n fields: subFields,\n global,\n operation,\n path,\n previousDoc: data,\n previousSiblingDoc: { ...data },\n req,\n schemaPath,\n siblingData: originalData || {},\n siblingDoc: { ...data },\n })\n }\n }\n }\n return value\n },\n ],\n afterRead: [\n /**\n * afterRead hooks do not receive the originalNode. Thus, they can run on all nodes, not just nodes with an ID.\n */\n async (args) => {\n const {\n collection,\n context: context,\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n triggerAccessControl,\n triggerHooks,\n } = args\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.afterRead?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.afterRead) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.afterRead.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n const flattenedNodes: SerializedLexicalNode[] = []\n\n recurseNodeTree({\n flattenedNodes,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n for (let node of flattenedNodes) {\n const afterReadHooks = finalSanitizedEditorConfig.features.nodeHooks.afterRead\n if (afterReadHooks?.has(node.type)) {\n for (const hook of afterReadHooks.get(node.type)) {\n node = await hook({\n context,\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n fieldPromises,\n findMany,\n flattenLocales,\n locale,\n node,\n overrideAccess,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n populationPromises,\n req,\n showHiddenFields,\n triggerAccessControl,\n triggerHooks,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n\n if (subFields?.length) {\n afterReadTraverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc: data,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: subFields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n siblingDoc: data,\n triggerAccessControl,\n triggerHooks,\n })\n }\n }\n }\n\n return value\n },\n ],\n beforeChange: [\n async (args) => {\n const {\n collection,\n context: _context,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n path,\n req,\n schemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n } = args\n let { value } = args\n\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeChange?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeChange) {\n value = await hook(args)\n }\n }\n\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.beforeChange.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n\n const context: any = _context\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n /**\n * Get the originalNodeIDMap from the beforeValidate hook, which is always run before this hook.\n */\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = context?.internal?.richText?.[path.join('.')]?.originalNodeIDMap\n\n if (!originalNodeIDMap || !Object.keys(originalNodeIDMap).length || !value) {\n return value\n }\n\n const originalNodeWithLocalesIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (siblingDocWithLocales?.[field.name]) {\n recurseNodeTree({\n nodeIDMap: originalNodeWithLocalesIDMap,\n nodes:\n (siblingDocWithLocales[field.name] as SerializedEditorState)?.root?.children ??\n [],\n })\n }\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeChangeHooks = finalSanitizedEditorConfig.features.nodeHooks.beforeChange\n if (beforeChangeHooks?.has(node.type)) {\n for (const hook of beforeChangeHooks.get(node.type)) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeChange) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n duplicate,\n errors,\n mergeLocaleActions,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n originalNodeWithLocales: originalNodeWithLocalesIDMap[id],\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n skipValidation,\n })\n }\n }\n\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n const originalData = subFieldDataFn({ node: originalNodeIDMap[id], req }) ?? {}\n const originalDataWithLocales =\n subFieldDataFn({\n node: originalNodeWithLocalesIDMap[id],\n req,\n }) ?? {}\n\n if (subFields?.length) {\n await beforeChangeTraverseFields({\n id,\n collection,\n context,\n data,\n doc: originalData,\n docWithLocales: originalDataWithLocales ?? {},\n duplicate,\n errors,\n fields: subFields,\n global,\n mergeLocaleActions,\n operation,\n path,\n req,\n schemaPath,\n siblingData: data,\n siblingDoc: originalData,\n siblingDocWithLocales: originalDataWithLocales ?? {},\n skipValidation,\n })\n }\n }\n }\n\n /**\n * within the beforeChange hook, id's may be re-generated.\n * Example:\n * 1. Seed data contains IDs for block feature blocks.\n * 2. Those are used in beforeValidate\n * 3. in beforeChange, those IDs are regenerated, because you cannot provide IDs during document creation. See baseIDField beforeChange hook for reasoning\n * 4. Thus, in order for all post-beforeChange hooks to receive the correct ID, we need to update the originalNodeIDMap with the new ID's, by regenerating the nodeIDMap.\n * The reason this is not generated for every hook, is to save on performance. We know we only really have to generate it in beforeValidate, which is the first hook,\n * and in beforeChange, which is where modifications to the provided IDs can occur.\n */\n const newOriginalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n const previousValue = siblingData[field.name]\n\n recurseNodeTree({\n nodeIDMap: newOriginalNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!context.internal.richText) {\n context.internal.richText = {}\n }\n context.internal.richText[path.join('.')] = {\n originalNodeIDMap: newOriginalNodeIDMap,\n }\n\n return value\n },\n ],\n beforeValidate: [\n async (args) => {\n const {\n collection,\n context,\n global,\n operation,\n overrideAccess,\n path,\n previousValue,\n req,\n schemaPath,\n } = args\n let { value } = args\n if (finalSanitizedEditorConfig?.features?.hooks?.beforeValidate?.length) {\n for (const hook of finalSanitizedEditorConfig.features.hooks.beforeValidate) {\n value = await hook(args)\n }\n }\n\n // return value if there are NO hooks\n if (\n !finalSanitizedEditorConfig.features.nodeHooks.beforeValidate.size &&\n !finalSanitizedEditorConfig.features.nodeHooks.afterChange.size &&\n !finalSanitizedEditorConfig.features.nodeHooks.beforeChange.size &&\n !finalSanitizedEditorConfig.features.getSubFields.size\n ) {\n return value\n }\n\n /**\n * beforeValidate is the first field hook which runs. This is where we can create the node map, which can then be used in the other hooks.\n *\n */\n\n /**\n * flattenedNodes contains all nodes in the editor, in the order they appear in the editor. They will be used for the following hooks:\n * - afterRead\n *\n * The other hooks require nodes to have IDs, which is why those are ran only from the nodeIDMap. They require IDs because they have both doc/siblingDoc and data/siblingData, and\n * thus require a reliable way to match new node data to old node data. Given that node positions can change in between hooks, this is only reliably possible for nodes which are saved with\n * an ID.\n */\n //const flattenedNodes: SerializedLexicalNode[] = []\n\n /**\n * Only nodes with id's (so, nodes with hooks added to them) will be added to the nodeIDMap. They will be used for the following hooks:\n * - afterChange\n * - beforeChange\n * - beforeValidate\n * - beforeDuplicate\n *\n * Other hooks are handled by the flattenedNodes. All nodes in the nodeIDMap are part of flattenedNodes.\n */\n\n const originalNodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n\n recurseNodeTree({\n nodeIDMap: originalNodeIDMap,\n nodes: (previousValue as SerializedEditorState)?.root?.children ?? [],\n })\n\n if (!context.internal) {\n // Add to context, for other hooks to use\n context.internal = {}\n }\n if (!(context as any).internal.richText) {\n ;(context as any).internal.richText = {}\n }\n ;(context as any).internal.richText[path.join('.')] = {\n originalNodeIDMap,\n }\n\n /**\n * Now that the maps for all hooks are set up, we can run the validate hook\n */\n if (!finalSanitizedEditorConfig.features.nodeHooks.beforeValidate.size) {\n return value\n }\n const nodeIDMap: {\n [key: string]: SerializedLexicalNode\n } = {}\n recurseNodeTree({\n //flattenedNodes,\n nodeIDMap,\n nodes: (value as SerializedEditorState)?.root?.children ?? [],\n })\n\n // eslint-disable-next-line prefer-const\n for (let [id, node] of Object.entries(nodeIDMap)) {\n const beforeValidateHooks =\n finalSanitizedEditorConfig.features.nodeHooks.beforeValidate\n if (beforeValidateHooks?.has(node.type)) {\n for (const hook of beforeValidateHooks.get(node.type)) {\n if (!originalNodeIDMap[id]) {\n console.warn(\n '(beforeValidate) No original node found for node with id',\n id,\n 'node:',\n node,\n 'path',\n path.join('.'),\n )\n continue\n }\n node = await hook({\n context,\n node,\n operation,\n originalNode: originalNodeIDMap[id],\n overrideAccess,\n parentRichTextFieldPath: path,\n parentRichTextFieldSchemaPath: schemaPath,\n req,\n })\n }\n }\n const subFieldFn = finalSanitizedEditorConfig.features.getSubFields.get(node.type)\n const subFieldDataFn = finalSanitizedEditorConfig.features.getSubFieldsData.get(\n node.type,\n )\n\n if (subFieldFn) {\n const subFields = subFieldFn({ node, req })\n const data = subFieldDataFn({ node, req }) ?? {}\n const originalData = subFieldDataFn({ node: originalNodeIDMap[id], req }) ?? {}\n\n if (subFields?.length) {\n await beforeValidateTraverseFields({\n id,\n collection,\n context,\n data,\n doc: originalData,\n fields: subFields,\n global,\n operation,\n overrideAccess,\n path,\n req,\n schemaPath,\n siblingData: data,\n siblingDoc: originalData,\n })\n }\n }\n }\n\n return value\n },\n ],\n },\n i18n: featureI18n,\n outputSchema: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let outputSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes\n .modifyOutputSchemas) {\n outputSchema = modifyOutputSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: outputSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return outputSchema\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n }\n}\n\nexport { AlignFeature } from './features/align/server/index.js'\nexport { BlockquoteFeature } from './features/blockquote/server/index.js'\nexport { BlocksFeature, type BlocksFeatureProps } from './features/blocks/server/index.js'\nexport { type BlockFields } from './features/blocks/server/nodes/BlocksNode.js'\n\nexport { LinebreakHTMLConverter } from './features/converters/html/converter/converters/linebreak.js'\nexport { ParagraphHTMLConverter } from './features/converters/html/converter/converters/paragraph.js'\n\nexport { TextHTMLConverter } from './features/converters/html/converter/converters/text.js'\nexport { defaultHTMLConverters } from './features/converters/html/converter/defaultConverters.js'\nexport {\n convertLexicalNodesToHTML,\n convertLexicalToHTML,\n} from './features/converters/html/converter/index.js'\n\nexport type { HTMLConverter } from './features/converters/html/converter/types.js'\nexport { consolidateHTMLConverters, lexicalHTML } from './features/converters/html/field/index.js'\nexport {\n HTMLConverterFeature,\n type HTMLConverterFeatureProps,\n} from './features/converters/html/index.js'\nexport { TestRecorderFeature } from './features/debug/testRecorder/server/index.js'\nexport { TreeViewFeature } from './features/debug/treeView/server/index.js'\nexport { EXPERIMENTAL_TableFeature } from './features/experimental_table/server/index.js'\nexport { BoldFeature } from './features/format/bold/feature.server.js'\nexport { InlineCodeFeature } from './features/format/inlineCode/feature.server.js'\nexport { ItalicFeature } from './features/format/italic/feature.server.js'\n\nexport { StrikethroughFeature } from './features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './features/format/underline/feature.server.js'\nexport { HeadingFeature, type HeadingFeatureProps } from './features/heading/server/index.js'\nexport { HorizontalRuleFeature } from './features/horizontalRule/server/index.js'\nexport { IndentFeature } from './features/indent/server/index.js'\n\nexport { AutoLinkNode } from './features/link/nodes/AutoLinkNode.js'\n\nexport { LinkNode } from './features/link/nodes/LinkNode.js'\nexport type { LinkFields } from './features/link/nodes/types.js'\nexport { LinkFeature, type LinkFeatureServerProps } from './features/link/server/index.js'\nexport { ChecklistFeature } from './features/lists/checklist/server/index.js'\nexport { OrderedListFeature } from './features/lists/orderedList/server/index.js'\nexport { UnorderedListFeature } from './features/lists/unorderedList/server/index.js'\n\nexport type {\n SlateNode,\n SlateNodeConverter,\n} from './features/migrations/slateToLexical/converter/types.js'\n\nexport { ParagraphFeature } from './features/paragraph/server/index.js'\nexport {\n RelationshipFeature,\n type RelationshipFeatureProps,\n} from './features/relationship/server/index.js'\nexport {\n type RelationshipData,\n RelationshipServerNode,\n} from './features/relationship/server/nodes/RelationshipNode.js'\n\nexport { FixedToolbarFeature } from './features/toolbars/fixed/server/index.js'\nexport { InlineToolbarFeature } from './features/toolbars/inline/server/index.js'\n\nexport type { ToolbarGroup, ToolbarGroupItem } from './features/toolbars/types.js'\nexport { createNode } from './features/typeUtilities.js' // Only useful in feature.server.ts\nexport type {\n ClientComponentProps,\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n PluginComponent,\n PluginComponentWithAnchor,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n} from './features/typesClient.js'\n\nexport type {\n AfterChangeNodeHook,\n AfterChangeNodeHookArgs,\n AfterReadNodeHook,\n AfterReadNodeHookArgs,\n BaseNodeHookArgs,\n BeforeChangeNodeHook,\n BeforeChangeNodeHookArgs,\n BeforeValidateNodeHook,\n BeforeValidateNodeHookArgs,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n NodeWithHooks,\n PopulationPromise,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './features/typesServer.js'\n\nexport { UploadFeature } from './features/upload/server/feature.server.js'\n\nexport type { UploadFeatureProps } from './features/upload/server/feature.server.js'\nexport { type UploadData, UploadServerNode } from './features/upload/server/nodes/UploadNode.js'\n\nexport type { EditorConfigContextType } from './lexical/config/client/EditorConfigProvider.js'\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n} from './lexical/config/server/default.js'\n\nexport { loadFeatures, sortFeaturesForOptimalLoading } from './lexical/config/server/loader.js'\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './lexical/config/server/sanitize.js'\n\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './lexical/config/types.js'\nexport { getEnabledNodes } from './lexical/nodes/index.js'\nexport type { AdapterProps }\n\nexport type {\n SlashMenuGroup,\n SlashMenuItem,\n} from './lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\n\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NON_BREAKING_SPACE,\n NodeFormat,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './lexical/utils/nodeFormat.js'\nexport { sanitizeUrl, validateUrl } from './lexical/utils/url.js'\n\nexport type * from './nodeTypes.js'\n\nexport { defaultRichTextValue } from './populateGraphQL/defaultValue.js'\n\nexport type { LexicalEditorProps, LexicalRichTextAdapter } from './types.js'\nexport { createServerFeature } from './utilities/createServerFeature.js'\nexport type { FieldsDrawerProps } from './utilities/fieldsDrawer/Drawer.js'\n\nexport { upgradeLexicalData } from './utilities/upgradeLexicalData/index.js'\n"],"mappings":"AAOA,SACEA,yBAAyB,EACzBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,iBAAiB,EACjBC,cAAc,EACdC,oBAAoB,EACpBC,0BAA0B,QACrB;AAWP,SAASC,IAAI,QAAQ;AACrB,SAASC,mBAAmB,EAAEC,qBAAqB,QAAQ;AAC3D,SAASC,YAAY,QAAQ;AAC7B,SACEC,0BAA0B,EAC1BC,sBAAsB,QACjB;AACP,SAASC,iCAAiC,QAAQ;AAClD,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AACrC,SAASC,eAAe,QAAQ;AAChC,SAASC,mBAAmB,QAAQ;AAEpC,IAAIC,kCAAA,GAAkE;AAEtE,OAAO,SAASC,cAAcC,KAA0B;EACtD,OAAO,OAAO;IAAEC,MAAM;IAAEC;EAAM,CAAE;IAC9B,IACEC,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,gBACzBF,OAAA,CAAQC,GAAG,CAACE,kCAAkC,KAAK,QACnD;MACA,MAAMvB,iBAAA,CAAkB;QACtBwB,gBAAA,EAAkB,CAChB;UACEC,IAAA,EAAM;UACNC,YAAA,EAAc,CACZ,WACA,qBACA,iBACA,iBACA,iBACA,qBACA,k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mB,QAEd;AACP,SAEEC,sBAAsB,QACjB;AAEP,SAASC,mBAAmB,QAAQ;AACpC,SAASC,oBAAoB,QAAQ;AAGrC,SAASC,UAAU,QAAQ,8BAA6B,CAAC;AAqCzD,SAASC,aAAa,QAAQ;AAG9B,SAA0BC,gBAAgB,QAAQ;AAGlD,SACE5L,mBAAmB,EACnBC,qBAAqB,EACrB4L,0BAA0B,QACrB;AAEP,SAAS3L,YAAY,EAAE4L,6BAA6B,QAAQ;AAC5D,SACE3L,0BAA0B,EAC1BC,sBAAsB,QACjB;AAQP,SAAS2L,eAAe,QAAQ;AAQhC,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,SAAS,EACTC,kBAAkB,EAClBC,UAAU,EACVC,SAAS,EACTC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ;AACP,SAASC,WAAW,EAAEC,WAAW,QAAQ;AAIzC,SAASC,oBAAoB,QAAQ;AAGrC,SAASC,mBAAmB,QAAQ;AAGpC,SAASC,kBAAkB,QAAQ","ignoreList":[]}
@@ -81,7 +81,7 @@ export const EditorConfigProvider = ({
81
81
  export const useEditorConfigContext = () => {
82
82
  const context = useContext(Context);
83
83
  if (context === undefined) {
84
- throw new Error("useEditorConfigContext must be used within an EditorConfigProvider");
84
+ throw new Error('useEditorConfigContext must be used within an EditorConfigProvider');
85
85
  }
86
86
  return context;
87
87
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EditorConfigProvider.js","names":["useLexicalComposerContext","React","createContext","useContext","useMemo","useRef","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","editorContainerRef","parentContext","editor","childrenEditors","Map","focusedEditor","setFocusedEditor","focusHistory","Set","editorContext","blurEditor","current","clear","focusEditor","editorUUID","has","add","forEach","childEditor","childUUID","parentEditor","registerChild","childEditorContext","newMap","set","unregisterChild","delete","_jsx","Provider","value","useEditorConfigContext","context","undefined","Error"],"sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { LexicalEditor } from 'lexical'\nimport type { RichTextFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport * as React from 'react'\nimport { createContext, useContext, useMemo, useRef, useState } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n focusedEditor: EditorConfigContextType | null\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n field,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n editor,\n editorConfig,\n editorContainerRef,\n field,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor, childUUID) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n focusedEditor,\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n field,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AACvB,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAKrE;AACA,SAASC,kBAAA;EACP,OAAOC,IAAA,CAAKC,MAAM,GAAGC,QAAQ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L,WAAW,CAACJ,eAAA;MAC1B;MAEAF,YAAA,CAAaI,OAAO,CAACC,KAAK;IAC5B;IACAP,aAAA;IACAe,YAAA,EAAcnB,aAAA;IACdoB,aAAA,EAAeA,CAACF,WAAA,EAAWG,kBAAA;MACzB,IAAI,CAACnB,eAAA,CAAgBQ,OAAO,CAACI,GAAG,CAACI,WAAA,GAAY;QAC3C,MAAMI,MAAA,GAAS,IAAInB,GAAA,CAAID,eAAA,CAAgBQ,OAAO;QAC9CY,MAAA,CAAOC,GAAG,CAACL,WAAA,EAAWG,kBAAA;QACtBnB,eAAA,CAAgBQ,OAAO,GAAGY,MAAA;MAC5B;IACF;IACAE,eAAA,EAAkBN,WAAA;MAChB,IAAIhB,eAAA,CAAgBQ,OAAO,CAACI,GAAG,CAACI,WAAA,GAAY;QAC1C,MAAMI,QAAA,GAAS,IAAInB,GAAA,CAAID,eAAA,CAAgBQ,OAAO;QAC9CY,QAAA,CAAOG,MAAM,CAACP,WAAA;QACdhB,eAAA,CAAgBQ,OAAO,GAAGY,QAAA;MAC5B;IACF;IAEA1B;EACF,IACF,CACEK,MAAA,EACAC,eAAA,EACAR,YAAA,EACAK,kBAAA,EACAJ,KAAA,EACAS,aAAA,EACAJ,aAAA,EACAJ,IAAA,CACD;EAGH,oBAAO8B,IAAA,CAACjC,OAAA,CAAQkC,QAAQ;IAACC,KAAA,EAAOpB,eAAA;cAAgBV;;AAClD;AAEA,OAAO,MAAM+B,sBAAA,GAAyBA,CAAA;EACpC,MAAAC,OAAA,GAAgB9C,UAAA,CAAAS,OAAW;EAAA,IACvBqC,OAAA,KAAAC,SAAY;IAAA,UAAAC,KAAA,CACE;EAAA;EAAA,OAEXF,OAAA;AAAA,CACT","ignoreList":[]}
1
+ {"version":3,"file":"EditorConfigProvider.js","names":["useLexicalComposerContext","React","createContext","useContext","useMemo","useRef","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","editorContainerRef","parentContext","editor","childrenEditors","Map","focusedEditor","setFocusedEditor","focusHistory","Set","editorContext","blurEditor","current","clear","focusEditor","editorUUID","has","add","forEach","childEditor","childUUID","parentEditor","registerChild","childEditorContext","newMap","set","unregisterChild","delete","_jsx","Provider","value","useEditorConfigContext","context","undefined","Error"],"sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { LexicalEditor } from 'lexical'\nimport type { RichTextFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport * as React from 'react'\nimport { createContext, useContext, useMemo, useRef, useState } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n focusedEditor: EditorConfigContextType | null\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n field,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n field: LexicalRichTextFieldProps['field']\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n editor,\n editorConfig,\n editorContainerRef,\n field,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor, childUUID) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n focusedEditor,\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n field,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,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]}
@@ -300,122 +300,84 @@ export function LexicalMenu({
300
300
  return menuRenderFn(anchorElementRef, listItemProps, resolution.match ? resolution.match.matchingString : '');
301
301
  }
302
302
  export function useMenuAnchorRef(anchorElem, resolution, setResolution, className) {
303
- const $ = _c(14);
304
303
  const [editor] = useLexicalComposerContext();
305
- let t0;
306
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
307
- t0 = document.createElement("div");
308
- $[0] = t0;
309
- } else {
310
- t0 = $[0];
311
- }
312
- const anchorElementRef = useRef(t0);
313
- let t1;
314
- if ($[1] !== editor || $[2] !== resolution || $[3] !== anchorElem || $[4] !== className) {
315
- t1 = () => {
316
- const rootElement = editor.getRootElement();
317
- const containerDiv = anchorElementRef.current;
318
- const menuEle = containerDiv.firstChild;
319
- if (rootElement !== null && resolution !== null) {
320
- const {
321
- height,
322
- width
323
- } = resolution.getRect();
324
- let {
325
- left,
326
- top
327
- } = resolution.getRect();
328
- const rawTop = top;
329
- top = top - (anchorElem.getBoundingClientRect().top + window.scrollY);
330
- left = left - (anchorElem.getBoundingClientRect().left + window.scrollX);
331
- containerDiv.style.left = `${left + window.scrollX}px`;
332
- containerDiv.style.height = `${height}px`;
333
- containerDiv.style.width = `${width}px`;
334
- if (menuEle !== null) {
335
- const menuRect = menuEle.getBoundingClientRect();
336
- const menuHeight = menuRect.height;
337
- const menuWidth = menuRect.width;
338
- const rootElementRect = rootElement.getBoundingClientRect();
339
- if (left + menuWidth > rootElementRect.right) {
340
- containerDiv.style.left = `${rootElementRect.right - menuWidth + window.scrollX}px`;
341
- }
342
- const wouldGoOffBottomOfScreen = rawTop + menuHeight + 32 > window.innerHeight;
343
- const wouldGoOffTopOfScreen = rawTop < 0;
344
- if (wouldGoOffBottomOfScreen && !wouldGoOffTopOfScreen) {
345
- containerDiv.style.top = `${top + 32 - menuHeight + window.scrollY - (height + 24)}px`;
346
- } else {
347
- containerDiv.style.top = `${top + window.scrollY + 32}px`;
348
- }
304
+ const anchorElementRef = useRef(document.createElement('div'));
305
+ const positionMenu = useCallback(() => {
306
+ const rootElement = editor.getRootElement();
307
+ const containerDiv = anchorElementRef.current;
308
+ const VERTICAL_OFFSET = 32;
309
+ const menuEle = containerDiv.firstChild;
310
+ if (rootElement !== null && resolution !== null) {
311
+ const {
312
+ height,
313
+ width
314
+ } = resolution.getRect();
315
+ let {
316
+ left,
317
+ top
318
+ } = resolution.getRect();
319
+ const rawTop = top;
320
+ top -= anchorElem.getBoundingClientRect().top + window.scrollY;
321
+ left -= anchorElem.getBoundingClientRect().left + window.scrollX;
322
+ containerDiv.style.left = `${left + window.scrollX}px`;
323
+ containerDiv.style.height = `${height}px`;
324
+ containerDiv.style.width = `${width}px`;
325
+ if (menuEle !== null) {
326
+ const menuRect = menuEle.getBoundingClientRect();
327
+ const menuHeight = menuRect.height;
328
+ const menuWidth = menuRect.width;
329
+ const rootElementRect = rootElement.getBoundingClientRect();
330
+ if (left + menuWidth > rootElementRect.right) {
331
+ containerDiv.style.left = `${rootElementRect.right - menuWidth + window.scrollX}px`;
349
332
  }
350
- if (!containerDiv.isConnected) {
351
- if (className != null) {
352
- containerDiv.className = className;
353
- }
354
- containerDiv.setAttribute("aria-label", "Slash menu");
355
- containerDiv.setAttribute("id", "slash-menu");
356
- containerDiv.setAttribute("role", "listbox");
357
- containerDiv.style.display = "block";
358
- containerDiv.style.position = "absolute";
359
- anchorElem.append(containerDiv);
333
+ const wouldGoOffBottomOfScreen = rawTop + menuHeight + VERTICAL_OFFSET > window.innerHeight;
334
+ //const wouldGoOffBottomOfContainer = top + menuHeight > rootElementRect.bottom
335
+ const wouldGoOffTopOfScreen = rawTop < 0;
336
+ // Position slash menu above the cursor instead of below (default) if it would otherwise go off the bottom of the screen.
337
+ if (wouldGoOffBottomOfScreen && !wouldGoOffTopOfScreen) {
338
+ const margin = 24;
339
+ containerDiv.style.top = `${top + VERTICAL_OFFSET - menuHeight + window.scrollY - (height + margin)}px`;
340
+ } else {
341
+ containerDiv.style.top = `${top + window.scrollY + VERTICAL_OFFSET}px`;
360
342
  }
361
- anchorElementRef.current = containerDiv;
362
- rootElement.setAttribute("aria-controls", "slash-menu");
363
343
  }
364
- };
365
- $[1] = editor;
366
- $[2] = resolution;
367
- $[3] = anchorElem;
368
- $[4] = className;
369
- $[5] = t1;
370
- } else {
371
- t1 = $[5];
372
- }
373
- const positionMenu = t1;
374
- let t2;
375
- let t3;
376
- if ($[6] !== editor || $[7] !== resolution || $[8] !== positionMenu) {
377
- t2 = () => {
378
- const rootElement_0 = editor.getRootElement();
379
- if (resolution !== null) {
380
- positionMenu();
381
- return () => {
382
- if (rootElement_0 !== null) {
383
- rootElement_0.removeAttribute("aria-controls");
384
- }
385
- const containerDiv_0 = anchorElementRef.current;
386
- if (containerDiv_0 !== null && containerDiv_0.isConnected) {
387
- containerDiv_0.remove();
388
- }
389
- };
344
+ if (!containerDiv.isConnected) {
345
+ if (className != null) {
346
+ containerDiv.className = className;
347
+ }
348
+ containerDiv.setAttribute('aria-label', 'Slash menu');
349
+ containerDiv.setAttribute('id', 'slash-menu');
350
+ containerDiv.setAttribute('role', 'listbox');
351
+ containerDiv.style.display = 'block';
352
+ containerDiv.style.position = 'absolute';
353
+ anchorElem.append(containerDiv);
390
354
  }
391
- };
392
- t3 = [editor, positionMenu, resolution];
393
- $[6] = editor;
394
- $[7] = resolution;
395
- $[8] = positionMenu;
396
- $[9] = t2;
397
- $[10] = t3;
398
- } else {
399
- t2 = $[9];
400
- t3 = $[10];
401
- }
402
- useEffect(t2, t3);
403
- let t4;
404
- if ($[11] !== resolution || $[12] !== setResolution) {
405
- t4 = isInView => {
406
- if (resolution !== null) {
407
- if (!isInView) {
408
- setResolution(null);
355
+ anchorElementRef.current = containerDiv;
356
+ rootElement.setAttribute('aria-controls', 'slash-menu');
357
+ }
358
+ }, [editor, resolution, className, anchorElem]);
359
+ useEffect(() => {
360
+ const rootElement_0 = editor.getRootElement();
361
+ if (resolution !== null) {
362
+ positionMenu();
363
+ return () => {
364
+ if (rootElement_0 !== null) {
365
+ rootElement_0.removeAttribute('aria-controls');
409
366
  }
367
+ const containerDiv_0 = anchorElementRef.current;
368
+ if (containerDiv_0 !== null && containerDiv_0.isConnected) {
369
+ containerDiv_0.remove();
370
+ }
371
+ };
372
+ }
373
+ }, [editor, positionMenu, resolution]);
374
+ const onVisibilityChange = useCallback(isInView => {
375
+ if (resolution !== null) {
376
+ if (!isInView) {
377
+ setResolution(null);
410
378
  }
411
- };
412
- $[11] = resolution;
413
- $[12] = setResolution;
414
- $[13] = t4;
415
- } else {
416
- t4 = $[13];
417
- }
418
- const onVisibilityChange = t4;
379
+ }
380
+ }, [resolution, setResolution]);
419
381
  useDynamicPositioning(resolution, anchorElementRef.current, positionMenu, onVisibilityChange);
420
382
  return anchorElementRef;
421
383
  }