@payloadcms/richtext-lexical 3.23.0 → 3.24.0-canary.1cfcb91
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/dependencyChecker.spec.js +0 -2
- package/dist/dependencyChecker.spec.js.map +1 -1
- package/dist/exports/client/{Field-ZQTPXWY3.js → Field-NNWFQETL.js} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-EE27FURT.js +2 -0
- package/dist/exports/client/chunk-EE27FURT.js.map +7 -0
- package/dist/exports/client/chunk-OZ6Q4DWN.js +12 -0
- package/dist/exports/client/chunk-OZ6Q4DWN.js.map +7 -0
- package/dist/exports/client/componentInline-XEH2GDVO.js +2 -0
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/components/RichText/converter/converters/table.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/table.js +10 -7
- package/dist/exports/react/components/RichText/converter/converters/table.js.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/upload.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/upload.js +14 -10
- package/dist/exports/react/components/RichText/converter/converters/upload.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +5 -2
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +5 -2
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +3 -2
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +3 -3
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +58 -38
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts +5 -0
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js +8 -2
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/converters/html/field/index.d.ts.map +1 -1
- package/dist/features/converters/html/field/index.js +3 -43
- package/dist/features/converters/html/field/index.js.map +1 -1
- package/dist/features/experimental_table/server/index.js +1 -1
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +23 -7
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js +3 -2
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/upload/server/feature.server.d.ts.map +1 -1
- package/dist/features/upload/server/feature.server.js +4 -3
- package/dist/features/upload/server/feature.server.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +19 -8
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js +5 -4
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js +5 -5
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.js +6 -5
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +6 -4
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +4 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +1 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/index.js +8 -4
- package/dist/utilities/migrateSlateToLexical/index.js.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts +3 -2
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js +18 -13
- package/dist/utilities/migrateSlateToLexical/migrateDocumentFieldsRecursively.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/index.js +8 -4
- package/dist/utilities/upgradeLexicalData/index.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts +3 -2
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.d.ts.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +18 -13
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/dist/validate/hasText.js +1 -1
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +7 -17
- package/dist/exports/client/chunk-CIY6PKN6.js +0 -12
- package/dist/exports/client/chunk-CIY6PKN6.js.map +0 -7
- package/dist/exports/client/chunk-KEEUF5NK.js +0 -2
- package/dist/exports/client/chunk-KEEUF5NK.js.map +0 -7
- package/dist/exports/client/componentInline-UG3ZWWJY.js +0 -2
- /package/dist/exports/client/{Field-ZQTPXWY3.js.map → Field-NNWFQETL.js.map} +0 -0
- /package/dist/exports/client/{componentInline-UG3ZWWJY.js.map → componentInline-XEH2GDVO.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAC3C,uBAAuB,GAAG,mBAAmB,GAAG,sBAAsB,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAC3C,uBAAuB,GAAG,mBAAmB,GAAG,sBAAsB,CAgDvE,CAAA"}
|
|
@@ -7,13 +7,16 @@ export const TableJSXConverter = {
|
|
|
7
7
|
const children = nodesToJSX({
|
|
8
8
|
nodes: node.children
|
|
9
9
|
});
|
|
10
|
-
return /*#__PURE__*/_jsx("
|
|
11
|
-
className: "lexical-table",
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
return /*#__PURE__*/_jsx("div", {
|
|
11
|
+
className: "lexical-table-container",
|
|
12
|
+
children: /*#__PURE__*/_jsx("table", {
|
|
13
|
+
className: "lexical-table",
|
|
14
|
+
style: {
|
|
15
|
+
borderCollapse: 'collapse'
|
|
16
|
+
},
|
|
17
|
+
children: /*#__PURE__*/_jsx("tbody", {
|
|
18
|
+
children: children
|
|
19
|
+
})
|
|
17
20
|
})
|
|
18
21
|
});
|
|
19
22
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.js","names":["TableJSXConverter","table","node","nodesToJSX","children","nodes","_jsx","className","style","borderCollapse","tablecell","TagName","headerState","headerStateClass","backgroundColor","undefined","border","padding","colSpan","rowSpan","tablerow"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/table.tsx"],"sourcesContent":["import type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const TableJSXConverter: JSXConverters<\n SerializedTableCellNode | SerializedTableNode | SerializedTableRowNode\n> = {\n table: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n return (\n <table className=\"lexical-table\" style={{ borderCollapse: 'collapse' }}>\n
|
|
1
|
+
{"version":3,"file":"table.js","names":["TableJSXConverter","table","node","nodesToJSX","children","nodes","_jsx","className","style","borderCollapse","tablecell","TagName","headerState","headerStateClass","backgroundColor","undefined","border","padding","colSpan","rowSpan","tablerow"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/table.tsx"],"sourcesContent":["import type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const TableJSXConverter: JSXConverters<\n SerializedTableCellNode | SerializedTableNode | SerializedTableRowNode\n> = {\n table: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n return (\n <div className=\"lexical-table-container\">\n <table className=\"lexical-table\" style={{ borderCollapse: 'collapse' }}>\n <tbody>{children}</tbody>\n </table>\n </div>\n )\n },\n tablecell: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const TagName = node.headerState > 0 ? 'th' : 'td' // Use capital letter to denote a component\n const headerStateClass = `lexical-table-cell-header-${node.headerState}`\n const style = {\n backgroundColor: node.backgroundColor || undefined, // Use undefined to avoid setting the style property if not needed\n border: '1px solid #ccc',\n padding: '8px',\n }\n\n // Note: JSX does not support setting attributes directly as strings, so you must convert the colSpan and rowSpan to numbers\n const colSpan = node.colSpan && node.colSpan > 1 ? node.colSpan : undefined\n const rowSpan = node.rowSpan && node.rowSpan > 1 ? node.rowSpan : undefined\n\n return (\n <TagName\n className={`lexical-table-cell ${headerStateClass}`}\n colSpan={colSpan} // colSpan and rowSpan will only be added if they are not null\n rowSpan={rowSpan}\n style={style}\n >\n {children}\n </TagName>\n )\n },\n tablerow: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n return <tr className=\"lexical-table-row\">{children}</tr>\n },\n}\n"],"mappings":";AAOA,OAAO,MAAMA,iBAAA,GAET;EACFC,KAAA,EAAOA,CAAC;IAAEC,IAAI;IAAEC;EAAU,CAAE;IAC1B,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IACA,oBACEE,IAAA,CAAC;MAAIC,SAAA,EAAU;gBACb,aAAAD,IAAA,CAAC;QAAMC,SAAA,EAAU;QAAgBC,KAAA,EAAO;UAAEC,cAAA,EAAgB;QAAW;kBACnE,aAAAH,IAAA,CAAC;oBAAOF;;;;EAIhB;EACAM,SAAA,EAAWA,CAAC;IAAER,IAAI;IAAEC;EAAU,CAAE;IAC9B,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,MAAMO,OAAA,GAAUT,IAAA,CAAKU,WAAW,GAAG,IAAI,OAAO,KAAK;IAAA;IACnD,MAAMC,gBAAA,GAAmB,6BAA6BX,IAAA,CAAKU,WAAW,EAAE;IACxE,MAAMJ,KAAA,GAAQ;MACZM,eAAA,EAAiBZ,IAAA,CAAKY,eAAe,IAAIC,SAAA;MACzCC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;IAEA;IACA,MAAMC,OAAA,GAAUhB,IAAA,CAAKgB,OAAO,IAAIhB,IAAA,CAAKgB,OAAO,GAAG,IAAIhB,IAAA,CAAKgB,OAAO,GAAGH,SAAA;IAClE,MAAMI,OAAA,GAAUjB,IAAA,CAAKiB,OAAO,IAAIjB,IAAA,CAAKiB,OAAO,GAAG,IAAIjB,IAAA,CAAKiB,OAAO,GAAGJ,SAAA;IAElE,oBACET,IAAA,CAACK,OAAA;MACCJ,SAAA,EAAW,sBAAsBM,gBAAA,EAAkB;MACnDK,OAAA,EAASA,OAAA;MACTC,OAAA,EAASA,OAAA;MACTX,KAAA,EAAOA,KAAA;gBAENJ;;EAGP;EACAgB,QAAA,EAAUA,CAAC;IAAElB,IAAI;IAAEC;EAAU,CAAE;IAC7B,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IACA,oBAAOE,IAAA,CAAC;MAAGC,SAAA,EAAU;gBAAqBH;;EAC5C;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAAC,oBAAoB,CA+ElE,CAAA"}
|
|
@@ -3,27 +3,31 @@ export const UploadJSXConverter = {
|
|
|
3
3
|
upload: ({
|
|
4
4
|
node
|
|
5
5
|
}) => {
|
|
6
|
+
// TO-DO (v4): SerializedUploadNode should use UploadData_P4
|
|
6
7
|
const uploadDocument = node;
|
|
7
|
-
|
|
8
|
+
if (typeof uploadDocument.value !== 'object') {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const url = uploadDocument.value.url;
|
|
8
12
|
/**
|
|
9
13
|
* If the upload is not an image, return a link to the upload
|
|
10
14
|
*/
|
|
11
|
-
if (!uploadDocument
|
|
15
|
+
if (!uploadDocument.value.mimeType.startsWith('image')) {
|
|
12
16
|
return /*#__PURE__*/_jsx("a", {
|
|
13
17
|
href: url,
|
|
14
18
|
rel: "noopener noreferrer",
|
|
15
|
-
children: uploadDocument.value
|
|
19
|
+
children: uploadDocument.value.filename
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* If the upload is a simple image with no different sizes, return a simple img tag
|
|
20
24
|
*/
|
|
21
|
-
if (!
|
|
25
|
+
if (!Object.keys(uploadDocument.value.sizes).length) {
|
|
22
26
|
return /*#__PURE__*/_jsx("img", {
|
|
23
|
-
alt: uploadDocument
|
|
24
|
-
height: uploadDocument
|
|
27
|
+
alt: uploadDocument.value.filename,
|
|
28
|
+
height: uploadDocument.value.height,
|
|
25
29
|
src: url,
|
|
26
|
-
width: uploadDocument
|
|
30
|
+
width: uploadDocument.value.width
|
|
27
31
|
});
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
@@ -31,10 +35,10 @@ export const UploadJSXConverter = {
|
|
|
31
35
|
*/
|
|
32
36
|
const pictureJSX = [];
|
|
33
37
|
// Iterate through each size in the data.sizes object
|
|
34
|
-
for (const size in uploadDocument.value
|
|
35
|
-
const imageSize = uploadDocument.value
|
|
38
|
+
for (const size in uploadDocument.value.sizes) {
|
|
39
|
+
const imageSize = uploadDocument.value.sizes[size];
|
|
36
40
|
// Skip if any property of the size object is null
|
|
37
|
-
if (!imageSize.width || !imageSize.height || !imageSize.mimeType || !imageSize.filesize || !imageSize.filename || !imageSize.url) {
|
|
41
|
+
if (!imageSize || !imageSize.width || !imageSize.height || !imageSize.mimeType || !imageSize.filesize || !imageSize.filename || !imageSize.url) {
|
|
38
42
|
continue;
|
|
39
43
|
}
|
|
40
44
|
const imageSizeURL = imageSize?.url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":["UploadJSXConverter","upload","node","uploadDocument","
|
|
1
|
+
{"version":3,"file":"upload.js","names":["UploadJSXConverter","upload","node","uploadDocument","value","url","mimeType","startsWith","_jsx","href","rel","filename","Object","keys","sizes","length","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","media","srcSet","type"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"sourcesContent":["import type { FileSizeImproved } from 'payload'\n\nimport type { UploadDataImproved } from '../../../../../../features/upload/server/nodes/UploadNode.js'\nimport type { SerializedUploadNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n // TO-DO (v4): SerializedUploadNode should use UploadData_P4\n const uploadDocument = node as UploadDataImproved\n if (typeof uploadDocument.value !== 'object') {\n return null\n }\n const url = uploadDocument.value.url\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument.value.mimeType.startsWith('image')) {\n return (\n <a href={url} rel=\"noopener noreferrer\">\n {uploadDocument.value.filename}\n </a>\n )\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!Object.keys(uploadDocument.value.sizes).length) {\n return (\n <img\n alt={uploadDocument.value.filename}\n height={uploadDocument.value.height}\n src={url}\n width={uploadDocument.value.width}\n />\n )\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n const pictureJSX: React.ReactNode[] = []\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.value.sizes) {\n const imageSize = uploadDocument.value.sizes[size] as FileSizeImproved\n\n // Skip if any property of the size object is null\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL = imageSize?.url\n\n pictureJSX.push(\n <source\n key={size}\n media={`(max-width: ${imageSize.width}px)`}\n srcSet={imageSizeURL}\n type={imageSize.mimeType}\n ></source>,\n )\n }\n\n // Add the default img tag\n pictureJSX.push(\n <img\n alt={uploadDocument.value?.filename}\n height={uploadDocument.value?.height}\n key={'image'}\n src={url}\n width={uploadDocument.value?.width}\n />,\n )\n return <picture>{pictureJSX}</picture>\n },\n}\n"],"mappings":";AAMA,OAAO,MAAMA,kBAAA,GAA0D;EACrEC,MAAA,EAAQA,CAAC;IAAEC;EAAI,CAAE;IACf;IACA,MAAMC,cAAA,GAAiBD,IAAA;IACvB,IAAI,OAAOC,cAAA,CAAeC,KAAK,KAAK,UAAU;MAC5C,OAAO;IACT;IACA,MAAMC,GAAA,GAAMF,cAAA,CAAeC,KAAK,CAACC,GAAG;IAEpC;;;IAGA,IAAI,CAACF,cAAA,CAAeC,KAAK,CAACE,QAAQ,CAACC,UAAU,CAAC,UAAU;MACtD,oBACEC,IAAA,CAAC;QAAEC,IAAA,EAAMJ,GAAA;QAAKK,GAAA,EAAI;kBACfP,cAAA,CAAeC,KAAK,CAACO;;IAG5B;IAEA;;;IAGA,IAAI,CAACC,MAAA,CAAOC,IAAI,CAACV,cAAA,CAAeC,KAAK,CAACU,KAAK,EAAEC,MAAM,EAAE;MACnD,oBACEP,IAAA,CAAC;QACCQ,GAAA,EAAKb,cAAA,CAAeC,KAAK,CAACO,QAAQ;QAClCM,MAAA,EAAQd,cAAA,CAAeC,KAAK,CAACa,MAAM;QACnCC,GAAA,EAAKb,GAAA;QACLc,KAAA,EAAOhB,cAAA,CAAeC,KAAK,CAACe;;IAGlC;IAEA;;;IAGA,MAAMC,UAAA,GAAgC,EAAE;IAExC;IACA,KAAK,MAAMC,IAAA,IAAQlB,cAAA,CAAeC,KAAK,CAACU,KAAK,EAAE;MAC7C,MAAMQ,SAAA,GAAYnB,cAAA,CAAeC,KAAK,CAACU,KAAK,CAACO,IAAA,CAAK;MAElD;MACA,IACE,CAACC,SAAA,IACD,CAACA,SAAA,CAAUH,KAAK,IAChB,CAACG,SAAA,CAAUL,MAAM,IACjB,CAACK,SAAA,CAAUhB,QAAQ,IACnB,CAACgB,SAAA,CAAUC,QAAQ,IACnB,CAACD,SAAA,CAAUX,QAAQ,IACnB,CAACW,SAAA,CAAUjB,GAAG,EACd;QACA;MACF;MACA,MAAMmB,YAAA,GAAeF,SAAA,EAAWjB,GAAA;MAEhCe,UAAA,CAAWK,IAAI,cACbjB,IAAA,CAAC;QAECkB,KAAA,EAAO,eAAeJ,SAAA,CAAUH,KAAK,KAAK;QAC1CQ,MAAA,EAAQH,YAAA;QACRI,IAAA,EAAMN,SAAA,CAAUhB;SAHXe,IAAA;IAMX;IAEA;IACAD,UAAA,CAAWK,IAAI,cACbjB,IAAA,CAAC;MACCQ,GAAA,EAAKb,cAAA,CAAeC,KAAK,EAAEO,QAAA;MAC3BM,MAAA,EAAQd,cAAA,CAAeC,KAAK,EAAEa,MAAA;MAE9BC,GAAA,EAAKb,GAAA;MACLc,KAAA,EAAOhB,cAAA,CAAeC,KAAK,EAAEe;OAFxB;IAKT,oBAAOX,IAAA,CAAC;gBAASY;;EACnB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAetE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,OAAO,cAAc,CAAA;AAKrB,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAgiB1C,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
-
import { Button, Collapsible, Drawer, EditDepthProvider, ErrorPill, Form, formatDrawerSlug, FormSubmit, Pill, RenderFields, SectionTitle, useDocumentForm, useDocumentInfo, useEditDepth, useFormSubmitted, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { Button, Collapsible, Drawer, EditDepthProvider, ErrorPill, Form, formatDrawerSlug, FormSubmit, Pill, RenderFields, SectionTitle, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useFormSubmitted, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
5
5
|
import { abortAndIgnore } from '@payloadcms/ui/shared';
|
|
6
6
|
import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
|
|
7
7
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
@@ -44,6 +44,9 @@ export const BlockComponent = props => {
|
|
|
44
44
|
const onChangeAbortControllerRef = useRef(new AbortController());
|
|
45
45
|
const editDepth = useEditDepth();
|
|
46
46
|
const [errorCount, setErrorCount] = React.useState(0);
|
|
47
|
+
const {
|
|
48
|
+
config
|
|
49
|
+
} = useConfig();
|
|
47
50
|
const drawerSlug = formatDrawerSlug({
|
|
48
51
|
slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,
|
|
49
52
|
depth: editDepth
|
|
@@ -152,7 +155,7 @@ export const BlockComponent = props => {
|
|
|
152
155
|
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`;
|
|
153
156
|
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
154
157
|
const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
|
|
155
|
-
const clientBlock = blocksField?.blocks?.[0];
|
|
158
|
+
const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
|
|
156
159
|
const {
|
|
157
160
|
i18n,
|
|
158
161
|
t
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","getTranslation","$getNodeByKey","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","getFormState","schemaFieldsPath","blockType","initialState","setInitialState","formState","blockName","initialValue","passesCondition","valid","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","Object","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","className","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","admin","BlockCollapsible","children","disableBlockName","editButton","fieldHasErrors","Label","removeButton","join","collapsibleStyle","header","_jsxs","pillStyle","path","count","withMessage","isEditable","onToggle","incomingCollapsedState","clientBlockFields","BlockDrawer","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\n\nconst baseClass = 'lexical-block'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport { $getNodeByKey } from 'lexical'\nimport { type BlocksFieldClient, type CollapsedPreferences, type FormState } from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\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 const [editor] = useLexicalComposerContext()\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n return initialLexicalFormState?.[formData.id]?.formState\n ? {\n ...initialLexicalFormState?.[formData.id]?.formState,\n blockName: {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n : false\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel)\n setCustomBlock(state._components?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock = blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel)\n setCustomBlock(newFormState._components?.customComponents?.Block)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n formData.blockType,\n parentDocumentFields,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.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(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={parentLexicalRichTextField?.admin?.readOnly || false}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [parentLexicalRichTextField?.admin?.readOnly, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n children,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n removeButton,\n }: {\n children?: React.ReactNode\n disableBlockName?: boolean\n editButton?: boolean\n errorCount?: number\n fieldHasErrors?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }) => (\n <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ].join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {(Label ?? CustomLabel) ? (\n (Label ?? CustomLabel)\n ) : (\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {blockDisplayName ?? formData?.blockType}\n </Pill>\n {!disableBlockName && (\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && editor.isEditable() ? <RemoveButton /> : null}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n {children}\n </Collapsible>\n </div>\n ),\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n editor,\n formData.blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n parentLexicalRichTextField?.admin?.readOnly,\n ],\n )\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlockFields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockDisplayName,\n t,\n clientBlock?.fields,\n schemaFieldsPath,\n permissions,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n fields={clientBlockFields}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlockFields}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n clientBlockFields,\n RemoveButton,\n EditButton,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className=\"lexical-block-not-found\">\n Error: Block '{formData.blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAE/D,MAAMC,SAAA,GAAY;AAElB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAE9B,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;A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AAA;QACpB;QACAA,SAAA,CAAQjC,SAAS,GAAGhC,QAAA,CAASgC,SAAS;QACtCH,MAAA,CAAOkC,MAAM,CAAC;UACZ,MAAMC,MAAA,GAAO3E,aAAA,CAAcY,OAAA;UAC3B,IAAI+D,MAAA,IAAQtE,YAAA,CAAasE,MAAA,GAAO;YAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA,EAAwB;UACzC;QACF;QACAvC,YAAA;MACF;MACAxB,SAAA,EAAWA,SAAA;MACXX,IAAA,EAAMA,IAAA;gBAEN,aAAAsH,IAAA,CAAClH,YAAA;QACCT,SAAA,EAAWA,SAAA;QACX+J,WAAA,EAAaA,WAAA;QACbvL,WAAA,EAAaoK,gBAAA;QACb9E,WAAA,EAAaA,WAAA;QACb4D,UAAA,EAAYA,UAAA;QACZxF,UAAA,EAAYA,UAAA;QACZuI,UAAA,EAAYX,iBAAA;QACZ/G,YAAA,EAAcA,YAAA;QACdhC,OAAA,EAASA,OAAA;QACT2H,YAAA,EAAcA;;;EAItB,GAAG,CACDE,gBAAA,EACAmB,WAAA,EACAjG,WAAA,EACAgG,iBAAA,EACApB,YAAA,EACAhB,UAAA,EACA/E,MAAA,EACAT,UAAA,EACAM,YAAA,EACAgD,WAAA,EAAa3D,MAAA;EACb;EACAkB,YAAA,EACAhC,OAAA,EACA6E,QAAA,EACA5E,SAAA,CACD;EAED,IAAI,CAACwE,WAAA,EAAa;IAChB,oBACEmC,IAAA,CAACiB,gBAAA;MAAiBE,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAM,KAAA,CAAC;QAAIzB,SAAA,EAAU;mBAA0B,kBACxB/G,QAAA,CAASgC,SAAS,EAAC;;;EAI1C;EAEA,OAAOkB,KAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","getTranslation","$getNodeByKey","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","getFormState","schemaFieldsPath","blockType","initialState","setInitialState","formState","blockName","initialValue","passesCondition","valid","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","Object","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","className","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","admin","BlockCollapsible","children","disableBlockName","editButton","fieldHasErrors","Label","removeButton","join","collapsibleStyle","header","_jsxs","pillStyle","path","count","withMessage","isEditable","onToggle","incomingCollapsedState","clientBlockFields","BlockDrawer","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\n\nconst baseClass = 'lexical-block'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport './index.scss'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\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 const [editor] = useLexicalComposerContext()\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n return initialLexicalFormState?.[formData.id]?.formState\n ? {\n ...initialLexicalFormState?.[formData.id]?.formState,\n blockName: {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n },\n }\n : false\n })\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel)\n setCustomBlock(state._components?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const { i18n, t } = useTranslation<object, string>()\n\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state: newFormState } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel)\n setCustomBlock(newFormState._components?.customComponents?.Block)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n formData.blockType,\n parentDocumentFields,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.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(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={parentLexicalRichTextField?.admin?.readOnly || false}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [parentLexicalRichTextField?.admin?.readOnly, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n children,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n removeButton,\n }: {\n children?: React.ReactNode\n disableBlockName?: boolean\n editButton?: boolean\n errorCount?: number\n fieldHasErrors?: boolean\n /**\n * Override the default label with a custom label\n */\n Label?: React.ReactNode\n removeButton?: boolean\n }) => (\n <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ].join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {(Label ?? CustomLabel) ? (\n (Label ?? CustomLabel)\n ) : (\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {blockDisplayName ?? formData?.blockType}\n </Pill>\n {!disableBlockName && (\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && editor.isEditable() ? <RemoveButton /> : null}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n {children}\n </Collapsible>\n </div>\n ),\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n editor,\n formData.blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n parentLexicalRichTextField?.admin?.readOnly,\n ],\n )\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlockFields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockDisplayName,\n t,\n clientBlock?.fields,\n schemaFieldsPath,\n permissions,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n fields={clientBlockFields}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlockFields}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n clientBlockFields,\n RemoveButton,\n EditButton,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className=\"lexical-block-not-found\">\n Error: Block '{formData.blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAE/D,MAAMC,SAAA,GAAY;AAElB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAO9B,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AAEjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,YAAY,QAAQ;AAC7B,SAASC,sBAAsB,QAAQ;AAavC,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGH,KAAA;EAC3C,MAAMI,SAAA,GAAY3B,gBAAA;EAClB,MAAM;IAAE4B,EAAE;IAAEC,cAAc;IAAEC;EAAU,CAAE,GAAGhC,eAAA;E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AAS;QACtCH,MAAA,CAAOkC,MAAM,CAAC;UACZ,MAAMC,MAAA,GAAO5E,aAAA,CAAcY,OAAA;UAC3B,IAAIgE,MAAA,IAAQvE,YAAA,CAAauE,MAAA,GAAO;YAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA,EAAwB;UACzC;QACF;QACAvC,YAAA;MACF;MACAzB,SAAA,EAAWA,SAAA;MACXX,IAAA,EAAMA,IAAA;gBAEN,aAAAyH,IAAA,CAACrH,YAAA;QACCT,SAAA,EAAWA,SAAA;QACXkK,WAAA,EAAaA,WAAA;QACb3L,WAAA,EAAawK,gBAAA;QACbhF,WAAA,EAAaA,WAAA;QACb8D,UAAA,EAAYA,UAAA;QACZ3F,UAAA,EAAYA,UAAA;QACZ0I,UAAA,EAAYX,iBAAA;QACZjH,YAAA,EAAcA,YAAA;QACdjC,OAAA,EAASA,OAAA;QACT8H,YAAA,EAAcA;;;EAItB,GAAG,CACDE,gBAAA,EACAmB,WAAA,EACAnG,WAAA,EACAkG,iBAAA,EACApB,YAAA,EACAhB,UAAA,EACAjF,MAAA,EACAV,UAAA,EACAO,YAAA,EACAgD,WAAA,EAAa5D,MAAA;EACb;EACAmB,YAAA,EACAjC,OAAA,EACAgF,QAAA,EACA/E,SAAA,CACD;EAED,IAAI,CAACyE,WAAA,EAAa;IAChB,oBACEqC,IAAA,CAACiB,gBAAA;MAAiBE,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAM,KAAA,CAAC;QAAIzB,SAAA,EAAU;mBAA0B,kBACxBlH,QAAA,CAASiC,SAAS,EAAC;;;EAI1C;EAEA,OAAOkB,KAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiE,MAAM,OAAO,CAAA;AAGrF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiE,MAAM,OAAO,CAAA;AAGrF,OAAO,KAAK,EAAwC,SAAS,EAAE,MAAM,SAAS,CAAA;AAuB9E,OAAO,cAAc,CAAA;AAKrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAM/E,KAAK,KAAK,GAAG;IACX;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,KAAK,+BAA+B,GAAG;IACrC,UAAU,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IACrB,YAAY,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;IAC3C,oBAAoB,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,CAAC,CAAA;IAC9D,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAA;CACxB,CAAA;AAMD,eAAO,MAAM,8BAA8B,uCAAsD,CAAA;AAEjG,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmYhD,CAAA"}
|
|
@@ -5,7 +5,7 @@ import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'r
|
|
|
5
5
|
const baseClass = 'inline-block';
|
|
6
6
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
7
7
|
import { getTranslation } from '@payloadcms/translations';
|
|
8
|
-
import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, FormSubmit, RenderFields, ShimmerEffect, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
8
|
+
import { Button, Drawer, EditDepthProvider, Form, formatDrawerSlug, FormSubmit, RenderFields, ShimmerEffect, useConfig, useDocumentForm, useDocumentInfo, useEditDepth, useServerFunctions, useTranslation } from '@payloadcms/ui';
|
|
9
9
|
import { abortAndIgnore } from '@payloadcms/ui/shared';
|
|
10
10
|
import { $getNodeByKey } from 'lexical';
|
|
11
11
|
import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared';
|
|
@@ -83,10 +83,13 @@ export const InlineBlockComponent = props => {
|
|
|
83
83
|
getDocPreferences,
|
|
84
84
|
globalSlug
|
|
85
85
|
} = useDocumentInfo();
|
|
86
|
+
const {
|
|
87
|
+
config
|
|
88
|
+
} = useConfig();
|
|
86
89
|
const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`;
|
|
87
90
|
const clientSchemaMap = featureClientSchemaMap['blocks'];
|
|
88
91
|
const blocksField = clientSchemaMap?.[componentMapRenderedBlockPath]?.[0];
|
|
89
|
-
const clientBlock = blocksField?.blocks?.[0];
|
|
92
|
+
const clientBlock = blocksField.blockReferences ? typeof blocksField?.blockReferences?.[0] === 'string' ? config.blocksMap[blocksField?.blockReferences?.[0]] : blocksField?.blockReferences?.[0] : blocksField?.blocks?.[0];
|
|
90
93
|
const clientBlockFields = clientBlock?.fields ?? [];
|
|
91
94
|
// Open drawer on "mount"
|
|
92
95
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","createContext","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","useContext","InlineBlockComponent","props","cacheBuster","formData","nodeKey","editor","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","permissions","readOnly","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","id","formState","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blocks","clientBlockFields","getKey","length","undefined","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","initialBlockFormState","operation","renderAllFields","signal","newFormStateData","node","newData","setFields","onChange","prevFormState","submit","controller","onFormSubmit","RemoveButton","_jsx","buttonStyle","className","disabled","icon","onClick","e","preventDefault","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","isEditable","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","Provider","value","height","width"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n () => initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock = blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,MAAMC,SAAA,GAAY;AAIlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAI9B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAsBnC,MAAMC,2BAAA,gBAA8B9B,aAAA,CAA+C;EACjF+B,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,8BAAA,GAAiCA,CAAA;EAAA,OAAMjC,KAAA,CAAAkC,UAAA,CAAAH,2BAAiB;AAAA;AAErE,OAAO,MAAMI,oBAAA,GAAyCC,KAAA;EACpD,MAAM;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGH,KAAA;EAE3C,MAAM,CAACI,MAAA,CAAO,GAAGjC,yBAA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sG,oBAAA;QACAM,KAAA;QACArG,OAAA;QACAgF;MACF;gBAECnD;sBAGHyE,KAAA,CAACP,oBAAA;iBACEtG,YAAA,gBAAewF,IAAA,CAACoB,KAAA,qBAAWpB,IAAA,CAACxG,aAAA;QAAc2I,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DpH,MAAA,CAAOsG,UAAU,kBAChBD,KAAA,CAAC;QAAInB,SAAA,EAAW,GAAGpH,SAAA,WAAoB;gCACrCkH,IAAA,CAACY,UAAA,O,aACDZ,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","createContext","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","useContext","InlineBlockComponent","props","cacheBuster","formData","nodeKey","editor","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","permissions","readOnly","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","id","formState","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","clientBlockFields","getKey","length","undefined","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","initialBlockFormState","operation","renderAllFields","signal","newFormStateData","node","newData","setFields","onChange","prevFormState","submit","controller","onFormSubmit","RemoveButton","_jsx","buttonStyle","className","disabled","icon","onClick","e","preventDefault","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","isEditable","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","Provider","value","height","width"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n () => initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MA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c+I,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DvH,MAAA,CAAOyG,UAAU,kBAChBD,KAAA,CAAC;QAAInB,SAAA,EAAW,GAAGxH,SAAA,WAAoB;gCACrCsH,IAAA,CAACY,UAAA,O,aACDZ,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/client/index.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/client/index.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,mBAAmB,8EAyL/B,CAAA"}
|
|
@@ -10,6 +10,7 @@ import { InlineBlockNode } from './nodes/InlineBlocksNode.js';
|
|
|
10
10
|
import { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './plugin/commands.js';
|
|
11
11
|
import { BlocksPlugin } from './plugin/index.js';
|
|
12
12
|
export const BlocksFeatureClient = createClientFeature(({
|
|
13
|
+
config,
|
|
13
14
|
featureClientSchemaMap,
|
|
14
15
|
props,
|
|
15
16
|
schemaPath
|
|
@@ -23,10 +24,10 @@ export const BlocksFeatureClient = createClientFeature(({
|
|
|
23
24
|
const blocksFields = Object.entries(clientSchema).filter(([key]) => key.startsWith(schemaMapRenderedBlockPathPrefix + '.') && !key.replace(schemaMapRenderedBlockPathPrefix + '.', '').includes('.')).map(([, value]) => value[0]);
|
|
24
25
|
const inlineBlocksFields = Object.entries(clientSchema).filter(([key]) => key.startsWith(schemaMapRenderedInlineBlockPathPrefix + '.') && !key.replace(schemaMapRenderedInlineBlockPathPrefix + '.', '').includes('.')).map(([, value]) => value[0]);
|
|
25
26
|
const clientBlocks = blocksFields.map(field => {
|
|
26
|
-
return field.blocks[0];
|
|
27
|
+
return field.blockReferences ? typeof field.blockReferences[0] === 'string' ? config.blocksMap[field.blockReferences[0]] : field.blockReferences[0] : field.blocks[0];
|
|
27
28
|
}).filter(block => block !== undefined);
|
|
28
29
|
const clientInlineBlocks = inlineBlocksFields.map(field => {
|
|
29
|
-
return field.blocks[0];
|
|
30
|
+
return field.blockReferences ? typeof field.blockReferences[0] === 'string' ? config.blocksMap[field.blockReferences[0]] : field.blockReferences[0] : field.blocks[0];
|
|
30
31
|
}).filter(block => block !== undefined);
|
|
31
32
|
return {
|
|
32
33
|
nodes: [BlockNode, InlineBlockNode],
|