@payloadcms/richtext-lexical 3.2.1 → 3.2.2-canary.317488d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-JP7H7AZE.js +2 -0
- package/dist/exports/client/Field-JP7H7AZE.js.map +7 -0
- package/dist/exports/client/{chunk-WS6E5WE4.js → chunk-WHL7AV5U.js} +2 -2
- package/dist/exports/client/chunk-WHL7AV5U.js.map +7 -0
- package/dist/exports/client/componentInline-GXYBWVCR.js +2 -0
- package/dist/exports/client/index.js +11 -11
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/react/components/RichText/converter/converters/list.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/list.js +1 -6
- package/dist/exports/react/components/RichText/converter/converters/list.js.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/text.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/converters/text.js +1 -4
- package/dist/exports/react/components/RichText/converter/converters/text.js.map +1 -1
- package/dist/exports/react/components/RichText/converter/defaultConverters.d.ts +2 -1
- package/dist/exports/react/components/RichText/converter/defaultConverters.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/defaultConverters.js.map +1 -1
- package/dist/exports/react/components/RichText/converter/index.js +1 -1
- package/dist/exports/react/components/RichText/converter/index.js.map +1 -1
- package/dist/exports/react/components/RichText/converter/types.d.ts +26 -8
- package/dist/exports/react/components/RichText/converter/types.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/converter/types.js.map +1 -1
- package/dist/exports/react/components/RichText/index.css +4 -0
- package/dist/exports/react/components/RichText/index.d.ts +14 -3
- package/dist/exports/react/components/RichText/index.d.ts.map +1 -1
- package/dist/exports/react/components/RichText/index.js +2 -1
- package/dist/exports/react/components/RichText/index.js.map +1 -1
- package/dist/features/blocks/client/component/index.js +1 -0
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -0
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +3 -14
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +4 -4
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/validate.d.ts +1 -1
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +5 -0
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/indent/client/plugins/index.d.ts +3 -0
- package/dist/features/indent/client/plugins/index.d.ts.map +1 -0
- package/dist/features/indent/client/plugins/index.js +73 -0
- package/dist/features/indent/client/plugins/index.js.map +1 -0
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +2 -2
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/nodeTypes.d.ts +1 -1
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js.map +1 -1
- package/package.json +8 -8
- package/dist/exports/client/Field-4JYUMYYH.js +0 -2
- package/dist/exports/client/Field-4JYUMYYH.js.map +0 -7
- package/dist/exports/client/chunk-WS6E5WE4.js.map +0 -7
- package/dist/exports/client/componentInline-7YSGAB45.js +0 -2
- /package/dist/exports/client/{componentInline-7YSGAB45.js.map → componentInline-GXYBWVCR.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAChG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,sBAAsB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAChG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,sBAAsB,GAAG,kBAAkB,CAgDvF,CAAA"}
|
|
@@ -30,15 +30,13 @@ export const ListJSXConverter = {
|
|
|
30
30
|
className: `list-item-checkbox${node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked'}${hasSubLists ? ' nestedListItem' : ''}`,
|
|
31
31
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
32
32
|
role: "checkbox",
|
|
33
|
-
style: {
|
|
34
|
-
listStyleType: 'none'
|
|
35
|
-
},
|
|
36
33
|
tabIndex: -1,
|
|
37
34
|
value: node?.value,
|
|
38
35
|
children: hasSubLists ? children : /*#__PURE__*/_jsxs(_Fragment, {
|
|
39
36
|
children: [/*#__PURE__*/_jsx("input", {
|
|
40
37
|
checked: node.checked,
|
|
41
38
|
id: uuid,
|
|
39
|
+
readOnly: true,
|
|
42
40
|
type: "checkbox"
|
|
43
41
|
}), /*#__PURE__*/_jsx("label", {
|
|
44
42
|
htmlFor: uuid,
|
|
@@ -49,9 +47,6 @@ export const ListJSXConverter = {
|
|
|
49
47
|
} else {
|
|
50
48
|
return /*#__PURE__*/_jsx("li", {
|
|
51
49
|
className: hasSubLists ? 'nestedListItem' : '',
|
|
52
|
-
style: hasSubLists ? {
|
|
53
|
-
listStyleType: 'none'
|
|
54
|
-
} : {},
|
|
55
50
|
value: node?.value,
|
|
56
51
|
children: children
|
|
57
52
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":["v4","uuidv4","ListJSXConverter","list","node","nodesToJSX","children","nodes","NodeTag","tag","_jsx","className","listType","listitem","parent","hasSubLists","some","child","type","uuid","checked","role","
|
|
1
|
+
{"version":3,"file":"list.js","names":["v4","uuidv4","ListJSXConverter","list","node","nodesToJSX","children","nodes","NodeTag","tag","_jsx","className","listType","listitem","parent","hasSubLists","some","child","type","uuid","checked","role","tabIndex","value","_jsxs","_Fragment","id","readOnly","htmlFor"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/list.tsx"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid'\n\nimport type { SerializedListItemNode, SerializedListNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const ListJSXConverter: JSXConverters<SerializedListItemNode | SerializedListNode> = {\n list: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const NodeTag = node.tag\n\n return <NodeTag className={`list-${node?.listType}`}>{children}</NodeTag>\n },\n listitem: ({ node, nodesToJSX, parent }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n const uuid = uuidv4()\n\n return (\n <li\n aria-checked={node.checked ? 'true' : 'false'}\n className={`list-item-checkbox${node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked'}${hasSubLists ? ' nestedListItem' : ''}`}\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n role=\"checkbox\"\n tabIndex={-1}\n value={node?.value}\n >\n {hasSubLists ? (\n children\n ) : (\n <>\n <input checked={node.checked} id={uuid} readOnly={true} type=\"checkbox\" />\n <label htmlFor={uuid}>{children}</label>\n <br />\n </>\n )}\n </li>\n )\n } else {\n return (\n <li className={hasSubLists ? 'nestedListItem' : ''} value={node?.value}>\n {children}\n </li>\n )\n }\n },\n}\n"],"mappings":";AAAA,SAASA,EAAA,IAAMC,MAAM,QAAQ;AAK7B,OAAO,MAAMC,gBAAA,GAA+E;EAC1FC,IAAA,EAAMA,CAAC;IAAEC,IAAI;IAAEC;EAAU,CAAE;IACzB,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,MAAME,OAAA,GAAUJ,IAAA,CAAKK,GAAG;IAExB,oBAAOC,IAAA,CAACF,OAAA;MAAQG,SAAA,EAAW,QAAQP,IAAA,EAAMQ,QAAA,EAAU;gBAAGN;;EACxD;EACAO,QAAA,EAAUA,CAAC;IAAET,IAAI;IAAEC,UAAU;IAAES;EAAM,CAAE;IACrC,MAAMC,WAAA,GAAcX,IAAA,CAAKE,QAAQ,CAACU,IAAI,CAAEC,KAAA,IAAUA,KAAA,CAAMC,IAAI,KAAK;IAEjE,MAAMZ,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,IAAI,cAAcQ,MAAA,IAAUA,MAAA,EAAQF,QAAA,KAAa,SAAS;MACxD,MAAMO,IAAA,GAAOlB,MAAA;MAEb,oBACES,IAAA,CAAC;QACC,gBAAcN,IAAA,CAAKgB,OAAO,GAAG,SAAS;QACtCT,SAAA,EAAW,qBAAqBP,IAAA,CAAKgB,OAAO,GAAG,gCAAgC,kCAAkCL,WAAA,GAAc,oBAAoB,IAAI;QACvJ;QACAM,IAAA,EAAK;QACLC,QAAA,EAAU,CAAC;QACXC,KAAA,EAAOnB,IAAA,EAAMmB,KAAA;kBAEZR,WAAA,GACCT,QAAA,gBAEAkB,KAAA,CAAAC,SAAA;kCACEf,IAAA,CAAC;YAAMU,OAAA,EAAShB,IAAA,CAAKgB,OAAO;YAAEM,EAAA,EAAIP,IAAA;YAAMQ,QAAA,EAAU;YAAMT,IAAA,EAAK;2BAC7DR,IAAA,CAAC;YAAMkB,OAAA,EAAST,IAAA;sBAAOb;2BACvBI,IAAA,CAAC;;;IAKX,OAAO;MACL,oBACEA,IAAA,CAAC;QAAGC,SAAA,EAAWI,WAAA,GAAc,mBAAmB;QAAIQ,KAAA,EAAOnB,IAAA,EAAMmB,KAAA;kBAC9DjB;;IAGP;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/text.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/text.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,kBAAkB,CA4B9D,CAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import escapeHTML from 'escape-html';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import { NodeFormat } from '../../../../../../lexical/utils/nodeFormat.js';
|
|
5
4
|
export const TextJSXConverter = {
|
|
6
5
|
text: ({
|
|
7
6
|
node
|
|
8
7
|
}) => {
|
|
9
|
-
let text =
|
|
10
|
-
children: escapeHTML(node.text)
|
|
11
|
-
});
|
|
8
|
+
let text = node.text;
|
|
12
9
|
if (node.format & NodeFormat.IS_BOLD) {
|
|
13
10
|
text = /*#__PURE__*/_jsx("strong", {
|
|
14
11
|
children: text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["
|
|
1
|
+
{"version":3,"file":"text.js","names":["React","NodeFormat","TextJSXConverter","text","node","format","IS_BOLD","_jsx","IS_ITALIC","IS_STRIKETHROUGH","style","textDecoration","IS_UNDERLINE","IS_CODE","IS_SUBSCRIPT","IS_SUPERSCRIPT"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/text.tsx"],"sourcesContent":["import React from 'react'\n\nimport type { SerializedTextNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nimport { NodeFormat } from '../../../../../../lexical/utils/nodeFormat.js'\n\nexport const TextJSXConverter: JSXConverters<SerializedTextNode> = {\n text: ({ node }) => {\n let text: React.ReactNode = node.text\n\n if (node.format & NodeFormat.IS_BOLD) {\n text = <strong>{text}</strong>\n }\n if (node.format & NodeFormat.IS_ITALIC) {\n text = <em>{text}</em>\n }\n if (node.format & NodeFormat.IS_STRIKETHROUGH) {\n text = <span style={{ textDecoration: 'line-through' }}>{text}</span>\n }\n if (node.format & NodeFormat.IS_UNDERLINE) {\n text = <span style={{ textDecoration: 'underline' }}>{text}</span>\n }\n if (node.format & NodeFormat.IS_CODE) {\n text = <code>{text}</code>\n }\n if (node.format & NodeFormat.IS_SUBSCRIPT) {\n text = <sub>{text}</sub>\n }\n if (node.format & NodeFormat.IS_SUPERSCRIPT) {\n text = <sup>{text}</sup>\n }\n\n return text\n },\n}\n"],"mappings":";AAAA,OAAOA,KAAA,MAAW;AAKlB,SAASC,UAAU,QAAQ;AAE3B,OAAO,MAAMC,gBAAA,GAAsD;EACjEC,IAAA,EAAMA,CAAC;IAAEC;EAAI,CAAE;IACb,IAAID,IAAA,GAAwBC,IAAA,CAAKD,IAAI;IAErC,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWK,OAAO,EAAE;MACpCH,IAAA,gBAAOI,IAAA,CAAC;kBAAQJ;;IAClB;IACA,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWO,SAAS,EAAE;MACtCL,IAAA,gBAAOI,IAAA,CAAC;kBAAIJ;;IACd;IACA,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWQ,gBAAgB,EAAE;MAC7CN,IAAA,gBAAOI,IAAA,CAAC;QAAKG,KAAA,EAAO;UAAEC,cAAA,EAAgB;QAAe;kBAAIR;;IAC3D;IACA,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWW,YAAY,EAAE;MACzCT,IAAA,gBAAOI,IAAA,CAAC;QAAKG,KAAA,EAAO;UAAEC,cAAA,EAAgB;QAAY;kBAAIR;;IACxD;IACA,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWY,OAAO,EAAE;MACpCV,IAAA,gBAAOI,IAAA,CAAC;kBAAMJ;;IAChB;IACA,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWa,YAAY,EAAE;MACzCX,IAAA,gBAAOI,IAAA,CAAC;kBAAKJ;;IACf;IACA,IAAIC,IAAA,CAAKC,MAAM,GAAGJ,UAAA,CAAWc,cAAc,EAAE;MAC3CZ,IAAA,gBAAOI,IAAA,CAAC;kBAAKJ;;IACf;IAEA,OAAOA,IAAA;EACT;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DefaultNodeTypes } from '../../../../../nodeTypes.js';
|
|
1
2
|
import type { JSXConverters } from './types.js';
|
|
2
|
-
export declare const defaultJSXConverters: JSXConverters
|
|
3
|
+
export declare const defaultJSXConverters: JSXConverters<DefaultNodeTypes>;
|
|
3
4
|
//# sourceMappingURL=defaultConverters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultConverters.d.ts","sourceRoot":"","sources":["../../../../../../src/exports/react/components/RichText/converter/defaultConverters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAa/C,eAAO,MAAM,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"defaultConverters.d.ts","sourceRoot":"","sources":["../../../../../../src/exports/react/components/RichText/converter/defaultConverters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAa/C,eAAO,MAAM,oBAAoB,EAAE,aAAa,CAAC,gBAAgB,CAWhE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultConverters.js","names":["BlockquoteJSXConverter","HeadingJSXConverter","HorizontalRuleJSXConverter","LinebreakJSXConverter","LinkJSXConverter","ListJSXConverter","ParagraphJSXConverter","TableJSXConverter","TextJSXConverter","UploadJSXConverter","defaultJSXConverters"],"sources":["../../../../../../src/exports/react/components/RichText/converter/defaultConverters.ts"],"sourcesContent":["import type { JSXConverters } from './types.js'\n\nimport { BlockquoteJSXConverter } from './converters/blockquote.js'\nimport { HeadingJSXConverter } from './converters/heading.js'\nimport { HorizontalRuleJSXConverter } from './converters/horizontalRule.js'\nimport { LinebreakJSXConverter } from './converters/linebreak.js'\nimport { LinkJSXConverter } from './converters/link.js'\nimport { ListJSXConverter } from './converters/list.js'\nimport { ParagraphJSXConverter } from './converters/paragraph.js'\nimport { TableJSXConverter } from './converters/table.js'\nimport { TextJSXConverter } from './converters/text.js'\nimport { UploadJSXConverter } from './converters/upload.js'\n\nexport const defaultJSXConverters: JSXConverters = {\n ...ParagraphJSXConverter,\n ...TextJSXConverter,\n ...LinebreakJSXConverter,\n ...BlockquoteJSXConverter,\n ...TableJSXConverter,\n ...HeadingJSXConverter,\n ...HorizontalRuleJSXConverter,\n ...ListJSXConverter,\n ...LinkJSXConverter({}),\n ...UploadJSXConverter,\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaultConverters.js","names":["BlockquoteJSXConverter","HeadingJSXConverter","HorizontalRuleJSXConverter","LinebreakJSXConverter","LinkJSXConverter","ListJSXConverter","ParagraphJSXConverter","TableJSXConverter","TextJSXConverter","UploadJSXConverter","defaultJSXConverters"],"sources":["../../../../../../src/exports/react/components/RichText/converter/defaultConverters.ts"],"sourcesContent":["import type { DefaultNodeTypes } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from './types.js'\n\nimport { BlockquoteJSXConverter } from './converters/blockquote.js'\nimport { HeadingJSXConverter } from './converters/heading.js'\nimport { HorizontalRuleJSXConverter } from './converters/horizontalRule.js'\nimport { LinebreakJSXConverter } from './converters/linebreak.js'\nimport { LinkJSXConverter } from './converters/link.js'\nimport { ListJSXConverter } from './converters/list.js'\nimport { ParagraphJSXConverter } from './converters/paragraph.js'\nimport { TableJSXConverter } from './converters/table.js'\nimport { TextJSXConverter } from './converters/text.js'\nimport { UploadJSXConverter } from './converters/upload.js'\n\nexport const defaultJSXConverters: JSXConverters<DefaultNodeTypes> = {\n ...ParagraphJSXConverter,\n ...TextJSXConverter,\n ...LinebreakJSXConverter,\n ...BlockquoteJSXConverter,\n ...TableJSXConverter,\n ...HeadingJSXConverter,\n ...HorizontalRuleJSXConverter,\n ...ListJSXConverter,\n ...LinkJSXConverter({}),\n ...UploadJSXConverter,\n}\n"],"mappings":"AAGA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,qBAAqB,QAAQ;AACtC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,iBAAiB,QAAQ;AAClC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAEnC,OAAO,MAAMC,oBAAA,GAAwD;EACnE,GAAGJ,qBAAqB;EACxB,GAAGE,gBAAgB;EACnB,GAAGL,qBAAqB;EACxB,GAAGH,sBAAsB;EACzB,GAAGO,iBAAiB;EACpB,GAAGN,mBAAmB;EACtB,GAAGC,0BAA0B;EAC7B,GAAGG,gBAAgB;EACnB,GAAGD,gBAAA,CAAiB,CAAC,EAAE;EACvB,GAAGK;AACL","ignoreList":[]}
|
|
@@ -110,7 +110,7 @@ export function convertLexicalNodesToJSX({
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
if (!disableIndent && (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))) {
|
|
113
|
-
if ('indent' in node && node.indent) {
|
|
113
|
+
if ('indent' in node && node.indent && node.type !== 'listitem') {
|
|
114
114
|
style.paddingInlineStart = `${Number(node.indent) * 2}em`;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","convertLexicalToJSX","converters","data","disableIndent","disableTextAlign","root","children","length","convertLexicalNodesToJSX","nodes","parent","_jsx","_Fragment","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","childIndex","nodesToJSX","args","reactNode","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean","jsx"],"sources":["../../../../../../src/exports/react/components/RichText/converter/index.tsx"],"sourcesContent":["import type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nexport type ConvertLexicalToHTMLArgs = {\n converters: JSXConverters\n data: SerializedEditorState\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n}\n\nexport function convertLexicalToJSX({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n}: ConvertLexicalToHTMLArgs): React.ReactNode {\n if (data?.root?.children?.length) {\n return convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes: data?.root?.children,\n parent: data?.root,\n })\n }\n return <></>\n}\n\nexport function convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes,\n parent,\n}: {\n converters: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent: SerializedLexicalNodeWithParent\n}): React.ReactNode[] {\n const unknownConverter: JSXConverter<any> = converters.unknown as JSXConverter<any>\n\n const jsxArray: React.ReactNode[] = nodes.map((node, i) => {\n let converterForNode: JSXConverter<any> | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[(node as SerializedBlockNode)?.fields?.blockType]\n if (!converterForNode) {\n console.error(\n `Lexical => JSX converter: Blocks converter: found ${(node as SerializedBlockNode)?.fields?.blockType} block, but no converter is provided`,\n )\n }\n } else if (node.type === 'inlineBlock') {\n converterForNode =\n converters?.inlineBlocks?.[(node as SerializedInlineBlockNode)?.fields?.blockType]\n if (!converterForNode) {\n console.error(\n `Lexical => JSX converter: Inline Blocks converter: found ${(node as SerializedInlineBlockNode)?.fields?.blockType} inline block, but no converter is provided`,\n )\n }\n } else {\n converterForNode = converters[node.type] as JSXConverter<any>\n }\n\n try {\n if (!converterForNode) {\n if (unknownConverter) {\n return unknownConverter({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n }\n return <span key={i}>unknown node</span>\n }\n\n const reactNode = converterForNode({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n\n const style: React.CSSProperties = {}\n\n // Check if disableTextAlign is not true and does not include node type\n if (\n !disableTextAlign &&\n (!Array.isArray(disableTextAlign) || !disableTextAlign?.includes(node.type))\n ) {\n if ('format' in node && node.format) {\n switch (node.format) {\n case 'center':\n style.textAlign = 'center'\n break\n case 'end':\n style.textAlign = 'right'\n break\n case 'justify':\n style.textAlign = 'justify'\n break\n case 'left':\n //style.textAlign = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style.textAlign = 'right'\n break\n case 'start':\n style.textAlign = 'left'\n break\n }\n }\n }\n\n if (\n !disableIndent &&\n (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))\n ) {\n if ('indent' in node && node.indent) {\n style.paddingInlineStart = `${Number(node.indent) * 2}em`\n }\n }\n\n if (React.isValidElement(reactNode)) {\n // Inject style into reactNode\n if (style.textAlign || style.paddingInlineStart) {\n const newStyle = {\n ...style,\n // @ts-expect-error type better later\n ...(reactNode?.props?.style ?? {}),\n // reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here\n }\n\n return React.cloneElement(reactNode, {\n key: i,\n // @ts-expect-error type better later\n style: newStyle,\n })\n }\n return React.cloneElement(reactNode, {\n key: i,\n })\n }\n\n return reactNode\n } catch (error) {\n console.error('Error converting lexical node to HTML:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean).map((jsx) => jsx)\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAYlB,OAAO,SAASC,oBAAoB;EAClCC,UAAU;EACVC,IAAI;EACJC,aAAa;EACbC;AAAgB,CACS;EACzB,IAAIF,IAAA,EAAMG,IAAA,EAAMC,QAAA,EAAUC,MAAA,EAAQ;IAChC,OAAOC,wBAAA,CAAyB;MAC9BP,UAAA;MACAE,aAAA;MACAC,gBAAA;MACAK,KAAA,EAAOP,IAAA,EAAMG,IAAA,EAAMC,QAAA;MACnBI,MAAA,EAAQR,IAAA,EAAMG;IAChB;EACF;EACA,oBAAOM,IAAA,CAAAC,SAAA;AACT;AAEA,OAAO,SAASJ,yBAAyB;EACvCP,UAAU;EACVE,aA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9B,aAAA,KAAkB,CAACA,aAAA,EAAe+B,QAAA,CAASjB,IAAA,CAAKG,IAAI,IACpE;QACA,IAAI,YAAYH,IAAA,IAAQA,IAAA,CAAKoB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","convertLexicalToJSX","converters","data","disableIndent","disableTextAlign","root","children","length","convertLexicalNodesToJSX","nodes","parent","_jsx","_Fragment","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","childIndex","nodesToJSX","args","reactNode","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean","jsx"],"sources":["../../../../../../src/exports/react/components/RichText/converter/index.tsx"],"sourcesContent":["import type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nexport type ConvertLexicalToHTMLArgs = {\n converters: JSXConverters\n data: SerializedEditorState\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n}\n\nexport function convertLexicalToJSX({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n}: ConvertLexicalToHTMLArgs): React.ReactNode {\n if (data?.root?.children?.length) {\n return convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes: data?.root?.children,\n parent: data?.root,\n })\n }\n return <></>\n}\n\nexport function convertLexicalNodesToJSX({\n converters,\n disableIndent,\n disableTextAlign,\n nodes,\n parent,\n}: {\n converters: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent: SerializedLexicalNodeWithParent\n}): React.ReactNode[] {\n const unknownConverter: JSXConverter<any> = converters.unknown as JSXConverter<any>\n\n const jsxArray: React.ReactNode[] = nodes.map((node, i) => {\n let converterForNode: JSXConverter<any> | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[(node as SerializedBlockNode)?.fields?.blockType]\n if (!converterForNode) {\n console.error(\n `Lexical => JSX converter: Blocks converter: found ${(node as SerializedBlockNode)?.fields?.blockType} block, but no converter is provided`,\n )\n }\n } else if (node.type === 'inlineBlock') {\n converterForNode =\n converters?.inlineBlocks?.[(node as SerializedInlineBlockNode)?.fields?.blockType]\n if (!converterForNode) {\n console.error(\n `Lexical => JSX converter: Inline Blocks converter: found ${(node as SerializedInlineBlockNode)?.fields?.blockType} inline block, but no converter is provided`,\n )\n }\n } else {\n converterForNode = converters[node.type] as JSXConverter<any>\n }\n\n try {\n if (!converterForNode) {\n if (unknownConverter) {\n return unknownConverter({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n }\n return <span key={i}>unknown node</span>\n }\n\n const reactNode = converterForNode({\n childIndex: i,\n converters,\n node,\n nodesToJSX: (args) => {\n return convertLexicalNodesToJSX({\n converters: args.converters ?? converters,\n disableIndent: args.disableIndent ?? disableIndent,\n disableTextAlign: args.disableTextAlign ?? disableTextAlign,\n nodes: args.nodes,\n parent: args.parent ?? {\n ...node,\n parent,\n },\n })\n },\n parent,\n })\n\n const style: React.CSSProperties = {}\n\n // Check if disableTextAlign is not true and does not include node type\n if (\n !disableTextAlign &&\n (!Array.isArray(disableTextAlign) || !disableTextAlign?.includes(node.type))\n ) {\n if ('format' in node && node.format) {\n switch (node.format) {\n case 'center':\n style.textAlign = 'center'\n break\n case 'end':\n style.textAlign = 'right'\n break\n case 'justify':\n style.textAlign = 'justify'\n break\n case 'left':\n //style.textAlign = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style.textAlign = 'right'\n break\n case 'start':\n style.textAlign = 'left'\n break\n }\n }\n }\n\n if (\n !disableIndent &&\n (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))\n ) {\n if ('indent' in node && node.indent && node.type !== 'listitem') {\n style.paddingInlineStart = `${Number(node.indent) * 2}em`\n }\n }\n\n if (React.isValidElement(reactNode)) {\n // Inject style into reactNode\n if (style.textAlign || style.paddingInlineStart) {\n const newStyle = {\n ...style,\n // @ts-expect-error type better later\n ...(reactNode?.props?.style ?? {}),\n // reactNode style comes after, thus a textAlign specified in the converter has priority over the one we inject here\n }\n\n return React.cloneElement(reactNode, {\n key: i,\n // @ts-expect-error type better later\n style: newStyle,\n })\n }\n return React.cloneElement(reactNode, {\n key: i,\n })\n }\n\n return reactNode\n } catch (error) {\n console.error('Error converting lexical node to HTML:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean).map((jsx) => jsx)\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AAYlB,OAAO,SAASC,oBAAoB;EAClCC,UAAU;EACVC,IAAI;EACJC,aAAa;EACbC;AAAgB,CACS;EACzB,IAAIF,IAAA,EAAMG,IAAA,EAAMC,QAAA,EAAUC,MAAA,EAAQ;IAChC,OAAOC,wBAAA,CAAyB;MAC9BP,UAAA;MACAE,aAAA;MACAC,gBAAA;MACAK,KAAA,EAAOP,IAAA,EAAMG,IAAA,EAAMC,QAAA;MACnBI,MAAA,EAAQR,IAAA,EAAMG;IAChB;EACF;EACA,oBAAOM,IAAA,CAAAC,SAAA;AACT;AAEA,OAAO,SAASJ,yBAAyB;EACvCP,UAAU;EACVE,aAAa;EACbC,gBAAgB;EAChBK,KAAK;EACLC;AAAM,CAOP;EACC,MAAMG,gBAAA,GAAsCZ,UAAA,CAAWa,OAAO;EAE9D,MAAMC,QAAA,GAA8BN,KAAA,CAAMO,GAAG,CAAC,CAACC,IAAA,EAAMC,CAAA;IACnD,IAAIC,gBAAA;IACJ,IAAIF,IAAA,CAAKG,IAAI,KAAK,SAAS;MACzBD,gBAAA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K;QAC3D;MACF;MAEA,iBAAItC,KAAA,CAAMyC,cAAc,CAACV,SAAA,GAAY;QACnC;QACA,IAAIC,KAAA,CAAMK,SAAS,IAAIL,KAAA,CAAMO,kBAAkB,EAAE;UAC/C,MAAMG,QAAA,GAAW;YACf,GAAGV,KAAK;YACR;YACA,IAAID,SAAA,EAAWY,KAAA,EAAOX,KAAA,IAAS,CAAC,CAAC;UAEnC;UAEA,oBAAOhC,KAAA,CAAM4C,YAAY,CAACb,SAAA,EAAW;YACnCc,GAAA,EAAK1B,CAAA;YACL;YACAa,KAAA,EAAOU;UACT;QACF;QACA,oBAAO1C,KAAA,CAAM4C,YAAY,CAACb,SAAA,EAAW;UACnCc,GAAA,EAAK1B;QACP;MACF;MAEA,OAAOY,SAAA;IACT,EAAE,OAAOL,KAAA,EAAO;MACdD,OAAA,CAAQC,KAAK,CAAC,0CAA0CA,KAAA,EAAO,SAASR,IAAA;MACxE,OAAO;IACT;EACF;EAEA,OAAOF,QAAA,CAAS8B,MAAM,CAACC,OAAA,EAAS9B,GAAG,CAAE+B,GAAA,IAAQA,GAAA;AAC/C","ignoreList":[]}
|
|
@@ -19,24 +19,42 @@ export type JSXConverter<T extends {
|
|
|
19
19
|
export type JSXConverters<T extends {
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
type?: string;
|
|
22
|
-
} = DefaultNodeTypes
|
|
22
|
+
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
23
|
+
blockName?: null | string;
|
|
24
|
+
blockType: string;
|
|
25
|
+
}> | SerializedInlineBlockNode<{
|
|
26
|
+
blockName?: null | string;
|
|
27
|
+
blockType: string;
|
|
28
|
+
}>> = {
|
|
23
29
|
[key: string]: {
|
|
24
30
|
[blockSlug: string]: JSXConverter<any>;
|
|
25
31
|
} | JSXConverter<any> | undefined;
|
|
26
32
|
} & {
|
|
27
|
-
[nodeType in NonNullable<T['type']>]?: JSXConverter<Extract<T, {
|
|
33
|
+
[nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: JSXConverter<Extract<T, {
|
|
28
34
|
type: nodeType;
|
|
29
35
|
}>>;
|
|
30
36
|
} & {
|
|
31
37
|
blocks?: {
|
|
32
|
-
[
|
|
33
|
-
|
|
34
|
-
}
|
|
38
|
+
[K in Extract<Extract<T, {
|
|
39
|
+
type: 'block';
|
|
40
|
+
}> extends SerializedBlockNode<infer B> ? B extends {
|
|
41
|
+
blockType: string;
|
|
42
|
+
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<T, {
|
|
43
|
+
type: 'block';
|
|
44
|
+
}> extends SerializedBlockNode<infer B> ? SerializedBlockNode<Extract<B, {
|
|
45
|
+
blockType: K;
|
|
46
|
+
}>> : SerializedBlockNode>;
|
|
35
47
|
};
|
|
36
48
|
inlineBlocks?: {
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
}
|
|
49
|
+
[K in Extract<Extract<T, {
|
|
50
|
+
type: 'inlineBlock';
|
|
51
|
+
}> extends SerializedInlineBlockNode<infer B> ? B extends {
|
|
52
|
+
blockType: string;
|
|
53
|
+
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<T, {
|
|
54
|
+
type: 'inlineBlock';
|
|
55
|
+
}> extends SerializedInlineBlockNode<infer B> ? SerializedInlineBlockNode<Extract<B, {
|
|
56
|
+
blockType: K;
|
|
57
|
+
}>> : SerializedInlineBlockNode>;
|
|
40
58
|
};
|
|
41
59
|
};
|
|
42
60
|
export type SerializedLexicalNodeWithParent = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/exports/react/components/RichText/converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,qBAAqB,IAC9F,CAAC,IAAI,EAAE;IACL,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,aAAa,CAAA;IACzB,IAAI,EAAE,CAAC,CAAA;IACP,UAAU,EAAE,CAAC,IAAI,EAAE;QACjB,UAAU,CAAC,EAAE,aAAa,CAAA;QAC1B,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;QAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;QACrC,KAAK,EAAE,qBAAqB,EAAE,CAAA;QAC9B,MAAM,CAAC,EAAE,+BAA+B,CAAA;KACzC,KAAK,KAAK,CAAC,SAAS,EAAE,CAAA;IACvB,MAAM,EAAE,+BAA+B,CAAA;CACxC,KAAK,KAAK,CAAC,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/exports/react/components/RichText/converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,6BAA6B,CAAA;AACpC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,qBAAqB,IAC9F,CAAC,IAAI,EAAE;IACL,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,aAAa,CAAA;IACzB,IAAI,EAAE,CAAC,CAAA;IACP,UAAU,EAAE,CAAC,IAAI,EAAE;QACjB,UAAU,CAAC,EAAE,aAAa,CAAA;QAC1B,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;QAClC,gBAAgB,CAAC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AAK,GACP,KAAK,EACT,MAAM,CACP,CAAC,CAAC,EAAE,YAAY,CACf,OAAO,CAAC,CAAC,EAAE;YAAE,IAAI,EAAE,OAAO,CAAA;SAAE,CAAC,SAAS,mBAAmB,CAAC,MAAM,CAAC,CAAC,GAC9D,mBAAmB,CAAC,OAAO,CAAC,CAAC,EAAE;YAAE,SAAS,EAAE,CAAC,CAAA;SAAE,CAAC,CAAC,GACjD,mBAAmB,CACxB;KACF,CAAA;IACD,YAAY,CAAC,EAAE;SACZ,CAAC,IAAI,OAAO,CACX,OAAO,CAAC,CAAC,EAAE;YAAE,IAAI,EAAE,aAAa,CAAA;SAAE,CAAC,SAAS,yBAAyB,CAAC,MAAM,CAAC,CAAC,GAC1E,CAAC,SAAS;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,GAC7B,CAAC,CAAC,WAAW,CAAC,GACd,KAAK,GACP,KAAK,EACT,MAAM,CACP,CAAC,CAAC,EAAE,YAAY,CACf,OAAO,CAAC,CAAC,EAAE;YAAE,IAAI,EAAE,aAAa,CAAA;SAAE,CAAC,SAAS,yBAAyB,CAAC,MAAM,CAAC,CAAC,GAC1E,yBAAyB,CAAC,OAAO,CAAC,CAAC,EAAE;YAAE,SAAS,EAAE,CAAC,CAAA;SAAE,CAAC,CAAC,GACvD,yBAAyB,CAC9B;KACF,CAAA;CACF,CAAA;AACD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,CAAC,EAAE,qBAAqB,CAAA;CAC/B,GAAG,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/exports/react/components/RichText/converter/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../../nodeTypes.js'\nexport type JSXConverter<T extends { [key: string]: any; type?: string } = SerializedLexicalNode> =\n (args: {\n childIndex: number\n converters: JSXConverters\n node: T\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n parent: SerializedLexicalNodeWithParent\n }) => React.ReactNode\nexport type JSXConverters
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/exports/react/components/RichText/converter/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../../nodeTypes.js'\nexport type JSXConverter<T extends { [key: string]: any; type?: string } = SerializedLexicalNode> =\n (args: {\n childIndex: number\n converters: JSXConverters\n node: T\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n parent: SerializedLexicalNodeWithParent\n }) => React.ReactNode\n\nexport type JSXConverters<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: JSXConverter<any>\n }\n | JSXConverter<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: JSXConverter<\n Extract<T, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<T, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: JSXConverter<\n Extract<T, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<T, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: JSXConverter<\n Extract<T, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n}\nexport type SerializedLexicalNodeWithParent = {\n parent?: SerializedLexicalNode\n} & SerializedLexicalNode\n"],"mappings":"AAoEA","ignoreList":[]}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { SerializedEditorState } from 'lexical';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js';
|
|
3
4
|
import type { JSXConverters } from './converter/types.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import './index.css';
|
|
6
|
+
export type JSXConvertersFunction<T extends {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
type?: string;
|
|
9
|
+
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
10
|
+
blockName?: null | string;
|
|
11
|
+
blockType: string;
|
|
12
|
+
}> | SerializedInlineBlockNode<{
|
|
13
|
+
blockName?: null | string;
|
|
14
|
+
blockType: string;
|
|
15
|
+
}>> = (args: {
|
|
16
|
+
defaultConverters: JSXConverters<DefaultNodeTypes>;
|
|
17
|
+
}) => JSXConverters<T>;
|
|
7
18
|
type Props = {
|
|
8
19
|
className?: string;
|
|
9
20
|
converters?: JSXConverters | JSXConvertersFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exports/react/components/RichText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAA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C,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { defaultJSXConverters } from './converter/defaultConverters.js';
|
|
4
4
|
import { convertLexicalToJSX } from './converter/index.js';
|
|
5
|
+
import './index.css';
|
|
5
6
|
export const RichText = ({
|
|
6
7
|
className,
|
|
7
8
|
converters,
|
|
@@ -25,7 +26,7 @@ export const RichText = ({
|
|
|
25
26
|
finalConverters = defaultJSXConverters;
|
|
26
27
|
}
|
|
27
28
|
return /*#__PURE__*/_jsx("div", {
|
|
28
|
-
className: className,
|
|
29
|
+
className: className ?? 'payload-richtext',
|
|
29
30
|
children: editorState && !Array.isArray(editorState) && typeof editorState === 'object' && 'root' in editorState && convertLexicalToJSX({
|
|
30
31
|
converters: finalConverters,
|
|
31
32
|
data: editorState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableIndent","disableTextAlign","finalConverters","defaultConverters","_jsx","Array","isArray"],"sources":["../../../../../src/exports/react/components/RichText/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\n\nimport React from 'react'\n\nimport type { JSXConverters } from './converter/types.js'\n\nimport { defaultJSXConverters } from './converter/defaultConverters.js'\nimport { convertLexicalToJSX } from './converter/index.js'\n\nexport type JSXConvertersFunction = (args: { defaultConverters: JSXConverters }) => JSXConverters
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableIndent","disableTextAlign","finalConverters","defaultConverters","_jsx","Array","isArray"],"sources":["../../../../../src/exports/react/components/RichText/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\n\nimport React from 'react'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\nimport type { JSXConverters } from './converter/types.js'\n\nimport { defaultJSXConverters } from './converter/defaultConverters.js'\nimport { convertLexicalToJSX } from './converter/index.js'\nimport './index.css'\n\nexport type JSXConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }>\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>,\n> = (args: { defaultConverters: JSXConverters<DefaultNodeTypes> }) => JSXConverters<T>\n\ntype Props = {\n className?: string\n converters?: JSXConverters | JSXConvertersFunction\n data: SerializedEditorState\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n}\n\nexport const RichText: React.FC<Props> = ({\n className,\n converters,\n data: editorState,\n disableIndent,\n disableTextAlign,\n}) => {\n if (!editorState) {\n return null\n }\n\n let finalConverters: JSXConverters = {}\n if (converters) {\n if (typeof converters === 'function') {\n finalConverters = converters({ defaultConverters: defaultJSXConverters })\n } else {\n finalConverters = converters\n }\n } else {\n finalConverters = defaultJSXConverters\n }\n\n return (\n <div className={className ?? 'payload-richtext'}>\n {editorState &&\n !Array.isArray(editorState) &&\n typeof editorState === 'object' &&\n 'root' in editorState &&\n convertLexicalToJSX({\n converters: finalConverters,\n data: editorState,\n disableIndent,\n disableTextAlign,\n })}\n </div>\n )\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AASlB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,mBAAmB,QAAQ;AACpC,OAAO;AAiBP,OAAO,MAAMC,QAAA,GAA4BA,CAAC;EACxCC,SAAS;EACTC,UAAU;EACVC,IAAA,EAAMC,WAAW;EACjBC,aAAa;EACbC;AAAgB,CACjB;EACC,IAAI,CAACF,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAIG,eAAA,GAAiC,CAAC;EACtC,IAAIL,UAAA,EAAY;IACd,IAAI,OAAOA,UAAA,KAAe,YAAY;MACpCK,eAAA,GAAkBL,UAAA,CAAW;QAAEM,iBAAA,EAAmBV;MAAqB;IACzE,OAAO;MACLS,eAAA,GAAkBL,UAAA;IACpB;EACF,OAAO;IACLK,eAAA,GAAkBT,oBAAA;EACpB;EAEA,oBACEW,IAAA,CAAC;IAAIR,SAAA,EAAWA,SAAA,IAAa;cAC1BG,WAAA,IACC,CAACM,KAAA,CAAMC,OAAO,CAACP,WAAA,KACf,OAAOA,WAAA,KAAgB,YACvB,UAAUA,WAAA,IACVL,mBAAA,CAAoB;MAClBG,UAAA,EAAYK,eAAA;MACZJ,IAAA,EAAMC,WAAA;MACNC,aAAA;MACAC;IACF;;AAGR","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","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","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","getFormState","schemaFieldsPath","blockType","initialState","setInitialState","formState","blockName","initialValue","passesCondition","valid","value","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","fields","docPreferences","operation","renderAllFields","signal","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blocks","i18n","t","onChange","prevFormState","submit","current","controller","newFormState","newFormStateData","setTimeout","update","node","newData","setFields","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","editButton","fieldHasErrors","Label","removeButton","join","collapsibleStyle","header","_jsxs","pillStyle","path","count","withMessage","isEditable","onToggle","incomingCollapsedState","BlockDrawer","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","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 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'\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 { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { 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 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 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 [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 globalSlug,\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 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 initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 = 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 formState: prevFormState,\n globalSlug,\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 newFormState.blockName = prevFormState.blockName\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)\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 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 editButton,\n errorCount,\n fieldHasErrors,\n Label,\n removeButton,\n }: {\n children?: React.ReactNode\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}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\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 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={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>{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={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(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 const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData)\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={clientBlock.fields}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\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 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,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;AAClB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAE9B,SAASC,EA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ACdoC,QAAA,EAAU,CAACA,QAAA,CAAS;MACpB8E,QAAA,EAAWhH,WAAA;QACT;QACA,MAAM4C,SAAA,GAAehG,oBAAA,CAAqBoD,WAAA;QAC1C4C,SAAA,CAAQ/C,SAAS,GAAG9B,QAAA,CAAS8B,SAAS;QACtCH,MAAA,CAAOgD,MAAM,CAAC;UACZ,MAAMC,MAAA,GAAOtF,aAAA,CAAcW,OAAA;UAC3B,IAAI2E,MAAA,IAAQjF,YAAA,CAAaiF,MAAA,GAAO;YAC9BA,MAAA,CAAKE,SAAS,CAACD,SAAA;UACjB;QACF;QACArD,YAAA;MACF;MACAtB,SAAA,EAAWA,SAAA;MACXV,IAAA,EAAMA,IAAA;gBAEN,aAAA+G,IAAA,CAAC3G,YAAA;QACCT,SAAA,EAAWA,SAAA;QACXsJ,WAAA,EAAaA,WAAA;QACb7K,WAAA,EAAa4J,gBAAA;QACb7E,WAAA,EAAaA,WAAA;QACb2D,UAAA,EAAYA,UAAA;QACZpF,UAAA,EAAYA,UAAA;QACZgI,UAAA,EAAYnF,WAAA,CAAYZ,MAAM;QAC9BpB,YAAA,EAAcA,YAAA;QACd9B,OAAA,EAASA,OAAA;QACTqH,YAAA,EAAcA;;;EAItB,GAAG,CACDE,gBAAA,EACAiB,WAAA,EACA9F,WAAA,EACA2E,YAAA,EACAhB,UAAA,EACA3E,MAAA,EACAT,UAAA,EACAM,YAAA,EACAuC,WAAA,CAAYZ,MAAM;EAClB;EACApB,YAAA,EACA9B,OAAA,EACAkE,QAAA,EACAjE,SAAA,CACD;EAED,OAAO2C,KAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","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","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","getFormState","schemaFieldsPath","blockType","initialState","setInitialState","formState","blockName","initialValue","passesCondition","valid","value","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","fields","docPreferences","operation","renderAllFields","signal","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blocks","i18n","t","onChange","prevFormState","submit","current","controller","newFormState","newFormStateData","setTimeout","update","node","newData","setFields","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","editButton","fieldHasErrors","Label","removeButton","join","collapsibleStyle","header","_jsxs","pillStyle","path","count","withMessage","isEditable","onToggle","incomingCollapsedState","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 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'\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 { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { BlockContent } from './BlockContent.js'\nimport './index.scss'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { 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 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 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 [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 globalSlug,\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 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 initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 = 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 formState: prevFormState,\n globalSlug,\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 newFormState.blockName = prevFormState.blockName\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)\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 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 editButton,\n errorCount,\n fieldHasErrors,\n Label,\n removeButton,\n }: {\n children?: React.ReactNode\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}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\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 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={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 ),\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={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(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 const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData)\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={clientBlock.fields}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\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 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,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;AAClB,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;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAASC,YAAY,QAAQ;AAE7B,SAASC,sBAAsB,QAAQ;AAQvC,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGF,KAAA;EAC9B,MAAMG,SAAA,GAAY1B,gBAAA;EAClB,MAAM;IAAE2B,EAAE;IAAEC,cAAc;IAAEC;EAAU,CAAE,GAAG/B,eAAA;EAC3C,MAAM;IACJgC,UAAA,EAAY;MACVC,sBAAsB;MACtBC,KAAA,EAAOC,0BAA0B;MACjCC,uBAAuB;MACvBC,WAAW;MACXC,QAAQ;MACRC;IAAU,CACX;IACDrB,IAAA,EAAMsB;EAAe,CACtB,GAAGrB,sBAAA;EACJ,MAAMsB,0BAAA,GAA6B7B,M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A,EAAaA,WAAA;QACb2D,UAAA,EAAYA,UAAA;QACZpF,UAAA,EAAYA,UAAA;QACZiI,UAAA,EAAYpF,WAAA,CAAYZ,MAAM;QAC9BpB,YAAA,EAAcA,YAAA;QACd9B,OAAA,EAASA,OAAA;QACTqH,YAAA,EAAcA;;;EAItB,GAAG,CACDE,gBAAA,EACAiB,WAAA,EACA9F,WAAA,EACA2E,YAAA,EACAhB,UAAA,EACA3E,MAAA,EACAT,UAAA,EACAM,YAAA,EACAuC,WAAA,CAAYZ,MAAM;EAClB;EACApB,YAAA,EACA9B,OAAA,EACAkE,QAAA,EACAjE,SAAA,CACD;EAED,OAAO2C,KAAA;AACT","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FormState } from 'payload';
|
|
3
3
|
import './index.scss';
|
|
4
|
-
import type { InlineBlockFields } from '
|
|
4
|
+
import type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js';
|
|
5
5
|
type Props = {
|
|
6
6
|
readonly formData: InlineBlockFields;
|
|
7
7
|
readonly nodeKey: string;
|
|
@@ -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,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAA;AAgC3D,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,
|
|
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,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAA;AAgC3D,OAAO,cAAc,CAAA;AAIrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAM/E,KAAK,KAAK,GAAG;IACX,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,CAqWhD,CAAA"}
|