@payloadcms/richtext-lexical 3.0.0-beta.55 → 3.0.0-beta.57
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.
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-OAQL5GDK.js +2 -0
- package/dist/exports/client/chunk-OAQL5GDK.js.map +7 -0
- package/dist/exports/client/component-V5QZ7EVZ.js +2 -0
- package/dist/exports/client/component-V5QZ7EVZ.js.map +7 -0
- package/dist/exports/client/{component-PEFMKIXI.js → component-YNZTTMBY.js} +2 -2
- package/dist/exports/client/component-YNZTTMBY.js.map +7 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +7 -7
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/component/index.js +1 -1
- package/dist/features/blocks/component/index.js.map +1 -1
- package/dist/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/features/blocks/feature.server.js +1 -11
- package/dist/features/blocks/feature.server.js.map +1 -1
- package/dist/features/heading/feature.server.d.ts +5 -1
- package/dist/features/heading/feature.server.d.ts.map +1 -1
- package/dist/features/heading/feature.server.js.map +1 -1
- package/dist/features/link/feature.server.d.ts.map +1 -1
- package/dist/features/link/feature.server.js +1 -11
- package/dist/features/link/feature.server.js.map +1 -1
- package/dist/features/link/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/plugins/autoLink/index.js +5 -2
- package/dist/features/link/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +9 -5
- package/dist/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/converters/heading/converter.js.map +1 -1
- package/dist/features/typesServer.d.ts +7 -7
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/component/index.d.ts.map +1 -1
- package/dist/features/upload/component/index.js +34 -11
- package/dist/features/upload/component/index.js.map +1 -1
- package/dist/features/upload/feature.server.d.ts.map +1 -1
- package/dist/features/upload/feature.server.js +1 -11
- package/dist/features/upload/feature.server.js.map +1 -1
- package/dist/field/index.js +8 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/nodeTypes.d.ts +11 -7
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js.map +1 -1
- package/dist/populateGraphQL/populate.d.ts +2 -2
- package/dist/populateGraphQL/populate.d.ts.map +1 -1
- package/dist/populateGraphQL/populate.js.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts +2 -2
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.d.ts.map +1 -1
- package/dist/populateGraphQL/recursivelyPopulateFieldsForGraphQL.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.d.ts +18 -0
- package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -0
- package/dist/utilities/fieldsDrawer/Drawer.js +26 -0
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -0
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -0
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -0
- package/dist/{features/link/drawer/index.js → utilities/fieldsDrawer/DrawerContent.js} +38 -40
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -0
- package/dist/utilities/generateSchemaMap.d.ts.map +1 -1
- package/dist/utilities/generateSchemaMap.js +9 -0
- package/dist/utilities/generateSchemaMap.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +2 -2
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +9 -0
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -0
- package/dist/utilities/migrateSlateToLexical/{recurse.js → migrateDocumentFieldsRecursively.js} +7 -7
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -0
- package/dist/utilities/upgradeLexicalData/index.d.ts +11 -0
- package/dist/utilities/upgradeLexicalData/index.d.ts.map +1 -0
- package/dist/utilities/upgradeLexicalData/index.js +101 -0
- package/dist/utilities/upgradeLexicalData/index.js.map +1 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +9 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +74 -0
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -0
- package/package.json +29 -29
- package/dist/exports/client/chunk-5RJS5YZT.js +0 -2
- package/dist/exports/client/chunk-5RJS5YZT.js.map +0 -7
- package/dist/exports/client/component-F6V63OLD.js +0 -2
- package/dist/exports/client/component-F6V63OLD.js.map +0 -7
- package/dist/exports/client/component-PEFMKIXI.js.map +0 -7
- package/dist/features/link/drawer/index.d.ts +0 -5
- package/dist/features/link/drawer/index.d.ts.map +0 -1
- package/dist/features/link/drawer/index.js.map +0 -1
- package/dist/features/link/drawer/types.d.ts +0 -10
- package/dist/features/link/drawer/types.d.ts.map +0 -1
- package/dist/features/link/drawer/types.js +0 -3
- package/dist/features/link/drawer/types.js.map +0 -1
- package/dist/features/upload/component/ExtraFieldsDrawer/index.d.ts +0 -12
- package/dist/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +0 -1
- package/dist/features/upload/component/ExtraFieldsDrawer/index.js +0 -123
- package/dist/features/upload/component/ExtraFieldsDrawer/index.js.map +0 -1
- package/dist/utilities/migrateSlateToLexical/recurse.d.ts +0 -9
- package/dist/utilities/migrateSlateToLexical/recurse.d.ts.map +0 -1
- package/dist/utilities/migrateSlateToLexical/recurse.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.57",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lexical/headless": "0.16.
|
|
34
|
-
"@lexical/link": "0.16.
|
|
35
|
-
"@lexical/list": "0.16.
|
|
36
|
-
"@lexical/mark": "0.16.
|
|
37
|
-
"@lexical/markdown": "0.16.
|
|
38
|
-
"@lexical/react": "0.16.
|
|
39
|
-
"@lexical/rich-text": "0.16.
|
|
40
|
-
"@lexical/selection": "0.16.
|
|
41
|
-
"@lexical/utils": "0.16.
|
|
33
|
+
"@lexical/headless": "0.16.1",
|
|
34
|
+
"@lexical/link": "0.16.1",
|
|
35
|
+
"@lexical/list": "0.16.1",
|
|
36
|
+
"@lexical/mark": "0.16.1",
|
|
37
|
+
"@lexical/markdown": "0.16.1",
|
|
38
|
+
"@lexical/react": "0.16.1",
|
|
39
|
+
"@lexical/rich-text": "0.16.1",
|
|
40
|
+
"@lexical/selection": "0.16.1",
|
|
41
|
+
"@lexical/utils": "0.16.1",
|
|
42
42
|
"@types/uuid": "^9.0.8",
|
|
43
43
|
"bson-objectid": "2.0.4",
|
|
44
44
|
"dequal": "2.0.3",
|
|
45
45
|
"json-schema": "^0.4.0",
|
|
46
|
-
"lexical": "0.16.
|
|
46
|
+
"lexical": "0.16.1",
|
|
47
47
|
"react-error-boundary": "4.0.13",
|
|
48
48
|
"uuid": "10.0.0"
|
|
49
49
|
},
|
|
@@ -56,30 +56,30 @@
|
|
|
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.
|
|
60
|
-
"@payloadcms/
|
|
61
|
-
"@payloadcms/
|
|
62
|
-
"payload": "3.0.0-beta.
|
|
59
|
+
"@payloadcms/next": "3.0.0-beta.57",
|
|
60
|
+
"@payloadcms/translations": "3.0.0-beta.57",
|
|
61
|
+
"@payloadcms/ui": "3.0.0-beta.57",
|
|
62
|
+
"payload": "3.0.0-beta.57"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@faceless-ui/modal": "3.0.0-beta.0",
|
|
66
66
|
"@faceless-ui/scroll-info": "2.0.0-beta.0",
|
|
67
|
-
"@lexical/headless": "0.16.
|
|
68
|
-
"@lexical/link": "0.16.
|
|
69
|
-
"@lexical/list": "0.16.
|
|
70
|
-
"@lexical/mark": "0.16.
|
|
71
|
-
"@lexical/markdown": "0.16.
|
|
72
|
-
"@lexical/react": "0.16.
|
|
73
|
-
"@lexical/rich-text": "0.16.
|
|
74
|
-
"@lexical/selection": "0.16.
|
|
75
|
-
"@lexical/utils": "0.16.
|
|
76
|
-
"lexical": "0.16.
|
|
67
|
+
"@lexical/headless": "0.16.1",
|
|
68
|
+
"@lexical/link": "0.16.1",
|
|
69
|
+
"@lexical/list": "0.16.1",
|
|
70
|
+
"@lexical/mark": "0.16.1",
|
|
71
|
+
"@lexical/markdown": "0.16.1",
|
|
72
|
+
"@lexical/react": "0.16.1",
|
|
73
|
+
"@lexical/rich-text": "0.16.1",
|
|
74
|
+
"@lexical/selection": "0.16.1",
|
|
75
|
+
"@lexical/utils": "0.16.1",
|
|
76
|
+
"lexical": "0.16.1",
|
|
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/
|
|
80
|
-
"@payloadcms/
|
|
81
|
-
"@payloadcms/
|
|
82
|
-
"payload": "3.0.0-beta.
|
|
79
|
+
"@payloadcms/translations": "3.0.0-beta.57",
|
|
80
|
+
"@payloadcms/next": "3.0.0-beta.57",
|
|
81
|
+
"@payloadcms/ui": "3.0.0-beta.57",
|
|
82
|
+
"payload": "3.0.0-beta.57"
|
|
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,YAAAN,CAAY,EAAIJ,EAAU,EAC5B,CAAE,KAAAc,CAAK,EAAIf,EAAQ,EACnB,CAAE,gBAAAgB,CAAgB,EAAId,EAAoB,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wB,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,cAAAC,GACA,gB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-
"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
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/blocks/component/index.tsx", "../../../src/features/blocks/component/BlockContent.tsx", "../../../src/features/blocks/component/FormSavePlugin.tsx", "../../../src/features/blocks/component/removeEmptyArrayValues.ts"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport type { FormProps } from '@payloadcms/ui'\n\nimport {\n Collapsible,\n Form,\n Pill,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { type BlockFields } from '../nodes/BlocksNode.js'\nconst baseClass = 'lexical-block'\nimport type { ReducedBlock } from '@payloadcms/ui/utilities/buildComponentMap'\nimport type { FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { ClientComponentProps } from '../../typesClient.js'\nimport type { BlocksFeatureClientProps } from '../feature.client.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { BlockContent } from './BlockContent.js'\ntype Props = {\n children?: React.ReactNode\n\n formData: BlockFields\n nodeKey?: string\n /**\n * This transformedFormData already comes wrapped in blockFieldWrapperName\n */\n transformedFormData: BlockFields\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const config = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { editorConfig, field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<FormState | false>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const componentMapRenderedFieldsPath = `feature.blocks.fields.${formData?.blockType}`\n const schemaFieldsPath = `${schemaPath}.feature.blocks.${formData?.blockType}`\n\n const reducedBlock: ReducedBlock = (\n editorConfig?.resolvedFeatureMap?.get('blocks')\n ?.sanitizedClientFeatureProps as ClientComponentProps<BlocksFeatureClientProps>\n )?.reducedBlocks?.find((block) => block.slug === formData?.blockType)\n\n const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath)\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const state = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: JSON.parse(JSON.stringify(formData)),\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n if (state) {\n setInitialState({\n ...state,\n blockName: {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n })\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id])\n\n const onChange: FormProps['onChange'][0] = useCallback(\n async ({ formState: prevFormState }) => {\n const formState = 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 return {\n ...formState,\n blockName: {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n },\n\n [config.routes.api, config.serverURL, schemaFieldsPath, id, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return reducedBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n // @ts-expect-error TODO: Fix this\n fields={fieldMap}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={Array.isArray(fieldMap) ? fieldMap : []}\n nodeKey={nodeKey}\n path={`${path}.feature.blocks.${formData.blockType}`}\n reducedBlock={reducedBlock}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof reducedBlock.labels.singular === 'string'\n ? getTranslation(reducedBlock.labels.singular, i18n)\n : '[Singular Label]'}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={parentLexicalRichTextField?.readOnly} />\n </div>\n </div>\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n classNames,\n fieldMap,\n parentLexicalRichTextField,\n nodeKey,\n i18n,\n submitted,\n initialState,\n reducedBlock,\n onChange,\n schemaFieldsPath,\n path,\n ]) // Adding formData to the dependencies here might break it\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n", "import type { FormFieldBase } from '@payloadcms/ui'\nimport type { FieldMap, ReducedBlock } from '@payloadcms/ui/utilities/buildComponentMap'\nimport type { CollapsedPreferences, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite' // lite: no need for Map and Set support\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { SanitizedClientEditorConfig } from '../../../lexical/config/types.js'\nimport type { BlockFields, BlockNode } from '../nodes/BlocksNode.js'\n\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n formData: BlockFields\n formSchema: FieldMap\n nodeKey: string\n path: string\n reducedBlock: ReducedBlock\n schemaPath: string\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const {\n baseClass,\n field,\n formData,\n formSchema,\n nodeKey,\n reducedBlock: { labels },\n schemaPath,\n } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => {\n newFormData = {\n ...newFormData,\n id: formData.id,\n blockType: formData.blockType,\n }\n\n // Recursively remove all undefined values from even being present in formData, as they will\n // cause isDeepEqual to return false if, for example, formData has a key that fields.data\n // does not have, even if it's undefined.\n // Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n // Inside of fields.data however, that sub-blocks blockName property does not exist at all.\n function removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n }\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node: BlockNode = $getNodeByKey(nodeKey)\n if (node) {\n node.setFields(newFormData as BlockFields)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof labels.singular === 'string'\n ? getTranslation(labels.singular, i18n)\n : '[Singular Label]'}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.readOnly} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fieldMap={Array.isArray(formSchema) ? formSchema : []}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n", "import type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from '@payloadcms/ui/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n", "import type { FormState } from 'payload'\n\n/**\n * By default, if an array field is empty, it will be included in the form state with a value of 0.\n * We do not need this behavior here, By setting `disableFormData` to true, we can prevent the field from being included in the form state\n * like that.\n * @param fields form state\n */\nexport function removeEmptyArrayValues({ fields }: { fields: FormState }): FormState {\n for (const key in fields) {\n const field = fields[key]\n if (Array.isArray(field.rows) && 'value' in field) {\n field.disableFormData = true\n }\n }\n return fields\n}\n"],
|
|
5
|
-
"mappings": "qDAIA,OACE,eAAAA,GACA,QAAAC,GACA,QAAAC,GACA,gBAAAC,GACA,iBAAAC,GACA,aAAAC,GACA,mBAAAC,GACA,iBAAAC,GACA,oBAAAC,GACA,kBAAAC,OACK,iBACP,OAAgB,eAAAC,GAAa,aAAAC,GAAW,WAAAC,GAAS,YAAAC,OAAgB,QAOjE,OAAS,kBAAAC,OAAsB,2BAC/B,OAAS,gBAAAC,MAAoB,wBAC7B,OAAS,MAAM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ACF,EAEAxB,EAAC0C,GAAA,CACC,UAAWN,EACX,iBAAiB,UACjB,OACEpC,EAAC,OAAI,UAAW,GAAGE,CAAS,iBAC1B,SAAAD,GAAC,OACC,UAAAD,EAAC2C,GAAA,CACC,UAAW,GAAGzC,CAAS,gBAAgBA,CAAS,gBAAgBG,GAAU,SAAS,GACnF,UAAU,QAET,gBAAOoB,EAAa,OAAO,UAAa,SACrCmB,GAAenB,EAAa,OAAO,SAAUS,CAAI,EACjD,mBACN,EACAlC,EAAC6C,GAAA,CAAa,KAAK,YAAY,SAAU5B,GAA4B,SAAU,GACjF,EACF,EAIF,SAAAjB,EAAC8C,GAAA,CAAc,OAAO,OAAO,GAFxB,CAGP,EAED,CACDV,EACAT,EACAV,EACAX,EACA4B,EACAzB,EACAU,EACAM,EACAM,EACAP,EACAX,CACF,CAAC,EACD,OAAOb,EAAC,OAAI,UAAWE,EAAY,IAAMA,EAAY,IAAMG,EAAS,UAAY,SAAAgC,EAAY,CAC9F",
|
|
6
|
-
"names": ["Collapsible", "Form", "Pill", "SectionTitle", "ShimmerEffect", "useConfig", "useDocumentInfo", "useFieldProps", "useFormSubmitted", "useTranslation", "useCallback", "useEffect", "useMemo", "useState", "getTranslation", "getFormState", "uuid", "useLexicalComposerContext", "getTranslation", "Button", "Collapsible", "ErrorPill", "Pill", "RenderFields", "SectionTitle", "useDocumentInfo", "useFormSubmitted", "useTranslation", "dequal", "$getNodeByKey", "React", "useCallback", "useAllFormFields", "reduceFieldsToValues", "useEffect", "removeEmptyArrayValues", "fields", "key", "field", "FormSavePlugin", "props", "onChange", "_fields", "useAllFormFields", "fields", "removeEmptyArrayValues", "newFormData", "reduceFieldsToValues", "useEffect", "jsx", "jsxs", "BlockContent", "props", "baseClass", "field", "formData", "formSchema", "nodeKey", "labels", "schemaPath", "i18n", "useTranslation", "editor", "useLexicalComposerContext", "getDocPreferences", "setDocFieldPreferences", "useDocumentInfo", "isCollapsed", "setIsCollapsed", "React", "initialState", "currentDocPreferences", "collapsedArray", "hasSubmitted", "useFormSubmitted", "errorCount", "setErrorCount", "fieldHasErrors", "classNames", "onFormChange", "useCallback", "fullFieldsWithValues", "newFormData", "removeUndefinedAndNullAndEmptyArraysRecursively", "obj", "key", "value", "dequal", "node", "$getNodeByKey", "rowErrorCount", "formField", "onCollapsedChange", "changedCollapsed", "newCollapsed", "removeBlock", "Collapsible", "Pill", "getTranslation", "SectionTitle", "ErrorPill", "Button", "e", "incomingCollapsedState", "RenderFields", "FormSavePlugin", "jsx", "jsxs", "baseClass", "BlockComponent", "props", "formData", "nodeKey", "config", "useConfig", "submitted", "useFormSubmitted", "id", "useDocumentInfo", "path", "schemaPath", "useFieldProps", "editorConfig", "parentLexicalRichTextField", "useEditorConfigContext", "initialState", "setInitialState", "useState", "richTextComponentMap", "componentMapRenderedFieldsPath", "schemaFieldsPath", "reducedBlock", "block", "fieldMap", "useEffect", "state", "getFormState", "onChange", "useCallback", "prevFormState", "i18n", "useTranslation", "classNames", "formContent", "useMemo", "Form", "uuid", "BlockContent", "Collapsible", "Pill", "getTranslation", "SectionTitle", "ShimmerEffect"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/link/drawer/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,cAAc,CAAA;AACrB,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAA;AAIvC,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA8EtC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/link/drawer/index.tsx"],"sourcesContent":["import type { FormProps } from '@payloadcms/ui'\nimport type { FormState } from 'payload'\n\nimport {\n Drawer,\n Form,\n FormSubmit,\n RenderFields,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useTranslation,\n} from '@payloadcms/ui'\nimport { getFormState } from '@payloadcms/ui/shared'\nimport React, { useCallback, useEffect, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { type Props } from './types.js'\n\nconst baseClass = 'lexical-link-edit-drawer'\n\nexport const LinkDrawer: React.FC<Props> = ({ drawerSlug, handleModalSubmit, stateData }) => {\n const { 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.link.fields.fields`\n const schemaFieldsPath = `${schemaPath}.feature.link.fields`\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: stateData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n }) // Form State\n\n setInitialState(state)\n }\n\n if (stateData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id, stateData])\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 return (\n <Drawer className={baseClass} slug={drawerSlug} title={t('fields:editLink') ?? ''}>\n {initialState !== false && (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fieldMap) ? fieldMap : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleModalSubmit}\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\n <FormSubmit>{t('general:submit')}</FormSubmit>\n </Form>\n )}\n </Drawer>\n )\n}\n"],"names":["Drawer","Form","FormSubmit","RenderFields","useConfig","useDocumentInfo","useFieldProps","useTranslation","getFormState","React","useCallback","useEffect","useState","v4","uuid","useEditorConfigContext","baseClass","LinkDrawer","drawerSlug","handleModalSubmit","stateData","t","id","schemaPath","config","initialState","setInitialState","field","richTextComponentMap","componentMapRenderedFieldsPath","schemaFieldsPath","fieldMap","get","awaitInitialState","state","apiRoute","routes","api","body","data","operation","serverURL","onChange","formState","prevFormState","className","slug","title","beforeSubmit","disableValidationOnSubmit","fields","Array","isArray","onSubmit","forceRender","path","readOnly"],"mappings":";AAGA,SACEA,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,cAAc,QACT,iBAAgB;AACvB,SAASC,YAAY,QAAQ,wBAAuB;AACpD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC/D,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAEjC,SAASC,sBAAsB,QAAQ,yDAAwD;AAI/F,MAAMC,YAAY;AAElB,OAAO,MAAMC,aAA8B,CAAC,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,SAAS,EAAE;IACtF,MAAM,EAAEC,CAAC,EAAE,GAAGd;IACd,MAAM,EAAEe,EAAE,EAAE,GAAGjB;IACf,MAAM,EAAEkB,UAAU,EAAE,GAAGjB;IACvB,MAAMkB,SAASpB;IACf,MAAM,CAACqB,cAAcC,gBAAgB,GAAGd,SAA4B;IACpE,MAAM,EACJe,OAAO,EAAEC,oBAAoB,EAAE,EAChC,GAAGb;IAEJ,MAAMc,iCAAiC,CAAC,0BAA0B,CAAC;IACnE,MAAMC,mBAAmB,CAAC,EAAEP,WAAW,oBAAoB,CAA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;8BAAYmB,EAAE;;;;;AAKzB,EAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { FormState } from 'payload';
|
|
2
|
-
import type { LinkFields } from '../nodes/types.js';
|
|
3
|
-
export interface Props {
|
|
4
|
-
drawerSlug: string;
|
|
5
|
-
handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void;
|
|
6
|
-
stateData: {} | (LinkFields & {
|
|
7
|
-
text: string;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/features/link/drawer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,WAAW,KAAK;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;IAC7E,SAAS,EAAE,EAAE,GAAG,CAAC,UAAU,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAChD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/link/drawer/types.ts"],"sourcesContent":["import type { FormState } from 'payload'\n\nimport type { LinkFields } from '../nodes/types.js'\n\nexport interface Props {\n drawerSlug: string\n handleModalSubmit: (fields: FormState, data: Record<string, unknown>) => void\n stateData: {} | (LinkFields & { text: string })\n}\n"],"names":[],"mappings":"AAIA,WAIC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ClientCollectionConfig } from 'payload';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type { ElementProps } from '../index.js';
|
|
4
|
-
/**
|
|
5
|
-
* This handles the extra fields, e.g. captions or alt text, which are
|
|
6
|
-
* potentially added to the upload feature.
|
|
7
|
-
*/
|
|
8
|
-
export declare const ExtraFieldsUploadDrawer: React.FC<ElementProps & {
|
|
9
|
-
drawerSlug: string;
|
|
10
|
-
relatedCollection: ClientCollectionConfig;
|
|
11
|
-
}>;
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/upload/component/ExtraFieldsDrawer/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAa,MAAM,SAAS,CAAA;AAkBhE,OAAO,KAA2C,MAAM,OAAO,CAAA;AAI/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC5C,YAAY,GAAG;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,sBAAsB,CAAA;CAC1C,CAgHF,CAAA"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
4
|
-
import { getTranslation } from '@payloadcms/translations';
|
|
5
|
-
import { Drawer, Form, FormSubmit, RenderFields, useConfig, useDocumentInfo, useFieldProps, useModal, useTranslation } from '@payloadcms/ui';
|
|
6
|
-
import { getFormState } from '@payloadcms/ui/shared';
|
|
7
|
-
import { $getNodeByKey } from 'lexical';
|
|
8
|
-
import { deepCopyObject } from 'payload/shared';
|
|
9
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
10
|
-
import { v4 as uuid } from 'uuid';
|
|
11
|
-
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
12
|
-
/**
|
|
13
|
-
* This handles the extra fields, e.g. captions or alt text, which are
|
|
14
|
-
* potentially added to the upload feature.
|
|
15
|
-
*/ export const ExtraFieldsUploadDrawer = (props)=>{
|
|
16
|
-
const { data: { fields, relationTo, value }, drawerSlug, nodeKey, relatedCollection } = props;
|
|
17
|
-
const [editor] = useLexicalComposerContext();
|
|
18
|
-
const { closeModal } = useModal();
|
|
19
|
-
const { i18n, t } = useTranslation();
|
|
20
|
-
const { id } = useDocumentInfo();
|
|
21
|
-
const { schemaPath } = useFieldProps();
|
|
22
|
-
const config = useConfig();
|
|
23
|
-
const [initialState, setInitialState] = useState(false);
|
|
24
|
-
const { field: { richTextComponentMap } } = useEditorConfigContext();
|
|
25
|
-
const componentMapRenderedFieldsPath = `feature.upload.fields.${relatedCollection.slug}`;
|
|
26
|
-
const schemaFieldsPath = `${schemaPath}.feature.upload.${relatedCollection.slug}`;
|
|
27
|
-
const fieldMap = richTextComponentMap.get(componentMapRenderedFieldsPath) // Field Schema
|
|
28
|
-
;
|
|
29
|
-
useEffect(()=>{
|
|
30
|
-
const awaitInitialState = async ()=>{
|
|
31
|
-
const state = await getFormState({
|
|
32
|
-
apiRoute: config.routes.api,
|
|
33
|
-
body: {
|
|
34
|
-
id,
|
|
35
|
-
data: deepCopyObject(fields || {}),
|
|
36
|
-
operation: 'update',
|
|
37
|
-
schemaPath: schemaFieldsPath
|
|
38
|
-
},
|
|
39
|
-
serverURL: config.serverURL
|
|
40
|
-
}) // Form State
|
|
41
|
-
;
|
|
42
|
-
setInitialState(state);
|
|
43
|
-
};
|
|
44
|
-
void awaitInitialState();
|
|
45
|
-
}, [
|
|
46
|
-
config.routes.api,
|
|
47
|
-
config.serverURL,
|
|
48
|
-
schemaFieldsPath,
|
|
49
|
-
id,
|
|
50
|
-
fields
|
|
51
|
-
]);
|
|
52
|
-
const onChange = useCallback(async ({ formState: prevFormState })=>{
|
|
53
|
-
return await getFormState({
|
|
54
|
-
apiRoute: config.routes.api,
|
|
55
|
-
body: {
|
|
56
|
-
id,
|
|
57
|
-
formState: prevFormState,
|
|
58
|
-
operation: 'update',
|
|
59
|
-
schemaPath: schemaFieldsPath
|
|
60
|
-
},
|
|
61
|
-
serverURL: config.serverURL
|
|
62
|
-
});
|
|
63
|
-
}, [
|
|
64
|
-
config.routes.api,
|
|
65
|
-
config.serverURL,
|
|
66
|
-
schemaFieldsPath,
|
|
67
|
-
id
|
|
68
|
-
]);
|
|
69
|
-
const handleUpdateEditData = useCallback((_, data)=>{
|
|
70
|
-
// Update lexical node (with key nodeKey) with new data
|
|
71
|
-
editor.update(()=>{
|
|
72
|
-
const uploadNode = $getNodeByKey(nodeKey);
|
|
73
|
-
if (uploadNode) {
|
|
74
|
-
const newData = {
|
|
75
|
-
...uploadNode.getData(),
|
|
76
|
-
fields: data
|
|
77
|
-
};
|
|
78
|
-
uploadNode.setData(newData);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
closeModal(drawerSlug);
|
|
82
|
-
}, [
|
|
83
|
-
closeModal,
|
|
84
|
-
editor,
|
|
85
|
-
drawerSlug,
|
|
86
|
-
nodeKey
|
|
87
|
-
]);
|
|
88
|
-
return /*#__PURE__*/ _jsx(Drawer, {
|
|
89
|
-
slug: drawerSlug,
|
|
90
|
-
title: t('general:editLabel', {
|
|
91
|
-
label: getTranslation(relatedCollection.labels.singular, i18n)
|
|
92
|
-
}),
|
|
93
|
-
children: initialState !== false && /*#__PURE__*/ _jsxs(Form, {
|
|
94
|
-
beforeSubmit: [
|
|
95
|
-
onChange
|
|
96
|
-
],
|
|
97
|
-
disableValidationOnSubmit: true,
|
|
98
|
-
// @ts-expect-error TODO: Fix this
|
|
99
|
-
fields: fieldMap,
|
|
100
|
-
initialState: initialState,
|
|
101
|
-
onChange: [
|
|
102
|
-
onChange
|
|
103
|
-
],
|
|
104
|
-
onSubmit: handleUpdateEditData,
|
|
105
|
-
uuid: uuid(),
|
|
106
|
-
children: [
|
|
107
|
-
/*#__PURE__*/ _jsx(RenderFields, {
|
|
108
|
-
fieldMap: Array.isArray(fieldMap) ? fieldMap : [],
|
|
109
|
-
forceRender: true,
|
|
110
|
-
path: "" // See Blocks feature path for details as for why this is empty
|
|
111
|
-
,
|
|
112
|
-
readOnly: false,
|
|
113
|
-
schemaPath: schemaFieldsPath
|
|
114
|
-
}),
|
|
115
|
-
/*#__PURE__*/ _jsx(FormSubmit, {
|
|
116
|
-
children: t('fields:saveChanges')
|
|
117
|
-
})
|
|
118
|
-
]
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/upload/component/ExtraFieldsDrawer/index.tsx"],"sourcesContent":["'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"],"names":["useLexicalComposerContext","getTranslation","Drawer","Form","FormSubmit","RenderFields","useConfig","useDocumentInfo","useFieldProps","useModal","useTranslation","getFormState","$getNodeByKey","deepCopyObject","React","useCallback","useEffect","useState","v4","uuid","useEditorConfigContext","ExtraFieldsUploadDrawer","props","data","fields","relationTo","value","drawerSlug","nodeKey","relatedCollection","editor","closeModal","i18n","t","id","schemaPath","config","initialState","setInitialState","field","richTextComponentMap","componentMapRenderedFieldsPath","slug","schemaFieldsPath","fieldMap","get","awaitInitialState","state","apiRoute","routes","api","body","operation","serverURL","onChange","formState","prevFormState","handleUpdateEditData","_","update","uploadNode","newData","getData","setData","title","label","labels","singular","beforeSubmit","disableValidationOnSubmit","onSubmit","Array","isArray","forceRender","path","readOnly"],"mappings":"AAAA;;AAIA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SACEC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,QAAQ,EACRC,cAAc,QACT,iBAAgB;AACvB,SAASC,YAAY,QAAQ,wBAAuB;AACpD,SAASC,aAAa,QAAQ,UAAS;AACvC,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAC/D,SAASC,MAAMC,IAAI,QAAQ,OAAM;AAKjC,SAASC,sBAAsB,QAAQ,4DAA2D;AAElG;;;CAGC,GACD,OAAO,MAAMC,0BAKT,CAACC;IACH,MAAM,EACJC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAA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WjB,OAAOiB,SAAS;QAC7B;IACF,GAEA;QAACjB,OAAOa,MAAM,CAACC,GAAG;QAAEd,OAAOiB,SAAS;QAAEV;QAAkBT;KAAG;IAG7D,MAAMuB,uBAAuB1C,YAC3B,CAAC2C,GAAGnC;QACF,uDAAuD;QACvDO,OAAO6B,MAAM,CAAC;YACZ,MAAMC,aAAgChD,cAAcgB;YACpD,IAAIgC,YAAY;gBACd,MAAMC,UAAsB;oBAC1B,GAAGD,WAAWE,OAAO,EAAE;oBACvBtC,QAAQD;gBACV;gBACAqC,WAAWG,OAAO,CAACF;YACrB;QACF;QAEA9B,WAAWJ;IACb,GACA;QAACI;QAAYD;QAAQH;QAAYC;KAAQ;IAG3C,qBACE,KAAC1B;QACCwC,MAAMf;QACNqC,OAAO/B,EAAE,qBAAqB;YAC5BgC,OAAOhE,eAAe4B,kBAAkBqC,MAAM,CAACC,QAAQ,EAAEnC;QAC3D;kBAECK,iBAAiB,uBAChB,MAAClC;YACCiE,cAAc;gBAACd;aAAS;YACxBe,yBAAyB;YACzB,kCAAkC;YAClC7C,QAAQoB;YACRP,cAAcA;YACdiB,UAAU;gBAACA;aAAS;YACpBgB,UAAUb;YACVtC,MAAMA;;8BAEN,KAACd;oBACCuC,UAAU2B,MAAMC,OAAO,CAAC5B,YAAYA,WAAW,EAAE;oBACjD6B,WAAW;oBACXC,MAAK,GAAG,+DAA+D;;oBACvEC,UAAU;oBACVxC,YAAYQ;;8BAEd,KAACvC;8BAAY6B,EAAE;;;;;AAKzB,EAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Field } from 'payload';
|
|
2
|
-
type NestedRichTextFieldsArgs = {
|
|
3
|
-
data: unknown;
|
|
4
|
-
fields: Field[];
|
|
5
|
-
found: number;
|
|
6
|
-
};
|
|
7
|
-
export declare const migrateDocumentFields: ({ data, fields, found, }: NestedRichTextFieldsArgs) => number;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=recurse.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recurse.d.ts","sourceRoot":"","sources":["../../../src/utilities/migrateSlateToLexical/recurse.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,qBAAqB,6BAI/B,wBAAwB,KAAG,MAwF7B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utilities/migrateSlateToLexical/recurse.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 migrateDocumentFields = ({\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 migrateDocumentFields({\n data: data[field.name],\n fields: field.fields,\n found,\n })\n } else {\n migrateDocumentFields({\n data,\n found,\n\n fields: field.fields,\n })\n }\n } else if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n migrateDocumentFields({\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 migrateDocumentFields({\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 migrateDocumentFields({\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","migrateDocumentFields","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;AASnG,OAAO,MAAMC,wBAAwB,CAAC,EACpCC,IAAI,EACJC,MAAM,EACNC,KAAK,EACoB;IACzB,KAAK,MAAMC,SAASF,OAAQ;QAC1B,IAAIL,kBAAkBO,UAAU,CAACN,iBAAiBM,QAAQ;YACxD,IAAIR,iBAAiBQ,UAAU,OAAOH,IAAI,CAACG,MAAMC,IAAI,CAAC,KAAK,UAAU;gBACnEL,sBAAsB;oBACpBC,MAAMA,IAAI,CAACG,MAAMC,IAAI,CAAC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