@payloadcms/richtext-lexical 3.0.0-beta.25 → 3.0.0-beta.27

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 (176) hide show
  1. package/dist/exports/components.d.ts +5 -0
  2. package/dist/exports/components.d.ts.map +1 -1
  3. package/dist/exports/components.js +5 -0
  4. package/dist/exports/components.js.map +1 -1
  5. package/dist/field/features/blockquote/feature.client.d.ts +1 -1
  6. package/dist/field/features/blockquote/feature.client.js +2 -2
  7. package/dist/field/features/blockquote/feature.client.js.map +1 -1
  8. package/dist/field/features/blockquote/feature.server.d.ts +1 -1
  9. package/dist/field/features/blockquote/feature.server.js +3 -3
  10. package/dist/field/features/blockquote/feature.server.js.map +1 -1
  11. package/dist/field/features/blocks/feature.server.d.ts +2 -5
  12. package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
  13. package/dist/field/features/blocks/feature.server.js +2 -2
  14. package/dist/field/features/blocks/feature.server.js.map +1 -1
  15. package/dist/field/features/blocks/plugin/index.d.ts +3 -2
  16. package/dist/field/features/blocks/plugin/index.d.ts.map +1 -1
  17. package/dist/field/features/blocks/plugin/index.js +2 -2
  18. package/dist/field/features/blocks/plugin/index.js.map +1 -1
  19. package/dist/field/features/debug/testRecorder/plugin/index.d.ts +2 -2
  20. package/dist/field/features/debug/testRecorder/plugin/index.d.ts.map +1 -1
  21. package/dist/field/features/debug/testRecorder/plugin/index.js.map +1 -1
  22. package/dist/field/features/debug/treeView/plugin/index.d.ts +2 -2
  23. package/dist/field/features/debug/treeView/plugin/index.d.ts.map +1 -1
  24. package/dist/field/features/debug/treeView/plugin/index.js +2 -2
  25. package/dist/field/features/debug/treeView/plugin/index.js.map +1 -1
  26. package/dist/field/features/horizontalRule/plugin/index.d.ts +2 -1
  27. package/dist/field/features/horizontalRule/plugin/index.d.ts.map +1 -1
  28. package/dist/field/features/horizontalRule/plugin/index.js +2 -2
  29. package/dist/field/features/horizontalRule/plugin/index.js.map +1 -1
  30. package/dist/field/features/link/drawer/baseFields.d.ts +2 -2
  31. package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
  32. package/dist/field/features/link/drawer/baseFields.js +2 -1
  33. package/dist/field/features/link/drawer/baseFields.js.map +1 -1
  34. package/dist/field/features/link/drawer/types.d.ts +2 -2
  35. package/dist/field/features/link/drawer/types.d.ts.map +1 -1
  36. package/dist/field/features/link/drawer/types.js.map +1 -1
  37. package/dist/field/features/link/feature.client.d.ts.map +1 -1
  38. package/dist/field/features/link/feature.client.js +11 -1
  39. package/dist/field/features/link/feature.client.js.map +1 -1
  40. package/dist/field/features/link/feature.server.d.ts +10 -3
  41. package/dist/field/features/link/feature.server.d.ts.map +1 -1
  42. package/dist/field/features/link/feature.server.js +3 -3
  43. package/dist/field/features/link/feature.server.js.map +1 -1
  44. package/dist/field/features/link/plugins/autoLink/index.d.ts +3 -2
  45. package/dist/field/features/link/plugins/autoLink/index.d.ts.map +1 -1
  46. package/dist/field/features/link/plugins/autoLink/index.js +2 -2
  47. package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
  48. package/dist/field/features/link/plugins/clickableLink/index.d.ts +3 -2
  49. package/dist/field/features/link/plugins/clickableLink/index.d.ts.map +1 -1
  50. package/dist/field/features/link/plugins/clickableLink/index.js +2 -2
  51. package/dist/field/features/link/plugins/clickableLink/index.js.map +1 -1
  52. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  53. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +75 -68
  54. package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  55. package/dist/field/features/link/plugins/floatingLinkEditor/index.d.ts +3 -4
  56. package/dist/field/features/link/plugins/floatingLinkEditor/index.d.ts.map +1 -1
  57. package/dist/field/features/link/plugins/floatingLinkEditor/index.js.map +1 -1
  58. package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +2 -2
  59. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -3
  60. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
  61. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +2 -2
  62. package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
  63. package/dist/field/features/link/plugins/link/index.d.ts +3 -1
  64. package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
  65. package/dist/field/features/link/plugins/link/index.js +2 -2
  66. package/dist/field/features/link/plugins/link/index.js.map +1 -1
  67. package/dist/field/features/link/validate.js.map +1 -1
  68. package/dist/field/features/lists/checklist/plugin/index.d.ts +2 -2
  69. package/dist/field/features/lists/checklist/plugin/index.d.ts.map +1 -1
  70. package/dist/field/features/lists/checklist/plugin/index.js +2 -2
  71. package/dist/field/features/lists/checklist/plugin/index.js.map +1 -1
  72. package/dist/field/features/lists/plugin/index.d.ts +2 -2
  73. package/dist/field/features/lists/plugin/index.d.ts.map +1 -1
  74. package/dist/field/features/lists/plugin/index.js +2 -2
  75. package/dist/field/features/lists/plugin/index.js.map +1 -1
  76. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.d.ts +1 -1
  77. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js +1 -1
  78. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/client.js.map +1 -1
  79. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js +2 -2
  80. package/dist/field/features/migrations/slateToLexical/converter/converters/blockquote/index.js.map +1 -1
  81. package/dist/field/features/relationship/feature.client.d.ts.map +1 -1
  82. package/dist/field/features/relationship/feature.client.js +1 -5
  83. package/dist/field/features/relationship/feature.client.js.map +1 -1
  84. package/dist/field/features/relationship/feature.server.d.ts +10 -1
  85. package/dist/field/features/relationship/feature.server.d.ts.map +1 -1
  86. package/dist/field/features/relationship/feature.server.js +2 -2
  87. package/dist/field/features/relationship/feature.server.js.map +1 -1
  88. package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
  89. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +4 -2
  90. package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
  91. package/dist/field/features/relationship/plugins/index.d.ts +2 -2
  92. package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
  93. package/dist/field/features/relationship/plugins/index.js +6 -6
  94. package/dist/field/features/relationship/plugins/index.js.map +1 -1
  95. package/dist/field/features/relationship/populationPromise.d.ts +2 -1
  96. package/dist/field/features/relationship/populationPromise.d.ts.map +1 -1
  97. package/dist/field/features/relationship/populationPromise.js +25 -21
  98. package/dist/field/features/relationship/populationPromise.js.map +1 -1
  99. package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts +2 -4
  100. package/dist/field/features/toolbars/fixed/Toolbar/index.d.ts.map +1 -1
  101. package/dist/field/features/toolbars/fixed/Toolbar/index.js +2 -2
  102. package/dist/field/features/toolbars/fixed/Toolbar/index.js.map +1 -1
  103. package/dist/field/features/toolbars/fixed/Toolbar/index.scss +2 -2
  104. package/dist/field/features/toolbars/inline/Toolbar/index.d.ts +2 -4
  105. package/dist/field/features/toolbars/inline/Toolbar/index.d.ts.map +1 -1
  106. package/dist/field/features/toolbars/inline/Toolbar/index.js +25 -7
  107. package/dist/field/features/toolbars/inline/Toolbar/index.js.map +1 -1
  108. package/dist/field/features/toolbars/inline/Toolbar/index.scss +1 -1
  109. package/dist/field/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
  110. package/dist/field/features/toolbars/shared/ToolbarButton/index.js +12 -3
  111. package/dist/field/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
  112. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.d.ts.map +1 -1
  113. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js +11 -3
  114. package/dist/field/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
  115. package/dist/field/features/types.d.ts +20 -12
  116. package/dist/field/features/types.d.ts.map +1 -1
  117. package/dist/field/features/types.js.map +1 -1
  118. package/dist/field/features/upload/component/index.d.ts.map +1 -1
  119. package/dist/field/features/upload/component/index.js +6 -2
  120. package/dist/field/features/upload/component/index.js.map +1 -1
  121. package/dist/field/features/upload/feature.server.d.ts +10 -3
  122. package/dist/field/features/upload/feature.server.d.ts.map +1 -1
  123. package/dist/field/features/upload/feature.server.js +2 -2
  124. package/dist/field/features/upload/feature.server.js.map +1 -1
  125. package/dist/field/features/upload/nodes/UploadNode.d.ts.map +1 -1
  126. package/dist/field/features/upload/nodes/UploadNode.js +18 -2
  127. package/dist/field/features/upload/nodes/UploadNode.js.map +1 -1
  128. package/dist/field/features/upload/plugin/index.d.ts +3 -2
  129. package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
  130. package/dist/field/features/upload/plugin/index.js +2 -2
  131. package/dist/field/features/upload/plugin/index.js.map +1 -1
  132. package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
  133. package/dist/field/features/upload/populationPromise.js +2 -1
  134. package/dist/field/features/upload/populationPromise.js.map +1 -1
  135. package/dist/field/features/upload/validate.d.ts.map +1 -1
  136. package/dist/field/features/upload/validate.js +3 -0
  137. package/dist/field/features/upload/validate.js.map +1 -1
  138. package/dist/field/lexical/EditorPlugin.d.ts +1 -0
  139. package/dist/field/lexical/EditorPlugin.d.ts.map +1 -1
  140. package/dist/field/lexical/EditorPlugin.js +6 -3
  141. package/dist/field/lexical/EditorPlugin.js.map +1 -1
  142. package/dist/field/lexical/LexicalEditor.d.ts.map +1 -1
  143. package/dist/field/lexical/LexicalEditor.js +5 -0
  144. package/dist/field/lexical/LexicalEditor.js.map +1 -1
  145. package/dist/field/lexical/config/client/sanitize.d.ts.map +1 -1
  146. package/dist/field/lexical/config/client/sanitize.js +1 -0
  147. package/dist/field/lexical/config/client/sanitize.js.map +1 -1
  148. package/dist/field/lexical/config/server/default.js +2 -2
  149. package/dist/field/lexical/config/server/default.js.map +1 -1
  150. package/dist/field/lexical/config/server/loader.d.ts +2 -1
  151. package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
  152. package/dist/field/lexical/config/server/loader.js +2 -1
  153. package/dist/field/lexical/config/server/loader.js.map +1 -1
  154. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts +1 -1
  155. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.d.ts.map +1 -1
  156. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js +2 -2
  157. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/getNodeCloseToPoint.js.map +1 -1
  158. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
  159. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js +6 -3
  160. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
  161. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/index.scss +8 -0
  162. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.d.ts.map +1 -1
  163. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js +25 -6
  164. package/dist/field/lexical/plugins/handles/DraggableBlockPlugin/setTargetLine.js.map +1 -1
  165. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +11 -1
  166. package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
  167. package/dist/field/lexical/utils/setFloatingElemPosition.js +3 -2
  168. package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
  169. package/dist/index.d.ts +3 -4
  170. package/dist/index.d.ts.map +1 -1
  171. package/dist/index.js +3 -3
  172. package/dist/index.js.map +1 -1
  173. package/dist/types.d.ts +2 -1
  174. package/dist/types.d.ts.map +1 -1
  175. package/dist/types.js.map +1 -1
  176. package/package.json +9 -9
@@ -1,4 +1,9 @@
1
1
  export { RichTextCell } from '../cell/index.js';
2
+ export { createClientComponent } from '../field/features/createClientComponent.js';
3
+ export { toolbarFormatGroupWithItems } from '../field/features/format/shared/toolbarFormatGroup.js';
4
+ export { toolbarAddDropdownGroupWithItems } from '../field/features/shared/toolbar/addDropdownGroup.js';
5
+ export { toolbarFeatureButtonsGroupWithItems } from '../field/features/shared/toolbar/featureButtonsGroup.js';
6
+ export { toolbarTextDropdownGroupWithItems } from '../field/features/shared/toolbar/textDropdownGroup.js';
2
7
  export { ToolbarButton } from '../field/features/toolbars/shared/ToolbarButton/index.js';
3
8
  export { ToolbarDropdown } from '../field/features/toolbars/shared/ToolbarDropdown/index.js';
4
9
  export { RichTextField } from '../field/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/exports/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0DAA0D,CAAA;AAExF,OAAO,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAA;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACL,KAAK,sBAAsB,EAC3B,mBAAmB,EACnB,cAAc,GACf,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/exports/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAA;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAA;AACnG,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAA;AAC7G,OAAO,EAAE,iCAAiC,EAAE,MAAM,uDAAuD,CAAA;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,0DAA0D,CAAA;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,4DAA4D,CAAA;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EACL,KAAK,sBAAsB,EAC3B,mBAAmB,EACnB,cAAc,GACf,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA"}
@@ -1,4 +1,9 @@
1
1
  export { RichTextCell } from '../cell/index.js';
2
+ export { createClientComponent } from '../field/features/createClientComponent.js';
3
+ export { toolbarFormatGroupWithItems } from '../field/features/format/shared/toolbarFormatGroup.js';
4
+ export { toolbarAddDropdownGroupWithItems } from '../field/features/shared/toolbar/addDropdownGroup.js';
5
+ export { toolbarFeatureButtonsGroupWithItems } from '../field/features/shared/toolbar/featureButtonsGroup.js';
6
+ export { toolbarTextDropdownGroupWithItems } from '../field/features/shared/toolbar/textDropdownGroup.js';
2
7
  export { ToolbarButton } from '../field/features/toolbars/shared/ToolbarButton/index.js';
3
8
  export { ToolbarDropdown } from '../field/features/toolbars/shared/ToolbarDropdown/index.js';
4
9
  export { RichTextField } from '../field/index.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/components.ts"],"sourcesContent":["export { RichTextCell } from '../cell/index.js'\nexport { ToolbarButton } from '../field/features/toolbars/shared/ToolbarButton/index.js'\n\nexport { ToolbarDropdown } from '../field/features/toolbars/shared/ToolbarDropdown/index.js'\nexport { RichTextField } from '../field/index.js'\nexport {\n type EditorFocusContextType,\n EditorFocusProvider,\n useEditorFocus,\n} from '../field/lexical/EditorFocusProvider.js'\nexport { defaultEditorLexicalConfig } from '../field/lexical/config/client/default.js'\n"],"names":["RichTextCell","ToolbarButton","ToolbarDropdown","RichTextField","EditorFocusProvider","useEditorFocus","defaultEditorLexicalConfig"],"rangeMappings":";;;;;","mappings":"AAAA,SAASA,YAAY,QAAQ,mBAAkB;AAC/C,SAASC,aAAa,QAAQ,2DAA0D;AAExF,SAASC,eAAe,QAAQ,6DAA4D;AAC5F,SAASC,aAAa,QAAQ,oBAAmB;AACjD,SAEEC,mBAAmB,EACnBC,cAAc,QACT,0CAAyC;AAChD,SAASC,0BAA0B,QAAQ,4CAA2C"}
1
+ {"version":3,"sources":["../../src/exports/components.ts"],"sourcesContent":["export { RichTextCell } from '../cell/index.js'\nexport { createClientComponent } from '../field/features/createClientComponent.js'\n\nexport { toolbarFormatGroupWithItems } from '../field/features/format/shared/toolbarFormatGroup.js'\nexport { toolbarAddDropdownGroupWithItems } from '../field/features/shared/toolbar/addDropdownGroup.js'\nexport { toolbarFeatureButtonsGroupWithItems } from '../field/features/shared/toolbar/featureButtonsGroup.js'\nexport { toolbarTextDropdownGroupWithItems } from '../field/features/shared/toolbar/textDropdownGroup.js'\nexport { ToolbarButton } from '../field/features/toolbars/shared/ToolbarButton/index.js'\nexport { ToolbarDropdown } from '../field/features/toolbars/shared/ToolbarDropdown/index.js'\n\nexport { RichTextField } from '../field/index.js'\nexport {\n type EditorFocusContextType,\n EditorFocusProvider,\n useEditorFocus,\n} from '../field/lexical/EditorFocusProvider.js'\nexport { defaultEditorLexicalConfig } from '../field/lexical/config/client/default.js'\n"],"names":["RichTextCell","createClientComponent","toolbarFormatGroupWithItems","toolbarAddDropdownGroupWithItems","toolbarFeatureButtonsGroupWithItems","toolbarTextDropdownGroupWithItems","ToolbarButton","ToolbarDropdown","RichTextField","EditorFocusProvider","useEditorFocus","defaultEditorLexicalConfig"],"rangeMappings":";;;;;;;;;;","mappings":"AAAA,SAASA,YAAY,QAAQ,mBAAkB;AAC/C,SAASC,qBAAqB,QAAQ,6CAA4C;AAElF,SAASC,2BAA2B,QAAQ,wDAAuD;AACnG,SAASC,gCAAgC,QAAQ,uDAAsD;AACvG,SAASC,mCAAmC,QAAQ,0DAAyD;AAC7G,SAASC,iCAAiC,QAAQ,wDAAuD;AACzG,SAASC,aAAa,QAAQ,2DAA0D;AACxF,SAASC,eAAe,QAAQ,6DAA4D;AAE5F,SAASC,aAAa,QAAQ,oBAAmB;AACjD,SAEEC,mBAAmB,EACnBC,cAAc,QACT,0CAAyC;AAChD,SAASC,0BAA0B,QAAQ,4CAA2C"}
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" resolution-mode="require"/>
2
- export declare const BlockQuoteFeatureClientComponent: import("react").FC<undefined>;
2
+ export declare const BlockquoteFeatureClientComponent: import("react").FC<undefined>;
3
3
  //# sourceMappingURL=feature.client.d.ts.map
@@ -33,7 +33,7 @@ const toolbarGroups = [
33
33
  }
34
34
  ])
35
35
  ];
36
- const BlockQuoteFeatureClient = (props)=>{
36
+ const BlockquoteFeatureClient = (props)=>{
37
37
  return {
38
38
  clientFeatureProps: props,
39
39
  feature: ()=>({
@@ -78,6 +78,6 @@ const BlockQuoteFeatureClient = (props)=>{
78
78
  })
79
79
  };
80
80
  };
81
- export const BlockQuoteFeatureClientComponent = createClientComponent(BlockQuoteFeatureClient);
81
+ export const BlockquoteFeatureClientComponent = createClientComponent(BlockquoteFeatureClient);
82
82
 
83
83
  //# sourceMappingURL=feature.client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/blockquote/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { $createQuoteNode, $isQuoteNode, QuoteNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getSelection, $isRangeSelection } from 'lexical'\n\nimport type { ToolbarGroup } from '../toolbars/types.js'\nimport type { FeatureProviderProviderClient } from '../types.js'\n\nimport { BlockquoteIcon } from '../../lexical/ui/icons/Blockquote/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { toolbarTextDropdownGroupWithItems } from '../shared/toolbar/textDropdownGroup.js'\nimport { MarkdownTransformer } from './markdownTransformer.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarTextDropdownGroupWithItems([\n {\n ChildComponent: BlockquoteIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if (!$isQuoteNode(node) && !$isQuoteNode(node.getParent())) {\n return false\n }\n }\n return true\n },\n key: 'blockquote',\n label: `Blockquote`,\n onSelect: ({ editor }) => {\n editor.update(() => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createQuoteNode())\n })\n },\n order: 20,\n },\n ]),\n]\n\nconst BlockQuoteFeatureClient: FeatureProviderProviderClient<undefined> = (props) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n markdownTransformers: [MarkdownTransformer],\n nodes: [QuoteNode],\n\n slashMenu: {\n groups: [\n {\n items: [\n {\n Icon: BlockquoteIcon,\n key: 'blockquote',\n keywords: ['quote', 'blockquote'],\n label: 'Blockquote',\n onSelect: ({ editor }) => {\n editor.update(() => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createQuoteNode())\n })\n },\n },\n ],\n key: 'basic',\n label: 'Basic',\n },\n ],\n },\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n }),\n }\n}\n\nexport const BlockQuoteFeatureClientComponent = createClientComponent(BlockQuoteFeatureClient)\n"],"names":["$createQuoteNode","$isQuoteNode","QuoteNode","$setBlocksType","$getSelection","$isRangeSelection","BlockquoteIcon","createClientComponent","toolbarTextDropdownGroupWithItems","MarkdownTransformer","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getParent","key","label","onSelect","editor","update","order","BlockQuoteFeatureClient","props","clientFeatureProps","feature","markdownTransformers","nodes","slashMenu","groups","items","Icon","keywords","toolbarFixed","toolbarInline","BlockQuoteFeatureClientComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,gBAAgB,EAAEC,YAAY,EAAEC,SAAS,QAAQ,qBAAoB;AAC9E,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ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ACF;AACF;AAEA,OAAO,MAAM0B,mCAAmC7B,sBAAsBgB,yBAAwB"}
1
+ {"version":3,"sources":["../../../../src/field/features/blockquote/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { $createQuoteNode, $isQuoteNode, QuoteNode } from '@lexical/rich-text'\nimport { $setBlocksType } from '@lexical/selection'\nimport { $getSelection, $isRangeSelection } from 'lexical'\n\nimport type { ToolbarGroup } from '../toolbars/types.js'\nimport type { FeatureProviderProviderClient } from '../types.js'\n\nimport { BlockquoteIcon } from '../../lexical/ui/icons/Blockquote/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { toolbarTextDropdownGroupWithItems } from '../shared/toolbar/textDropdownGroup.js'\nimport { MarkdownTransformer } from './markdownTransformer.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarTextDropdownGroupWithItems([\n {\n ChildComponent: BlockquoteIcon,\n isActive: ({ selection }) => {\n if (!$isRangeSelection(selection)) {\n return false\n }\n for (const node of selection.getNodes()) {\n if (!$isQuoteNode(node) && !$isQuoteNode(node.getParent())) {\n return false\n }\n }\n return true\n },\n key: 'blockquote',\n label: `Blockquote`,\n onSelect: ({ editor }) => {\n editor.update(() => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createQuoteNode())\n })\n },\n order: 20,\n },\n ]),\n]\n\nconst BlockquoteFeatureClient: FeatureProviderProviderClient<undefined> = (props) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n markdownTransformers: [MarkdownTransformer],\n nodes: [QuoteNode],\n\n slashMenu: {\n groups: [\n {\n items: [\n {\n Icon: BlockquoteIcon,\n key: 'blockquote',\n keywords: ['quote', 'blockquote'],\n label: 'Blockquote',\n onSelect: ({ editor }) => {\n editor.update(() => {\n const selection = $getSelection()\n $setBlocksType(selection, () => $createQuoteNode())\n })\n },\n },\n ],\n key: 'basic',\n label: 'Basic',\n },\n ],\n },\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n }),\n }\n}\n\nexport const BlockquoteFeatureClientComponent = createClientComponent(BlockquoteFeatureClient)\n"],"names":["$createQuoteNode","$isQuoteNode","QuoteNode","$setBlocksType","$getSelection","$isRangeSelection","BlockquoteIcon","createClientComponent","toolbarTextDropdownGroupWithItems","MarkdownTransformer","toolbarGroups","ChildComponent","isActive","selection","node","getNodes","getParent","key","label","onSelect","editor","update","order","BlockquoteFeatureClient","props","clientFeatureProps","feature","markdownTransformers","nodes","slashMenu","groups","items","Icon","keywords","toolbarFixed","toolbarInline","BlockquoteFeatureClientComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,gBAAgB,EAAEC,YAAY,EAAEC,SAAS,QAAQ,qBAAoB;AAC9E,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,UAAS;AAK1D,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,iCAAiC,QAAQ,yCAAwC;AAC1F,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,MAAMC,gBAAgC;IACpCF,kCAAkC;QAChC;YACEG,gBAAgBL;YAChBM,UAAU,CAAC,EAAEC,SAAS,EAAE;gBACtB,IAAI,CAACR,kBAAkBQ,YAAY;oBACjC,OAAO;gBACT;gBACA,KAAK,MAAMC,QAAQD,UAAUE,QAAQ,GAAI;oBACvC,IAAI,CAACd,aAAaa,SAAS,CAACb,aAAaa,KAAKE,SAAS,KAAK;wBAC1D,OAAO;oBACT;gBACF;gBACA,OAAO;YACT;YACAC,KAAK;YACLC,OAAO,CAAC,UAAU,CAAC;YACnBC,UAAU,CAAC,EAAEC,MAAM,EAAE;gBACnBA,OAAOC,MAAM,CAAC;oBACZ,MAAMR,YAAYT;oBAClBD,eAAeU,WAAW,IAAMb;gBAClC;YACF;YACAsB,OAAO;QACT;KACD;CACF;AAED,MAAMC,0BAAoE,CAACC;IACzE,OAAO;QACLC,oBAAoBD;QACpBE,SAAS,IAAO,CAAA;gBACdD,oBAAoBD;gBACpBG,sBAAsB;oBAAClB;iBAAoB;gBAC3CmB,OAAO;oBAAC1B;iBAAU;gBAElB2B,WAAW;oBACTC,QAAQ;wBACN;4BACEC,OAAO;gCACL;oCACEC,MAAM1B;oCACNW,KAAK;oCACLgB,UAAU;wCAAC;wCAAS;qCAAa;oCACjCf,OAAO;oCACPC,UAAU,CAAC,EAAEC,MAAM,EAAE;wCACnBA,OAAOC,MAAM,CAAC;4CACZ,MAAMR,YAAYT;4CAClBD,eAAeU,WAAW,IAAMb;wCAClC;oCACF;gCACF;6BACD;4BACDiB,KAAK;4BACLC,OAAO;wBACT;qBACD;gBACH;gBACAgB,cAAc;oBACZJ,QAAQpB;gBACV;gBACAyB,eAAe;oBACbL,QAAQpB;gBACV;YACF,CAAA;IACF;AACF;AAEA,OAAO,MAAM0B,mCAAmC7B,sBAAsBgB,yBAAwB"}
@@ -1,3 +1,3 @@
1
1
  import type { FeatureProviderProviderServer } from '../types.js';
2
- export declare const BlockQuoteFeature: FeatureProviderProviderServer<undefined, undefined>;
2
+ export declare const BlockquoteFeature: FeatureProviderProviderServer<undefined, undefined>;
3
3
  //# sourceMappingURL=feature.server.d.ts.map
@@ -1,13 +1,13 @@
1
1
  import { QuoteNode } from '@lexical/rich-text';
2
2
  import { convertLexicalNodesToHTML } from '../converters/html/converter/index.js';
3
3
  import { createNode } from '../typeUtilities.js';
4
- import { BlockQuoteFeatureClientComponent } from './feature.client.js';
4
+ import { BlockquoteFeatureClientComponent } from './feature.client.js';
5
5
  import { MarkdownTransformer } from './markdownTransformer.js';
6
- export const BlockQuoteFeature = (props)=>{
6
+ export const BlockquoteFeature = (props)=>{
7
7
  return {
8
8
  feature: ()=>{
9
9
  return {
10
- ClientComponent: BlockQuoteFeatureClientComponent,
10
+ ClientComponent: BlockquoteFeatureClientComponent,
11
11
  clientFeatureProps: null,
12
12
  markdownTransformers: [
13
13
  MarkdownTransformer
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/blockquote/feature.server.ts"],"sourcesContent":["import { QuoteNode } from '@lexical/rich-text'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { BlockQuoteFeatureClientComponent } from './feature.client.js'\nimport { MarkdownTransformer } from './markdownTransformer.js'\n\nexport const BlockQuoteFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => {\n return {\n feature: () => {\n return {\n ClientComponent: BlockQuoteFeatureClientComponent,\n clientFeatureProps: null,\n markdownTransformers: [MarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n return `<blockquote>${childrenText}</blockquote>`\n },\n nodeTypes: [QuoteNode.getType()],\n },\n },\n node: QuoteNode,\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blockquote',\n serverFeatureProps: props,\n }\n}\n"],"names":["QuoteNode","convertLexicalNodesToHTML","createNode","BlockQuoteFeatureClientComponent","MarkdownTransformer","BlockQuoteFeature","props","feature","ClientComponent","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","node","parent","payload","childrenText","lexicalNodes","children","nodeTypes","getType","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAoB;AAI9C,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,gCAAgC,QAAQ,sBAAqB;AACtE,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,OAAO,MAAMC,oBAAyE,CAACC;IACrF,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBL;gBACjBM,oBAAoB;gBACpBC,sBAAsB;oBAACN;iBAAoB;gBAC3CO,OAAO;oBACLT,WAAW;wBACTU,YAAY;4BACVC,MAAM;gCACJC,WAAW,OAAO,EAAEF,UAAU,EAAEG,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;oCACrD,MAAMC,eAAe,MAAMjB,0BAA0B;wCACnDW;wCACAO,cAAcJ,KAAKK,QAAQ;wCAC3BJ,QAAQ;4CACN,GAAGD,IAAI;4CACPC;wCACF;wCACAC;oCACF;oCAEA,OAAO,CAAC,YAAY,EAAEC,aAAa,aAAa,CAAC;gCACnD;gCACAG,WAAW;oCAACrB,UAAUsB,OAAO;iCAAG;4BAClC;wBACF;wBACAP,MAAMf;oBACR;iBACD;gBACDuB,oBAAoBjB;YACtB;QACF;QACAkB,KAAK;QACLD,oBAAoBjB;IACtB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/blockquote/feature.server.ts"],"sourcesContent":["import { QuoteNode } from '@lexical/rich-text'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { BlockquoteFeatureClientComponent } from './feature.client.js'\nimport { MarkdownTransformer } from './markdownTransformer.js'\n\nexport const BlockquoteFeature: FeatureProviderProviderServer<undefined, undefined> = (props) => {\n return {\n feature: () => {\n return {\n ClientComponent: BlockquoteFeatureClientComponent,\n clientFeatureProps: null,\n markdownTransformers: [MarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n return `<blockquote>${childrenText}</blockquote>`\n },\n nodeTypes: [QuoteNode.getType()],\n },\n },\n node: QuoteNode,\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blockquote',\n serverFeatureProps: props,\n }\n}\n"],"names":["QuoteNode","convertLexicalNodesToHTML","createNode","BlockquoteFeatureClientComponent","MarkdownTransformer","BlockquoteFeature","props","feature","ClientComponent","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","node","parent","payload","childrenText","lexicalNodes","children","nodeTypes","getType","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAoB;AAI9C,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,gCAAgC,QAAQ,sBAAqB;AACtE,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,OAAO,MAAMC,oBAAyE,CAACC;IACrF,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBL;gBACjBM,oBAAoB;gBACpBC,sBAAsB;oBAACN;iBAAoB;gBAC3CO,OAAO;oBACLT,WAAW;wBACTU,YAAY;4BACVC,MAAM;gCACJC,WAAW,OAAO,EAAEF,UAAU,EAAEG,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;oCACrD,MAAMC,eAAe,MAAMjB,0BAA0B;wCACnDW;wCACAO,cAAcJ,KAAKK,QAAQ;wCAC3BJ,QAAQ;4CACN,GAAGD,IAAI;4CACPC;wCACF;wCACAC;oCACF;oCAEA,OAAO,CAAC,YAAY,EAAEC,aAAa,aAAa,CAAC;gCACnD;gCACAG,WAAW;oCAACrB,UAAUsB,OAAO;iCAAG;4BAClC;wBACF;wBACAP,MAAMf;oBACR;iBACD;gBACDuB,oBAAoBjB;YACtB;QACF;QACAkB,KAAK;QACLD,oBAAoBjB;IACtB;AACF,EAAC"}
@@ -1,11 +1,8 @@
1
- import type { Block, FieldWithRichTextRequiredEditor } from 'payload/types';
1
+ import type { Block } from 'payload/types';
2
2
  import type { FeatureProviderProviderServer } from '../types.js';
3
3
  import type { BlocksFeatureClientProps } from './feature.client.js';
4
- export type LexicalBlock = Omit<Block, 'fields'> & {
5
- fields: FieldWithRichTextRequiredEditor[];
6
- };
7
4
  export type BlocksFeatureProps = {
8
- blocks: LexicalBlock[];
5
+ blocks: Block[];
9
6
  };
10
7
  export declare const BlocksFeature: FeatureProviderProviderServer<BlocksFeatureProps, BlocksFeatureClientProps>;
11
8
  //# sourceMappingURL=feature.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/feature.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAqB,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAM9F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG;IACjD,MAAM,EAAE,+BAA+B,EAAE,CAAA;CAC1C,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,YAAY,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAsKzB,CAAA"}
1
+ {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/feature.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAA;AAM7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAsKzB,CAAA"}
@@ -8,7 +8,7 @@ import { blockPopulationPromiseHOC } from './populationPromise.js';
8
8
  import { blockValidationHOC } from './validate.js';
9
9
  export const BlocksFeature = (props)=>{
10
10
  return {
11
- feature: async ({ config: _config })=>{
11
+ feature: async ({ config: _config, isRoot })=>{
12
12
  if (props?.blocks?.length) {
13
13
  const validRelationships = _config.collections.map((c)=>c.slug) || [];
14
14
  for (const block of props.blocks){
@@ -17,7 +17,7 @@ export const BlocksFeature = (props)=>{
17
17
  block.fields = await sanitizeFields({
18
18
  config: _config,
19
19
  fields: block.fields,
20
- requireFieldLevelRichTextEditor: true,
20
+ requireFieldLevelRichTextEditor: isRoot,
21
21
  validRelationships
22
22
  });
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/blocks/feature.server.ts"],"sourcesContent":["import type { Config } from 'payload/config'\nimport type { Block, BlockField, Field, FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\nimport { baseBlockFields, sanitizeFields } from 'payload/config'\nimport { fieldsToJSONSchema, formatLabels } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { BlocksFeatureClientProps } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { BlocksFeatureClientComponent } from './feature.client.js'\nimport { BlockNode } from './nodes/BlocksNode.js'\nimport { blockPopulationPromiseHOC } from './populationPromise.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type LexicalBlock = Omit<Block, 'fields'> & {\n fields: FieldWithRichTextRequiredEditor[]\n}\n\nexport type BlocksFeatureProps = {\n blocks: LexicalBlock[]\n}\n\nexport const BlocksFeature: FeatureProviderProviderServer<\n BlocksFeatureProps,\n BlocksFeatureClientProps\n> = (props) => {\n return {\n feature: async ({ config: _config }) => {\n if (props?.blocks?.length) {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const block of props.blocks) {\n block.fields = block.fields.concat(baseBlockFields as FieldWithRichTextRequiredEditor[])\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = (await sanitizeFields({\n config: _config as unknown as Config,\n fields: block.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })) as FieldWithRichTextRequiredEditor[]\n }\n }\n\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n reducedBlocks: [],\n }\n for (const block of props.blocks) {\n clientProps.reducedBlocks.push({\n slug: block.slug,\n fieldMap: [],\n imageAltText: block.imageAltText,\n imageURL: block.imageURL,\n labels: block.labels,\n })\n }\n\n return {\n ClientComponent: BlocksFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap = new Map<string, Field[]>()\n\n for (const block of props.blocks) {\n schemaMap.set(block.slug, block.fields || [])\n\n traverseFields({\n config,\n fields: block.fields,\n i18n,\n schemaMap,\n schemaPath: block.slug,\n validRelationships,\n })\n }\n\n return schemaMap\n },\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length) {\n return currentSchema\n }\n\n const blocksField: BlockField = {\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n }\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(\n collectionIDFieldTypes,\n [blocksField],\n interfaceNameDefinitions,\n config,\n )\n\n return currentSchema\n },\n },\n nodes: [\n createNode({\n /* // TODO: Implement these hooks once docWithLocales / originalSiblingDoc => node matching has been figured out\n hooks: {\n beforeChange: [\n async ({ context, findMany, node, operation, overrideAccess, req }) => {\n const blockType = node.fields.blockType\n\n const block = deepCopyObject(\n props.blocks.find((block) => block.slug === blockType),\n )\n\n\n await beforeChangeTraverseFields({\n id: null,\n collection: null,\n context,\n data: node.fields,\n doc: node.fields,\n fields: sanitizedBlock.fields,\n global: null,\n mergeLocaleActions: [],\n operation:\n operation === 'create' || operation === 'update' ? operation : 'update',\n overrideAccess,\n path: '',\n req,\n siblingData: node.fields,\n siblingDoc: node.fields,\n })\n\n\n return node\n },\n ],\n beforeValidate: [\n async ({ context, findMany, node, operation, overrideAccess, req }) => {\n const blockType = node.fields.blockType\n\n const block = deepCopyObject(\n props.blocks.find((block) => block.slug === blockType),\n )\n\n\n\n await beforeValidateTraverseFields({\n id: null,\n collection: null,\n context,\n data: node.fields,\n doc: node.fields,\n fields: sanitizedBlock.fields,\n global: null,\n operation:\n operation === 'create' || operation === 'update' ? operation : 'update',\n overrideAccess,\n req,\n siblingData: node.fields,\n siblingDoc: node.fields,\n })\n\n return node\n },\n ],\n },*/\n node: BlockNode,\n populationPromises: [blockPopulationPromiseHOC(props)],\n validations: [blockValidationHOC(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blocks',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","baseBlockFields","sanitizeFields","fieldsToJSONSchema","formatLabels","createNode","BlocksFeatureClientComponent","BlockNode","blockPopulationPromiseHOC","blockValidationHOC","BlocksFeature","props","feature","config","_config","blocks","length","validRelationships","collections","map","c","slug","block","fields","concat","labels","requireFieldLevelRichTextEditor","clientProps","reducedBlocks","push","fieldMap","imageAltText","imageURL","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","set","schemaPath","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","blocksField","name","type","nodes","node","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACA4C,KAAK;QACLD,oBAAoB3C;IACtB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/blocks/feature.server.ts"],"sourcesContent":["import type { Config } from 'payload/config'\nimport type { Block, BlockField, Field } from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\nimport { baseBlockFields, sanitizeFields } from 'payload/config'\nimport { fieldsToJSONSchema, formatLabels } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { BlocksFeatureClientProps } from './feature.client.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { BlocksFeatureClientComponent } from './feature.client.js'\nimport { BlockNode } from './nodes/BlocksNode.js'\nimport { blockPopulationPromiseHOC } from './populationPromise.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks: Block[]\n}\n\nexport const BlocksFeature: FeatureProviderProviderServer<\n BlocksFeatureProps,\n BlocksFeatureClientProps\n> = (props) => {\n return {\n feature: async ({ config: _config, isRoot }) => {\n if (props?.blocks?.length) {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n for (const block of props.blocks) {\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: block.fields,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n }\n }\n\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n reducedBlocks: [],\n }\n for (const block of props.blocks) {\n clientProps.reducedBlocks.push({\n slug: block.slug,\n fieldMap: [],\n imageAltText: block.imageAltText,\n imageURL: block.imageURL,\n labels: block.labels,\n })\n }\n\n return {\n ClientComponent: BlocksFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap = new Map<string, Field[]>()\n\n for (const block of props.blocks) {\n schemaMap.set(block.slug, block.fields || [])\n\n traverseFields({\n config,\n fields: block.fields,\n i18n,\n schemaMap,\n schemaPath: block.slug,\n validRelationships,\n })\n }\n\n return schemaMap\n },\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length) {\n return currentSchema\n }\n\n const blocksField: BlockField = {\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n }\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(\n collectionIDFieldTypes,\n [blocksField],\n interfaceNameDefinitions,\n config,\n )\n\n return currentSchema\n },\n },\n nodes: [\n createNode({\n /* // TODO: Implement these hooks once docWithLocales / originalSiblingDoc => node matching has been figured out\n hooks: {\n beforeChange: [\n async ({ context, findMany, node, operation, overrideAccess, req }) => {\n const blockType = node.fields.blockType\n\n const block = deepCopyObject(\n props.blocks.find((block) => block.slug === blockType),\n )\n\n\n await beforeChangeTraverseFields({\n id: null,\n collection: null,\n context,\n data: node.fields,\n doc: node.fields,\n fields: sanitizedBlock.fields,\n global: null,\n mergeLocaleActions: [],\n operation:\n operation === 'create' || operation === 'update' ? operation : 'update',\n overrideAccess,\n path: '',\n req,\n siblingData: node.fields,\n siblingDoc: node.fields,\n })\n\n\n return node\n },\n ],\n beforeValidate: [\n async ({ context, findMany, node, operation, overrideAccess, req }) => {\n const blockType = node.fields.blockType\n\n const block = deepCopyObject(\n props.blocks.find((block) => block.slug === blockType),\n )\n\n\n\n await beforeValidateTraverseFields({\n id: null,\n collection: null,\n context,\n data: node.fields,\n doc: node.fields,\n fields: sanitizedBlock.fields,\n global: null,\n operation:\n operation === 'create' || operation === 'update' ? operation : 'update',\n overrideAccess,\n req,\n siblingData: node.fields,\n siblingDoc: node.fields,\n })\n\n return node\n },\n ],\n },*/\n node: BlockNode,\n populationPromises: [blockPopulationPromiseHOC(props)],\n validations: [blockValidationHOC(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blocks',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","baseBlockFields","sanitizeFields","fieldsToJSONSchema","formatLabels","createNode","BlocksFeatureClientComponent","BlockNode","blockPopulationPromiseHOC","blockValidationHOC","BlocksFeature","props","feature","config","_config","isRoot","blocks","length","validRelationships","collections","map","c","slug","block","fields","concat","labels","requireFieldLevelRichTextEditor","clientProps","reducedBlocks","push","fieldMap","imageAltText","imageURL","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","schemaMap","Map","set","schemaPath","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","blocksField","name","type","nodes","node","populationPromises","validations","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,eAAe,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,oBAAmB;AAKpE,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,yBAAyB,QAAQ,yBAAwB;AAClE,SAASC,kBAAkB,QAAQ,gBAAe;AAMlD,OAAO,MAAMC,gBAGT,CAACC;IACH,OAAO;QACLC,SAAS,OAAO,EAAEC,QAAQC,OAAO,EAAEC,MAAM,EAAE;YACzC,IAAIJ,OAAOK,QAAQC,QAAQ;gBACzB,MAAMC,qBAAq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;gBACAI,gBAAgB;oBACdC,oBAAoB,CAAC,EACnBC,sBAAsB,EACtB/B,MAAM,EACNgC,aAAa,EACbC,KAAK,EACLC,wBAAwB,EACzB;wBACC,IAAI,CAACpC,OAAOK,QAAQC,QAAQ;4BAC1B,OAAO4B;wBACT;wBAEA,MAAMG,cAA0B;4BAC9BC,MAAMH,OAAOG,OAAO;4BACpBC,MAAM;4BACNlC,QAAQL,MAAMK,MAAM;wBACtB;wBACA,wFAAwF;wBACxF,2EAA2E;wBAC3Eb,mBACEyC,wBACA;4BAACI;yBAAY,EACbD,0BACAlC;wBAGF,OAAOgC;oBACT;gBACF;gBACAM,OAAO;oBACL9C,WAAW;wBACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8DE,GACF+C,MAAM7C;wBACN8C,oBAAoB;4BAAC7C,0BAA0BG;yBAAO;wBACtD2C,aAAa;4BAAC7C,mBAAmBE;yBAAO;oBAC1C;iBACD;gBACD4C,oBAAoB5C;YACtB;QACF;QACA6C,KAAK;QACLD,oBAAoB5C;IACtB;AACF,EAAC"}
@@ -1,5 +1,6 @@
1
- import React from 'react';
1
+ import type { PluginComponent } from '../../types.js';
2
+ import type { BlocksFeatureClientProps } from '../feature.client.js';
2
3
  import type { BlockFields } from '../nodes/BlocksNode.js';
3
4
  export type InsertBlockPayload = Exclude<BlockFields, 'id'>;
4
- export declare function BlocksPlugin(): React.ReactNode;
5
+ export declare const BlocksPlugin: PluginComponent<BlocksFeatureClientProps>;
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAMzD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAE3D,wBAAgB,YAAY,IAAI,KAAK,CAAC,SAAS,CA8C9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAMzD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAE3D,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,wBAAwB,CA8ClE,CAAA"}
@@ -6,7 +6,7 @@ import React, { useEffect } from 'react';
6
6
  import { BlocksDrawerComponent } from '../drawer/index.js';
7
7
  import { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js';
8
8
  import { INSERT_BLOCK_COMMAND } from './commands.js';
9
- export function BlocksPlugin() {
9
+ export const BlocksPlugin = ()=>{
10
10
  const [editor] = useLexicalComposerContext();
11
11
  useEffect(()=>{
12
12
  if (!editor.hasNodes([
@@ -35,6 +35,6 @@ export function BlocksPlugin() {
35
35
  editor
36
36
  ]);
37
37
  return /*#__PURE__*/ React.createElement(BlocksDrawerComponent, null);
38
- }
38
+ };
39
39
 
40
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { BlockFields } from '../nodes/BlocksNode.js'\n\nimport { BlocksDrawerComponent } from '../drawer/index.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { INSERT_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = Exclude<BlockFields, 'id'>\n\nexport function BlocksPlugin(): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const blockNode = $createBlockNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(blockNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <BlocksDrawerComponent />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","mergeRegister","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","React","useEffect","BlocksDrawerComponent","$createBlockNode","BlockNode","INSERT_BLOCK_COMMAND","BlocksPlugin","editor","hasNodes","Error","registerCommand","payload","update","blockNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,iBAAgB;AACxE,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,QAClB,UAAS;AAChB,OAAOC,SAASC,SAAS,QAAQ,QAAO;AAIxC,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,yBAAwB;AACpE,SAASC,oBAAoB,QAAQ,gBAAe;AAIpD,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGf;IAEjBS,UAAU;QACR,IAAI,CAACM,OAAOC,QAAQ,CAAC;YAACJ;SAAU,GAAG;YACjC,MAAM,IAAIK,MAAM;QAClB;QAEA,OAAOf,cACLa,OAAOG,eAAe,CACpBL,sBACA,CAACM;YACCJ,OAAOK,MAAM,CAAC;gBACZ,MAAMC,YAAYV,iBAAiBQ;gBAEnC,MAAMG,YAAYlB,mBAAmBD;gBAErC,IAAIG,kBAAkBgB,YAAY;oBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;oBAClB,MAAME,YAAYD,MAAME,OAAO;oBAE/B,+FAA+F;oBAC/F,0FAA0F;oBAC1F,IACEpB,iBAAiBmB,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXC,MAAM,CAAC,CAACC,OAASzB,iBAAiByB,OAAOC,MAAM,GAAG,GACrD;wBACAP,UAAUQ,MAAM;oBAClB;oBAEA/B,yBAAyBoB;gBAC3B;YACF;YAEA,OAAO;QACT,GACAd;IAGN,GAAG;QAACQ;KAAO;IAEX,qBAAO,oBAACL;AACV"}
1
+ {"version":3,"sources":["../../../../../src/field/features/blocks/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, mergeRegister } from '@lexical/utils'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport React, { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../types.js'\nimport type { BlocksFeatureClientProps } from '../feature.client.js'\nimport type { BlockFields } from '../nodes/BlocksNode.js'\n\nimport { BlocksDrawerComponent } from '../drawer/index.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { INSERT_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = Exclude<BlockFields, 'id'>\n\nexport const BlocksPlugin: PluginComponent<BlocksFeatureClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const blockNode = $createBlockNode(payload)\n\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParent()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n\n $insertNodeToNearestRoot(blockNode)\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor])\n\n return <BlocksDrawerComponent />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","mergeRegister","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","React","useEffect","BlocksDrawerComponent","$createBlockNode","BlockNode","INSERT_BLOCK_COMMAND","BlocksPlugin","editor","hasNodes","Error","registerCommand","payload","update","blockNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","filter","node","length","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,EAAEC,aAAa,QAAQ,iBAAgB;AACxE,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,QAClB,UAAS;AAChB,OAAOC,SAASC,SAAS,QAAQ,QAAO;AAMxC,SAASC,qBAAqB,QAAQ,qBAAoB;AAC1D,SAASC,gBAAgB,EAAEC,SAAS,QAAQ,yBAAwB;AACpE,SAASC,oBAAoB,QAAQ,gBAAe;AAIpD,OAAO,MAAMC,eAA0D;IACrE,MAAM,CAACC,OAAO,GAAGf;IAEjBS,UAAU;QACR,IAAI,CAACM,OAAOC,QAAQ,CAAC;YAACJ;SAAU,GAAG;YACjC,MAAM,IAAIK,MAAM;QAClB;QAEA,OAAOf,cACLa,OAAOG,eAAe,CACpBL,sBACA,CAACM;YACCJ,OAAOK,MAAM,CAAC;gBACZ,MAAMC,YAAYV,iBAAiBQ;gBAEnC,MAAMG,YAAYlB,mBAAmBD;gBAErC,IAAIG,kBAAkBgB,YAAY;oBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;oBAClB,MAAME,YAAYD,MAAME,OAAO;oBAE/B,+FAA+F;oBAC/F,0FAA0F;oBAC1F,IACEpB,iBAAiBmB,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXC,MAAM,CAAC,CAACC,OAASzB,iBAAiByB,OAAOC,MAAM,GAAG,GACrD;wBACAP,UAAUQ,MAAM;oBAClB;oBAEA/B,yBAAyBoB;gBAC3B;YACF;YAEA,OAAO;QACT,GACAd;IAGN,GAAG;QAACQ;KAAO;IAEX,qBAAO,oBAACL;AACV,EAAC"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
1
+ import type { PluginComponent } from '../../../types.js';
2
2
  import './index.scss';
3
3
  export declare function isSelectAll(event: KeyboardEvent): boolean;
4
- export declare const TestRecorderPlugin: React.FC;
4
+ export declare const TestRecorderPlugin: PluginComponent<undefined>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/debug/testRecorder/plugin/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,cAAc,CAAA;AA8ErB,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAEzD;AAmWD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAYtC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/debug/testRecorder/plugin/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAGxD,OAAO,cAAc,CAAA;AA8ErB,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAEzD;AAmWD,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,SAAS,CAYzD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/debug/testRecorder/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, $createTextNode, $getRoot } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nimport { IS_APPLE } from '../../../../lexical/utils/environment.js'\nimport './index.scss'\n\nconst copy = (text: null | string) => {\n const textArea = document.createElement('textarea')\n textArea.value = text || ''\n textArea.style.position = 'absolute'\n textArea.style.opacity = '0'\n document.body?.appendChild(textArea)\n textArea.focus()\n textArea.select()\n try {\n const result = document.execCommand('copy')\n // eslint-disable-next-line no-console\n console.log(result)\n } catch (error) {\n console.error(error)\n }\n document.body?.removeChild(textArea)\n}\n\nconst download = (filename: string, text: null | string) => {\n const a = document.createElement('a')\n a.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text || ''))\n a.setAttribute('download', filename)\n a.style.display = 'none'\n document.body?.appendChild(a)\n a.click()\n document.body?.removeChild(a)\n}\n\nconst formatStep = (step: Step) => {\n const formatOneStep = (name: string, value: Step['value']) => {\n switch (name) {\n case 'click': {\n return ` await page.mouse.click(${value.x}, ${value.y});`\n }\n case 'press': {\n return ` await page.keyboard.press('${value}');`\n }\n case 'keydown': {\n return ` await page.keyboard.keydown('${value}');`\n }\n case 'keyup': {\n return ` await page.keyboard.keyup('${value}');`\n }\n case 'type': {\n return ` await page.keyboard.type('${value}');`\n }\n case 'selectAll': {\n return ` await selectAll(page);`\n }\n case 'snapshot': {\n return ` await assertHTMLSnapshot(page);\n await assertSelection(page, {\n anchorPath: [${value.anchorPath.toString()}],\n anchorOffset: ${value.anchorOffset},\n focusPath: [${value.focusPath.toString()}],\n focusOffset: ${value.focusOffset},\n });\n`\n }\n default:\n return ``\n }\n }\n const formattedStep = formatOneStep(step.name, step.value)\n switch (step.count) {\n case 1:\n return formattedStep\n case 2:\n return [formattedStep, formattedStep].join(`\\n`)\n default:\n return ` await repeat(${step.count}, async () => {\n ${formattedStep}\n );`\n }\n}\n\nexport function isSelectAll(event: KeyboardEvent): boolean {\n return event.keyCode === 65 && (IS_APPLE ? event.metaKey : event.ctrlKey)\n}\n\n// stolen from LexicalSelection-test\nfunction sanitizeSelection(selection: Selection) {\n const { anchorNode, focusNode } = selection\n let { anchorOffset, focusOffset } = selection\n if (anchorOffset !== 0) {\n anchorOffset--\n }\n if (focusOffset !== 0) {\n focusOffset--\n }\n return { anchorNode, anchorOffset, focusNode, focusOffset }\n}\n\nfunction getPathFromNodeToEditor(node: Node, rootElement: HTMLElement | null) {\n let currentNode: Node | null | undefined = node\n const path = []\n while (currentNode !== rootElement) {\n if (currentNode !== null && currentNode !== undefined) {\n path.unshift(\n Array.from(currentNode?.parentNode?.childNodes ?? []).indexOf(currentNode as ChildNode),\n )\n }\n currentNode = currentNode?.parentNode\n }\n return path\n}\n\nconst keyPresses = new Set([\n 'Enter',\n 'Backspace',\n 'Delete',\n 'Escape',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowDown',\n])\n\ntype Step = {\n count: number\n name: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any\n}\n\ntype Steps = Step[]\n\nfunction useTestRecorder(editor: LexicalEditor): [JSX.Element, JSX.Element | null] {\n const [steps, setSteps] = useState<Steps>([])\n const [isRecording, setIsRecording] = useState(false)\n const [, setCurrentInnerHTML] = useState('')\n const [templatedTest, setTemplatedTest] = useState('')\n const previousSelectionRef = useRef<BaseSelection | null>(null)\n const skipNextSelectionChangeRef = useRef(false)\n const preRef = useRef<HTMLPreElement>(null)\n\n const getCurrentEditor = useCallback(() => {\n return editor\n }, [editor])\n\n const generateTestContent = useCallback(() => {\n const rootElement = editor.getRootElement()\n const browserSelection = window.getSelection()\n\n if (\n rootElement == null ||\n browserSelection == null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null ||\n !rootElement.contains(browserSelection.anchorNode) ||\n !rootElement.contains(browserSelection.focusNode)\n ) {\n return null\n }\n\n return `\nimport {\n initializeE2E,\n assertHTMLSnapshot,\n assertSelection,\n repeat,\n} from '../utils';\nimport {selectAll} from '../keyboardShortcuts';\nimport { RangeSelection } from 'lexical';\nimport { NodeSelection } from 'lexical';\n\ndescribe('Test case', () => {\n initializeE2E((e2e) => {\n it('Should pass this test', async () => {\n const {page} = e2e;\n\n await page.focus('div[contenteditable=\"true\"]');\n${steps.map(formatStep).join(`\\n`)}\n });\n});\n `\n }, [editor, steps])\n\n // just a wrapper around inserting new actions so that we can\n // coalesce some actions like insertText/moveNativeSelection\n const pushStep = useCallback(\n (name: string, value: Step['value']) => {\n setSteps((currentSteps) => {\n // trying to group steps\n const currentIndex = steps.length - 1\n const lastStep = steps[currentIndex]\n if (lastStep) {\n if (lastStep.name === name) {\n if (name === 'type') {\n // for typing events we just append the text\n return [\n ...steps.slice(0, currentIndex),\n { ...lastStep, value: lastStep.value + value },\n ]\n } else {\n // for other events we bump the counter if their values are the same\n if (lastStep.value === value) {\n return [...steps.slice(0, currentIndex), { ...lastStep, count: lastStep.count + 1 }]\n }\n }\n }\n }\n // could not group, just append a new one\n return [...currentSteps, { name, count: 1, value }]\n })\n },\n [steps, setSteps],\n )\n\n useLayoutEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (isSelectAll(event)) {\n pushStep('selectAll', '')\n } else if (keyPresses.has(key)) {\n pushStep('press', event.key)\n } else if ([...key].length > 1) {\n pushStep('keydown', event.key)\n } else {\n pushStep('type', event.key)\n }\n }\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (!keyPresses.has(key) && [...key].length > 1) {\n pushStep('keyup', event.key)\n }\n }\n\n return editor.registerRootListener(\n (rootElement: HTMLElement | null, prevRootElement: HTMLElement | null) => {\n if (prevRootElement !== null) {\n prevRootElement.removeEventListener('keydown', onKeyDown)\n prevRootElement.removeEventListener('keyup', onKeyUp)\n }\n if (rootElement !== null) {\n rootElement.addEventListener('keydown', onKeyDown)\n rootElement.addEventListener('keyup', onKeyUp)\n }\n },\n )\n }, [editor, isRecording, pushStep])\n\n useLayoutEffect(() => {\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }, [generateTestContent])\n\n useEffect(() => {\n if (steps) {\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }\n }, [generateTestContent, steps])\n\n useEffect(() => {\n const removeUpdateListener = editor.registerUpdateListener(\n ({ dirtyElements, dirtyLeaves, editorState }) => {\n if (!isRecording) {\n return\n }\n const currentSelection = editorState._selection\n const previousSelection = previousSelectionRef.current\n const skipNextSelectionChange = skipNextSelectionChangeRef.current\n if (previousSelection !== currentSelection) {\n if (dirtyLeaves.size === 0 && dirtyElements.size === 0 && !skipNextSelectionChange) {\n const browserSelection = window.getSelection()\n if (\n browserSelection &&\n (browserSelection.anchorNode == null || browserSelection.focusNode == null)\n ) {\n return\n }\n }\n previousSelectionRef.current = currentSelection\n }\n skipNextSelectionChangeRef.current = false\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n },\n )\n return removeUpdateListener\n }, [editor, generateTestContent, isRecording, pushStep])\n\n // save innerHTML\n useEffect(() => {\n if (!isRecording) {\n return\n }\n const removeUpdateListener = editor.registerUpdateListener(() => {\n const rootElement = editor.getRootElement()\n if (rootElement !== null) {\n setCurrentInnerHTML(rootElement?.innerHTML)\n }\n })\n return removeUpdateListener\n }, [editor, isRecording])\n\n // clear editor and start recording\n const toggleEditorSelection = useCallback(\n (currentEditor: LexicalEditor) => {\n if (!isRecording) {\n currentEditor.update(() => {\n const root = $getRoot()\n root.clear()\n const text = $createTextNode()\n root.append($createParagraphNode().append(text))\n text.select()\n })\n setSteps([])\n }\n setIsRecording((currentIsRecording) => !currentIsRecording)\n },\n [isRecording],\n )\n\n const onSnapshotClick = useCallback(() => {\n if (!isRecording) {\n return\n }\n const browserSelection = window.getSelection()\n if (\n browserSelection === null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null\n ) {\n return\n }\n const { anchorNode, anchorOffset, focusNode, focusOffset } = sanitizeSelection(browserSelection)\n const rootElement = getCurrentEditor().getRootElement()\n let anchorPath\n if (anchorNode !== null) {\n anchorPath = getPathFromNodeToEditor(anchorNode, rootElement)\n }\n let focusPath\n if (focusNode !== null) {\n focusPath = getPathFromNodeToEditor(focusNode, rootElement)\n }\n pushStep('snapshot', {\n anchorNode,\n anchorOffset,\n anchorPath,\n focusNode,\n focusOffset,\n focusPath,\n })\n }, [pushStep, isRecording, getCurrentEditor])\n\n const onCopyClick = useCallback(() => {\n copy(generateTestContent())\n }, [generateTestContent])\n\n const onDownloadClick = useCallback(() => {\n download('test.js', generateTestContent())\n }, [generateTestContent])\n\n const button = (\n <button\n className={`editor-dev-button ${isRecording ? 'active' : ''}`}\n id=\"test-recorder-button\"\n onClick={(e) => {\n toggleEditorSelection(getCurrentEditor())\n e.preventDefault()\n }}\n title={isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n type=\"button\"\n >\n {isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n </button>\n )\n const output = isRecording ? (\n <div className=\"test-recorder-output\">\n <div className=\"test-recorder-toolbar\">\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-snapshot\"\n onClick={(e) => {\n onSnapshotClick()\n e.preventDefault()\n }}\n title=\"Insert snapshot\"\n type=\"button\"\n >\n Insert Snapshot\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-copy\"\n onClick={(e) => {\n onCopyClick()\n e.preventDefault()\n }}\n title=\"Copy to clipboard\"\n type=\"button\"\n >\n Copy\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-download\"\n onClick={(e) => {\n onDownloadClick()\n e.preventDefault()\n }}\n title=\"Download as a file\"\n type=\"button\"\n >\n Download\n </button>\n </div>\n <pre id=\"test-recorder\" ref={preRef}>\n {templatedTest}\n </pre>\n </div>\n ) : null\n\n return [button, output]\n}\nexport const TestRecorderPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor)\n\n return (\n <React.Fragment>\n <p>HI</p>\n {testRecorderButton}\n {testRecorderOutput}\n <p>DONE</p>\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","$createParagraphNode","$createTextNode","$getRoot","React","useCallback","useEffect","useLayoutEffect","useRef","useState","IS_APPLE","copy","text","textArea","document","createElement","value","style","position","opacity","body","appendChild","focus","select","result","execCommand","console","log","error","removeChild","download","filename","a","setAttribute","encodeURIComponent","display","click","formatStep","step","formatOneStep","name","x","y","anchorPath","toString","anchorOffset","focusPath","focusOffset","formattedStep","count","join","isSelectAll","event","keyCode","metaKey","ctrlKey","sanitizeSelection","selection","anchorNode","focusNode","getPathFromNodeToEditor","node","rootElement","currentNode","path","undefined","unshift","Array","from","parentNode","childNodes","indexOf","keyPresses","Set","useTestRecorder","editor","steps","setSteps","isRecording","setIsRecording","setCurrentInnerHTML","templatedTest","setTemplatedTest","previousSelectionRef","skipNextSelectionChangeRef","preRef","getCurrentEditor","generateTestContent","getRootElement","browserSelection","window","getSelection","contains","map","pushStep","currentSteps","currentIndex","length","lastStep","slice","onKeyDown","key","has","onKeyUp","registerRootListener","prevRootElement","removeEventListener","addEventListener","current","scrollTo","scrollHeight","testContent","removeUpdateListener","registerUpdateListener","dirtyElements","dirtyLeaves","editorState","currentSelection","_selection","previousSelection","skipNextSelectionChange","size","innerHTML","toggleEditorSelection","currentEditor","update","root","clear","append","currentIsRecording","onSnapshotClick","onCopyClick","onDownloadClick","button","className","id","onClick","e","preventDefault","title","type","output","div","pre","ref","TestRecorderPlugin","testRecorderButton","testRecorderOutput","Fragment","p"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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RN;YACAM,EAAEC,cAAc;QAClB;QACAC,OAAM;QACNC,MAAK;OACN,uBAGD,oBAACP;QACCC,WAAU;QACVC,IAAG;QACHC,SAAS,CAACC;YACRL;YACAK,EAAEC,cAAc;QAClB;QACAC,OAAM;QACNC,MAAK;OACN,4BAIH,oBAACG;QAAIR,IAAG;QAAgBS,KAAK3D;OAC1BJ,kBAGH;IAEJ,OAAO;QAACoD;QAAQQ;KAAO;AACzB;AACA,OAAO,MAAMI,qBAA+B;IAC1C,MAAM,CAACtE,OAAO,GAAG3E;IACjB,MAAM,CAACkJ,oBAAoBC,mBAAmB,GAAGzE,gBAAgBC;IAEjE,qBACE,oBAACvE,MAAMgJ,QAAQ,sBACb,oBAACC,WAAE,OACFH,oBACAC,kCACD,oBAACE,WAAE;AAGT,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/debug/testRecorder/plugin/index.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $createParagraphNode, $createTextNode, $getRoot } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\n\nimport type { PluginComponent } from '../../../types.js'\n\nimport { IS_APPLE } from '../../../../lexical/utils/environment.js'\nimport './index.scss'\n\nconst copy = (text: null | string) => {\n const textArea = document.createElement('textarea')\n textArea.value = text || ''\n textArea.style.position = 'absolute'\n textArea.style.opacity = '0'\n document.body?.appendChild(textArea)\n textArea.focus()\n textArea.select()\n try {\n const result = document.execCommand('copy')\n // eslint-disable-next-line no-console\n console.log(result)\n } catch (error) {\n console.error(error)\n }\n document.body?.removeChild(textArea)\n}\n\nconst download = (filename: string, text: null | string) => {\n const a = document.createElement('a')\n a.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text || ''))\n a.setAttribute('download', filename)\n a.style.display = 'none'\n document.body?.appendChild(a)\n a.click()\n document.body?.removeChild(a)\n}\n\nconst formatStep = (step: Step) => {\n const formatOneStep = (name: string, value: Step['value']) => {\n switch (name) {\n case 'click': {\n return ` await page.mouse.click(${value.x}, ${value.y});`\n }\n case 'press': {\n return ` await page.keyboard.press('${value}');`\n }\n case 'keydown': {\n return ` await page.keyboard.keydown('${value}');`\n }\n case 'keyup': {\n return ` await page.keyboard.keyup('${value}');`\n }\n case 'type': {\n return ` await page.keyboard.type('${value}');`\n }\n case 'selectAll': {\n return ` await selectAll(page);`\n }\n case 'snapshot': {\n return ` await assertHTMLSnapshot(page);\n await assertSelection(page, {\n anchorPath: [${value.anchorPath.toString()}],\n anchorOffset: ${value.anchorOffset},\n focusPath: [${value.focusPath.toString()}],\n focusOffset: ${value.focusOffset},\n });\n`\n }\n default:\n return ``\n }\n }\n const formattedStep = formatOneStep(step.name, step.value)\n switch (step.count) {\n case 1:\n return formattedStep\n case 2:\n return [formattedStep, formattedStep].join(`\\n`)\n default:\n return ` await repeat(${step.count}, async () => {\n ${formattedStep}\n );`\n }\n}\n\nexport function isSelectAll(event: KeyboardEvent): boolean {\n return event.keyCode === 65 && (IS_APPLE ? event.metaKey : event.ctrlKey)\n}\n\n// stolen from LexicalSelection-test\nfunction sanitizeSelection(selection: Selection) {\n const { anchorNode, focusNode } = selection\n let { anchorOffset, focusOffset } = selection\n if (anchorOffset !== 0) {\n anchorOffset--\n }\n if (focusOffset !== 0) {\n focusOffset--\n }\n return { anchorNode, anchorOffset, focusNode, focusOffset }\n}\n\nfunction getPathFromNodeToEditor(node: Node, rootElement: HTMLElement | null) {\n let currentNode: Node | null | undefined = node\n const path = []\n while (currentNode !== rootElement) {\n if (currentNode !== null && currentNode !== undefined) {\n path.unshift(\n Array.from(currentNode?.parentNode?.childNodes ?? []).indexOf(currentNode as ChildNode),\n )\n }\n currentNode = currentNode?.parentNode\n }\n return path\n}\n\nconst keyPresses = new Set([\n 'Enter',\n 'Backspace',\n 'Delete',\n 'Escape',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'ArrowDown',\n])\n\ntype Step = {\n count: number\n name: string\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value: any\n}\n\ntype Steps = Step[]\n\nfunction useTestRecorder(editor: LexicalEditor): [JSX.Element, JSX.Element | null] {\n const [steps, setSteps] = useState<Steps>([])\n const [isRecording, setIsRecording] = useState(false)\n const [, setCurrentInnerHTML] = useState('')\n const [templatedTest, setTemplatedTest] = useState('')\n const previousSelectionRef = useRef<BaseSelection | null>(null)\n const skipNextSelectionChangeRef = useRef(false)\n const preRef = useRef<HTMLPreElement>(null)\n\n const getCurrentEditor = useCallback(() => {\n return editor\n }, [editor])\n\n const generateTestContent = useCallback(() => {\n const rootElement = editor.getRootElement()\n const browserSelection = window.getSelection()\n\n if (\n rootElement == null ||\n browserSelection == null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null ||\n !rootElement.contains(browserSelection.anchorNode) ||\n !rootElement.contains(browserSelection.focusNode)\n ) {\n return null\n }\n\n return `\nimport {\n initializeE2E,\n assertHTMLSnapshot,\n assertSelection,\n repeat,\n} from '../utils';\nimport {selectAll} from '../keyboardShortcuts';\nimport { RangeSelection } from 'lexical';\nimport { NodeSelection } from 'lexical';\n\ndescribe('Test case', () => {\n initializeE2E((e2e) => {\n it('Should pass this test', async () => {\n const {page} = e2e;\n\n await page.focus('div[contenteditable=\"true\"]');\n${steps.map(formatStep).join(`\\n`)}\n });\n});\n `\n }, [editor, steps])\n\n // just a wrapper around inserting new actions so that we can\n // coalesce some actions like insertText/moveNativeSelection\n const pushStep = useCallback(\n (name: string, value: Step['value']) => {\n setSteps((currentSteps) => {\n // trying to group steps\n const currentIndex = steps.length - 1\n const lastStep = steps[currentIndex]\n if (lastStep) {\n if (lastStep.name === name) {\n if (name === 'type') {\n // for typing events we just append the text\n return [\n ...steps.slice(0, currentIndex),\n { ...lastStep, value: lastStep.value + value },\n ]\n } else {\n // for other events we bump the counter if their values are the same\n if (lastStep.value === value) {\n return [...steps.slice(0, currentIndex), { ...lastStep, count: lastStep.count + 1 }]\n }\n }\n }\n }\n // could not group, just append a new one\n return [...currentSteps, { name, count: 1, value }]\n })\n },\n [steps, setSteps],\n )\n\n useLayoutEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (isSelectAll(event)) {\n pushStep('selectAll', '')\n } else if (keyPresses.has(key)) {\n pushStep('press', event.key)\n } else if ([...key].length > 1) {\n pushStep('keydown', event.key)\n } else {\n pushStep('type', event.key)\n }\n }\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!isRecording) {\n return\n }\n const key = event.key\n if (!keyPresses.has(key) && [...key].length > 1) {\n pushStep('keyup', event.key)\n }\n }\n\n return editor.registerRootListener(\n (rootElement: HTMLElement | null, prevRootElement: HTMLElement | null) => {\n if (prevRootElement !== null) {\n prevRootElement.removeEventListener('keydown', onKeyDown)\n prevRootElement.removeEventListener('keyup', onKeyUp)\n }\n if (rootElement !== null) {\n rootElement.addEventListener('keydown', onKeyDown)\n rootElement.addEventListener('keyup', onKeyUp)\n }\n },\n )\n }, [editor, isRecording, pushStep])\n\n useLayoutEffect(() => {\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }, [generateTestContent])\n\n useEffect(() => {\n if (steps) {\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n if (preRef.current) {\n preRef.current.scrollTo(0, preRef.current.scrollHeight)\n }\n }\n }, [generateTestContent, steps])\n\n useEffect(() => {\n const removeUpdateListener = editor.registerUpdateListener(\n ({ dirtyElements, dirtyLeaves, editorState }) => {\n if (!isRecording) {\n return\n }\n const currentSelection = editorState._selection\n const previousSelection = previousSelectionRef.current\n const skipNextSelectionChange = skipNextSelectionChangeRef.current\n if (previousSelection !== currentSelection) {\n if (dirtyLeaves.size === 0 && dirtyElements.size === 0 && !skipNextSelectionChange) {\n const browserSelection = window.getSelection()\n if (\n browserSelection &&\n (browserSelection.anchorNode == null || browserSelection.focusNode == null)\n ) {\n return\n }\n }\n previousSelectionRef.current = currentSelection\n }\n skipNextSelectionChangeRef.current = false\n const testContent = generateTestContent()\n if (testContent !== null) {\n setTemplatedTest(testContent)\n }\n },\n )\n return removeUpdateListener\n }, [editor, generateTestContent, isRecording, pushStep])\n\n // save innerHTML\n useEffect(() => {\n if (!isRecording) {\n return\n }\n const removeUpdateListener = editor.registerUpdateListener(() => {\n const rootElement = editor.getRootElement()\n if (rootElement !== null) {\n setCurrentInnerHTML(rootElement?.innerHTML)\n }\n })\n return removeUpdateListener\n }, [editor, isRecording])\n\n // clear editor and start recording\n const toggleEditorSelection = useCallback(\n (currentEditor: LexicalEditor) => {\n if (!isRecording) {\n currentEditor.update(() => {\n const root = $getRoot()\n root.clear()\n const text = $createTextNode()\n root.append($createParagraphNode().append(text))\n text.select()\n })\n setSteps([])\n }\n setIsRecording((currentIsRecording) => !currentIsRecording)\n },\n [isRecording],\n )\n\n const onSnapshotClick = useCallback(() => {\n if (!isRecording) {\n return\n }\n const browserSelection = window.getSelection()\n if (\n browserSelection === null ||\n browserSelection.anchorNode == null ||\n browserSelection.focusNode == null\n ) {\n return\n }\n const { anchorNode, anchorOffset, focusNode, focusOffset } = sanitizeSelection(browserSelection)\n const rootElement = getCurrentEditor().getRootElement()\n let anchorPath\n if (anchorNode !== null) {\n anchorPath = getPathFromNodeToEditor(anchorNode, rootElement)\n }\n let focusPath\n if (focusNode !== null) {\n focusPath = getPathFromNodeToEditor(focusNode, rootElement)\n }\n pushStep('snapshot', {\n anchorNode,\n anchorOffset,\n anchorPath,\n focusNode,\n focusOffset,\n focusPath,\n })\n }, [pushStep, isRecording, getCurrentEditor])\n\n const onCopyClick = useCallback(() => {\n copy(generateTestContent())\n }, [generateTestContent])\n\n const onDownloadClick = useCallback(() => {\n download('test.js', generateTestContent())\n }, [generateTestContent])\n\n const button = (\n <button\n className={`editor-dev-button ${isRecording ? 'active' : ''}`}\n id=\"test-recorder-button\"\n onClick={(e) => {\n toggleEditorSelection(getCurrentEditor())\n e.preventDefault()\n }}\n title={isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n type=\"button\"\n >\n {isRecording ? 'Disable test recorder' : 'Enable test recorder'}\n </button>\n )\n const output = isRecording ? (\n <div className=\"test-recorder-output\">\n <div className=\"test-recorder-toolbar\">\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-snapshot\"\n onClick={(e) => {\n onSnapshotClick()\n e.preventDefault()\n }}\n title=\"Insert snapshot\"\n type=\"button\"\n >\n Insert Snapshot\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-copy\"\n onClick={(e) => {\n onCopyClick()\n e.preventDefault()\n }}\n title=\"Copy to clipboard\"\n type=\"button\"\n >\n Copy\n </button>\n <button\n className=\"test-recorder-button\"\n id=\"test-recorder-button-download\"\n onClick={(e) => {\n onDownloadClick()\n e.preventDefault()\n }}\n title=\"Download as a file\"\n type=\"button\"\n >\n Download\n </button>\n </div>\n <pre id=\"test-recorder\" ref={preRef}>\n {templatedTest}\n </pre>\n </div>\n ) : null\n\n return [button, output]\n}\nexport const TestRecorderPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n const [testRecorderButton, testRecorderOutput] = useTestRecorder(editor)\n\n return (\n <React.Fragment>\n <p>HI</p>\n {testRecorderButton}\n {testRecorderOutput}\n <p>DONE</p>\n </React.Fragment>\n )\n}\n"],"names":["useLexicalComposerContext","$createParagraphNode","$createTextNode","$getRoot","React","useCallback","useEffect","useLayoutEffect","useRef","useState","IS_APPLE","copy","text","textArea","document","createElement","value","style","position","opacity","body","appendChild","focus","select","result","execCommand","console","log","error","removeChild","download","filename","a","setAttribute","encodeURIComponent","display","click","formatStep","step","formatOneStep","name","x","y","anchorPath","toString","anchorOffset","focusPath","focusOffset","formattedStep","count","join","isSelectAll","event","keyCode","metaKey","ctrlKey","sanitizeSelection","selection","anchorNode","focusNode","getPathFromNodeToEditor","node","rootElement","currentNode","path","undefined","unshift","Array","from","parentNode","childNodes","indexOf","keyPresses","Set","useTestRecorder","editor","steps","setSteps","isRecording","setIsRecording","setCurrentInnerHTML","templatedTest","setTemplatedTest","previousSelectionRef","skipNextSelectionChangeRef","preRef","getCurrentEditor","generateTestContent","getRootElement","browserSelection","window","getSelection","contains","map","pushStep","currentSteps","currentIndex","length","lastStep","slice","onKeyDown","key","has","onKeyUp","registerRootListener","prevRootElement","removeEventListener","addEventListener","current","scrollTo","scrollHeight","testContent","removeUpdateListener","registerUpdateListener","dirtyElements","dirtyLeaves","editorState","currentSelection","_selection","previousSelection","skipNextSelectionChange","size","innerHTML","toggleEditorSelection","currentEditor","update","root","clear","append","currentIsRecording","onSnapshotClick","onCopyClick","onDownloadClick","button","className","id","onClick","e","preventDefault","title","type","output","div","pre","ref","TestRecorderPlugin","testRecorderButton","testRecorderOutput","Fragment","p"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,oBAAoB,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,UAAS;AACzE,YAAYC,WAAW,QAAO;AAC9B,SAASC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H,oBAACG;QAAIR,IAAG;QAAgBS,KAAK3D;OAC1BJ,kBAGH;IAEJ,OAAO;QAACoD;QAAQQ;KAAO;AACzB;AACA,OAAO,MAAMI,qBAAiD;IAC5D,MAAM,CAACtE,OAAO,GAAG3E;IACjB,MAAM,CAACkJ,oBAAoBC,mBAAmB,GAAGzE,gBAAgBC;IAEjE,qBACE,oBAACvE,MAAMgJ,QAAQ,sBACb,oBAACC,WAAE,OACFH,oBACAC,kCACD,oBAACE,WAAE;AAGT,EAAC"}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import type { PluginComponent } from '../../../types.js';
2
2
  import './index.scss';
3
- export declare function TreeViewPlugin(): React.ReactNode;
3
+ export declare const TreeViewPlugin: PluginComponent<undefined>;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/debug/treeView/plugin/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,cAAc,CAAA;AAErB,wBAAgB,cAAc,IAAI,KAAK,CAAC,SAAS,CAahD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/debug/treeView/plugin/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,cAAc,EAAE,eAAe,CAAC,SAAS,CAarD,CAAA"}
@@ -3,7 +3,7 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
3
3
  import { TreeView } from '@lexical/react/LexicalTreeView.js';
4
4
  import * as React from 'react';
5
5
  import './index.scss';
6
- export function TreeViewPlugin() {
6
+ export const TreeViewPlugin = ()=>{
7
7
  const [editor] = useLexicalComposerContext();
8
8
  return /*#__PURE__*/ React.createElement(TreeView, {
9
9
  editor: editor,
@@ -14,6 +14,6 @@ export function TreeViewPlugin() {
14
14
  treeTypeButtonClassName: "debug-treetype-button",
15
15
  viewClassName: "tree-view-output"
16
16
  });
17
- }
17
+ };
18
18
 
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/debug/treeView/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { TreeView } from '@lexical/react/LexicalTreeView.js'\nimport * as React from 'react'\n\nimport './index.scss'\n\nexport function TreeViewPlugin(): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n return (\n <TreeView\n editor={editor}\n timeTravelButtonClassName=\"debug-timetravel-button\"\n timeTravelPanelButtonClassName=\"debug-timetravel-panel-button\"\n timeTravelPanelClassName=\"debug-timetravel-panel\"\n timeTravelPanelSliderClassName=\"debug-timetravel-panel-slider\"\n treeTypeButtonClassName=\"debug-treetype-button\"\n viewClassName=\"tree-view-output\"\n />\n )\n}\n"],"names":["useLexicalComposerContext","TreeView","React","TreeViewPlugin","editor","timeTravelButtonClassName","timeTravelPanelButtonClassName","timeTravelPanelClassName","timeTravelPanelSliderClassName","treeTypeButtonClassName","viewClassName"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,YAAYC,WAAW,QAAO;AAE9B,OAAO,eAAc;AAErB,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGJ;IACjB,qBACE,oBAACC;QACCG,QAAQA;QACRC,2BAA0B;QAC1BC,gCAA+B;QAC/BC,0BAAyB;QACzBC,gCAA+B;QAC/BC,yBAAwB;QACxBC,eAAc;;AAGpB"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/debug/treeView/plugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { TreeView } from '@lexical/react/LexicalTreeView.js'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../types.js'\n\nimport './index.scss'\n\nexport const TreeViewPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n return (\n <TreeView\n editor={editor}\n timeTravelButtonClassName=\"debug-timetravel-button\"\n timeTravelPanelButtonClassName=\"debug-timetravel-panel-button\"\n timeTravelPanelClassName=\"debug-timetravel-panel\"\n timeTravelPanelSliderClassName=\"debug-timetravel-panel-slider\"\n treeTypeButtonClassName=\"debug-treetype-button\"\n viewClassName=\"tree-view-output\"\n />\n )\n}\n"],"names":["useLexicalComposerContext","TreeView","React","TreeViewPlugin","editor","timeTravelButtonClassName","timeTravelPanelButtonClassName","timeTravelPanelClassName","timeTravelPanelSliderClassName","treeTypeButtonClassName","viewClassName"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,QAAQ,QAAQ,oCAAmC;AAC5D,YAAYC,WAAW,QAAO;AAI9B,OAAO,eAAc;AAErB,OAAO,MAAMC,iBAA6C;IACxD,MAAM,CAACC,OAAO,GAAGJ;IACjB,qBACE,oBAACC;QACCG,QAAQA;QACRC,2BAA0B;QAC1BC,gCAA+B;QAC/BC,0BAAyB;QACzBC,gCAA+B;QAC/BC,yBAAwB;QACxBC,eAAc;;AAGpB,EAAC"}
@@ -1,6 +1,7 @@
1
+ import type { PluginComponent } from '../../types.js';
1
2
  import './index.scss';
2
3
  /**
3
4
  * Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.
4
5
  */
5
- export declare function HorizontalRulePlugin(): null;
6
+ export declare const HorizontalRulePlugin: PluginComponent<undefined>;
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/horizontalRule/plugin/index.tsx"],"names":[],"mappings":"AAWA,OAAO,cAAc,CAAA;AAErB;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CA2B3C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/horizontalRule/plugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,OAAO,cAAc,CAAA;AAErB;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAAC,SAAS,CA2B3D,CAAA"}
@@ -7,7 +7,7 @@ import { $createHorizontalRuleNode, INSERT_HORIZONTAL_RULE_COMMAND } from '../no
7
7
  import './index.scss';
8
8
  /**
9
9
  * Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.
10
- */ export function HorizontalRulePlugin() {
10
+ */ export const HorizontalRulePlugin = ()=>{
11
11
  const [editor] = useLexicalComposerContext();
12
12
  useEffect(()=>{
13
13
  return editor.registerCommand(INSERT_HORIZONTAL_RULE_COMMAND, (type)=>{
@@ -26,6 +26,6 @@ import './index.scss';
26
26
  editor
27
27
  ]);
28
28
  return null;
29
- }
29
+ };
30
30
 
31
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/horizontalRule/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport { useEffect } from 'react'\n\nimport {\n $createHorizontalRuleNode,\n INSERT_HORIZONTAL_RULE_COMMAND,\n} from '../nodes/HorizontalRuleNode.js'\nimport './index.scss'\n\n/**\n * Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.\n */\nexport function HorizontalRulePlugin(): null {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand(\n INSERT_HORIZONTAL_RULE_COMMAND,\n (type) => {\n const selection = $getSelection()\n\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n const focusNode = selection.focus.getNode()\n\n if (focusNode !== null) {\n const horizontalRuleNode = $createHorizontalRuleNode()\n $insertNodeToNearestRoot(horizontalRuleNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","useEffect","$createHorizontalRuleNode","INSERT_HORIZONTAL_RULE_COMMAND","HorizontalRulePlugin","editor","registerCommand","type","selection","focusNode","focus","getNode","horizontalRuleNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAQ,UAAS;AACnF,SAASC,SAAS,QAAQ,QAAO;AAEjC,SACEC,yBAAyB,EACzBC,8BAA8B,QACzB,iCAAgC;AACvC,OAAO,eAAc;AAErB;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGT;IAEjBK,UAAU;QACR,OAAOI,OAAOC,eAAe,CAC3BH,gCACA,CAACI;YACC,MAAMC,YAAYV;YAElB,IAAI,CAACC,kBAAkBS,YAAY;gBACjC,OAAO;YACT;YAEA,MAAMC,YAAYD,UAAUE,KAAK,CAACC,OAAO;YAEzC,IAAIF,cAAc,MAAM;gBACtB,MAAMG,qBAAqBV;gBAC3BL,yBAAyBe;YAC3B;YAEA,OAAO;QACT,GACAZ;IAEJ,GAAG;QAACK;KAAO;IAEX,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../../../src/field/features/horizontalRule/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR } from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../types.js'\n\nimport {\n $createHorizontalRuleNode,\n INSERT_HORIZONTAL_RULE_COMMAND,\n} from '../nodes/HorizontalRuleNode.js'\nimport './index.scss'\n\n/**\n * Registers the INSERT_HORIZONTAL_RULE_COMMAND lexical command and defines the behavior for when it is called.\n */\nexport const HorizontalRulePlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerCommand(\n INSERT_HORIZONTAL_RULE_COMMAND,\n (type) => {\n const selection = $getSelection()\n\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n const focusNode = selection.focus.getNode()\n\n if (focusNode !== null) {\n const horizontalRuleNode = $createHorizontalRuleNode()\n $insertNodeToNearestRoot(horizontalRuleNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return null\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","$getSelection","$isRangeSelection","COMMAND_PRIORITY_EDITOR","useEffect","$createHorizontalRuleNode","INSERT_HORIZONTAL_RULE_COMMAND","HorizontalRulePlugin","editor","registerCommand","type","selection","focusNode","focus","getNode","horizontalRuleNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,aAAa,EAAEC,iBAAiB,EAAEC,uBAAuB,QAAQ,UAAS;AACnF,SAASC,SAAS,QAAQ,QAAO;AAIjC,SACEC,yBAAyB,EACzBC,8BAA8B,QACzB,iCAAgC;AACvC,OAAO,eAAc;AAErB;;CAEC,GACD,OAAO,MAAMC,uBAAmD;IAC9D,MAAM,CAACC,OAAO,GAAGT;IAEjBK,UAAU;QACR,OAAOI,OAAOC,eAAe,CAC3BH,gCACA,CAACI;YACC,MAAMC,YAAYV;YAElB,IAAI,CAACC,kBAAkBS,YAAY;gBACjC,OAAO;YACT;YAEA,MAAMC,YAAYD,UAAUE,KAAK,CAACC,OAAO;YAEzC,IAAIF,cAAc,MAAM;gBACtB,MAAMG,qBAAqBV;gBAC3BL,yBAAyBe;YAC3B;YAEA,OAAO;QACT,GACAZ;IAEJ,GAAG;QAACK;KAAO;IAEX,OAAO;AACT,EAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { SanitizedConfig } from 'payload/config';
2
- import type { FieldWithRichTextRequiredEditor } from 'payload/types';
3
- export declare const getBaseFields: (config: SanitizedConfig, enabledCollections: false | string[], disabledCollections: false | string[]) => FieldWithRichTextRequiredEditor[];
2
+ import type { Field } from 'payload/types';
3
+ export declare const getBaseFields: (config: SanitizedConfig, enabledCollections: false | string[], disabledCollections: false | string[], maxDepth?: number) => Field[];
4
4
  //# sourceMappingURL=baseFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"baseFields.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/link/drawer/baseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAS,+BAA+B,EAAyB,MAAM,eAAe,CAAA;AAIlG,eAAO,MAAM,aAAa,WAChB,eAAe,sBACH,KAAK,GAAG,MAAM,EAAE,uBACf,KAAK,GAAG,MAAM,EAAE,KACpC,+BAA+B,EAqGjC,CAAA"}
1
+ {"version":3,"file":"baseFields.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/link/drawer/baseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,KAAK,EAAyB,MAAM,eAAe,CAAA;AAIjE,eAAO,MAAM,aAAa,WAChB,eAAe,sBACH,KAAK,GAAG,MAAM,EAAE,uBACf,KAAK,GAAG,MAAM,EAAE,aAC1B,MAAM,KAChB,KAAK,EAsGP,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { validateUrl } from '../../../lexical/utils/url.js';
2
- export const getBaseFields = (config, enabledCollections, disabledCollections)=>{
2
+ export const getBaseFields = (config, enabledCollections, disabledCollections, maxDepth)=>{
3
3
  let enabledRelations;
4
4
  /**
5
5
  * Figure out which relations should be enabled (enabledRelations) based on a collection's admin.enableRichTextLink property,
@@ -78,6 +78,7 @@ export const getBaseFields = (config, enabledCollections, disabledCollections)=>
78
78
  }
79
79
  } : null,
80
80
  label: ({ t })=>t('fields:chooseDocumentToLink'),
81
+ maxDepth,
81
82
  relationTo: enabledRelations,
82
83
  required: true
83
84
  });