@payloadcms/richtext-lexical 3.68.0-internal-debug.35482da → 3.68.0-internal-debug.654e4ad

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 (98) hide show
  1. package/dist/exports/client/index.d.ts +1 -0
  2. package/dist/exports/client/index.d.ts.map +1 -1
  3. package/dist/exports/client/index.js +1 -0
  4. package/dist/exports/client/index.js.map +1 -1
  5. package/dist/exports/client/internal-client.d.ts +3 -0
  6. package/dist/exports/client/internal-client.d.ts.map +1 -0
  7. package/dist/exports/client/internal-client.js +4 -0
  8. package/dist/exports/client/internal-client.js.map +1 -0
  9. package/dist/exports/react/index.d.ts +1 -1
  10. package/dist/exports/react/index.d.ts.map +1 -1
  11. package/dist/exports/react/index.js.map +1 -1
  12. package/dist/features/blocks/client/component/index.js +2 -2
  13. package/dist/features/blocks/client/component/index.js.map +1 -1
  14. package/dist/features/blocks/client/componentInline/index.js +2 -2
  15. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  16. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  17. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  18. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
  19. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  20. package/dist/features/converters/lexicalToJSX/Component/index.js +4 -9
  21. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  22. package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
  23. package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
  24. package/dist/features/converters/lexicalToJSX/converter/index.js +87 -5
  25. package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
  26. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
  27. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  28. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  29. package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
  30. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  31. package/dist/features/link/nodes/LinkNode.js.map +1 -1
  32. package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  33. package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
  34. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  35. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  36. package/dist/field/Field.d.ts.map +1 -1
  37. package/dist/field/Field.js +37 -21
  38. package/dist/field/Field.js.map +1 -1
  39. package/dist/field/RichTextViewProvider.d.ts +83 -0
  40. package/dist/field/RichTextViewProvider.d.ts.map +1 -0
  41. package/dist/field/RichTextViewProvider.js +102 -0
  42. package/dist/field/RichTextViewProvider.js.map +1 -0
  43. package/dist/field/ViewSelector.d.ts +4 -0
  44. package/dist/field/ViewSelector.d.ts.map +1 -0
  45. package/dist/field/ViewSelector.js +90 -0
  46. package/dist/field/ViewSelector.js.map +1 -0
  47. package/dist/field/ViewSelector.scss +34 -0
  48. package/dist/field/index.d.ts +1 -0
  49. package/dist/field/index.d.ts.map +1 -1
  50. package/dist/field/index.js +41 -16
  51. package/dist/field/index.js.map +1 -1
  52. package/dist/field/index.scss +12 -0
  53. package/dist/field/rscEntry.d.ts +1 -1
  54. package/dist/field/rscEntry.d.ts.map +1 -1
  55. package/dist/field/rscEntry.js +13 -1
  56. package/dist/field/rscEntry.js.map +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +3 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  62. package/dist/lexical/LexicalEditor.js +34 -28
  63. package/dist/lexical/LexicalEditor.js.map +1 -1
  64. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  65. package/dist/lexical/LexicalProvider.js +19 -11
  66. package/dist/lexical/LexicalProvider.js.map +1 -1
  67. package/dist/lexical/config/client/sanitize.d.ts +1 -1
  68. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  69. package/dist/lexical/config/client/sanitize.js +3 -2
  70. package/dist/lexical/config/client/sanitize.js.map +1 -1
  71. package/dist/lexical/config/types.d.ts +4 -0
  72. package/dist/lexical/config/types.d.ts.map +1 -1
  73. package/dist/lexical/config/types.js +3 -1
  74. package/dist/lexical/config/types.js.map +1 -1
  75. package/dist/lexical/nodes/index.d.ts +12 -2
  76. package/dist/lexical/nodes/index.d.ts.map +1 -1
  77. package/dist/lexical/nodes/index.js +187 -2
  78. package/dist/lexical/nodes/index.js.map +1 -1
  79. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
  80. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
  81. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +31 -0
  82. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
  83. package/dist/lexical/utils/point.js.map +1 -1
  84. package/dist/lexical/utils/rect.js.map +1 -1
  85. package/dist/types.d.ts +152 -2
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/types.js +55 -0
  88. package/dist/types.js.map +1 -1
  89. package/dist/utilities/fieldsDrawer/DrawerContent.js +2 -2
  90. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  91. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  92. package/dist/utilities/generateImportMap.js +1 -0
  93. package/dist/utilities/generateImportMap.js.map +1 -1
  94. package/dist/validate/hasText.d.ts +6 -1
  95. package/dist/validate/hasText.d.ts.map +1 -1
  96. package/dist/validate/hasText.js +10 -4
  97. package/dist/validate/hasText.js.map +1 -1
  98. package/package.json +13 -8
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lexical/nodes/index.ts"],"sourcesContent":["import type { Klass, LexicalNode, LexicalNodeReplacement } from 'lexical'\n\nimport type { NodeWithHooks } from '../../features/typesServer.js'\nimport type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js'\n\nexport function getEnabledNodes({\n editorConfig,\n}: {\n editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return getEnabledNodesFromServerNodes({\n nodes: editorConfig.features.nodes,\n })\n}\n\nexport function getEnabledNodesFromServerNodes({\n nodes,\n}: {\n nodes: Array<Klass<LexicalNode> | LexicalNodeReplacement> | Array<NodeWithHooks>\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return nodes.map((node) => {\n if ('node' in node) {\n return node.node\n }\n return node\n })\n}\n"],"names":["getEnabledNodes","editorConfig","getEnabledNodesFromServerNodes","nodes","features","map","node"],"mappings":"AAKA,OAAO,SAASA,gBAAgB,EAC9BC,YAAY,EAGb;IACC,OAAOC,+BAA+B;QACpCC,OAAOF,aAAaG,QAAQ,CAACD,KAAK;IACpC;AACF;AAEA,OAAO,SAASD,+BAA+B,EAC7CC,KAAK,EAGN;IACC,OAAOA,MAAME,GAAG,CAAC,CAACC;QAChB,IAAI,UAAUA,MAAM;YAClB,OAAOA,KAAKA,IAAI;QAClB;QACA,OAAOA;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/lexical/nodes/index.ts"],"sourcesContent":["import type {\n EditorConfig,\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n} from 'lexical'\n\nimport React from 'react'\n\nimport type { NodeWithHooks } from '../../features/typesServer.js'\nimport type { LexicalEditorNodeMap, NodeMapValue } from '../../types.js'\nimport type { SanitizedClientEditorConfig, SanitizedServerEditorConfig } from '../config/types.js'\n\n// Store view definitions for each editor and node type\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst editorNodeViews = new WeakMap<LexicalEditor, Map<string, NodeMapValue<any>>>()\n\n/**\n * Register view definitions for an editor\n */\nexport function registerEditorNodeViews(\n editor: LexicalEditor,\n nodeViews: LexicalEditorNodeMap,\n): void {\n if (!editorNodeViews.has(editor)) {\n editorNodeViews.set(editor, new Map())\n }\n const editorViews = editorNodeViews.get(editor)!\n\n // Register each node type's view\n for (const [nodeType, value] of Object.entries(nodeViews)) {\n if (!value || typeof value !== 'object') {\n continue\n }\n\n // Handle blocks specially - store each block type with key 'block:blockType'\n if (nodeType === 'blocks') {\n for (const [blockType, viewDef] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value as Record<string, NodeMapValue<any>>,\n )) {\n editorViews.set(`block:${blockType}`, viewDef)\n }\n continue\n }\n\n // Handle inlineBlocks specially - store each block type with key 'inlineBlock:blockType'\n if (nodeType === 'inlineBlocks') {\n for (const [blockType, viewDef] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value as Record<string, NodeMapValue<any>>,\n )) {\n editorViews.set(`inlineBlock:${blockType}`, viewDef)\n }\n continue\n }\n\n // Regular node types\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n editorViews.set(nodeType, value as NodeMapValue<any>)\n }\n}\n\n/**\n * Clear all view overrides for an editor (restores default rendering)\n */\nexport function clearEditorNodeViews(editor: LexicalEditor): void {\n editorNodeViews.delete(editor)\n}\n\n/**\n * Get the view definition for a specific editor and node\n */\nfunction getEditorNodeView(\n editor: LexicalEditor,\n nodeType: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n node?: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): NodeMapValue<any> | undefined {\n const editorViews = editorNodeViews.get(editor)\n\n // For block nodes, look up by blockType\n if (nodeType === 'block' && node?.['__fields']?.blockType) {\n const blockType = node['__fields'].blockType\n return editorViews?.get(`block:${blockType}`)\n }\n\n // For inlineBlock nodes, look up by blockType\n if (nodeType === 'inlineBlock' && node?.['__fields']?.blockType) {\n const blockType = node['__fields'].blockType\n return editorViews?.get(`inlineBlock:${blockType}`)\n }\n\n // Regular node types\n return editorViews?.get(nodeType)\n}\n\n/**\n * Apply view overrides to a specific node type by modifying its prototype\n * Uses WeakMap to check per-editor at runtime\n */\nfunction applyNodeOverride({\n node,\n nodeType,\n}: {\n node: Klass<LexicalNode>\n nodeType: string\n}): void {\n if (!('getType' in node) || node.getType() !== nodeType) {\n return\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const NodeClass = node as any\n\n // Store original methods if not already stored\n if (!NodeClass.prototype._originalDecorate) {\n NodeClass.prototype._originalDecorate = NodeClass.prototype.decorate\n }\n if (!NodeClass.prototype._originalCreateDOM) {\n NodeClass.prototype._originalCreateDOM = NodeClass.prototype.createDOM\n }\n\n // Override decorate method (for DecoratorNodes)\n if (NodeClass.prototype.decorate && !NodeClass.prototype._decorateOverridden) {\n NodeClass.prototype._decorateOverridden = true\n const hasCreateDOM = !!NodeClass.prototype.createDOM\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n NodeClass.prototype.decorate = function (editor: LexicalEditor, config: EditorConfig): any {\n const viewDef = getEditorNodeView(editor, nodeType, this)\n\n if (viewDef) {\n // Priority 1: If Component is provided, use it\n if (viewDef.Component) {\n return viewDef.Component({\n config,\n editor,\n isEditor: true,\n isJSXConverter: false,\n node: this,\n })\n }\n\n // Priority 2: If custom createDOM is provided, use html in decorate\n if (viewDef.createDOM && viewDef.html) {\n const htmlContent =\n typeof viewDef.html === 'function'\n ? viewDef.html({ config, editor, isEditor: true, isJSXConverter: false, node: this })\n : viewDef.html\n return React.createElement('span', {\n dangerouslySetInnerHTML: { __html: htmlContent },\n })\n }\n\n // Priority 3: If only html is provided (no custom createDOM),\n // createDOM will handle it, so decorate returns empty fragment\n if (viewDef.html && hasCreateDOM && !viewDef.createDOM) {\n return React.createElement(React.Fragment)\n }\n }\n\n // Otherwise use original\n return NodeClass.prototype._originalDecorate.call(this, editor, config)\n }\n }\n\n // Override createDOM method (for ElementNodes)\n if (NodeClass.prototype.createDOM && !NodeClass.prototype._createDOMOverridden) {\n NodeClass.prototype._createDOMOverridden = true\n NodeClass.prototype.createDOM = function (\n config: EditorConfig,\n editor: LexicalEditor,\n ): HTMLElement {\n const viewDef = getEditorNodeView(editor, nodeType, this)\n\n if (viewDef) {\n // If createDOM is provided, use it\n if (viewDef.createDOM) {\n return viewDef.createDOM({ config, editor, node: this })\n }\n\n // If html is provided (as a function or string), create element from it\n if (viewDef.html) {\n const htmlContent =\n typeof viewDef.html === 'function'\n ? viewDef.html({ config, editor, isEditor: true, isJSXConverter: false, node: this })\n : viewDef.html\n const tempDiv = document.createElement('div')\n tempDiv.innerHTML = htmlContent\n return (tempDiv.firstElementChild as HTMLElement) || tempDiv\n }\n }\n\n // Otherwise use original\n return NodeClass.prototype._originalCreateDOM.call(this, config, editor)\n }\n }\n}\n\nexport function getEnabledNodes({\n editorConfig,\n nodeViews,\n}: {\n editorConfig: SanitizedClientEditorConfig | SanitizedServerEditorConfig\n nodeViews?: LexicalEditorNodeMap\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n const nodes = getEnabledNodesFromServerNodes({\n nodes: editorConfig.features.nodes,\n })\n\n if (nodeViews) {\n // Apply node overrides by modifying prototypes (once globally)\n // The overrides check per-editor at runtime using WeakMap\n const nodeTypesToOverride = new Set<string>()\n\n for (const [key, value] of Object.entries(nodeViews)) {\n if (!value || typeof value !== 'object') {\n continue\n }\n\n // If 'blocks' key exists with content, we need to override 'block' nodes\n if (key === 'blocks' && Object.keys(value).length > 0) {\n nodeTypesToOverride.add('block')\n }\n // If 'inlineBlocks' key exists with content, we need to override 'inlineBlock' nodes\n else if (key === 'inlineBlocks' && Object.keys(value).length > 0) {\n nodeTypesToOverride.add('inlineBlock')\n }\n // Regular node types\n else {\n nodeTypesToOverride.add(key)\n }\n }\n\n for (const node of nodes) {\n if ('getType' in node) {\n const nodeType = node.getType()\n\n if (nodeTypesToOverride.has(nodeType)) {\n applyNodeOverride({ node, nodeType })\n }\n }\n }\n }\n\n return nodes\n}\n\nexport function getEnabledNodesFromServerNodes({\n nodes,\n}: {\n nodes: Array<Klass<LexicalNode> | LexicalNodeReplacement> | Array<NodeWithHooks>\n}): Array<Klass<LexicalNode> | LexicalNodeReplacement> {\n return nodes.map((node) => {\n if ('node' in node) {\n return node.node\n }\n return node\n })\n}\n"],"names":["React","editorNodeViews","WeakMap","registerEditorNodeViews","editor","nodeViews","has","set","Map","editorViews","get","nodeType","value","Object","entries","blockType","viewDef","clearEditorNodeViews","delete","getEditorNodeView","node","applyNodeOverride","getType","NodeClass","prototype","_originalDecorate","decorate","_originalCreateDOM","createDOM","_decorateOverridden","hasCreateDOM","config","Component","isEditor","isJSXConverter","html","htmlContent","createElement","dangerouslySetInnerHTML","__html","Fragment","call","_createDOMOverridden","tempDiv","document","innerHTML","firstElementChild","getEnabledNodes","editorConfig","nodes","getEnabledNodesFromServerNodes","features","nodeTypesToOverride","Set","key","keys","length","add","map"],"mappings":"AAQA,OAAOA,WAAW,QAAO;AAMzB,uDAAuD;AACvD,8DAA8D;AAC9D,MAAMC,kBAAkB,IAAIC;AAE5B;;CAEC,GACD,OAAO,SAASC,wBACdC,MAAqB,EACrBC,SAA+B;IAE/B,IAAI,CAACJ,gBAAgBK,GAAG,CAACF,SAAS;QAChCH,gBAAgBM,GAAG,CAACH,QAAQ,IAAII;IAClC;IACA,MAAMC,cAAcR,gBAAgBS,GAAG,CAACN;IAExC,iCAAiC;IACjC,KAAK,MAAM,CAACO,UAAUC,MAAM,IAAIC,OAAOC,OAAO,CAACT,WAAY;QACzD,IAAI,CAACO,SAAS,OAAOA,UAAU,UAAU;YACvC;QACF;QAEA,6EAA6E;QAC7E,IAAID,aAAa,UAAU;YACzB,KAAK,MAAM,CAACI,WAAWC,QAAQ,IAAIH,OAAOC,OAAO,CAC/C,8DAA8D;YAC9DF,OACC;gBACDH,YAAYF,GAAG,CAAC,CAAC,MAAM,EAAEQ,WAAW,EAAEC;YACxC;YACA;QACF;QAEA,yFAAyF;QACzF,IAAIL,aAAa,gBAAgB;YAC/B,KAAK,MAAM,CAACI,WAAWC,QAAQ,IAAIH,OAAOC,OAAO,CAC/C,8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QAAQ,YAAYzC,OAAO0C,IAAI,CAAC3C,OAAO4C,MAAM,GAAG,GAAG;gBACrDJ,oBAAoBK,GAAG,CAAC;YAC1B,OACA,qFAAqF;YAChF,IAAIH,QAAQ,kBAAkBzC,OAAO0C,IAAI,CAAC3C,OAAO4C,MAAM,GAAG,GAAG;gBAChEJ,oBAAoBK,GAAG,CAAC;YAC1B,OACA,qBAAqB;YAChB;gBACHL,oBAAoBK,GAAG,CAACH;YAC1B;QACF;QAEA,KAAK,MAAMlC,QAAQ6B,MAAO;YACxB,IAAI,aAAa7B,MAAM;gBACrB,MAAMT,WAAWS,KAAKE,OAAO;gBAE7B,IAAI8B,oBAAoB9C,GAAG,CAACK,WAAW;oBACrCU,kBAAkB;wBAAED;wBAAMT;oBAAS;gBACrC;YACF;QACF;IACF;IAEA,OAAOsC;AACT;AAEA,OAAO,SAASC,+BAA+B,EAC7CD,KAAK,EAGN;IACC,OAAOA,MAAMS,GAAG,CAAC,CAACtC;QAChB,IAAI,UAAUA,MAAM;YAClB,OAAOA,KAAKA,IAAI;QAClB;QACA,OAAOA;IACT;AACF"}
@@ -0,0 +1,2 @@
1
+ export declare function NodeViewOverridePlugin(): null;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"names":[],"mappings":"AAOA,wBAAgB,sBAAsB,IAAI,IAAI,CAsB7C"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
3
+ import { useEffect } from 'react';
4
+ import { useRichTextView } from '../../../field/RichTextViewProvider.js';
5
+ import { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js';
6
+ export function NodeViewOverridePlugin() {
7
+ const [editor] = useLexicalComposerContext();
8
+ const { currentView, views } = useRichTextView();
9
+ useEffect(()=>{
10
+ if (!views) {
11
+ return;
12
+ }
13
+ if (currentView === 'default') {
14
+ if (views.default) {
15
+ registerEditorNodeViews(editor, views.default?.nodes);
16
+ } else {
17
+ clearEditorNodeViews(editor);
18
+ }
19
+ } else if (views[currentView]) {
20
+ clearEditorNodeViews(editor);
21
+ registerEditorNodeViews(editor, views[currentView]?.nodes);
22
+ }
23
+ }, [
24
+ editor,
25
+ views,
26
+ currentView
27
+ ]);
28
+ return null;
29
+ }
30
+
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n }, [editor, views, currentView])\n\n return null\n}\n"],"names":["useLexicalComposerContext","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","NodeViewOverridePlugin","editor","currentView","views","default","nodes"],"mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,QAAO;AAEjC,SAASC,eAAe,QAAQ,yCAAwC;AACxE,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ,uBAAsB;AAEpF,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGN;IACjB,MAAM,EAAEO,WAAW,EAAEC,KAAK,EAAE,GAAGN;IAE/BD,UAAU;QACR,IAAI,CAACO,OAAO;YACV;QACF;QAEA,IAAID,gBAAgB,WAAW;YAC7B,IAAIC,MAAMC,OAAO,EAAE;gBACjBL,wBAAwBE,QAAQE,MAAMC,OAAO,EAAEC;YACjD,OAAO;gBACLP,qBAAqBG;YACvB;QACF,OAAO,IAAIE,KAAK,CAACD,YAAY,EAAE;YAC7BJ,qBAAqBG;YACrBF,wBAAwBE,QAAQE,KAAK,CAACD,YAAY,EAAEG;QACtD;IACF,GAAG;QAACJ;QAAQE;QAAOD;KAAY;IAE/B,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lexical/utils/point.ts"],"sourcesContent":["'use client'\nexport class Point {\n private readonly _x: number\n\n private readonly _y: number\n\n constructor(x: number, y: number) {\n this._x = x\n this._y = y\n }\n\n public calcDeltaXTo({ x }: Point): number {\n return this.x - x\n }\n\n public calcDeltaYTo({ y }: Point): number {\n return this.y - y\n }\n\n public calcDistanceTo(point: Point): number {\n return Math.sqrt(Math.pow(this.calcDeltaXTo(point), 2) + Math.pow(this.calcDeltaYTo(point), 2))\n }\n\n public calcHorizontalDistanceTo(point: Point): number {\n return Math.abs(this.calcDeltaXTo(point))\n }\n\n public calcVerticalDistance(point: Point): number {\n return Math.abs(this.calcDeltaYTo(point))\n }\n\n public equals({ x, y }: Point): boolean {\n return this.x === x && this.y === y\n }\n\n get x(): number {\n return this._x\n }\n\n get y(): number {\n return this._y\n }\n}\n\nexport function isPoint(x: unknown): x is Point {\n return x instanceof Point\n}\n"],"names":["Point","_x","_y","constructor","x","y","calcDeltaXTo","calcDeltaYTo","calcDistanceTo","point","Math","sqrt","pow","calcHorizontalDistanceTo","abs","calcVerticalDistance","equals","isPoint"],"mappings":"AAAA;AACA,OAAO,MAAMA;IACMC,GAAU;IAEVC,GAAU;IAE3BC,YAAYC,CAAS,EAAEC,CAAS,CAAE;QAChC,IAAI,CAACJ,EAAE,GAAGG;QACV,IAAI,CAACF,EAAE,GAAGG;IACZ;IAEOC,aAAa,EAAEF,CAAC,EAAS,EAAU;QACxC,OAAO,IAAI,CAACA,CAAC,GAAGA;IAClB;IAEOG,aAAa,EAAEF,CAAC,EAAS,EAAU;QACxC,OAAO,IAAI,CAACA,CAAC,GAAGA;IAClB;IAEOG,eAAeC,KAAY,EAAU;QAC1C,OAAOC,KAAKC,IAAI,CAACD,KAAKE,GAAG,CAAC,IAAI,CAACN,YAAY,CAACG,QAAQ,KAAKC,KAAKE,GAAG,CAAC,IAAI,CAACL,YAAY,CAACE,QAAQ;IAC9F;IAEOI,yBAAyBJ,KAAY,EAAU;QACpD,OAAOC,KAAKI,GAAG,CAAC,IAAI,CAACR,YAAY,CAACG;IACpC;IAEOM,qBAAqBN,KAAY,EAAU;QAChD,OAAOC,KAAKI,GAAG,CAAC,IAAI,CAACP,YAAY,CAACE;IACpC;IAEOO,OAAO,EAAEZ,CAAC,EAAEC,CAAC,EAAS,EAAW;QACtC,OAAO,IAAI,CAACD,CAAC,KAAKA,KAAK,IAAI,CAACC,CAAC,KAAKA;IACpC;IAEA,IAAID,IAAY;QACd,OAAO,IAAI,CAACH,EAAE;IAChB;IAEA,IAAII,IAAY;QACd,OAAO,IAAI,CAACH,EAAE;IAChB;AACF;AAEA,OAAO,SAASe,QAAQb,CAAU;IAChC,OAAOA,aAAaJ;AACtB"}
1
+ {"version":3,"sources":["../../../src/lexical/utils/point.ts"],"sourcesContent":["'use client'\nexport class Point {\n private readonly _x: number\n\n private readonly _y: number\n\n constructor(x: number, y: number) {\n this._x = x\n this._y = y\n }\n\n public calcDeltaXTo({ x }: Point): number {\n return this.x - x\n }\n\n public calcDeltaYTo({ y }: Point): number {\n return this.y - y\n }\n\n public calcDistanceTo(point: Point): number {\n return Math.sqrt(Math.pow(this.calcDeltaXTo(point), 2) + Math.pow(this.calcDeltaYTo(point), 2))\n }\n\n public calcHorizontalDistanceTo(point: Point): number {\n return Math.abs(this.calcDeltaXTo(point))\n }\n\n public calcVerticalDistance(point: Point): number {\n return Math.abs(this.calcDeltaYTo(point))\n }\n\n public equals({ x, y }: Point): boolean {\n return this.x === x && this.y === y\n }\n\n get x(): number {\n return this._x\n }\n\n get y(): number {\n return this._y\n }\n}\n\nexport function isPoint(x: unknown): x is Point {\n return x instanceof Point\n}\n"],"names":["Point","_x","_y","x","y","calcDeltaXTo","calcDeltaYTo","calcDistanceTo","point","Math","sqrt","pow","calcHorizontalDistanceTo","abs","calcVerticalDistance","equals","isPoint"],"mappings":"AAAA;AACA,OAAO,MAAMA;IACMC,GAAU;IAEVC,GAAU;IAE3B,YAAYC,CAAS,EAAEC,CAAS,CAAE;QAChC,IAAI,CAACH,EAAE,GAAGE;QACV,IAAI,CAACD,EAAE,GAAGE;IACZ;IAEOC,aAAa,EAAEF,CAAC,EAAS,EAAU;QACxC,OAAO,IAAI,CAACA,CAAC,GAAGA;IAClB;IAEOG,aAAa,EAAEF,CAAC,EAAS,EAAU;QACxC,OAAO,IAAI,CAACA,CAAC,GAAGA;IAClB;IAEOG,eAAeC,KAAY,EAAU;QAC1C,OAAOC,KAAKC,IAAI,CAACD,KAAKE,GAAG,CAAC,IAAI,CAACN,YAAY,CAACG,QAAQ,KAAKC,KAAKE,GAAG,CAAC,IAAI,CAACL,YAAY,CAACE,QAAQ;IAC9F;IAEOI,yBAAyBJ,KAAY,EAAU;QACpD,OAAOC,KAAKI,GAAG,CAAC,IAAI,CAACR,YAAY,CAACG;IACpC;IAEOM,qBAAqBN,KAAY,EAAU;QAChD,OAAOC,KAAKI,GAAG,CAAC,IAAI,CAACP,YAAY,CAACE;IACpC;IAEOO,OAAO,EAAEZ,CAAC,EAAEC,CAAC,EAAS,EAAW;QACtC,OAAO,IAAI,CAACD,CAAC,KAAKA,KAAK,IAAI,CAACC,CAAC,KAAKA;IACpC;IAEA,IAAID,IAAY;QACd,OAAO,IAAI,CAACF,EAAE;IAChB;IAEA,IAAIG,IAAY;QACd,OAAO,IAAI,CAACF,EAAE;IAChB;AACF;AAEA,OAAO,SAASc,QAAQb,CAAU;IAChC,OAAOA,aAAaH;AACtB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lexical/utils/rect.ts"],"sourcesContent":["'use client'\nimport { isPoint, type Point } from './point.js'\n\ninterface ContainsPointReturn {\n reason: {\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n }\n result: boolean\n}\n\nexport class Rect {\n private readonly _bottom: number\n\n private readonly _left: number\n\n private readonly _right: number\n\n private readonly _top: number\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top]\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left]\n\n this._top = physicTop\n this._right = physicRight\n this._left = physicLeft\n this._bottom = physicBottom\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { height, left, top, width } = dom.getBoundingClientRect()\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromDOMRect(domRect: DOMRect): Rect {\n const { height, left, top, width } = domRect\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height)\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { x: left, y: top } = startPoint\n const { x: right, y: bottom } = endPoint\n return Rect.fromLTRB(left, top, right, bottom)\n }\n\n public contains({ x, y }: Point): ContainsPointReturn\n\n public contains({ bottom, left, right, top }: Rect): boolean\n\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target\n\n const isOnTopSide = y < this._top\n const isOnBottomSide = y > this._bottom\n const isOnLeftSide = x < this._left\n const isOnRightSide = x > this._right\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide,\n },\n result,\n }\n }\n const { bottom, left, right, top } = target\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n )\n }\n\n public distanceFromPoint(point: Point): {\n distance: number\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n } {\n const containsResult = this.contains(point)\n if (containsResult.result) {\n return {\n distance: 0,\n isOnBottomSide: containsResult.reason.isOnBottomSide,\n isOnLeftSide: containsResult.reason.isOnLeftSide,\n isOnRightSide: containsResult.reason.isOnRightSide,\n isOnTopSide: containsResult.reason.isOnTopSide,\n }\n }\n\n let dx = 0 // Horizontal distance to the closest edge\n let dy = 0 // Vertical distance to the closest edge\n\n // If the point is to the left of the rectangle\n if (point.x < this._left) {\n dx = this._left - point.x\n }\n // If the point is to the right of the rectangle\n else if (point.x > this._right) {\n dx = point.x - this._right\n }\n\n // If the point is above the rectangle\n if (point.y < this._top) {\n dy = this._top - point.y\n }\n // If the point is below the rectangle\n else if (point.y > this._bottom) {\n dy = point.y - this._bottom\n }\n\n // Use the Pythagorean theorem to calculate the distance\n return {\n distance: Math.sqrt(dx * dx + dy * dy),\n isOnBottomSide: point.y > this._bottom,\n isOnLeftSide: point.x < this._left,\n isOnRightSide: point.x > this._right,\n isOnTopSide: point.y < this._top,\n }\n }\n\n public equals({ bottom, left, right, top }: Rect): boolean {\n return (\n top === this._top && bottom === this._bottom && left === this._left && right === this._right\n )\n }\n\n public generateNewRect({\n bottom = this.bottom,\n left = this.left,\n right = this.right,\n top = this.top,\n }): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { height: h1, left: x1, top: y1, width: w1 } = rect\n const { height: h2, left: x2, top: y2, width: w2 } = this\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2\n const minX = x1 <= x2 ? x1 : x2\n const minY = y1 <= y2 ? y1 : y2\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2\n }\n\n get bottom(): number {\n return this._bottom\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top)\n }\n\n get left(): number {\n return this._left\n }\n\n get right(): number {\n return this._right\n }\n\n get top(): number {\n return this._top\n }\n\n get width(): number {\n return Math.abs(this._left - this._right)\n }\n}\n"],"names":["isPoint","Rect","_bottom","_left","_right","_top","constructor","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","fromDOM","dom","height","width","getBoundingClientRect","fromLWTH","fromDOMRect","domRect","fromLTRB","fromPoints","startPoint","endPoint","x","y","contains","target","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","distanceFromPoint","point","containsResult","distance","dx","dy","Math","sqrt","equals","generateNewRect","intersectsWith","rect","h1","x1","y1","w1","h2","x2","y2","w2","maxX","maxY","minX","minY","abs"],"mappings":"AAAA;AACA,SAASA,OAAO,QAAoB,aAAY;AAYhD,OAAO,MAAMC;IACMC,QAAe;IAEfC,MAAa;IAEbC,OAAc;IAEdC,KAAY;IAE7BC,YAAYC,IAAY,EAAEC,GAAW,EAAEC,KAAa,EAAEC,MAAc,CAAE;QACpE,MAAM,CAACC,WAAWC,aAAa,GAAGJ,OAAOE,SAAS;YAACF;YAAKE;SAAO,GAAG;YAACA;YAAQF;SAAI;QAE/E,MAAM,CAACK,YAAYC,YAAY,GAAGP,QAAQE,QAAQ;YAACF;YAAME;SAAM,GAAG;YAACA;YAAOF;SAAK;QAE/E,IAAI,CAACF,IAAI,GAAGM;QACZ,IAAI,CAACP,MAAM,GAAGU;QACd,IAAI,CAACX,KAAK,GAAGU;QACb,IAAI,CAACX,OAAO,GAAGU;IACjB;IAEA,OAAOG,QAAQC,GAAgB,EAAQ;QACrC,MAAM,EAAEC,MAAM,EAAEV,IAAI,EAAEC,GAAG,EAAEU,KAAK,EAAE,GAAGF,IAAIG,qBAAqB;QAC9D,OAAOlB,K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MI,KAAKJ,KAAKI;QAC7B,OAAOE,OAAOE,QAAQP,KAAKI,MAAME,OAAOE,QAAQX,KAAKI;IACvD;IAEA,IAAI3C,SAAiB;QACnB,OAAO,IAAI,CAACR,OAAO;IACrB;IAEA,IAAIe,SAAiB;QACnB,OAAO0B,KAAKkB,GAAG,CAAC,IAAI,CAAC3D,OAAO,GAAG,IAAI,CAACG,IAAI;IAC1C;IAEA,IAAIE,OAAe;QACjB,OAAO,IAAI,CAACJ,KAAK;IACnB;IAEA,IAAIM,QAAgB;QAClB,OAAO,IAAI,CAACL,MAAM;IACpB;IAEA,IAAII,MAAc;QAChB,OAAO,IAAI,CAACH,IAAI;IAClB;IAEA,IAAIa,QAAgB;QAClB,OAAOyB,KAAKkB,GAAG,CAAC,IAAI,CAAC1D,KAAK,GAAG,IAAI,CAACC,MAAM;IAC1C;AACF"}
1
+ {"version":3,"sources":["../../../src/lexical/utils/rect.ts"],"sourcesContent":["'use client'\nimport { isPoint, type Point } from './point.js'\n\ninterface ContainsPointReturn {\n reason: {\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n }\n result: boolean\n}\n\nexport class Rect {\n private readonly _bottom: number\n\n private readonly _left: number\n\n private readonly _right: number\n\n private readonly _top: number\n\n constructor(left: number, top: number, right: number, bottom: number) {\n const [physicTop, physicBottom] = top <= bottom ? [top, bottom] : [bottom, top]\n\n const [physicLeft, physicRight] = left <= right ? [left, right] : [right, left]\n\n this._top = physicTop\n this._right = physicRight\n this._left = physicLeft\n this._bottom = physicBottom\n }\n\n static fromDOM(dom: HTMLElement): Rect {\n const { height, left, top, width } = dom.getBoundingClientRect()\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromDOMRect(domRect: DOMRect): Rect {\n const { height, left, top, width } = domRect\n return Rect.fromLWTH(left, width, top, height)\n }\n\n static fromLTRB(left: number, top: number, right: number, bottom: number): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n static fromLWTH(left: number, width: number, top: number, height: number): Rect {\n return new Rect(left, top, left + width, top + height)\n }\n\n static fromPoints(startPoint: Point, endPoint: Point): Rect {\n const { x: left, y: top } = startPoint\n const { x: right, y: bottom } = endPoint\n return Rect.fromLTRB(left, top, right, bottom)\n }\n\n public contains({ x, y }: Point): ContainsPointReturn\n\n public contains({ bottom, left, right, top }: Rect): boolean\n\n public contains(target: Point | Rect): boolean | ContainsPointReturn {\n if (isPoint(target)) {\n const { x, y } = target\n\n const isOnTopSide = y < this._top\n const isOnBottomSide = y > this._bottom\n const isOnLeftSide = x < this._left\n const isOnRightSide = x > this._right\n\n const result = !isOnTopSide && !isOnBottomSide && !isOnLeftSide && !isOnRightSide\n\n return {\n reason: {\n isOnBottomSide,\n isOnLeftSide,\n isOnRightSide,\n isOnTopSide,\n },\n result,\n }\n }\n const { bottom, left, right, top } = target\n\n return (\n top >= this._top &&\n top <= this._bottom &&\n bottom >= this._top &&\n bottom <= this._bottom &&\n left >= this._left &&\n left <= this._right &&\n right >= this._left &&\n right <= this._right\n )\n }\n\n public distanceFromPoint(point: Point): {\n distance: number\n isOnBottomSide: boolean\n isOnLeftSide: boolean\n isOnRightSide: boolean\n isOnTopSide: boolean\n } {\n const containsResult = this.contains(point)\n if (containsResult.result) {\n return {\n distance: 0,\n isOnBottomSide: containsResult.reason.isOnBottomSide,\n isOnLeftSide: containsResult.reason.isOnLeftSide,\n isOnRightSide: containsResult.reason.isOnRightSide,\n isOnTopSide: containsResult.reason.isOnTopSide,\n }\n }\n\n let dx = 0 // Horizontal distance to the closest edge\n let dy = 0 // Vertical distance to the closest edge\n\n // If the point is to the left of the rectangle\n if (point.x < this._left) {\n dx = this._left - point.x\n }\n // If the point is to the right of the rectangle\n else if (point.x > this._right) {\n dx = point.x - this._right\n }\n\n // If the point is above the rectangle\n if (point.y < this._top) {\n dy = this._top - point.y\n }\n // If the point is below the rectangle\n else if (point.y > this._bottom) {\n dy = point.y - this._bottom\n }\n\n // Use the Pythagorean theorem to calculate the distance\n return {\n distance: Math.sqrt(dx * dx + dy * dy),\n isOnBottomSide: point.y > this._bottom,\n isOnLeftSide: point.x < this._left,\n isOnRightSide: point.x > this._right,\n isOnTopSide: point.y < this._top,\n }\n }\n\n public equals({ bottom, left, right, top }: Rect): boolean {\n return (\n top === this._top && bottom === this._bottom && left === this._left && right === this._right\n )\n }\n\n public generateNewRect({\n bottom = this.bottom,\n left = this.left,\n right = this.right,\n top = this.top,\n }): Rect {\n return new Rect(left, top, right, bottom)\n }\n\n public intersectsWith(rect: Rect): boolean {\n const { height: h1, left: x1, top: y1, width: w1 } = rect\n const { height: h2, left: x2, top: y2, width: w2 } = this\n const maxX = x1 + w1 >= x2 + w2 ? x1 + w1 : x2 + w2\n const maxY = y1 + h1 >= y2 + h2 ? y1 + h1 : y2 + h2\n const minX = x1 <= x2 ? x1 : x2\n const minY = y1 <= y2 ? y1 : y2\n return maxX - minX <= w1 + w2 && maxY - minY <= h1 + h2\n }\n\n get bottom(): number {\n return this._bottom\n }\n\n get height(): number {\n return Math.abs(this._bottom - this._top)\n }\n\n get left(): number {\n return this._left\n }\n\n get right(): number {\n return this._right\n }\n\n get top(): number {\n return this._top\n }\n\n get width(): number {\n return Math.abs(this._left - this._right)\n }\n}\n"],"names":["isPoint","Rect","_bottom","_left","_right","_top","left","top","right","bottom","physicTop","physicBottom","physicLeft","physicRight","fromDOM","dom","height","width","getBoundingClientRect","fromLWTH","fromDOMRect","domRect","fromLTRB","fromPoints","startPoint","endPoint","x","y","contains","target","isOnTopSide","isOnBottomSide","isOnLeftSide","isOnRightSide","result","reason","distanceFromPoint","point","containsResult","distance","dx","dy","Math","sqrt","equals","generateNewRect","intersectsWith","rect","h1","x1","y1","w1","h2","x2","y2","w2","maxX","maxY","minX","minY","abs"],"mappings":"AAAA;AACA,SAASA,OAAO,QAAoB,aAAY;AAYhD,OAAO,MAAMC;IACMC,QAAe;IAEfC,MAAa;IAEbC,OAAc;IAEdC,KAAY;IAE7B,YAAYC,IAAY,EAA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K,MAAMC,KAAKC,OAAOC;IACpC;IAEOqC,eAAeC,IAAU,EAAW;QACzC,MAAM,EAAE/B,QAAQgC,EAAE,EAAE1C,MAAM2C,EAAE,EAAE1C,KAAK2C,EAAE,EAAEjC,OAAOkC,EAAE,EAAE,GAAGJ;QACrD,MAAM,EAAE/B,QAAQoC,EAAE,EAAE9C,MAAM+C,EAAE,EAAE9C,KAAK+C,EAAE,EAAErC,OAAOsC,EAAE,EAAE,GAAG,IAAI;QACzD,MAAMC,OAAOP,KAAKE,MAAME,KAAKE,KAAKN,KAAKE,KAAKE,KAAKE;QACjD,MAAME,OAAOP,KAAKF,MAAMM,KAAKF,KAAKF,KAAKF,KAAKM,KAAKF;QACjD,MAAMM,OAAOT,MAAMI,KAAKJ,KAAKI;QAC7B,MAAMM,OAAOT,MAAMI,KAAKJ,KAAKI;QAC7B,OAAOE,OAAOE,QAAQP,KAAKI,MAAME,OAAOE,QAAQX,KAAKI;IACvD;IAEA,IAAI3C,SAAiB;QACnB,OAAO,IAAI,CAACP,OAAO;IACrB;IAEA,IAAIc,SAAiB;QACnB,OAAO0B,KAAKkB,GAAG,CAAC,IAAI,CAAC1D,OAAO,GAAG,IAAI,CAACG,IAAI;IAC1C;IAEA,IAAIC,OAAe;QACjB,OAAO,IAAI,CAACH,KAAK;IACnB;IAEA,IAAIK,QAAgB;QAClB,OAAO,IAAI,CAACJ,MAAM;IACpB;IAEA,IAAIG,MAAc;QAChB,OAAO,IAAI,CAACF,IAAI;IAClB;IAEA,IAAIY,QAAgB;QAClB,OAAOyB,KAAKkB,GAAG,CAAC,IAAI,CAACzD,KAAK,GAAG,IAAI,CAACC,MAAM;IAC1C;AACF"}
package/dist/types.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical';
2
- import type { ClientField, DefaultServerCellComponentProps, LabelFunction, RichTextAdapter, RichTextField, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
1
+ import type { DecoratorNode, EditorConfig, LexicalEditor, EditorConfig as LexicalEditorConfig, LexicalNode, SerializedEditorState, SerializedLexicalNode } from 'lexical';
2
+ import type { ClientField, DefaultServerCellComponentProps, LabelFunction, PayloadComponent, RichTextAdapter, RichTextField, RichTextFieldClient, RichTextFieldClientProps, SanitizedConfig, ServerFieldBase, StaticLabel } from 'payload';
3
+ import type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js';
3
4
  import type { BaseClientFeatureProps, FeatureProviderProviderClient } from './features/typesClient.js';
4
5
  import type { FeatureProviderServer } from './features/typesServer.js';
5
6
  import type { SanitizedServerEditorConfig } from './lexical/config/types.js';
7
+ import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from './nodeTypes.js';
6
8
  import type { InitialLexicalFormState } from './utilities/buildInitialState.js';
7
9
  export type LexicalFieldAdminProps = {
8
10
  /**
@@ -56,10 +58,156 @@ export type FeaturesInput = (({ defaultFeatures, rootFeatures, }: {
56
58
  */
57
59
  rootFeatures: FeatureProviderServer<any, any, any>[];
58
60
  }) => FeatureProviderServer<any, any, any>[]) | FeatureProviderServer<any, any, any>[];
61
+ type WithinEditorArgs = {
62
+ config: EditorConfig;
63
+ editor: LexicalEditor;
64
+ node: LexicalNode;
65
+ };
66
+ /**
67
+ *
68
+ * @experimental - This API is experimental and may change in a minor release.
69
+ * @internal
70
+ */
71
+ export type NodeMapValue<TNode extends {
72
+ [key: string]: any;
73
+ type?: string;
74
+ } = SerializedLexicalNode> = {
75
+ /**
76
+ * Provide a react component to render the node.
77
+ *
78
+ * **JSX Converter:** Always works. Takes priority over `html`.
79
+ *
80
+ * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.
81
+ */
82
+ Component?: (args: ({
83
+ isEditor: false;
84
+ isJSXConverter: true;
85
+ } & JSXConverterArgs<TNode>) | ({
86
+ isEditor: true;
87
+ isJSXConverter: false;
88
+ node: {
89
+ _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode;
90
+ } & DecoratorNode<React.ReactNode>;
91
+ } & Omit<WithinEditorArgs, 'node'>)) => React.ReactNode;
92
+ /**
93
+ * Provide a function to create the DOM element for the node.
94
+ *
95
+ * **JSX Converter:** Not used (only `Component` and `html` work).
96
+ *
97
+ * **Lexical Editor:** Always works (renders in `createDOM` method).
98
+ * - For ElementNodes: This is the standard way to customize rendering.
99
+ * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.
100
+ */
101
+ createDOM?: (args: WithinEditorArgs) => HTMLElement;
102
+ /**
103
+ * Provide HTML string or function to render the node.
104
+ *
105
+ * **JSX Converter:** Always works (ignored if `Component` is provided).
106
+ *
107
+ * **Lexical Editor behavior depends on node type:**
108
+ *
109
+ * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.
110
+ *
111
+ * - **DecoratorNodes (have both `createDOM` and `decorate`):**
112
+ * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`
113
+ * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`
114
+ * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content
115
+ * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)
116
+ */
117
+ html?: (args: ({
118
+ isEditor: false;
119
+ isJSXConverter: true;
120
+ } & JSXConverterArgs<TNode>) | ({
121
+ isEditor: true;
122
+ isJSXConverter: false;
123
+ } & WithinEditorArgs)) => string;
124
+ };
125
+ /**
126
+ * @experimental - This API is experimental and may change in a minor release.
127
+ * @internal
128
+ */
129
+ export type LexicalEditorNodeMap<TNodes extends {
130
+ [key: string]: any;
131
+ type?: string;
132
+ } = DefaultNodeTypes | SerializedBlockNode<{
133
+ blockName?: null | string;
134
+ blockType: string;
135
+ }> | SerializedInlineBlockNode<{
136
+ blockName?: null | string;
137
+ blockType: string;
138
+ }>> = {
139
+ [key: string]: {
140
+ [blockSlug: string]: NodeMapValue<any>;
141
+ } | NodeMapValue<any> | undefined;
142
+ } & {
143
+ [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<Extract<TNodes, {
144
+ type: nodeType;
145
+ }>>;
146
+ } & {
147
+ blocks?: {
148
+ [K in Extract<Extract<TNodes, {
149
+ type: 'block';
150
+ }> extends SerializedBlockNode<infer B> ? B extends {
151
+ blockType: string;
152
+ } ? B['blockType'] : never : never, string>]?: NodeMapValue<Extract<TNodes, {
153
+ type: 'block';
154
+ }> extends SerializedBlockNode<infer B> ? SerializedBlockNode<Extract<B, {
155
+ blockType: K;
156
+ }>> : SerializedBlockNode>;
157
+ };
158
+ inlineBlocks?: {
159
+ [K in Extract<Extract<TNodes, {
160
+ type: 'inlineBlock';
161
+ }> extends SerializedInlineBlockNode<infer B> ? B extends {
162
+ blockType: string;
163
+ } ? B['blockType'] : never : never, string>]?: NodeMapValue<Extract<TNodes, {
164
+ type: 'inlineBlock';
165
+ }> extends SerializedInlineBlockNode<infer B> ? SerializedInlineBlockNode<Extract<B, {
166
+ blockType: K;
167
+ }>> : SerializedInlineBlockNode>;
168
+ };
169
+ unknown?: NodeMapValue<SerializedLexicalNode>;
170
+ };
171
+ /**
172
+ * A map of views, which can be used to render the editor in different ways.
173
+ *
174
+ * In order to override the default view, you can add a `default` key to the map.
175
+ *
176
+ * @experimental - This API is experimental and may change in a minor release.
177
+ * @internal
178
+ */
179
+ export type LexicalEditorViewMap<TNodes extends {
180
+ [key: string]: any;
181
+ type?: string;
182
+ } = DefaultNodeTypes | SerializedBlockNode<{
183
+ blockName?: null | string;
184
+ blockType: string;
185
+ }> | SerializedInlineBlockNode<{
186
+ blockName?: null | string;
187
+ blockType: string;
188
+ }>> = {
189
+ [viewKey: string]: {
190
+ admin?: LexicalFieldAdminClientProps;
191
+ lexical?: LexicalEditorConfig;
192
+ nodes: LexicalEditorNodeMap<TNodes>;
193
+ };
194
+ };
195
+ /**
196
+ * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function
197
+ */
59
198
  export type LexicalEditorProps = {
60
199
  admin?: LexicalFieldAdminProps;
61
200
  features?: FeaturesInput;
62
201
  lexical?: LexicalEditorConfig;
202
+ /**
203
+ * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.
204
+ *
205
+ * In order to override the default view, you can add a `default` key to the map.
206
+ *
207
+ * @experimental - This API is experimental and may change in a minor release.
208
+ * @internal
209
+ */
210
+ views?: PayloadComponent;
63
211
  };
64
212
  export type LexicalRichTextAdapter = {
65
213
  editorConfig: SanitizedServerEditorConfig;
@@ -96,6 +244,7 @@ export type LexicalRichTextFieldProps = {
96
244
  featureClientSchemaMap: FeatureClientSchemaMap;
97
245
  initialLexicalFormState: InitialLexicalFormState;
98
246
  lexicalEditorConfig: LexicalEditorConfig | undefined;
247
+ views?: LexicalEditorViewMap;
99
248
  } & Pick<ServerFieldBase, 'permissions'> & RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>;
100
249
  export type LexicalRichTextCellProps = DefaultServerCellComponentProps<RichTextFieldClient<SerializedEditorState, AdapterProps, object>, SerializedEditorState>;
101
250
  export type AdapterProps = {
@@ -106,4 +255,5 @@ export type GeneratedFeatureProviderComponent = {
106
255
  clientFeatureProps: BaseClientFeatureProps<object>;
107
256
  };
108
257
  export type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>;
258
+ export {};
109
259
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACzF,OAAO,KAAK,EACV,WAAW,EACX,+BAA+B,EAC/B,aAAa,EACb,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,WAAW,EACZ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AAM,wBAAwB,GAAG,+BAA+B,CACpE,mBAAmB,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,EAChE,qBAAqB,CACtB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,YAAY,EAAE,2BAA2B,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,aAAa,EAAE,6BAA6B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACtD,kBAAkB,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAA"}
package/dist/types.js CHANGED
@@ -30,6 +30,61 @@
30
30
  * })
31
31
  * ```
32
32
  */ /**
33
+ *
34
+ * @experimental - This API is experimental and may change in a minor release.
35
+ * @internal
36
+ */ /**
37
+ * Provide a react component to render the node.
38
+ *
39
+ * **JSX Converter:** Always works. Takes priority over `html`.
40
+ *
41
+ * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.
42
+ */ /**
43
+ * Provide a function to create the DOM element for the node.
44
+ *
45
+ * **JSX Converter:** Not used (only `Component` and `html` work).
46
+ *
47
+ * **Lexical Editor:** Always works (renders in `createDOM` method).
48
+ * - For ElementNodes: This is the standard way to customize rendering.
49
+ * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.
50
+ */ /**
51
+ * Provide HTML string or function to render the node.
52
+ *
53
+ * **JSX Converter:** Always works (ignored if `Component` is provided).
54
+ *
55
+ * **Lexical Editor behavior depends on node type:**
56
+ *
57
+ * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.
58
+ *
59
+ * - **DecoratorNodes (have both `createDOM` and `decorate`):**
60
+ * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`
61
+ * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`
62
+ * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content
63
+ * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)
64
+ */ /**
65
+ * @experimental - This API is experimental and may change in a minor release.
66
+ * @internal
67
+ */ // need these to ensure types for blocks and inlineBlocks work if no generics are provided
68
+ // need these to ensure types for blocks and inlineBlocks work if no generics are provided
69
+ /**
70
+ * A map of views, which can be used to render the editor in different ways.
71
+ *
72
+ * In order to override the default view, you can add a `default` key to the map.
73
+ *
74
+ * @experimental - This API is experimental and may change in a minor release.
75
+ * @internal
76
+ */ // need these to ensure types for blocks and inlineBlocks work if no generics are provided
77
+ // need these to ensure types for blocks and inlineBlocks work if no generics are provided
78
+ /**
79
+ * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function
80
+ */ /**
81
+ * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.
82
+ *
83
+ * In order to override the default view, you can add a `default` key to the map.
84
+ *
85
+ * @experimental - This API is experimental and may change in a minor release.
86
+ * @internal
87
+ */ /**
33
88
  * This is being called during the payload sanitization process
34
89
  */ // clientFeatures is added through the rsc field
35
90
  /**
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { EditorConfig as LexicalEditorConfig, SerializedEditorState } from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"names":[],"mappings":"AAuBE;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAaG;;;;;;;;;;OAUC,GAED;;;;;;;;;;;OAWC,GAiBL;;GAEC,GAoBD,gDAAgD;AAOhD;;;GAGC,GAIoD,4DAA4D;AAkBnH,WAAqF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type {\n DecoratorNode,\n EditorConfig,\n LexicalEditor,\n EditorConfig as LexicalEditorConfig,\n LexicalNode,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n PayloadComponent,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport type { JSXConverterArgs } from './features/converters/lexicalToJSX/converter/types.js'\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from './features/typesClient.js'\nimport type { FeatureProviderServer } from './features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from './lexical/config/types.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\nimport type { InitialLexicalFormState } from './utilities/buildInitialState.js'\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\ntype WithinEditorArgs = {\n config: EditorConfig\n editor: LexicalEditor\n node: LexicalNode\n}\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapValue<\n TNode extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> = {\n /**\n * Provide a react component to render the node.\n *\n * **JSX Converter:** Always works. Takes priority over `html`.\n *\n * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.\n */\n Component?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n node: {\n _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode\n } & DecoratorNode<React.ReactNode>\n } & Omit<WithinEditorArgs, 'node'>),\n ) => React.ReactNode\n /**\n * Provide a function to create the DOM element for the node.\n *\n * **JSX Converter:** Not used (only `Component` and `html` work).\n *\n * **Lexical Editor:** Always works (renders in `createDOM` method).\n * - For ElementNodes: This is the standard way to customize rendering.\n * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.\n */\n createDOM?: (args: WithinEditorArgs) => HTMLElement\n /**\n * Provide HTML string or function to render the node.\n *\n * **JSX Converter:** Always works (ignored if `Component` is provided).\n *\n * **Lexical Editor behavior depends on node type:**\n *\n * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.\n *\n * - **DecoratorNodes (have both `createDOM` and `decorate`):**\n * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`\n * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`\n * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content\n * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)\n */\n html?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => string\n}\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: NodeMapValue<any>\n }\n | NodeMapValue<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapValue<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: NodeMapValue<SerializedLexicalNode>\n}\n\n/**\n * A map of views, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorViewMap<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n lexical?: LexicalEditorConfig\n nodes: LexicalEditorNodeMap<TNodes>\n }\n}\n\n/**\n * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function\n */\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n /**\n * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\n views?: PayloadComponent\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n }\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n views?: LexicalEditorViewMap\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"names":[],"mappings":"AAuCE;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAED;;GAEC,GAaG;;;;;;;;;;OAUC,GAED;;;;;;;;;;;OAWC,GAWP;;;;CAIC,GAIC;;;;;;GAMC,GAeD;;;;;;;;GAQC,GAED;;;;;;;;;;;;;;GAcC,GAcH;;;CAGC,GAI2E,0FAA0F;AACnF,0FAA0F;AA4C7K;;;;;;;CAOC,GAI2E,0FAA0F;AACnF,0FAA0F;AAS7K;;CAEC,GAKC;;;;;;;GAOC,GAUD;;GAEC,GAoBD,gDAAgD;AAOhD;;;GAGC,GAIoD,4DAA4D;AAmBnH,WAAqF"}
@@ -116,8 +116,8 @@ export const DrawerContent = ({ data, featureKey, fieldMapOverride, handleDrawer
116
116
  fields: Array.isArray(fields) ? fields : [],
117
117
  forceRender: true,
118
118
  parentIndexPath: "",
119
- parentPath: "",
120
- // See Blocks feature path for details as for why this is empty
119
+ parentPath: // See Blocks feature path for details as for why this is empty
120
+ "",
121
121
  parentSchemaPath: schemaFieldsPath,
122
122
  permissions: true,
123
123
  readOnly: !isEditable
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"mappings":"AAAA;;AAGA,SAASA,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,EAClBC,cAAc,QACT,iBAAgB;AACvB,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,0CAA0C,QAAQ,iBAAgB;AAC3E,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACvE,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAIjC,SAASC,sBAAsB,QAAQ,sDAAqD;AAE5F,OAAO,MAAMC,gBAAiF,CAAC,EAC7FC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAChBC,kBAAkB,EAClBC,wBAAwB,EACxBC,UAAU,EACVC,gBAAgB,EACjB;IACC,MAAM,EAAEC,CAAC,EAAE,GAAGnB;IACd,MAAM,EAAEoB,EAAE,EAAEC,cAAc,EAAEC,iBAAiB,EAAEC,UAAU,EAAE,GAAGzB;IAC9D,MAAM,EAAE0B,QAAQC,oBAAoB,EAAE,GAAG5B;IACzC,MAAM6B,aAAajC;IAEnB,MAAMkC,6BAA6BrB,OAAO,IAAIsB;IAE9C,MAAM,CAACC,cAAcC,gBAAgB,GAAGvB,SAAwC;IAEhF,MAAM,EACJwB,YAAY,EAAEC,sBAAsB,EAAE,EACvC,GAAGtB;IAEJ,MAAM,EAAEuB,YAAY,EAAE,GAAGlC;IAEzB,MA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AM;QACAL;QACAC;QACAG;QACAF;QACAW;KACD;IAGH,iBAAiB;IACjB7B,UAAU;QACR,OAAO;YACLJ,eAAe0B,2BAA2BsB,OAAO;QACnD;IACF,GAAG,EAAE;IAEL,IAAIpB,iBAAiB,OAAO;QAC1B,OAAO;IACT;IAEA,qBACE,QAACnC;QACCyD,cAAc;YAACL;SAAS;QACxBM,yBAAyB;QACzB5B,QAAQ6B,MAAMC,OAAO,CAAC9B,UAAUA,SAAS,EAAE;QAC3CK,cAAcA;QACdiB,UAAU;YAACA;SAAS;QACpBS,UAAUxC;QACVN,MAAMA;;0BAEN,QAACb;gBACC4B,QAAQ6B,MAAMC,OAAO,CAAC9B,UAAUA,SAAS,EAAE;gBAC3CgC,WAAW;gBACXC,iBAAgB;gBAChBC,YAAW;gBAAG,+DAA+D;gBAC7EC,kBAAkBzB;gBAClB0B,aAAa;gBACbjB,UAAU,CAACjB;;;;;;0BAEb,QAAC/B;0BAAYwB,EAAE;;;;;;;;;;;;AAGrB,EAAC"}
1
+ {"version":3,"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"mappings":"AAAA;;AAGA,SAASA,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBA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S,EAAE;gBAC3CgC,WAAW;gBACXC,iBAAgB;gBAChBC,YAAc,+DAA+D;gBAAlE;gBACXC,kBAAkBzB;gBAClB0B,aAAa;gBACbjB,UAAU,CAACjB;;;;;;0BAEb,QAAC/B;0BAAYwB,EAAE;;;;;;;;;;;;AAGrB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CA+CtC,CAAA"}
1
+ {"version":3,"file":"generateImportMap.d.ts","sourceRoot":"","sources":["../../src/utilities/generateImportMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,oBAAoB,SACxB;IACL,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;IACtC,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,mBAAmB,CAiDtC,CAAA"}
@@ -3,6 +3,7 @@ export const getGenerateImportMap = (args)=>({ addToImportMap, baseDir, config,
3
3
  addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell');
4
4
  addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField');
5
5
  addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent');
6
+ addToImportMap(args.lexicalEditorArgs?.views);
6
7
  for (const resolvedFeature of args.resolvedFeatureMap.values()){
7
8
  if ('componentImports' in resolvedFeature) {
8
9
  if (typeof resolvedFeature.componentImports === 'function') {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAKnD,OAAO,MAAMC,uBACX,CAACC,OAID,CAAC,EAAEC,cAAc,EAAEC,OAAO,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAE;QACtDJ,eAAe;QACfA,eAAe;QACfA,eAAe;QAEf,KAAK,MAAMK,mBAAmBN,KAAKO,kBAAkB,CAACC,MAAM,GAAI;YAC9D,IAAI,sBAAsBF,iBAAiB;gBACzC,IAAI,OAAOA,gBAAgBG,gBAAgB,KAAK,YAAY;oBAC1DH,gBAAgBG,gBAAgB,CAAC;wBAC/BR;wBACAC;wBACAC;wBACAC;wBACAC;oBACF;gBACF,OAAO,IAAIK,MAAMC,OAAO,CAACL,gBAAgBG,gBAAgB,GAAG;oBAC1DR,eAAeK,gBAAgBG,gBAAgB;gBACjD,OAAO,IAAI,OAAOH,gBAAgBG,gBAAgB,KAAK,UAAU;oBAC/DR,eAAeW,OAAOJ,MAAM,CAACF,gBAAgBG,gBAAgB;gBAC/D;YACF;YAEAR,eAAeK,gBAAgBO,aAAa;YAE5C;;OAEC,GACD,IAAIP,gBAAgBQ,KAAK,EAAEC,QAAQ;gBACjC,KAAK,MAAMC,QAAQV,gBAAgBQ,KAAK,CAAE;oBACxC,IAAI,OAAOE,MAAMC,iBAAiB,YAAY;wBAC5C;oBACF;oBACA,MAAMC,YAAYF,KAAKC,YAAY,CAAC,CAAC;oBACrC,IAAIC,WAAWH,QAAQ;wBACrBjB,0BAA0B;4BACxBG;4BACAC;4BACAC;4BACAgB,QAAQD;4BACRd;4BACAC;wBACF;oBACF;gBACF;YACF;QACF;IACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/generateImportMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { genImportMapIterateFields } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\nimport type { LexicalEditorProps } from '../types.js'\n\nexport const getGenerateImportMap =\n (args: {\n lexicalEditorArgs?: LexicalEditorProps\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateImportMap'] =>\n ({ addToImportMap, baseDir, config, importMap, imports }) => {\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalCell')\n addToImportMap('@payloadcms/richtext-lexical/rsc#RscEntryLexicalField')\n addToImportMap('@payloadcms/richtext-lexical/rsc#LexicalDiffComponent')\n\n addToImportMap(args.lexicalEditorArgs?.views)\n\n for (const resolvedFeature of args.resolvedFeatureMap.values()) {\n if ('componentImports' in resolvedFeature) {\n if (typeof resolvedFeature.componentImports === 'function') {\n resolvedFeature.componentImports({\n addToImportMap,\n baseDir,\n config,\n importMap,\n imports,\n })\n } else if (Array.isArray(resolvedFeature.componentImports)) {\n addToImportMap(resolvedFeature.componentImports)\n } else if (typeof resolvedFeature.componentImports === 'object') {\n addToImportMap(Object.values(resolvedFeature.componentImports))\n }\n }\n\n addToImportMap(resolvedFeature.ClientFeature)\n\n /*\n * Now run for all possible sub-fields\n */\n if (resolvedFeature.nodes?.length) {\n for (const node of resolvedFeature.nodes) {\n if (typeof node?.getSubFields !== 'function') {\n continue\n }\n const subFields = node.getSubFields({})\n if (subFields?.length) {\n genImportMapIterateFields({\n addToImportMap,\n baseDir,\n config,\n fields: subFields,\n importMap,\n imports,\n })\n }\n }\n }\n }\n }\n"],"names":["genImportMapIterateFields","getGenerateImportMap","args","addToImportMap","baseDir","config","importMap","imports","lexicalEditorArgs","views","resolvedFeature","resolvedFeatureMap","values","componentImports","Array","isArray","Object","ClientFeature","nodes","length","node","getSubFields","subFields","fields"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ,UAAS;AAKnD,OAAO,MAAMC,uBACX,CAACC,OAID,CAAC,EAAEC,cAAc,EAAEC,OAAO,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,EAAE;QACtDJ,eAAe;QACfA,eAAe;QACfA,eAAe;QAEfA,eAAeD,KAAKM,iBAAiB,EAAEC;QAEvC,KAAK,MAAMC,mBAAmBR,KAAKS,kBAAkB,CAACC,MAAM,GAAI;YAC9D,IAAI,sBAAsBF,iBAAiB;gBACzC,IAAI,OAAOA,gBAAgBG,gBAAgB,KAAK,YAAY;oBAC1DH,gBAAgBG,gBAAgB,CAAC;wBAC/BV;wBACAC;wBACAC;wBACAC;wBACAC;oBACF;gBACF,OAAO,IAAIO,MAAMC,OAAO,CAACL,gBAAgBG,gBAAgB,GAAG;oBAC1DV,eAAeO,gBAAgBG,gBAAgB;gBACjD,OAAO,IAAI,OAAOH,gBAAgBG,gBAAgB,KAAK,UAAU;oBAC/DV,eAAea,OAAOJ,MAAM,CAACF,gBAAgBG,gBAAgB;gBAC/D;YACF;YAEAV,eAAeO,gBAAgBO,aAAa;YAE5C;;OAEC,GACD,IAAIP,gBAAgBQ,KAAK,EAAEC,QAAQ;gBACjC,KAAK,MAAMC,QAAQV,gBAAgBQ,KAAK,CAAE;oBACxC,IAAI,OAAOE,MAAMC,iBAAiB,YAAY;wBAC5C;oBACF;oBACA,MAAMC,YAAYF,KAAKC,YAAY,CAAC,CAAC;oBACrC,IAAIC,WAAWH,QAAQ;wBACrBnB,0BAA0B;4BACxBG;4BACAC;4BACAC;4BACAkB,QAAQD;4BACRhB;4BACAC;wBACF;oBACF;gBACF;YACF;QACF;IACF,EAAC"}
@@ -1,3 +1,8 @@
1
1
  import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
2
- export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): boolean;
2
+ /**
3
+ * This function checks if the editor state is empty (has any text). If the editor state has no nodes,
4
+ * or only an empty paragraph node (no TextNode with length > 0), it returns false.
5
+ * Otherwise, it returns true.
6
+ */
7
+ export declare function hasText(value: null | SerializedEditorState<SerializedLexicalNode> | undefined): value is SerializedEditorState<SerializedLexicalNode>;
3
8
  //# sourceMappingURL=hasText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,OAAO,CA0BT"}
1
+ {"version":3,"file":"hasText.d.ts","sourceRoot":"","sources":["../../src/validate/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EAGtB,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,IAAI,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,SAAS,GACrE,KAAK,IAAI,qBAAqB,CAAC,qBAAqB,CAAC,CA6BvD"}
@@ -1,5 +1,12 @@
1
- export function hasText(value) {
1
+ /**
2
+ * This function checks if the editor state is empty (has any text). If the editor state has no nodes,
3
+ * or only an empty paragraph node (no TextNode with length > 0), it returns false.
4
+ * Otherwise, it returns true.
5
+ */ export function hasText(value) {
2
6
  const hasChildren = !!value?.root?.children?.length;
7
+ if (!hasChildren) {
8
+ return false;
9
+ }
3
10
  let hasOnlyEmptyParagraph = false;
4
11
  if (value?.root?.children?.length === 1) {
5
12
  if (value?.root?.children[0]?.type === 'paragraph') {
@@ -16,11 +23,10 @@ export function hasText(value) {
16
23
  }
17
24
  }
18
25
  }
19
- if (!hasChildren || hasOnlyEmptyParagraph) {
26
+ if (hasOnlyEmptyParagraph) {
20
27
  return false;
21
- } else {
22
- return true;
23
28
  }
29
+ return true;
24
30
  }
25
31
 
26
32
  //# sourceMappingURL=hasText.js.map