@payloadcms/richtext-lexical 3.0.0-beta.55 → 3.0.0-beta.56

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 (88) hide show
  1. package/dist/exports/client/bundled.css +1 -1
  2. package/dist/exports/client/chunk-OAQL5GDK.js +2 -0
  3. package/dist/exports/client/chunk-OAQL5GDK.js.map +7 -0
  4. package/dist/exports/client/component-V5QZ7EVZ.js +2 -0
  5. package/dist/exports/client/component-V5QZ7EVZ.js.map +7 -0
  6. package/dist/exports/client/{component-PEFMKIXI.js → component-YNZTTMBY.js} +2 -2
  7. package/dist/exports/client/component-YNZTTMBY.js.map +7 -0
  8. package/dist/exports/client/index.d.ts +1 -0
  9. package/dist/exports/client/index.d.ts.map +1 -1
  10. package/dist/exports/client/index.js +7 -7
  11. package/dist/exports/client/index.js.map +4 -4
  12. package/dist/features/blocks/component/index.js +1 -1
  13. package/dist/features/blocks/component/index.js.map +1 -1
  14. package/dist/features/blocks/feature.server.d.ts.map +1 -1
  15. package/dist/features/blocks/feature.server.js +1 -11
  16. package/dist/features/blocks/feature.server.js.map +1 -1
  17. package/dist/features/heading/feature.server.d.ts +5 -1
  18. package/dist/features/heading/feature.server.d.ts.map +1 -1
  19. package/dist/features/heading/feature.server.js.map +1 -1
  20. package/dist/features/link/feature.server.d.ts.map +1 -1
  21. package/dist/features/link/feature.server.js +1 -11
  22. package/dist/features/link/feature.server.js.map +1 -1
  23. package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
  24. package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +9 -5
  25. package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
  26. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.d.ts.map +1 -1
  27. package/dist/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.js.map +1 -1
  28. package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.d.ts.map +1 -1
  29. package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
  30. package/dist/features/upload/component/index.d.ts.map +1 -1
  31. package/dist/features/upload/component/index.js +34 -11
  32. package/dist/features/upload/component/index.js.map +1 -1
  33. package/dist/features/upload/feature.server.d.ts.map +1 -1
  34. package/dist/features/upload/feature.server.js +1 -11
  35. package/dist/features/upload/feature.server.js.map +1 -1
  36. package/dist/field/index.js +8 -8
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/nodeTypes.d.ts +11 -7
  42. package/dist/nodeTypes.d.ts.map +1 -1
  43. package/dist/nodeTypes.js.map +1 -1
  44. package/dist/utilities/fieldsDrawer/Drawer.d.ts +18 -0
  45. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -0
  46. package/dist/utilities/fieldsDrawer/Drawer.js +26 -0
  47. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -0
  48. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -0
  49. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -0
  50. package/dist/{features/link/drawer/index.js → utilities/fieldsDrawer/DrawerContent.js} +38 -40
  51. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -0
  52. package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
  53. package/dist/utilities/generateSchemaMap.js +9 -0
  54. package/dist/utilities/generateSchemaMap.js.map +1 -1
  55. package/dist/utilities/migrateSlateToLexical/index.js +2 -2
  56. package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
  57. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +9 -0
  58. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -0
  59. package/dist/utilities/migrateSlateToLexical/{recurse.js → migrateDocumentFieldsRecursively.js} +7 -7
  60. package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -0
  61. package/dist/utilities/upgradeLexicalData/index.d.ts +11 -0
  62. package/dist/utilities/upgradeLexicalData/index.d.ts.map +1 -0
  63. package/dist/utilities/upgradeLexicalData/index.js +101 -0
  64. package/dist/utilities/upgradeLexicalData/index.js.map +1 -0
  65. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +9 -0
  66. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -0
  67. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +74 -0
  68. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -0
  69. package/package.json +9 -9
  70. package/dist/exports/client/chunk-5RJS5YZT.js +0 -2
  71. package/dist/exports/client/chunk-5RJS5YZT.js.map +0 -7
  72. package/dist/exports/client/component-F6V63OLD.js +0 -2
  73. package/dist/exports/client/component-F6V63OLD.js.map +0 -7
  74. package/dist/exports/client/component-PEFMKIXI.js.map +0 -7
  75. package/dist/features/link/drawer/index.d.ts +0 -5
  76. package/dist/features/link/drawer/index.d.ts.map +0 -1
  77. package/dist/features/link/drawer/index.js.map +0 -1
  78. package/dist/features/link/drawer/types.d.ts +0 -10
  79. package/dist/features/link/drawer/types.d.ts.map +0 -1
  80. package/dist/features/link/drawer/types.js +0 -3
  81. package/dist/features/link/drawer/types.js.map +0 -1
  82. package/dist/features/upload/component/ExtraFieldsDrawer/index.d.ts +0 -12
  83. package/dist/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +0 -1
  84. package/dist/features/upload/component/ExtraFieldsDrawer/index.js +0 -123
  85. package/dist/features/upload/component/ExtraFieldsDrawer/index.js.map +0 -1
  86. package/dist/utilities/migrateSlateToLexical/recurse.d.ts +0 -9
  87. package/dist/utilities/migrateSlateToLexical/recurse.d.ts.map +0 -1
  88. package/dist/utilities/migrateSlateToLexical/recurse.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { traverseFields } from '@payloadcms/ui/utilities/buildFieldSchemaMap/traverseFields';
1
2
  export const getGenerateSchemaMap = (args)=>({ config, i18n, schemaMap, schemaPath })=>{
2
3
  for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()){
3
4
  if (!('generateSchemaMap' in resolvedFeature) || typeof resolvedFeature.generateSchemaMap !== 'function') {
@@ -12,6 +13,14 @@ export const getGenerateSchemaMap = (args)=>({ config, i18n, schemaMap, schemaPa
12
13
  });
13
14
  if (schemas) {
14
15
  for (const [schemaKey, fields] of schemas.entries()){
16
+ // generate schema map entries for sub-fields using traverseFields
17
+ traverseFields({
18
+ config,
19
+ fields,
20
+ i18n,
21
+ schemaMap: schemas,
22
+ schemaPath: schemaKey
23
+ });
15
24
  schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, fields);
16
25
  }
17
26
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/generateSchemaMap.ts"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\n\nexport const getGenerateSchemaMap =\n (args: { resolvedFeatureMap: ResolvedServerFeatureMap }): RichTextAdapter['generateSchemaMap'] =>\n ({ config, i18n, schemaMap, schemaPath }) => {\n for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()) {\n if (\n !('generateSchemaMap' in resolvedFeature) ||\n typeof resolvedFeature.generateSchemaMap !== 'function'\n ) {\n continue\n }\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n i18n,\n props: resolvedFeature.sanitizedServerFeatureProps,\n schemaMap,\n schemaPath,\n })\n\n if (schemas) {\n for (const [schemaKey, fields] of schemas.entries()) {\n schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, fields)\n }\n }\n }\n\n return schemaMap\n }\n"],"names":["getGenerateSchemaMap","args","config","i18n","schemaMap","schemaPath","featureKey","resolvedFeature","resolvedFeatureMap","entries","generateSchemaMap","schemas","props","sanitizedServerFeatureProps","schemaKey","fields","set"],"mappings":"AAIA,OAAO,MAAMA,uBACX,CAACC,OACD,CAAC,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE;QACtC,KAAK,MAAM,CAACC,YAAYC,gBAAgB,IAAIN,KAAKO,kBAAkB,CAACC,OAAO,GAAI;YAC7E,IACE,CAAE,CAAA,uBAAuBF,eAAc,KACvC,OAAOA,gBAAgBG,iBAAiB,KAAK,YAC7C;gBACA;YACF;YACA,MAAMC,UAAUJ,gBAAgBG,iBAAiB,CAAC;gBAChDR;gBACAC;gBACAS,OAAOL,gBAAgBM,2BAA2B;gBAClDT;gBACAC;YACF;YAEA,IAAIM,SAAS;gBACX,KAAK,MAAM,CAACG,WAAWC,OAAO,IAAIJ,QAAQF,OAAO,GAAI;oBACnDL,UAAUY,GAAG,CAAC,CAAC,EAAEX,WAAW,SAAS,EAAEC,WAAW,CAAC,EAAEQ,UAAU,CAAC,EAAEC;gBACpE;YACF;QACF;QAEA,OAAOX;IACT,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/generateSchemaMap.ts"],"sourcesContent":["import type { RichTextAdapter } from 'payload'\n\nimport { traverseFields } from '@payloadcms/ui/utilities/buildFieldSchemaMap/traverseFields'\n\nimport type { ResolvedServerFeatureMap } from '../features/typesServer.js'\n\nexport const getGenerateSchemaMap =\n (args: { resolvedFeatureMap: ResolvedServerFeatureMap }): RichTextAdapter['generateSchemaMap'] =>\n ({ config, i18n, schemaMap, schemaPath }) => {\n for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()) {\n if (\n !('generateSchemaMap' in resolvedFeature) ||\n typeof resolvedFeature.generateSchemaMap !== 'function'\n ) {\n continue\n }\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n i18n,\n props: resolvedFeature.sanitizedServerFeatureProps,\n schemaMap,\n schemaPath,\n })\n\n if (schemas) {\n for (const [schemaKey, fields] of schemas.entries()) {\n // generate schema map entries for sub-fields using traverseFields\n traverseFields({\n config,\n fields,\n i18n,\n schemaMap: schemas,\n schemaPath: schemaKey,\n })\n\n schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, fields)\n }\n }\n }\n\n return schemaMap\n }\n"],"names":["traverseFields","getGenerateSchemaMap","args","config","i18n","schemaMap","schemaPath","featureKey","resolvedFeature","resolvedFeatureMap","entries","generateSchemaMap","schemas","props","sanitizedServerFeatureProps","schemaKey","fields","set"],"mappings":"AAEA,SAASA,cAAc,QAAQ,8DAA6D;AAI5F,OAAO,MAAMC,uBACX,CAACC,OACD,CAAC,EAAEC,MAAM,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAE;QACtC,KAAK,MAAM,CAACC,YAAYC,gBAAgB,IAAIN,KAAKO,kBAAkB,CAACC,OAAO,GAAI;YAC7E,IACE,CAAE,CAAA,uBAAuBF,eAAc,KACvC,OAAOA,gBAAgBG,iBAAiB,KAAK,YAC7C;gBACA;YACF;YACA,MAAMC,UAAUJ,gBAAgBG,iBAAiB,CAAC;gBAChDR;gBACAC;gBACAS,OAAOL,gBAAgBM,2BAA2B;gBAClDT;gBACAC;YACF;YAEA,IAAIM,SAAS;gBACX,KAAK,MAAM,CAACG,WAAWC,OAAO,IAAIJ,QAAQF,OAAO,GAAI;oBACnD,kEAAkE;oBAClEV,eAAe;wBACbG;wBACAa;wBACAZ;wBACAC,WAAWO;wBACXN,YAAYS;oBACd;oBAEAV,UAAUY,GAAG,CAAC,CAAC,EAAEX,WAAW,SAAS,EAAEC,WAAW,CAAC,EAAEQ,UAAU,CAAC,EAAEC;gBACpE;YACF;QACF;QAEA,OAAOX;IACT,EAAC"}
@@ -1,4 +1,4 @@
1
- import { migrateDocumentFields } from './recurse.js';
1
+ import { migrateDocumentFieldsRecursively } from './migrateDocumentFieldsRecursively.js';
2
2
  /**
3
3
  * This goes through every single collection and field in the payload config, and migrates its data from Slate to Lexical. This does not support sub-fields within slate.
4
4
  *
@@ -95,7 +95,7 @@ async function migrateCollection({ collection, cur, locale, max, payload }) {
95
95
  }
96
96
  }
97
97
  function migrateDocument({ document, fields }) {
98
- return !!migrateDocumentFields({
98
+ return !!migrateDocumentFieldsRecursively({
99
99
  data: document,
100
100
  fields,
101
101
  found: 0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utilities/migrateSlateToLexical/index.ts"],"sourcesContent":["import type { CollectionConfig, Field, GlobalConfig, Payload } from 'payload'\n\nimport { migrateDocumentFields } from './recurse.js'\n\n/**\n * This goes through every single collection and field in the payload config, and migrates its data from Slate to Lexical. This does not support sub-fields within slate.\n *\n * It will only translate fields fulfilling all these requirements:\n * - field schema uses lexical editor\n * - lexical editor has SlateToLexicalFeature added\n * - saved field data is in Slate format\n *\n * @param payload\n */\nexport async function migrateSlateToLexical({ payload }: { payload: Payload }) {\n const collections = payload.config.collections\n\n const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null]\n\n const totalCollections = collections.length\n for (const locale of allLocales) {\n let curCollection = 0\n for (const collection of collections) {\n curCollection++\n await migrateCollection({\n collection,\n cur: curCollection,\n locale,\n max: totalCollections,\n payload,\n })\n }\n for (const global of payload.config.globals) {\n await migrateGlobal({\n global,\n locale,\n payload,\n })\n }\n }\n}\n\nasync function migrateGlobal({\n global,\n locale,\n payload,\n}: {\n global: GlobalConfig\n locale: null | string\n payload: Payload\n}) {\n console.log(`SlateToLexical: ${locale}: Migrating global:`, global.slug)\n\n const document = await payload.findGlobal({\n slug: global.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n\n const found = migrateDocument({\n document,\n fields: global.fields,\n })\n\n if (found) {\n await payload.updateGlobal({\n slug: global.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n}\n\nasync function migrateCollection({\n collection,\n cur,\n locale,\n max,\n payload,\n}: {\n collection: CollectionConfig\n cur: number\n locale: null | string\n max: number\n payload: Payload\n}) {\n console.log(\n `SlateToLexical: ${locale}: Migrating collection:`,\n collection.slug,\n '(' + cur + '/' + max + ')',\n )\n\n const documentCount = (\n await payload.count({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n })\n ).totalDocs\n\n let page = 1\n let migrated = 0\n\n while (migrated < documentCount) {\n const documents = await payload.find({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n page,\n pagination: true,\n })\n\n for (const document of documents.docs) {\n migrated++\n console.log(\n `SlateToLexical: ${locale}: Migrating collection:`,\n collection.slug,\n '(' +\n cur +\n '/' +\n max +\n ') - Migrating Document: ' +\n document.id +\n ' (' +\n migrated +\n '/' +\n documentCount +\n ')',\n )\n const found = migrateDocument({\n document,\n fields: collection.fields,\n })\n\n if (found) {\n await payload.update({\n id: document.id,\n collection: collection.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n }\n page++\n }\n}\n\nfunction migrateDocument({\n document,\n fields,\n}: {\n document: Record<string, unknown>\n fields: Field[]\n}): boolean {\n return !!migrateDocumentFields({\n data: document,\n fields,\n found: 0,\n })\n}\n"],"names":["migrateDocumentFields","migrateSlateToLexical","payload","collections","config","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","migrateCollection","cur","max","global","globals","migrateGlobal","console","log","slug","document","findGlobal","depth","undefined","overrideAccess","found","migrateDocument","fields","updateGlobal","data","documentCount","count","totalDocs","page","migrated","documents","find","pagination","docs","id","update"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,eAAc;AAEpD;;;;;;;;;CASC,GACD,OAAO,eAAeC,sBAAsB,EAAEC,OAAO,EAAwB;IAC3E,MAAMC,cAAcD,QAAQE,MAAM,CAACD,WAAW;IAE9C,MAAME,aAAaH,QAAQE,MAAM,CAACE,YAAY,GAAGJ,QAAQE,MAAM,CAACE,YAAY,CAACC,WAAW,GAAG;QAAC;KAAK;IAEjG,MAAMC,mBAAmBL,YAAYM,MAAM;IAC3C,KAAK,MAAMC,UAAUL,WAAY;QAC/B,IAAIM,gBAAgB;QACpB,KAAK,MAAMC,cAAcT,YAAa;YACpCQ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QA,UAAUe;YAClBC,gBAAgB;YAChBS;YACAI,YAAY;QACd;QAEA,KAAK,MAAMjB,YAAYe,UAAUG,IAAI,CAAE;YACrCJ;YACAjB,QAAQC,GAAG,CACT,CAAC,gBAAgB,EAAEV,OAAO,uBAAuB,CAAC,EAClDE,WAAWS,IAAI,EACf,MACEP,MACA,MACAC,MACA,6BACAO,SAASmB,EAAE,GACX,OACAL,WACA,MACAJ,gBACA;YAEJ,MAAML,QAAQC,gBAAgB;gBAC5BN;gBACAO,QAAQjB,WAAWiB,MAAM;YAC3B;YAEA,IAAIF,OAAO;gBACT,MAAMzB,QAAQwC,MAAM,CAAC;oBACnBD,IAAInB,SAASmB,EAAE;oBACf7B,YAAYA,WAAWS,IAAI;oBAC3BU,MAAMT;oBACNE,OAAO;oBACPd,QAAQA,UAAUe;gBACpB;YACF;QACF;QACAU;IACF;AACF;AAEA,SAASP,gBAAgB,EACvBN,QAAQ,EACRO,MAAM,EAIP;IACC,OAAO,CAAC,CAAC7B,sBAAsB;QAC7B+B,MAAMT;QACNO;QACAF,OAAO;IACT;AACF"}
1
+ {"version":3,"sources":["../../../src/utilities/migrateSlateToLexical/index.ts"],"sourcesContent":["import type { CollectionConfig, Field, GlobalConfig, Payload } from 'payload'\n\nimport { migrateDocumentFieldsRecursively } from './migrateDocumentFieldsRecursively.js'\n\n/**\n * This goes through every single collection and field in the payload config, and migrates its data from Slate to Lexical. This does not support sub-fields within slate.\n *\n * It will only translate fields fulfilling all these requirements:\n * - field schema uses lexical editor\n * - lexical editor has SlateToLexicalFeature added\n * - saved field data is in Slate format\n *\n * @param payload\n */\nexport async function migrateSlateToLexical({ payload }: { payload: Payload }) {\n const collections = payload.config.collections\n\n const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null]\n\n const totalCollections = collections.length\n for (const locale of allLocales) {\n let curCollection = 0\n for (const collection of collections) {\n curCollection++\n await migrateCollection({\n collection,\n cur: curCollection,\n locale,\n max: totalCollections,\n payload,\n })\n }\n for (const global of payload.config.globals) {\n await migrateGlobal({\n global,\n locale,\n payload,\n })\n }\n }\n}\n\nasync function migrateGlobal({\n global,\n locale,\n payload,\n}: {\n global: GlobalConfig\n locale: null | string\n payload: Payload\n}) {\n console.log(`SlateToLexical: ${locale}: Migrating global:`, global.slug)\n\n const document = await payload.findGlobal({\n slug: global.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n\n const found = migrateDocument({\n document,\n fields: global.fields,\n })\n\n if (found) {\n await payload.updateGlobal({\n slug: global.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n}\n\nasync function migrateCollection({\n collection,\n cur,\n locale,\n max,\n payload,\n}: {\n collection: CollectionConfig\n cur: number\n locale: null | string\n max: number\n payload: Payload\n}) {\n console.log(\n `SlateToLexical: ${locale}: Migrating collection:`,\n collection.slug,\n '(' + cur + '/' + max + ')',\n )\n\n const documentCount = (\n await payload.count({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n })\n ).totalDocs\n\n let page = 1\n let migrated = 0\n\n while (migrated < documentCount) {\n const documents = await payload.find({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n page,\n pagination: true,\n })\n\n for (const document of documents.docs) {\n migrated++\n console.log(\n `SlateToLexical: ${locale}: Migrating collection:`,\n collection.slug,\n '(' +\n cur +\n '/' +\n max +\n ') - Migrating Document: ' +\n document.id +\n ' (' +\n migrated +\n '/' +\n documentCount +\n ')',\n )\n const found = migrateDocument({\n document,\n fields: collection.fields,\n })\n\n if (found) {\n await payload.update({\n id: document.id,\n collection: collection.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n }\n page++\n }\n}\n\nfunction migrateDocument({\n document,\n fields,\n}: {\n document: Record<string, unknown>\n fields: Field[]\n}): boolean {\n return !!migrateDocumentFieldsRecursively({\n data: document,\n fields,\n found: 0,\n })\n}\n"],"names":["migrateDocumentFieldsRecursively","migrateSlateToLexical","payload","collections","config","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","migrateCollection","cur","max","global","globals","migrateGlobal","console","log","slug","document","findGlobal","depth","undefined","overrideAccess","found","migrateDocument","fields","updateGlobal","data","documentCount","count","totalDocs","page","migrated","documents","find","pagination","docs","id","update"],"mappings":"AAEA,SAASA,gCAAgC,QAAQ,wCAAuC;AAExF;;;;;;;;;CASC,GACD,OAAO,eAAeC,sBAAsB,EAAEC,OAAO,EAAwB;IAC3E,MAAMC,cAAcD,QAAQE,MAAM,CAACD,WAAW;IAE9C,MAAME,aAAaH,QAAQE,MAAM,CAACE,YAAY,GAAGJ,QAAQE,MAAM,CAACE,YAAY,CAACC,WAAW,GAAG;QAAC;KAAK;IAEjG,MAAMC,mBAAmBL,YAAYM,MAAM;IAC3C,KAAK,MAAMC,UAAUL,WAAY;QAC/B,IAAIM,gBAAgB;QACpB,KAAK,MAAMC,cAAcT,YAAa;YACpCQ;YACA,MAAME,kBAAkB;gBACtBD;gBACAE,KAAKH;gBACLD;gBACAK,KAAKP;gBACLN;YACF;QACF;QACA,KAAK,MAAMc,UAAUd,QAAQE,MAAM,CAACa,OAAO,CAAE;YAC3C,MAAMC,cAAc;gBAClBF;gBACAN;gBACAR;YACF;QACF;IACF;AACF;AAEA,eAAegB,cAAc,EAC3BF,MAAM,EACNN,MAAM,EACNR,OAAO,EAKR;IACCiB,QAAQC,GAAG,CAAC,CAAC,gBAAgB,EAAEV,OAAO,mBAAmB,CAAC,EAAEM,OAAOK,IAAI;IAEvE,MAAMC,WAAW,MAAMpB,QAAQqB,UAAU,CAAC;QACxCF,MAAML,OAAOK,IAAI;QACjBG,OAAO;QACPd,QAAQA,UAAUe;QAClBC,gBAAgB;IAClB;IAEA,MAAMC,QAAQC,gBAAgB;QAC5BN;QACAO,QAAQb,OAAOa,MAAM;IACvB;IAEA,IAAIF,OAAO;QACT,MAAMzB,QAAQ4B,YAAY,CAAC;YACzBT,MAAML,OAAOK,IAAI;YACjBU,MAAMT;YACNE,OAAO;YACPd,QAA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
@@ -0,0 +1,9 @@
1
+ import type { Field } from 'payload';
2
+ type NestedRichTextFieldsArgs = {
3
+ data: unknown;
4
+ fields: Field[];
5
+ found: number;
6
+ };
7
+ export declare const migrateDocumentFieldsRecursively: ({ data, fields, found, }: NestedRichTextFieldsArgs) => number;
8
+ export {};
9
+ //# sourceMappingURL=migrateDocumentFieldsRecursively.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrateDocumentFieldsRecursively.d.ts","sourceRoot":"","sources":["../../../src/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAYpC,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAA;IAEb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gCAAgC,6BAI1C,wBAAwB,KAAG,MAwF7B,CAAA"}
@@ -1,16 +1,16 @@
1
1
  import { fieldAffectsData, fieldHasSubFields, fieldIsArrayType } from 'payload/shared';
2
2
  import { convertSlateToLexical } from '../../features/migrations/slateToLexical/converter/index.js';
3
- export const migrateDocumentFields = ({ data, fields, found })=>{
3
+ export const migrateDocumentFieldsRecursively = ({ data, fields, found })=>{
4
4
  for (const field of fields){
5
5
  if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {
6
6
  if (fieldAffectsData(field) && typeof data[field.name] === 'object') {
7
- migrateDocumentFields({
7
+ migrateDocumentFieldsRecursively({
8
8
  data: data[field.name],
9
9
  fields: field.fields,
10
10
  found
11
11
  });
12
12
  } else {
13
- migrateDocumentFields({
13
+ migrateDocumentFieldsRecursively({
14
14
  data,
15
15
  found,
16
16
  fields: field.fields
@@ -18,7 +18,7 @@ export const migrateDocumentFields = ({ data, fields, found })=>{
18
18
  }
19
19
  } else if (field.type === 'tabs') {
20
20
  field.tabs.forEach((tab)=>{
21
- migrateDocumentFields({
21
+ migrateDocumentFieldsRecursively({
22
22
  data,
23
23
  found,
24
24
  fields: tab.fields
@@ -29,7 +29,7 @@ export const migrateDocumentFields = ({ data, fields, found })=>{
29
29
  data[field.name].forEach((row, i)=>{
30
30
  const block = field.blocks.find(({ slug })=>slug === row?.blockType);
31
31
  if (block) {
32
- migrateDocumentFields({
32
+ migrateDocumentFieldsRecursively({
33
33
  data: data[field.name][i],
34
34
  found,
35
35
  fields: block.fields
@@ -39,7 +39,7 @@ export const migrateDocumentFields = ({ data, fields, found })=>{
39
39
  }
40
40
  if (field.type === 'array') {
41
41
  data[field.name].forEach((_, i)=>{
42
- migrateDocumentFields({
42
+ migrateDocumentFieldsRecursively({
43
43
  data: data[field.name][i],
44
44
  found,
45
45
  fields: field.fields
@@ -74,4 +74,4 @@ export const migrateDocumentFields = ({ data, fields, found })=>{
74
74
  return found;
75
75
  };
76
76
 
77
- //# sourceMappingURL=recurse.js.map
77
+ //# sourceMappingURL=migrateDocumentFieldsRecursively.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport { fieldAffectsData, fieldHasSubFields, fieldIsArrayType } from 'payload/shared'\n\nimport type {\n SlateNodeConverter,\n SlateNodeConverterProvider,\n} from '../../features/migrations/slateToLexical/converter/types.js'\nimport type { LexicalRichTextAdapter } from '../../types.js'\n\nimport { convertSlateToLexical } from '../../features/migrations/slateToLexical/converter/index.js'\n\ntype NestedRichTextFieldsArgs = {\n data: unknown\n\n fields: Field[]\n found: number\n}\n\nexport const migrateDocumentFieldsRecursively = ({\n data,\n fields,\n found,\n}: NestedRichTextFieldsArgs): number => {\n for (const field of fields) {\n if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {\n if (fieldAffectsData(field) && typeof data[field.name] === 'object') {\n migrateDocumentFieldsRecursively({\n data: data[field.name],\n fields: field.fields,\n found,\n })\n } else {\n migrateDocumentFieldsRecursively({\n data,\n found,\n\n fields: field.fields,\n })\n }\n } else if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n migrateDocumentFieldsRecursively({\n data,\n found,\n\n fields: tab.fields,\n })\n })\n } else if (Array.isArray(data[field.name])) {\n if (field.type === 'blocks') {\n data[field.name].forEach((row, i) => {\n const block = field.blocks.find(({ slug }) => slug === row?.blockType)\n if (block) {\n migrateDocumentFieldsRecursively({\n data: data[field.name][i],\n found,\n\n fields: block.fields,\n })\n }\n })\n }\n\n if (field.type === 'array') {\n data[field.name].forEach((_, i) => {\n migrateDocumentFieldsRecursively({\n data: data[field.name][i],\n found,\n\n fields: field.fields,\n })\n })\n }\n }\n\n if (field.type === 'richText' && Array.isArray(data[field.name])) {\n // Slate richText\n const editor: LexicalRichTextAdapter = field.editor as LexicalRichTextAdapter\n if (editor && typeof editor === 'object') {\n if ('features' in editor && editor.features?.length) {\n // find slatetolexical feature\n const slateToLexicalFeature = editor.editorConfig.resolvedFeatureMap.get('slateToLexical')\n if (slateToLexicalFeature) {\n // DO CONVERSION\n\n const converterProviders = (\n slateToLexicalFeature.sanitizedServerFeatureProps as {\n converters?: SlateNodeConverterProvider[]\n }\n ).converters\n\n const converters: SlateNodeConverter[] = []\n\n for (const converter of converterProviders) {\n converters.push(converter.converter)\n }\n\n data[field.name] = convertSlateToLexical({\n converters,\n slateData: data[field.name],\n })\n\n found++\n }\n }\n }\n }\n }\n\n return found\n}\n"],"names":["fieldAffectsData","fieldHasSubFields","fieldIsArrayType","convertSlateToLexical","migrateDocumentFieldsRecursively","data","fields","found","field","name","type","tabs","forEach","tab","Array","isArray","row","i","block","blocks","find","slug","blockType","_","editor","features","length","slateToLexicalFeature","editorConfig","resolvedFeatureMap","get","converterProviders","sanitizedServerFeatureProps","converters","converter","push","slateData"],"mappings":"AAEA,SAASA,gBAAgB,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,iBAAgB;AAQtF,SAASC,qBAAqB,QAAQ,8DAA6D;A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AE;wBACzBV;wBAEAD,QAAQE,MAAMF,MAAM;oBACtB;gBACF;YACF;QACF;QAEA,IAAIE,MAAME,IAAI,KAAK,cAAcI,MAAMC,OAAO,CAACV,IAAI,CAACG,MAAMC,IAAI,CAAC,GAAG;YAChE,iBAAiB;YACjB,MAAMe,SAAiChB,MAAMgB,MAAM;YACnD,IAAIA,UAAU,OAAOA,WAAW,UAAU;gBACxC,IAAI,cAAcA,UAAUA,OAAOC,QAAQ,EAAEC,QAAQ;oBACnD,8BAA8B;oBAC9B,MAAMC,wBAAwBH,OAAOI,YAAY,CAACC,kBAAkB,CAACC,GAAG,CAAC;oBACzE,IAAIH,uBAAuB;wBACzB,gBAAgB;wBAEhB,MAAMI,qBAAqB,AACzBJ,sBAAsBK,2BAA2B,CAGjDC,UAAU;wBAEZ,MAAMA,aAAmC,EAAE;wBAE3C,KAAK,MAAMC,aAAaH,mBAAoB;4BAC1CE,WAAWE,IAAI,CAACD,UAAUA,SAAS;wBACrC;wBAEA7B,IAAI,CAACG,MAAMC,IAAI,CAAC,GAAGN,sBAAsB;4BACvC8B;4BACAG,WAAW/B,IAAI,CAACG,MAAMC,IAAI,CAAC;wBAC7B;wBAEAF;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOA;AACT,EAAC"}
@@ -0,0 +1,11 @@
1
+ import type { Payload } from 'payload';
2
+ /**
3
+ * This goes through every single document in your payload app and re-saves it, if it has a lexical editor.
4
+ * This way, the data is automatically converted to the new format, and that automatic conversion gets applied to every single document in your app.
5
+ *
6
+ * @param payload
7
+ */
8
+ export declare function upgradeLexicalData({ payload }: {
9
+ payload: Payload;
10
+ }): Promise<void>;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utilities/upgradeLexicalData/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyC,OAAO,EAAE,MAAM,SAAS,CAAA;AAI7E;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,iBA0BzE"}
@@ -0,0 +1,101 @@
1
+ import { upgradeDocumentFieldsRecursively } from './upgradeDocumentFieldsRecursively.js';
2
+ /**
3
+ * This goes through every single document in your payload app and re-saves it, if it has a lexical editor.
4
+ * This way, the data is automatically converted to the new format, and that automatic conversion gets applied to every single document in your app.
5
+ *
6
+ * @param payload
7
+ */ export async function upgradeLexicalData({ payload }) {
8
+ const collections = payload.config.collections;
9
+ const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [
10
+ null
11
+ ];
12
+ const totalCollections = collections.length;
13
+ for (const locale of allLocales){
14
+ let curCollection = 0;
15
+ for (const collection of collections){
16
+ curCollection++;
17
+ await upgradeCollection({
18
+ collection,
19
+ cur: curCollection,
20
+ locale,
21
+ max: totalCollections,
22
+ payload
23
+ });
24
+ }
25
+ for (const global of payload.config.globals){
26
+ await upgradeGlobal({
27
+ global,
28
+ locale,
29
+ payload
30
+ });
31
+ }
32
+ }
33
+ }
34
+ async function upgradeGlobal({ global, locale, payload }) {
35
+ console.log(`Lexical Upgrader: ${locale}: Upgrading global:`, global.slug);
36
+ const document = await payload.findGlobal({
37
+ slug: global.slug,
38
+ depth: 0,
39
+ locale: locale || undefined,
40
+ overrideAccess: true
41
+ });
42
+ const found = upgradeDocument({
43
+ document,
44
+ fields: global.fields
45
+ });
46
+ if (found) {
47
+ await payload.updateGlobal({
48
+ slug: global.slug,
49
+ data: document,
50
+ depth: 0,
51
+ locale: locale || undefined
52
+ });
53
+ }
54
+ }
55
+ async function upgradeCollection({ collection, cur, locale, max, payload }) {
56
+ console.log(`Lexical Upgrade: ${locale}: Upgrading collection:`, collection.slug, '(' + cur + '/' + max + ')');
57
+ const documentCount = (await payload.count({
58
+ collection: collection.slug,
59
+ depth: 0,
60
+ locale: locale || undefined
61
+ })).totalDocs;
62
+ let page = 1;
63
+ let upgraded = 0;
64
+ while(upgraded < documentCount){
65
+ const documents = await payload.find({
66
+ collection: collection.slug,
67
+ depth: 0,
68
+ locale: locale || undefined,
69
+ overrideAccess: true,
70
+ page,
71
+ pagination: true
72
+ });
73
+ for (const document of documents.docs){
74
+ upgraded++;
75
+ console.log(`Lexical Upgrade: ${locale}: Upgrading collection:`, collection.slug, '(' + cur + '/' + max + ') - Upgrading Document: ' + document.id + ' (' + upgraded + '/' + documentCount + ')');
76
+ const found = upgradeDocument({
77
+ document,
78
+ fields: collection.fields
79
+ });
80
+ if (found) {
81
+ await payload.update({
82
+ id: document.id,
83
+ collection: collection.slug,
84
+ data: document,
85
+ depth: 0,
86
+ locale: locale || undefined
87
+ });
88
+ }
89
+ }
90
+ page++;
91
+ }
92
+ }
93
+ function upgradeDocument({ document, fields }) {
94
+ return !!upgradeDocumentFieldsRecursively({
95
+ data: document,
96
+ fields,
97
+ found: 0
98
+ });
99
+ }
100
+
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utilities/upgradeLexicalData/index.ts"],"sourcesContent":["import type { CollectionConfig, Field, GlobalConfig, Payload } from 'payload'\n\nimport { upgradeDocumentFieldsRecursively } from './upgradeDocumentFieldsRecursively.js'\n\n/**\n * This goes through every single document in your payload app and re-saves it, if it has a lexical editor.\n * This way, the data is automatically converted to the new format, and that automatic conversion gets applied to every single document in your app.\n *\n * @param payload\n */\nexport async function upgradeLexicalData({ payload }: { payload: Payload }) {\n const collections = payload.config.collections\n\n const allLocales = payload.config.localization ? payload.config.localization.localeCodes : [null]\n\n const totalCollections = collections.length\n for (const locale of allLocales) {\n let curCollection = 0\n for (const collection of collections) {\n curCollection++\n await upgradeCollection({\n collection,\n cur: curCollection,\n locale,\n max: totalCollections,\n payload,\n })\n }\n for (const global of payload.config.globals) {\n await upgradeGlobal({\n global,\n locale,\n payload,\n })\n }\n }\n}\n\nasync function upgradeGlobal({\n global,\n locale,\n payload,\n}: {\n global: GlobalConfig\n locale: null | string\n payload: Payload\n}) {\n console.log(`Lexical Upgrader: ${locale}: Upgrading global:`, global.slug)\n\n const document = await payload.findGlobal({\n slug: global.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n })\n\n const found = upgradeDocument({\n document,\n fields: global.fields,\n })\n\n if (found) {\n await payload.updateGlobal({\n slug: global.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n}\n\nasync function upgradeCollection({\n collection,\n cur,\n locale,\n max,\n payload,\n}: {\n collection: CollectionConfig\n cur: number\n locale: null | string\n max: number\n payload: Payload\n}) {\n console.log(\n `Lexical Upgrade: ${locale}: Upgrading collection:`,\n collection.slug,\n '(' + cur + '/' + max + ')',\n )\n\n const documentCount = (\n await payload.count({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n })\n ).totalDocs\n\n let page = 1\n let upgraded = 0\n\n while (upgraded < documentCount) {\n const documents = await payload.find({\n collection: collection.slug,\n depth: 0,\n locale: locale || undefined,\n overrideAccess: true,\n page,\n pagination: true,\n })\n\n for (const document of documents.docs) {\n upgraded++\n console.log(\n `Lexical Upgrade: ${locale}: Upgrading collection:`,\n collection.slug,\n '(' +\n cur +\n '/' +\n max +\n ') - Upgrading Document: ' +\n document.id +\n ' (' +\n upgraded +\n '/' +\n documentCount +\n ')',\n )\n const found = upgradeDocument({\n document,\n fields: collection.fields,\n })\n\n if (found) {\n await payload.update({\n id: document.id,\n collection: collection.slug,\n data: document,\n depth: 0,\n locale: locale || undefined,\n })\n }\n }\n page++\n }\n}\n\nfunction upgradeDocument({\n document,\n fields,\n}: {\n document: Record<string, unknown>\n fields: Field[]\n}): boolean {\n return !!upgradeDocumentFieldsRecursively({\n data: document,\n fields,\n found: 0,\n })\n}\n"],"names":["upgradeDocumentFieldsRecursively","upgradeLexicalData","payload","collections","config","allLocales","localization","localeCodes","totalCollections","length","locale","curCollection","collection","upgradeCollection","cur","max","global","globals","upgradeGlobal","console","log","slug","document","findGlobal","depth","undefined","overrideAccess","found","upgradeDocument","fields","updateGlobal","data","documentCount","count","totalDocs","page","upgraded","documents","find","pagination","docs","id","update"],"mappings":"AAEA,SAASA,gCAAgC,QAAQ,wCAAuC;AAExF;;;;;CAKC,GACD,OAAO,eAAeC,mBAAmB,EAAEC,OAAO,EAAwB;IACxE,MAAMC,cAAcD,QAAQE,MAAM,CAACD,WAAW;IAE9C,MAAME,aAAaH,QAAQE,MAAM,CAACE,YAAY,GAAGJ,QAAQE,MAAM,CAACE,YAAY,CAACC,WAAW,GAAG;QAAC;KAAK;IAEjG,MAAMC,mBAAmBL,YAAYM,MAAM;IAC3C,KAAK,MAAMC,UAAUL,WAAY;QAC/B,IAAIM,gBAAgB;QACpB,KAAK,MAAMC,cAAcT,YAAa;YACpCQ;YACA,MAAME,kBAAkB;gBACtBD;gBACAE,KAAKH;gBACLD;gBACAK,KAAKP;gBACLN;YACF;QACF;QACA,KAAK,MAAMc,UAAUd,QAAQE,MAAM,CAACa,OAAO,CAAE;YAC3C,MAAMC,cAAc;gBAClBF;gBACAN;gBACAR;YACF;QACF;IACF;AACF;AAEA,eAAegB,cAAc,EAC3BF,MAAM,EACNN,MAAM,EACNR,OAAO,EAKR;IACCiB,QAAQC,GAAG,CAAC,CAAC,kBAAkB,EAAEV,OAAO,mBAAmB,CAAC,EAAEM,OAAOK,IAAI;IAEzE,MAAMC,WAAW,MAAMpB,QAAQqB,UAAU,CAAC;QACxCF,MAAML,OAAOK,IAAI;QACjBG,OAAO;QACPd,QAAQA,UAAUe;QAClBC,gBAAgB;IAClB;IAEA,MAAMC,QAAQC,gBAAgB;QAC5BN;QACAO,QAAQb,OAAOa,MAAM;IACvB;IAEA,IAAIF,OAAO;QACT,MAAMzB,QAAQ4B,YAAY,CAAC;YACzBT,MAAML,OAAOK,IAAI;YACjBU,MAAMT;YACNE,OAAO;YACPd,QAAQA,UAAUe;QACpB;IACF;AACF;AAEA,eAAeZ,kBAAkB,EAC/BD,UAAU,EACVE,GAAG,EACHJ,MAAM,EACNK,GAAG,EACHb,OAAO,EAOR;IACCiB,QAAQC,GAAG,CACT,CAAC,iBAAiB,EAAEV,OAAO,uBAAuB,CAAC,EACnDE,WAAWS,IAAI,EACf,MAAMP,MAAM,MAAMC,MAAM;IAG1B,MAAMiB,gBAAgB,AACpB,CAAA,MAAM9B,QAAQ+B,KAAK,CAAC;QAClBrB,YAAYA,WAAWS,IAAI;QAC3BG,OAAO;QACPd,QAAQA,UAAUe;IACpB,EAAC,EACDS,SAAS;IAEX,IAAIC,OAAO;IACX,IAAIC,WAAW;IAEf,MAAOA,WAAWJ,cAAe;QAC/B,MAAMK,YAAY,MAAMnC,QAAQoC,IAAI,CAAC;YACnC1B,YAAYA,WAAWS,IAAI;YAC3BG,OAAO;YACPd,QAAQA,UAAUe;YAClBC,gBAAgB;YAChBS;YACAI,YAAY;QACd;QAEA,KAAK,MAAMjB,YAAYe,UAAUG,IAAI,CAAE;YACrCJ;YACAjB,QAAQC,GAAG,CACT,CAAC,iBAAiB,EAAEV,OAAO,uBAAuB,CAAC,EACnDE,WAAWS,IAAI,EACf,MACEP,MACA,MACAC,MACA,6BACAO,SAASmB,EAAE,GACX,OACAL,WACA,MACAJ,gBACA;YAEJ,MAAML,QAAQC,gBAAgB;gBAC5BN;gBACAO,QAAQjB,WAAWiB,MAAM;YAC3B;YAEA,IAAIF,OAAO;gBACT,MAAMzB,QAAQwC,MAAM,CAAC;oBACnBD,IAAInB,SAASmB,EAAE;oBACf7B,YAAYA,WAAWS,IAAI;oBAC3BU,MAAMT;oBACNE,OAAO;oBACPd,QAAQA,UAAUe;gBACpB;YACF;QACF;QACAU;IACF;AACF;AAEA,SAASP,gBAAgB,EACvBN,QAAQ,EACRO,MAAM,EAIP;IACC,OAAO,CAAC,CAAC7B,iCAAiC;QACxC+B,MAAMT;QACNO;QACAF,OAAO;IACT;AACF"}
@@ -0,0 +1,9 @@
1
+ import type { Field } from 'payload';
2
+ type NestedRichTextFieldsArgs = {
3
+ data: unknown;
4
+ fields: Field[];
5
+ found: number;
6
+ };
7
+ export declare const upgradeDocumentFieldsRecursively: ({ data, fields, found, }: NestedRichTextFieldsArgs) => number;
8
+ export {};
9
+ //# sourceMappingURL=upgradeDocumentFieldsRecursively.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgradeDocumentFieldsRecursively.d.ts","sourceRoot":"","sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AASpC,KAAK,wBAAwB,GAAG;IAC9B,IAAI,EAAE,OAAO,CAAA;IAEb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gCAAgC,6BAI1C,wBAAwB,KAAG,MAmF7B,CAAA"}
@@ -0,0 +1,74 @@
1
+ import { createHeadlessEditor } from '@lexical/headless';
2
+ import { fieldAffectsData, fieldHasSubFields, fieldIsArrayType } from 'payload/shared';
3
+ import { getEnabledNodes } from '../../lexical/nodes/index.js';
4
+ export const upgradeDocumentFieldsRecursively = ({ data, fields, found })=>{
5
+ for (const field of fields){
6
+ if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {
7
+ if (fieldAffectsData(field) && typeof data[field.name] === 'object') {
8
+ upgradeDocumentFieldsRecursively({
9
+ data: data[field.name],
10
+ fields: field.fields,
11
+ found
12
+ });
13
+ } else {
14
+ upgradeDocumentFieldsRecursively({
15
+ data,
16
+ found,
17
+ fields: field.fields
18
+ });
19
+ }
20
+ } else if (field.type === 'tabs') {
21
+ field.tabs.forEach((tab)=>{
22
+ upgradeDocumentFieldsRecursively({
23
+ data,
24
+ found,
25
+ fields: tab.fields
26
+ });
27
+ });
28
+ } else if (Array.isArray(data[field.name])) {
29
+ if (field.type === 'blocks') {
30
+ data[field.name].forEach((row, i)=>{
31
+ const block = field.blocks.find(({ slug })=>slug === row?.blockType);
32
+ if (block) {
33
+ upgradeDocumentFieldsRecursively({
34
+ data: data[field.name][i],
35
+ found,
36
+ fields: block.fields
37
+ });
38
+ }
39
+ });
40
+ }
41
+ if (field.type === 'array') {
42
+ data[field.name].forEach((_, i)=>{
43
+ upgradeDocumentFieldsRecursively({
44
+ data: data[field.name][i],
45
+ found,
46
+ fields: field.fields
47
+ });
48
+ });
49
+ }
50
+ }
51
+ if (field.type === 'richText' && data[field.name] && !Array.isArray(data[field.name]) && 'root' in data[field.name]) {
52
+ // Lexical richText
53
+ const editor = field.editor;
54
+ if (editor && typeof editor === 'object') {
55
+ if ('features' in editor && editor.features?.length) {
56
+ // Load lexical editor into lexical, then save it immediately
57
+ const editorState = data[field.name];
58
+ const headlessEditor = createHeadlessEditor({
59
+ nodes: getEnabledNodes({
60
+ editorConfig: editor.editorConfig
61
+ })
62
+ });
63
+ headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState));
64
+ // get editor state
65
+ data[field.name] = headlessEditor.getEditorState().toJSON();
66
+ found++;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ return found;
72
+ };
73
+
74
+ //# sourceMappingURL=upgradeDocumentFieldsRecursively.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.ts"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { Field } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { fieldAffectsData, fieldHasSubFields, fieldIsArrayType } from 'payload/shared'\n\nimport type { LexicalRichTextAdapter } from '../../types.js'\n\nimport { getEnabledNodes } from '../../lexical/nodes/index.js'\n\ntype NestedRichTextFieldsArgs = {\n data: unknown\n\n fields: Field[]\n found: number\n}\n\nexport const upgradeDocumentFieldsRecursively = ({\n data,\n fields,\n found,\n}: NestedRichTextFieldsArgs): number => {\n for (const field of fields) {\n if (fieldHasSubFields(field) && !fieldIsArrayType(field)) {\n if (fieldAffectsData(field) && typeof data[field.name] === 'object') {\n upgradeDocumentFieldsRecursively({\n data: data[field.name],\n fields: field.fields,\n found,\n })\n } else {\n upgradeDocumentFieldsRecursively({\n data,\n found,\n\n fields: field.fields,\n })\n }\n } else if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n upgradeDocumentFieldsRecursively({\n data,\n found,\n\n fields: tab.fields,\n })\n })\n } else if (Array.isArray(data[field.name])) {\n if (field.type === 'blocks') {\n data[field.name].forEach((row, i) => {\n const block = field.blocks.find(({ slug }) => slug === row?.blockType)\n if (block) {\n upgradeDocumentFieldsRecursively({\n data: data[field.name][i],\n found,\n\n fields: block.fields,\n })\n }\n })\n }\n\n if (field.type === 'array') {\n data[field.name].forEach((_, i) => {\n upgradeDocumentFieldsRecursively({\n data: data[field.name][i],\n found,\n\n fields: field.fields,\n })\n })\n }\n }\n\n if (\n field.type === 'richText' &&\n data[field.name] &&\n !Array.isArray(data[field.name]) &&\n 'root' in data[field.name]\n ) {\n // Lexical richText\n const editor: LexicalRichTextAdapter = field.editor as LexicalRichTextAdapter\n if (editor && typeof editor === 'object') {\n if ('features' in editor && editor.features?.length) {\n // Load lexical editor into lexical, then save it immediately\n const editorState: SerializedEditorState = data[field.name]\n\n const headlessEditor = createHeadlessEditor({\n nodes: getEnabledNodes({\n editorConfig: editor.editorConfig,\n }),\n })\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState))\n\n // get editor state\n data[field.name] = headlessEditor.getEditorState().toJSON()\n\n found++\n }\n }\n }\n }\n\n return found\n}\n"],"names":["createHeadlessEditor","fieldAffectsData","fieldHasSubFields","fieldIsArrayType","getEnabledNodes","upgradeDocumentFieldsRecursively","data","fields","found","field","name","type","tabs","forEach","tab","Array","isArray","row","i","block","blocks","find","slug","blockType","_","editor","features","length","editorState","headlessEditor","nodes","editorConfig","setEditorState","parseEditorState","getEditorState","toJSON"],"mappings":"AAGA,SAASA,oBAAoB,QAAQ,oBAAmB;AACxD,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,gBAAgB,QAAQ,iBAAgB;A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CAACG,MAAMC,IAAI,CAAC,CAACQ,EAAE;wBACzBV;wBAEAD,QAAQE,MAAMF,MAAM;oBACtB;gBACF;YACF;QACF;QAEA,IACEE,MAAME,IAAI,KAAK,cACfL,IAAI,CAACG,MAAMC,IAAI,CAAC,IAChB,CAACK,MAAMC,OAAO,CAACV,IAAI,CAACG,MAAMC,IAAI,CAAC,KAC/B,UAAUJ,IAAI,CAACG,MAAMC,IAAI,CAAC,EAC1B;YACA,mBAAmB;YACnB,MAAMe,SAAiChB,MAAMgB,MAAM;YACnD,IAAIA,UAAU,OAAOA,WAAW,UAAU;gBACxC,IAAI,cAAcA,UAAUA,OAAOC,QAAQ,EAAEC,QAAQ;oBACnD,6DAA6D;oBAC7D,MAAMC,cAAqCtB,IAAI,CAACG,MAAMC,IAAI,CAAC;oBAE3D,MAAMmB,iBAAiB7B,qBAAqB;wBAC1C8B,OAAO1B,gBAAgB;4BACrB2B,cAAcN,OAAOM,YAAY;wBACnC;oBACF;oBACAF,eAAeG,cAAc,CAACH,eAAeI,gBAAgB,CAACL;oBAE9D,mBAAmB;oBACnBtB,IAAI,CAACG,MAAMC,IAAI,CAAC,GAAGmB,eAAeK,cAAc,GAAGC,MAAM;oBAEzD3B;gBACF;YACF;QACF;IACF;IAEA,OAAOA;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.0.0-beta.55",
3
+ "version": "3.0.0-beta.56",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -56,10 +56,10 @@
56
56
  "esbuild": "^0.21.4",
57
57
  "esbuild-sass-plugin": "^3.3.0",
58
58
  "@payloadcms/eslint-config": "1.1.1",
59
- "@payloadcms/next": "3.0.0-beta.55",
60
- "@payloadcms/ui": "3.0.0-beta.55",
61
- "@payloadcms/translations": "3.0.0-beta.55",
62
- "payload": "3.0.0-beta.55"
59
+ "@payloadcms/ui": "3.0.0-beta.56",
60
+ "@payloadcms/next": "3.0.0-beta.56",
61
+ "@payloadcms/translations": "3.0.0-beta.56",
62
+ "payload": "3.0.0-beta.56"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@faceless-ui/modal": "3.0.0-beta.0",
@@ -76,10 +76,10 @@
76
76
  "lexical": "0.16.0",
77
77
  "react": "^19.0.0 || ^19.0.0-rc-f994737d14-20240522",
78
78
  "react-dom": "^19.0.0 || ^19.0.0-rc-f994737d14-20240522",
79
- "@payloadcms/next": "3.0.0-beta.55",
80
- "@payloadcms/ui": "3.0.0-beta.55",
81
- "@payloadcms/translations": "3.0.0-beta.55",
82
- "payload": "3.0.0-beta.55"
79
+ "@payloadcms/next": "3.0.0-beta.56",
80
+ "@payloadcms/ui": "3.0.0-beta.56",
81
+ "payload": "3.0.0-beta.56",
82
+ "@payloadcms/translations": "3.0.0-beta.56"
83
83
  },
84
84
  "engines": {
85
85
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- import{useAuth as f,useConfig as D,useEntityVisibility as g}from"@payloadcms/ui";import*as l from"react";var y=(e,t)=>e.filter(({slug:o,admin:{enableRichTextRelationship:a},upload:n})=>t.visibleEntities.collections.includes(o)?t?.uploads?a&&!!n:n?!1:a:!1),S=e=>{let{children:t,uploads:o=!1,...a}=e,{collections:n}=D(),{user:d}=f(),{visibleEntities:u}=g(),[r]=l.useState(()=>y(n,{uploads:o,user:d,visibleEntities:u}).map(({slug:m})=>m));return r.length?l.cloneElement(t,{...a,enabledCollectionSlugs:r}):null};import{createCommand as C}from"lexical";var T=C("INSERT_UPLOAD_WITH_DRAWER_COMMAND");import{DecoratorBlockNode as x}from"@lexical/react/LexicalDecoratorBlockNode.js";import s from"bson-objectid";import{$applyNodeReplacement as _}from"lexical";import*as p from"react";import{jsx as O}from"react/jsx-runtime";var U=p.lazy(()=>import("./component-F6V63OLD.js").then(e=>({default:e.UploadComponent})));function v(e){return e.parentElement!=null&&e.parentElement.tagName==="LI"&&e.previousSibling===null&&e.getAttribute("aria-roledescription")==="checkbox"}function E(e){if(e.hasAttribute("data-lexical-upload-relation-to")&&e.hasAttribute("data-lexical-upload-id")){let o=e.getAttribute("data-lexical-upload-id"),a=e.getAttribute("data-lexical-upload-relation-to");if(o!=null&&a!=null)return{node:c({data:{fields:{},relationTo:a,value:o}})}}let t=e;return t.src.startsWith("file:///")||v(t),null}var i=class e extends x{__data;constructor({data:t,format:o,key:a}){super(o,a),this.__data=t}static clone(t){return new e({data:t.__data,format:t.__format,key:t.__key})}static getType(){return"upload"}static importDOM(){return{img:t=>({conversion:E,priority:0})}}static importJSON(t){t.version===1&&t?.value?.id&&(t.value=t.value.id),t.version===2&&!t?.id&&(t.id=new s.default().toHexString(),t.version=3);let o={id:t.id,fields:t.fields,relationTo:t.relationTo,value:t.value},a=c({data:o});return a.setFormat(t.format),a}static isInline(){return!1}decorate(){return O(U,{data:this.__data,format:this.__format,nodeKey:this.getKey()})}exportDOM(){let t=document.createElement("img");return t.setAttribute("data-lexical-upload-id",String(this.__data?.value)),t.setAttribute("data-lexical-upload-relation-to",this.__data?.relationTo),{element:t}}exportJSON(){return{...super.exportJSON(),...this.getData(),type:"upload",version:3}}getData(){return this.getLatest().__data}setData(t){let o=this.getWritable();o.__data=t}updateDOM(){return!1}};function c({data:e}){return e?.id||(e.id=new s.default().toHexString()),_(new i({data:e}))}function I(e){return e instanceof i}export{S as a,T as b,i as c,c as d,I as e};
2
- //# sourceMappingURL=chunk-5RJS5YZT.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/relationship/utils/EnabledRelationshipsCondition.tsx", "../../../src/features/upload/drawer/commands.ts", "../../../src/features/upload/nodes/UploadNode.tsx"],
4
- "sourcesContent": ["import type { ClientCollectionConfig, ClientUser, VisibleEntities } from 'payload'\n\nimport { useAuth, useConfig, useEntityVisibility } from '@payloadcms/ui'\nimport * as React from 'react'\n\ntype Options = {\n uploads: boolean\n user: ClientUser\n visibleEntities: VisibleEntities\n}\n\ntype FilteredCollectionsT = (\n collections: ClientCollectionConfig[],\n options?: Options,\n) => ClientCollectionConfig[]\n\nconst filterRichTextCollections: FilteredCollectionsT = (collections, options) => {\n return collections.filter(({ slug, admin: { enableRichTextRelationship }, upload }) => {\n if (!options.visibleEntities.collections.includes(slug)) {\n return false\n }\n\n if (options?.uploads) {\n return enableRichTextRelationship && Boolean(upload) === true\n }\n\n return upload ? false : enableRichTextRelationship\n })\n}\n\nexport const EnabledRelationshipsCondition: React.FC<any> = (props) => {\n const { children, uploads = false, ...rest } = props\n const { collections } = useConfig()\n const { user } = useAuth()\n const { visibleEntities } = useEntityVisibility()\n\n const [enabledCollectionSlugs] = React.useState(() =>\n filterRichTextCollections(collections, { uploads, user, visibleEntities }).map(\n ({ slug }) => slug,\n ),\n )\n\n if (!enabledCollectionSlugs.length) {\n return null\n }\n\n return React.cloneElement(children, { ...rest, enabledCollectionSlugs })\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", "import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n ElementFormatType,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { CollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement } from 'lexical'\nimport * as React from 'react'\n\nconst RawUploadComponent = React.lazy(() =>\n import('../component/index.js').then((module) => ({ default: module.UploadComponent })),\n)\n\nexport type UploadData = {\n fields: {\n // unknown, custom fields:\n [key: string]: unknown\n }\n id: string\n relationTo: CollectionSlug\n value: number | string\n}\n\nfunction 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\nfunction $convertUploadElement(domNode: HTMLImageElement): DOMConversionOutput | null {\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 = $createUploadNode({\n data: {\n fields: {},\n relationTo,\n value: id,\n },\n })\n return { node }\n }\n }\n const img = domNode\n if (img.src.startsWith('file:///') || isGoogleDocCheckboxImg(img)) {\n return null\n }\n // TODO: Auto-upload functionality here!\n //}\n return null\n}\n\nexport type SerializedUploadNode = Spread<UploadData, SerializedDecoratorBlockNode> & {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'upload'\n}\n\nexport class UploadNode 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 clone(node: UploadNode): UploadNode {\n return new UploadNode({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static getType(): string {\n return 'upload'\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n img: (node: HTMLImageElement) => ({\n conversion: $convertUploadElement,\n priority: 0,\n }),\n }\n }\n\n static 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: UploadData = {\n id: serializedNode.id,\n fields: serializedNode.fields,\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 static isInline(): false {\n return false\n }\n\n decorate(): JSX.Element {\n // @ts-expect-error\n return <RawUploadComponent data={this.__data} format={this.__format} nodeKey={this.getKey()} />\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement('img')\n element.setAttribute('data-lexical-upload-id', String(this.__data?.value))\n element.setAttribute('data-lexical-upload-relation-to', this.__data?.relationTo)\n\n return { element }\n }\n\n 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 // eslint-disable-next-line class-methods-use-this\n updateDOM(): false {\n return false\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 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"],
5
- "mappings": "AAEA,OAAS,WAAAA,EAAS,aAAAC,EAAW,uBAAAC,MAA2B,iBACxD,UAAYC,MAAW,QAavB,IAAMC,EAAkD,CAACC,EAAaC,IAC7DD,EAAY,OAAO,CAAC,CAAE,KAAAE,EAAM,MAAO,CAAE,2BAAAC,CAA2B,EAAG,OAAAC,CAAO,IAC1EH,EAAQ,gBAAgB,YAAY,SAASC,CAAI,EAIlDD,GAAS,QACJE,GAA8B,EAAQC,EAGxCA,EAAS,GAAQD,EAPf,EAQV,EAGUE,EAAgDC,GAAU,CACrE,GAAM,CAAE,SAAAC,EAAU,QAAAC,EAAU,GAAO,GAAGC,CAAK,EAAIH,EACzC,CAAE,YAAA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AAQ,EAChB,KAAM,SACN,QAAS,CACX,CACF,CAEA,SAAsB,CACpB,OAAO,KAAK,UAAU,EAAE,MAC1B,CAEA,QAAQN,EAAwB,CAC9B,IAAMO,EAAW,KAAK,YAAY,EAClCA,EAAS,OAASP,CACpB,CAGA,WAAmB,CACjB,MAAO,EACT,CACF,EAEO,SAASH,EAAkB,CAChC,KAAAG,CACF,EAEe,CACb,OAAKA,GAAM,KACTA,EAAK,GAAK,IAAIf,EAAS,QAAQ,EAAE,YAAY,GAExCC,EAAsB,IAAIY,EAAW,CAAE,KAAME,CAAmB,CAAC,CAAC,CAC3E,CAEO,SAASQ,EAAcL,EAA0D,CACtF,OAAOA,aAAgBL,CACzB",
6
- "names": ["useAuth", "useConfig", "useEntityVisibility", "React", "filterRichTextCollections", "collections", "options", "slug", "enableRichTextRelationship", "upload", "EnabledRelationshipsCondition", "props", "children", "uploads", "rest", "user", "visibleEntities", "enabledCollectionSlugs", "createCommand", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "DecoratorBlockNode", "ObjectID", "$applyNodeReplacement", "React", "jsx", "RawUploadComponent", "module", "isGoogleDocCheckboxImg", "img", "$convertUploadElement", "domNode", "id", "relationTo", "$createUploadNode", "UploadNode", "_UploadNode", "data", "format", "key", "node", "serializedNode", "importedData", "element", "writable", "$isUploadNode"]
7
- }
@@ -1,2 +0,0 @@
1
- "use client";import{a as j,b as W,e as Y}from"./chunk-5RJS5YZT.js";import{b as N}from"./chunk-3K3B6PJM.js";import{useLexicalComposerContext as Ce}from"@lexical/react/LexicalComposerContext.js";import{useLexicalNodeSelection as ge}from"@lexical/react/useLexicalNodeSelection.js";import{mergeRegister as ve}from"@lexical/utils";import{getTranslation as ye}from"@payloadcms/translations";import{Button as T,DrawerToggler as De,File as be,useConfig as he,useDocumentDrawer as Re,useDrawerSlug as Se,usePayloadAPI as _e,useTranslation as Ee}from"@payloadcms/ui";import{$getNodeByKey as q,$getSelection as we,$isNodeSelection as Ne,CLICK_COMMAND as Ue,COMMAND_PRIORITY_LOW as O,KEY_BACKSPACE_COMMAND as Pe,KEY_DELETE_COMMAND as Fe}from"lexical";import{useCallback as U,useEffect as $e,useReducer as xe,useRef as Me,useState as Le}from"react";import{useLexicalComposerContext as X}from"@lexical/react/LexicalComposerContext.js";import{getTranslation as Z}from"@payloadcms/translations";import{Drawer as ee,Form as te,FormSubmit as oe,RenderFields as ae,useConfig as le,useDocumentInfo as re,useFieldProps as ie,useModal as ne,useTranslation as se}from"@payloadcms/ui";import{getFormState as H}from"@payloadcms/ui/shared";import{$getNodeByKey as de}from"lexical";import{deepCopyObject as ce}from"payload/shared";import{useCallback as z,useEffect as pe,useState as me}from"react";import{v4 as ue}from"uuid";import{jsx as L,jsxs as fe}from"react/jsx-runtime";var V=d=>{let{data:{fields:P,relationTo:F,value:C},drawerSlug:a,nodeKey:R,relatedCollection:g}=d,[S]=X(),{closeModal:p}=ne(),{i18n:l,t:r}=se(),{id:n}=re(),{schemaPath:v}=ie(),i=le(),[m,$]=me(!1),{field:{richTextComponentMap:y}}=N(),_=`feature.upload.fields.${g.slug}`,c=`${v}.feature.upload.${g.slug}`,s=y.get(_);pe(()=>{(async()=>{let b=await H({apiRoute:i.routes.api,body:{id:n,data:ce(P||{}),operation:"update",schemaPath:c},serverURL:i.serverURL});$(b)})()},[i.routes.api,i.serverURL,c,n,P]);let x=z(async({formState:D})=>await H({apiRoute:i.routes.api,body:{id:n,formState:D,operation:"update",schemaPath:c},serverURL:i.serverURL}),[i.routes.api,i.serverURL,c,n]),E=z((D,b)=>{S.update(()=>{let u=de(R);if(u){let f={...u.getData(),fields:b};u.setData(f)}}),p(a)},[p,S,a,R]);return L(ee,{slug:a,title:r("general:editLabel",{label:Z(g.labels.singular,l)}),children:m!==!1&&fe(te,{beforeSubmit:[x],disableValidationOnSubmit:!0,fields:s,initialState:m,onChange:[x],onSubmit:E,uuid:ue(),children:[L(ae,{fieldMap:Array.isArray(s)?s:[],forceRender:!0,path:"",readOnly:!1,schemaPath:c}),L(oe,{children:r("fields:saveChanges")})]})})};import{jsx as e,jsxs as h}from"react/jsx-runtime";var o="lexical-upload",G={depth:0},Te=d=>{let{data:{fields:P,relationTo:F,value:C},nodeKey:a}=d,{collections:R,routes:{api:g},serverURL:S}=he(),p=Me(null),[l]=Ce(),[r,n,v]=ge(a),{editorConfig:i,field:m}=N(),{i18n:$,t:y}=Ee(),[_,c]=xe(t=>t+1,0),[s,x]=Le(()=>R.find(t=>t.slug===F)),E=Se("upload-drawer"),[D,b,{closeDrawer:u}]=Re({id:C,collectionSlug:s.slug}),[{data:f},{setParams:A}]=_e(`${S}${g}/${s.slug}/${C}`,{initialParams:G}),K=f?.thumbnailURL||f?.url,J=U(()=>{l.update(()=>{q(a).remove()})},[l,a]),Q=U(t=>{A({...G,cacheBust:_}),c(),u()},[A,_,u]),M=U(t=>{if(r&&Ne(we())){t.preventDefault();let k=q(a);if(Y(k))return k.remove(),!0}return!1},[r,a]),I=U(t=>{let w=t;return w.target===p.current||p.current?.contains(w.target)?(w.shiftKey?n(!r):r||(v(),n(!0)),!0):!1},[r,n,v]);$e(()=>ve(l.registerCommand(Ue,I,O),l.registerCommand(Fe,M,O),l.registerCommand(Pe,M,O)),[v,l,r,a,M,n,I]);let B=(i?.resolvedFeatureMap?.get("upload")?.sanitizedClientFeatureProps).collections?.[s.slug]?.hasExtraFields;return h("div",{className:[o,r&&`${o}--selected`].filter(Boolean).join(" "),contentEditable:!1,ref:p,children:[h("div",{className:`${o}__card`,children:[h("div",{className:`${o}__topRow`,children:[e("div",{className:`${o}__thumbnail`,children:K?e("img",{alt:f?.filename,"data-lexical-upload-id":C,"data-lexical-upload-relation-to":F,src:K}):e(be,{})}),h("div",{className:`${o}__topRowRightPanel`,children:[e("div",{className:`${o}__collectionLabel`,children:ye(s.labels.singular,$)}),l.isEditable()&&h("div",{className:`${o}__actions`,children:[B?e(De,{className:`${o}__upload-drawer-toggler`,disabled:m?.readOnly,slug:E,children:e(T,{buttonStyle:"icon-label",el:"div",icon:"edit",onClick:t=>{t.preventDefault()},round:!0,tooltip:y("fields:editRelationship")})}):null,e(T,{buttonStyle:"icon-label",disabled:m?.readOnly,el:"div",icon:"swap",onClick:()=>{l.dispatchCommand(W,{replace:{nodeKey:a}})},round:!0,tooltip:y("fields:swapUpload")}),e(T,{buttonStyle:"icon-label",className:`${o}__removeButton`,disabled:m?.readOnly,icon:"x",onClick:t=>{t.preventDefault(),J()},round:!0,tooltip:y("fields:removeUpload")})]})]})]}),e("div",{className:`${o}__bottomRow`,children:e(b,{className:`${o}__doc-drawer-toggler`,children:e("strong",{children:f?.filename})})})]}),C&&e(D,{onSave:Q}),B?e(V,{drawerSlug:E,relatedCollection:s,...d}):null]})},nt=d=>e(j,{...d,uploads:!0,children:e(Te,{...d})});export{nt as UploadComponent};
2
- //# sourceMappingURL=component-F6V63OLD.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/features/upload/component/index.tsx", "../../../src/features/upload/component/ExtraFieldsDrawer/index.tsx"],
4
- "sourcesContent": ["'use client'\nimport type { ClientCollectionConfig } from 'payload'\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 {\n Button,\n DrawerToggler,\n File,\n useConfig,\n useDocumentDrawer,\n useDrawerSlug,\n usePayloadAPI,\n useTranslation,\n} from '@payloadcms/ui'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport React, { useCallback, useEffect, useReducer, useRef, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../typesClient.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { $isUploadNode } from '../nodes/UploadNode.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n const uploadRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\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 (json) => {\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 closeDrawer()\n },\n [setParams, cacheBust, 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 ($isUploadNode(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 uploadRef.target or anything WITHIN uploadRef.target was clicked\n if (event.target === uploadRef.current || uploadRef.current?.contains(event.target as Node)) {\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 const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.sanitizedClientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n ref={uploadRef}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? (\n <img\n alt={data?.filename}\n data-lexical-upload-id={value}\n data-lexical-upload-relation-to={relationTo}\n src={thumbnailSRC}\n />\n ) : (\n <File />\n )}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\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 removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value && <DocumentDrawer onSave={updateUpload} />}\n {hasExtraFields ? (\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n ) : null}\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n", "'use client'\nimport type { FormProps } from '@payloadcms/ui'\nimport type { ClientCollectionConfig, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Drawer,\n Form,\n FormSubmit,\n RenderFields,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useModal,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\nimport { deepCopyObject } from 'payload/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { UploadData, UploadNode } from '../../nodes/UploadNode.js'\nimport type { ElementProps } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\n\n/**\n * This handles the extra fields, e.g. captions or alt text, which are\n * potentially added to the upload feature.\n */\nexport const ExtraFieldsUploadDrawer: React.FC<\n ElementProps & {\n drawerSlug: string\n relatedCollection: ClientCollectionConfig\n }\n> = (props) => {\n const {\n data: { fields, relationTo, value },\n drawerSlug,\n nodeKey,\n relatedCollection,\n } = props\n\n const [editor] = useLexicalComposerContext()\n\n const { closeModal } = useModal()\n\n const { i18n, t } = useTranslation()\n const { id } = useDocumentInfo()\n const { schemaPath } = useFieldProps()\n const config = useConfig()\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `feature.upload.fields.${relatedCollection.slug}`\n const schemaFieldsPath = `${schemaPath}.feature.upload.${relatedCollection.slug}`\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath) // Field Schema\n\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: deepCopyObject(fields || {}),\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id, fields])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n return await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id],\n )\n\n const handleUpdateEditData = useCallback(\n (_, data) => {\n // Update lexical node (with key nodeKey) with new data\n editor.update(() => {\n const uploadNode: UploadNode | null = $getNodeByKey(nodeKey)\n if (uploadNode) {\n const newData: UploadData = {\n ...uploadNode.getData(),\n fields: data,\n }\n uploadNode.setData(newData)\n }\n })\n\n closeModal(drawerSlug)\n },\n [closeModal, editor, drawerSlug, nodeKey],\n )\n\n return (\n <Drawer\n slug={drawerSlug}\n title={t('general:editLabel', {\n label: getTranslation(relatedCollection.labels.singular, i18n),\n })}\n >\n {initialState !== false && (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n // @ts-expect-error TODO: Fix this\n fields={fieldMap}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleUpdateEditData}\n uuid={uuid()}\n >\n <RenderFields\n fieldMap={Array.isArray(fieldMap) ? fieldMap : []}\n forceRender\n path=\"\" // See Blocks feature path for details as for why this is empty\n readOnly={false}\n schemaPath={schemaFieldsPath}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )}\n </Drawer>\n )\n}\n"],
5
- "mappings": "2GAGA,OAAS,6BAAAA,OAAiC,2CAC1C,OAAS,2BAAAC,OAA+B,4CACxC,OAAS,iBAAAC,OAAqB,iBAC9B,OAAS,kBAAAC,OAAsB,2BAC/B,OACE,UAAAC,EACA,iBAAAC,GACA,QAAAC,GACA,aAAAC,GACA,qBAAAC,GACA,iBAAAC,GACA,iBAAAC,GACA,kBAAAC,OACK,iBACP,OACE,iBAAAC,EACA,iBAAAC,GACA,oBAAAC,GACA,iBAAAC,GACA,wBAAAC,EACA,yBAAAC,GACA,sBAAAC,OACK,UACP,OAAgB,eAAAC,EAAa,aAAAC,GAAW,cAAAC,GAAY,UAAAC,GAAQ,YAAAC,OAAgB,QCtB5E,OAAS,6BAAAC,MAAiC,2CAC1C,OAAS,kBAAAC,MAAsB,2BAC/B,OACE,UAAAC,GACA,QAAAC,GACA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ACxB",
6
- "names": ["useLexicalComposerContext", "useLexicalNodeSelection", "mergeRegister", "getTranslation", "Button", "DrawerToggler", "File", "useConfig", "useDocumentDrawer", "useDrawerSlug", "usePayloadAPI", "useTranslation", "$getNodeByKey", "$getSelection", "$isNodeSelection", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_BACKSPACE_COMMAND", "KEY_DELETE_COMMAND", "useCallback", "useEffect", "useReducer", "useRef", "useState", "useLexicalComposerContext", "getTranslation", "Drawer", "Form", "FormSubmit", "RenderFields", "useConfig", "useDocumentInfo", "useFieldProps", "useModal", "useTranslation", "getFormState", "$getNodeByKey", "deepCopyObject", "useCallback", "useEffect", "useState", "uuid", "jsx", "jsxs", "ExtraFieldsUploadDrawer", "props", "fields", "relationTo", "value", "drawerSlug", "nodeKey", "relatedCollection", "editor", "useLexicalComposerContext", "closeModal", "useModal", "i18n", "t", "useTranslation", "id", "useDocumentInfo", "schemaPath", "useFieldProps", "config", "useConfig", "initialState", "setInitialState", "useState", "richTextComponentMap", "useEditorConfigContext", "componentMapRenderedFieldsPath", "schemaFieldsPath", "fieldMap", "useEffect", "state", "getFormState", "deepCopyObject", "onChange", "useCallback", "prevFormState", "handleUpdateEditData", "_", "data", "uploadNode", "$getNodeByKey", "newData", "Drawer", "getTranslation", "Form", "uuid", "RenderFields", "FormSubmit", "jsx", "jsxs", "baseClass", "initialParams", "Component", "props", "fields", "relationTo", "value", "nodeKey", "collections", "api", "serverURL", "useConfig", "uploadRef", "useRef", "editor", "useLexicalComposerContext", "isSelected", "setSelected", "clearSelection", "useLexicalNodeSelection", "editorConfig", "field", "useEditorConfigContext", "i18n", "t", "useTranslation", "cacheBust", "dispatchCacheBust", "useReducer", "state", "relatedCollection", "setRelatedCollection", "useState", "coll", "drawerSlug", "useDrawerSlug", "DocumentDrawer", "DocumentDrawerToggler", "closeDrawer", "useDocumentDrawer", "data", "setParams", "usePayloadAPI", "thumbnailSRC", "removeUpload", "useCallback", "$getNodeByKey", "updateUpload", "json", "$onDelete", "payload", "$isNodeSelection", "$getSelection", "node", "$isUploadNode", "onClick", "event", "useEffect", "mergeRegister", "CLICK_COMMAND", "COMMAND_PRIORITY_LOW", "KEY_DELETE_COMMAND", "KEY_BACKSPACE_COMMAND", "hasExtraFields", "File", "getTranslation", "DrawerToggler", "Button", "e", "INSERT_UPLOAD_WITH_DRAWER_COMMAND", "ExtraFieldsUploadDrawer", "UploadComponent", "EnabledRelationshipsCondition"]
7
- }