@payloadcms/richtext-lexical 3.89.0 → 3.90.0

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 (195) hide show
  1. package/dist/exports/client/{Field-J6MIUIWP.js → Field-YZR46UCY.js} +1 -1
  2. package/dist/exports/client/{Field-J6MIUIWP.js.map → Field-YZR46UCY.js.map} +1 -1
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-OSMEE5HW.js +2 -0
  5. package/dist/exports/client/chunk-OSMEE5HW.js.map +7 -0
  6. package/dist/exports/client/component-UBRNPIQ6.js +2 -0
  7. package/dist/exports/client/component-UBRNPIQ6.js.map +7 -0
  8. package/dist/exports/client/index.js +21 -21
  9. package/dist/exports/client/index.js.map +4 -4
  10. package/dist/features/converters/lexicalToHtml/async/converters/heading.js +1 -1
  11. package/dist/features/converters/lexicalToHtml/async/converters/heading.js.map +1 -1
  12. package/dist/features/converters/lexicalToHtml/async/converters/list.d.ts.map +1 -1
  13. package/dist/features/converters/lexicalToHtml/async/converters/list.js +4 -3
  14. package/dist/features/converters/lexicalToHtml/async/converters/list.js.map +1 -1
  15. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js +1 -1
  16. package/dist/features/converters/lexicalToHtml/sync/converters/heading.js.map +1 -1
  17. package/dist/features/converters/lexicalToHtml/sync/converters/list.d.ts.map +1 -1
  18. package/dist/features/converters/lexicalToHtml/sync/converters/list.js +4 -3
  19. package/dist/features/converters/lexicalToHtml/sync/converters/list.js.map +1 -1
  20. package/dist/features/converters/lexicalToJSX/Component/nodeTags.spec.js +114 -0
  21. package/dist/features/converters/lexicalToJSX/Component/nodeTags.spec.js.map +1 -0
  22. package/dist/features/converters/lexicalToJSX/converter/converters/heading.d.ts.map +1 -1
  23. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js +2 -1
  24. package/dist/features/converters/lexicalToJSX/converter/converters/heading.js.map +1 -1
  25. package/dist/features/converters/lexicalToJSX/converter/converters/list.d.ts.map +1 -1
  26. package/dist/features/converters/lexicalToJSX/converter/converters/list.js +2 -1
  27. package/dist/features/converters/lexicalToJSX/converter/converters/list.js.map +1 -1
  28. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts +8 -0
  29. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/computeSelectionCount.d.ts.map +1 -0
  30. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js +19 -0
  31. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/computeSelectionCount.js.map +1 -0
  32. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  33. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js +16 -43
  34. package/dist/features/experimental_table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
  35. package/dist/features/heading/constants.d.ts +2 -0
  36. package/dist/features/heading/constants.d.ts.map +1 -0
  37. package/dist/features/heading/constants.js +2 -0
  38. package/dist/features/heading/constants.js.map +1 -0
  39. package/dist/features/heading/server/index.d.ts.map +1 -1
  40. package/dist/features/heading/server/index.js +8 -2
  41. package/dist/features/heading/server/index.js.map +1 -1
  42. package/dist/features/heading/server/validate.d.ts +6 -0
  43. package/dist/features/heading/server/validate.d.ts.map +1 -0
  44. package/dist/features/heading/server/validate.js +15 -0
  45. package/dist/features/heading/server/validate.js.map +1 -0
  46. package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
  47. package/dist/features/lists/checklist/server/index.js +5 -2
  48. package/dist/features/lists/checklist/server/index.js.map +1 -1
  49. package/dist/features/lists/htmlConverter.d.ts.map +1 -1
  50. package/dist/features/lists/htmlConverter.js +6 -3
  51. package/dist/features/lists/htmlConverter.js.map +1 -1
  52. package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
  53. package/dist/features/lists/orderedList/server/index.js +5 -2
  54. package/dist/features/lists/orderedList/server/index.js.map +1 -1
  55. package/dist/features/lists/shared/constants.d.ts +2 -0
  56. package/dist/features/lists/shared/constants.d.ts.map +1 -0
  57. package/dist/features/lists/shared/constants.js +2 -0
  58. package/dist/features/lists/shared/constants.js.map +1 -0
  59. package/dist/features/lists/shared/validate.d.ts +5 -0
  60. package/dist/features/lists/shared/validate.d.ts.map +1 -0
  61. package/dist/features/lists/shared/validate.js +15 -0
  62. package/dist/features/lists/shared/validate.js.map +1 -0
  63. package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
  64. package/dist/features/lists/unorderedList/server/index.js +5 -2
  65. package/dist/features/lists/unorderedList/server/index.js.map +1 -1
  66. package/dist/features/relationship/client/index.d.ts +2 -2
  67. package/dist/features/relationship/client/index.d.ts.map +1 -1
  68. package/dist/features/relationship/client/index.js.map +1 -1
  69. package/dist/features/relationship/client/plugins/index.d.ts +2 -2
  70. package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
  71. package/dist/features/relationship/client/plugins/index.js +27 -31
  72. package/dist/features/relationship/client/plugins/index.js.map +1 -1
  73. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts +2 -4
  74. package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
  75. package/dist/features/relationship/client/utils/useEnabledRelationships.js +52 -50
  76. package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
  77. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +2 -2
  78. package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
  79. package/dist/features/relationship/server/graphQLPopulationPromise.js +2 -2
  80. package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
  81. package/dist/features/relationship/server/index.d.ts +8 -1
  82. package/dist/features/relationship/server/index.d.ts.map +1 -1
  83. package/dist/features/relationship/server/index.js +28 -11
  84. package/dist/features/relationship/server/index.js.map +1 -1
  85. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +7 -0
  86. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -0
  87. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +23 -0
  88. package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -0
  89. package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
  90. package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
  91. package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
  92. package/dist/features/upload/client/component/index.js +2 -1
  93. package/dist/features/upload/client/component/index.js.map +1 -1
  94. package/dist/features/upload/client/index.d.ts +3 -2
  95. package/dist/features/upload/client/index.d.ts.map +1 -1
  96. package/dist/features/upload/client/index.js.map +1 -1
  97. package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
  98. package/dist/features/upload/client/plugin/index.js +47 -52
  99. package/dist/features/upload/client/plugin/index.js.map +1 -1
  100. package/dist/features/upload/server/graphQLPopulationPromise.d.ts +2 -2
  101. package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
  102. package/dist/features/upload/server/graphQLPopulationPromise.js +1 -1
  103. package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
  104. package/dist/features/upload/server/index.d.ts +6 -2
  105. package/dist/features/upload/server/index.d.ts.map +1 -1
  106. package/dist/features/upload/server/index.js +21 -14
  107. package/dist/features/upload/server/index.js.map +1 -1
  108. package/dist/features/upload/server/validate.d.ts +2 -2
  109. package/dist/features/upload/server/validate.d.ts.map +1 -1
  110. package/dist/features/upload/server/validate.js +3 -0
  111. package/dist/features/upload/server/validate.js.map +1 -1
  112. package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -1
  113. package/dist/field/Diff/converters/listitem/index.js +2 -1
  114. package/dist/field/Diff/converters/listitem/index.js.map +1 -1
  115. package/dist/field/Diff/index.d.ts.map +1 -1
  116. package/dist/field/Diff/index.js +1 -0
  117. package/dist/field/Diff/index.js.map +1 -1
  118. package/dist/field/RenderLexical/index.d.ts +3 -1
  119. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  120. package/dist/field/RenderLexical/index.js +23 -23
  121. package/dist/field/RenderLexical/index.js.map +1 -1
  122. package/dist/field/bundled.css +1 -1
  123. package/dist/index.d.ts +1 -1
  124. package/dist/index.js +1 -1
  125. package/dist/index.js.map +1 -1
  126. package/dist/lexical/LexicalEditor.js.map +1 -1
  127. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts +2 -0
  128. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.d.ts.map +1 -0
  129. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js +2 -0
  130. package/dist/lexical-proxy/@lexical-react/ExtensionComponent.js.map +1 -0
  131. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts +2 -0
  132. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.d.ts.map +1 -0
  133. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js +2 -0
  134. package/dist/lexical-proxy/@lexical-react/LexicalExtensionComposer.js.map +1 -0
  135. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts +2 -0
  136. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.d.ts.map +1 -0
  137. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js +2 -0
  138. package/dist/lexical-proxy/@lexical-react/LexicalExtensionEditorComposer.js.map +1 -0
  139. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts +2 -0
  140. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.d.ts.map +1 -0
  141. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js +2 -0
  142. package/dist/lexical-proxy/@lexical-react/LexicalSelectionAlwaysOnDisplay.js.map +1 -0
  143. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts +2 -0
  144. package/dist/lexical-proxy/@lexical-react/ReactExtension.d.ts.map +1 -0
  145. package/dist/lexical-proxy/@lexical-react/ReactExtension.js +2 -0
  146. package/dist/lexical-proxy/@lexical-react/ReactExtension.js.map +1 -0
  147. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts +2 -0
  148. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.d.ts.map +1 -0
  149. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js +2 -0
  150. package/dist/lexical-proxy/@lexical-react/ReactPluginHostExtension.js.map +1 -0
  151. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts +2 -0
  152. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.d.ts.map +1 -0
  153. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js +2 -0
  154. package/dist/lexical-proxy/@lexical-react/ReactProviderExtension.js.map +1 -0
  155. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts +2 -0
  156. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.d.ts.map +1 -0
  157. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js +2 -0
  158. package/dist/lexical-proxy/@lexical-react/TreeViewExtension.js.map +1 -0
  159. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts +2 -0
  160. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.d.ts.map +1 -0
  161. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js +2 -0
  162. package/dist/lexical-proxy/@lexical-react/useExtensionComponent.js.map +1 -0
  163. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts +2 -0
  164. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.d.ts.map +1 -0
  165. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js +2 -0
  166. package/dist/lexical-proxy/@lexical-react/useExtensionSignalValue.js.map +1 -0
  167. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts +2 -0
  168. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.d.ts.map +1 -0
  169. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js +2 -0
  170. package/dist/lexical-proxy/@lexical-react/useLexicalAriaLiveRegion.js.map +1 -0
  171. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts +2 -0
  172. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.d.ts.map +1 -0
  173. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js +2 -0
  174. package/dist/lexical-proxy/@lexical-react/useLexicalFocusManagerRef.js.map +1 -0
  175. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts +2 -0
  176. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.d.ts.map +1 -0
  177. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js +2 -0
  178. package/dist/lexical-proxy/@lexical-react/useLexicalFocusTrapRef.js.map +1 -0
  179. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts +2 -0
  180. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.d.ts.map +1 -0
  181. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js +2 -0
  182. package/dist/lexical-proxy/@lexical-react/useLexicalRovingTabIndexRef.js.map +1 -0
  183. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts +2 -0
  184. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.d.ts.map +1 -0
  185. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js +2 -0
  186. package/dist/lexical-proxy/@lexical-react/useLexicalSlotRef.js.map +1 -0
  187. package/package.json +94 -24
  188. package/dist/exports/client/chunk-FWFDJAJ5.js +0 -2
  189. package/dist/exports/client/chunk-FWFDJAJ5.js.map +0 -7
  190. package/dist/exports/client/component-BAAVC34S.js +0 -2
  191. package/dist/exports/client/component-BAAVC34S.js.map +0 -7
  192. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
  193. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
  194. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
  195. package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import{b as I}from"./chunk-BZZVLW4U.js";import{c as ot}from"react/compiler-runtime";import{jsx as y}from"react/jsx-runtime";import{Drawer as at,EditDepthProvider as it,useModal as lt}from"@payloadcms/ui";import"react";import{jsx as R,jsxs as K}from"react/jsx-runtime";import{useLexicalEditable as G}from"@lexical/react/useLexicalEditable";import{Form as V,FormSubmit as q,RenderFields as Q,useDocumentForm as X,useDocumentInfo as Y,useEffectEvent as Z,useServerFunctions as N,useTranslation as z}from"@payloadcms/ui";import{abortAndIgnore as O}from"@payloadcms/ui/shared";import{deepCopyObjectSimpleWithoutReactComponents as T}from"payload/shared";import{useCallback as tt,useEffect as F,useRef as et,useState as rt}from"react";import{v4 as nt}from"uuid";var j=({data:r,featureKey:t,fieldMapOverride:e,handleDrawerSubmit:n,schemaFieldsPathOverride:o,schemaPath:_,schemaPathSuffix:f})=>{let{t:x}=z(),{id:l,collectionSlug:s,getDocPreferences:c,globalSlug:u}=Y(),{fields:p}=X(),i=G(),a=et(new AbortController),[d,w]=rt(!1),{fieldProps:{featureClientSchemaMap:C}}=I(),{getFormState:S}=N(),g=o??`${_}.lexical_internal_feature.${t}${f?`.${f}`:""}`,b=e??C[t]?.[g],B=Z(async m=>{let{state:D}=await S({id:l,collectionSlug:s,data:r??{},docPermissions:{fields:!0},docPreferences:await c(),documentFormState:T(p,{excludeFiles:!0}),globalSlug:u,initialBlockData:r,operation:"update",readOnly:!i,renderAllFields:!0,schemaPath:g,signal:m.signal});w(D)});F(()=>{let m=new AbortController;return B(m),()=>{O(m)}},[g,l,r,S,s,i,u,c]);let E=tt(async({formState:m})=>{O(a.current);let D=new AbortController;a.current=D;let{state:P}=await S({id:l,collectionSlug:s,docPermissions:{fields:!0},docPreferences:await c(),documentFormState:T(p,{excludeFiles:!0}),formState:m,globalSlug:u,initialBlockFormState:m,operation:"update",readOnly:!i,schemaPath:g,signal:D.signal});return P||m},[S,l,i,s,c,p,u,g]);return F(()=>()=>{O(a.current)},[]),d===!1?null:K(V,{beforeSubmit:[E],disableValidationOnSubmit:!0,fields:Array.isArray(b)?b:[],initialState:d,onChange:[E],onSubmit:n,uuid:nt(),children:[R(Q,{fields:Array.isArray(b)?b:[],forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:g,permissions:!0,readOnly:!i}),R(q,{children:x("fields:saveChanges")})]})};var Tt=r=>{let t=ot(15),{className:e,data:n,drawerSlug:o,drawerTitle:_,featureKey:f,fieldMapOverride:x,handleDrawerSubmit:l,schemaFieldsPathOverride:s,schemaPath:c,schemaPathSuffix:u}=r,{closeModal:p}=lt(),i=_??"",a;t[0]!==p||t[1]!==o||t[2]!==l?(a=(w,C)=>{p(o),setTimeout(()=>{l(w,C)},1)},t[0]=p,t[1]=o,t[2]=l,t[3]=a):a=t[3];let d;return t[4]!==e||t[5]!==n||t[6]!==o||t[7]!==f||t[8]!==x||t[9]!==s||t[10]!==c||t[11]!==u||t[12]!==i||t[13]!==a?(d=y(it,{children:y(at,{className:e,slug:o,title:i,children:y(j,{data:n,featureKey:f,fieldMapOverride:x,handleDrawerSubmit:a,schemaFieldsPathOverride:s,schemaPath:c,schemaPathSuffix:u})})}),t[4]=e,t[5]=n,t[6]=o,t[7]=f,t[8]=x,t[9]=s,t[10]=c,t[11]=u,t[12]=i,t[13]=a,t[14]=d):d=t[14],d};import{createCommand as st}from"lexical";var Mt=st("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{jsx as H}from"react/jsx-runtime";import L from"bson-objectid";import{$applyNodeReplacement as ft}from"lexical";import*as W from"react";import ct from"bson-objectid";function v(r,t){if(r.hasAttribute("data-lexical-pending-upload-form-id")){let n=r.getAttribute("data-lexical-pending-upload-form-id");if(n!=null)return{node:t({data:{pending:{formID:n,src:r.getAttribute("src")||""}}})}}if(r.hasAttribute("data-lexical-upload-relation-to")&&r.hasAttribute("data-lexical-upload-id")){let n=r.getAttribute("data-lexical-upload-id"),o=r.getAttribute("data-lexical-upload-relation-to");if(n!=null&&o!=null)return{node:t({data:{fields:{},relationTo:o,value:n}})}}return{node:t({data:{pending:{formID:new ct.default().toHexString(),src:r.getAttribute("src")||""}}})}}import{DecoratorBlockNode as ut}from"@lexical/react/LexicalDecoratorBlockNode.js";import{addClassNamesToElement as mt}from"@lexical/utils";import U from"bson-objectid";import{$applyNodeReplacement as pt}from"lexical";var h=class extends ut{__data;constructor({data:t,format:e,key:n}){super(e,n),this.__data=t}static clone(t){return new this({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:e=>v(e,M),priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new U.default().toHexString(),t.version=3);let e={id:t.id,fields:t.fields,pending:t.pending,relationTo:t.relationTo,value:t.value},n=M({data:e});return n.setFormat(t.format),n}static isInline(){return!1}createDOM(t){let e=document.createElement("div");return mt(e,t?.theme?.upload),e}decorate(){return null}exportDOM(){let t=document.createElement("img"),e=this.__data;return e.pending?(t.setAttribute("data-lexical-pending-upload-form-id",String(e?.pending?.formID)),t.setAttribute("src",e?.pending?.src||"")):(t.setAttribute("data-lexical-upload-id",String(e?.value)),t.setAttribute("data-lexical-upload-relation-to",e?.relationTo)),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(t){let e=this.getWritable();e.__data=t}updateDOM(){return!1}};function M({data:r}){return r?.id||(r.id=new U.default().toHexString()),pt(new h({data:r}))}import{jsx as $}from"react/jsx-runtime";import{ShimmerEffect as dt}from"@payloadcms/ui";var k=()=>$("div",{className:"lexical-upload",children:$(dt,{height:"95px",width:"203px"})});var gt=W.lazy(()=>import("./component-UBRNPIQ6.js").then(r=>({default:r.UploadComponent}))),A=class extends h{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importDOM(){return{img:t=>({conversion:e=>v(e,J),priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new L.default().toHexString(),t.version=3);let e={id:t.id,fields:t.fields,pending:t.pending,relationTo:t.relationTo,value:t.value},n=J({data:e});return n.setFormat(t.format),n}decorate(t,e){return this.__data.pending?H(k,{}):H(gt,{className:e?.theme?.upload??"LexicalEditorTheme__upload",data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function J({data:r}){return r?.id||(r.id=new L.default().toHexString()),ft(new A({data:r}))}function te(r){return r instanceof A}export{Tt as a,Mt as b,A as c,J as d,te as e};
2
+ //# sourceMappingURL=chunk-OSMEE5HW.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/fieldsDrawer/Drawer.tsx", "../../../src/utilities/fieldsDrawer/DrawerContent.tsx", "../../../src/features/upload/client/drawer/commands.ts", "../../../src/features/upload/client/nodes/UploadNode.tsx", "../../../src/features/upload/server/nodes/conversions.ts", "../../../src/features/upload/server/nodes/UploadNode.tsx", "../../../src/features/upload/client/component/pending/index.tsx"],
4
+ "sourcesContent": ["'use client'\nimport type { ClientField, Data, FormState, JsonObject } from 'payload'\n\nimport { Drawer, EditDepthProvider, useModal } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { DrawerContent } from './DrawerContent.js'\n\nexport type FieldsDrawerProps = {\n readonly className?: string\n readonly data?: Data\n readonly drawerSlug: string\n readonly drawerTitle?: string\n readonly featureKey: string\n readonly fieldMapOverride?: ClientField[]\n readonly handleDrawerSubmit: (fields: FormState, data: JsonObject) => void\n readonly schemaFieldsPathOverride?: string\n readonly schemaPath: string\n readonly schemaPathSuffix?: string\n}\n\n/**\n * This FieldsDrawer component can be used to easily create a Drawer that contains a form with fields within your feature.\n * The fields are taken directly from the schema map based on your `featureKey` and `schemaPathSuffix`. Thus, this can only\n * be used if you provide your field schema inside the `generateSchemaMap` prop of your feature.server.ts.\n */\nexport const FieldsDrawer: React.FC<FieldsDrawerProps> = ({\n className,\n data,\n drawerSlug,\n drawerTitle,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { closeModal } = useModal()\n // The Drawer only renders its children (and itself) if it's open. Thus, by extracting the main content\n // to DrawerContent, this should be faster\n return (\n <EditDepthProvider>\n <Drawer className={className} slug={drawerSlug} title={drawerTitle ?? ''}>\n <DrawerContent\n data={data}\n featureKey={featureKey}\n fieldMapOverride={fieldMapOverride}\n handleDrawerSubmit={(args, args2) => {\n // Simply close drawer - no need for useLexicalDrawer here as at this point,\n // we don't need to restore the cursor position. This is handled by the useEffect in useLexicalDrawer.\n closeModal(drawerSlug)\n\n // Actual drawer submit logic needs to be triggered after the drawer is closed.\n // That's because the lexical selection / cursor restore logic that is striggerer by\n // `useLexicalDrawer` neeeds to be triggered before any editor.update calls that may happen\n // in the `handleDrawerSubmit` function.\n setTimeout(() => {\n handleDrawerSubmit(args, args2)\n }, 1)\n }}\n schemaFieldsPathOverride={schemaFieldsPathOverride}\n schemaPath={schemaPath}\n schemaPathSuffix={schemaPathSuffix}\n />\n </Drawer>\n </EditDepthProvider>\n )\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useEffectEvent,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n // Parent form state changes after autosave. Read its latest value when initializing without\n // reinitializing this drawer and discarding its unsaved form state after every parent update.\n const getInitialState = useEffectEvent(async (controller: AbortController) => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n })\n\n useEffect(() => {\n const controller = new AbortController()\n\n void getInitialState(controller)\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields, {\n excludeFiles: true,\n }),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? fields : []}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={!isEditable}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n", "'use client'\nimport type { LexicalCommand } from 'lexical'\n\nimport { createCommand } from 'lexical'\n\nexport const INSERT_UPLOAD_WITH_DRAWER_COMMAND: LexicalCommand<{\n replace: { nodeKey: string } | false\n}> = createCommand('INSERT_UPLOAD_WITH_DRAWER_COMMAND')\n", "'use client'\nimport type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nimport type {\n Internal_UploadData,\n SerializedUploadNode,\n UploadData,\n} from '../../server/nodes/UploadNode.js'\n\nimport { $convertUploadElement } from '../../server/nodes/conversions.js'\nimport { UploadServerNode } from '../../server/nodes/UploadNode.js'\nimport { PendingUploadComponent } from '../component/pending/index.js'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../../client/component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport class UploadNode extends UploadServerNode {\n static override clone(node: UploadServerNode): UploadServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n override decorate(editor?: LexicalEditor, config?: EditorConfig): JSX.Element {\n if ((this.__data as Internal_UploadData).pending) {\n return <PendingUploadComponent />\n }\n return (\n <RawUploadComponent\n className={config?.theme?.upload ?? 'LexicalEditorTheme__upload'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedUploadNode {\n return super.exportJSON()\n }\n}\n\nexport function $createUploadNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n\n return $applyNodeReplacement(new UploadNode({ data: data as UploadData }))\n}\n\nexport function $isUploadNode(node: LexicalNode | null | undefined): node is UploadNode {\n return node instanceof UploadNode\n}\n", "// This file contains functions used to convert dom elements to upload or pending upload lexical nodes. It requires the actual node\n// creation functions to be passed in to stay compatible with both client and server code.\nimport type { DOMConversionOutput } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\n\nimport type { $createUploadNode } from '../../client/nodes/UploadNode.js'\nimport type { $createUploadServerNode, Internal_UploadData } from './UploadNode.js'\n\nexport function isGoogleDocCheckboxImg(img: HTMLImageElement): boolean {\n return (\n img.parentElement != null &&\n img.parentElement.tagName === 'LI' &&\n img.previousSibling === null &&\n img.getAttribute('aria-roledescription') === 'checkbox'\n )\n}\n\nexport function $convertUploadElement(\n domNode: HTMLImageElement,\n $createNode: typeof $createUploadNode | typeof $createUploadServerNode,\n): DOMConversionOutput | null {\n if (domNode.hasAttribute('data-lexical-pending-upload-form-id')) {\n const formID = domNode.getAttribute('data-lexical-pending-upload-form-id')\n\n if (formID != null) {\n const node = $createNode({\n data: {\n pending: {\n formID,\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n return { node }\n }\n }\n if (\n domNode.hasAttribute('data-lexical-upload-relation-to') &&\n domNode.hasAttribute('data-lexical-upload-id')\n ) {\n const id = domNode.getAttribute('data-lexical-upload-id')\n const relationTo = domNode.getAttribute('data-lexical-upload-relation-to')\n\n if (id != null && relationTo != null) {\n const node = $createNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n\n // Create pending UploadNode. Auto-Upload functionality will then be handled by the node transform\n const node = $createNode({\n data: {\n pending: {\n formID: new ObjectID.default().toHexString(),\n src: domNode.getAttribute('src') || '',\n },\n } as Internal_UploadData,\n })\n\n return { node }\n}\n", "import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type {\n CollectionSlug,\n DataFromCollectionSlug,\n JsonObject,\n TypedUploadCollection,\n UploadCollectionSlug,\n} from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nimport { $convertUploadElement } from './conversions.js'\n\nexport type UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in CollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\n/**\n * Internal use only - UploadData type that can contain a pending state\n * @internal\n */\nexport type Internal_UploadData<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n pending?: {\n /**\n * ID that corresponds to the bulk upload form ID\n */\n formID: string\n /**\n * src value of the image dom element\n */\n src: string\n }\n} & UploadData<TUploadExtraFieldsData>\n\n/**\n * UploadDataImproved is a more precise type, and will replace UploadData in Payload v4.\n * This type is for internal use only as it will be deprecated in the future.\n * @internal\n *\n * @todo Replace UploadData with UploadDataImproved in 4.0\n */\nexport type UploadDataImproved<TUploadExtraFieldsData extends JsonObject = JsonObject> = {\n [TCollectionSlug in UploadCollectionSlug]: {\n fields: TUploadExtraFieldsData\n /**\n * Every lexical node that has sub-fields needs to have a unique ID. This is the ID of this upload node, not the ID of the linked upload document\n */\n id: string\n relationTo: TCollectionSlug\n /**\n * Value can be just the document ID, or the full, populated document\n */\n value: number | string | TypedUploadCollection[TCollectionSlug]\n }\n}[UploadCollectionSlug]\n\nexport type SerializedUploadNode = StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'upload'> &\n UploadData\n\nexport class UploadServerNode extends DecoratorBlockNode {\n __data: UploadData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: UploadData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: UploadServerNode): UploadServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'upload'\n }\n\n static override importDOM(): DOMConversionMap<HTMLImageElement> {\n return {\n img: (node) => ({\n conversion: (domNode) => $convertUploadElement(domNode, $createUploadServerNode),\n priority: 0,\n }),\n }\n }\n\n static override importJSON(serializedNode: SerializedUploadNode): UploadServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n if (serializedNode.version === 2 && !serializedNode?.id) {\n serializedNode.id = new ObjectID.default().toHexString()\n serializedNode.version = 3\n }\n\n const importedData: Internal_UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\n pending: (serializedNode as Internal_UploadData).pending,\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n\n const node = $createUploadServerNode({ data: importedData })\n node.setFormat(serializedNode.format)\n\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('div')\n addClassNamesToElement(element, config?.theme?.upload)\n return element\n }\n\n override decorate(): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n const data = this.__data as Internal_UploadData\n if (data.pending) {\n element.setAttribute('data-lexical-pending-upload-form-id', String(data?.pending?.formID))\n element.setAttribute('src', data?.pending?.src || '')\n } else {\n element.setAttribute('data-lexical-upload-id', String(data?.value))\n element.setAttribute('data-lexical-upload-relation-to', data?.relationTo)\n }\n\n return { element }\n }\n\n override exportJSON(): SerializedUploadNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'upload',\n version: 3,\n }\n }\n\n getData(): UploadData {\n return this.getLatest().__data\n }\n\n setData(data: UploadData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n\n override updateDOM(): false {\n return false\n }\n}\n\nexport function $createUploadServerNode({\n data,\n}: {\n data: Omit<UploadData, 'id'> & Partial<Pick<UploadData, 'id'>>\n}): UploadServerNode {\n if (!data?.id) {\n data.id = new ObjectID.default().toHexString()\n }\n return $applyNodeReplacement(new UploadServerNode({ data: data as UploadData }))\n}\n\nexport function $isUploadServerNode(\n node: LexicalNode | null | undefined,\n): node is UploadServerNode {\n return node instanceof UploadServerNode\n}\n", "'use client'\n\nimport { ShimmerEffect } from '@payloadcms/ui'\n\nimport '../index.scss'\n\nexport const PendingUploadComponent = (): React.ReactNode => {\n return (\n <div className={'lexical-upload'}>\n <ShimmerEffect height={'95px'} width={'203px'} />\n </div>\n )\n}\n"],
5
+ "mappings": "wCAAA,OAAAA,KAAAC,OAAA,iEAGA,OAASC,UAAAA,GAAQC,qBAAAA,GAAmBC,YAAAA,OAAgB,iBACpD,MAAkB,0DCDlB,OAASC,sBAAAA,MAA0B,oCACnC,OACEC,QAAAA,EACAC,cAAAA,EACAC,gBAAAA,EACAC,mBAAAA,EACAC,mBAAAA,EACAC,kBAAAA,EACAC,sBAAAA,EACAC,kBAAAA,MACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAASC,8CAAAA,MAAkD,iBAC3D,OAAgBC,eAAAA,GAAaC,aAAAA,EAAWC,UAAAA,GAAQC,YAAAA,OAAgB,QAChE,OAASC,MAAMC,OAAY,OAMpB,IAAMC,EAAiFA,CAAC,CAC7FC,KAAAA,EACAC,WAAAA,EACAC,iBAAAA,EACAC,mBAAAA,EACAC,yBAAAA,EACAC,WAAAA,EACAC,iBAAAA,CAAgB,IACjB,CACC,GAAM,CAAEC,EAAAA,CAAC,EAAKC,EAAA,EACR,CAAEC,GAAAA,EAAIC,eAAAA,EAAgBC,kBAAAA,EAAmBC,WAAAA,CAAU,EAAKC,EAAA,EACxD,CAAEC,OAAQC,CAAoB,EAAKC,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AAU,6BACpCX,KAAM,KAAKM,OACXJ,OAAQ,KAAKU,SACbC,QAAS,KAAKC,OAAM,GAG1B,CAESC,YAAmC,CAC1C,OAAO,MAAMA,WAAA,CACf,CACF,EAEO,SAAS5B,EAAkB,CAChCa,KAAAA,CAAI,EAGL,CACC,OAAKA,GAAMP,KACTO,EAAKP,GAAK,IAAIC,EAASnB,QAAO,EAAGoB,YAAW,GAGvCqB,GAAsB,IAAIvC,EAAW,CAAEuB,KAAMA,CAAmB,CAAA,CAAA,CACzE,CAEO,SAASiB,GAAcrC,EAAoC,CAChE,OAAOA,aAAgBH,CACzB",
6
+ "names": ["c", "_c", "Drawer", "EditDepthProvider", "useModal", "useLexicalEditable", "Form", "FormSubmit", "RenderFields", "useDocumentForm", "useDocumentInfo", "useEffectEvent", "useServerFunctions", "useTranslation", "abortAndIgnore", "deepCopyObjectSimpleWithoutReactComponents", "useCallback", "useEffect", "useRef", "useState", "v4", "uuid", "DrawerContent", "data", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "t", "useTranslation", "id", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "fields", "parentDocumentFields", "useDocumentForm", "isEditable", "useLexicalEditable", "onChangeAbortControllerRef", "useRef", "AbortController", "initialState", "setInitialState", "useState", "fieldProps", "featureClientSchemaMap", "useEditorConfigContext", "getFormState", "useServerFunctions", "schemaFieldsPath", "getInitialState", "useEffectEvent", "controller", "state", "docPermissions", "docPreferences", "documentFormState", "deepCopyObjectSimpleWithoutReactComponents", "excludeFiles", "initialBlockData", "operation", "readOnly", "renderAllFields", "signal", "useEffect", "abortAndIgnore", "onChange", "useCallback", "formState", "prevFormState", "current", "initialBlockFormState", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "Array", "isArray", "onSubmit", "uuid", "_jsx", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "permissions", "FormSubmit", "FieldsDrawer", "t0", "$", "_c", "className", "data", "drawerSlug", "drawerTitle", "featureKey", "fieldMapOverride", "handleDrawerSubmit", "schemaFieldsPathOverride", "schemaPath", "schemaPathSuffix", "closeModal", "useModal", "t1", "t2", "args", "args2", "setTimeout", "t3", "_jsx", "EditDepthProvider", "children", "Drawer", "slug", "title", "DrawerContent", "createCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "ObjectID", "$applyNodeReplacement", "React", "ObjectID", "$convertUploadElement", "domNode", "$createNode", "hasAttribute", "formID", "getAttribute", "node", "data", "pending", "src", "id", "relationTo", "fields", "value", "ObjectID", "default", "toHexString", "DecoratorBlockNode", "addClassNamesToElement", "ObjectID", "$applyNodeReplacement", "UploadServerNode", "DecoratorBlockNode", "__data", "constructor", "data", "format", "key", "clone", "node", "__format", "__key", "getType", "importDOM", "img", "conversion", "domNode", "$convertUploadElement", "$createUploadServerNode", "priority", "importJSON", "serializedNode", "version", "value", "id", "ObjectID", "default", "toHexString", "importedData", "fields", "pending", "relationTo", "setFormat", "isInline", "createDOM", "config", "element", "document", "createElement", "addClassNamesToElement", "theme", "upload", "decorate", "exportDOM", "setAttribute", "String", "formID", "src", "exportJSON", "getData", "type", "getLatest", "setData", "writable", "getWritable", "updateDOM", "$applyNodeReplacement", "ShimmerEffect", "PendingUploadComponent", "_jsx", "className", "height", "width", "RawUploadComponent", "lazy", "then", "module", "default", "UploadComponent", "UploadNode", "UploadServerNode", "clone", "node", "getType", "importDOM", "img", "conversion", "domNode", "$convertUploadElement", "$createUploadNode", "priority", "importJSON", "serializedNode", "version", "value", "id", "ObjectID", "toHexString", "importedData", "fields", "pending", "relationTo", "data", "setFormat", "format", "decorate", "editor", "config", "__data", "_jsx", "PendingUploadComponent", "className", "theme", "upload", "__format", "nodeKey", "getKey", "exportJSON", "$applyNodeReplacement", "$isUploadNode"]
7
+ }
@@ -0,0 +1,2 @@
1
+ "use client";import{a as C,b as S,e as R}from"./chunk-OSMEE5HW.js";import{a as x}from"./chunk-INBEEENE.js";import{a as N}from"./chunk-F26IQ5RE.js";import{b as m}from"./chunk-BZZVLW4U.js";import{jsx as a,jsxs as n}from"react/jsx-runtime";import{useLexicalComposerContext as Z}from"@lexical/react/LexicalComposerContext.js";import{useLexicalEditable as ee}from"@lexical/react/useLexicalEditable";import{getTranslation as y}from"@payloadcms/translations";import{Button as p,formatDrawerSlug as te,Thumbnail as ae,useConfig as oe,useEditDepth as le,usePayloadAPI as ie,useTranslation as se}from"@payloadcms/ui";import{$getNodeByKey as U}from"lexical";import{formatAdminURL as re,isImage as ne}from"payload/shared";import{useCallback as h,useId as de,useReducer as ce,useRef as ue,useState as me}from"react";var E={depth:0},ye=L=>{let{className:e,data:{fields:P,relationTo:f,value:d},format:T,nodeKey:l}=L;if(typeof d=="object")throw new Error("Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.");let{config:{routes:{api:F},serverURL:j},getEntityConfig:I}=oe(),z=ue(null),{uuid:A}=m(),B=le(),[i]=Z(),{editorConfig:k,fieldProps:{schemaPath:K}}=m(),c=ee(),{i18n:g,t:s}=se(),[_,M]=ce(r=>r+1,0),[o]=me(()=>I({collectionSlug:f})),O=de(),b=te({slug:"lexical-upload-drawer-"+A+O,depth:B}),{toggleDrawer:W}=x(b,!0),{closeDocumentDrawer:w,DocumentDrawer:H,DocumentDrawerToggler:q}=N({id:d,collectionSlug:o.slug}),[{data:t},{setParams:D}]=ie(re({apiRoute:F,path:`/${o.slug}/${d}`,serverURL:j}),{initialParams:E}),v=t?.thumbnailURL||t?.url,G=h(()=>{i.update(()=>{U(l)?.remove()})},[i,l]),J=h(r=>{D({...E,cacheBust:_}),M(),w()},[D,_,w]),$=k?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps.collections?.[o.slug]?.hasExtraFields,Q=h((r,X)=>{i.update(()=>{let u=U(l);if(R(u)){let Y={...u.getData(),fields:X};u.setData(Y)}})},[i,l]),V=v&&t?.width&&t?.height?t.width>t.height?"landscape":"portrait":"landscape";return n("div",{className:`${e}__contents ${e}__contents--${V}`,"data-align":T||void 0,"data-filename":t?.filename,ref:z,children:[n("div",{className:`${e}__card`,children:[n("div",{className:`${e}__media`,children:[a(ae,{collectionSlug:f,fileSrc:ne(t?.mimeType)?v:null,height:t?.height,size:"none",width:t?.width}),c&&a("div",{className:`${e}__overlay ${e}__floater`,children:n("div",{className:`${e}__actions`,role:"toolbar",children:[$?a(p,{buttonStyle:"icon-label",className:`${e}__upload-drawer-toggler`,disabled:!c,el:"button",icon:"edit",onClick:W,round:!0,size:"medium",tooltip:s("fields:editRelationship")}):null,a(p,{buttonStyle:"icon-label",className:`${e}__swap-drawer-toggler`,disabled:!c,el:"button",icon:"swap",onClick:()=>{i.dispatchCommand(S,{replace:{nodeKey:l}})},round:!0,size:"medium",tooltip:s("fields:swapUpload")}),a(p,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:!c,icon:"x",onClick:r=>{r.preventDefault(),G()},round:!0,size:"medium",tooltip:s("fields:removeUpload")})]})})]}),n("div",{className:`${e}__metaOverlay ${e}__floater`,children:[a(q,{className:`${e}__doc-drawer-toggler`,children:a("strong",{className:`${e}__filename`,children:t?.filename||s("general:untitled")})}),a("div",{className:`${e}__collectionLabel`,children:y(o.labels.singular,g)})]})]}),d?a(H,{onSave:J}):null,$?a(C,{data:P,drawerSlug:b,drawerTitle:s("general:editLabel",{label:y(o.labels.singular,g)}),featureKey:"upload",handleDrawerSubmit:Q,schemaPath:K,schemaPathSuffix:o.slug}):null]})};export{ye as UploadComponent};
2
+ //# sourceMappingURL=component-UBRNPIQ6.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/features/upload/client/component/index.tsx"],
4
+ "sourcesContent": ["'use client'\nimport type { ClientCollectionConfig, Data, FormState, JsonObject } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n formatDrawerSlug,\n Thumbnail,\n useConfig,\n useEditDepth,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport { $getNodeByKey, type ElementFormatType } from 'lexical'\nimport { formatAdminURL, isImage } from 'payload/shared'\nimport React, { useCallback, useId, useReducer, useRef, useState } from 'react'\n\nimport type { BaseClientFeatureProps } from '../../../typesClient.js'\nimport type { UploadData } from '../../server/nodes/UploadNode.js'\nimport type { UploadFeaturePropsClient } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isUploadNode } from '../nodes/UploadNode.js'\nimport './index.scss'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n className: string\n data: UploadData\n format?: ElementFormatType\n nodeKey: string\n}\n\nexport const UploadComponent: React.FC<ElementProps> = (props) => {\n const {\n className: baseClass,\n data: { fields, relationTo, value },\n format,\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Upload value should be a string or number. The Lexical Upload component should not receive the populated value object.',\n )\n }\n\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n const [editor] = useLexicalComposerContext()\n\n const {\n editorConfig,\n fieldProps: { schemaPath },\n } = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection] = useState<ClientCollectionConfig>(() =>\n getEntityConfig({ collectionSlug: relationTo }),\n )\n\n const componentID = useId()\n\n const extraFieldsDrawerSlug = formatDrawerSlug({\n slug: `lexical-upload-drawer-` + uuid + componentID, // There can be multiple upload components, each with their own drawer, in one single editor => separate them by componentID\n depth: editDepth,\n })\n\n // Need to use hook to initialize useEffect that restores cursor position\n const { toggleDrawer } = useLexicalDrawer(extraFieldsDrawerSlug, true)\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n formatAdminURL({ apiRoute: api, path: `/${relatedCollection.slug}/${value}`, serverURL }),\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (_data: Data) => {\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 dispatchCacheBust()\n closeDocumentDrawer()\n },\n [setParams, cacheBust, closeDocumentDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as BaseClientFeatureProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n const onExtraFieldsDrawerSubmit = useCallback(\n (_: FormState, data: JsonObject) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode = $getNodeByKey(nodeKey)\n if ($isUploadNode(uploadNode)) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n },\n [editor, nodeKey],\n )\n\n const aspectRatio =\n thumbnailSRC && data?.width && data?.height\n ? data.width > data.height\n ? 'landscape'\n : 'portrait'\n : 'landscape'\n\n return (\n <div\n className={`${baseClass}__contents ${baseClass}__contents--${aspectRatio}`}\n data-align={format || undefined}\n data-filename={data?.filename}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__media`}>\n <Thumbnail\n collectionSlug={relationTo}\n fileSrc={isImage(data?.mimeType) ? thumbnailSRC : null}\n height={data?.height}\n size=\"none\"\n width={data?.width}\n />\n\n {isEditable && (\n <div className={`${baseClass}__overlay ${baseClass}__floater`}>\n <div className={`${baseClass}__actions`} role=\"toolbar\">\n {hasExtraFields ? (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={toggleDrawer}\n round\n size=\"medium\"\n tooltip={t('fields:editRelationship')}\n />\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swap-drawer-toggler`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n size=\"medium\"\n tooltip={t('fields:swapUpload')}\n />\n\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n size=\"medium\"\n tooltip={t('fields:removeUpload')}\n />\n </div>\n </div>\n )}\n </div>\n\n <div className={`${baseClass}__metaOverlay ${baseClass}__floater`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong className={`${baseClass}__filename`}>\n {data?.filename || t('general:untitled')}\n </strong>\n </DocumentDrawerToggler>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n </div>\n </div>\n\n {value ? <DocumentDrawer onSave={updateUpload} /> : null}\n {hasExtraFields ? (\n <FieldsDrawer\n data={fields}\n drawerSlug={extraFieldsDrawerSlug}\n drawerTitle={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n featureKey=\"upload\"\n handleDrawerSubmit={onExtraFieldsDrawerSubmit}\n schemaPath={schemaPath}\n schemaPathSuffix={relatedCollection.slug}\n />\n ) : null}\n </div>\n )\n}\n"],
5
+ "mappings": "6OAGA,OAASA,6BAAAA,MAAiC,2CAC1C,OAASC,sBAAAA,OAA0B,oCACnC,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,oBAAAA,GACAC,aAAAA,GACAC,aAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,iBAAAA,MAA6C,UACtD,OAASC,kBAAAA,GAAgBC,WAAAA,OAAe,iBACxC,OAAgBC,eAAAA,EAAaC,SAAAA,GAAOC,cAAAA,GAAYC,UAAAA,GAAQC,YAAAA,OAAgB,QAcxE,IAAMC,EAAgB,CACpBC,MAAO,CACT,EASaC,GAA2CC,GAAA,CACtD,GAAM,CACJC,UAAWC,EACXC,KAAM,CAAEC,OAAAA,EAAQC,WAAAA,EAAYC,MAAAA,CAAK,EACjCC,OAAAA,EACAC,QAAAA,CAAO,EACLR,EAEJ,GAAI,OAAOM,GAAU,SACnB,MAAM,IAAIG,MACR,wHAAA,EAIJ,GAAM,CACJC,OAAQ,CACNC,OAAQ,CAAEC,IAAAA,CAAG,EACbC,UAAAA,CAAS,EAEXC,gBAAAA,CAAe,EACbC,GAAA,EACEC,EAAYC,GAA8B,IAAA,EAC1C,CAAEC,KAAAA,CAAI,EAAKC,EAAA,EACXC,EAAYC,GAAA,EACZ,CAACC,CAAA,EAAUC,EAAA,EAEX,CACJC,aAAAA,EACAC,WAAY,CAAEC,WAAAA,CAAU,CAAE,EACxBP,EAAA,EACEQ,EAAaC,GAAA,EACb,CAAEC,KAAAA,EAAMC,EAAAA,CAAC,EAAKC,GAAA,EACd,CAACC,EAAWC,CAAA,EAAqBC,GAAYC,GAAUA,EAAQ,EAAG,CAAA,EAClE,CAACC,CAAA,EAAqBC,G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,GAAA,CACRA,EAAEC,eAAc,EAChB7C,EAAA,CACF,EACAuC,MAAK,GACLR,KAAK,SACLS,QAASrE,EAAE,qBAAA,YAOrBmD,EAAC,MAAA,CAAIhF,UAAW,GAAGC,CAAA,iBAA0BA,CAAA,sBAC3CmF,EAACrC,EAAA,CAAsB/C,UAAW,GAAGC,CAAA,gCACnCmF,EAAC,SAAA,CAAOpF,UAAW,GAAGC,CAAA,sBACnBC,GAAMgF,UAAYrD,EAAE,kBAAA,MAGzBuD,EAAC,MAAA,CAAIpF,UAAW,GAAGC,CAAA,6BAChBuG,EAAerE,EAAkBsE,OAAOC,SAAU9E,CAAA,UAKxDvB,EAAQ+E,EAACtC,EAAA,CAAe6D,OAAQ5C,IAAmB,KACnDE,EACCmB,EAACwB,EAAA,CACC1G,KAAMC,EACN0G,WAAYrE,EACZsE,YAAajF,EAAE,oBAAqB,CAClCkF,MAAOP,EAAerE,EAAkBsE,OAAOC,SAAU9E,CAAA,CAC3D,CAAA,EACAoF,WAAW,SACXC,mBAAoB3C,EACpB7C,WAAYA,EACZyF,iBAAkB/E,EAAkBO,OAEpC,IAAA,GAGV",
6
+ "names": ["useLexicalComposerContext", "useLexicalEditable", "getTranslation", "Button", "formatDrawerSlug", "Thumbnail", "useConfig", "useEditDepth", "usePayloadAPI", "useTranslation", "$getNodeByKey", "formatAdminURL", "isImage", "useCallback", "useId", "useReducer", "useRef", "useState", "initialParams", "depth", "UploadComponent", "props", "className", "baseClass", "data", "fields", "relationTo", "value", "format", "nodeKey", "Error", "config", "routes", "api", "serverURL", "getEntityConfig", "useConfig", "uploadRef", "useRef", "uuid", "useEditorConfigContext", "editDepth", "useEditDepth", "editor", "useLexicalComposerContext", "editorConfig", "fieldProps", "schemaPath", "isEditable", "useLexicalEditable", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "relatedCollection", "useState", "collectionSlug", "componentID", "useId", "extraFieldsDrawerSlug", "formatDrawerSlug", "slug", "toggleDrawer", "useLexicalDrawer", "closeDocumentDrawer", "DocumentDrawer", "DocumentDrawerToggler", "useLexicalDocumentDrawer", "id", "setParams", "usePayloadAPI", "formatAdminURL", "apiRoute", "path", "thumbnailSRC", "thumbnailURL", "url", "removeUpload", "useCallback", "update", "$getNodeByKey", "remove", "updateUpload", "_data", "hasExtraFields", "resolvedFeatureMap", "get", "sanitizedClientFeatureProps", "collections", "onExtraFieldsDrawerSubmit", "_", "uploadNode", "$isUploadNode", "newData", "getData", "setData", "aspectRatio", "width", "height", "_jsxs", "undefined", "filename", "ref", "_jsx", "Thumbnail", "fileSrc", "isImage", "mimeType", "size", "role", "Button", "buttonStyle", "disabled", "el", "icon", "onClick", "round", "tooltip", "dispatchCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "replace", "e", "preventDefault", "getTranslation", "labels", "singular", "onSave", "FieldsDrawer", "drawerSlug", "drawerTitle", "label", "featureKey", "handleDrawerSubmit", "schemaPathSuffix"]
7
+ }