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

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 +10 -10
@@ -1,5 +1,4 @@
1
1
  'use client';
2
- import { withMergedProps } from '@payloadcms/ui/elements/withMergedProps';
3
2
  import { $isNodeSelection } from 'lexical';
4
3
  import { RelationshipIcon } from '../../lexical/ui/icons/Relationship/index.js';
5
4
  import { createClientComponent } from '../createClientComponent.js';
@@ -17,10 +16,7 @@ const RelationshipFeatureClient = (props)=>{
17
16
  ],
18
17
  plugins: [
19
18
  {
20
- Component: withMergedProps({
21
- Component: RelationshipPlugin,
22
- toMergeIntoProps: props
23
- }),
19
+ Component: RelationshipPlugin,
24
20
  position: 'normal'
25
21
  }
26
22
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/relationship/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { withMergedProps } from '@payloadcms/ui/elements/withMergedProps'\nimport { $isNodeSelection } from 'lexical'\n\nimport type { FeatureProviderProviderClient } from '../types.js'\nimport type { RelationshipFeatureProps } from './feature.server.js'\n\nimport { RelationshipIcon } from '../../lexical/ui/icons/Relationship/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { toolbarAddDropdownGroupWithItems } from '../shared/toolbar/addDropdownGroup.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './drawer/commands.js'\nimport { $isRelationshipNode, RelationshipNode } from './nodes/RelationshipNode.js'\nimport { RelationshipPlugin } from './plugins/index.js'\n\nconst RelationshipFeatureClient: FeatureProviderProviderClient<RelationshipFeatureProps> = (\n props,\n) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n nodes: [RelationshipNode],\n plugins: [\n {\n Component: withMergedProps({\n Component: RelationshipPlugin,\n toMergeIntoProps: props,\n }),\n position: 'normal',\n },\n ],\n slashMenu: {\n groups: [\n {\n items: [\n {\n Icon: RelationshipIcon,\n key: 'relationship',\n keywords: ['relationship', 'relation', 'rel'],\n label: 'Relationship',\n onSelect: ({ editor }) => {\n // dispatch INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: false,\n })\n },\n },\n ],\n key: 'basic',\n label: 'Basic',\n },\n ],\n },\n toolbarFixed: {\n groups: [\n toolbarAddDropdownGroupWithItems([\n {\n ChildComponent: RelationshipIcon,\n isActive: ({ selection }) => {\n if (!$isNodeSelection(selection) || !selection.getNodes().length) {\n return false\n }\n\n const firstNode = selection.getNodes()[0]\n return $isRelationshipNode(firstNode)\n },\n key: 'relationship',\n label: 'Relationship',\n onSelect: ({ editor }) => {\n // dispatch INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: false,\n })\n },\n },\n ]),\n ],\n },\n }),\n }\n}\n\nexport const RelationshipFeatureClientComponent = createClientComponent(RelationshipFeatureClient)\n"],"names":["withMergedProps","$isNodeSelection","RelationshipIcon","createClientComponent","toolbarAddDropdownGroupWithItems","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","RelationshipNode","RelationshipPlugin","RelationshipFeatureClient","props","clientFeatureProps","feature","nodes","plugins","Component","toMergeIntoProps","position","slashMenu","groups","items","Icon","key","keywords","label","onSelect","editor","dispatchCommand","replace","toolbarFixed","ChildComponent","isActive","selection","getNodes","length","firstNode","RelationshipFeatureClientComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,eAAe,QAAQ,0CAAyC;AACzE,SAASC,gBAAgB,QAAQ,UAAS;AAK1C,SAASC,gBAAgB,QAAQ,+CAA8C;AAC/E,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,gCAAgC,QAAQ,wCAAuC;AACxF,SAASC,uCAAuC,QAAQ,uBAAsB;AAC9E,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,8BAA6B;AACnF,SAASC,kBAAkB,QAAQ,qBAAoB;AAEvD,MAAMC,4BAAqF,CACzFC;IAEA,OAAO;QACLC,oBAAoBD;QACpBE,SAAS,IAAO,CAAA;gBACdD,oBAAoBD;gBACpBG,OAAO;oBAACN;iBAAiB;gBACzBO,SAAS;oBACP;wBACEC,WAAWf,gBAAgB;4BACzBe,WAAWP;4BACXQ,kBAAkBN;wBACpB;wBACAO,UAAU;oBACZ;iBACD;gBACDC,WAAW;oBACTC,QAAQ;wBACN;4BACEC,OAAO;gCACL;oCACEC,MAAMnB;oCACNoB,KAAK;oCACLC,UAAU;wCAAC;wCAAgB;wCAAY;qCAAM;oCAC7CC,OAAO;oCACPC,UAAU,CAAC,EAAEC,MAAM,EAAE;wCACnB,mDAAmD;wCACnDA,OAAOC,eAAe,CAACtB,yCAAyC;4CAC9DuB,SAAS;wCACX;oCACF;gCACF;6BACD;4BACDN,KAAK;4BACLE,OAAO;wBACT;qBACD;gBACH;gBACAK,cAAc;oBACZV,QAAQ;wBACNf,iCAAiC;4BAC/B;gCACE0B,gBAAgB5B;gCAChB6B,UAAU,CAAC,EAAEC,SAAS,EAAE;oCACtB,IAAI,CAAC/B,iBAAiB+B,cAAc,CAACA,UAAUC,QAAQ,GAAGC,MAAM,EAAE;wCAChE,OAAO;oCACT;oCAEA,MAAMC,YAAYH,UAAUC,QAAQ,EAAE,CAAC,EAAE;oCACzC,OAAO3B,oBAAoB6B;gCAC7B;gCACAb,KAAK;gCACLE,OAAO;gCACPC,UAAU,CAAC,EAAEC,MAAM,EAAE;oCACnB,mDAAmD;oCACnDA,OAAOC,eAAe,CAACtB,yCAAyC;wCAC9DuB,SAAS;oCACX;gCACF;4BACF;yBACD;qBACF;gBACH;YACF,CAAA;IACF;AACF;AAEA,OAAO,MAAMQ,qCAAqCjC,sBAAsBM,2BAA0B"}
1
+ {"version":3,"sources":["../../../../src/field/features/relationship/feature.client.tsx"],"sourcesContent":["'use client'\n\nimport { $isNodeSelection } from 'lexical'\n\nimport type { FeatureProviderProviderClient } from '../types.js'\nimport type { RelationshipFeatureProps } from './feature.server.js'\n\nimport { RelationshipIcon } from '../../lexical/ui/icons/Relationship/index.js'\nimport { createClientComponent } from '../createClientComponent.js'\nimport { toolbarAddDropdownGroupWithItems } from '../shared/toolbar/addDropdownGroup.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from './drawer/commands.js'\nimport { $isRelationshipNode, RelationshipNode } from './nodes/RelationshipNode.js'\nimport { RelationshipPlugin } from './plugins/index.js'\n\nconst RelationshipFeatureClient: FeatureProviderProviderClient<RelationshipFeatureProps> = (\n props,\n) => {\n return {\n clientFeatureProps: props,\n feature: () => ({\n clientFeatureProps: props,\n nodes: [RelationshipNode],\n plugins: [\n {\n Component: RelationshipPlugin,\n position: 'normal',\n },\n ],\n slashMenu: {\n groups: [\n {\n items: [\n {\n Icon: RelationshipIcon,\n key: 'relationship',\n keywords: ['relationship', 'relation', 'rel'],\n label: 'Relationship',\n onSelect: ({ editor }) => {\n // dispatch INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: false,\n })\n },\n },\n ],\n key: 'basic',\n label: 'Basic',\n },\n ],\n },\n toolbarFixed: {\n groups: [\n toolbarAddDropdownGroupWithItems([\n {\n ChildComponent: RelationshipIcon,\n isActive: ({ selection }) => {\n if (!$isNodeSelection(selection) || !selection.getNodes().length) {\n return false\n }\n\n const firstNode = selection.getNodes()[0]\n return $isRelationshipNode(firstNode)\n },\n key: 'relationship',\n label: 'Relationship',\n onSelect: ({ editor }) => {\n // dispatch INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: false,\n })\n },\n },\n ]),\n ],\n },\n }),\n }\n}\n\nexport const RelationshipFeatureClientComponent = createClientComponent(RelationshipFeatureClient)\n"],"names":["$isNodeSelection","RelationshipIcon","createClientComponent","toolbarAddDropdownGroupWithItems","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","RelationshipNode","RelationshipPlugin","RelationshipFeatureClient","props","clientFeatureProps","feature","nodes","plugins","Component","position","slashMenu","groups","items","Icon","key","keywords","label","onSelect","editor","dispatchCommand","replace","toolbarFixed","ChildComponent","isActive","selection","getNodes","length","firstNode","RelationshipFeatureClientComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAEA,SAASA,gBAAgB,QAAQ,UAAS;AAK1C,SAASC,gBAAgB,QAAQ,+CAA8C;AAC/E,SAASC,qBAAqB,QAAQ,8BAA6B;AACnE,SAASC,gCAAgC,QAAQ,wCAAuC;AACxF,SAASC,uCAAuC,QAAQ,uBAAsB;AAC9E,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,8BAA6B;AACnF,SAASC,kBAAkB,QAAQ,qBAAoB;AAEvD,MAAMC,4BAAqF,CACzFC;IAEA,OAAO;QACLC,oBAAoBD;QACpBE,SAAS,IAAO,CAAA;gBACdD,oBAAoBD;gBACpBG,OAAO;oBAACN;iBAAiB;gBACzBO,SAAS;oBACP;wBACEC,WAAWP;wBACXQ,UAAU;oBACZ;iBACD;gBACDC,WAAW;oBACTC,QAAQ;wBACN;4BACEC,OAAO;gCACL;oCACEC,MAAMlB;oCACNmB,KAAK;oCACLC,UAAU;wCAAC;wCAAgB;wCAAY;qCAAM;oCAC7CC,OAAO;oCACPC,UAAU,CAAC,EAAEC,MAAM,EAAE;wCACnB,mDAAmD;wCACnDA,OAAOC,eAAe,CAACrB,yCAAyC;4CAC9DsB,SAAS;wCACX;oCACF;gCACF;6BACD;4BACDN,KAAK;4BACLE,OAAO;wBACT;qBACD;gBACH;gBACAK,cAAc;oBACZV,QAAQ;wBACNd,iCAAiC;4BAC/B;gCACEyB,gBAAgB3B;gCAChB4B,UAAU,CAAC,EAAEC,SAAS,EAAE;oCACtB,IAAI,CAAC9B,iBAAiB8B,cAAc,CAACA,UAAUC,QAAQ,GAAGC,MAAM,EAAE;wCAChE,OAAO;oCACT;oCAEA,MAAMC,YAAYH,UAAUC,QAAQ,EAAE,CAAC,EAAE;oCACzC,OAAO1B,oBAAoB4B;gCAC7B;gCACAb,KAAK;gCACLE,OAAO;gCACPC,UAAU,CAAC,EAAEC,MAAM,EAAE;oCACnB,mDAAmD;oCACnDA,OAAOC,eAAe,CAACrB,yCAAyC;wCAC9DsB,SAAS;oCACX;gCACF;4BACF;yBACD;qBACF;gBACH;YACF,CAAA;IACF;AACF;AAEA,OAAO,MAAMQ,qCAAqChC,sBAAsBM,2BAA0B"}
@@ -1,5 +1,5 @@
1
1
  import type { FeatureProviderProviderServer } from '../types.js';
2
- export type RelationshipFeatureProps = {
2
+ export type ExclusiveRelationshipFeatureProps = {
3
3
  /**
4
4
  * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.
5
5
  * When this property is set, `enabledCollections` will not be available.
@@ -14,5 +14,14 @@ export type RelationshipFeatureProps = {
14
14
  **/
15
15
  enabledCollections?: string[];
16
16
  };
17
+ export type RelationshipFeatureProps = ExclusiveRelationshipFeatureProps & {
18
+ /**
19
+ * Sets a maximum population depth for this relationship, regardless of the remaining depth when the respective field is reached.
20
+ * This behaves exactly like the maxDepth properties of relationship and upload fields.
21
+ *
22
+ * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}
23
+ */
24
+ maxDepth?: number;
25
+ };
17
26
  export declare const RelationshipFeature: FeatureProviderProviderServer<RelationshipFeatureProps, RelationshipFeatureProps>;
18
27
  //# sourceMappingURL=feature.server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/relationship/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAOhE,MAAM,MAAM,wBAAwB,GAChC;IACE;;;QAGI;IACJ,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAG9B,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B,GACD;IAEE,mBAAmB,CAAC,EAAE,KAAK,CAAA;IAE3B;;;QAGI;IACJ,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B,CAAA;AAEL,eAAO,MAAM,mBAAmB,EAAE,6BAA6B,CAC7D,wBAAwB,EACxB,wBAAwB,CAoBzB,CAAA"}
1
+ {"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/relationship/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAOhE,MAAM,MAAM,iCAAiC,GACzC;IACE;;;QAGI;IACJ,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAG9B,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B,GACD;IAEE,mBAAmB,CAAC,EAAE,KAAK,CAAA;IAE3B;;;QAGI;IACJ,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B,CAAA;AAEL,MAAM,MAAM,wBAAwB,GAAG,iCAAiC,GAAG;IACzE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,6BAA6B,CAC7D,wBAAwB,EACxB,wBAAwB,CAmBzB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { createNode } from '../typeUtilities.js';
2
2
  import { RelationshipFeatureClientComponent } from './feature.client.js';
3
3
  import { RelationshipNode } from './nodes/RelationshipNode.js';
4
- import { relationshipPopulationPromise } from './populationPromise.js';
4
+ import { relationshipPopulationPromiseHOC } from './populationPromise.js';
5
5
  export const RelationshipFeature = (props)=>{
6
6
  return {
7
7
  feature: ()=>{
@@ -12,7 +12,7 @@ export const RelationshipFeature = (props)=>{
12
12
  createNode({
13
13
  node: RelationshipNode,
14
14
  populationPromises: [
15
- relationshipPopulationPromise
15
+ relationshipPopulationPromiseHOC(props)
16
16
  ]
17
17
  })
18
18
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/relationship/feature.server.ts"],"sourcesContent":["import type { FeatureProviderProviderServer } from '../types.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { RelationshipFeatureClientComponent } from './feature.client.js'\nimport { RelationshipNode } from './nodes/RelationshipNode.js'\nimport { relationshipPopulationPromise } from './populationPromise.js'\n\nexport type RelationshipFeatureProps =\n | {\n /**\n * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: string[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled. Overrides the `enableRichTextRelationship` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: string[]\n }\n\nexport const RelationshipFeature: FeatureProviderProviderServer<\n RelationshipFeatureProps,\n RelationshipFeatureProps\n> = (props) => {\n return {\n feature: () => {\n return {\n ClientComponent: RelationshipFeatureClientComponent,\n clientFeatureProps: props,\n nodes: [\n createNode({\n node: RelationshipNode,\n populationPromises: [relationshipPopulationPromise],\n // TODO: Add validation similar to upload\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'relationship',\n serverFeatureProps: props,\n }\n}\n"],"names":["createNode","RelationshipFeatureClientComponent","RelationshipNode","relationshipPopulationPromise","RelationshipFeature","props","feature","ClientComponent","clientFeatureProps","nodes","node","populationPromises","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,UAAU,QAAQ,sBAAqB;AAChD,SAASC,kCAAkC,QAAQ,sBAAqB;AACxE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,6BAA6B,QAAQ,yBAAwB;AAwBtE,OAAO,MAAMC,sBAGT,CAACC;IACH,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBN;gBACjBO,oBAAoBH;gBACpBI,OAAO;oBACLT,WAAW;wBACTU,MAAMR;wBACNS,oBAAoB;4BAACR;yBAA8B;oBAErD;iBACD;gBACDS,oBAAoBP;YACtB;QACF;QACAQ,KAAK;QACLD,oBAAoBP;IACtB;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/relationship/feature.server.ts"],"sourcesContent":["import type { FeatureProviderProviderServer } from '../types.js'\n\nimport { createNode } from '../typeUtilities.js'\nimport { RelationshipFeatureClientComponent } from './feature.client.js'\nimport { RelationshipNode } from './nodes/RelationshipNode.js'\nimport { relationshipPopulationPromiseHOC } from './populationPromise.js'\n\nexport type ExclusiveRelationshipFeatureProps =\n | {\n /**\n * The collections that should be disabled. Overrides the `enableRichTextRelationship` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: string[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled. Overrides the `enableRichTextRelationship` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: string[]\n }\n\nexport type RelationshipFeatureProps = ExclusiveRelationshipFeatureProps & {\n /**\n * Sets a maximum population depth for this relationship, regardless of the remaining depth when the respective field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n}\n\nexport const RelationshipFeature: FeatureProviderProviderServer<\n RelationshipFeatureProps,\n RelationshipFeatureProps\n> = (props) => {\n return {\n feature: () => {\n return {\n ClientComponent: RelationshipFeatureClientComponent,\n clientFeatureProps: props,\n nodes: [\n createNode({\n node: RelationshipNode,\n populationPromises: [relationshipPopulationPromiseHOC(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'relationship',\n serverFeatureProps: props,\n }\n}\n"],"names":["createNode","RelationshipFeatureClientComponent","RelationshipNode","relationshipPopulationPromiseHOC","RelationshipFeature","props","feature","ClientComponent","clientFeatureProps","nodes","node","populationPromises","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,UAAU,QAAQ,sBAAqB;AAChD,SAASC,kCAAkC,QAAQ,sBAAqB;AACxE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,gCAAgC,QAAQ,yBAAwB;AAkCzE,OAAO,MAAMC,sBAGT,CAACC;IACH,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBN;gBACjBO,oBAAoBH;gBACpBI,OAAO;oBACLT,WAAW;wBACTU,MAAMR;wBACNS,oBAAoB;4BAACR,iCAAiCE;yBAAO;oBAC/D;iBACD;gBACDO,oBAAoBP;YACtB;QACF;QACAQ,KAAK;QACLD,oBAAoBP;IACtB;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAoBhD,OAAO,KAA+D,MAAM,OAAO,CAAA;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAK9D,OAAO,cAAc,CAAA;AAQrB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AA4JD,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,MAAM,SAE1D,CAAA"}
1
+ {"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAoBhD,OAAO,KAA+D,MAAM,OAAO,CAAA;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAK9D,OAAO,cAAc,CAAA;AAQrB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AA8JD,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,MAAM,SAE1D,CAAA"}
@@ -78,8 +78,10 @@ const Component = (props)=>{
78
78
  if (event.shiftKey) {
79
79
  setSelected(!isSelected);
80
80
  } else {
81
- clearSelection();
82
- setSelected(true);
81
+ if (!isSelected) {
82
+ clearSelection();
83
+ setSelected(true);
84
+ }
83
85
  }
84
86
  return true;
85
87
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport {\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport { $isRelationshipNode } from '../RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: { relationTo, value: id },\n nodeKey,\n } = props\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n const onDelete = useCallback(\n (payload: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isRelationshipNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if relationshipElemRef.target or anything WITHIN relationshipElemRef.target was clicked\n if (\n event.target === relationshipElemRef.current ||\n relationshipElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n clearSelection()\n setSelected(true)\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected, onClick])\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={relationshipElemRef}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","$getNodeByKey","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","relationshipElemRef","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","onDelete","payload","event","preventDefault","node","onClick","target","current","contains","shiftKey","registerCommand","div","className","filter","Boolean","join","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA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AAA;QACAC,SAAS/C,EAAE;sBAEb,oBAAChD;QACCuF,aAAY;QACZb,WAAW,CAAC,EAAErD,UAAU,cAAc,CAAC;QACvCmE,UAAUnD,OAAOoD;QACjBE,MAAK;QACLxB,SAAS,CAAC6B;YACRA,EAAE/B,cAAc;YAChBR;QACF;QACAqC,OAAAA;QACAC,SAAS/C,EAAE;SAKhBlB,oBAAM,oBAACuB;QAAe4C,QAAQrC;QAC9BlC;AAGP;AAEA,OAAO,MAAMwE,wBAAwB,CAACzE;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport {\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../RelationshipNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../../drawer/commands.js'\nimport { $isRelationshipNode } from '../RelationshipNode.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-relationship'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n children?: React.ReactNode\n className?: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nconst Component: React.FC<Props> = (props) => {\n const {\n children,\n data: { relationTo, value: id },\n nodeKey,\n } = props\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { field } = useEditorConfigContext()\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [relatedCollection, setRelatedCollection] = useState(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${id}`,\n { initialParams },\n )\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(\n ({ doc }) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDrawer()\n dispatchCacheBust()\n },\n [cacheBust, setParams, closeDrawer],\n )\n\n const onDelete = useCallback(\n (payload: KeyboardEvent) => {\n if (isSelected && $isNodeSelection($getSelection())) {\n const event: KeyboardEvent = payload\n event.preventDefault()\n const node = $getNodeByKey(nodeKey)\n if ($isRelationshipNode(node)) {\n node.remove()\n return true\n }\n }\n return false\n },\n [isSelected, nodeKey],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if relationshipElemRef.target or anything WITHIN relationshipElemRef.target was clicked\n if (\n event.target === relationshipElemRef.current ||\n relationshipElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, onDelete, setSelected, onClick])\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={relationshipElemRef}\n >\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : id}\n </p>\n </DocumentDrawerToggler>\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {id && <DocumentDrawer onSave={updateRelationship} />}\n {children}\n </div>\n )\n}\n\nexport const RelationshipComponent = (props: Props): React.ReactNode => {\n return <Component {...props} />\n}\n"],"names":["useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","useDocumentDrawer","usePayloadAPI","useConfig","useTranslation","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","$getNodeByKey","React","useCallback","useEffect","useReducer","useRef","useState","useEditorConfigContext","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","$isRelationshipNode","baseClass","initialParams","depth","Component","props","children","data","relationTo","value","id","nodeKey","relationshipElemRef","editor","isSelected","setSelected","clearSelection","field","collections","routes","api","serverURL","relatedCollection","setRelatedCollection","find","coll","slug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","DocumentDrawer","DocumentDrawerToggler","closeDrawer","collectionSlug","removeRelationship","update","remove","updateRelationship","doc","onDelete","payload","event","preventDefault","node","onClick","target","current","contains","shiftKey","registerCommand","div","className","filter","Boolean","join","contentEditable","ref","p","label","labels","singular","admin","useAsTitle","isEditable","buttonStyle","disabled","readOnly","el","icon","dispatchCommand","replace","round","tooltip","e","onSave","RelationshipComponent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SACEC,aAAa,EACbC,gBAAgB,EAChB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wB,CAACzE;IACpC,qBAAO,oBAACD,WAAcC;AACxB,EAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { LexicalCommand } from 'lexical';
2
- import React from 'react';
2
+ import type { PluginComponent } from '../../types.js';
3
3
  import type { RelationshipFeatureProps } from '../feature.server.js';
4
4
  import type { RelationshipData } from '../nodes/RelationshipNode.js';
5
5
  export declare const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData>;
6
- export declare function RelationshipPlugin(props?: RelationshipFeatureProps): React.ReactNode;
6
+ export declare const RelationshipPlugin: PluginComponent<RelationshipFeatureProps>;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAc7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAKpE,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,wBAAwB,GAAG,KAAK,CAAC,SAAS,CAqDpF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAgB7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAKpE,eAAO,MAAM,2BAA2B,EAAE,cAAc,CAAC,gBAAgB,CAExE,CAAA;AAED,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,wBAAwB,CAqDxE,CAAA"}
@@ -8,14 +8,14 @@ import React from 'react';
8
8
  import { RelationshipDrawer } from '../drawer/index.js';
9
9
  import { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js';
10
10
  export const INSERT_RELATIONSHIP_COMMAND = createCommand('INSERT_RELATIONSHIP_COMMAND');
11
- export function RelationshipPlugin(props) {
11
+ export const RelationshipPlugin = ({ clientProps })=>{
12
12
  const [editor] = useLexicalComposerContext();
13
13
  const { collections } = useConfig();
14
14
  let enabledRelations = null;
15
- if (props?.enabledCollections) {
16
- enabledRelations = props?.enabledCollections;
17
- } else if (props?.disabledCollections) {
18
- enabledRelations = collections.filter(({ slug })=>!props?.disabledCollections?.includes(slug)).map(({ slug })=>slug);
15
+ if (clientProps?.enabledCollections) {
16
+ enabledRelations = clientProps?.enabledCollections;
17
+ } else if (clientProps?.disabledCollections) {
18
+ enabledRelations = collections.filter(({ slug })=>!clientProps?.disabledCollections?.includes(slug)).map(({ slug })=>slug);
19
19
  }
20
20
  useEffect(()=>{
21
21
  if (!editor.hasNodes([
@@ -44,6 +44,6 @@ export function RelationshipPlugin(props) {
44
44
  return /*#__PURE__*/ React.createElement(RelationshipDrawer, {
45
45
  enabledCollectionSlugs: enabledRelations
46
46
  });
47
- }
47
+ };
48
48
 
49
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport function RelationshipPlugin(props?: RelationshipFeatureProps): React.ReactNode {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (props?.enabledCollections) {\n enabledRelations = props?.enabledCollections\n } else if (props?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !props?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const relationshipNode = $createRelationshipNode(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(relationshipNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","props","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","relationshipNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SACEC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,uBAAuB,EACvBC,aAAa,QACR,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AACjC,OAAOC,WAAW,QAAO;AAKzB,SAASC,kBAAkB,QAAQ,qBAAoB;AACvD,SAASC,uBAAuB,EAAEC,gBAAgB,QAAQ,+BAA8B;AAExF,OAAO,MAAMC,8BAAgEN,cAC3E,+BACD;AAED,OAAO,SAASO,mBAAmBC,KAAgC;IACjE,MAAM,CAACC,OAAO,GAAGjB;IACjB,MAAM,EAAEkB,WAAW,EAAE,GAAGhB;IAExB,IAAIiB,mBAA6B;IAEjC,IAAIH,OAAOI,oBAAoB;QAC7BD,mBAAmBH,OAAOI;IAC5B,OAAO,IAAIJ,OAAOK,qBAAqB;QACrCF,mBAAmBD,YAChBI,MAAM,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAK,CAACP,OAAOK,qBAAqBG,SAASD,OAC3DE,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAE,GAAKA;IACvB;IAEAd,UAAU;QACR,IAAI,CAACQ,OAAOS,QAAQ,CAAC;YAACb;SAAiB,GAAG;YACxC,MAAM,IAAIc,MAAM;QAClB;QAEA,OAAOV,OAAOW,eAAe,CAC3Bd,6BACA,CAACe;YACC,MAAMC,mBAAmBlB,wBAAwBiB;YAEjD,MAAME,YAAY3B,mBAAmBD;YAErC,IAAIG,kBAAkByB,YAAY;gBAChC,MAAM,EAAEC,KAAK,EAAE,GAAGD;gBAClB,MAAME,YAAYD,MAAME,OAAO;gBAE/B,+FAA+F;gBAC/F,0FAA0F;gBAC1F,IACE7B,iBAAiB4B,cACjBA,UAAUE,kBAAkB,OAAO,KACnCF,UACGG,SAAS,GACTC,WAAW,GACXf,MAAM,CAAC,CAACgB,OAASjC,iBAAiBiC,OAAOC,MAAM,GAAG,GACrD;oBACAN,UAAUO,MAAM;gBAClB;gBAEAvC,yBAAyB6B;YAC3B;YAEA,OAAO;QACT,GACAvB;IAEJ,GAAG;QAACU;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD"}
1
+ {"version":3,"sources":["../../../../../src/field/features/relationship/plugins/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot } from '@lexical/utils'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport {\n $getPreviousSelection,\n $getSelection,\n $isParagraphNode,\n $isRangeSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { useEffect } from 'react'\nimport React from 'react'\n\nimport type { PluginComponent } from '../../types.js'\nimport type { RelationshipFeatureProps } from '../feature.server.js'\nimport type { RelationshipData } from '../nodes/RelationshipNode.js'\n\nimport { RelationshipDrawer } from '../drawer/index.js'\nimport { $createRelationshipNode, RelationshipNode } from '../nodes/RelationshipNode.js'\n\nexport const INSERT_RELATIONSHIP_COMMAND: LexicalCommand<RelationshipData> = createCommand(\n 'INSERT_RELATIONSHIP_COMMAND',\n)\n\nexport const RelationshipPlugin: PluginComponent<RelationshipFeatureProps> = ({ clientProps }) => {\n const [editor] = useLexicalComposerContext()\n const { collections } = useConfig()\n\n let enabledRelations: string[] = null\n\n if (clientProps?.enabledCollections) {\n enabledRelations = clientProps?.enabledCollections\n } else if (clientProps?.disabledCollections) {\n enabledRelations = collections\n .filter(({ slug }) => !clientProps?.disabledCollections?.includes(slug))\n .map(({ slug }) => slug)\n }\n\n useEffect(() => {\n if (!editor.hasNodes([RelationshipNode])) {\n throw new Error('RelationshipPlugin: RelationshipNode not registered on editor')\n }\n\n return editor.registerCommand<RelationshipData>(\n INSERT_RELATIONSHIP_COMMAND,\n (payload) => {\n const relationshipNode = $createRelationshipNode(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(relationshipNode)\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n )\n }, [editor])\n\n return <RelationshipDrawer enabledCollectionSlugs={enabledRelations} />\n}\n"],"names":["useLexicalComposerContext","$insertNodeToNearestRoot","useConfig","$getPreviousSelection","$getSelection","$isParagraphNode","$isRangeSelection","COMMAND_PRIORITY_EDITOR","createCommand","useEffect","React","RelationshipDrawer","$createRelationshipNode","RelationshipNode","INSERT_RELATIONSHIP_COMMAND","RelationshipPlugin","clientProps","editor","collections","enabledRelations","enabledCollections","disabledCollections","filter","slug","includes","map","hasNodes","Error","registerCommand","payload","relationshipNode","selection","focus","focusNode","getNode","getTextContentSize","getParent","getChildren","node","length","remove","enabledCollectionSlugs"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,wBAAwB,QAAQ,iBAAgB;AACzD,SAASC,S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;gBAClB;gBAEAvC,yBAAyB6B;YAC3B;YAEA,OAAO;QACT,GACAvB;IAEJ,GAAG;QAACU;KAAO;IAEX,qBAAO,oBAACN;QAAmB8B,wBAAwBtB;;AACrD,EAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { PopulationPromise } from '../types.js';
2
+ import type { RelationshipFeatureProps } from './feature.server.js';
2
3
  import type { SerializedRelationshipNode } from './nodes/RelationshipNode.js';
3
- export declare const relationshipPopulationPromise: PopulationPromise<SerializedRelationshipNode>;
4
+ export declare const relationshipPopulationPromiseHOC: (props: RelationshipFeatureProps) => PopulationPromise<SerializedRelationshipNode>;
4
5
  //# sourceMappingURL=populationPromise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/relationship/populationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AAI7E,eAAO,MAAM,6BAA6B,EAAE,iBAAiB,CAAC,0BAA0B,CAmCvF,CAAA"}
1
+ {"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/relationship/populationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AAI7E,eAAO,MAAM,gCAAgC,UACpC,wBAAwB,KAC9B,kBAAkB,0BAA0B,CA0C9C,CAAA"}
@@ -1,26 +1,30 @@
1
1
  import { populate } from '../../../populate/populate.js';
2
- export const relationshipPopulationPromise = ({ currentDepth, depth, draft, field, node, overrideAccess, populationPromises, req, showHiddenFields })=>{
3
- if (node?.value) {
4
- // @ts-expect-error
5
- const id = node?.value?.id || node?.value // for backwards-compatibility
6
- ;
7
- const collection = req.payload.collections[node?.relationTo];
8
- if (collection) {
9
- populationPromises.push(populate({
10
- id,
11
- collection,
12
- currentDepth,
13
- data: node,
14
- depth,
15
- draft,
16
- field,
17
- key: 'value',
18
- overrideAccess,
19
- req,
20
- showHiddenFields
21
- }));
2
+ export const relationshipPopulationPromiseHOC = (props)=>{
3
+ const relationshipPopulationPromise = ({ currentDepth, depth, draft, field, node, overrideAccess, populationPromises, req, showHiddenFields })=>{
4
+ if (node?.value) {
5
+ // @ts-expect-error
6
+ const id = node?.value?.id || node?.value // for backwards-compatibility
7
+ ;
8
+ const collection = req.payload.collections[node?.relationTo];
9
+ if (collection) {
10
+ const populateDepth = props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth;
11
+ populationPromises.push(populate({
12
+ id,
13
+ collection,
14
+ currentDepth,
15
+ data: node,
16
+ depth: populateDepth,
17
+ draft,
18
+ field,
19
+ key: 'value',
20
+ overrideAccess,
21
+ req,
22
+ showHiddenFields
23
+ }));
24
+ }
22
25
  }
23
- }
26
+ };
27
+ return relationshipPopulationPromise;
24
28
  };
25
29
 
26
30
  //# sourceMappingURL=populationPromise.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/field/features/relationship/populationPromise.ts"],"sourcesContent":["import type { PopulationPromise } from '../types.js'\nimport type { SerializedRelationshipNode } from './nodes/RelationshipNode.js'\n\nimport { populate } from '../../../populate/populate.js'\n\nexport const relationshipPopulationPromise: PopulationPromise<SerializedRelationshipNode> = ({\n currentDepth,\n depth,\n draft,\n field,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n}) => {\n if (node?.value) {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n const collection = req.payload.collections[node?.relationTo]\n\n if (collection) {\n populationPromises.push(\n populate({\n id,\n collection,\n currentDepth,\n data: node,\n depth,\n draft,\n field,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n }),\n )\n }\n }\n}\n"],"names":["populate","relationshipPopulationPromise","currentDepth","depth","draft","field","node","overrideAccess","populationPromises","req","showHiddenFields","value","id","collection","payload","collections","relationTo","push","data","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,QAAQ,QAAQ,gCAA+B;AAExD,OAAO,MAAMC,gCAA+E,CAAC,EAC3FC,YAAY,EACZC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EACjB;IACC,IAAIJ,MAAMK,OAAO;QACf,mBAAmB;QACnB,MAAMC,KAAKN,MAAMK,OAAOC,MAAMN,MAAMK,MAAM,8BAA8B;;QAExE,MAAME,aAAaJ,IAAIK,OAAO,CAACC,WAAW,CAACT,MAAMU,WAAW;QAE5D,IAAIH,YAAY;YACdL,mBAAmBS,IAAI,CACrBjB,SAAS;gBACPY;gBACAC;gBACAX;gBACAgB,MAAMZ;gBACNH;gBACAC;gBACAC;gBACAc,KAAK;gBACLZ;gBACAE;gBACAC;YACF;QAEJ;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/field/features/relationship/populationPromise.ts"],"sourcesContent":["import type { PopulationPromise } from '../types.js'\nimport type { RelationshipFeatureProps } from './feature.server.js'\nimport type { SerializedRelationshipNode } from './nodes/RelationshipNode.js'\n\nimport { populate } from '../../../populate/populate.js'\n\nexport const relationshipPopulationPromiseHOC = (\n props: RelationshipFeatureProps,\n): PopulationPromise<SerializedRelationshipNode> => {\n const relationshipPopulationPromise: PopulationPromise<SerializedRelationshipNode> = ({\n currentDepth,\n depth,\n draft,\n field,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (node?.value) {\n // @ts-expect-error\n const id = node?.value?.id || node?.value // for backwards-compatibility\n\n const collection = req.payload.collections[node?.relationTo]\n\n if (collection) {\n const populateDepth =\n props?.maxDepth !== undefined && props?.maxDepth < depth ? props?.maxDepth : depth\n\n populationPromises.push(\n populate({\n id,\n collection,\n currentDepth,\n data: node,\n depth: populateDepth,\n draft,\n field,\n key: 'value',\n overrideAccess,\n req,\n showHiddenFields,\n }),\n )\n }\n }\n }\n\n return relationshipPopulationPromise\n}\n"],"names":["populate","relationshipPopulationPromiseHOC","props","relationshipPopulationPromise","currentDepth","depth","draft","field","node","overrideAccess","populationPromises","req","showHiddenFields","value","id","collection","payload","collections","relationTo","populateDepth","maxDepth","undefined","push","data","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,gCAA+B;AAExD,OAAO,MAAMC,mCAAmC,CAC9CC;IAEA,MAAMC,gCAA+E,CAAC,EACpFC,YAAY,EACZC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EACjB;QACC,IAAIJ,MAAMK,OAAO;YACf,mBAAmB;YACnB,MAAMC,KAAKN,MAAMK,OAAOC,MAAMN,MAAMK,MAAM,8BAA8B;;YAExE,MAAME,aAAaJ,IAAIK,OAAO,CAACC,WAAW,CAACT,MAAMU,WAAW;YAE5D,IAAIH,YAAY;gBACd,MAAMI,gBACJjB,OAAOkB,aAAaC,aAAanB,OAAOkB,WAAWf,QAAQH,OAAOkB,WAAWf;gBAE/EK,mBAAmBY,IAAI,CACrBtB,SAAS;oBACPc;oBACAC;oBACAX;oBACAmB,MAAMf;oBACNH,OAAOc;oBACPb;oBACAC;oBACAiB,KAAK;oBACLf;oBACAE;oBACAC;gBACF;YAEJ;QACF;IACF;IAEA,OAAOT;AACT,EAAC"}
@@ -1,6 +1,4 @@
1
- import * as React from 'react';
1
+ import type { PluginComponentWithAnchor } from '../../../types.js';
2
2
  import './index.scss';
3
- export declare function FixedToolbarPlugin({ anchorElem, }: {
4
- anchorElem?: HTMLElement;
5
- }): React.ReactElement | null;
3
+ export declare const FixedToolbarPlugin: PluginComponentWithAnchor<undefined>;
6
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/fixed/Toolbar/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,OAAO,cAAc,CAAA;AA2KrB,wBAAgB,kBAAkB,CAAC,EACjC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAqB5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/fixed/Toolbar/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAOlE,OAAO,cAAc,CAAA;AA2KrB,eAAO,MAAM,kBAAkB,EAAE,yBAAyB,CAAC,SAAS,CAqBnE,CAAA"}
@@ -128,7 +128,7 @@ const checkParentEditor = (editorFocus)=>{
128
128
  }
129
129
  return false;
130
130
  };
131
- export function FixedToolbarPlugin({ anchorElem = document.body }) {
131
+ export const FixedToolbarPlugin = ({ anchorElem })=>{
132
132
  const [currentEditor] = useLexicalComposerContext();
133
133
  const { editorConfig: currentEditorConfig, uuid } = useEditorConfigContext();
134
134
  const editorFocus = useEditorFocus();
@@ -147,6 +147,6 @@ export function FixedToolbarPlugin({ anchorElem = document.body }) {
147
147
  editor: editor,
148
148
  editorConfig: editorConfig
149
149
  });
150
- }
150
+ };
151
151
 
152
152
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/field/features/toolbars/fixed/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport * as React from 'react'\n\nimport type { EditorFocusContextType } from '../../../../lexical/EditorFocusProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../lexical/config/types.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../types.js'\n\nimport { useEditorFocus } from '../../../../lexical/EditorFocusProvider.js'\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../shared/ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n {item?.ChildComponent && <item.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation()\n\n const [dropdownLabel, setDropdownLabel] = React.useState<null | string>(null)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | null>(null)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent)\n } else {\n setDropdownIcon(null)\n }\n }, [group])\n\n const onActiveChange = ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent)\n setDropdownLabel(null)\n } else {\n setDropdownIcon(null)\n setDropdownLabel(null)\n }\n return\n }\n const item = activeItems[0]\n\n let label = item.key\n if (item.label) {\n label = typeof item.label === 'function' ? item.label({ i18n }) : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n }\n\n return (\n <div className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`} key={group.key}>\n {group.type === 'dropdown' &&\n group.items.length &&\n (DropdownIcon ? (\n <ToolbarDropdown\n Icon={DropdownIcon}\n anchorElem={anchorElem}\n editor={editor}\n groupKey={group.key}\n items={group.items}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n groupKey={group.key}\n items={group.items}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ))}\n {group.type === 'buttons' &&\n group.items.length &&\n group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n editor,\n editorConfig,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n}): React.ReactNode {\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n >\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst checkParentEditor = (editorFocus: EditorFocusContextType): boolean => {\n if (editorFocus.parentEditorConfigContext?.editorConfig) {\n if (\n editorFocus.parentEditorConfigContext?.editorConfig.resolvedFeatureMap.has('toolbarFixed')\n ) {\n return true\n } else {\n if (editorFocus.parentEditorFocus) {\n return checkParentEditor(editorFocus.parentEditorFocus)\n }\n }\n }\n return false\n}\n\nexport function FixedToolbarPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactElement | null {\n const [currentEditor] = useLexicalComposerContext()\n const { editorConfig: currentEditorConfig, uuid } = useEditorConfigContext()\n\n const editorFocus = useEditorFocus()\n const editor = editorFocus.focusedEditor || currentEditor\n\n const editorConfig = editorFocus.focusedEditorConfigContext?.editorConfig || currentEditorConfig\n\n // Check if there is a parent editor with a fixed toolbar already\n const hasParentWithFixedToolbar = checkParentEditor(editorFocus)\n\n if (hasParentWithFixedToolbar) {\n return null\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return <FixedToolbar anchorElem={anchorElem} editor={editor} editorConfig={editorConfig} />\n}\n"],"names":["useLexicalComposerContext","useTranslation","React","useEditorFocus","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","i18n","dropdownLabel","setDropdownLabel","useState","DropdownIcon","setDropdownIcon","useEffect","type","items","length","onActiveChange","activeItems","label","substring","div","className","Icon","groupKey","itemsContainerClassNames","maxActiveItems","map","features","toolbarFixed","groups","FixedToolbar","onFocus","event","stopPropagation","isEditable","Fragment","i","checkParentEditor","editorFocus","parentEditorConfigContext","resolvedFeatureMap","has","parentEditorFocus","FixedToolbarPlugin","document","body","currentEditor","currentEditorConfig","uuid","focusedEditor","focusedEditorConfigContext","hasParentWithFixedToolbar"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,4BAA4Bd,kBAAkBC;IAEpD,IAAIa,2BAA2B;QAC7B,OAAO;IACT;IAEA,IAAI,CAAChD,cAAcwB,UAAUC,cAAcC,QAAQd,QAAQ;QACzD,OAAO;IACT;IAEA,qBAAO,oBAACe;QAAalC,YAAYA;QAAYC,QAAQA;QAAQM,cAAcA;;AAC7E"}
1
+ {"version":3,"sources":["../../../../../../src/field/features/toolbars/fixed/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport * as React from 'react'\n\nimport type { EditorFocusContextType } from '../../../../lexical/EditorFocusProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../lexical/config/types.js'\nimport type { PluginComponentWithAnchor } from '../../../types.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../types.js'\n\nimport { useEditorFocus } from '../../../../lexical/EditorFocusProvider.js'\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../shared/ToolbarDropdown/index.js'\nimport './index.scss'\n\nfunction ButtonGroupItem({\n anchorElem,\n editor,\n item,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n return (\n <ToolbarButton editor={editor} item={item} key={item.key}>\n {item?.ChildComponent && <item.ChildComponent />}\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n}): React.ReactNode {\n const { i18n } = useTranslation()\n\n const [dropdownLabel, setDropdownLabel] = React.useState<null | string>(null)\n const [DropdownIcon, setDropdownIcon] = React.useState<React.FC | null>(null)\n\n React.useEffect(() => {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent)\n } else {\n setDropdownIcon(null)\n }\n }, [group])\n\n const onActiveChange = ({ activeItems }: { activeItems: ToolbarGroupItem[] }) => {\n if (!activeItems.length) {\n if (group?.type === 'dropdown' && group.items.length && group.ChildComponent) {\n setDropdownIcon(() => group.ChildComponent)\n setDropdownLabel(null)\n } else {\n setDropdownIcon(null)\n setDropdownLabel(null)\n }\n return\n }\n const item = activeItems[0]\n\n let label = item.key\n if (item.label) {\n label = typeof item.label === 'function' ? item.label({ i18n }) : item.label\n }\n // Crop title to max. 25 characters\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n setDropdownLabel(label)\n setDropdownIcon(() => item.ChildComponent)\n }\n\n return (\n <div className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`} key={group.key}>\n {group.type === 'dropdown' &&\n group.items.length &&\n (DropdownIcon ? (\n <ToolbarDropdown\n Icon={DropdownIcon}\n anchorElem={anchorElem}\n editor={editor}\n groupKey={group.key}\n items={group.items}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ) : (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n groupKey={group.key}\n items={group.items}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n maxActiveItems={1}\n onActiveChange={onActiveChange}\n />\n ))}\n {group.type === 'buttons' &&\n group.items.length &&\n group.items.map((item) => {\n return (\n <ButtonGroupItem anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n })}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n editor,\n editorConfig,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n}): React.ReactNode {\n return (\n <div\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n >\n {editor.isEditable() && (\n <React.Fragment>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n />\n )\n })}\n </React.Fragment>\n )}\n </div>\n )\n}\n\nconst checkParentEditor = (editorFocus: EditorFocusContextType): boolean => {\n if (editorFocus.parentEditorConfigContext?.editorConfig) {\n if (\n editorFocus.parentEditorConfigContext?.editorConfig.resolvedFeatureMap.has('toolbarFixed')\n ) {\n return true\n } else {\n if (editorFocus.parentEditorFocus) {\n return checkParentEditor(editorFocus.parentEditorFocus)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponentWithAnchor<undefined> = ({ anchorElem }) => {\n const [currentEditor] = useLexicalComposerContext()\n const { editorConfig: currentEditorConfig, uuid } = useEditorConfigContext()\n\n const editorFocus = useEditorFocus()\n const editor = editorFocus.focusedEditor || currentEditor\n\n const editorConfig = editorFocus.focusedEditorConfigContext?.editorConfig || currentEditorConfig\n\n // Check if there is a parent editor with a fixed toolbar already\n const hasParentWithFixedToolbar = checkParentEditor(editorFocus)\n\n if (hasParentWithFixedToolbar) {\n return null\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return <FixedToolbar anchorElem={anchorElem} editor={editor} editorConfig={editorConfig} />\n}\n"],"names":["useLexicalComposerContext","useTranslation","React","useEditorFocus","useEditorConfigContext","ToolbarButton","ToolbarDropdown","ButtonGroupItem","anchorElem","editor","item","Component","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","i18n","dropdownLabel","setDropdownLabel","useState","DropdownIcon","setDropdownIcon","useEffect","type","items","length","onActiveChange","activeItems","label","substring","div","className","Icon","groupKey","itemsContainerClassNames","maxActiveItems","map","features","toolbarFixed","groups","FixedToolbar","onFocus","event","stopPropagation","isEditable","Fragment","i","checkParentEditor","editorFocus","parentEditorConfigContext","resolvedFeatureMap","has","parentEditorFocus","FixedToolbarPlugin","currentEditor","currentEditorConfig","uuid","focusedEditor","focusedEditorConfigContext","hasParentWithFixedToolbar"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,cAAc,QAAQ,uCAAsC;AACrE,YAAYC,WAAW,QAAO;AAO9B,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,sBAAsB,QAAQ,4DAA2D;AAClG,SAASC,aAAa,QAAQ,sCAAqC;AACnE,SAASC,eAAe,QAAQ,wCAAuC;AACvE,OAAO,eAAc;AAErB,SAASC,gBAAgB,EACvBC,UAAU,EACVC,MAAM,EACNC,IAAI,EAKL;IACC,IAAIA,KAAKC,SAAS,EAAE;QAClB,OACED,MAAMC,2BACJ,oBAACD,KAAKC,SAAS;YAACH,YAAYA;YAAYC,QAAQA;YAAQC,MAAMA;YAAME,KAAKF,KAAKE,GAAG;;IAGvF;IAEA,qBACE,oBAACP;QAAcI,QAAQA;QAAQC,MAAMA;QAAME,KAAKF,KAAKE,GAAG;OACrDF,MAAMG,gCAAkB,oBAACH,KAAKG,cAAc;AAGnD;AAEA,SAASC,sBAAsB,EAC7BN,UAAU,EACVC,MAAM,EACNM,YAAY,EACZC,KAAK,EACLC,KAAK,EAON;IACC,MAAM,EAAEC,IAAI,EAAE,GAAGjB;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,OAAO;YACL,IAAIH,YAAYI,iBAAiB,EAAE;gBACjC,OAAOL,kBAAkBC,YAAYI,iBAAiB;YACxD;QACF;IACF;IACA,OAAO;AACT;AAEA,OAAO,MAAMC,qBAA2D,CAAC,EAAE/C,UAAU,EAAE;IACrF,MAAM,CAACgD,cAAc,GAAGxD;IACxB,MAAM,EAAEe,cAAc0C,mBAAmB,EAAEC,IAAI,EAAE,GAAGtD;IAEpD,MAAM8C,cAAc/C;IACpB,MAAMM,SAASyC,YAAYS,aAAa,IAAIH;IAE5C,MAAMzC,eAAemC,YAAYU,0BAA0B,EAAE7C,gBAAgB0C;IAE7E,iEAAiE;IACjE,MAAMI,4BAA4BZ,kBAAkBC;IAEpD,IAAIW,2BAA2B;QAC7B,OAAO;IACT;IAEA,IAAI,CAAC9C,cAAcwB,UAAUC,cAAcC,QAAQd,QAAQ;QACzD,OAAO;IACT;IAEA,qBAAO,oBAACe;QAAalC,YAAYA;QAAYC,QAAQA;QAAQM,cAAcA;;AAC7E,EAAC"}
@@ -47,10 +47,10 @@ html[data-theme='dark'] {
47
47
  .fixed-toolbar {
48
48
  @include blur-bg(var(--theme-elevation-0));
49
49
  display: flex;
50
- align-items: center;
50
+ flex-wrap: wrap;
51
+ align-items: stretch;
51
52
  padding: 0 3.72px 0 6.25px;
52
53
  vertical-align: middle;
53
- height: 37.5px;
54
54
  position: sticky;
55
55
  z-index: 2;
56
56
  top: var(--doc-controls-height);
@@ -1,6 +1,4 @@
1
- import * as React from 'react';
1
+ import type { PluginComponentWithAnchor } from '../../../types.js';
2
2
  import './index.scss';
3
- export declare function InlineToolbarPlugin({ anchorElem, }: {
4
- anchorElem?: HTMLElement;
5
- }): React.ReactElement | null;
3
+ export declare const InlineToolbarPlugin: PluginComponentWithAnchor<undefined>;
6
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/inline/Toolbar/index.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,OAAO,cAAc,CAAA;AA4WrB,wBAAgB,mBAAmB,CAAC,EAClC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAI5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/toolbars/inline/Toolbar/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAQlE,OAAO,cAAc,CAAA;AAqXrB,eAAO,MAAM,mBAAmB,EAAE,yBAAyB,CAAC,SAAS,CAIpE,CAAA"}
@@ -124,9 +124,7 @@ function InlineToolbar({ anchorElem, editor }) {
124
124
  floatingToolbarRef.current.style.pointerEvents = 'auto';
125
125
  }
126
126
  }
127
- }, [
128
- floatingToolbarRef
129
- ]);
127
+ }, []);
130
128
  useEffect(()=>{
131
129
  document.addEventListener('mousemove', mouseMoveListener);
132
130
  document.addEventListener('mouseup', mouseUpListener);
@@ -145,18 +143,38 @@ function InlineToolbar({ anchorElem, editor }) {
145
143
  if (floatingToolbarRef.current === null) {
146
144
  return;
147
145
  }
146
+ const possibleLinkEditor = anchorElem.querySelector(':scope > .link-editor');
147
+ const isLinkEditorVisible = possibleLinkEditor !== null && 'style' in possibleLinkEditor && possibleLinkEditor?.style?.['opacity'] === '1';
148
148
  const rootElement = editor.getRootElement();
149
149
  if (selection !== null && nativeSelection !== null && !nativeSelection.isCollapsed && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
150
150
  const rangeRect = getDOMRangeRect(nativeSelection, rootElement);
151
151
  // Position floating toolbar
152
- const offsetIfFlipped = setFloatingElemPosition(rangeRect, floatingToolbarRef.current, anchorElem, 'center');
152
+ const offsetIfFlipped = setFloatingElemPosition({
153
+ alwaysDisplayOnTop: isLinkEditorVisible,
154
+ anchorElem,
155
+ floatingElem: floatingToolbarRef.current,
156
+ horizontalPosition: 'center',
157
+ targetRect: rangeRect
158
+ });
153
159
  // Position caret
154
160
  if (caretRef.current) {
155
- setFloatingElemPosition(rangeRect, caretRef.current, floatingToolbarRef.current, 'center', 10, 5, true, offsetIfFlipped);
161
+ setFloatingElemPosition({
162
+ anchorElem: floatingToolbarRef.current,
163
+ anchorFlippedOffset: offsetIfFlipped,
164
+ floatingElem: caretRef.current,
165
+ horizontalOffset: 5,
166
+ horizontalPosition: 'center',
167
+ specialHandlingForCaret: true,
168
+ targetRect: rangeRect,
169
+ verticalGap: 10
170
+ });
156
171
  }
172
+ } else {
173
+ closeFloatingToolbar();
157
174
  }
158
175
  }, [
159
176
  editor,
177
+ closeFloatingToolbar,
160
178
  anchorElem
161
179
  ]);
162
180
  useEffect(()=>{
@@ -286,9 +304,9 @@ function useInlineToolbar(editor, anchorElem) {
286
304
  editor: editor
287
305
  }), anchorElem);
288
306
  }
289
- export function InlineToolbarPlugin({ anchorElem = document.body }) {
307
+ export const InlineToolbarPlugin = ({ anchorElem })=>{
290
308
  const [editor] = useLexicalComposerContext();
291
309
  return useInlineToolbar(editor, anchorElem);
292
- }
310
+ };
293
311
 
294
312
  //# sourceMappingURL=index.js.map