@payloadcms/richtext-lexical 3.50.0-canary.0 → 3.50.0-canary.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js +6 -1
- package/dist/features/blockquote/server/index.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +5 -1
- package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.js +6 -1
- package/dist/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +5 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.d.ts +1 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.d.ts.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js +6 -3
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +6 -1
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.js +37 -24
- package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blockquote/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACrF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAUrC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC;IACE,IAAI,EAAE,OAAO,CAAA;CACd,EACD,oBAAoB,CACrB,CAAA;AAED,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blockquote/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AACrF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAUrC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC;IACE,IAAI,EAAE,OAAO,CAAA;CACd,EACD,oBAAoB,CACrB,CAAA;AAED,eAAO,MAAM,iBAAiB,0FAwD5B,CAAA"}
|
|
@@ -38,7 +38,12 @@ export const BlockquoteFeature = createServerFeature({
|
|
|
38
38
|
req,
|
|
39
39
|
showHiddenFields
|
|
40
40
|
});
|
|
41
|
-
const style = [node.format ? `text-align: ${node.format};` : '',
|
|
41
|
+
const style = [node.format ? `text-align: ${node.format};` : '',
|
|
42
|
+
// the unit should be px. Do not change it to rem, em, or something else.
|
|
43
|
+
// The quantity should be 40px. Do not change it either.
|
|
44
|
+
// See rationale in
|
|
45
|
+
// https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085
|
|
46
|
+
node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : ''].filter(Boolean).join(' ');
|
|
42
47
|
return `<blockquote${style ? ` style='${style}'` : ''}>${childrenText}</blockquote>`;
|
|
43
48
|
},
|
|
44
49
|
nodeTypes: [QuoteNode.getType()]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["QuoteNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","BlockquoteFeature","feature","ClientFeature","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","
|
|
1
|
+
{"version":3,"file":"index.js","names":["QuoteNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","BlockquoteFeature","feature","ClientFeature","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","filter","Boolean","join","nodeTypes","getType","key"],"sources":["../../../../src/features/blockquote/server/index.ts"],"sourcesContent":["import type { SerializedQuoteNode as _SerializedQuoteNode } from '@lexical/rich-text'\nimport type { Spread } from 'lexical'\n\nimport { QuoteNode } from '@lexical/rich-text'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { MarkdownTransformer } from '../markdownTransformer.js'\nimport { i18n } from './i18n.js'\n\nexport type SerializedQuoteNode = Spread<\n {\n type: 'quote'\n },\n _SerializedQuoteNode\n>\n\nexport const BlockquoteFeature = createServerFeature({\n feature: {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlockquoteFeatureClient',\n clientFeatureProps: null,\n i18n,\n markdownTransformers: [MarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n const style = [\n node.format ? `text-align: ${node.format};` : '',\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 node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : '',\n ]\n .filter(Boolean)\n .join(' ')\n\n return `<blockquote${style ? ` style='${style}'` : ''}>${childrenText}</blockquote>`\n },\n nodeTypes: [QuoteNode.getType()],\n },\n },\n node: QuoteNode,\n }),\n ],\n },\n key: 'blockquote',\n})\n"],"mappings":"AAGA,SAASA,SAAS,QAAQ;AAE1B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AASrB,OAAO,MAAMC,iBAAA,GAAoBL,mBAAA,CAAoB;EACnDM,OAAA,EAAS;IACPC,aAAA,EAAe;IACfC,kBAAA,EAAoB;IACpBJ,IAAA;IACAK,oBAAA,EAAsB,CAACN,mBAAA,CAAoB;IAC3CO,KAAA,EAAO,CACLR,UAAA,CAAW;MACTS,UAAA,EAAY;QACVC,IAAA,EAAM;UACJC,SAAA,EAAW,MAAAA,CAAO;YAChBF,UAAU;YACVG,YAAY;YACZC,KAAK;YACLC,KAAK;YACLC,IAAI;YACJC,cAAc;YACdC,MAAM;YACNC,GAAG;YACHC;UAAgB,CACjB;YACC,MAAMC,YAAA,GAAe,MAAMrB,yBAAA,CAA0B;cACnDU,UAAA;cACAG,YAAA;cACAC,KAAA;cACAC,KAAA;cACAO,YAAA,EAAcN,IAAA,CAAKO,QAAQ;cAC3BN,cAAA;cACAC,MAAA,EAAQ;gBACN,GAAGF,IAAI;gBACPE;cACF;cACAC,GAAA;cACAC;YACF;YACA,MAAMI,KAAA,GAAQ,CACZR,IAAA,CAAKS,MAAM,GAAG,eAAeT,IAAA,CAAKS,MAAM,GAAG,GAAG;YAC9C;YACA;YACA;YACA;YACAT,IAAA,CAAKU,MAAM,GAAG,IAAI,yBAAyBV,IAAA,CAAKU,MAAM,GAAG,OAAO,GAAG,GACpE,CACEC,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;YAER,OAAO,cAAcL,KAAA,GAAQ,WAAWA,KAAA,GAAQ,GAAG,MAAMH,YAAA,eAA2B;UACtF;UACAS,SAAA,EAAW,CAAChC,SAAA,CAAUiC,OAAO;QAC/B;MACF;MACAf,IAAA,EAAMlB;IACR;EAEJ;EACAkC,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findConverterForNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml/shared/findConverterForNode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAGpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGrE,wBAAgB,oBAAoB,CAClC,WAAW,SAAS,cAAc,GAAG,mBAAmB,EACxD,UAAU,SAAS,aAAa,GAAG,kBAAkB,EACrD,EACA,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,gBAAgB,GACjB,EAAE;IACD,UAAU,EAAE,WAAW,CAAA;IACvB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IACrC,IAAI,EAAE,qBAAqB,CAAA;IAC3B,gBAAgB,EAAE,UAAU,CAAA;CAC7B,GAAG;IACF,gBAAgB,EAAE,UAAU,GAAG,SAAS,CAAA;IACxC,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;CACzB,
|
|
1
|
+
{"version":3,"file":"findConverterForNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml/shared/findConverterForNode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAGpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGrE,wBAAgB,oBAAoB,CAClC,WAAW,SAAS,cAAc,GAAG,mBAAmB,EACxD,UAAU,SAAS,aAAa,GAAG,kBAAkB,EACrD,EACA,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,gBAAgB,GACjB,EAAE;IACD,UAAU,EAAE,WAAW,CAAA;IACvB,aAAa,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IAClC,gBAAgB,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAA;IACrC,IAAI,EAAE,qBAAqB,CAAA;IAC3B,gBAAgB,EAAE,UAAU,CAAA;CAC7B,GAAG;IACF,gBAAgB,EAAE,UAAU,GAAG,SAAS,CAAA;IACxC,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CA8EA"}
|
|
@@ -46,7 +46,11 @@
|
|
|
46
46
|
}
|
|
47
47
|
if (!disableIndent && (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))) {
|
|
48
48
|
if ('indent' in node && node.indent && node.type !== 'listitem') {
|
|
49
|
-
|
|
49
|
+
// the unit should be px. Do not change it to rem, em, or something else.
|
|
50
|
+
// The quantity should be 40px. Do not change it either.
|
|
51
|
+
// See rationale in
|
|
52
|
+
// https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085
|
|
53
|
+
style['padding-inline-start'] = `${Number(node.indent) * 40}px`;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
let providedCSSString = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findConverterForNode.js","names":["findConverterForNode","converters","disableIndent","disableTextAlign","node","unknownConverter","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","style","Array","isArray","includes","format","indent","Number","providedCSSString","key","Object","keys","providedStyleTag","length"],"sources":["../../../../../src/features/converters/lexicalToHtml/shared/findConverterForNode.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedLexicalNode } from 'lexical'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type { HTMLConverterAsync, HTMLConvertersAsync } from '../async/types.js'\nimport type { HTMLConverter, HTMLConverters } from '../sync/types.js'\nimport type { ProvidedCSS } from './types.js'\n\nexport function findConverterForNode<\n TConverters extends HTMLConverters | HTMLConvertersAsync,\n TConverter extends HTMLConverter | HTMLConverterAsync,\n>({\n converters,\n disableIndent,\n disableTextAlign,\n node,\n unknownConverter,\n}: {\n converters: TConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n node: SerializedLexicalNode\n unknownConverter: TConverter\n}): {\n converterForNode: TConverter | undefined\n providedCSSString: string\n providedStyleTag: string\n} {\n let converterForNode: TConverter | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[\n (node as SerializedBlockNode)?.fields?.blockType\n ] as TConverter\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => HTML 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 = converters?.inlineBlocks?.[\n (node as SerializedInlineBlockNode)?.fields?.blockType\n ] as TConverter\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => HTML 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 TConverter\n }\n\n const style: ProvidedCSS = {}\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['text-align'] = 'center'\n break\n case 'end':\n style['text-align'] = 'right'\n break\n case 'justify':\n style['text-align'] = 'justify'\n break\n case 'left':\n //style['text-align'] = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style['text-align'] = 'right'\n break\n case 'start':\n style['text-align'] = 'left'\n break\n }\n }\n }\n\n if (!disableIndent && (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))) {\n if ('indent' in node && node.indent && node.type !== 'listitem') {\n style['padding-inline-start'] = `${Number(node.indent) *
|
|
1
|
+
{"version":3,"file":"findConverterForNode.js","names":["findConverterForNode","converters","disableIndent","disableTextAlign","node","unknownConverter","converterForNode","type","blocks","fields","blockType","console","error","inlineBlocks","style","Array","isArray","includes","format","indent","Number","providedCSSString","key","Object","keys","providedStyleTag","length"],"sources":["../../../../../src/features/converters/lexicalToHtml/shared/findConverterForNode.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { SerializedLexicalNode } from 'lexical'\n\nimport type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'\nimport type { HTMLConverterAsync, HTMLConvertersAsync } from '../async/types.js'\nimport type { HTMLConverter, HTMLConverters } from '../sync/types.js'\nimport type { ProvidedCSS } from './types.js'\n\nexport function findConverterForNode<\n TConverters extends HTMLConverters | HTMLConvertersAsync,\n TConverter extends HTMLConverter | HTMLConverterAsync,\n>({\n converters,\n disableIndent,\n disableTextAlign,\n node,\n unknownConverter,\n}: {\n converters: TConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n node: SerializedLexicalNode\n unknownConverter: TConverter\n}): {\n converterForNode: TConverter | undefined\n providedCSSString: string\n providedStyleTag: string\n} {\n let converterForNode: TConverter | undefined\n if (node.type === 'block') {\n converterForNode = converters?.blocks?.[\n (node as SerializedBlockNode)?.fields?.blockType\n ] as TConverter\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => HTML 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 = converters?.inlineBlocks?.[\n (node as SerializedInlineBlockNode)?.fields?.blockType\n ] as TConverter\n if (!converterForNode && !unknownConverter) {\n console.error(\n `Lexical => HTML 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 TConverter\n }\n\n const style: ProvidedCSS = {}\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['text-align'] = 'center'\n break\n case 'end':\n style['text-align'] = 'right'\n break\n case 'justify':\n style['text-align'] = 'justify'\n break\n case 'left':\n //style['text-align'] = 'left'\n // Do nothing, as left is the default\n break\n case 'right':\n style['text-align'] = 'right'\n break\n case 'start':\n style['text-align'] = 'left'\n break\n }\n }\n }\n\n if (!disableIndent && (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))) {\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['padding-inline-start'] = `${Number(node.indent) * 40}px`\n }\n }\n\n let providedCSSString: string = ''\n for (const key of Object.keys(style)) {\n // @ts-expect-error we're iterating over the keys of the object\n providedCSSString += `${key}: ${style[key]};`\n }\n const providedStyleTag = providedCSSString?.length ? ` style=\"${providedCSSString}\"` : ''\n\n return {\n converterForNode: converterForNode ?? unknownConverter,\n providedCSSString,\n providedStyleTag,\n }\n}\n"],"mappings":"AAAA,+BAQA,OAAO,SAASA,qBAGd;EACAC,UAAU;EACVC,aAAa;EACbC,gBAAgB;EAChBC,IAAI;EACJC;AAAgB,CAOjB;EAKC,IAAIC,gBAAA;EACJ,I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,aAAA,KAAkB,CAACA,aAAA,EAAee,QAAA,CAASb,IAAA,CAAKG,IAAI,IAAI;IAC5F,IAAI,YAAYH,IAAA,IAAQA,IAAA,CAAKe,MAAM,IAAIf,IAAA,CAAKG,IAAI,KAAK,YAAY;MAC/D;MACA;MACA;MACA;MACAO,KAAK,CAAC,uBAAuB,GAAG,GAAGM,MAAA,CAAOhB,IAAA,CAAKe,MAAM,IAAI,MAAM;IACjE;EACF;EAEA,IAAIE,iBAAA,GAA4B;EAChC,KAAK,MAAMC,GAAA,IAAOC,MAAA,CAAOC,IAAI,CAACV,KAAA,GAAQ;IACpC;IACAO,iBAAA,IAAqB,GAAGC,GAAA,KAAQR,KAAK,CAACQ,GAAA,CAAI,GAAG;EAC/C;EACA,MAAMG,gBAAA,GAAmBJ,iBAAA,EAAmBK,MAAA,GAAS,WAAWL,iBAAA,GAAoB,GAAG;EAEvF,OAAO;IACLf,gBAAA,EAAkBA,gBAAA,IAAoBD,gBAAA;IACtCgB,iBAAA;IACAI;EACF;AACF","ignoreList":[]}
|
package/dist/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../../../src/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,uBAAuB,
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../../../../../src/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AAC1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,uBAAuB,CAuCzE,CAAA"}
|
|
@@ -25,7 +25,12 @@ export const ParagraphHTMLConverter = {
|
|
|
25
25
|
req,
|
|
26
26
|
showHiddenFields
|
|
27
27
|
});
|
|
28
|
-
const style = [node.format ? `text-align: ${node.format};` : '',
|
|
28
|
+
const style = [node.format ? `text-align: ${node.format};` : '',
|
|
29
|
+
// the unit should be px. Do not change it to rem, em, or something else.
|
|
30
|
+
// The quantity should be 40px. Do not change it either.
|
|
31
|
+
// See rationale in
|
|
32
|
+
// https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085
|
|
33
|
+
node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : ''].filter(Boolean).join(' ');
|
|
29
34
|
return `<p${style ? ` style='${style}'` : ''}>${childrenText}</p>`;
|
|
30
35
|
},
|
|
31
36
|
nodeTypes: ['paragraph']
|
package/dist/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.js","names":["convertLexicalNodesToHTML","ParagraphHTMLConverter","converter","converters","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","
|
|
1
|
+
{"version":3,"file":"paragraph.js","names":["convertLexicalNodesToHTML","ParagraphHTMLConverter","converter","converters","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","filter","Boolean","join","nodeTypes"],"sources":["../../../../../../src/features/converters/lexicalToHtml_deprecated/converter/converters/paragraph.ts"],"sourcesContent":["import type { SerializedParagraphNode } from '../../../../../nodeTypes.js'\nimport type { HTMLConverter } from '../types.js'\n\nimport { convertLexicalNodesToHTML } from '../index.js'\n\nexport const ParagraphHTMLConverter: HTMLConverter<SerializedParagraphNode> = {\n async converter({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n const style = [\n node.format ? `text-align: ${node.format};` : '',\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 node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : '',\n ]\n .filter(Boolean)\n .join(' ')\n return `<p${style ? ` style='${style}'` : ''}>${childrenText}</p>`\n },\n nodeTypes: ['paragraph'],\n}\n"],"mappings":"AAGA,SAASA,yBAAyB,QAAQ;AAE1C,OAAO,MAAMC,sBAAA,GAAiE;EAC5E,MAAMC,UAAU;IACdC,UAAU;IACVC,YAAY;IACZC,KAAK;IACLC,KAAK;IACLC,IAAI;IACJC,cAAc;IACdC,MAAM;IACNC,GAAG;IACHC;EAAgB,CACjB;IACC,MAAMC,YAAA,GAAe,MAAMZ,yBAAA,CAA0B;MACnDG,UAAA;MACAC,YAAA;MACAC,KAAA;MACAC,KAAA;MACAO,YAAA,EAAcN,IAAA,CAAKO,QAAQ;MAC3BN,cAAA;MACAC,MAAA,EAAQ;QACN,GAAGF,IAAI;QACPE;MACF;MACAC,GAAA;MACAC;IACF;IACA,MAAMI,KAAA,GAAQ,CACZR,IAAA,CAAKS,MAAM,GAAG,eAAeT,IAAA,CAAKS,MAAM,GAAG,GAAG;IAC9C;IACA;IACA;IACA;IACAT,IAAA,CAAKU,MAAM,GAAG,IAAI,yBAAyBV,IAAA,CAAKU,MAAM,GAAG,OAAO,GAAG,GACpE,CACEC,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;IACR,OAAO,KAAKL,KAAA,GAAQ,WAAWA,KAAA,GAAQ,GAAG,MAAMH,YAAA,MAAkB;EACpE;EACAS,SAAA,EAAW,CAAC;AACd","ignoreList":[]}
|
|
@@ -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,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,
|
|
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"}
|
|
@@ -98,7 +98,11 @@ export function convertLexicalNodesToJSX({
|
|
|
98
98
|
}
|
|
99
99
|
if (!disableIndent && (!Array.isArray(disableIndent) || !disableIndent?.includes(node.type))) {
|
|
100
100
|
if ('indent' in node && node.indent && node.type !== 'listitem') {
|
|
101
|
-
|
|
101
|
+
// the unit should be px. Do not change it to rem, em, or something else.
|
|
102
|
+
// The quantity should be 40px. Do not change it either.
|
|
103
|
+
// See rationale in
|
|
104
|
+
// https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085
|
|
105
|
+
style.paddingInlineStart = `${Number(node.indent) * 40}px`;
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
if (/*#__PURE__*/React.isValidElement(reactNode)) {
|
|
@@ -1 +1 @@
|
|
|
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 style.paddingInlineStart = `${Number(node.indent) *
|
|
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;MACAE,aAAA;MACAC,gBAAA;MACAE,KAAA,EAAOJ,IAAA,EAAMK,IAAA,EAAMC,QAAA;MACnBC,MAAA,EAAQP,IAAA,EAAMK;IAChB;EACF;EACA,oBAAOZ,IAAA,CAAAE,SAAA;AACT;AAEA,OAAO,SAASQ,yBAAyB;EACvCJ,UAAU;EACVE,aAAa;EACbC,gBAAgB;EAChBE,KAAK;EACLG;AAAM,CAOP;EACC,MAAMC,gBAAA,GAAsCT,UAAA,CAAWU,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,GAAmBf,UAAA,EAAYiB,MAAA,GAAUJ,IAAA,EAA8BK,MAAA,E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AA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"names":[],"mappings":"AAOA,OAAO,cAAc,CAAA;AAErB,wBAAgB,cAAc,gCAe7B"}
|
|
@@ -38,9 +38,12 @@ export function RichTextPlugin() {
|
|
|
38
38
|
useEffect(t1, t2);
|
|
39
39
|
let t3;
|
|
40
40
|
if ($[5] !== editorState) {
|
|
41
|
-
t3 = _jsx(
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
t3 = _jsx("div", {
|
|
42
|
+
className: "debug-jsx-converter",
|
|
43
|
+
children: _jsx(RichText, {
|
|
44
|
+
converters: defaultJSXConverters,
|
|
45
|
+
data: editorState
|
|
46
|
+
})
|
|
44
47
|
});
|
|
45
48
|
$[5] = editorState;
|
|
46
49
|
$[6] = t3;
|
|
@@ -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","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'\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 <RichText converters={defaultJSXConverters} data={editorState} />\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;
|
|
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,yBAA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../src/features/heading/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,IAAI,sBAAsB,EAC/C,cAAc,EACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAUrC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,IAAI,EAAE,SAAS,CAAA;CAChB,EACD,sBAAsB,CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/heading/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,IAAI,sBAAsB,EAC/C,cAAc,EACf,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAUrC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CACxC;IACE,IAAI,EAAE,SAAS,CAAA;CAChB,EACD,sBAAsB,CACvB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,cAAc,6HAoEzB,CAAA"}
|
|
@@ -47,7 +47,12 @@ export const HeadingFeature = createServerFeature({
|
|
|
47
47
|
req,
|
|
48
48
|
showHiddenFields
|
|
49
49
|
});
|
|
50
|
-
const style = [node.format ? `text-align: ${node.format};` : '',
|
|
50
|
+
const style = [node.format ? `text-align: ${node.format};` : '',
|
|
51
|
+
// the unit should be px. Do not change it to rem, em, or something else.
|
|
52
|
+
// The quantity should be 40px. Do not change it either.
|
|
53
|
+
// See rationale in
|
|
54
|
+
// https://github.com/payloadcms/payload/issues/13130#issuecomment-3058348085
|
|
55
|
+
node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : ''].filter(Boolean).join(' ');
|
|
51
56
|
return `<${node?.tag}${style ? ` style='${style}'` : ''}>${childrenText}</${node?.tag}>`;
|
|
52
57
|
},
|
|
53
58
|
nodeTypes: [HeadingNode.getType()]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["HeadingNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","HeadingFeature","feature","props","enabledHeadingSizes","ClientFeature","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","
|
|
1
|
+
{"version":3,"file":"index.js","names":["HeadingNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","HeadingFeature","feature","props","enabledHeadingSizes","ClientFeature","clientFeatureProps","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","style","format","indent","filter","Boolean","join","tag","nodeTypes","getType","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/heading/server/index.ts"],"sourcesContent":["import type {\n SerializedHeadingNode as _SerializedHeadingNode,\n HeadingTagType,\n} from '@lexical/rich-text'\nimport type { Spread } from 'lexical'\n\nimport { HeadingNode } from '@lexical/rich-text'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { MarkdownTransformer } from '../markdownTransformer.js'\nimport { i18n } from './i18n.js'\n\nexport type SerializedHeadingNode = Spread<\n {\n type: 'heading'\n },\n _SerializedHeadingNode\n>\n\nexport type HeadingFeatureProps = {\n enabledHeadingSizes?: HeadingTagType[]\n}\n\nexport const HeadingFeature = createServerFeature<\n HeadingFeatureProps,\n HeadingFeatureProps,\n HeadingFeatureProps\n>({\n feature: ({ props }) => {\n if (!props) {\n props = {}\n }\n\n const { enabledHeadingSizes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] } = props\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#HeadingFeatureClient',\n clientFeatureProps: props,\n i18n,\n markdownTransformers: [MarkdownTransformer(enabledHeadingSizes)],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n currentDepth,\n depth,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n currentDepth,\n depth,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n const style = [\n node.format ? `text-align: ${node.format};` : '',\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 node.indent > 0 ? `padding-inline-start: ${node.indent * 40}px;` : '',\n ]\n .filter(Boolean)\n .join(' ')\n return `<${node?.tag}${style ? ` style='${style}'` : ''}>${childrenText}</${node?.tag}>`\n },\n nodeTypes: [HeadingNode.getType()],\n },\n },\n node: HeadingNode,\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'heading',\n})\n"],"mappings":"AAMA,SAASA,WAAW,QAAQ;AAE5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AAarB,OAAO,MAAMC,cAAA,GAAiBL,mBAAA,CAI5B;EACAM,OAAA,EAASA,CAAC;IAAEC;EAAK,CAAE;IACjB,IAAI,CAACA,KAAA,EAAO;MACVA,KAAA,GAAQ,CAAC;IACX;IAEA,MAAM;MAAEC,mBAAA,GAAsB,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM;IAAK,CAAE,GAAGD,KAAA;IAEvE,OAAO;MACLE,aAAA,EAAe;MACfC,kBAAA,EAAoBH,KAAA;MACpBH,IAAA;MACAO,oBAAA,EAAsB,CAACR,mBAAA,CAAoBK,mBAAA,EAAqB;MAChEI,KAAA,EAAO,CACLV,UAAA,CAAW;QACTW,UAAA,EAAY;UACVC,IAAA,EAAM;YACJC,SAAA,EAAW,MAAAA,CAAO;cAChBF,UAAU;cACVG,YAAY;cACZC,KAAK;cACLC,KAAK;cACLC,IAAI;cACJC,cAAc;cACdC,MAAM;cACNC,GAAG;cACHC;YAAgB,CACjB;cACC,MAAMC,YAAA,GAAe,MAAMvB,yBAAA,CAA0B;gBACnDY,UAAA;gBACAG,YAAA;gBACAC,KAAA;gBACAC,KAAA;gBACAO,YAAA,EAAcN,IAAA,CAAKO,QAAQ;gBAC3BN,cAAA;gBACAC,MAAA,EAAQ;kBACN,GAAGF,IAAI;kBACPE;gBACF;gBACAC,GAAA;gBACAC;cACF;cACA,MAAMI,KAAA,GAAQ,CACZR,IAAA,CAAKS,MAAM,GAAG,eAAeT,IAAA,CAAKS,MAAM,GAAG,GAAG;cAC9C;cACA;cACA;cACA;cACAT,IAAA,CAAKU,MAAM,GAAG,IAAI,yBAAyBV,IAAA,CAAKU,MAAM,GAAG,OAAO,GAAG,GACpE,CACEC,MAAM,CAACC,OAAA,EACPC,IAAI,CAAC;cACR,OAAO,IAAIb,IAAA,EAAMc,GAAA,GAAMN,KAAA,GAAQ,WAAWA,KAAA,GAAQ,GAAG,MAAMH,YAAA,KAAiBL,IAAA,EAAMc,GAAA,GAAM;YAC1F;YACAC,SAAA,EAAW,CAACnC,WAAA,CAAYoC,OAAO;UACjC;QACF;QACAhB,IAAA,EAAMpB;MACR,GACD;MACDqC,2BAAA,EAA6B7B;IAC/B;EACF;EACA8B,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAI/D,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,SAAS,GACV,EAAE;IACD,UAAU,EAAE,kBAAkB,EAAE,CAAA;IAChC,SAAS,EAAE,SAAS,EAAE,CAAA;CACvB,GAAG,qBAAqB,CAgBxB;AAED,wBAAgB,0BAA0B,CAAC,EACzC,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,UAAU,GACX,EAAE;IACD,oBAAoB,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAA;IAC5C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB,GAAG,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAI/D,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,SAAS,GACV,EAAE;IACD,UAAU,EAAE,kBAAkB,EAAE,CAAA;IAChC,SAAS,EAAE,SAAS,EAAE,CAAA;CACvB,GAAG,qBAAqB,CAgBxB;AAED,wBAAgB,0BAA0B,CAAC,EACzC,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,UAAU,GACX,EAAE;IACD,oBAAoB,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAA;IAC5C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB,GAAG,qBAAqB,EAAE,CAiD1B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,kBAAkB,EAAE,EAChC,IAAI,EAAE,SAAS,GACd,uBAAuB,CAgBzB;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAUnE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAwB3D"}
|
|
@@ -30,36 +30,49 @@ export function convertSlateNodesToLexical({
|
|
|
30
30
|
}
|
|
31
31
|
const unknownConverter = converters.find(converter => converter.nodeTypes.includes('unknown'));
|
|
32
32
|
// @ts-expect-error - vestiges of the migration to strict mode. Probably not important enough in this file to fix
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
return (
|
|
34
|
+
// Flatten in case we unwrap an array of child nodes
|
|
35
|
+
slateNodes.flatMap((slateNode, i) => {
|
|
36
|
+
if (!('type' in slateNode)) {
|
|
37
|
+
if (canContainParagraphs) {
|
|
38
|
+
// This is a paragraph node. They do not have a type property in Slate
|
|
39
|
+
return convertParagraphNode(converters, slateNode);
|
|
40
|
+
} else {
|
|
41
|
+
// Unwrap generic Slate nodes recursively since depth wasn't guaranteed by Slate, especially when copy + pasting rich text
|
|
42
|
+
// - If there are children and it can't be a paragraph in Lexical, assume that the generic node should be unwrapped until the text nodes, and only assume that its a text node when there are no more children
|
|
43
|
+
if (slateNode.children) {
|
|
44
|
+
return convertSlateNodesToLexical({
|
|
45
|
+
canContainParagraphs,
|
|
46
|
+
converters,
|
|
47
|
+
parentNodeType,
|
|
48
|
+
slateNodes: slateNode.children || []
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// This is a simple text node. canContainParagraphs may be false if this is nested inside a paragraph already, since paragraphs cannot contain paragraphs
|
|
52
|
+
return convertTextNode(slateNode);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (slateNode.type === 'p') {
|
|
37
56
|
return convertParagraphNode(converters, slateNode);
|
|
38
|
-
} else {
|
|
39
|
-
// This is a simple text node. canContainParagraphs may be false if this is nested inside a paragraph already, since paragraphs cannot contain paragraphs
|
|
40
|
-
return convertTextNode(slateNode);
|
|
41
57
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
const converter = converters.find(converter => converter.nodeTypes.includes(slateNode.type));
|
|
59
|
+
if (converter) {
|
|
60
|
+
return converter.converter({
|
|
61
|
+
childIndex: i,
|
|
62
|
+
converters,
|
|
63
|
+
parentNodeType,
|
|
64
|
+
slateNode
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
console.warn('slateToLexical > No converter found for node type: ' + slateNode.type);
|
|
68
|
+
return unknownConverter?.converter({
|
|
49
69
|
childIndex: i,
|
|
50
70
|
converters,
|
|
51
71
|
parentNodeType,
|
|
52
72
|
slateNode
|
|
53
73
|
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return unknownConverter?.converter({
|
|
57
|
-
childIndex: i,
|
|
58
|
-
converters,
|
|
59
|
-
parentNodeType,
|
|
60
|
-
slateNode
|
|
61
|
-
});
|
|
62
|
-
}) || [];
|
|
74
|
+
}) || []
|
|
75
|
+
);
|
|
63
76
|
}
|
|
64
77
|
export function convertParagraphNode(converters, node) {
|
|
65
78
|
return {
|
|
@@ -85,7 +98,7 @@ export function convertTextNode(node) {
|
|
|
85
98
|
format: convertNodeToFormat(node),
|
|
86
99
|
mode: 'normal',
|
|
87
100
|
style: '',
|
|
88
|
-
text: node.text,
|
|
101
|
+
text: node.text ?? "",
|
|
89
102
|
version: 1
|
|
90
103
|
};
|
|
91
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["NodeFormat","convertSlateToLexical","converters","slateData","root","type","children","convertSlateNodesToLexical","canContainParagraphs","parentNodeType","slateNodes","direction","format","indent","version","length","unknownConverter","find","converter","nodeTypes","includes","
|
|
1
|
+
{"version":3,"file":"index.js","names":["NodeFormat","convertSlateToLexical","converters","slateData","root","type","children","convertSlateNodesToLexical","canContainParagraphs","parentNodeType","slateNodes","direction","format","indent","version","length","unknownConverter","find","converter","nodeTypes","includes","flatMap","slateNode","i","convertParagraphNode","convertTextNode","childIndex","console","warn","node","textFormat","textStyle","detail","convertNodeToFormat","mode","style","text","bold","IS_BOLD","italic","IS_ITALIC","strikethrough","IS_STRIKETHROUGH","underline","IS_UNDERLINE","subscript","IS_SUBSCRIPT","superscript","IS_SUPERSCRIPT","code","IS_CODE"],"sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\nimport type { SlateNode, SlateNodeConverter } from './types.js'\n\nimport { NodeFormat } from '../../../../lexical/utils/nodeFormat.js'\n\nexport function convertSlateToLexical({\n converters,\n slateData,\n}: {\n converters: SlateNodeConverter[]\n slateData: SlateNode[]\n}): SerializedEditorState {\n return {\n root: {\n type: 'root',\n children: convertSlateNodesToLexical({\n canContainParagraphs: true,\n converters,\n parentNodeType: 'root',\n slateNodes: slateData,\n }),\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n}\n\nexport function convertSlateNodesToLexical({\n canContainParagraphs,\n converters,\n parentNodeType,\n slateNodes,\n}: {\n canContainParagraphs: boolean\n converters: SlateNodeConverter[] | undefined\n /**\n * Type of the parent lexical node (not the type of the original, parent slate type)\n */\n parentNodeType: string\n slateNodes: SlateNode[]\n}): SerializedLexicalNode[] {\n if (!converters?.length || !slateNodes?.length) {\n return []\n }\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n // @ts-expect-error - vestiges of the migration to strict mode. Probably not important enough in this file to fix\n return (\n // Flatten in case we unwrap an array of child nodes\n slateNodes.flatMap((slateNode, i) => {\n if (!('type' in slateNode)) {\n if (canContainParagraphs) {\n // This is a paragraph node. They do not have a type property in Slate\n return convertParagraphNode(converters, slateNode)\n } else {\n // Unwrap generic Slate nodes recursively since depth wasn't guaranteed by Slate, especially when copy + pasting rich text\n // - If there are children and it can't be a paragraph in Lexical, assume that the generic node should be unwrapped until the text nodes, and only assume that its a text node when there are no more children\n if (slateNode.children) {\n return convertSlateNodesToLexical({\n canContainParagraphs,\n converters,\n parentNodeType,\n slateNodes: slateNode.children || [],\n })\n }\n // This is a simple text node. canContainParagraphs may be false if this is nested inside a paragraph already, since paragraphs cannot contain paragraphs\n return convertTextNode(slateNode)\n }\n }\n if (slateNode.type === 'p') {\n return convertParagraphNode(converters, slateNode)\n }\n\n const converter = converters.find((converter) =>\n converter.nodeTypes.includes(slateNode.type!),\n )\n\n if (converter) {\n return converter.converter({ childIndex: i, converters, parentNodeType, slateNode })\n }\n\n console.warn('slateToLexical > No converter found for node type: ' + slateNode.type)\n return unknownConverter?.converter({\n childIndex: i,\n converters,\n parentNodeType,\n slateNode,\n })\n }) || []\n )\n}\n\nexport function convertParagraphNode(\n converters: SlateNodeConverter[],\n node: SlateNode,\n): SerializedParagraphNode {\n return {\n type: 'paragraph',\n children: convertSlateNodesToLexical({\n canContainParagraphs: false,\n converters,\n parentNodeType: 'paragraph',\n slateNodes: node.children || [],\n }),\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n }\n}\nexport function convertTextNode(node: SlateNode): SerializedTextNode {\n return {\n type: 'text',\n detail: 0,\n format: convertNodeToFormat(node),\n mode: 'normal',\n style: '',\n text: node.text ?? \"\",\n version: 1,\n }\n}\n\nexport function convertNodeToFormat(node: SlateNode): number {\n let format = 0\n if (node.bold) {\n format = format | NodeFormat.IS_BOLD\n }\n if (node.italic) {\n format = format | NodeFormat.IS_ITALIC\n }\n if (node.strikethrough) {\n format = format | NodeFormat.IS_STRIKETHROUGH\n }\n if (node.underline) {\n format = format | NodeFormat.IS_UNDERLINE\n }\n if (node.subscript) {\n format = format | NodeFormat.IS_SUBSCRIPT\n }\n if (node.superscript) {\n format = format | NodeFormat.IS_SUPERSCRIPT\n }\n if (node.code) {\n format = format | NodeFormat.IS_CODE\n }\n return format\n}\n"],"mappings":"AASA,SAASA,UAAU,QAAQ;AAE3B,OAAO,SAASC,sBAAsB;EACpCC,UAAU;EACVC;AAAS,CAIV;EACC,OAAO;IACLC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAUC,0BAAA,CAA2B;QACnCC,oBAAA,EAAsB;QACtBN,UAAA;QACAO,cAAA,EAAgB;QAChBC,UAAA,EAAYP;MACd;MACAQ,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;AACF;AAEA,OAAO,SAASP,2BAA2B;EACzCC,oBAAoB;EACpBN,UAAU;EACVO,cAAc;EACdC;AAAU,CASX;EACC,IAAI,CAACR,UAAA,EAAYa,MAAA,IAAU,CAACL,UAAA,EAAYK,MAAA,EAAQ;IAC9C,OAAO,EAAE;EACX;EACA,MAAMC,gBAAA,GAAmBd,UAAA,CAAWe,IAAI,CAAEC,SAAA,IAAcA,SAAA,CAAUC,SAAS,CAACC,QAAQ,CAAC;EACrF;EACA;IACE;IACAV,UAAA,CAAWW,OAAO,CAAC,CAACC,SAAA,EAAWC,CAAA;MAC7B,IAAI,EAAE,UAAUD,SAAQ,GAAI;QAC1B,IAAId,oBAAA,EAAsB;UACxB;UACA,OAAOgB,oBAAA,CAAqBtB,UAAA,EAAYoB,SAAA;QAC1C,OAAO;UACL;UACA;UACA,IAAIA,SAAA,CAAUhB,QAAQ,EAAE;YACtB,OAAOC,0BAAA,CAA2B;cAChCC,oBAAA;cACAN,UAAA;cACAO,cAAA;cACAC,UAAA,EAAYY,SAAA,CAAUhB,QAAQ,IAAI;YACpC;UACF;UACA;UACA,OAAOmB,eAAA,CAAgBH,SAAA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