@payloadcms/richtext-lexical 3.60.0-canary.1 → 3.60.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.
Files changed (77) hide show
  1. package/dist/exports/client/Field-YHS7VMOE.js +2 -0
  2. package/dist/exports/client/Field-YHS7VMOE.js.map +7 -0
  3. package/dist/exports/client/{chunk-XNERFY6G.js → chunk-ADWHGDDR.js} +2 -2
  4. package/dist/exports/client/{chunk-XNERFY6G.js.map → chunk-ADWHGDDR.js.map} +2 -2
  5. package/dist/exports/client/componentInline-MIPTDFRK.js +2 -0
  6. package/dist/exports/client/index.d.ts +1 -1
  7. package/dist/exports/client/index.d.ts.map +1 -1
  8. package/dist/exports/client/index.js +13 -13
  9. package/dist/exports/client/index.js.map +3 -3
  10. package/dist/features/blockquote/server/index.d.ts +3 -4
  11. package/dist/features/blockquote/server/index.d.ts.map +1 -1
  12. package/dist/features/blockquote/server/index.js.map +1 -1
  13. package/dist/features/blocks/premade/CodeBlock/index.d.ts +3 -1
  14. package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -1
  15. package/dist/features/blocks/premade/CodeBlock/index.js +7 -2
  16. package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -1
  17. package/dist/features/blocks/server/nodes/BlocksNode.d.ts +4 -5
  18. package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
  19. package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
  20. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +4 -5
  21. package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
  22. package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
  23. package/dist/features/converters/lexicalToHtml_deprecated/field/index.d.ts.map +1 -1
  24. package/dist/features/converters/lexicalToHtml_deprecated/field/index.js.map +1 -1
  25. package/dist/features/experimental_table/server/index.d.ts +5 -10
  26. package/dist/features/experimental_table/server/index.d.ts.map +1 -1
  27. package/dist/features/experimental_table/server/index.js.map +1 -1
  28. package/dist/features/heading/server/index.d.ts +3 -4
  29. package/dist/features/heading/server/index.d.ts.map +1 -1
  30. package/dist/features/heading/server/index.js.map +1 -1
  31. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +3 -5
  32. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
  33. package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
  34. package/dist/features/link/nodes/types.d.ts +6 -6
  35. package/dist/features/link/nodes/types.d.ts.map +1 -1
  36. package/dist/features/link/nodes/types.js.map +1 -1
  37. package/dist/features/lists/plugin/index.d.ts +6 -7
  38. package/dist/features/lists/plugin/index.d.ts.map +1 -1
  39. package/dist/features/lists/plugin/index.js.map +1 -1
  40. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +3 -5
  41. package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
  42. package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
  43. package/dist/features/typesServer.d.ts +4 -4
  44. package/dist/features/typesServer.d.ts.map +1 -1
  45. package/dist/features/typesServer.js.map +1 -1
  46. package/dist/features/upload/server/nodes/UploadNode.d.ts +3 -5
  47. package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
  48. package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
  49. package/dist/field/RenderLexical/index.d.ts +2 -1
  50. package/dist/field/RenderLexical/index.d.ts.map +1 -1
  51. package/dist/field/RenderLexical/index.js.map +1 -1
  52. package/dist/index.d.ts +1 -1
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +1 -1
  55. package/dist/index.js.map +1 -1
  56. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  57. package/dist/lexical/LexicalEditor.js +2 -1
  58. package/dist/lexical/LexicalEditor.js.map +1 -1
  59. package/dist/lexical/plugins/ClipboardPlugin/index.d.ts +2 -0
  60. package/dist/lexical/plugins/ClipboardPlugin/index.d.ts.map +1 -0
  61. package/dist/lexical/plugins/ClipboardPlugin/index.js +64 -0
  62. package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -0
  63. package/dist/nodeTypes.d.ts +46 -20
  64. package/dist/nodeTypes.d.ts.map +1 -1
  65. package/dist/nodeTypes.js.map +1 -1
  66. package/dist/types.d.ts +2 -1
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/types.js.map +1 -1
  69. package/dist/utilities/buildEditorState.d.ts +47 -6
  70. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  71. package/dist/utilities/buildEditorState.js +10 -1
  72. package/dist/utilities/buildEditorState.js.map +1 -1
  73. package/package.json +7 -6
  74. package/dist/exports/client/Field-CJFETHA3.js +0 -2
  75. package/dist/exports/client/Field-CJFETHA3.js.map +0 -7
  76. package/dist/exports/client/componentInline-NGTRUSGB.js +0 -2
  77. /package/dist/exports/client/{componentInline-NGTRUSGB.js.map → componentInline-MIPTDFRK.js.map} +0 -0
@@ -1,7 +1,6 @@
1
1
  import type { SerializedQuoteNode as _SerializedQuoteNode } from '@lexical/rich-text';
2
- import type { Spread } from 'lexical';
3
- export type SerializedQuoteNode = Spread<{
4
- type: 'quote';
5
- }, _SerializedQuoteNode>;
2
+ import type { SerializedLexicalNode } from 'lexical';
3
+ import type { StronglyTypedElementNode } from '../../../nodeTypes.js';
4
+ export type SerializedQuoteNode<T extends SerializedLexicalNode = SerializedLexicalNode> = StronglyTypedElementNode<_SerializedQuoteNode, 'quote', T>;
6
5
  export declare const BlockquoteFeature: import("../../typesServer.js").FeatureProviderProviderServer<undefined, undefined, null>;
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -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,0FAwD5B,CAAA"}
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,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAQrE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IACrF,wBAAwB,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AAE5D,eAAO,MAAM,iBAAiB,0FAwD5B,CAAA"}
@@ -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","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
+ {"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 { SerializedLexicalNode } from 'lexical'\n\nimport { QuoteNode } from '@lexical/rich-text'\n\nimport type { StronglyTypedElementNode } from '../../../nodeTypes.js'\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<T extends SerializedLexicalNode = SerializedLexicalNode> =\n StronglyTypedElementNode<_SerializedQuoteNode, 'quote', T>\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;AAI1B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AAKrB,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":[]}
@@ -3,5 +3,7 @@ import type { AdditionalCodeComponentProps } from './Component/Code.js';
3
3
  /**
4
4
  * @experimental - this API may change in future, minor releases
5
5
  */
6
- export declare const CodeBlock: (args?: AdditionalCodeComponentProps) => Block;
6
+ export declare const CodeBlock: (args?: {
7
+ fieldOverrides?: Partial<Block>;
8
+ } & AdditionalCodeComponentProps) => Block;
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/premade/CodeBlock/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAKvE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,4BAA4B,KAAK,KA+ChE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/premade/CodeBlock/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAKvE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,CACtB,IAAI,CAAC,EAAE;IACL,cAAc,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;CAChC,GAAG,4BAA4B,KAC7B,KAiDJ,CAAA"}
@@ -3,7 +3,11 @@ import { codeConverter } from './converter.js';
3
3
  /**
4
4
  * @experimental - this API may change in future, minor releases
5
5
  */
6
- export const CodeBlock = args => {
6
+ export const CodeBlock = _args => {
7
+ const {
8
+ fieldOverrides,
9
+ ...args
10
+ } = _args || {};
7
11
  const languages = args?.languages || defaultLanguages;
8
12
  return {
9
13
  slug: args?.slug || 'Code',
@@ -44,7 +48,8 @@ export const CodeBlock = args => {
44
48
  },
45
49
  label: ''
46
50
  }],
47
- jsx: codeConverter
51
+ jsx: codeConverter,
52
+ ...(fieldOverrides || {})
48
53
  };
49
54
  };
50
55
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["defaultLanguages","codeConverter","CodeBlock","args","languages","slug","admin","components","Block","clientProps","path","jsx","fields","name","type","hidden","defaultValue","defaultLanguage","Object","keys","options","entries","map","key","value","label","Field"],"sources":["../../../../../src/features/blocks/premade/CodeBlock/index.ts"],"sourcesContent":["import type { Block } from 'payload'\n\nimport type { AdditionalCodeComponentProps } from './Component/Code.js'\n\nimport { defaultLanguages } from './Component/defaultLanguages.js'\nimport { codeConverter } from './converter.js'\n\n/**\n * @experimental - this API may change in future, minor releases\n */\nexport const CodeBlock: (args?: AdditionalCodeComponentProps) => Block = (args) => {\n const languages = args?.languages || defaultLanguages\n\n return {\n slug: args?.slug || 'Code',\n admin: {\n components: {\n Block: {\n clientProps: {\n // If default languages are used, return undefined (=> do not pass `languages` variable) in order to reduce data sent to the client\n languages: args?.languages,\n },\n path: '@payloadcms/richtext-lexical/client#CodeBlockBlockComponent',\n },\n },\n jsx: '@payloadcms/richtext-lexical/client#codeConverterClient',\n },\n fields: [\n {\n name: 'language',\n type: 'select',\n admin: {\n // We'll manually render this field into the block component header\n hidden: true,\n },\n defaultValue: args?.defaultLanguage || Object.keys(languages)[0],\n options: Object.entries(languages).map(([key, value]) => ({\n label: value,\n value: key,\n })),\n },\n {\n name: 'code',\n type: 'code',\n admin: {\n components: {\n Field: {\n clientProps: args,\n path: '@payloadcms/richtext-lexical/client#CodeComponent',\n },\n },\n },\n label: '',\n },\n ],\n jsx: codeConverter,\n }\n}\n"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ;AACjC,SAASC,aAAa,QAAQ;AAE9B;;;AAGA,OAAO,MAAMC,SAAA,GAA6DC,IAAA;EACxE,MAAMC,SAAA,GAAYD,IAAA,EAAMC,SAAA,IAAaJ,gBAAA;EAErC,OAAO;IACLK,IAAA,EAAMF,IAAA,EAAME,IAAA,IAAQ;IACpBC,KAAA,EAAO;MACLC,UAAA,EAAY;QACVC,KAAA,EAAO;UACLC,WAAA,EAAa;YACX;YACAL,SAAA,EAAWD,IAAA,EAAMC;UACnB;UACAM,IAAA,EAAM;QACR;MACF;MACAC,GAAA,EAAK;IACP;IACAC,MAAA,EAAQ,CACN;MACEC,IAAA,EAAM;MACNC,IAAA,EAAM;MACNR,KAAA,EAAO;QACL;QACAS,MAAA,EAAQ;MACV;MACAC,YAAA,EAAcb,IAAA,EAAMc,eAAA,IAAmBC,MAAA,CAAOC,IAAI,CAACf,SAAA,CAAU,CAAC,EAAE;MAChEgB,OAAA,EAASF,MAAA,CAAOG,OAAO,CAACjB,SAAA,EAAWkB,GAAG,CAAC,CAAC,CAACC,GAAA,EAAKC,KAAA,CAAM,MAAM;QACxDC,KAAA,EAAOD,KAAA;QACPA,KAAA,EAAOD;MACT;IACF,GACA;MACEV,IAAA,EAAM;MACNC,IAAA,EAAM;MACNR,KAAA,EAAO;QACLC,UAAA,EAAY;UACVmB,KAAA,EAAO;YACLjB,WAAA,EAAaN,IAAA;YACbO,IAAA,EAAM;UACR;QACF;MACF;MACAe,KAAA,EAAO;IACT,EACD;IACDd,GAAA,EAAKV;EACP;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["defaultLanguages","codeConverter","CodeBlock","_args","fieldOverrides","args","languages","slug","admin","components","Block","clientProps","path","jsx","fields","name","type","hidden","defaultValue","defaultLanguage","Object","keys","options","entries","map","key","value","label","Field"],"sources":["../../../../../src/features/blocks/premade/CodeBlock/index.ts"],"sourcesContent":["import type { Block } from 'payload'\n\nimport type { AdditionalCodeComponentProps } from './Component/Code.js'\n\nimport { defaultLanguages } from './Component/defaultLanguages.js'\nimport { codeConverter } from './converter.js'\n\n/**\n * @experimental - this API may change in future, minor releases\n */\nexport const CodeBlock: (\n args?: {\n fieldOverrides?: Partial<Block>\n } & AdditionalCodeComponentProps,\n) => Block = (_args) => {\n const { fieldOverrides, ...args } = _args || {}\n const languages = args?.languages || defaultLanguages\n\n return {\n slug: args?.slug || 'Code',\n admin: {\n components: {\n Block: {\n clientProps: {\n // If default languages are used, return undefined (=> do not pass `languages` variable) in order to reduce data sent to the client\n languages: args?.languages,\n },\n path: '@payloadcms/richtext-lexical/client#CodeBlockBlockComponent',\n },\n },\n jsx: '@payloadcms/richtext-lexical/client#codeConverterClient',\n },\n fields: [\n {\n name: 'language',\n type: 'select',\n admin: {\n // We'll manually render this field into the block component header\n hidden: true,\n },\n defaultValue: args?.defaultLanguage || Object.keys(languages)[0],\n options: Object.entries(languages).map(([key, value]) => ({\n label: value,\n value: key,\n })),\n },\n {\n name: 'code',\n type: 'code',\n admin: {\n components: {\n Field: {\n clientProps: args,\n path: '@payloadcms/richtext-lexical/client#CodeComponent',\n },\n },\n },\n label: '',\n },\n ],\n jsx: codeConverter,\n ...(fieldOverrides || {}),\n }\n}\n"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ;AACjC,SAASC,aAAa,QAAQ;AAE9B;;;AAGA,OAAO,MAAMC,SAAA,GAICC,KAAA;EACZ,MAAM;IAAEC,cAAc;IAAE,GAAGC;EAAA,CAAM,GAAGF,KAAA,IAAS,CAAC;EAC9C,MAAMG,SAAA,GAAYD,IAAA,EAAMC,SAAA,IAAaN,gBAAA;EAErC,OAAO;IACLO,IAAA,EAAMF,IAAA,EAAME,IAAA,IAAQ;IACpBC,KAAA,EAAO;MACLC,UAAA,EAAY;QACVC,KAAA,EAAO;UACLC,WAAA,EAAa;YACX;YACAL,SAAA,EAAWD,IAAA,EAAMC;UACnB;UACAM,IAAA,EAAM;QACR;MACF;MACAC,GAAA,EAAK;IACP;IACAC,MAAA,EAAQ,CACN;MACEC,IAAA,EAAM;MACNC,IAAA,EAAM;MACNR,KAAA,EAAO;QACL;QACAS,MAAA,EAAQ;MACV;MACAC,YAAA,EAAcb,IAAA,EAAMc,eAAA,IAAmBC,MAAA,CAAOC,IAAI,CAACf,SAAA,CAAU,CAAC,EAAE;MAChEgB,OAAA,EAASF,MAAA,CAAOG,OAAO,CAACjB,SAAA,EAAWkB,GAAG,CAAC,CAAC,CAACC,GAAA,EAAKC,KAAA,CAAM,MAAM;QACxDC,KAAA,EAAOD,KAAA;QACPA,KAAA,EAAOD;MACT;IACF,GACA;MACEV,IAAA,EAAM;MACNC,IAAA,EAAM;MACNR,KAAA,EAAO;QACLC,UAAA,EAAY;UACVmB,KAAA,EAAO;YACLjB,WAAA,EAAaN,IAAA;YACbO,IAAA,EAAM;UACR;QACF;MACF;MACAe,KAAA,EAAO;IACT,EACD;IACDd,GAAA,EAAKZ,aAAA;IACL,IAAIG,cAAA,IAAkB,CAAC,CAAC;EAC1B;AACF","ignoreList":[]}
@@ -1,8 +1,9 @@
1
1
  import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
2
- import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey, Spread } from 'lexical';
2
+ import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
3
3
  import type { JsonObject } from 'payload';
4
4
  import type { JSX } from 'react';
5
5
  import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
6
+ import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
6
7
  type BaseBlockFields<TBlockFields extends JsonObject = JsonObject> = {
7
8
  /** Block form data */
8
9
  blockName: string;
@@ -14,11 +15,9 @@ export type BlockFields<TBlockFields extends JsonObject = JsonObject> = {
14
15
  export type BlockFieldsOptionalID<TBlockFields extends JsonObject = JsonObject> = {
15
16
  id?: string;
16
17
  } & BaseBlockFields<TBlockFields>;
17
- export type SerializedBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<{
18
- children?: never;
18
+ export type SerializedBlockNode<TBlockFields extends JsonObject = JsonObject> = {
19
19
  fields: BlockFields<TBlockFields>;
20
- type: 'block';
21
- }, SerializedDecoratorBlockNode>;
20
+ } & StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'block'>;
22
21
  export declare class ServerBlockNode extends DecoratorBlockNode {
23
22
  __cacheBuster: number;
24
23
  __fields: BlockFields;
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/server/nodes/BlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAA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EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;IAIlE,SAAS,IAAI,eAAe;IAQ5B,UAAU,IAAI,mBAAmB;IAS1C,cAAc,IAAI,MAAM;IAIxB,SAAS,IAAI,WAAW;IAIf,cAAc,IAAI,MAAM;IAIjC,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI;CAOvE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CAOrF;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,eAAe,GAAG,SAAS,GACrD,IAAI,IAAI,eAAe,CAEzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksNode.js","names":["DecoratorBlockNode","ObjectID","ServerBlockNode","__cacheBuster","__fields","constructor","cacheBuster","fields","format","key","clone","node","__format","__key","getType","importDOM","importJSON","serializedNode","version","data","$createServerBlockNode","setFormat","isInline","decorate","editor","config","exportDOM","element","document","createElement","text","createTextNode","getTextContent","append","exportJSON","type","getFields","getCacheBuster","getLatest","setFields","preventFormStateUpdate","writable","getWritable","id","default","toHexString","$isServerBlockNode"],"sources":["../../../../../src/features/blocks/server/nodes/BlocksNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\n\ntype BaseBlockFields<TBlockFields extends JsonObject = JsonObject> = {\n /** Block form data */\n blockName: string\n blockType: string\n} & TBlockFields\n\nexport type BlockFields<TBlockFields extends JsonObject = JsonObject> = {\n id: string\n} & BaseBlockFields<TBlockFields>\n\nexport type BlockFieldsOptionalID<TBlockFields extends JsonObject = JsonObject> = {\n id?: string\n} & BaseBlockFields<TBlockFields>\n\nexport type SerializedBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: BlockFields<TBlockFields>\n type: 'block'\n },\n SerializedDecoratorBlockNode\n>\n\nexport class ServerBlockNode extends DecoratorBlockNode {\n __cacheBuster: number\n __fields: BlockFields\n\n constructor({\n cacheBuster,\n fields,\n format,\n key,\n }: {\n cacheBuster?: number\n fields: BlockFields\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerBlockNode): ServerBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'block'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedBlockNode): ServerBlockNode {\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 = $createServerBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedBlockNode {\n return {\n ...super.exportJSON(),\n type: 'block',\n fields: this.getFields(),\n version: 2,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): BlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n setFields(fields: BlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n}\n\nexport function $createServerBlockNode(fields: BlockFieldsOptionalID): ServerBlockNode {\n return new ServerBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerBlockNode(\n node: LexicalNode | null | ServerBlockNode | undefined,\n): node is ServerBlockNode {\n return node instanceof ServerBlockNode\n}\n"],"mappings":"AAcA,SAASA,kBAAkB,QAAQ;AACnC,OAAOC,QAAA,MAAc;AAyBrB,OAAO,MAAMC,eAAA,SAAwBF,kBAAA;EACnCG,aAAA;EACAC,QAAA;EAEAC,YAAY;IACVC,WAAW;IACXC,MAAM;IACNC,MAAM;IACNC;EAAG,CAMJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACL,QAAQ,GAAGG,MAAA;IAChB,IAAI,CAACJ,aAAa,GAAGG,WAAA,IAAe;EACtC;EAEA,OAAgBI,MAAMC,IAAqB,EAAmB;IAC5D,OAAO,IAAI,IAAI,CAAC;MACdL,WAAA,EAAaK,IAAA,CAAKR,aAAa;MAC/BI,MAAA,EAAQI,IAAA,CAAKP,QAAQ;MACrBI,MAAA,EAAQG,IAAA,CAAKC,QAAQ;MACrBH,GAAA,EAAKE,IAAA,CAAKE;IACZ;EACF;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO;EACT;EAEA,OAAgBC,UAAA,EAAqD;IACnE,OAAO,CAAC;EACV;EAEA,OAAgBC,WAAWC,cAAmC,EAAmB;IAC/E,IAAIA,cAAA,CAAeC,OAAO,KAAK,GAAG;MAChC;MACAD,cAAA,GAAiB;QACf,GAAGA,cAAc;QACjBV,MAAA,EAAQ;UACN,GAAGU,cAAC,CAAuBV,MAAM,CAACY;QACpC;QACAD,OAAA,EAAS;MACX;IACF;IACA,MAAMP,IAAA,GAAOS,s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OA,IAAA,YAAgBT,eAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"BlocksNode.js","names":["DecoratorBlockNode","ObjectID","ServerBlockNode","__cacheBuster","__fields","constructor","cacheBuster","fields","format","key","clone","node","__format","__key","getType","importDOM","importJSON","serializedNode","version","data","$createServerBlockNode","setFormat","isInline","decorate","editor","config","exportDOM","element","document","createElement","text","createTextNode","getTextContent","append","exportJSON","type","getFields","getCacheBuster","getLatest","setFields","preventFormStateUpdate","writable","getWritable","id","default","toHexString","$isServerBlockNode"],"sources":["../../../../../src/features/blocks/server/nodes/BlocksNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n ElementFormatType,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport ObjectID from 'bson-objectid'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\ntype BaseBlockFields<TBlockFields extends JsonObject = JsonObject> = {\n /** Block form data */\n blockName: string\n blockType: string\n} & TBlockFields\n\nexport type BlockFields<TBlockFields extends JsonObject = JsonObject> = {\n id: string\n} & BaseBlockFields<TBlockFields>\n\nexport type BlockFieldsOptionalID<TBlockFields extends JsonObject = JsonObject> = {\n id?: string\n} & BaseBlockFields<TBlockFields>\n\nexport type SerializedBlockNode<TBlockFields extends JsonObject = JsonObject> = {\n fields: BlockFields<TBlockFields>\n} & StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'block'>\n\nexport class ServerBlockNode extends DecoratorBlockNode {\n __cacheBuster: number\n __fields: BlockFields\n\n constructor({\n cacheBuster,\n fields,\n format,\n key,\n }: {\n cacheBuster?: number\n fields: BlockFields\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerBlockNode): ServerBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'block'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedBlockNode): ServerBlockNode {\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 = $createServerBlockNode(serializedNode.fields)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedBlockNode {\n return {\n ...super.exportJSON(),\n type: 'block',\n fields: this.getFields(),\n version: 2,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): BlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n setFields(fields: BlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n}\n\nexport function $createServerBlockNode(fields: BlockFieldsOptionalID): ServerBlockNode {\n return new ServerBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerBlockNode(\n node: LexicalNode | null | ServerBlockNode | undefined,\n): node is ServerBlockNode {\n return node instanceof ServerBlockNode\n}\n"],"mappings":"AAaA,SAASA,kBAAkB,QAAQ;AACnC,OAAOC,QAAA,MAAc;AAsBrB,OAAO,MAAMC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;EACnB;EAESO,WAAA,EAAkC;IACzC,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrBC,IAAA,EAAM;MACN5B,MAAA,EAAQ,IAAI,CAAC6B,SAAS;MACtBlB,OAAA,EAAS;IACX;EACF;EAEAmB,eAAA,EAAyB;IACvB,OAAO,IAAI,CAACC,SAAS,GAAGnC,aAAa;EACvC;EAEAiC,UAAA,EAAyB;IACvB,OAAO,IAAI,CAACE,SAAS,GAAGlC,QAAQ;EAClC;EAES4B,eAAA,EAAyB;IAChC,OAAO,aAAa;EACtB;EAEAO,UAAUhC,MAAmB,EAAEiC,sBAAgC,EAAQ;IACrE,MAAMC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAASrC,QAAQ,GAAGG,MAAA;IACpB,IAAI,CAACiC,sBAAA,EAAwB;MAC3BC,QAAA,CAAStC,aAAa;IACxB;EACF;AACF;AAEA,OAAO,SAASiB,uBAAuBb,MAA6B;EAClE,OAAO,IAAIL,eAAA,CAAgB;IACzBK,MAAA,EAAQ;MACN,GAAGA,MAAM;MACToC,EAAA,EAAIpC,MAAA,EAAQoC,EAAA,IAAM,IAAI1C,QAAA,CAAS2C,OAAO,GAAGC,WAAW;IACtD;EACF;AACF;AAEA,OAAO,SAASC,mBACdnC,IAAsD;EAEtD,OAAOA,IAAA,YAAgBT,eAAA;AACzB","ignoreList":[]}
@@ -1,17 +1,16 @@
1
- import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical';
1
+ import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedLexicalNode } from 'lexical';
2
2
  import type { JsonObject } from 'payload';
3
3
  import type React from 'react';
4
4
  import type { JSX } from 'react';
5
5
  import { DecoratorNode } from 'lexical';
6
+ import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
6
7
  export type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {
7
8
  blockType: string;
8
9
  id: string;
9
10
  } & TInlineBlockFields;
10
- export type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<{
11
- children?: never;
11
+ export type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = {
12
12
  fields: InlineBlockFields<TBlockFields>;
13
- type: 'inlineBlock';
14
- }, SerializedLexicalNode>;
13
+ } & StronglyTypedLeafNode<SerializedLexicalNode, 'inlineBlock'>;
15
14
  export declare class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {
16
15
  __cacheBuster: number;
17
16
  __fields: InlineBlockFields;
@@ -1 +1 @@
1
- {"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACP,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEvC,MAAM,MAAM,iBAAiB,CAAC,kBAAkB,SAAS,UAAU,GAAG,UAAU,IAAI;IAClF,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;CACX,GAAG,kBAAkB,CAAA;AAEtB,MAAM,MAAM,yBAAyB,CAAC,YAAY,SAAS,UAAU,GAAG,UAAU,IAAI,MAAM,CAC1F;IACE,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,MAAM,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAA;IACvC,IAAI,EAAE,aAAa,CAAA;CACpB,EACD,qBAAqB,CACtB,CAAA;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AM,CAAC,QAAQ,IAAI,KAAK;IAIxB,SAAS;IAGA,SAAS;IAOT,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI;IAIzE,SAAS,IAAI,eAAe;IAS5B,UAAU,IAAI,yBAAyB;IAQhD,cAAc,IAAI,MAAM;IAIxB,SAAS,IAAI,iBAAiB;IAIrB,cAAc,IAAI,MAAM;IAIxB,QAAQ;IAIjB,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI;IAQnE,SAAS,IAAI,OAAO;CAG9B;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,GACvC,qBAAqB,CAOvB;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,qBAAqB,GAAG,SAAS,GAC3D,IAAI,IAAI,qBAAqB,CAE/B"}
@@ -1 +1 @@
1
- {"version":3,"file":"InlineBlocksNode.js","names":["ObjectID","DecoratorNode","ServerInlineBlockNode","__cacheBuster","__fields","constructor","cacheBuster","fields","key","clone","node","__key","getType","importDOM","importJSON","serializedNode","$createServerInlineBlockNode","isInline","canIndent","createDOM","element","document","createElement","classList","add","decorate","editor","config","exportDOM","text","createTextNode","getTextContent","append","exportJSON","type","getFields","version","getCacheBuster","getLatest","setFields","preventFormStateUpdate","writable","getWritable","updateDOM","id","default","toHexString","$isServerInlineBlockNode"],"sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],"mappings":"AAcA,OAAOA,QAAA,MAAc;AACrB,SAASC,aAAa,QAAQ;AAgB9B,OAAO,MAAMC,qBAAA,SAA8BD,aAAA;EACzCE,aAAA;EACAC,QAAA;EAEAC,YAAY;IACVC,WAAW;IACXC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACA,GAAA;IACN,IAAI,CAACJ,QAAQ,GAAGG,MAAA;IAChB,IAAI,CAACJ,aAAa,GAAGG,WAAA,IAAe;EACtC;EAEA,OAAgBG,MAAMC,IAA2B,EAAyB;IACxE,OAAO,IAAI,IAAI,CAAC;MACdJ,WAAA,EAAaI,IAAA,CAAKP,aAAa;MAC/BI,MAAA,EAAQG,IAAA,CAAKN,QAAQ;MACrBI,GAAA,EAAKE,IAAA,CAAKC;IACZ;EACF;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO;EACT;EAEA,OAAgBC,UAAA,EAAqD;IACnE,OAAO,CAAC;EACV;EAEA,OAAgBC,WAAWC,cAAyC,EAAyB;IAC3F,MAAML,IAAA,GAAOM,4BAAA,CAA6BD,cAAA,CAAeR,MAAM;IAC/D,OAAOG,IAAA;EACT;EAEA,OAAOO,SAAA,EAAkB;IACvB,OAAO;EACT;EAEAC,UAAA,EAAY;IACV,OAAO;EACT;EACSC,UAAA,EAAY;IACnB,MAAMC,OAAA,GAAUC,QAAA,CAASC,aAAa,CAAC;IACvCF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IAAA,YAAgBR,qBAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"InlineBlocksNode.js","names":["ObjectID","DecoratorNode","ServerInlineBlockNode","__cacheBuster","__fields","constructor","cacheBuster","fields","key","clone","node","__key","getType","importDOM","importJSON","serializedNode","$createServerInlineBlockNode","isInline","canIndent","createDOM","element","document","createElement","classList","add","decorate","editor","config","exportDOM","text","createTextNode","getTextContent","append","exportJSON","type","getFields","version","getCacheBuster","getLatest","setFields","preventFormStateUpdate","writable","getWritable","updateDOM","id","default","toHexString","$isServerInlineBlockNode"],"sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = {\n fields: InlineBlockFields<TBlockFields>\n} & StronglyTypedLeafNode<SerializedLexicalNode, 'inlineBlock'>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],"mappings":"AAaA,OAAOA,QAAA,MAAc;AACrB,SAASC,aAAa,QAAQ;AAa9B,OAAO,MAAMC,qBAAA,SAA8BD,aAAA;EACzCE,aAAA;EACAC,QAAA;EAEAC,YAAY;IACVC,WAAW;IACXC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACA,GAAA;IACN,IAAI,CAACJ,QAAQ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AI,CAACG,SAAS,GAAGlC,QAAQ;EAClC;EAES2B,eAAA,EAAyB;IAChC,OAAO,aAAa;EACtB;EAESd,SAAA,EAAW;IAClB,OAAO;EACT;EAEAsB,UAAUhC,MAAyB,EAAEiC,sBAAgC,EAAQ;IAC3E,MAAMC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAASrC,QAAQ,GAAGG,MAAA;IACpB,IAAI,CAACiC,sBAAA,EAAwB;MAC3BC,QAAA,CAAStC,aAAa;IACxB;EACF;EAESwC,UAAA,EAAqB;IAC5B,OAAO;EACT;AACF;AAEA,OAAO,SAAS3B,6BACdT,MAAwC;EAExC,OAAO,IAAIL,qBAAA,CAAsB;IAC/BK,MAAA,EAAQ;MACN,GAAGA,MAAM;MACTqC,EAAA,EAAIrC,MAAA,EAAQqC,EAAA,IAAM,IAAI5C,QAAA,CAAS6C,OAAO,GAAGC,WAAW;IACtD;EACF;AACF;AAEA,OAAO,SAASC,yBACdrC,IAA4D;EAE5D,OAAOA,IAAA,YAAgBR,qBAAA;AACzB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/field/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAA;AAEnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAA;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAM1D,KAAK,IAAI,GAAG;IACV;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,sBAEnC;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAG,aAAa,EA+ChB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE;AACxB;;;;IAII;AACJ,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,IAAI,KACP,KAwFJ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/field/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAA;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAM1D,KAAK,IAAI,GAAG;IACV;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,sBAEnC;IACD,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAG,aAAa,EA+ChB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE;AACxB;;;;IAII;AACJ,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,IAAI,KACP,KAuFJ,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["defaultHTMLConverters","convertLexicalToHTML","consolidateHTMLConverters","editorConfig","htmlConverterFeature","resolvedFeatureMap","get","htmlConverterFeatureProps","sanitizedServerFeatureProps","defaultConvertersWithConvertersFromFeatures","converter","features","converters","html","push","finalConverters","defaultConverters","foundNodeTypes","filteredConverters","reverse","nodeTypes","length","newConverter","filter","nodeType","includes","lexicalHTML","lexicalFieldName","args","name","hidden","storeInDB","type","admin","editorOptions","language","hooks","afterRead","currentDepth","depth","draft","field","overrideAccess","req","showHiddenFields","siblingData","siblingFields","Error","lexicalField","find","lexicalFieldData","config","editor","has","data","beforeChange","value"],"sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/field/index.ts"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { Field, RichTextField } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../../../../lexical/config/types.js'\nimport type { AdapterProps, LexicalRichTextAdapter } from '../../../../types.js'\nimport type { HTMLConverter } from '../converter/types.js'\nimport type { HTMLConverterFeatureProps } from '../index.js'\n\nimport { defaultHTMLConverters } from '../converter/defaultConverters.js'\nimport { convertLexicalToHTML } from '../converter/index.js'\n\ntype Args = {\n /**\n * Whether the lexicalHTML field should be hidden in the admin panel\n *\n * @default true\n */\n hidden?: boolean\n name: string\n /**\n * Whether the HTML should be stored in the database\n *\n * @default false\n */\n storeInDB?: boolean\n}\n\n/**\n * Combines the default HTML converters with HTML converters found in the features, and with HTML converters configured in the htmlConverter feature.\n *\n * @deprecated - will be removed in 4.0\n * @param editorConfig\n */\nexport const consolidateHTMLConverters = ({\n editorConfig,\n}: {\n editorConfig: SanitizedServerEditorConfig\n}): HTMLConverter[] => {\n const htmlConverterFeature = editorConfig.resolvedFeatureMap.get('htmlConverter')\n const htmlConverterFeatureProps: HTMLConverterFeatureProps =\n htmlConverterFeature?.sanitizedServerFeatureProps\n\n const defaultConvertersWithConvertersFromFeatures = [...defaultHTMLConverters]\n\n for (const converter of editorConfig.features.converters.html) {\n defaultConvertersWithConvertersFromFeatures.push(converter)\n }\n\n const finalConverters =\n htmlConverterFeatureProps?.converters &&\n typeof htmlConverterFeatureProps?.converters === 'function'\n ? htmlConverterFeatureProps.converters({\n defaultConverters: defaultConvertersWithConvertersFromFeatures,\n })\n : (htmlConverterFeatureProps?.converters as HTMLConverter[]) ||\n defaultConvertersWithConvertersFromFeatures\n\n // filter converters by nodeTypes. The last converter in the list wins. If there are multiple converters for the same nodeType, the last one will be used and the node types will be removed from\n // previous converters. If previous converters do not have any nodeTypes left, they will be removed from the list.\n // This guarantees that user-added converters which are added after the default ones will always have precedence\n const foundNodeTypes: string[] = []\n const filteredConverters: HTMLConverter[] = []\n for (const converter of finalConverters.reverse()) {\n if (!converter.nodeTypes?.length) {\n continue\n }\n const newConverter: HTMLConverter = {\n converter: converter.converter,\n nodeTypes: [...converter.nodeTypes],\n }\n newConverter.nodeTypes = newConverter.nodeTypes.filter((nodeType) => {\n if (foundNodeTypes.includes(nodeType)) {\n return false\n }\n foundNodeTypes.push(nodeType)\n return true\n })\n\n if (newConverter.nodeTypes.length) {\n filteredConverters.push(newConverter)\n }\n }\n\n return filteredConverters\n}\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport const lexicalHTML: (\n /**\n * A string which matches the lexical field name you want to convert to HTML.\n *\n * This has to be a sibling field of this lexicalHTML field - otherwise, it won't be able to find the lexical field.\n **/\n lexicalFieldName: string,\n args: Args,\n) => Field = (lexicalFieldName, args) => {\n const { name = 'lexicalHTML', hidden = true, storeInDB = false } = args\n return {\n name,\n type: 'code',\n admin: {\n editorOptions: {\n language: 'html',\n },\n hidden,\n },\n hooks: {\n afterRead: [\n async ({\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n req,\n showHiddenFields,\n siblingData,\n siblingFields,\n }) => {\n if (!siblingFields) {\n throw new Error(\n `Could not find sibling fields of current lexicalHTML field with name ${field?.name}`,\n )\n }\n\n const lexicalField: RichTextField<SerializedEditorState, AdapterProps> =\n siblingFields.find(\n (field) => 'name' in field && field.name === lexicalFieldName,\n ) as RichTextField<SerializedEditorState, AdapterProps>\n\n const lexicalFieldData: SerializedEditorState = siblingData[lexicalFieldName]\n\n if (!lexicalFieldData) {\n return ''\n }\n\n if (!lexicalField) {\n throw new Error(\n 'You cannot use the lexicalHTML field because the referenced lexical field was not found',\n )\n }\n\n const config = (lexicalField?.editor as LexicalRichTextAdapter)?.editorConfig\n\n if (!config) {\n throw new Error(\n 'The linked lexical field does not have an editorConfig. This is needed for the lexicalHTML field.',\n )\n }\n\n if (!config?.resolvedFeatureMap?.has('htmlConverter')) {\n throw new Error(\n 'You cannot use the lexicalHTML field because the linked lexical field does not have a HTMLConverterFeature',\n )\n }\n\n const finalConverters = consolidateHTMLConverters({\n editorConfig: config,\n })\n\n return await convertLexicalToHTML({\n converters: finalConverters,\n currentDepth,\n data: lexicalFieldData,\n depth,\n draft,\n overrideAccess,\n req,\n showHiddenFields,\n })\n },\n ],\n beforeChange: [\n ({ siblingData, value }) => {\n if (storeInDB) {\n return value\n }\n delete siblingData[name]\n return null\n },\n ],\n },\n }\n}\n"],"mappings":"AAQA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,oBAAoB,QAAQ;AAkBrC;;;;;;AAMA,OAAO,MAAMC,yBAAA,GAA4BA,CAAC;EACxCC;AAAY,CAGb;EACC,MAAMC,oBAAA,GAAuBD,YAAA,CAAaE,kBAAkB,CAACC,GAAG,CAAC;EACjE,MAAMC,yBAAA,GACJH,oBAAA,EAAsBI,2BAAA;EAExB,MAAMC,2CAAA,GAA8C,C,GAAIT,qBAAA,CAAsB;EAE9E,KAAK,MAAMU,SAAA,IAAaP,YAAA,CAAaQ,QAAQ,CAACC,UAAU,CAACC,IAAI,EAAE;IAC7DJ,2CAAA,CAA4CK,IAAI,CAACJ,SAAA;EACnD;EAEA,MAAMK,eAAA,GACJR,yBAAA,EAA2BK,UAAA,IAC3B,OAAOL,yBAAA,EAA2BK,UAAA,KAAe,aAC7CL,yBAAA,CAA0BK,UAAU,CAAC;IACnCI,iBAAA,EAAmBP;EACrB,KACAF,yBAAC,EAA2BK,UAAA,IAC5BH,2CAAA;EAEN;EACA;EACA;EACA,MAAMQ,cAAA,GAA2B,EAAE;EACnC,MAAMC,kBAAA,GAAsC,EAAE;EAC9C,KAAK,MAAMR,SAAA,IAAaK,eAAA,CAAgBI,OAAO,IAAI;IACjD,IAAI,CAACT,SAAA,CAAUU,SAAS,EAAEC,MAAA,EAAQ;MAChC;IACF;IACA,MAAMC,YAAA,GAA8B;MAClCZ,SAAA,EAAWA,SAAA,CAAUA,SAAS;MAC9BU,SAAA,EAAW,C,GAAIV,SAAA,CAAUU,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AcI,MAAA,EAAmCjD,YAAA;QAEjE,IAAI,CAACgD,MAAA,EAAQ;UACX,MAAM,IAAIJ,KAAA,CACR;QAEJ;QAEA,IAAI,CAACI,MAAA,EAAQ9C,kBAAA,EAAoBgD,GAAA,CAAI,kBAAkB;UACrD,MAAM,IAAIN,KAAA,CACR;QAEJ;QAEA,MAAMhC,eAAA,GAAkBb,yBAAA,CAA0B;UAChDC,YAAA,EAAcgD;QAChB;QAEA,OAAO,MAAMlD,oBAAA,CAAqB;UAChCW,UAAA,EAAYG,eAAA;UACZuB,YAAA;UACAgB,IAAA,EAAMJ,gBAAA;UACNX,KAAA;UACAC,KAAA;UACAE,cAAA;UACAC,GAAA;UACAC;QACF;MACF,EACD;MACDW,YAAA,EAAc,CACZ,CAAC;QAAEV,WAAW;QAAEW;MAAK,CAAE;QACrB,IAAIzB,SAAA,EAAW;UACb,OAAOyB,KAAA;QACT;QACA,OAAOX,WAAW,CAAChB,IAAA,CAAK;QACxB,OAAO;MACT;IAEJ;EACF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["defaultHTMLConverters","convertLexicalToHTML","consolidateHTMLConverters","editorConfig","htmlConverterFeature","resolvedFeatureMap","get","htmlConverterFeatureProps","sanitizedServerFeatureProps","defaultConvertersWithConvertersFromFeatures","converter","features","converters","html","push","finalConverters","defaultConverters","foundNodeTypes","filteredConverters","reverse","nodeTypes","length","newConverter","filter","nodeType","includes","lexicalHTML","lexicalFieldName","args","name","hidden","storeInDB","type","admin","editorOptions","language","hooks","afterRead","currentDepth","depth","draft","field","overrideAccess","req","showHiddenFields","siblingData","siblingFields","Error","lexicalField","find","lexicalFieldData","config","editor","has","data","beforeChange","value"],"sources":["../../../../../src/features/converters/lexicalToHtml_deprecated/field/index.ts"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { Field } from 'payload'\n\nimport type { SanitizedServerEditorConfig } from '../../../../lexical/config/types.js'\nimport type { LexicalRichTextAdapter, LexicalRichTextField } from '../../../../types.js'\nimport type { HTMLConverter } from '../converter/types.js'\nimport type { HTMLConverterFeatureProps } from '../index.js'\n\nimport { defaultHTMLConverters } from '../converter/defaultConverters.js'\nimport { convertLexicalToHTML } from '../converter/index.js'\n\ntype Args = {\n /**\n * Whether the lexicalHTML field should be hidden in the admin panel\n *\n * @default true\n */\n hidden?: boolean\n name: string\n /**\n * Whether the HTML should be stored in the database\n *\n * @default false\n */\n storeInDB?: boolean\n}\n\n/**\n * Combines the default HTML converters with HTML converters found in the features, and with HTML converters configured in the htmlConverter feature.\n *\n * @deprecated - will be removed in 4.0\n * @param editorConfig\n */\nexport const consolidateHTMLConverters = ({\n editorConfig,\n}: {\n editorConfig: SanitizedServerEditorConfig\n}): HTMLConverter[] => {\n const htmlConverterFeature = editorConfig.resolvedFeatureMap.get('htmlConverter')\n const htmlConverterFeatureProps: HTMLConverterFeatureProps =\n htmlConverterFeature?.sanitizedServerFeatureProps\n\n const defaultConvertersWithConvertersFromFeatures = [...defaultHTMLConverters]\n\n for (const converter of editorConfig.features.converters.html) {\n defaultConvertersWithConvertersFromFeatures.push(converter)\n }\n\n const finalConverters =\n htmlConverterFeatureProps?.converters &&\n typeof htmlConverterFeatureProps?.converters === 'function'\n ? htmlConverterFeatureProps.converters({\n defaultConverters: defaultConvertersWithConvertersFromFeatures,\n })\n : (htmlConverterFeatureProps?.converters as HTMLConverter[]) ||\n defaultConvertersWithConvertersFromFeatures\n\n // filter converters by nodeTypes. The last converter in the list wins. If there are multiple converters for the same nodeType, the last one will be used and the node types will be removed from\n // previous converters. If previous converters do not have any nodeTypes left, they will be removed from the list.\n // This guarantees that user-added converters which are added after the default ones will always have precedence\n const foundNodeTypes: string[] = []\n const filteredConverters: HTMLConverter[] = []\n for (const converter of finalConverters.reverse()) {\n if (!converter.nodeTypes?.length) {\n continue\n }\n const newConverter: HTMLConverter = {\n converter: converter.converter,\n nodeTypes: [...converter.nodeTypes],\n }\n newConverter.nodeTypes = newConverter.nodeTypes.filter((nodeType) => {\n if (foundNodeTypes.includes(nodeType)) {\n return false\n }\n foundNodeTypes.push(nodeType)\n return true\n })\n\n if (newConverter.nodeTypes.length) {\n filteredConverters.push(newConverter)\n }\n }\n\n return filteredConverters\n}\n\n/**\n * @deprecated - will be removed in 4.0\n */\nexport const lexicalHTML: (\n /**\n * A string which matches the lexical field name you want to convert to HTML.\n *\n * This has to be a sibling field of this lexicalHTML field - otherwise, it won't be able to find the lexical field.\n **/\n lexicalFieldName: string,\n args: Args,\n) => Field = (lexicalFieldName, args) => {\n const { name = 'lexicalHTML', hidden = true, storeInDB = false } = args\n return {\n name,\n type: 'code',\n admin: {\n editorOptions: {\n language: 'html',\n },\n hidden,\n },\n hooks: {\n afterRead: [\n async ({\n currentDepth,\n depth,\n draft,\n field,\n overrideAccess,\n req,\n showHiddenFields,\n siblingData,\n siblingFields,\n }) => {\n if (!siblingFields) {\n throw new Error(\n `Could not find sibling fields of current lexicalHTML field with name ${field?.name}`,\n )\n }\n\n const lexicalField: LexicalRichTextField = siblingFields.find(\n (field) => 'name' in field && field.name === lexicalFieldName,\n ) as LexicalRichTextField\n\n const lexicalFieldData: SerializedEditorState = siblingData[lexicalFieldName]\n\n if (!lexicalFieldData) {\n return ''\n }\n\n if (!lexicalField) {\n throw new Error(\n 'You cannot use the lexicalHTML field because the referenced lexical field was not found',\n )\n }\n\n const config = (lexicalField?.editor as LexicalRichTextAdapter)?.editorConfig\n\n if (!config) {\n throw new Error(\n 'The linked lexical field does not have an editorConfig. This is needed for the lexicalHTML field.',\n )\n }\n\n if (!config?.resolvedFeatureMap?.has('htmlConverter')) {\n throw new Error(\n 'You cannot use the lexicalHTML field because the linked lexical field does not have a HTMLConverterFeature',\n )\n }\n\n const finalConverters = consolidateHTMLConverters({\n editorConfig: config,\n })\n\n return await convertLexicalToHTML({\n converters: finalConverters,\n currentDepth,\n data: lexicalFieldData,\n depth,\n draft,\n overrideAccess,\n req,\n showHiddenFields,\n })\n },\n ],\n beforeChange: [\n ({ siblingData, value }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EJ;QAEA,MAAMhC,eAAA,GAAkBb,yBAAA,CAA0B;UAChDC,YAAA,EAAcgD;QAChB;QAEA,OAAO,MAAMlD,oBAAA,CAAqB;UAChCW,UAAA,EAAYG,eAAA;UACZuB,YAAA;UACAgB,IAAA,EAAMJ,gBAAA;UACNX,KAAA;UACAC,KAAA;UACAE,cAAA;UACAC,GAAA;UACAC;QACF;MACF,EACD;MACDW,YAAA,EAAc,CACZ,CAAC;QAAEV,WAAW;QAAEW;MAAK,CAAE;QACrB,IAAIzB,SAAA,EAAW;UACb,OAAOyB,KAAA;QACT;QACA,OAAOX,WAAW,CAAChB,IAAA,CAAK;QACxB,OAAO;MACT;IAEJ;EACF;AACF","ignoreList":[]}
@@ -1,13 +1,8 @@
1
1
  import type { SerializedTableCellNode as _SerializedTableCellNode, SerializedTableNode as _SerializedTableNode, SerializedTableRowNode as _SerializedTableRowNode } from '@lexical/table';
2
- import type { Spread } from 'lexical';
3
- export type SerializedTableCellNode = Spread<{
4
- type: 'tablecell';
5
- }, _SerializedTableCellNode>;
6
- export type SerializedTableNode = Spread<{
7
- type: 'table';
8
- }, _SerializedTableNode>;
9
- export type SerializedTableRowNode = Spread<{
10
- type: 'tablerow';
11
- }, _SerializedTableRowNode>;
2
+ import type { SerializedLexicalNode } from 'lexical';
3
+ import type { StronglyTypedElementNode } from '../../../nodeTypes.js';
4
+ export type SerializedTableCellNode<T extends SerializedLexicalNode = SerializedLexicalNode> = StronglyTypedElementNode<_SerializedTableCellNode, 'tablecell', T>;
5
+ export type SerializedTableNode<T extends SerializedLexicalNode = SerializedLexicalNode> = StronglyTypedElementNode<_SerializedTableNode, 'table', T>;
6
+ export type SerializedTableRowNode<T extends SerializedLexicalNode = SerializedLexicalNode> = StronglyTypedElementNode<_SerializedTableRowNode, 'tablerow', T>;
12
7
  export declare const EXPERIMENTAL_TableFeature: import("../../typesServer.js").FeatureProviderProviderServer<undefined, undefined, undefined>;
13
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/experimental_table/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,IAAI,wBAAwB,EACnD,mBAAmB,IAAI,oBAAoB,EAC3C,sBAAsB,IAAI,uBAAuB,EAClD,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AA0BrC,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C;IACE,IAAI,EAAE,WAAW,CAAA;CAClB,EACD,wBAAwB,CACzB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC;IACE,IAAI,EAAE,OAAO,CAAA;CACd,EACD,oBAAoB,CACrB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,CACzC;IACE,IAAI,EAAE,UAAU,CAAA;CACjB,EACD,uBAAuB,CACxB,CAAA;AACD,eAAO,MAAM,yBAAyB,+FA8IpC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/experimental_table/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,IAAI,wBAAwB,EACnD,mBAAmB,IAAI,oBAAoB,EAC3C,sBAAsB,IAAI,uBAAuB,EAClD,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAMpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAsBrE,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IACzF,wBAAwB,CAAC,wBAAwB,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;AAEpE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IACrF,wBAAwB,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;AAE5D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IACxF,wBAAwB,CAAC,uBAAuB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;AAClE,eAAO,MAAM,yBAAyB,+FA8IpC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["TableCellNode","TableNode","TableRowNode","sanitizeFields","createServerFeature","convertLexicalNodesToHTML","createNode","TableMarkdownTransformer","fields","name","type","defaultValue","required","EXPERIMENTAL_TableFeature","feature","config","isRoot","parentIsLocalized","validRelationships","collections","map","c","slug","sanitizedFields","requireFieldLevelRichTextEditor","ClientFeature","generateSchemaMap","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","nodeTypes","getType","tagName","headerState","headerStateClass","backgroundColor","colSpan","rowSpan","key"],"sources":["../../../../src/features/experimental_table/server/index.ts"],"sourcesContent":["import type {\n SerializedTableCellNode as _SerializedTableCellNode,\n SerializedTableNode as _SerializedTableNode,\n SerializedTableRowNode as _SerializedTableRowNode,\n} from '@lexical/table'\nimport type { Spread } from 'lexical'\nimport type { Config, Field, FieldSchemaMap } from 'payload'\n\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { sanitizeFields } from 'payload'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { TableMarkdownTransformer } from '../markdownTransformer.js'\n\nconst fields: Field[] = [\n {\n name: 'rows',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n {\n name: 'columns',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n]\n\nexport type SerializedTableCellNode = Spread<\n {\n type: 'tablecell'\n },\n _SerializedTableCellNode\n>\n\nexport type SerializedTableNode = Spread<\n {\n type: 'table'\n },\n _SerializedTableNode\n>\n\nexport type SerializedTableRowNode = Spread<\n {\n type: 'tablerow'\n },\n _SerializedTableRowNode\n>\nexport const EXPERIMENTAL_TableFeature = createServerFeature({\n feature: async ({ config, isRoot, parentIsLocalized }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedFields = await sanitizeFields({\n config: config as unknown as Config,\n fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#TableFeatureClient',\n generateSchemaMap: () => {\n const schemaMap: FieldSchemaMap = new Map()\n\n schemaMap.set('fields', {\n fields: sanitizedFields,\n })\n\n return schemaMap\n },\n markdownTransformers: [TableMarkdownTransformer],\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 return `<div class=\"lexical-table-container\"><table class=\"lexical-table\" style=\"border-collapse: collapse;\">${childrenText}</table></div>`\n },\n nodeTypes: [TableNode.getType()],\n },\n },\n node: TableNode,\n }),\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\n const tagName = node.headerState > 0 ? 'th' : 'td'\n const headerStateClass = `lexical-table-cell-header-${node.headerState}`\n const backgroundColor = node.backgroundColor\n ? `background-color: ${node.backgroundColor};`\n : ''\n const colSpan = node.colSpan && node.colSpan > 1 ? `colspan=\"${node.colSpan}\"` : ''\n const rowSpan = node.rowSpan && node.rowSpan > 1 ? `rowspan=\"${node.rowSpan}\"` : ''\n\n return `<${tagName} class=\"lexical-table-cell ${headerStateClass}\" style=\"border: 1px solid #ccc; padding: 8px; ${backgroundColor}\" ${colSpan} ${rowSpan}>${childrenText}</${tagName}>`\n },\n nodeTypes: [TableCellNode.getType()],\n },\n },\n node: TableCellNode,\n }),\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 return `<tr class=\"lexical-table-row\">${childrenText}</tr>`\n },\n nodeTypes: [TableRowNode.getType()],\n },\n },\n node: TableRowNode,\n }),\n ],\n }\n },\n key: 'experimental_table',\n})\n"],"mappings":"AAQA,SAASA,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ;AACvD,SAASC,cAAc,QAAQ;AAE/B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,wBAAwB,QAAQ;AAEzC,MAAMC,MAAA,GAAkB,CACtB;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,YAAA,EAAc;EACdC,QAAA,EAAU;AACZ,GACA;EACEH,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,YAAA,EAAc;EACdC,QAAA,EAAU;AACZ,EACD;AAsBD,OAAO,MAAMC,yBAAA,GAA4BT,mBAAA,CAAoB;EAC3DU,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAiB,CAAE;IACnD,MAAMC,kBAAA,GAAqBH,MAAA,CAAOI,WAAW,CAACC,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAK,EAAE;IAEtE,MAAMC,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ACPE;gBACF;gBACAC,GAAA;gBACAC;cACF;cACA,OAAO,iCAAiCC,YAAA,OAAmB;YAC7D;YACAG,SAAA,EAAW,CAAC5C,YAAA,CAAa6C,OAAO;UAClC;QACF;QACAT,IAAA,EAAMpC;MACR;IAEJ;EACF;EACAoD,GAAA,EAAK;AACP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["TableCellNode","TableNode","TableRowNode","sanitizeFields","createServerFeature","convertLexicalNodesToHTML","createNode","TableMarkdownTransformer","fields","name","type","defaultValue","required","EXPERIMENTAL_TableFeature","feature","config","isRoot","parentIsLocalized","validRelationships","collections","map","c","slug","sanitizedFields","requireFieldLevelRichTextEditor","ClientFeature","generateSchemaMap","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","currentDepth","depth","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","nodeTypes","getType","tagName","headerState","headerStateClass","backgroundColor","colSpan","rowSpan","key"],"sources":["../../../../src/features/experimental_table/server/index.ts"],"sourcesContent":["import type {\n SerializedTableCellNode as _SerializedTableCellNode,\n SerializedTableNode as _SerializedTableNode,\n SerializedTableRowNode as _SerializedTableRowNode,\n} from '@lexical/table'\nimport type { SerializedLexicalNode } from 'lexical'\nimport type { Config, Field, FieldSchemaMap } from 'payload'\n\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { sanitizeFields } from 'payload'\n\nimport type { StronglyTypedElementNode } from '../../../nodeTypes.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../../converters/lexicalToHtml_deprecated/converter/index.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { TableMarkdownTransformer } from '../markdownTransformer.js'\n\nconst fields: Field[] = [\n {\n name: 'rows',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n {\n name: 'columns',\n type: 'number',\n defaultValue: 5,\n required: true,\n },\n]\n\nexport type SerializedTableCellNode<T extends SerializedLexicalNode = SerializedLexicalNode> =\n StronglyTypedElementNode<_SerializedTableCellNode, 'tablecell', T>\n\nexport type SerializedTableNode<T extends SerializedLexicalNode = SerializedLexicalNode> =\n StronglyTypedElementNode<_SerializedTableNode, 'table', T>\n\nexport type SerializedTableRowNode<T extends SerializedLexicalNode = SerializedLexicalNode> =\n StronglyTypedElementNode<_SerializedTableRowNode, 'tablerow', T>\nexport const EXPERIMENTAL_TableFeature = createServerFeature({\n feature: async ({ config, isRoot, parentIsLocalized }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedFields = await sanitizeFields({\n config: config as unknown as Config,\n fields,\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#TableFeatureClient',\n generateSchemaMap: () => {\n const schemaMap: FieldSchemaMap = new Map()\n\n schemaMap.set('fields', {\n fields: sanitizedFields,\n })\n\n return schemaMap\n },\n markdownTransformers: [TableMarkdownTransformer],\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 return `<div class=\"lexical-table-container\"><table class=\"lexical-table\" style=\"border-collapse: collapse;\">${childrenText}</table></div>`\n },\n nodeTypes: [TableNode.getType()],\n },\n },\n node: TableNode,\n }),\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\n const tagName = node.headerState > 0 ? 'th' : 'td'\n const headerStateClass = `lexical-table-cell-header-${node.headerState}`\n const backgroundColor = node.backgroundColor\n ? `background-color: ${node.backgroundColor};`\n : ''\n const colSpan = node.colSpan && node.colSpan > 1 ? `colspan=\"${node.colSpan}\"` : ''\n const rowSpan = node.rowSpan && node.rowSpan > 1 ? `rowspan=\"${node.rowSpan}\"` : ''\n\n return `<${tagName} class=\"lexical-table-cell ${headerStateClass}\" style=\"border: 1px solid #ccc; padding: 8px; ${backgroundColor}\" ${colSpan} ${rowSpan}>${childrenText}</${tagName}>`\n },\n nodeTypes: [TableCellNode.getType()],\n },\n },\n node: TableCellNode,\n }),\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 return `<tr class=\"lexical-table-row\">${childrenText}</tr>`\n },\n nodeTypes: [TableRowNode.getType()],\n },\n },\n node: TableRowNode,\n }),\n ],\n }\n },\n key: 'experimental_table',\n})\n"],"mappings":"AAQA,SAASA,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ;AACvD,SAASC,cAAc,QAAQ;AAI/B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,wBAAwB,QAAQ;AAEzC,MAAMC,MAAA,GAAkB,CACtB;EACEC,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,YAAA,EAAc;EACdC,QAAA,EAAU;AACZ,GACA;EACEH,IAAA,EAAM;EACNC,IAAA,EAAM;EACNC,YAAA,EAAc;EACdC,QAAA,EAAU;AACZ,EACD;AAUD,OAAO,MAAMC,yBAAA,GAA4BT,mBAAA,CAAoB;EAC3DU,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAM;I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A0B;gBACnD2B,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,OAAO,iCAAiCC,YAAA,OAAmB;YAC7D;YACAG,SAAA,EAAW,CAAC5C,YAAA,CAAa6C,OAAO;UAClC;QACF;QACAT,IAAA,EAAMpC;MACR;IAEJ;EACF;EACAoD,GAAA,EAAK;AACP","ignoreList":[]}
@@ -1,8 +1,7 @@
1
1
  import type { SerializedHeadingNode as _SerializedHeadingNode, HeadingTagType } from '@lexical/rich-text';
2
- import type { Spread } from 'lexical';
3
- export type SerializedHeadingNode = Spread<{
4
- type: 'heading';
5
- }, _SerializedHeadingNode>;
2
+ import type { SerializedLexicalNode } from 'lexical';
3
+ import type { StronglyTypedElementNode } from '../../../nodeTypes.js';
4
+ export type SerializedHeadingNode<T extends SerializedLexicalNode = SerializedLexicalNode> = StronglyTypedElementNode<_SerializedHeadingNode, 'heading', T>;
6
5
  export type HeadingFeatureProps = {
7
6
  enabledHeadingSizes?: HeadingTagType[];
8
7
  };
@@ -1 +1 @@
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,6HAsEzB,CAAA"}
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,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAQrE,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IACvF,wBAAwB,CAAC,sBAAsB,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;AAEhE,MAAM,MAAM,mBAAmB,GAAG;IAChC,mBAAmB,CAAC,EAAE,cAAc,EAAE,CAAA;CACvC,CAAA;AAED,eAAO,MAAM,cAAc,6HAsEzB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["HeadingNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","HeadingFeature","feature","props","enabledHeadingSizes","sort","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 enabledHeadingSizes.sort()\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,I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ACR,GACD;MACDsC,2BAAA,EAA6B9B;IAC/B;EACF;EACA+B,GAAA,EAAK;AACP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["HeadingNode","createServerFeature","convertLexicalNodesToHTML","createNode","MarkdownTransformer","i18n","HeadingFeature","feature","props","enabledHeadingSizes","sort","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 { SerializedLexicalNode } from 'lexical'\n\nimport { HeadingNode } from '@lexical/rich-text'\n\nimport type { StronglyTypedElementNode } from '../../../nodeTypes.js'\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<T extends SerializedLexicalNode = SerializedLexicalNode> =\n StronglyTypedElementNode<_SerializedHeadingNode, 'heading', T>\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 enabledHeadingSizes.sort()\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;AAI5B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,UAAU,QAAQ;AAC3B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,IAAI,QAAQ;AASrB,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;IAEvEC,mBAAA,CAAoBC,IAAI;IAExB,OAAO;MACLC,aAAA,EAAe;MACfC,kBAAA,EAAoBJ,KAAA;MACpBH,IAAA;MACAQ,oBAAA,EAAsB,CAACT,mBAAA,CAAoBK,mBAAA,EAAqB;MAChEK,KAAA,EAAO,CACLX,UAAA,CAAW;QACTY,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,MAAMxB,yBAAA,CAA0B;gBACnDa,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,CAACpC,WAAA,CAAYqC,OAAO;UACjC;QACF;QACAhB,IAAA,EAAMrB;MACR,GACD;MACDsC,2BAAA,EAA6B9B;IAC/B;EACF;EACA+B,GAAA,EAAK;AACP","ignoreList":[]}
@@ -1,13 +1,11 @@
1
- import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalCommand, LexicalNode, SerializedLexicalNode, Spread } from 'lexical';
1
+ import type { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalCommand, LexicalNode, SerializedLexicalNode } from 'lexical';
2
2
  import type * as React from 'react';
3
3
  import { DecoratorNode } from 'lexical';
4
+ import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
4
5
  /**
5
6
  * Serialized representation of a horizontal rule node. Serialized = converted to JSON. This is what is stored in the database / in the lexical editor state.
6
7
  */
7
- export type SerializedHorizontalRuleNode = Spread<{
8
- children?: never;
9
- type: 'horizontalrule';
10
- }, SerializedLexicalNode>;
8
+ export type SerializedHorizontalRuleNode = StronglyTypedLeafNode<SerializedLexicalNode, 'horizontalrule'>;
11
9
  export declare const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void>;
12
10
  /**
13
11
  * This node is a DecoratorNode. DecoratorNodes allow you to render React components in the editor.
@@ -1 +1 @@
1
- {"version":3,"file":"HorizontalRuleNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/horizontalRule/server/nodes/HorizontalRuleNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,MAAM,EACP,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAwC,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAC/C;IACE,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,IAAI,EAAE,gBAAgB,CAAA;CACvB,EACD,qBAAqB,CACtB,CAAA;AAED,eAAO,MAAM,8BAA8B,EAAE,cAAc,CAAC,IAAI,CAE/D,CAAA;AAED;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC;WACpE,KAAK,CAAC,IAAI,EAAE,wBAAwB,GAAG,wBAAwB;WAI/D,OAAO,IAAI,MAAM;IAIjC;;;;OAIG;WACa,SAAS,IAAI,gBAAgB,GAAG,IAAI;IASpD;;OAEG;WACa,UAAU,CACxB,cAAc,EAAE,4BAA4B,GAC3C,wBAAwB;IAI3B;;OAEG;IACM,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAM5C,QAAQ,IAAI,IAAI,GAAG,KAAK,CAAC,YAAY;IAI9C;;;;OAIG;IACM,SAAS,IAAI,eAAe;IAGrC;;OAEG;IACM,UAAU,IAAI,qBAAqB;IAOnC,cAAc,IAAI,MAAM;IAIxB,QAAQ,IAAI,KAAK;IAIjB,SAAS,IAAI,OAAO;CAG9B;AAMD,wBAAgB,+BAA+B,IAAI,wBAAwB,CAE1E;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,wBAAwB,CAElC"}
1
+ {"version":3,"file":"HorizontalRuleNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/horizontalRule/server/nodes/HorizontalRuleNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,EACX,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAwC,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAErE;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,CAC9D,qBAAqB,EACrB,gBAAgB,CACjB,CAAA;AAED,eAAO,MAAM,8BAA8B,EAAE,cAAc,CAAC,IAAI,CAE/D,CAAA;AAED;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC;WACpE,KAAK,CAAC,IAAI,EAAE,wBAAwB,GAAG,wBAAwB;WAI/D,OAAO,IAAI,MAAM;IAIjC;;;;OAIG;WACa,SAAS,IAAI,gBAAgB,GAAG,IAAI;IASpD;;OAEG;WACa,UAAU,CACxB,cAAc,EAAE,4BAA4B,GAC3C,wBAAwB;IAI3B;;OAEG;IACM,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAM5C,QAAQ,IAAI,IAAI,GAAG,KAAK,CAAC,YAAY;IAI9C;;;;OAIG;IACM,SAAS,IAAI,eAAe;IAGrC;;OAEG;IACM,UAAU,IAAI,qBAAqB;IAOnC,cAAc,IAAI,MAAM;IAIxB,QAAQ,IAAI,KAAK;IAIjB,SAAS,IAAI,OAAO;CAG9B;AAMD,wBAAgB,+BAA+B,IAAI,wBAAwB,CAE1E;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,wBAAwB,CAElC"}
@@ -1 +1 @@
1
- {"version":3,"file":"HorizontalRuleNode.js","names":["addClassNamesToElement","$applyNodeReplacement","createCommand","DecoratorNode","INSERT_HORIZONTAL_RULE_COMMAND","HorizontalRuleServerNode","clone","node","__key","getType","importDOM","hr","conversion","$convertHorizontalRuleElement","priority","importJSON","serializedNode","$createHorizontalRuleServerNode","createDOM","config","element","document","createElement","theme","decorate","exportDOM","exportJSON","type","version","getTextContent","isInline","updateDOM","$isHorizontalRuleServerNode"],"sources":["../../../../../src/features/horizontalRule/server/nodes/HorizontalRuleNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n EditorConfig,\n LexicalCommand,\n LexicalNode,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type * as React from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { $applyNodeReplacement, createCommand, DecoratorNode } from 'lexical'\n\n/**\n * Serialized representation of a horizontal rule node. Serialized = converted to JSON. This is what is stored in the database / in the lexical editor state.\n */\nexport type SerializedHorizontalRuleNode = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n type: 'horizontalrule'\n },\n SerializedLexicalNode\n>\n\nexport const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void> = createCommand(\n 'INSERT_HORIZONTAL_RULE_COMMAND',\n)\n\n/**\n * This node is a DecoratorNode. DecoratorNodes allow you to render React components in the editor.\n *\n * They need both createDom and decorate functions. createDom => outside of the html. decorate => React Component inside of the html.\n *\n * If we used DecoratorBlockNode instead, we would only need a decorate method\n */\nexport class HorizontalRuleServerNode extends DecoratorNode<null | React.ReactElement> {\n static override clone(node: HorizontalRuleServerNode): HorizontalRuleServerNode {\n return new this(node.__key)\n }\n\n static override getType(): string {\n return 'horizontalrule'\n }\n\n /**\n * Defines what happens if you copy an hr element from another page and paste it into the lexical editor\n *\n * This also determines the behavior of lexical's internal HTML -> Lexical converter\n */\n static override importDOM(): DOMConversionMap | null {\n return {\n hr: () => ({\n conversion: $convertHorizontalRuleElement,\n priority: 0,\n }),\n }\n }\n\n /**\n * The data for this node is stored serialized as JSON. This is the \"load function\" of that node: it takes the saved data and converts it into a node.\n */\n static override importJSON(\n serializedNode: SerializedHorizontalRuleNode,\n ): HorizontalRuleServerNode {\n return $createHorizontalRuleServerNode()\n }\n\n /**\n * Determines how the hr element is rendered in the lexical editor. This is only the \"initial\" / \"outer\" HTML element.\n */\n override createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('hr')\n addClassNamesToElement(element, config.theme.hr)\n return element\n }\n\n override decorate(): null | React.ReactElement {\n return null\n }\n\n /**\n * Opposite of importDOM, this function defines what happens when you copy an hr element from the lexical editor and paste it into another page.\n *\n * This also determines the behavior of lexical's internal Lexical -> HTML converter\n */\n override exportDOM(): DOMExportOutput {\n return { element: document.createElement('hr') }\n }\n /**\n * Opposite of importJSON. This determines what data is saved in the database / in the lexical editor state.\n */\n override exportJSON(): SerializedLexicalNode {\n return {\n type: 'horizontalrule',\n version: 1,\n }\n }\n\n override getTextContent(): string {\n return '\\n'\n }\n\n override isInline(): false {\n return false\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nfunction $convertHorizontalRuleElement(): DOMConversionOutput {\n return { node: $createHorizontalRuleServerNode() }\n}\n\nexport function $createHorizontalRuleServerNode(): HorizontalRuleServerNode {\n return $applyNodeReplacement(new HorizontalRuleServerNode())\n}\n\nexport function $isHorizontalRuleServerNode(\n node: LexicalNode | null | undefined,\n): node is HorizontalRuleServerNode {\n return node instanceof HorizontalRuleServerNode\n}\n"],"mappings":"AAYA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,qBAAqB,EAAEC,aAAa,EAAEC,aAAa,QAAQ;AAapE,OAAO,MAAMC,8BAAA,GAAuDF,aAAA,CAClE;AAGF;;;;;;;AAOA,OAAO,MAAMG,wBAAA,SAAiCF,aAAA;EAC5C,OAAgBG,MAAMC,IAA8B,EAA4B;IAC9E,OAAO,IAAI,IAAI,CAACA,IAAA,CAAKC,KAAK;EAC5B;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO;EACT;EAEA;;;;;EAKA,OAAgBC,UAAA,EAAqC;IACnD,OAAO;MACLC,EAAA,EAAIA,CAAA,MAAO;QACTC,UAAA,EAAYC,6BAAA;QACZC,QAAA,EAAU;MACZ;IACF;EACF;EAEA;;;EAGA,OAAgBC,WACdC,cAA4C,EAClB;IAC1B,OAAOC,+BAAA;EACT;EAEA;;;EAGAC,SAASA,CAAUC,MAAoB,EAAe;IACpD,MAAMC,OAAA,GAAUC,QAAA,CAASC,aAAa,CAAC;IACvCtB,sBAAA,CAAuBoB,OAAA,EAASD,MAAA,CAAOI,KAAK,CAACZ,EAAE;IAC/C,OAAOS,OAAA;EACT;EAESI,SAAA,EAAsC;IAC7C,OAAO;EACT;EAEA;;;;;EAKAC,SAASA,CAAA,EAA6B;IACpC,OAAO;MAAEL,OAAA,EAASC,QAAA,CAASC,aAAa,CAAC;IAAM;EACjD;EACA;;;EAGAI,UAASA,CAAA,EAAoC;IAC3C,OAAO;MACLC,IAAA,EAAM;MACNC,OAAA,EAAS;IACX;EACF;EAESC,eAAA,EAAyB;IAChC,OAAO;EACT;EAESC,SAAA,EAAkB;IACzB,OAAO;EACT;EAESC,UAAA,EAAqB;IAC5B,OAAO;EACT;AACF;AAEA,SAASlB,8BAAA;EACP,OAAO;IAAEN,IAAA,EAAMU,+BAAA;EAAkC;AACnD;AAEA,OAAO,SAASA,gCAAA;EACd,OAAOhB,qBAAA,CAAsB,IAAII,wBAAA;AACnC;AAEA,OAAO,SAAS2B,4BACdzB,IAAoC;EAEpC,OAAOA,IAAA,YAAgBF,wBAAA;AACzB","ignoreList":[]}
1
+ {"version":3,"file":"HorizontalRuleNode.js","names":["addClassNamesToElement","$applyNodeReplacement","createCommand","DecoratorNode","INSERT_HORIZONTAL_RULE_COMMAND","HorizontalRuleServerNode","clone","node","__key","getType","importDOM","hr","conversion","$convertHorizontalRuleElement","priority","importJSON","serializedNode","$createHorizontalRuleServerNode","createDOM","config","element","document","createElement","theme","decorate","exportDOM","exportJSON","type","version","getTextContent","isInline","updateDOM","$isHorizontalRuleServerNode"],"sources":["../../../../../src/features/horizontalRule/server/nodes/HorizontalRuleNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n EditorConfig,\n LexicalCommand,\n LexicalNode,\n SerializedLexicalNode,\n} from 'lexical'\nimport type * as React from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { $applyNodeReplacement, createCommand, DecoratorNode } from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\n/**\n * Serialized representation of a horizontal rule node. Serialized = converted to JSON. This is what is stored in the database / in the lexical editor state.\n */\nexport type SerializedHorizontalRuleNode = StronglyTypedLeafNode<\n SerializedLexicalNode,\n 'horizontalrule'\n>\n\nexport const INSERT_HORIZONTAL_RULE_COMMAND: LexicalCommand<void> = createCommand(\n 'INSERT_HORIZONTAL_RULE_COMMAND',\n)\n\n/**\n * This node is a DecoratorNode. DecoratorNodes allow you to render React components in the editor.\n *\n * They need both createDom and decorate functions. createDom => outside of the html. decorate => React Component inside of the html.\n *\n * If we used DecoratorBlockNode instead, we would only need a decorate method\n */\nexport class HorizontalRuleServerNode extends DecoratorNode<null | React.ReactElement> {\n static override clone(node: HorizontalRuleServerNode): HorizontalRuleServerNode {\n return new this(node.__key)\n }\n\n static override getType(): string {\n return 'horizontalrule'\n }\n\n /**\n * Defines what happens if you copy an hr element from another page and paste it into the lexical editor\n *\n * This also determines the behavior of lexical's internal HTML -> Lexical converter\n */\n static override importDOM(): DOMConversionMap | null {\n return {\n hr: () => ({\n conversion: $convertHorizontalRuleElement,\n priority: 0,\n }),\n }\n }\n\n /**\n * The data for this node is stored serialized as JSON. This is the \"load function\" of that node: it takes the saved data and converts it into a node.\n */\n static override importJSON(\n serializedNode: SerializedHorizontalRuleNode,\n ): HorizontalRuleServerNode {\n return $createHorizontalRuleServerNode()\n }\n\n /**\n * Determines how the hr element is rendered in the lexical editor. This is only the \"initial\" / \"outer\" HTML element.\n */\n override createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('hr')\n addClassNamesToElement(element, config.theme.hr)\n return element\n }\n\n override decorate(): null | React.ReactElement {\n return null\n }\n\n /**\n * Opposite of importDOM, this function defines what happens when you copy an hr element from the lexical editor and paste it into another page.\n *\n * This also determines the behavior of lexical's internal Lexical -> HTML converter\n */\n override exportDOM(): DOMExportOutput {\n return { element: document.createElement('hr') }\n }\n /**\n * Opposite of importJSON. This determines what data is saved in the database / in the lexical editor state.\n */\n override exportJSON(): SerializedLexicalNode {\n return {\n type: 'horizontalrule',\n version: 1,\n }\n }\n\n override getTextContent(): string {\n return '\\n'\n }\n\n override isInline(): false {\n return false\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nfunction $convertHorizontalRuleElement(): DOMConversionOutput {\n return { node: $createHorizontalRuleServerNode() }\n}\n\nexport function $createHorizontalRuleServerNode(): HorizontalRuleServerNode {\n return $applyNodeReplacement(new HorizontalRuleServerNode())\n}\n\nexport function $isHorizontalRuleServerNode(\n node: LexicalNode | null | undefined,\n): node is HorizontalRuleServerNode {\n return node instanceof HorizontalRuleServerNode\n}\n"],"mappings":"AAWA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,qBAAqB,EAAEC,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AACzB","ignoreList":[]}
@@ -1,5 +1,6 @@
1
- import type { SerializedElementNode, SerializedLexicalNode, Spread } from 'lexical';
1
+ import type { SerializedElementNode, SerializedLexicalNode } from 'lexical';
2
2
  import type { DefaultDocumentIDType, JsonValue } from 'payload';
3
+ import type { StronglyTypedElementNode } from '../../../nodeTypes.js';
3
4
  export type LinkFields = {
4
5
  [key: string]: JsonValue;
5
6
  doc?: {
@@ -13,15 +14,14 @@ export type LinkFields = {
13
14
  newTab: boolean;
14
15
  url?: string;
15
16
  };
16
- export type SerializedLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<{
17
+ export type SerializedLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {
17
18
  fields: LinkFields;
18
19
  /**
19
20
  * @todo make required in 4.0 and type AutoLinkNode differently
20
21
  */
21
22
  id?: string;
22
- type: 'link';
23
- }, SerializedElementNode<T>>;
23
+ } & StronglyTypedElementNode<SerializedElementNode, 'link', T>;
24
24
  export type SerializedAutoLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {
25
- type: 'autolink';
26
- } & Omit<SerializedLinkNode<T>, 'id' | 'type'>;
25
+ fields: LinkFields;
26
+ } & StronglyTypedElementNode<SerializedElementNode, 'autolink', T>;
27
27
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/features/link/nodes/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,GAAG,CAAC,EAAE;QACJ,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EACD;YAEE,CAAC,GAAG,EAAE,MAAM,GAA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AQ,GAAG,UAAU,CAAA;IAC/B,MAAM,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI;IACxF,MAAM,EAAE,UAAU,CAAA;IAClB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;CACZ,GAAG,wBAAwB,CAAC,qBAAqB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AAE9D,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI;IAC5F,MAAM,EAAE,UAAU,CAAA;CACnB,GAAG,wBAAwB,CAAC,qBAAqB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/features/link/nodes/types.ts"],"sourcesContent":["import type { SerializedElementNode, SerializedLexicalNode, Spread } from 'lexical'\nimport type { DefaultDocumentIDType, JsonValue } from 'payload'\n\nexport type LinkFields = {\n [key: string]: JsonValue\n doc?: {\n relationTo: string\n value:\n | {\n // Actual doc data, populated in afterRead hook\n [key: string]: JsonValue\n id: DefaultDocumentIDType\n }\n | DefaultDocumentIDType\n } | null\n linkType: 'custom' | 'internal'\n newTab: boolean\n url?: string\n}\n\nexport type SerializedLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = Spread<\n {\n fields: LinkFields\n /**\n * @todo make required in 4.0 and type AutoLinkNode differently\n */\n id?: string // optional if AutoLinkNode\n type: 'link'\n },\n SerializedElementNode<T>\n>\nexport type SerializedAutoLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n type: 'autolink'\n} & Omit<SerializedLinkNode<T>, 'id' | 'type'>\n"],"mappings":"AA+BA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/features/link/nodes/types.ts"],"sourcesContent":["import type { SerializedElementNode, SerializedLexicalNode } from 'lexical'\nimport type { DefaultDocumentIDType, JsonValue } from 'payload'\n\nimport type { StronglyTypedElementNode } from '../../../nodeTypes.js'\n\nexport type LinkFields = {\n [key: string]: JsonValue\n doc?: {\n relationTo: string\n value:\n | {\n // Actual doc data, populated in afterRead hook\n [key: string]: JsonValue\n id: DefaultDocumentIDType\n }\n | DefaultDocumentIDType\n } | null\n linkType: 'custom' | 'internal'\n newTab: boolean\n url?: string\n}\n\nexport type SerializedLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n fields: LinkFields\n /**\n * @todo make required in 4.0 and type AutoLinkNode differently\n */\n id?: string // optional if AutoLinkNode\n} & StronglyTypedElementNode<SerializedElementNode, 'link', T>\n\nexport type SerializedAutoLinkNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {\n fields: LinkFields\n} & StronglyTypedElementNode<SerializedElementNode, 'autolink', T>\n"],"mappings":"AA8BA","ignoreList":[]}
@@ -1,13 +1,12 @@
1
1
  import type { SerializedListItemNode as _SerializedListItemNode, SerializedListNode as _SerializedListNode } from '@lexical/list';
2
- import type { Spread } from 'lexical';
2
+ import type { SerializedLexicalNode } from 'lexical';
3
+ import type { StronglyTypedElementNode } from '../../../nodeTypes.js';
3
4
  import type { PluginComponent } from '../../typesClient.js';
4
- export type SerializedListItemNode = Spread<{
5
+ export type SerializedListItemNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {
5
6
  checked?: boolean;
6
- type: 'listitem';
7
- }, _SerializedListItemNode>;
8
- export type SerializedListNode = Spread<{
7
+ } & StronglyTypedElementNode<_SerializedListItemNode, 'listitem', T>;
8
+ export type SerializedListNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {
9
9
  checked?: boolean;
10
- type: 'list';
11
- }, _SerializedListNode>;
10
+ } & StronglyTypedElementNode<_SerializedListNode, 'list', T>;
12
11
  export declare const LexicalListPlugin: PluginComponent<undefined>;
13
12
  //# sourceMappingURL=index.d.ts.map