@payloadcms/richtext-lexical 3.80.0-internal.60d6f94 → 3.80.0-internal.8d9ec7c
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-HJGV32KA.js +2 -0
- package/dist/exports/client/Field-HJGV32KA.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-2S5Q7QYO.js +2 -0
- package/dist/exports/client/chunk-2S5Q7QYO.js.map +7 -0
- package/dist/exports/client/chunk-EZX4YW7S.js +12 -0
- package/dist/exports/client/chunk-EZX4YW7S.js.map +7 -0
- package/dist/exports/client/componentInline-NL25DNZ5.js +2 -0
- package/dist/exports/client/index.d.ts +0 -1
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +23 -23
- package/dist/exports/client/index.js.map +3 -3
- package/dist/exports/react/index.d.ts +1 -3
- package/dist/exports/react/index.d.ts.map +1 -1
- package/dist/exports/react/index.js +0 -1
- package/dist/exports/react/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.d.ts +4 -7
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +8 -9
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +4 -20
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +55 -112
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +14 -8
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +18 -67
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -4
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +2 -4
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +1 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +20 -6
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +5 -7
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts +2 -17
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +4 -124
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +10 -14
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +6 -18
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts +0 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +35 -64
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +0 -12
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +1 -2
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +3 -12
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +2 -3
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/types.d.ts +0 -4
- package/dist/lexical/config/types.d.ts.map +1 -1
- package/dist/lexical/config/types.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +2 -12
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +2 -213
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/index.js +1 -14
- package/dist/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/types.d.ts +2 -329
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +0 -1
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/validate/hasText.d.ts +1 -6
- package/dist/validate/hasText.d.ts.map +1 -1
- package/dist/validate/hasText.js +4 -10
- package/dist/validate/hasText.js.map +1 -1
- package/package.json +7 -12
- package/dist/exports/client/Field-ESDONIMD.js +0 -2
- package/dist/exports/client/Field-ESDONIMD.js.map +0 -7
- package/dist/exports/client/chunk-VCJQ5B3S.js +0 -12
- package/dist/exports/client/chunk-VCJQ5B3S.js.map +0 -7
- package/dist/exports/client/chunk-YWIZCGSY.js +0 -2
- package/dist/exports/client/chunk-YWIZCGSY.js.map +0 -7
- package/dist/exports/client/componentInline-CBBUBQ7P.js +0 -2
- package/dist/exports/client/internal-client.d.ts +0 -3
- package/dist/exports/client/internal-client.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.d.ts +0 -86
- package/dist/field/RichTextViewProvider.d.ts.map +0 -1
- package/dist/field/RichTextViewProvider.js +0 -90
- package/dist/field/RichTextViewProvider.js.map +0 -1
- package/dist/field/ViewSelector.d.ts +0 -4
- package/dist/field/ViewSelector.d.ts.map +0 -1
- package/dist/field/ViewSelector.js +0 -89
- package/dist/field/ViewSelector.js.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +0 -2
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +0 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +0 -48
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +0 -1
- /package/dist/exports/client/{componentInline-CBBUBQ7P.js.map → componentInline-NL25DNZ5.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksNode.js","names":["ObjectID","$applyNodeReplacement","React","ServerBlockNode","BlockComponent","BlockNode","clone","node","getType","importJSON","serializedNode","version","fields","data","$createBlockNode","setFormat","format","decorate","_editor","config","
|
|
1
|
+
{"version":3,"file":"BlocksNode.js","names":["ObjectID","$applyNodeReplacement","React","ServerBlockNode","BlockComponent","BlockNode","clone","node","getType","importJSON","serializedNode","version","fields","data","$createBlockNode","setFormat","format","decorate","_editor","config","_jsx","cacheBuster","getCacheBuster","className","theme","block","formData","getFields","nodeKey","getKey","exportJSON","id","default","toHexString","$isBlockNode"],"sources":["../../../../../src/features/blocks/client/nodes/BlocksNode.tsx"],"sourcesContent":["'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type { BlockFieldsOptionalID, SerializedBlockNode } from '../../server/nodes/BlocksNode.js'\n\nimport { ServerBlockNode } from '../../server/nodes/BlocksNode.js'\nimport { BlockComponent } from '../component/index.js'\n\nexport class BlockNode extends ServerBlockNode {\n static override clone(node: ServerBlockNode): ServerBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedBlockNode): BlockNode {\n if (serializedNode.version === 1) {\n // Convert (version 1 had the fields wrapped in another, unnecessary data property)\n serializedNode = {\n ...serializedNode,\n fields: {\n ...(serializedNode as any).fields.data,\n },\n version: 2,\n }\n }\n const node = $createBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(_editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <BlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.block ?? 'LexicalEditorTheme__block'}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createBlockNode(fields: BlockFieldsOptionalID): BlockNode {\n return $applyNodeReplacement(\n new BlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isBlockNode(node: BlockNode | LexicalNode | null | undefined): node is BlockNode {\n return node instanceof BlockNode\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,QAAA,MAAc;AACrB,SACEC,qBAAqB,QAIhB;AACP,OAAOC,KAAA,MAAyB;AAIhC,SAASC,eAAe,QAAQ;AAChC,SAASC,cAAc,QAAQ;AAE/B,OAAO,MAAMC,SAAA,SAAkBF,eAAA;EAC7B,OAAgBG,MAAMC,IAAqB,EAAmB;IAC5D,OAAO,KAAK,CAACD,KAAA,CAAMC,IAAA;EACrB;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO,KAAK,CAACA,OAAA;EACf;EAEA,OAAgBC,WAAWC,cAAmC,EAAa;IACzE,IAAIA,cAAA,CAAeC,OAAO,KAAK,GAAG;MAChC;MACAD,cAAA,GAAiB;QACf,GAAGA,cAAc;QACjBE,MAAA,EAAQ;UACN,GAAGF,cAAC,CAAuBE,MAAM,CAACC;QACpC;QACAF,OAAA,EAAS;MACX;IACF;IACA,MAAMJ,IAAA,GAAOO,gBAAA,CAAiBJ,cAAA,CAAeE,MAAM;IACnDL,IAAA,CAAKQ,SAAS,CAACL,cAAA,CAAeM,MAAM;IACpC,OAAOT,IAAA;EACT;EAESU,SAASC,OAAsB,EAAEC,MAAoB,EAAe;IAC3E,oBACEC,IAAA,CAAChB,cAAA;MACCiB,WAAA,EAAa,IAAI,CAACC,cAAc;MAChCC,SAAA,EAAWJ,MAAA,CAAOK,KAAK,CAACC,KAAK,IAAI;MACjCC,QAAA,EAAU,IAAI,CAACC,SAAS;MACxBC,OAAA,EAAS,IAAI,CAACC,MAAM;;EAG1B;EAESC,WAAA,EAAkC;IACzC,OAAO,KAAK,CAACA,UAAA;EACf;AACF;AAEA,OAAO,SAAShB,iBAAiBF,MAA6B;EAC5D,OAAOX,qBAAA,CACL,IAAII,SAAA,CAAU;IACZO,MAAA,EAAQ;MACN,GAAGA,MAAM;MACTmB,EAAA,EAAInB,MAAA,EAAQmB,EAAA,IAAM,IAAI/B,QAAA,CAASgC,OAAO,GAAGC,WAAW;IACtD;EACF;AAEJ;AAEA,OAAO,SAASC,aAAa3B,IAAgD;EAC3E,OAAOA,IAAA,YAAgBF,SAAA;AACzB","ignoreList":[]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { type EditorConfig, type LexicalEditor, type LexicalNode } from 'lexical';
|
|
2
|
-
import
|
|
3
|
-
import type { ViewMapInlineBlockComponentProps } from '../../../../types.js';
|
|
2
|
+
import { type JSX } from 'react';
|
|
4
3
|
import type { InlineBlockFields, SerializedInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js';
|
|
5
4
|
import { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js';
|
|
6
|
-
export type InlineBlockDecorateFunction = (editor: LexicalEditor, config: EditorConfig, CustomBlock?: React.FC<ViewMapInlineBlockComponentProps>, CustomLabel?: React.FC<ViewMapInlineBlockComponentProps>) => JSX.Element;
|
|
7
5
|
export declare class InlineBlockNode extends ServerInlineBlockNode {
|
|
8
6
|
static clone(node: ServerInlineBlockNode): ServerInlineBlockNode;
|
|
9
7
|
static getType(): string;
|
|
10
8
|
static importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode;
|
|
11
|
-
decorate(
|
|
9
|
+
decorate(_editor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
12
10
|
exportJSON(): SerializedInlineBlockNode;
|
|
13
11
|
}
|
|
14
12
|
export declare function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAA;AAChB,
|
|
1
|
+
{"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAA;AAChB,OAAc,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,KAAK,EACV,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAQ9E,qBAAa,eAAgB,SAAQ,qBAAqB;WACxC,KAAK,CAAC,IAAI,EAAE,qBAAqB,GAAG,qBAAqB;WAIzD,OAAO,IAAI,MAAM;WAIjB,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,eAAe;IAK7E,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;IAWnE,UAAU,IAAI,yBAAyB;CAGjD;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,eAAe,CAShG;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI,GAAG,SAAS,GACrD,IAAI,IAAI,eAAe,CAEzB"}
|
|
@@ -19,12 +19,10 @@ export class InlineBlockNode extends ServerInlineBlockNode {
|
|
|
19
19
|
const node = $createInlineBlockNode(serializedNode.fields);
|
|
20
20
|
return node;
|
|
21
21
|
}
|
|
22
|
-
decorate(
|
|
22
|
+
decorate(_editor, config) {
|
|
23
23
|
return /*#__PURE__*/_jsx(InlineBlockComponent, {
|
|
24
24
|
cacheBuster: this.getCacheBuster(),
|
|
25
25
|
className: config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock',
|
|
26
|
-
CustomBlock: CustomBlock,
|
|
27
|
-
CustomLabel: CustomLabel,
|
|
28
26
|
formData: this.getFields(),
|
|
29
27
|
nodeKey: this.getKey()
|
|
30
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineBlocksNode.js","names":["ObjectID","$applyNodeReplacement","React","ServerInlineBlockNode","InlineBlockComponent","lazy","then","module","default","InlineBlockNode","clone","node","getType","importJSON","serializedNode","$createInlineBlockNode","fields","decorate","_editor","config","
|
|
1
|
+
{"version":3,"file":"InlineBlocksNode.js","names":["ObjectID","$applyNodeReplacement","React","ServerInlineBlockNode","InlineBlockComponent","lazy","then","module","default","InlineBlockNode","clone","node","getType","importJSON","serializedNode","$createInlineBlockNode","fields","decorate","_editor","config","_jsx","cacheBuster","getCacheBuster","className","theme","inlineBlock","formData","getFields","nodeKey","getKey","exportJSON","id","toHexString","$isInlineBlockNode"],"sources":["../../../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx"],"sourcesContent":["'use client'\nimport ObjectID from 'bson-objectid'\nimport {\n $applyNodeReplacement,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(_editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n className={config.theme.inlineBlock ?? 'LexicalEditorTheme__inlineBlock'}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return $applyNodeReplacement(\n new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n"],"mappings":"AAAA;;;AACA,OAAOA,QAAA,MAAc;AACrB,SACEC,qBAAqB,QAIhB;AACP,OAAOC,KAAA,MAAyB;AAOhC,SAASC,qBAAqB,QAAQ;AAEtC,MAAMC,oBAAA,gBAAuBF,KAAA,CAAMG,IAAI,CAAC,MACtC,MAAM,CAAC,+BAA+BC,IAAI,CAAEC,MAAA,KAAY;EACtDC,OAAA,EAASD,MAAA,CAAOH;AAClB;AAGF,OAAO,MAAMK,eAAA,SAAwBN,qBAAA;EACnC,OAAgBO,MAAMC,IAA2B,EAAyB;IACxE,OAAO,KAAK,CAACD,KAAA,CAAMC,IAAA;EACrB;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO,KAAK,CAACA,OAAA;EACf;EAEA,OAAgBC,WAAWC,cAAyC,EAAmB;IACrF,MAAMH,IAAA,GAAOI,sBAAA,CAAuBD,cAAA,CAAeE,MAAM;IACzD,OAAOL,IAAA;EACT;EAESM,SAASC,OAAsB,EAAEC,MAAoB,EAAe;IAC3E,oBACEC,IAAA,CAAChB,oBAAA;MACCiB,WAAA,EAAa,IAAI,CAACC,cAAc;MAChCC,SAAA,EAAWJ,MAAA,CAAOK,KAAK,CAACC,WAAW,IAAI;MACvCC,QAAA,EAAU,IAAI,CAACC,SAAS;MACxBC,OAAA,EAAS,IAAI,CAACC,MAAM;;EAG1B;EAESC,WAAA,EAAwC;IAC/C,OAAO,KAAK,CAACA,UAAA;EACf;AACF;AAEA,OAAO,SAASf,uBAAuBC,MAAwC;EAC7E,OAAOf,qBAAA,CACL,IAAIQ,eAAA,CAAgB;IAClBO,MAAA,EAAQ;MACN,GAAGA,MAAM;MACTe,EAAA,EAAIf,MAAA,EAAQe,EAAA,IAAM,IAAI/B,QAAA,CAASQ,OAAO,GAAGwB,WAAW;IACtD;EACF;AAEJ;AAEA,OAAO,SAASC,mBACdtB,IAAsD;EAEtD,OAAOA,IAAA,YAAgBF,eAAA;AACzB","ignoreList":[]}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import type { SerializedEditorState } from 'lexical';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js';
|
|
3
|
-
import type { SerializedNodeBase } from '../../../../types.js';
|
|
4
4
|
import type { JSXConverters } from '../converter/types.js';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export type JSXConvertersFunction<T extends {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
type?: string;
|
|
8
|
+
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
7
9
|
blockName?: null | string;
|
|
8
10
|
}> | SerializedInlineBlockNode<{
|
|
9
11
|
blockName?: null | string;
|
|
10
12
|
}>> = (args: {
|
|
11
13
|
defaultConverters: JSXConverters<DefaultNodeTypes>;
|
|
12
14
|
}) => JSXConverters<T>;
|
|
13
|
-
type RichTextProps
|
|
15
|
+
type RichTextProps = {
|
|
14
16
|
/**
|
|
15
17
|
* Override class names for the container.
|
|
16
18
|
*/
|
|
@@ -19,11 +21,23 @@ type RichTextProps<TNodes extends SerializedNodeBase = SerializedNodeBase> = {
|
|
|
19
21
|
* Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.
|
|
20
22
|
*/
|
|
21
23
|
converters?: JSXConverters | JSXConvertersFunction;
|
|
24
|
+
/**
|
|
25
|
+
* Serialized editor state to render.
|
|
26
|
+
*/
|
|
27
|
+
data: SerializedEditorState;
|
|
22
28
|
/**
|
|
23
29
|
* If true, removes the container div wrapper.
|
|
24
30
|
*/
|
|
25
31
|
disableContainer?: boolean;
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
/**
|
|
33
|
+
* If true, disables indentation globally. If an array, disables for specific node `type` values.
|
|
34
|
+
*/
|
|
35
|
+
disableIndent?: boolean | string[];
|
|
36
|
+
/**
|
|
37
|
+
* If true, disables text alignment globally. If an array, disables for specific node `type` values.
|
|
38
|
+
*/
|
|
39
|
+
disableTextAlign?: boolean | string[];
|
|
40
|
+
};
|
|
41
|
+
export declare const RichText: React.FC<RichTextProps>;
|
|
28
42
|
export {};
|
|
29
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAK1D,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC,GAClD,yBAAyB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC,IAC1D,CAAC,IAAI,EAAE;IAAE,iBAAiB,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAA;CAAE,KAAK,aAAa,CAAC,CAAC,CAAC,CAAA;AAEtF,KAAK,aAAa,GAAG;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,GAAG,qBAAqB,CAAA;IAClD;;OAEG;IACH,IAAI,EAAE,qBAAqB,CAAA;IAC3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAwC5C,CAAA"}
|
|
@@ -2,15 +2,14 @@ import { jsx as _jsx, Fragment as _Fragment } 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
|
-
export
|
|
5
|
+
export const RichText = ({
|
|
6
6
|
className,
|
|
7
7
|
converters,
|
|
8
8
|
data: editorState,
|
|
9
9
|
disableContainer,
|
|
10
10
|
disableIndent,
|
|
11
|
-
disableTextAlign
|
|
12
|
-
|
|
13
|
-
}) {
|
|
11
|
+
disableTextAlign
|
|
12
|
+
}) => {
|
|
14
13
|
if (!editorState) {
|
|
15
14
|
return null;
|
|
16
15
|
}
|
|
@@ -30,8 +29,7 @@ export function RichText({
|
|
|
30
29
|
converters: finalConverters,
|
|
31
30
|
data: editorState,
|
|
32
31
|
disableIndent,
|
|
33
|
-
disableTextAlign
|
|
34
|
-
nodeMap
|
|
32
|
+
disableTextAlign
|
|
35
33
|
});
|
|
36
34
|
if (disableContainer) {
|
|
37
35
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
@@ -42,5 +40,5 @@ export function RichText({
|
|
|
42
40
|
className: className ?? 'payload-richtext',
|
|
43
41
|
children: content
|
|
44
42
|
});
|
|
45
|
-
}
|
|
43
|
+
};
|
|
46
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","defaultJSXConverters","convertLexicalToJSX","RichText","className","converters","data","editorState","disableContainer","disableIndent","disableTextAlign","finalConverters","defaultConverters","content","Array","isArray","_jsx","_Fragment"],"sources":["../../../../../src/features/converters/lexicalToJSX/Component/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'\n\nexport type JSXConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string }>\n | SerializedInlineBlockNode<{ blockName?: null | string }>,\n> = (args: { defaultConverters: JSXConverters<DefaultNodeTypes> }) => JSXConverters<T>\n\ntype RichTextProps = {\n /**\n * Override class names for the container.\n */\n className?: string\n /**\n * Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.\n */\n converters?: JSXConverters | JSXConvertersFunction\n /**\n * Serialized editor state to render.\n */\n data: SerializedEditorState\n /**\n * If true, removes the container div wrapper.\n */\n disableContainer?: boolean\n /**\n * If true, disables indentation globally. If an array, disables for specific node `type` values.\n */\n disableIndent?: boolean | string[]\n /**\n * If true, disables text alignment globally. If an array, disables for specific node `type` values.\n */\n disableTextAlign?: boolean | string[]\n}\n\nexport const RichText: React.FC<RichTextProps> = ({\n className,\n converters,\n data: editorState,\n disableContainer,\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 const content =\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\n if (disableContainer) {\n return <>{content}</>\n }\n\n return <div className={className ?? 'payload-richtext'}>{content}</div>\n}\n"],"mappings":";AAEA,OAAOA,KAAA,MAAW;AASlB,SAASC,oBAAoB,QAAQ;AACrC,SAASC,mBAAmB,QAAQ;AAoCpC,OAAO,MAAMC,QAAA,GAAoCA,CAAC;EAChDC,SAAS;EACTC,UAAU;EACVC,IAAA,EAAMC,WAAW;EACjBC,gBAAgB;EAChBC,aAAa;EACbC;AAAgB,CACjB;EACC,IAAI,CAACH,WAAA,EAAa;IAChB,OAAO;EACT;EAEA,IAAII,eAAA,GAAiC,CAAC;EACtC,IAAIN,UAAA,EAAY;IACd,IAAI,OAAOA,UAAA,KAAe,YAAY;MACpCM,eAAA,GAAkBN,UAAA,CAAW;QAAEO,iBAAA,EAAmBX;MAAqB;IACzE,OAAO;MACLU,eAAA,GAAkBN,UAAA;IACpB;EACF,OAAO;IACLM,eAAA,GAAkBV,oBAAA;EACpB;EAEA,MAAMY,OAAA,GACJN,WAAA,IACA,CAACO,KAAA,CAAMC,OAAO,CAACR,WAAA,KACf,OAAOA,WAAA,KAAgB,YACvB,UAAUA,WAAA,IACVL,mBAAA,CAAoB;IAClBG,UAAA,EAAYM,eAAA;IACZL,IAAA,EAAMC,WAAA;IACNE,aAAA;IACAC;EACF;EAEF,IAAIF,gBAAA,EAAkB;IACpB,oBAAOQ,IAAA,CAAAC,SAAA;gBAAGJ;;EACZ;EAEA,oBAAOG,IAAA,CAAC;IAAIZ,SAAA,EAAWA,SAAA,IAAa;cAAqBS;;AAC3D","ignoreList":[]}
|
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
import type { SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { LexicalEditorNodeMap, SerializedNodeBase } from '../../../../types.js';
|
|
4
3
|
import type { JSXConverters, SerializedLexicalNodeWithParent } from './types.js';
|
|
5
|
-
export type ConvertLexicalToJSXArgs
|
|
4
|
+
export type ConvertLexicalToJSXArgs = {
|
|
6
5
|
converters: JSXConverters;
|
|
7
|
-
/**
|
|
8
|
-
* Serialized editor state to render.
|
|
9
|
-
*/
|
|
10
6
|
data: SerializedEditorState;
|
|
11
|
-
/**
|
|
12
|
-
* If true, disables indentation globally. If an array, disables for specific node `type` values.
|
|
13
|
-
*/
|
|
14
7
|
disableIndent?: boolean | string[];
|
|
15
|
-
/**
|
|
16
|
-
* If true, disables text alignment globally. If an array, disables for specific node `type` values.
|
|
17
|
-
*/
|
|
18
8
|
disableTextAlign?: boolean | string[];
|
|
19
|
-
/**
|
|
20
|
-
* You can use the lexical editor node map or view map as converters. NodeMap converters will override converters passed
|
|
21
|
-
* in the `converters` prop. If a LexicalEditorViewMap is provided, the `default` view will be used.
|
|
22
|
-
*/
|
|
23
|
-
nodeMap?: LexicalEditorNodeMap<TNodes>;
|
|
24
9
|
};
|
|
25
|
-
export declare function convertLexicalToJSX
|
|
10
|
+
export declare function convertLexicalToJSX({ converters, data, disableIndent, disableTextAlign, }: ConvertLexicalToJSXArgs): React.ReactNode;
|
|
26
11
|
export declare function convertLexicalNodesToJSX({ converters, disableIndent, disableTextAlign, nodes, parent, }: {
|
|
27
12
|
converters: JSXConverters;
|
|
28
13
|
disableIndent?: boolean | string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAE3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAgB,aAAa,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAI9F,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,aAAa,CAAA;IACzB,IAAI,EAAE,qBAAqB,CAAA;IAC3B,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;CACtC,CAAA;AAED,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,IAAI,EACJ,aAAa,EACb,gBAAgB,GACjB,EAAE,uBAAuB,GAAG,KAAK,CAAC,SAAS,CAW3C;AAED,wBAAgB,wBAAwB,CAAC,EACvC,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,MAAM,GACP,EAAE;IACD,UAAU,EAAE,aAAa,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IACrC,KAAK,EAAE,qBAAqB,EAAE,CAAA;IAC9B,MAAM,EAAE,+BAA+B,CAAA;CACxC,GAAG,KAAK,CAAC,SAAS,EAAE,CAmIpB"}
|
|
@@ -1,139 +1,19 @@
|
|
|
1
1
|
/* eslint-disable no-console */import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { hasText } from '../../../../validate/hasText.js';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a JSX converter from a NodeMapValue
|
|
6
|
-
*/
|
|
7
|
-
function createConverterFromNodeMapValue(viewDef) {
|
|
8
|
-
return args => {
|
|
9
|
-
const converterArgs = {
|
|
10
|
-
...args,
|
|
11
|
-
isEditor: false,
|
|
12
|
-
isJSXConverter: true
|
|
13
|
-
};
|
|
14
|
-
// If Component is provided, use it
|
|
15
|
-
if (viewDef.Component) {
|
|
16
|
-
return viewDef.Component(converterArgs);
|
|
17
|
-
}
|
|
18
|
-
// If html is provided (as a function or string), use it
|
|
19
|
-
// Note: Using span instead of div to avoid forcing block-level semantics
|
|
20
|
-
if (viewDef.html) {
|
|
21
|
-
const htmlContent = typeof viewDef.html === 'function' ? viewDef.html(converterArgs) : viewDef.html;
|
|
22
|
-
return /*#__PURE__*/_jsx("span", {
|
|
23
|
-
dangerouslySetInnerHTML: {
|
|
24
|
-
__html: htmlContent
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates a JSX converter from a NodeMapBlockValue (for blocks/inlineBlocks)
|
|
33
|
-
* This also checks for Block FC as a fallback when Component is not defined.
|
|
34
|
-
*/
|
|
35
|
-
function createConverterFromBlockValue(viewDef) {
|
|
36
|
-
return args => {
|
|
37
|
-
// Priority: Component > Block > html
|
|
38
|
-
if (viewDef.Component) {
|
|
39
|
-
const converterArgs = {
|
|
40
|
-
...args,
|
|
41
|
-
isEditor: false,
|
|
42
|
-
isJSXConverter: true
|
|
43
|
-
};
|
|
44
|
-
return viewDef.Component(converterArgs);
|
|
45
|
-
}
|
|
46
|
-
// Use Block FC with JSX converter props
|
|
47
|
-
if (viewDef.Block) {
|
|
48
|
-
const blockNode = args.node;
|
|
49
|
-
const blockProps = {
|
|
50
|
-
childIndex: args.childIndex,
|
|
51
|
-
converters: args.converters,
|
|
52
|
-
formData: blockNode.fields ?? {},
|
|
53
|
-
isEditor: false,
|
|
54
|
-
isJSXConverter: true,
|
|
55
|
-
node: blockNode,
|
|
56
|
-
nodesToJSX: args.nodesToJSX,
|
|
57
|
-
parent: args.parent
|
|
58
|
-
};
|
|
59
|
-
return /*#__PURE__*/React.createElement(viewDef.Block, blockProps);
|
|
60
|
-
}
|
|
61
|
-
if (viewDef.html) {
|
|
62
|
-
const converterArgs = {
|
|
63
|
-
...args,
|
|
64
|
-
isEditor: false,
|
|
65
|
-
isJSXConverter: true
|
|
66
|
-
};
|
|
67
|
-
const htmlContent = typeof viewDef.html === 'function' ? viewDef.html(converterArgs) : viewDef.html;
|
|
68
|
-
return /*#__PURE__*/_jsx("span", {
|
|
69
|
-
dangerouslySetInnerHTML: {
|
|
70
|
-
__html: htmlContent
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Converts a LexicalEditorNodeMap into JSXConverters
|
|
79
|
-
*/
|
|
80
|
-
function nodeMapToConverters(nodeMap) {
|
|
81
|
-
const converters = {};
|
|
82
|
-
for (const [nodeType, value] of Object.entries(nodeMap)) {
|
|
83
|
-
if (!value || typeof value !== 'object') {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
// Handle special keys: blocks, inlineBlocks
|
|
87
|
-
if (nodeType === 'blocks') {
|
|
88
|
-
converters.blocks = {};
|
|
89
|
-
for (const [blockType, _viewDef] of Object.entries(value)) {
|
|
90
|
-
const viewDef = _viewDef;
|
|
91
|
-
// Check for Component, Block, or html
|
|
92
|
-
if (viewDef.Component || viewDef.Block || viewDef.html) {
|
|
93
|
-
converters.blocks[blockType] = createConverterFromBlockValue(viewDef);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
if (nodeType === 'inlineBlocks') {
|
|
99
|
-
converters.inlineBlocks = {};
|
|
100
|
-
for (const [blockType, _viewDef] of Object.entries(value)) {
|
|
101
|
-
const viewDef = _viewDef;
|
|
102
|
-
// Check for Component, Block, or html
|
|
103
|
-
if (viewDef.Component || viewDef.Block || viewDef.html) {
|
|
104
|
-
converters.inlineBlocks[blockType] = createConverterFromBlockValue(viewDef);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
// Handle regular node types
|
|
110
|
-
const viewDef = value;
|
|
111
|
-
if (viewDef.Component || viewDef.html) {
|
|
112
|
-
converters[nodeType] = createConverterFromNodeMapValue(viewDef);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return converters;
|
|
116
|
-
}
|
|
117
4
|
export function convertLexicalToJSX({
|
|
118
5
|
converters,
|
|
119
6
|
data,
|
|
120
7
|
disableIndent,
|
|
121
|
-
disableTextAlign
|
|
122
|
-
nodeMap
|
|
8
|
+
disableTextAlign
|
|
123
9
|
}) {
|
|
124
10
|
if (hasText(data)) {
|
|
125
|
-
// Merge nodeMap converters with existing converters
|
|
126
|
-
// NodeMap converters override existing converters
|
|
127
|
-
const mergedConverters = nodeMap ? {
|
|
128
|
-
...converters,
|
|
129
|
-
...nodeMapToConverters(nodeMap)
|
|
130
|
-
} : converters;
|
|
131
11
|
return convertLexicalNodesToJSX({
|
|
132
|
-
converters
|
|
12
|
+
converters,
|
|
133
13
|
disableIndent,
|
|
134
14
|
disableTextAlign,
|
|
135
|
-
nodes: data
|
|
136
|
-
parent: data
|
|
15
|
+
nodes: data?.root?.children,
|
|
16
|
+
parent: data?.root
|
|
137
17
|
});
|
|
138
18
|
}
|
|
139
19
|
return /*#__PURE__*/_jsx(_Fragment, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["jsx","_jsx","Fragment","_Fragment","React","hasText","createConverterFromNodeMapValue","viewDef","args","converterArgs","isEditor","isJSXConverter","Component","html","htmlContent","dangerouslySetInnerHTML","__html","createConverterFromBlockValue","Block","blockNode","node","blockProps","childIndex","converters","formData","fields","nodesToJSX","parent","createElement","nodeMapToConverters","nodeMap","nodeType","value","Object","entries","blocks","blockType","_viewDef","inlineBlocks","convertLexicalToJSX","data","disableIndent","disableTextAlign","mergedConverters","convertLexicalNodesToJSX","nodes","root","children","unknownConverter","unknown","jsxArray","map","i","converterForNode","type","console","error","reactNode","converted","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean"],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedEditorState, SerializedLexicalNode } from 'lexical'\n\nimport React from 'react'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type {\n LexicalEditorNodeMap,\n NodeMapBlockValue,\n NodeMapValue,\n SerializedNodeBase,\n ViewMapBlockJSXConverterProps,\n} from '../../../../types.js'\nimport type { JSXConverter, JSXConverters, SerializedLexicalNodeWithParent } from './types.js'\n\nimport { hasText } from '../../../../validate/hasText.js'\n\n/**\n * Creates a JSX converter from a NodeMapValue\n */\nfunction createConverterFromNodeMapValue(viewDef: NodeMapValue): JSXConverter {\n return (args) => {\n const converterArgs = {\n ...args,\n isEditor: false as const,\n isJSXConverter: true as const,\n }\n\n // If Component is provided, use it\n if (viewDef.Component) {\n return viewDef.Component(converterArgs)\n }\n\n // If html is provided (as a function or string), use it\n // Note: Using span instead of div to avoid forcing block-level semantics\n if (viewDef.html) {\n const htmlContent =\n typeof viewDef.html === 'function' ? viewDef.html(converterArgs) : viewDef.html\n\n return <span dangerouslySetInnerHTML={{ __html: htmlContent }} />\n }\n\n return null\n }\n}\n\n/**\n * Creates a JSX converter from a NodeMapBlockValue (for blocks/inlineBlocks)\n * This also checks for Block FC as a fallback when Component is not defined.\n */\nfunction createConverterFromBlockValue(viewDef: NodeMapBlockValue<any>): JSXConverter {\n return (args) => {\n // Priority: Component > Block > html\n if (viewDef.Component) {\n const converterArgs = {\n ...args,\n isEditor: false as const,\n isJSXConverter: true as const,\n }\n return viewDef.Component(converterArgs)\n }\n\n // Use Block FC with JSX converter props\n if (viewDef.Block) {\n const blockNode = args.node as SerializedBlockNode\n const blockProps: ViewMapBlockJSXConverterProps<any> = {\n childIndex: args.childIndex,\n converters: args.converters,\n formData: blockNode.fields ?? {},\n isEditor: false,\n isJSXConverter: true,\n node: blockNode,\n nodesToJSX: args.nodesToJSX,\n parent: args.parent,\n }\n return React.createElement(viewDef.Block, blockProps)\n }\n\n if (viewDef.html) {\n const converterArgs = {\n ...args,\n isEditor: false as const,\n isJSXConverter: true as const,\n }\n const htmlContent =\n typeof viewDef.html === 'function' ? viewDef.html(converterArgs) : viewDef.html\n\n return <span dangerouslySetInnerHTML={{ __html: htmlContent }} />\n }\n\n return null\n }\n}\n\n/**\n * Converts a LexicalEditorNodeMap into JSXConverters\n */\nfunction nodeMapToConverters<TNodes extends SerializedNodeBase = SerializedNodeBase>(\n nodeMap: LexicalEditorNodeMap<TNodes>,\n): JSXConverters {\n const converters: JSXConverters = {}\n\n for (const [nodeType, value] of Object.entries(nodeMap)) {\n if (!value || typeof value !== 'object') {\n continue\n }\n\n // Handle special keys: blocks, inlineBlocks\n if (nodeType === 'blocks') {\n converters.blocks = {}\n for (const [blockType, _viewDef] of Object.entries(value)) {\n const viewDef = _viewDef as NodeMapBlockValue<any>\n // Check for Component, Block, or html\n if (viewDef.Component || viewDef.Block || viewDef.html) {\n converters.blocks[blockType] = createConverterFromBlockValue(viewDef)\n }\n }\n continue\n }\n\n if (nodeType === 'inlineBlocks') {\n converters.inlineBlocks = {}\n for (const [blockType, _viewDef] of Object.entries(value)) {\n const viewDef = _viewDef as NodeMapBlockValue<any>\n // Check for Component, Block, or html\n if (viewDef.Component || viewDef.Block || viewDef.html) {\n converters.inlineBlocks[blockType] = createConverterFromBlockValue(viewDef)\n }\n }\n continue\n }\n\n // Handle regular node types\n const viewDef = value as NodeMapValue\n\n if (viewDef.Component || viewDef.html) {\n converters[nodeType] = createConverterFromNodeMapValue(viewDef)\n }\n }\n\n return converters\n}\n\nexport type ConvertLexicalToJSXArgs<TNodes extends SerializedNodeBase = SerializedNodeBase> = {\n converters: JSXConverters\n /**\n * Serialized editor state to render.\n */\n data: SerializedEditorState\n /**\n * If true, disables indentation globally. If an array, disables for specific node `type` values.\n */\n disableIndent?: boolean | string[]\n /**\n * If true, disables text alignment globally. If an array, disables for specific node `type` values.\n */\n disableTextAlign?: boolean | string[]\n /**\n * You can use the lexical editor node map or view map as converters. NodeMap converters will override converters passed\n * in the `converters` prop. If a LexicalEditorViewMap is provided, the `default` view will be used.\n */\n nodeMap?: LexicalEditorNodeMap<TNodes>\n}\n\nexport function convertLexicalToJSX<TNodes extends SerializedNodeBase = SerializedNodeBase>({\n converters,\n data,\n disableIndent,\n disableTextAlign,\n nodeMap,\n}: ConvertLexicalToJSXArgs<TNodes>): React.ReactNode {\n if (hasText(data)) {\n // Merge nodeMap converters with existing converters\n // NodeMap converters override existing converters\n const mergedConverters = nodeMap\n ? {\n ...converters,\n ...nodeMapToConverters(nodeMap),\n }\n : converters\n\n return convertLexicalNodesToJSX({\n converters: mergedConverters,\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 && !unknownConverter) {\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 && !unknownConverter) {\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 && unknownConverter) {\n converterForNode = unknownConverter\n }\n\n let reactNode: React.ReactNode\n if (converterForNode) {\n const converted =\n typeof converterForNode === 'function'\n ? 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 : converterForNode\n reactNode = converted\n } else {\n reactNode = <span key={i}>unknown node</span>\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 // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n style.paddingInlineStart = `${Number(node.indent) * 40}px`\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 JSX:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean)\n}\n"],"mappings":"AAAA,+BAA6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AAK;YACR;YACA,IAAIF,SAAA,EAAWa,KAAA,EAAOX,KAAA,IAAS,CAAC,CAAC;UAEnC;UAEA,oBAAOvD,KAAA,CAAMmE,YAAY,CAACd,SAAA,EAAW;YACnCe,GAAA,EAAKpB,CAAA;YACL;YACAO,KAAA,EAAOU;UACT;QACF;QACA,oBAAOjE,KAAA,CAAMmE,YAAY,CAACd,SAAA,EAAW;UACnCe,GAAA,EAAKpB;QACP;MACF;MAEA,OAAOK,SAAA;IACT,EAAE,OAAOD,KAAA,EAAO;MACdD,OAAA,CAAQC,KAAK,CAAC,yCAAyCA,KAAA,EAAO,SAASpC,IAAA;MACvE,OAAO;IACT;EACF;EAEA,OAAO8B,QAAA,CAASuB,MAAM,CAACC,OAAA;AACzB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["jsx","_jsx","Fragment","_Fragment","React","hasText","convertLexicalToJSX","converters","data","disableIndent","disableTextAlign","convertLexicalNodesToJSX","nodes","root","children","parent","unknownConverter","unknown","jsxArray","map","node","i","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","reactNode","converted","childIndex","nodesToJSX","args","style","Array","isArray","includes","format","textAlign","indent","paddingInlineStart","Number","isValidElement","newStyle","props","cloneElement","key","filter","Boolean"],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/index.tsx"],"sourcesContent":["/* eslint-disable no-console */\nimport 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\nimport { hasText } from '../../../../validate/hasText.js'\n\nexport type ConvertLexicalToJSXArgs = {\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}: ConvertLexicalToJSXArgs): React.ReactNode {\n if (hasText(data)) {\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 && !unknownConverter) {\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 && !unknownConverter) {\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 && unknownConverter) {\n converterForNode = unknownConverter\n }\n\n let reactNode: React.ReactNode\n if (converterForNode) {\n const converted =\n typeof converterForNode === 'function'\n ? 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 : converterForNode\n reactNode = converted\n } else {\n reactNode = <span key={i}>unknown node</span>\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 // the unit should be px. Do not change it to rem, em, or something else.\n // The quantity should be 40px. Do not change it either.\n // See rationale in\n // https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085\n style.paddingInlineStart = `${Number(node.indent) * 40}px`\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 JSX:', error, 'node:', node)\n return null\n }\n })\n\n return jsxArray.filter(Boolean)\n}\n"],"mappings":"AAAA,+BAA6B,SAAAA,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAG7B,OAAOC,KAAA,MAAW;AAKlB,SAASC,OAAO,QAAQ;AASxB,OAAO,SAASC,oBAAoB;EAClCC,UAAU;EACVC,IAAI;EACJC,aAAa;EACbC;AAAgB,CACQ;EACxB,IAAIL,OAAA,CAAQG,IAAA,GAAO;IACjB,OAAOG,wBAAA,CAAyB;MAC9BJ,UAAA;MAC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AAKG,IAAI,IACpE;QACA,IAAI,YAAYH,IAAA,IAAQA,IAAA,CAAKqB,MAAM,IAAIrB,IAAA,CAAKG,IAAI,KAAK,YAAY;UAC/D;UACA;UACA;UACA;UACAY,KAAA,CAAMO,kBAAkB,GAAG,GAAGC,MAAA,CAAOvB,IAAA,CAAKqB,MAAM,IAAI,MAAM;QAC5D;MACF;MAEA,iBAAIrC,KAAA,CAAMwC,cAAc,CAACd,SAAA,GAAY;QACnC;QACA,IAAIK,KAAA,CAAMK,SAAS,IAAIL,KAAA,CAAMO,kBAAkB,EAAE;UAC/C,MAAMG,QAAA,GAAW;YACf,GAAGV,KAAK;YACR;YACA,IAAIL,SAAA,EAAWgB,KAAA,EAAOX,KAAA,IAAS,CAAC,CAAC;UAEnC;UAEA,oBAAO/B,KAAA,CAAM2C,YAAY,CAACjB,SAAA,EAAW;YACnCkB,GAAA,EAAK3B,CAAA;YACL;YACAc,KAAA,EAAOU;UACT;QACF;QACA,oBAAOzC,KAAA,CAAM2C,YAAY,CAACjB,SAAA,EAAW;UACnCkB,GAAA,EAAK3B;QACP;MACF;MAEA,OAAOS,SAAA;IACT,EAAE,OAAOF,KAAA,EAAO;MACdD,OAAA,CAAQC,KAAK,CAAC,yCAAyCA,KAAA,EAAO,SAASR,IAAA;MACvE,OAAO;IACT;EACF;EAEA,OAAOF,QAAA,CAAS+B,MAAM,CAACC,OAAA;AACzB","ignoreList":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import type { DefaultNodeTypes, SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js';
|
|
3
|
-
export type
|
|
3
|
+
export type JSXConverter<T extends {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
type?: string;
|
|
6
|
-
} = SerializedLexicalNode> = {
|
|
6
|
+
} = SerializedLexicalNode> = ((args: {
|
|
7
7
|
childIndex: number;
|
|
8
8
|
converters: JSXConverters;
|
|
9
|
-
node:
|
|
9
|
+
node: T;
|
|
10
10
|
nodesToJSX: (args: {
|
|
11
11
|
converters?: JSXConverters;
|
|
12
12
|
disableIndent?: boolean | string[];
|
|
@@ -15,12 +15,8 @@ export type JSXConverterArgs<TNode extends {
|
|
|
15
15
|
parent?: SerializedLexicalNodeWithParent;
|
|
16
16
|
}) => React.ReactNode[];
|
|
17
17
|
parent: SerializedLexicalNodeWithParent;
|
|
18
|
-
};
|
|
19
|
-
export type
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
type?: string;
|
|
22
|
-
} = SerializedLexicalNode> = ((args: JSXConverterArgs<TNode>) => React.ReactNode) | React.ReactNode;
|
|
23
|
-
export type JSXConverters<TNodes extends {
|
|
18
|
+
}) => React.ReactNode) | React.ReactNode;
|
|
19
|
+
export type JSXConverters<T extends {
|
|
24
20
|
[key: string]: any;
|
|
25
21
|
type?: string;
|
|
26
22
|
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
@@ -34,27 +30,27 @@ export type JSXConverters<TNodes extends {
|
|
|
34
30
|
[blockSlug: string]: JSXConverter<any>;
|
|
35
31
|
} | JSXConverter<any> | undefined;
|
|
36
32
|
} & {
|
|
37
|
-
[nodeType in Exclude<NonNullable<
|
|
33
|
+
[nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: JSXConverter<Extract<T, {
|
|
38
34
|
type: nodeType;
|
|
39
35
|
}>>;
|
|
40
36
|
} & {
|
|
41
37
|
blocks?: {
|
|
42
|
-
[K in Extract<Extract<
|
|
38
|
+
[K in Extract<Extract<T, {
|
|
43
39
|
type: 'block';
|
|
44
40
|
}> extends SerializedBlockNode<infer B> ? B extends {
|
|
45
41
|
blockType: string;
|
|
46
|
-
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<
|
|
42
|
+
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<T, {
|
|
47
43
|
type: 'block';
|
|
48
44
|
}> extends SerializedBlockNode<infer B> ? SerializedBlockNode<Extract<B, {
|
|
49
45
|
blockType: K;
|
|
50
46
|
}>> : SerializedBlockNode>;
|
|
51
47
|
};
|
|
52
48
|
inlineBlocks?: {
|
|
53
|
-
[K in Extract<Extract<
|
|
49
|
+
[K in Extract<Extract<T, {
|
|
54
50
|
type: 'inlineBlock';
|
|
55
51
|
}> extends SerializedInlineBlockNode<infer B> ? B extends {
|
|
56
52
|
blockType: string;
|
|
57
|
-
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<
|
|
53
|
+
} ? B['blockType'] : never : never, string>]?: JSXConverter<Extract<T, {
|
|
58
54
|
type: 'inlineBlock';
|
|
59
55
|
}> extends SerializedInlineBlockNode<infer B> ? SerializedInlineBlockNode<Extract<B, {
|
|
60
56
|
blockType: K;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/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,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/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,0BAA0B,CAAA;AACjC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,qBAAqB,IAC5F,CAAC,CAAC,IAAI,EAAE;IACN,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,aAAa,CAAA;IACzB,IAAI,EAAE,CAAC,C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":[],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToJSX/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 | 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 unknown?: JSXConverter<SerializedLexicalNode>\n}\nexport type SerializedLexicalNodeWithParent = {\n parent?: SerializedLexicalNode\n} & SerializedLexicalNode\n"],"mappings":"AAsEA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useEffect","useState","defaultJSXConverters","RichText","RichTextPlugin","$","editor","t0","getEditorState","toJSON","editorState","setEditorState","t1","t2","registerUpdateListener","t3","editorState_0","_jsx","className","children","converters","data"],"sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useEffect, useState } from 'react'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { defaultJSXConverters, RichText } from '../../../../../exports/react/index.js'\nimport './style.scss'\n\nexport function RichTextPlugin() {\n const [editor] = useLexicalComposerContext()\n const [editorState, setEditorState] = useState(
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useEffect","useState","defaultJSXConverters","RichText","RichTextPlugin","$","editor","t0","getEditorState","toJSON","editorState","setEditorState","t1","t2","registerUpdateListener","t3","editorState_0","_jsx","className","children","converters","data"],"sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useEffect, useState } from 'react'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { defaultJSXConverters, RichText } from '../../../../../exports/react/index.js'\nimport './style.scss'\n\nexport function RichTextPlugin() {\n const [editor] = useLexicalComposerContext()\n const [editorState, setEditorState] = useState(editor.getEditorState().toJSON())\n\n useEffect(() => {\n return editor.registerUpdateListener(({ editorState }) => {\n setEditorState(editorState.toJSON())\n })\n }, [editor])\n\n return (\n <div className=\"debug-jsx-converter\">\n <RichText converters={defaultJSXConverters} data={editorState} />\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAEpC;AACA,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAG/C,OAAO,SAAAC,eAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EACL,OAAAQ,MAAA,IAAiBP,yBAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAF,CAAA,QAAAC,MAAA;IAC8BC,EAAA,GAAAD,MAAA,CAAAE,cAAA,CAAqB,EAAAC,MAAA,CAAS;IAAAJ,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAA7E,OAAAK,WAAA,EAAAC,cAAA,IAAsCV,QAAA,CAASM,EAA8B;EAAA,IAAAK,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAR,CAAA,QAAAC,MAAA;IAEnEM,EAAA,GAAAA,CAAA,KACDN,MAAA,CAAAQ,sBAAA,CAAAC,EAAA;MAA+B;QAAAL,WAAA,EAAAM;MAAA,IAAAD,EAAe;MACnDJ,cAAA,CAAeD,aAAA,CAAAD,MAAA,CAAkB;IAAA,CACnC;IACCI,EAAA,IAACP,MAAA;IAAOD,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAO,EAAA;IAAAP,CAAA,MAAAQ,EAAA;EAAA;IAAAD,EAAA,GAAAP,CAAA;IAAAQ,EAAA,GAAAR,CAAA;EAAA;EAJXL,SAAA,CAAUY,EAIV,EAAGC,EAAQ;EAAA,IAAAE,EAAA;EAAA,IAAAV,CAAA,QAAAK,WAAA;IAGTK,EAAA,GAAAE,IAAA,CAAC;MAAAC,SAAA,EAAc;MAAAC,QAAA,EACbF,IAAA,CAAAd,QAAA;QAAAiB,UAAA,EAAAlB,oBAAA;QAAAmB,IAAA,EAAkDX;MAAA,C;;;;;;;SADpDK,E","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAO5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CA4K9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
|