@payloadcms/richtext-lexical 4.0.0-canary.3 → 4.0.0-internal.011fd46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/Field-VQX3RNMF.js +2 -0
- package/dist/exports/client/{Field-G5Z2HM5Y.js.map → Field-VQX3RNMF.js.map} +3 -3
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-X3D4LZS7.js +2 -0
- package/dist/exports/client/chunk-X3D4LZS7.js.map +7 -0
- package/dist/exports/client/index.js +22 -20
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/markdownTransformer.d.ts +1 -1
- package/dist/features/blockquote/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blockquote/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +1 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +1 -1
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +1 -2
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/converters/lexicalToMarkdown/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToMarkdown/index.js +1 -1
- package/dist/features/converters/lexicalToMarkdown/index.js.map +1 -1
- package/dist/features/converters/markdownToLexical/index.js +1 -1
- package/dist/features/converters/markdownToLexical/index.js.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.js +1 -1
- package/dist/features/experimental_table/markdownTransformer.js.map +1 -1
- package/dist/features/format/bold/markdownTransformers.d.ts +1 -1
- package/dist/features/format/bold/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/bold/markdownTransformers.js.map +1 -1
- package/dist/features/format/inlineCode/markdownTransformers.d.ts +1 -1
- package/dist/features/format/inlineCode/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/inlineCode/markdownTransformers.js.map +1 -1
- package/dist/features/format/italic/markdownTransformers.d.ts +1 -1
- package/dist/features/format/italic/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/italic/markdownTransformers.js.map +1 -1
- package/dist/features/format/strikethrough/markdownTransformers.d.ts +1 -1
- package/dist/features/format/strikethrough/markdownTransformers.d.ts.map +1 -1
- package/dist/features/format/strikethrough/markdownTransformers.js.map +1 -1
- package/dist/features/heading/markdownTransformer.d.ts +1 -1
- package/dist/features/heading/markdownTransformer.d.ts.map +1 -1
- package/dist/features/heading/markdownTransformer.js.map +1 -1
- package/dist/features/horizontalRule/client/markdownTransformer.d.ts +1 -1
- package/dist/features/horizontalRule/client/markdownTransformer.d.ts.map +1 -1
- package/dist/features/horizontalRule/client/markdownTransformer.js.map +1 -1
- package/dist/features/horizontalRule/server/markdownTransformer.d.ts +1 -1
- package/dist/features/horizontalRule/server/markdownTransformer.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/markdownTransformer.js.map +1 -1
- package/dist/features/link/markdownTransformer.d.ts +1 -1
- package/dist/features/link/markdownTransformer.d.ts.map +1 -1
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/features/link/markdownTransformer.spec.js +1 -1
- package/dist/features/link/markdownTransformer.spec.js.map +1 -1
- package/dist/features/lists/checklist/markdownTransformers.d.ts +1 -1
- package/dist/features/lists/checklist/markdownTransformers.d.ts.map +1 -1
- package/dist/features/lists/checklist/markdownTransformers.js.map +1 -1
- package/dist/features/lists/orderedList/markdownTransformer.d.ts +1 -1
- package/dist/features/lists/orderedList/markdownTransformer.d.ts.map +1 -1
- package/dist/features/lists/orderedList/markdownTransformer.js.map +1 -1
- package/dist/features/lists/shared/markdown.d.ts +1 -1
- package/dist/features/lists/shared/markdown.d.ts.map +1 -1
- package/dist/features/lists/shared/markdown.js.map +1 -1
- package/dist/features/lists/unorderedList/markdownTransformer.d.ts +1 -1
- package/dist/features/lists/unorderedList/markdownTransformer.d.ts.map +1 -1
- package/dist/features/lists/unorderedList/markdownTransformer.js.map +1 -1
- package/dist/features/toolbars/shared/useToolbarStates.d.ts.map +1 -1
- package/dist/features/toolbars/shared/useToolbarStates.js +3 -1
- package/dist/features/toolbars/shared/useToolbarStates.js.map +1 -1
- package/dist/features/typesClient.d.ts +1 -1
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts +1 -1
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/server/markdownTransformer.d.ts +1 -1
- package/dist/features/upload/server/markdownTransformer.d.ts.map +1 -1
- package/dist/features/upload/server/markdownTransformer.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.d.ts.map +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.js +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/lexical/utils/markdown/createBlockNode.d.ts +1 -1
- package/dist/lexical/utils/markdown/createBlockNode.d.ts.map +1 -1
- package/dist/lexical/utils/markdown/createBlockNode.js.map +1 -1
- package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +28 -0
- package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +1 -0
- package/dist/lexical/utils/markdown/normalizeMarkdown.js +95 -0
- package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts +40 -1
- package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
- package/dist/lexical-proxy/@lexical-markdown.js +56 -1
- package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
- package/dist/lexical-proxy/@lexical-markdown.spec.js +89 -0
- package/dist/lexical-proxy/@lexical-markdown.spec.js.map +1 -0
- package/package.json +20 -24
- package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
- package/dist/exports/client/chunk-LH634DPU.js +0 -12
- package/dist/exports/client/chunk-LH634DPU.js.map +0 -7
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +0 -2
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +0 -1
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +0 -2
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +0 -14
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownExport.js +0 -213
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +0 -19
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.js +0 -198
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +0 -11
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +0 -304
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +0 -147
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js +0 -268
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +0 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +0 -22
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +0 -91
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +0 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +0 -21
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +0 -54
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +0 -1
- package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +0 -18
- package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/importTextTransformers.js +0 -54
- package/dist/packages/@lexical/markdown/importTextTransformers.js.map +0 -1
- package/dist/packages/@lexical/markdown/index.d.ts +0 -29
- package/dist/packages/@lexical/markdown/index.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/index.js +0 -39
- package/dist/packages/@lexical/markdown/index.js.map +0 -1
- package/dist/packages/@lexical/markdown/utils.d.ts +0 -34
- package/dist/packages/@lexical/markdown/utils.d.ts.map +0 -1
- package/dist/packages/@lexical/markdown/utils.js +0 -267
- package/dist/packages/@lexical/markdown/utils.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.js","names":["INLINE_CODE","type","format","tag"],"sources":["../../../../src/features/format/inlineCode/markdownTransformers.ts"],"sourcesContent":["import type { TextFormatTransformer } from '
|
|
1
|
+
{"version":3,"file":"markdownTransformers.js","names":["INLINE_CODE","type","format","tag"],"sources":["../../../../src/features/format/inlineCode/markdownTransformers.ts"],"sourcesContent":["import type { TextFormatTransformer } from '@lexical/markdown'\n\nexport const INLINE_CODE: TextFormatTransformer = {\n type: 'text-format',\n format: ['code'],\n tag: '`',\n}\n"],"mappings":"AAEA,OAAO,MAAMA,WAAA,GAAqC;EAChDC,IAAA,EAAM;EACNC,MAAA,EAAQ,CAAC,OAAO;EAChBC,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TextFormatTransformer } from '
|
|
1
|
+
import type { TextFormatTransformer } from '@lexical/markdown';
|
|
2
2
|
export declare const ITALIC_STAR: TextFormatTransformer;
|
|
3
3
|
export declare const ITALIC_UNDERSCORE: TextFormatTransformer;
|
|
4
4
|
//# sourceMappingURL=markdownTransformers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/features/format/italic/markdownTransformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"markdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/features/format/italic/markdownTransformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE9D,eAAO,MAAM,WAAW,EAAE,qBAIzB,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,qBAK/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.js","names":["ITALIC_STAR","type","format","tag","ITALIC_UNDERSCORE","intraword"],"sources":["../../../../src/features/format/italic/markdownTransformers.ts"],"sourcesContent":["import type { TextFormatTransformer } from '
|
|
1
|
+
{"version":3,"file":"markdownTransformers.js","names":["ITALIC_STAR","type","format","tag","ITALIC_UNDERSCORE","intraword"],"sources":["../../../../src/features/format/italic/markdownTransformers.ts"],"sourcesContent":["import type { TextFormatTransformer } from '@lexical/markdown'\n\nexport const ITALIC_STAR: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n tag: '*',\n}\n\nexport const ITALIC_UNDERSCORE: TextFormatTransformer = {\n type: 'text-format',\n format: ['italic'],\n intraword: false,\n tag: '_',\n}\n"],"mappings":"AAEA,OAAO,MAAMA,WAAA,GAAqC;EAChDC,IAAA,EAAM;EACNC,MAAA,EAAQ,CAAC,SAAS;EAClBC,GAAA,EAAK;AACP;AAEA,OAAO,MAAMC,iBAAA,GAA2C;EACtDH,IAAA,EAAM;EACNC,MAAA,EAAQ,CAAC,SAAS;EAClBG,SAAA,EAAW;EACXF,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { TextFormatTransformer } from '
|
|
1
|
+
import type { TextFormatTransformer } from '@lexical/markdown';
|
|
2
2
|
export declare const STRIKETHROUGH: TextFormatTransformer;
|
|
3
3
|
//# sourceMappingURL=markdownTransformers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/features/format/strikethrough/markdownTransformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"markdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/features/format/strikethrough/markdownTransformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE9D,eAAO,MAAM,aAAa,EAAE,qBAI3B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.js","names":["STRIKETHROUGH","type","format","tag"],"sources":["../../../../src/features/format/strikethrough/markdownTransformers.ts"],"sourcesContent":["import type { TextFormatTransformer } from '
|
|
1
|
+
{"version":3,"file":"markdownTransformers.js","names":["STRIKETHROUGH","type","format","tag"],"sources":["../../../../src/features/format/strikethrough/markdownTransformers.ts"],"sourcesContent":["import type { TextFormatTransformer } from '@lexical/markdown'\n\nexport const STRIKETHROUGH: TextFormatTransformer = {\n type: 'text-format',\n format: ['strikethrough'],\n tag: '~~',\n}\n"],"mappings":"AAEA,OAAO,MAAMA,aAAA,GAAuC;EAClDC,IAAA,EAAM;EACNC,MAAA,EAAQ,CAAC,gBAAgB;EACzBC,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type { ElementTransformer } from '@lexical/markdown';
|
|
1
2
|
import type { HeadingTagType } from '@lexical/rich-text';
|
|
2
|
-
import type { ElementTransformer } from '../../packages/@lexical/markdown/MarkdownTransformers.js';
|
|
3
3
|
export declare const MarkdownTransformer: (enabledHeadingSizes: HeadingTagType[]) => ElementTransformer;
|
|
4
4
|
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../src/features/heading/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../src/features/heading/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAMxD,eAAO,MAAM,mBAAmB,EAAE,CAAC,mBAAmB,EAAE,cAAc,EAAE,KAAK,kBA0B5E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.js","names":["$createHeadingNode","$isHeadingNode","HeadingNode","createBlockNode","MarkdownTransformer","enabledHeadingSizes","enabledSizes","map","tag","Number","slice","pattern","size","join","regExp","RegExp","type","dependencies","export","node","exportChildren","level","getTag","repeat","replace","match","length"],"sources":["../../../src/features/heading/markdownTransformer.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["$createHeadingNode","$isHeadingNode","HeadingNode","createBlockNode","MarkdownTransformer","enabledHeadingSizes","enabledSizes","map","tag","Number","slice","pattern","size","join","regExp","RegExp","type","dependencies","export","node","exportChildren","level","getTag","repeat","replace","match","length"],"sources":["../../../src/features/heading/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\nimport type { HeadingTagType } from '@lexical/rich-text'\n\nimport { $createHeadingNode, $isHeadingNode, HeadingNode } from '@lexical/rich-text'\n\nimport { createBlockNode } from '../../lexical/utils/markdown/createBlockNode.js'\n\nexport const MarkdownTransformer: (enabledHeadingSizes: HeadingTagType[]) => ElementTransformer = (\n enabledHeadingSizes,\n) => {\n // Convert enabledHeadingSizes to a list of numbers (1 for h1, 2 for h2, etc.)\n const enabledSizes = enabledHeadingSizes.map((tag) => Number(tag.slice(1)))\n\n // Create a regex pattern that matches any of the enabled sizes\n const pattern = `^(${enabledSizes.map((size) => `#{${size}}`).join('|')})\\\\s`\n const regExp = new RegExp(pattern)\n\n return {\n type: 'element',\n dependencies: [HeadingNode],\n export: (node, exportChildren) => {\n if (!$isHeadingNode(node)) {\n return null\n }\n const level = Number(node.getTag().slice(1))\n return '#'.repeat(level) + ' ' + exportChildren(node)\n },\n regExp,\n replace: createBlockNode((match) => {\n const tag = ('h' + match[1]?.length) as HeadingTagType\n return $createHeadingNode(tag)\n }),\n }\n}\n"],"mappings":"AAGA,SAASA,kBAAkB,EAAEC,cAAc,EAAEC,WAAW,QAAQ;AAEhE,SAASC,eAAe,QAAQ;AAEhC,OAAO,MAAMC,mBAAA,GACXC,mBAAA;EAEA;EACA,MAAMC,YAAA,GAAeD,mBAAA,CAAoBE,GAAG,CAAEC,GAAA,IAAQC,MAAA,CAAOD,GAAA,CAAIE,KAAK,CAAC;EAEvE;EACA,MAAMC,OAAA,GAAU,KAAKL,YAAA,CAAaC,GAAG,CAAEK,IAAA,IAAS,KAAKA,IAAA,GAAO,EAAEC,IAAI,CAAC,UAAU;EAC7E,MAAMC,MAAA,GAAS,IAAIC,MAAA,CAAOJ,OAAA;EAE1B,OAAO;IACLK,IAAA,EAAM;IACNC,YAAA,EAAc,CAACf,WAAA,CAAY;IAC3BgB,MAAA,EAAQA,CAACC,IAAA,EAAMC,cAAA;MACb,IAAI,CAACnB,cAAA,CAAekB,IAAA,GAAO;QACzB,OAAO;MACT;MACA,MAAME,KAAA,GAAQZ,MAAA,CAAOU,IAAA,CAAKG,MAAM,GAAGZ,KAAK,CAAC;MACzC,OAAO,IAAIa,MAAM,CAACF,KAAA,IAAS,MAAMD,cAAA,CAAeD,IAAA;IAClD;IACAL,MAAA;IACAU,OAAA,EAASrB,eAAA,CAAiBsB,KAAA;MACxB,MAAMjB,GAAA,GAAO,MAAMiB,KAAK,CAAC,EAAE,EAAEC,MAAA;MAC7B,OAAO1B,kBAAA,CAAmBQ,GAAA;IAC5B;EACF;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ElementTransformer } from '
|
|
1
|
+
import type { ElementTransformer } from '@lexical/markdown';
|
|
2
2
|
export declare const MarkdownTransformer: ElementTransformer;
|
|
3
3
|
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/horizontalRule/client/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/horizontalRule/client/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAQ3D,eAAO,MAAM,mBAAmB,EAAE,kBAiBjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.js","names":["$createHorizontalRuleNode","$isHorizontalRuleNode","HorizontalRuleNode","MarkdownTransformer","type","dependencies","export","node","exportChildren","regExp","replace","parentNode"],"sources":["../../../../src/features/horizontalRule/client/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["$createHorizontalRuleNode","$isHorizontalRuleNode","HorizontalRuleNode","MarkdownTransformer","type","dependencies","export","node","exportChildren","regExp","replace","parentNode"],"sources":["../../../../src/features/horizontalRule/client/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport {\n $createHorizontalRuleNode,\n $isHorizontalRuleNode,\n HorizontalRuleNode,\n} from './nodes/HorizontalRuleNode.js'\n\nexport const MarkdownTransformer: ElementTransformer = {\n type: 'element',\n dependencies: [HorizontalRuleNode],\n export: (node, exportChildren) => {\n if (!$isHorizontalRuleNode(node)) {\n return null\n }\n return '---'\n },\n // match ---\n regExp: /^---\\s*$/,\n replace: (parentNode) => {\n const node = $createHorizontalRuleNode()\n if (node) {\n parentNode.replace(node)\n }\n },\n}\n"],"mappings":"AAEA,SACEA,yBAAyB,EACzBC,qBAAqB,EACrBC,kBAAkB,QACb;AAEP,OAAO,MAAMC,mBAAA,GAA0C;EACrDC,IAAA,EAAM;EACNC,YAAA,EAAc,CAACH,kBAAA,CAAmB;EAClCI,MAAA,EAAQA,CAACC,IAAA,EAAMC,cAAA;IACb,IAAI,CAACP,qBAAA,CAAsBM,IAAA,GAAO;MAChC,OAAO;IACT;IACA,OAAO;EACT;EACA;EACAE,MAAA,EAAQ;EACRC,OAAA,EAAUC,UAAA;IACR,MAAMJ,IAAA,GAAOP,yBAAA;IACb,IAAIO,IAAA,EAAM;MACRI,UAAA,CAAWD,OAAO,CAACH,IAAA;IACrB;EACF;AACF","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ElementTransformer } from '
|
|
1
|
+
import type { ElementTransformer } from '@lexical/markdown';
|
|
2
2
|
export declare const MarkdownTransformer: ElementTransformer;
|
|
3
3
|
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/horizontalRule/server/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/horizontalRule/server/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAQ3D,eAAO,MAAM,mBAAmB,EAAE,kBAiBjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.js","names":["$createHorizontalRuleServerNode","$isHorizontalRuleServerNode","HorizontalRuleServerNode","MarkdownTransformer","type","dependencies","export","node","exportChildren","regExp","replace","parentNode"],"sources":["../../../../src/features/horizontalRule/server/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["$createHorizontalRuleServerNode","$isHorizontalRuleServerNode","HorizontalRuleServerNode","MarkdownTransformer","type","dependencies","export","node","exportChildren","regExp","replace","parentNode"],"sources":["../../../../src/features/horizontalRule/server/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport {\n $createHorizontalRuleServerNode,\n $isHorizontalRuleServerNode,\n HorizontalRuleServerNode,\n} from './nodes/HorizontalRuleNode.js'\n\nexport const MarkdownTransformer: ElementTransformer = {\n type: 'element',\n dependencies: [HorizontalRuleServerNode],\n export: (node, exportChildren) => {\n if (!$isHorizontalRuleServerNode(node)) {\n return null\n }\n return '---'\n },\n // match ---\n regExp: /^---\\s*$/,\n replace: (parentNode) => {\n const node = $createHorizontalRuleServerNode()\n if (node) {\n parentNode.replace(node)\n }\n },\n}\n"],"mappings":"AAEA,SACEA,+BAA+B,EAC/BC,2BAA2B,EAC3BC,wBAAwB,QACnB;AAEP,OAAO,MAAMC,mBAAA,GAA0C;EACrDC,IAAA,EAAM;EACNC,YAAA,EAAc,CAACH,wBAAA,CAAyB;EACxCI,MAAA,EAAQA,CAACC,IAAA,EAAMC,cAAA;IACb,IAAI,CAACP,2BAAA,CAA4BM,IAAA,GAAO;MACtC,OAAO;IACT;IACA,OAAO;EACT;EACA;EACAE,MAAA,EAAQ;EACRC,OAAA,EAAUC,UAAA;IACR,MAAMJ,IAAA,GAAOP,+BAAA;IACb,IAAIO,IAAA,EAAM;MACRI,UAAA,CAAWD,OAAO,CAACH,IAAA;IACrB;EACF;AACF","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Code taken from https://github.com/facebook/lexical/blob/main/packages/lexical-markdown/src/MarkdownTransformers.ts#L357
|
|
3
3
|
*/
|
|
4
|
-
import type { TextMatchTransformer } from '
|
|
4
|
+
import type { TextMatchTransformer } from '@lexical/markdown';
|
|
5
5
|
import type { SerializedLinkNode } from './server/schema.js';
|
|
6
6
|
export type CreateLinkMarkdownTransformerArgs = {
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../src/features/link/markdownTransformer.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../src/features/link/markdownTransformer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAI7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAO5D,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,kBAAkB,CAAA;KAAE,KAAK,MAAM,CAAA;CACvE,CAAA;AAoBD,eAAO,MAAM,6BAA6B,GACxC,OAAO,iCAAiC,KACvC,oBAiCD,CAAA;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAAsD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.js","names":["$createTextNode","sanitizeUrl","$createLinkNode","$isLinkNode","LinkNode","replaceTransformer","textNode","match","linkText","linkUrl","linkNode","fields","doc","linkType","newTab","url","linkTextNode","setFormat","getFormat","append","replace","createLinkMarkdownTransformer","args","type","dependencies","export","_node","exportChildren","node","getFields","internalDocToHref","exportJSON","console","warn","textContent","importRegExp","regExp","trigger","LinkMarkdownTransformer"],"sources":["../../../src/features/link/markdownTransformer.ts"],"sourcesContent":["/**\n * Code taken from https://github.com/facebook/lexical/blob/main/packages/lexical-markdown/src/MarkdownTransformers.ts#L357\n */\n\n// Order of text transformers matters:\n//\n// - code should go first as it prevents any transformations inside\n\nimport {
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["$createTextNode","sanitizeUrl","$createLinkNode","$isLinkNode","LinkNode","replaceTransformer","textNode","match","linkText","linkUrl","linkNode","fields","doc","linkType","newTab","url","linkTextNode","setFormat","getFormat","append","replace","createLinkMarkdownTransformer","args","type","dependencies","export","_node","exportChildren","node","getFields","internalDocToHref","exportJSON","console","warn","textContent","importRegExp","regExp","trigger","LinkMarkdownTransformer"],"sources":["../../../src/features/link/markdownTransformer.ts"],"sourcesContent":["/**\n * Code taken from https://github.com/facebook/lexical/blob/main/packages/lexical-markdown/src/MarkdownTransformers.ts#L357\n */\n\n// Order of text transformers matters:\n//\n// - code should go first as it prevents any transformations inside\n\nimport type { TextMatchTransformer } from '@lexical/markdown'\n\nimport { $createTextNode, $isTextNode } from 'lexical'\n\nimport type { SerializedLinkNode } from './server/schema.js'\n\nimport { sanitizeUrl } from '../../lexical/utils/url.js'\nimport { $createLinkNode, $isLinkNode, LinkNode } from './nodes/LinkNode.js'\n\n// - then longer tags match (e.g. ** or __ should go before * or _)\n\nexport type CreateLinkMarkdownTransformerArgs = {\n /**\n * A function that receives a serialized internal link node and returns the URL string.\n * Required for internal links (linkType === 'internal') to be exported correctly, since\n * internal links store a doc reference rather than a URL.\n *\n * Without this, internal links will export as `[text]()` with an empty href.\n */\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}\n\nconst replaceTransformer: TextMatchTransformer['replace'] = (textNode, match) => {\n const [, linkText, linkUrl] = match\n const linkNode = $createLinkNode({\n fields: {\n doc: null,\n linkType: 'custom',\n newTab: false,\n url: linkUrl,\n },\n })\n const linkTextNode = $createTextNode(linkText)\n linkTextNode.setFormat(textNode.getFormat())\n linkNode.append(linkTextNode)\n textNode.replace(linkNode)\n\n return linkTextNode\n}\n\nexport const createLinkMarkdownTransformer = (\n args?: CreateLinkMarkdownTransformerArgs,\n): TextMatchTransformer => ({\n type: 'text-match',\n dependencies: [LinkNode],\n export: (_node, exportChildren) => {\n if (!$isLinkNode(_node)) {\n return null\n }\n const node: LinkNode = _node\n const fields = node.getFields()\n\n let url: string\n\n if (fields.linkType === 'internal') {\n if (args?.internalDocToHref) {\n url = sanitizeUrl(args.internalDocToHref({ linkNode: node.exportJSON() }))\n } else {\n // eslint-disable-next-line no-console\n console.warn(\n 'Lexical → Markdown converter: found internal link but internalDocToHref is not provided — link will have an empty href',\n )\n url = ''\n }\n } else {\n url = sanitizeUrl(fields.url ?? '')\n }\n\n const textContent = exportChildren(node)\n return `[${textContent}](${url})`\n },\n importRegExp: /(?<!!)\\[([^[]+)\\]\\(([^()\\s]+)(?:\\s\"((?:[^\"]*\\\\\")*[^\"]*)\"\\s*)?\\)/,\n regExp: /(?<!!)\\[([^[]+)\\]\\(([^()\\s]+)(?:\\s\"((?:[^\"]*\\\\\")*[^\"]*)\"\\s*)?\\)$/,\n replace: replaceTransformer,\n trigger: ')',\n})\n\nexport const LinkMarkdownTransformer: TextMatchTransformer = createLinkMarkdownTransformer()\n"],"mappings":"AAAA;;GAAA,CAIA;AACA;AACA;AAIA,SAASA,eAAe,QAAqB;AAI7C,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAevD,MAAMC,kBAAA,GAAsDA,CAACC,QAAA,EAAUC,KAAA;EACrE,MAAM,GAAGC,QAAA,EAAUC,OAAA,CAAQ,GAAGF,KAAA;EAC9B,MAAMG,QAAA,GAAWR,eAAA,CAAgB;IAC/BS,MAAA,EAAQ;MACNC,GAAA,EAAK;MACLC,QAAA,EAAU;MACVC,MAAA,EAAQ;MACRC,GAAA,EAAKN;IACP;EACF;EACA,MAAMO,YAAA,GAAehB,eAAA,CAAgBQ,QAAA;EACrCQ,YAAA,CAAaC,SAAS,CAACX,QAAA,CAASY,SAAS;EACzCR,QAAA,CAASS,MAAM,CAACH,YAAA;EAChBV,QAAA,CAASc,OAAO,CAACV,QAAA;EAEjB,OAAOM,YAAA;AACT;AAEA,OAAO,MAAMK,6BAAA,GACXC,IAAA,KAC0B;EAC1BC,IAAA,EAAM;EACNC,YAAA,EAAc,CAACpB,QAAA,CAAS;EACxBqB,MAAA,EAAQA,CAACC,KAAA,EAAOC,cAAA;IACd,IAAI,CAACxB,WAAA,CAAYuB,KAAA,GAAQ;MACvB,OAAO;IACT;IACA,MAAME,IAAA,GAAiBF,KAAA;IACvB,MAAMf,MAAA,GAASiB,IAAA,CAAKC,SAAS;IAE7B,IAAId,GAAA;IAEJ,IAAIJ,MAAA,CAAOE,QAAQ,KAAK,YAAY;MAClC,IAAIS,IAAA,EAAMQ,iBAAA,EAAmB;QAC3Bf,GAAA,GAAMd,WAAA,CAAYqB,IAAA,CAAKQ,iBAAiB,CAAC;UAAEpB,QAAA,EAAUkB,IAAA,CAAKG,UAAU;QAAG;MACzE,OAAO;QACL;QACAC,OAAA,CAAQC,IAAI,CACV;QAEFlB,GAAA,GAAM;MACR;IACF,OAAO;MACLA,GAAA,GAAMd,WAAA,CAAYU,MAAA,CAAOI,GAAG,IAAI;IAClC;IAEA,MAAMmB,WAAA,GAAcP,cAAA,CAAeC,IAAA;IACnC,OAAO,IAAIM,WAAA,KAAgBnB,GAAA,GAAM;EACnC;EACAoB,YAAA,EAAc;EACdC,MAAA,EAAQ;EACRhB,OAAA,EAASf,kBAAA;EACTgC,OAAA,EAAS;AACX;AAEA,OAAO,MAAMC,uBAAA,GAAgDjB,6BAAA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHeadlessEditor } from '@lexical/headless';
|
|
2
2
|
import { $createParagraphNode, $createTextNode, $getRoot } from 'lexical';
|
|
3
3
|
import { describe, expect, it } from 'vitest';
|
|
4
|
-
import { $convertToMarkdownString } from '
|
|
4
|
+
import { $convertToMarkdownString } from '@lexical/markdown';
|
|
5
5
|
import { AutoLinkNode } from './nodes/AutoLinkNode.js';
|
|
6
6
|
import { $createLinkNode, LinkNode } from './nodes/LinkNode.js';
|
|
7
7
|
import { LinkMarkdownTransformer, createLinkMarkdownTransformer } from './markdownTransformer.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.spec.js","names":["createHeadlessEditor","$createParagraphNode","$createTextNode","$getRoot","describe","expect","it","$convertToMarkdownString","AutoLinkNode","$createLinkNode","LinkNode","LinkMarkdownTransformer","createLinkMarkdownTransformer","createEditor","nodes","toMarkdown","setupFn","transformer","editor","update","discrete","markdown","getEditorState","read","link","fields","linkType","url","newTab","doc","append","toBe","markdownNull","markdownUndefined","relationTo","value","id","slug","internalDocToHref","linkNode","capturedLinkNode","title","not","toBeNull","toMatchObject","setup","fromStatic","fromFactory"],"sources":["../../../src/features/link/markdownTransformer.spec.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless'\nimport { $createParagraphNode, $createTextNode, $getRoot } from 'lexical'\nimport { describe, expect, it } from 'vitest'\n\nimport { $convertToMarkdownString } from '../../packages/@lexical/markdown/index.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { $createLinkNode, LinkNode } from './nodes/LinkNode.js'\nimport type { SerializedLinkNode } from './server/schema.js'\nimport { LinkMarkdownTransformer, createLinkMarkdownTransformer } from './markdownTransformer.js'\n\nfunction createEditor() {\n return createHeadlessEditor({ nodes: [LinkNode, AutoLinkNode] })\n}\n\nfunction toMarkdown(setupFn: () => void, transformer = LinkMarkdownTransformer): string {\n const editor = createEditor()\n editor.update(setupFn, { discrete: true })\n let markdown = ''\n editor.getEditorState().read(() => {\n markdown = $convertToMarkdownString([transformer])\n })\n return markdown\n}\n\ndescribe('createLinkMarkdownTransformer', () => {\n describe('custom links', () => {\n it('should export a custom link with its url', () => {\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: 'https://payloadcms.com', newTab: false, doc: null },\n })\n link.append($createTextNode('Payload'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdown).toBe('[Payload](https://payloadcms.com)')\n })\n\n it('should export a custom link that opens in a new tab', () => {\n // newTab is a Payload field — markdown has no equivalent, so it is intentionally dropped\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: 'https://payloadcms.com', newTab: true, doc: null },\n })\n link.append($createTextNode('Payload'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdown).toBe('[Payload](https://payloadcms.com)')\n })\n\n it('should produce an empty href when url is null or undefined', () => {\n const markdownNull = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: null as unknown as string, newTab: false, doc: null },\n })\n link.append($createTextNode('Broken'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n const markdownUndefined = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', newTab: false, doc: null },\n })\n link.append($createTextNode('Broken'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdownNull).toBe('[Broken]()')\n expect(markdownUndefined).toBe('[Broken]()')\n })\n })\n\n describe('internal links', () => {\n it('should export an empty href when no internalDocToHref is provided', () => {\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: {\n linkType: 'internal',\n doc: { relationTo: 'pages', value: { id: '1', slug: 'about' } },\n newTab: false,\n },\n })\n link.append($createTextNode('About'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdown).toBe('[About]()')\n })\n\n it('should call internalDocToHref and use the returned url', () => {\n const transformer = createLinkMarkdownTransformer({\n internalDocToHref: ({ linkNode }) => {\n const value = linkNode.fields.doc?.value\n if (value && typeof value === 'object' && 'slug' in value) {\n return `/${value.slug}`\n }\n return '/'\n },\n })\n\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: {\n linkType: 'internal',\n doc: { relationTo: 'pages', value: { id: '1', slug: 'about' } },\n newTab: false,\n },\n })\n link.append($createTextNode('About'))\n $getRoot().append($createParagraphNode().append(link))\n }, transformer)\n\n expect(markdown).toBe('[About](/about)')\n })\n\n it('should pass the full serialized link node to internalDocToHref', () => {\n let capturedLinkNode: SerializedLinkNode | null = null\n\n const transformer = createLinkMarkdownTransformer({\n internalDocToHref: ({ linkNode }) => {\n capturedLinkNode = linkNode\n return '/captured'\n },\n })\n\n toMarkdown(() => {\n const link = $createLinkNode({\n fields: {\n linkType: 'internal',\n doc: { relationTo: 'pages', value: { id: '42', title: 'Home' } },\n newTab: true,\n },\n })\n link.append($createTextNode('Home'))\n $getRoot().append($createParagraphNode().append(link))\n }, transformer)\n\n expect(capturedLinkNode).not.toBeNull()\n expect(capturedLinkNode!.fields.linkType).toBe('internal')\n expect(capturedLinkNode!.fields.doc?.relationTo).toBe('pages')\n expect(capturedLinkNode!.fields.doc?.value).toMatchObject({ id: '42', title: 'Home' })\n expect(capturedLinkNode!.fields.newTab).toBe(true)\n })\n })\n\n describe('LinkMarkdownTransformer (static export)', () => {\n it('should behave identically to createLinkMarkdownTransformer() with no args', () => {\n const setup = () => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: 'https://example.com', newTab: false, doc: null },\n })\n link.append($createTextNode('Example'))\n $getRoot().append($createParagraphNode().append(link))\n }\n\n const fromStatic = toMarkdown(setup, LinkMarkdownTransformer)\n const fromFactory = toMarkdown(setup, createLinkMarkdownTransformer())\n\n expect(fromStatic).toBe(fromFactory)\n expect(fromStatic).toBe('[Example](https://example.com)')\n })\n })\n})\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,EAAEC,eAAe,EAAEC,QAAQ,QAAQ;AAChE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,YAAY,QAAQ;AAC7B,SAASC,eAAe,EAAEC,QAAQ,QAAQ;AAE1C,SAASC,uBAAuB,EAAEC,6BAA6B,QAAQ;AAEvE,SAASC,aAAA;EACP,OAAOb,oBAAA,CAAqB;IAAEc,KAAA,EAAO,CAACJ,QAAA,EAAUF,YAAA;EAAc;AAChE;AAEA,SAASO,WAAWC,OAAmB,EAAEC,WAAA,GAAcN,uBAAuB;EAC5E,MAAMO,MAAA,GAASL,YAAA;EACfK,MAAA,CAAOC,MAAM,CAACH,OAAA,EAAS;IAAEI,QAAA,EAAU;EAAK;EACxC,IAAIC,QAAA,GAAW;EACfH,MAAA,CAAOI,cAAc,GAAGC,IAAI,CAAC;IAC3BF,QAAA,GAAWd,wBAAA,CAAyB,CAACU,WAAA,CAAY;EACnD;EACA,OAAOI,QAAA;AACT;AAEAjB,QAAA,CAAS,iCAAiC;EACxCA,QAAA,CAAS,gBAAgB;IACvBE,EAAA,CAAG,4CAA4C;MAC7C,MAAMe,QAAA,GAAWN,UAAA,CAAW;QAC1B,MAAMS,IAAA,GAAOf,eAAA,CAAgB;UAC3BgB,MAAA,EAAQ;YAAEC,QAAA,EAAU;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MAAM,EAAEG,IAAI,CAAC;IAC/C;EACF;EAEA3B,QAAA,CAAS,2CAA2C;IAClDE,EAAA,CAAG,6EAA6E;MAC9E,MAAMuC,KAAA,GAAQA,CAAA;QACZ,MAAMrB,IAAA,GAAOf,eAAA,CAAgB;UAC3BgB,MAAA,EAAQ;YAAEC,QAAA,EAAU;YAAUC,GAAA,EAAK;YAAuBC,MAAA,EAAQ;YAAOC,GAAA,EAAK;UAAK;QACrF;QACAL,IAAA,CAAKM,MAAM,CAAC5B,eAAA,CAAgB;QAC5BC,QAAA,GAAW2B,MAAM,CAAC7B,oBAAA,GAAuB6B,MAAM,CAACN,IAAA;MAClD;MAEA,MAAMsB,UAAA,GAAa/B,UAAA,CAAW8B,KAAA,EAAOlC,uBAAA;MACrC,MAAMoC,WAAA,GAAchC,UAAA,CAAW8B,KAAA,EAAOjC,6BAAA;MAEtCP,MAAA,CAAOyC,UAAA,EAAYf,IAAI,CAACgB,WAAA;MACxB1C,MAAA,CAAOyC,UAAA,EAAYf,IAAI,CAAC;IAC1B;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"markdownTransformer.spec.js","names":["createHeadlessEditor","$createParagraphNode","$createTextNode","$getRoot","describe","expect","it","$convertToMarkdownString","AutoLinkNode","$createLinkNode","LinkNode","LinkMarkdownTransformer","createLinkMarkdownTransformer","createEditor","nodes","toMarkdown","setupFn","transformer","editor","update","discrete","markdown","getEditorState","read","link","fields","linkType","url","newTab","doc","append","toBe","markdownNull","markdownUndefined","relationTo","value","id","slug","internalDocToHref","linkNode","capturedLinkNode","title","not","toBeNull","toMatchObject","setup","fromStatic","fromFactory"],"sources":["../../../src/features/link/markdownTransformer.spec.ts"],"sourcesContent":["import { createHeadlessEditor } from '@lexical/headless'\nimport { $createParagraphNode, $createTextNode, $getRoot } from 'lexical'\nimport { describe, expect, it } from 'vitest'\n\nimport { $convertToMarkdownString } from '@lexical/markdown'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { $createLinkNode, LinkNode } from './nodes/LinkNode.js'\nimport type { SerializedLinkNode } from './server/schema.js'\nimport { LinkMarkdownTransformer, createLinkMarkdownTransformer } from './markdownTransformer.js'\n\nfunction createEditor() {\n return createHeadlessEditor({ nodes: [LinkNode, AutoLinkNode] })\n}\n\nfunction toMarkdown(setupFn: () => void, transformer = LinkMarkdownTransformer): string {\n const editor = createEditor()\n editor.update(setupFn, { discrete: true })\n let markdown = ''\n editor.getEditorState().read(() => {\n markdown = $convertToMarkdownString([transformer])\n })\n return markdown\n}\n\ndescribe('createLinkMarkdownTransformer', () => {\n describe('custom links', () => {\n it('should export a custom link with its url', () => {\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: 'https://payloadcms.com', newTab: false, doc: null },\n })\n link.append($createTextNode('Payload'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdown).toBe('[Payload](https://payloadcms.com)')\n })\n\n it('should export a custom link that opens in a new tab', () => {\n // newTab is a Payload field — markdown has no equivalent, so it is intentionally dropped\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: 'https://payloadcms.com', newTab: true, doc: null },\n })\n link.append($createTextNode('Payload'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdown).toBe('[Payload](https://payloadcms.com)')\n })\n\n it('should produce an empty href when url is null or undefined', () => {\n const markdownNull = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: null as unknown as string, newTab: false, doc: null },\n })\n link.append($createTextNode('Broken'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n const markdownUndefined = toMarkdown(() => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', newTab: false, doc: null },\n })\n link.append($createTextNode('Broken'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdownNull).toBe('[Broken]()')\n expect(markdownUndefined).toBe('[Broken]()')\n })\n })\n\n describe('internal links', () => {\n it('should export an empty href when no internalDocToHref is provided', () => {\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: {\n linkType: 'internal',\n doc: { relationTo: 'pages', value: { id: '1', slug: 'about' } },\n newTab: false,\n },\n })\n link.append($createTextNode('About'))\n $getRoot().append($createParagraphNode().append(link))\n })\n\n expect(markdown).toBe('[About]()')\n })\n\n it('should call internalDocToHref and use the returned url', () => {\n const transformer = createLinkMarkdownTransformer({\n internalDocToHref: ({ linkNode }) => {\n const value = linkNode.fields.doc?.value\n if (value && typeof value === 'object' && 'slug' in value) {\n return `/${value.slug}`\n }\n return '/'\n },\n })\n\n const markdown = toMarkdown(() => {\n const link = $createLinkNode({\n fields: {\n linkType: 'internal',\n doc: { relationTo: 'pages', value: { id: '1', slug: 'about' } },\n newTab: false,\n },\n })\n link.append($createTextNode('About'))\n $getRoot().append($createParagraphNode().append(link))\n }, transformer)\n\n expect(markdown).toBe('[About](/about)')\n })\n\n it('should pass the full serialized link node to internalDocToHref', () => {\n let capturedLinkNode: SerializedLinkNode | null = null\n\n const transformer = createLinkMarkdownTransformer({\n internalDocToHref: ({ linkNode }) => {\n capturedLinkNode = linkNode\n return '/captured'\n },\n })\n\n toMarkdown(() => {\n const link = $createLinkNode({\n fields: {\n linkType: 'internal',\n doc: { relationTo: 'pages', value: { id: '42', title: 'Home' } },\n newTab: true,\n },\n })\n link.append($createTextNode('Home'))\n $getRoot().append($createParagraphNode().append(link))\n }, transformer)\n\n expect(capturedLinkNode).not.toBeNull()\n expect(capturedLinkNode!.fields.linkType).toBe('internal')\n expect(capturedLinkNode!.fields.doc?.relationTo).toBe('pages')\n expect(capturedLinkNode!.fields.doc?.value).toMatchObject({ id: '42', title: 'Home' })\n expect(capturedLinkNode!.fields.newTab).toBe(true)\n })\n })\n\n describe('LinkMarkdownTransformer (static export)', () => {\n it('should behave identically to createLinkMarkdownTransformer() with no args', () => {\n const setup = () => {\n const link = $createLinkNode({\n fields: { linkType: 'custom', url: 'https://example.com', newTab: false, doc: null },\n })\n link.append($createTextNode('Example'))\n $getRoot().append($createParagraphNode().append(link))\n }\n\n const fromStatic = toMarkdown(setup, LinkMarkdownTransformer)\n const fromFactory = toMarkdown(setup, createLinkMarkdownTransformer())\n\n expect(fromStatic).toBe(fromFactory)\n expect(fromStatic).toBe('[Example](https://example.com)')\n })\n })\n})\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,EAAEC,eAAe,EAAEC,QAAQ,QAAQ;AAChE,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ;AAErC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,YAAY,QAAQ;AAC7B,SAASC,eAAe,EAAEC,QAAQ,QAAQ;AAE1C,SAASC,uBAAuB,EAAEC,6BAA6B,QAAQ;AAEvE,SAASC,aAAA;EACP,OAAOb,oBAAA,CAAqB;IAAEc,KAAA,EAAO,CAACJ,QAAA,EAAUF,YAAA;EAAc;AAChE;AAEA,SAASO,WAAWC,OAAmB,EAAEC,WAAA,GAAcN,uBAAuB;EAC5E,MAAMO,MAAA,GAASL,YAAA;EACfK,MAAA,CAAOC,MAAM,CAACH,OAAA,EAAS;IAAEI,QAAA,EAAU;EAAK;EACxC,IAAIC,QAAA,GAAW;EACfH,MAAA,CAAOI,cAAc,GAAGC,IAAI,CAAC;IAC3BF,QAAA,GAAWd,wBAAA,CAAyB,CAACU,WAAA,CAAY;EACnD;EACA,OAAOI,QAAA;AACT;AAEAjB,QAAA,CAAS,iCAAiC;EACxCA,QAAA,CAAS,gBAAgB;IACvBE,EAAA,CAAG,4CAA4C;MAC7C,MAAMe,QAAA,GAAWN,UAAA,CAAW;QAC1B,MAAMS,IAAA,GAAOf,eAAA,CAAgB;UAC3BgB,MAAA,EAAQ;YAAEC,QAAA,EAAU;YAAUC,GAAA,EAAK;YAA0BC,MAAA,EAAQ;YAAOC,GAAA,EAAK;UAAK;QACxF;QACAL,IAAA,CAAKM,MAAM,CAAC5B,eAAA,CAAgB;QAC5BC,QAAA,GAAW2B,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,IAAA,GAAOf,eAAA,CAAgB;UAC3BgB,MAAA,EAAQ;YAAEC,QAAA,EAAU;YAAUC,GAAA,EAAK;YAAuBC,MAAA,EAAQ;YAAOC,GAAA,EAAK;UAAK;QACrF;QACAL,IAAA,CAAKM,MAAM,CAAC5B,eAAA,CAAgB;QAC5BC,QAAA,GAAW2B,MAAM,CAAC7B,oBAAA,GAAuB6B,MAAM,CAACN,IAAA;MAClD;MAEA,MAAMsB,UAAA,GAAa/B,UAAA,CAAW8B,KAAA,EAAOlC,uBAAA;MACrC,MAAMoC,WAAA,GAAchC,UAAA,CAAW8B,KAAA,EAAOjC,6BAAA;MAEtCP,MAAA,CAAOyC,UAAA,EAAYf,IAAI,CAACgB,WAAA;MACxB1C,MAAA,CAAOyC,UAAA,EAAYf,IAAI,CAAC;IAC1B;EACF;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/checklist/markdownTransformers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdownTransformers.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/checklist/markdownTransformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAM3D,eAAO,MAAM,UAAU,EAAE,kBAQxB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformers.js","names":["$isListNode","ListItemNode","ListNode","listExport","listReplace","CHECK_LIST","type","dependencies","export","node","exportChildren","regExp","replace"],"sources":["../../../../src/features/lists/checklist/markdownTransformers.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"markdownTransformers.js","names":["$isListNode","ListItemNode","ListNode","listExport","listReplace","CHECK_LIST","type","dependencies","export","node","exportChildren","regExp","replace"],"sources":["../../../../src/features/lists/checklist/markdownTransformers.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport { $isListNode, ListItemNode, ListNode } from '@lexical/list'\n\nimport { listExport, listReplace } from '../shared/markdown.js'\n\nexport const CHECK_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: /^(\\s*)(?:-\\s)?\\s?(\\[(\\s|x)?\\])\\s/i,\n replace: listReplace('check'),\n}\n"],"mappings":"AAEA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAEpD,SAASC,UAAU,EAAEC,WAAW,QAAQ;AAExC,OAAO,MAAMC,UAAA,GAAiC;EAC5CC,IAAA,EAAM;EACNC,YAAA,EAAc,CAACL,QAAA,EAAUD,YAAA,CAAa;EACtCO,MAAA,EAAQA,CAACC,IAAA,EAAMC,cAAA;IACb,OAAOV,WAAA,CAAYS,IAAA,IAAQN,UAAA,CAAWM,IAAA,EAAMC,cAAA,EAAgB,KAAK;EACnE;EACAC,MAAA,EAAQ;EACRC,OAAA,EAASR,WAAA,CAAY;AACvB","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ElementTransformer } from '
|
|
1
|
+
import type { ElementTransformer } from '@lexical/markdown';
|
|
2
2
|
export declare const ORDERED_LIST: ElementTransformer;
|
|
3
3
|
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/orderedList/markdownTransformer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/orderedList/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAM3D,eAAO,MAAM,YAAY,EAAE,kBAQ1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.js","names":["$isListNode","ListItemNode","ListNode","listExport","listReplace","ORDERED_LIST","type","dependencies","export","node","exportChildren","regExp","replace"],"sources":["../../../../src/features/lists/orderedList/markdownTransformer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["$isListNode","ListItemNode","ListNode","listExport","listReplace","ORDERED_LIST","type","dependencies","export","node","exportChildren","regExp","replace"],"sources":["../../../../src/features/lists/orderedList/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport { $isListNode, ListItemNode, ListNode } from '@lexical/list'\n\nimport { listExport, listReplace } from '../shared/markdown.js'\n\nexport const ORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: /^(\\s*)(\\d+)\\.\\s/,\n replace: listReplace('number'),\n}\n"],"mappings":"AAEA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAEpD,SAASC,UAAU,EAAEC,WAAW,QAAQ;AAExC,OAAO,MAAMC,YAAA,GAAmC;EAC9CC,IAAA,EAAM;EACNC,YAAA,EAAc,CAACL,QAAA,EAAUD,YAAA,CAAa;EACtCO,MAAA,EAAQA,CAACC,IAAA,EAAMC,cAAA;IACb,OAAOV,WAAA,CAAYS,IAAA,IAAQN,UAAA,CAAWM,IAAA,EAAMC,cAAA,EAAgB,KAAK;EACnE;EACAC,MAAA,EAAQ;EACRC,OAAA,EAASR,WAAA,CAAY;AACvB","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ListNode, ListType } from '@lexical/list';
|
|
2
|
+
import type { ElementTransformer } from '@lexical/markdown';
|
|
2
3
|
import type { ElementNode } from 'lexical';
|
|
3
|
-
import type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js';
|
|
4
4
|
export declare const listReplace: (listType: ListType) => ElementTransformer["replace"];
|
|
5
5
|
export declare const listExport: (listNode: ListNode, exportChildren: (node: ElementNode) => string, depth: number) => string;
|
|
6
6
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/shared/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/shared/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAO1C,eAAO,MAAM,WAAW,GAAI,UAAU,QAAQ,KAAG,kBAAkB,CAAC,SAAS,CA6B5E,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,EAClB,gBAAgB,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,EAC7C,OAAO,MAAM,KACZ,MA2BF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","names":["$createListItemNode","$createListNode","$isListItemNode","$isListNode","LIST_INDENT_SIZE","listReplace","listType","parentNode","children","match","previousNode","getPreviousSibling","nextNode","getNextSibling","listItem","undefined","getListType","firstChild","getFirstChild","insertBefore","append","remove","list","Number","replace","select","indent","Math","floor","length","setIndent","listExport","listNode","exportChildren","depth","output","getChildren","index","listItemNode","getChildrenSize","push","repeat","prefix","getStart","getChecked","join"],"sources":["../../../../src/features/lists/shared/markdown.ts"],"sourcesContent":["// Copied from https://github.com/facebook/lexical/blob/176b8cf16ecb332ee5efe2c75219e223b7b019f2/packages/lexical-markdown/src/MarkdownTransformers.ts#L97C1-L172C1\n\nimport type { ListNode, ListType } from '@lexical/list'\nimport type { ElementNode } from 'lexical'\n\nimport { $createListItemNode, $createListNode, $isListItemNode, $isListNode } from '@lexical/list'\n\
|
|
1
|
+
{"version":3,"file":"markdown.js","names":["$createListItemNode","$createListNode","$isListItemNode","$isListNode","LIST_INDENT_SIZE","listReplace","listType","parentNode","children","match","previousNode","getPreviousSibling","nextNode","getNextSibling","listItem","undefined","getListType","firstChild","getFirstChild","insertBefore","append","remove","list","Number","replace","select","indent","Math","floor","length","setIndent","listExport","listNode","exportChildren","depth","output","getChildren","index","listItemNode","getChildrenSize","push","repeat","prefix","getStart","getChecked","join"],"sources":["../../../../src/features/lists/shared/markdown.ts"],"sourcesContent":["// Copied from https://github.com/facebook/lexical/blob/176b8cf16ecb332ee5efe2c75219e223b7b019f2/packages/lexical-markdown/src/MarkdownTransformers.ts#L97C1-L172C1\n\nimport type { ListNode, ListType } from '@lexical/list'\nimport type { ElementTransformer } from '@lexical/markdown'\nimport type { ElementNode } from 'lexical'\n\nimport { $createListItemNode, $createListNode, $isListItemNode, $isListNode } from '@lexical/list'\n\n// Amount of spaces that define indentation level\nconst LIST_INDENT_SIZE = 4\n\nexport const listReplace = (listType: ListType): ElementTransformer['replace'] => {\n return (parentNode, children, match) => {\n const previousNode = parentNode.getPreviousSibling()\n const nextNode = parentNode.getNextSibling()\n const listItem = $createListItemNode(listType === 'check' ? match[3] === 'x' : undefined)\n if ($isListNode(nextNode) && nextNode.getListType() === listType) {\n const firstChild = nextNode.getFirstChild()\n if (firstChild !== null) {\n firstChild.insertBefore(listItem)\n } else {\n // should never happen, but let's handle gracefully, just in case.\n nextNode.append(listItem)\n }\n parentNode.remove()\n } else if ($isListNode(previousNode) && previousNode.getListType() === listType) {\n previousNode.append(listItem)\n parentNode.remove()\n } else {\n const list = $createListNode(listType, listType === 'number' ? Number(match[2]) : undefined)\n list.append(listItem)\n parentNode.replace(list)\n }\n listItem.append(...children)\n listItem.select(0, 0)\n const indent = Math.floor(match[1]!.length / LIST_INDENT_SIZE)\n if (indent) {\n listItem.setIndent(indent)\n }\n }\n}\n\nexport const listExport = (\n listNode: ListNode,\n exportChildren: (node: ElementNode) => string,\n depth: number,\n): string => {\n const output: string[] = []\n const children = listNode.getChildren()\n let index = 0\n for (const listItemNode of children) {\n if ($isListItemNode(listItemNode)) {\n if (listItemNode.getChildrenSize() === 1) {\n const firstChild = listItemNode.getFirstChild()\n if ($isListNode(firstChild)) {\n output.push(listExport(firstChild, exportChildren, depth + 1))\n continue\n }\n }\n const indent = ' '.repeat(depth * LIST_INDENT_SIZE)\n const listType = listNode.getListType()\n const prefix =\n listType === 'number'\n ? `${listNode.getStart() + index}. `\n : listType === 'check'\n ? `- [${listItemNode.getChecked() ? 'x' : ' '}] `\n : '- '\n output.push(indent + prefix + exportChildren(listItemNode))\n index++\n }\n }\n\n return output.join('\\n')\n}\n"],"mappings":"AAAA;AAMA,SAASA,mBAAmB,EAAEC,eAAe,EAAEC,eAAe,EAAEC,WAAW,QAAQ;AAEnF;AACA,MAAMC,gBAAA,GAAmB;AAEzB,OAAO,MAAMC,WAAA,GAAeC,QAAA;EAC1B,OAAO,CAACC,UAAA,EAAYC,QAAA,EAAUC,KAAA;IAC5B,MAAMC,YAAA,GAAeH,UAAA,CAAWI,kBAAkB;IAClD,MAAMC,QAAA,GAAWL,UAAA,CAAWM,cAAc;IAC1C,MAAMC,QAAA,GAAWd,mBAAA,CAAoBM,QAAA,KAAa,UAAUG,KAAK,CAAC,EAAE,KAAK,MAAMM,SAAA;IAC/E,IAAIZ,WAAA,CAAYS,QAAA,KAAaA,QAAA,CAASI,WAAW,OAAOV,QAAA,EAAU;MAChE,MAAMW,UAAA,GAAaL,QAAA,CAASM,aAAa;MACzC,IAAID,UAAA,KAAe,MAAM;QACvBA,UAAA,CAAWE,YAAY,CAACL,QAAA;MAC1B,OAAO;QACL;QACAF,QAAA,CAASQ,MAAM,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,gBAAA;MAClC,MAAME,QAAA,GAAW0B,QAAA,CAAShB,WAAW;MACrC,MAAM0B,MAAA,GACJpC,QAAA,KAAa,WACT,GAAG0B,QAAA,CAASW,QAAQ,KAAKN,KAAA,IAAS,GAClC/B,QAAA,KAAa,UACX,MAAMgC,YAAA,CAAaM,UAAU,KAAK,MAAM,OAAO,GAC/C;MACRT,MAAA,CAAOK,IAAI,CAACd,MAAA,GAASgB,MAAA,GAAST,cAAA,CAAeK,YAAA;MAC7CD,KAAA;IACF;EACF;EAEA,OAAOF,MAAA,CAAOU,IAAI,CAAC;AACrB","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ElementTransformer } from '
|
|
1
|
+
import type { ElementTransformer } from '@lexical/markdown';
|
|
2
2
|
export declare const UNORDERED_LIST: ElementTransformer;
|
|
3
3
|
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/unorderedList/markdownTransformer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/lists/unorderedList/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAM3D,eAAO,MAAM,cAAc,EAAE,kBAQ5B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.js","names":["$isListNode","ListItemNode","ListNode","listExport","listReplace","UNORDERED_LIST","type","dependencies","export","node","exportChildren","regExp","replace"],"sources":["../../../../src/features/lists/unorderedList/markdownTransformer.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["$isListNode","ListItemNode","ListNode","listExport","listReplace","UNORDERED_LIST","type","dependencies","export","node","exportChildren","regExp","replace"],"sources":["../../../../src/features/lists/unorderedList/markdownTransformer.ts"],"sourcesContent":["import type { ElementTransformer } from '@lexical/markdown'\n\nimport { $isListNode, ListItemNode, ListNode } from '@lexical/list'\n\nimport { listExport, listReplace } from '../shared/markdown.js'\n\nexport const UNORDERED_LIST: ElementTransformer = {\n type: 'element',\n dependencies: [ListNode, ListItemNode],\n export: (node, exportChildren) => {\n return $isListNode(node) ? listExport(node, exportChildren, 0) : null\n },\n regExp: /^(\\s*)[-*+]\\s/,\n replace: listReplace('bullet'),\n}\n"],"mappings":"AAEA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAEpD,SAASC,UAAU,EAAEC,WAAW,QAAQ;AAExC,OAAO,MAAMC,cAAA,GAAqC;EAChDC,IAAA,EAAM;EACNC,YAAA,EAAc,CAACL,QAAA,EAAUD,YAAA,CAAa;EACtCO,MAAA,EAAQA,CAACC,IAAA,EAAMC,cAAA;IACb,OAAOV,WAAA,CAAYS,IAAA,IAAQN,UAAA,CAAWM,IAAA,EAAMC,cAAA,EAAgB,KAAK;EACnE;EACAC,MAAA,EAAQ;EACRC,OAAA,EAASR,WAAA,CAAY;AACvB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolbarStates.d.ts","sourceRoot":"","sources":["../../../../src/features/toolbars/shared/useToolbarStates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKjE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,YAAY,EAAE,OAAO,CAAA;IACrB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC3C,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;CAC1C;AAgCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,GACjC,aAAa,
|
|
1
|
+
{"version":3,"file":"useToolbarStates.d.ts","sourceRoot":"","sources":["../../../../src/features/toolbars/shared/useToolbarStates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKjE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,WAAW,EAAE,gBAAgB,EAAE,CAAA;IAC/B,YAAY,EAAE,OAAO,CAAA;IACrB,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC3C,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;CAC1C;AAgCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,GACjC,aAAa,CA2Ff"}
|
|
@@ -114,7 +114,9 @@ export function useToolbarStates(editor, groups) {
|
|
|
114
114
|
}, [editor]);
|
|
115
115
|
useEffect(() => {
|
|
116
116
|
void runDeprioritized(updateStates);
|
|
117
|
-
const listener = () =>
|
|
117
|
+
const listener = () => {
|
|
118
|
+
void runDeprioritized(updateStates);
|
|
119
|
+
};
|
|
118
120
|
const cleanup = mergeRegister(editor.registerUpdateListener(listener));
|
|
119
121
|
document.addEventListener('mouseup', listener);
|
|
120
122
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToolbarStates.js","names":["mergeRegister","$getSelection","useCallback","useDeferredValue","useEffect","useRef","useState","useEditorConfigContext","useRunDeprioritized","buildDefaultStates","groups","itemStates","Map","groupStates","length","group","enabledItemKeys","item","items","set","key","active","enabled","push","activeItemKeys","activeItems","enabledGroup","useToolbarStates","editor","states","setStates","deferredStates","editorConfigContext","editorConfigContextRef","current","groupsRef","runDeprioritized","updateStates","getEditorState","read","selection","currentGroups","ctx","newItemStates","newGroupStates","maxActive","type","maxActiveItems","undefined","isActive","isEnabled","listener","cleanup","registerUpdateListener","document","addEventListener","removeEventListener"],"sources":["../../../../src/features/toolbars/shared/useToolbarStates.ts"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport { useCallback, useDeferredValue, useEffect, useRef, useState } from 'react'\n\nimport type { ToolbarGroup, ToolbarGroupItem } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { useRunDeprioritized } from '../../../utilities/useRunDeprioritized.js'\n\nexport interface ToolbarItemState {\n active: boolean\n enabled: boolean\n}\n\nexport interface ToolbarGroupState {\n activeItemKeys: string[]\n activeItems: ToolbarGroupItem[]\n enabledGroup: boolean\n enabledItemKeys: string[]\n}\n\nexport interface ToolbarStates {\n groupStates: Map<string, ToolbarGroupState>\n itemStates: Map<string, ToolbarItemState>\n}\n\n/**\n * Build default states where every item is enabled and nothing is active.\n * Used as the initial value so toolbar groups render immediately on mount\n * instead of waiting for the first updateStates call.\n */\nfunction buildDefaultStates(groups: ToolbarGroup[] | undefined): ToolbarStates {\n const itemStates = new Map<string, ToolbarItemState>()\n const groupStates = new Map<string, ToolbarGroupState>()\n\n if (!groups?.length) {\n return { groupStates, itemStates }\n }\n\n for (const group of groups) {\n const enabledItemKeys: string[] = []\n for (const item of group.items) {\n itemStates.set(item.key, { active: false, enabled: true })\n enabledItemKeys.push(item.key)\n }\n groupStates.set(group.key, {\n activeItemKeys: [],\n activeItems: [],\n enabledGroup: true,\n enabledItemKeys,\n })\n }\n\n return { groupStates, itemStates }\n}\n\n/**\n * Subscribes once to `editor.registerUpdateListener` and computes\n * isActive / isEnabled for every toolbar item in a read.\n */\nexport function useToolbarStates(\n editor: LexicalEditor,\n groups: ToolbarGroup[] | undefined,\n): ToolbarStates {\n const [states, setStates] = useState<ToolbarStates>(() => buildDefaultStates(groups))\n const deferredStates = useDeferredValue(states)\n\n const editorConfigContext = useEditorConfigContext()\n const editorConfigContextRef = useRef(editorConfigContext)\n editorConfigContextRef.current = editorConfigContext\n\n const groupsRef = useRef(groups)\n groupsRef.current = groups\n\n const runDeprioritized = useRunDeprioritized()\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!selection) {\n return\n }\n\n const currentGroups = groupsRef.current\n if (!currentGroups?.length) {\n return\n }\n\n const ctx = editorConfigContextRef.current\n const newItemStates = new Map<string, ToolbarItemState>()\n const newGroupStates = new Map<string, ToolbarGroupState>()\n\n for (const group of currentGroups) {\n const activeItemKeys: string[] = []\n const activeItems: ToolbarGroupItem[] = []\n const enabledItemKeys: string[] = []\n\n const maxActive = group.type === 'dropdown' ? (group.maxActiveItems ?? 1) : undefined\n\n for (const item of group.items) {\n const isActive = item.isActive\n ? (!maxActive || activeItemKeys.length < maxActive) &&\n item.isActive({ editor, editorConfigContext: ctx, selection })\n : false\n\n const isEnabled = item.isEnabled\n ? item.isEnabled({ editor, editorConfigContext: ctx, selection })\n : true\n\n if (isActive) {\n activeItemKeys.push(item.key)\n activeItems.push(item)\n }\n if (isEnabled) {\n enabledItemKeys.push(item.key)\n }\n\n newItemStates.set(item.key, { active: isActive, enabled: isEnabled })\n }\n\n const enabledGroup =\n group.type === 'dropdown' && group.isEnabled\n ? group.isEnabled({ editor, editorConfigContext: ctx, selection })\n : true\n\n newGroupStates.set(group.key, {\n activeItemKeys,\n activeItems,\n enabledGroup,\n enabledItemKeys,\n })\n }\n\n setStates({ groupStates: newGroupStates, itemStates: newItemStates })\n })\n }, [editor])\n\n useEffect(() => {\n void runDeprioritized(updateStates)\n\n const listener = () => runDeprioritized(updateStates)\n\n const cleanup = mergeRegister(editor.registerUpdateListener(listener))\n document.addEventListener('mouseup', listener)\n\n return () => {\n cleanup()\n document.removeEventListener('mouseup', listener)\n }\n }, [editor, runDeprioritized, updateStates])\n\n return deferredStates\n}\n"],"mappings":"AAAA;;AAGA,SAASA,aAAa,QAAQ;AAC9B,SAASC,aAAa,QAAQ;AAC9B,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI3E,SAASC,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AAmBpC;;;;;AAKA,SAASC,mBAAmBC,MAAkC;EAC5D,MAAMC,UAAA,GAAa,IAAIC,GAAA;EACvB,MAAMC,WAAA,GAAc,IAAID,GAAA;EAExB,IAAI,CAACF,MAAA,EAAQI,MAAA,EAAQ;IACnB,OAAO;MAAED,WAAA;MAAaF;IAAW;EACnC;EAEA,KAAK,MAAMI,KAAA,IAASL,MAAA,EAAQ;IAC1B,MAAMM,eAAA,GAA4B,EAAE;IACpC,KAAK,MAAMC,IAAA,IAAQF,KAAA,CAAMG,KAAK,EAAE;MAC9BP,UAAA,CAAWQ,GAAG,CAACF,IAAA,CAAKG,GAAG,EAAE;QAAEC,MAAA,EAAQ;QAAOC,OAAA,EAAS;MAAK;MACxDN,eAAA,CAAgBO,IAAI,CAACN,IAAA,CAAKG,GAAG;IAC/B;IACAP,WAAA,CAAYM,GAAG,CAACJ,KAAA,CAAMK,GAAG,EAAE;MACzBI,cAAA,EAAgB,EAA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AAMc,QAAA,GAAWA,CAAA,
|
|
1
|
+
{"version":3,"file":"useToolbarStates.js","names":["mergeRegister","$getSelection","useCallback","useDeferredValue","useEffect","useRef","useState","useEditorConfigContext","useRunDeprioritized","buildDefaultStates","groups","itemStates","Map","groupStates","length","group","enabledItemKeys","item","items","set","key","active","enabled","push","activeItemKeys","activeItems","enabledGroup","useToolbarStates","editor","states","setStates","deferredStates","editorConfigContext","editorConfigContextRef","current","groupsRef","runDeprioritized","updateStates","getEditorState","read","selection","currentGroups","ctx","newItemStates","newGroupStates","maxActive","type","maxActiveItems","undefined","isActive","isEnabled","listener","cleanup","registerUpdateListener","document","addEventListener","removeEventListener"],"sources":["../../../../src/features/toolbars/shared/useToolbarStates.ts"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { mergeRegister } from '@lexical/utils'\nimport { $getSelection } from 'lexical'\nimport { useCallback, useDeferredValue, useEffect, useRef, useState } from 'react'\n\nimport type { ToolbarGroup, ToolbarGroupItem } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { useRunDeprioritized } from '../../../utilities/useRunDeprioritized.js'\n\nexport interface ToolbarItemState {\n active: boolean\n enabled: boolean\n}\n\nexport interface ToolbarGroupState {\n activeItemKeys: string[]\n activeItems: ToolbarGroupItem[]\n enabledGroup: boolean\n enabledItemKeys: string[]\n}\n\nexport interface ToolbarStates {\n groupStates: Map<string, ToolbarGroupState>\n itemStates: Map<string, ToolbarItemState>\n}\n\n/**\n * Build default states where every item is enabled and nothing is active.\n * Used as the initial value so toolbar groups render immediately on mount\n * instead of waiting for the first updateStates call.\n */\nfunction buildDefaultStates(groups: ToolbarGroup[] | undefined): ToolbarStates {\n const itemStates = new Map<string, ToolbarItemState>()\n const groupStates = new Map<string, ToolbarGroupState>()\n\n if (!groups?.length) {\n return { groupStates, itemStates }\n }\n\n for (const group of groups) {\n const enabledItemKeys: string[] = []\n for (const item of group.items) {\n itemStates.set(item.key, { active: false, enabled: true })\n enabledItemKeys.push(item.key)\n }\n groupStates.set(group.key, {\n activeItemKeys: [],\n activeItems: [],\n enabledGroup: true,\n enabledItemKeys,\n })\n }\n\n return { groupStates, itemStates }\n}\n\n/**\n * Subscribes once to `editor.registerUpdateListener` and computes\n * isActive / isEnabled for every toolbar item in a read.\n */\nexport function useToolbarStates(\n editor: LexicalEditor,\n groups: ToolbarGroup[] | undefined,\n): ToolbarStates {\n const [states, setStates] = useState<ToolbarStates>(() => buildDefaultStates(groups))\n const deferredStates = useDeferredValue(states)\n\n const editorConfigContext = useEditorConfigContext()\n const editorConfigContextRef = useRef(editorConfigContext)\n editorConfigContextRef.current = editorConfigContext\n\n const groupsRef = useRef(groups)\n groupsRef.current = groups\n\n const runDeprioritized = useRunDeprioritized()\n\n const updateStates = useCallback(() => {\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if (!selection) {\n return\n }\n\n const currentGroups = groupsRef.current\n if (!currentGroups?.length) {\n return\n }\n\n const ctx = editorConfigContextRef.current\n const newItemStates = new Map<string, ToolbarItemState>()\n const newGroupStates = new Map<string, ToolbarGroupState>()\n\n for (const group of currentGroups) {\n const activeItemKeys: string[] = []\n const activeItems: ToolbarGroupItem[] = []\n const enabledItemKeys: string[] = []\n\n const maxActive = group.type === 'dropdown' ? (group.maxActiveItems ?? 1) : undefined\n\n for (const item of group.items) {\n const isActive = item.isActive\n ? (!maxActive || activeItemKeys.length < maxActive) &&\n item.isActive({ editor, editorConfigContext: ctx, selection })\n : false\n\n const isEnabled = item.isEnabled\n ? item.isEnabled({ editor, editorConfigContext: ctx, selection })\n : true\n\n if (isActive) {\n activeItemKeys.push(item.key)\n activeItems.push(item)\n }\n if (isEnabled) {\n enabledItemKeys.push(item.key)\n }\n\n newItemStates.set(item.key, { active: isActive, enabled: isEnabled })\n }\n\n const enabledGroup =\n group.type === 'dropdown' && group.isEnabled\n ? group.isEnabled({ editor, editorConfigContext: ctx, selection })\n : true\n\n newGroupStates.set(group.key, {\n activeItemKeys,\n activeItems,\n enabledGroup,\n enabledItemKeys,\n })\n }\n\n setStates({ groupStates: newGroupStates, itemStates: newItemStates })\n })\n }, [editor])\n\n useEffect(() => {\n void runDeprioritized(updateStates)\n\n const listener = () => {\n void runDeprioritized(updateStates)\n }\n\n const cleanup = mergeRegister(editor.registerUpdateListener(listener))\n document.addEventListener('mouseup', listener)\n\n return () => {\n cleanup()\n document.removeEventListener('mouseup', listener)\n }\n }, [editor, runDeprioritized, updateStates])\n\n return deferredStates\n}\n"],"mappings":"AAAA;;AAGA,SAASA,aAAa,QAAQ;AAC9B,SAASC,aAAa,QAAQ;AAC9B,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAI3E,SAASC,sBAAsB,QAAQ;AACvC,SAASC,mBAAmB,QAAQ;AAmBpC;;;;;AAKA,SAASC,mBAAmBC,MAAkC;EAC5D,MAAMC,UAAA,GAAa,IAAIC,GAAA;EACvB,MAAMC,WAAA,GAAc,IAAID,GAAA;EAExB,IAAI,CAACF,MAAA,EAAQI,MAAA,EAAQ;IACnB,OAAO;MAAED,WAAA;MAAaF;IAAW;EACnC;EAEA,KAAK,MAAMI,KAAA,IAASL,MAAA,EAAQ;IAC1B,MAAMM,eAAA,GAA4B,EAAE;IACpC,KAAK,MAAMC,IAAA,IAAQF,KAAA,CAAMG,KAAK,EAAE;MAC9BP,UAAA,CAAWQ,GAAG,CAACF,IAAA,CAAKG,GAAG,EAAE;QAAEC,MAAA,EAAQ;QAAOC,OAAA,EAAS;MAAK;MACxDN,eAAA,CAAgBO,IAAI,CAACN,IAAA,CAAKG,GAAG;IAC/B;IACAP,WAAA,CAAYM,GAAG,CAACJ,KAAA,CAAMK,GAAG,EAAE;MACzBI,cAAA,EAAgB,EAAE;MAClBC,WAAA,EAAa,EAAE;MACfC,YAAA,EAAc;MACdV;IACF;EACF;EAEA,OAAO;IAAEH,WAAA;IAAaF;EAAW;AACnC;AAE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AA,CAAOyB,sBAAsB,CAACF,QAAA;IAC5DG,QAAA,CAASC,gBAAgB,CAAC,WAAWJ,QAAA;IAErC,OAAO;MACLC,OAAA;MACAE,QAAA,CAASE,mBAAmB,CAAC,WAAWL,QAAA;IAC1C;EACF,GAAG,CAACvB,MAAA,EAAQQ,gBAAA,EAAkBC,YAAA,CAAa;EAE3C,OAAON,cAAA;AACT","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { Transformer } from '@lexical/markdown';
|
|
1
2
|
import type { Klass, LexicalEditor, LexicalNode, LexicalNodeReplacement, TextFormatType } from 'lexical';
|
|
2
3
|
import type { ClientConfig, RichTextFieldClient } from 'payload';
|
|
3
4
|
import type React from 'react';
|
|
4
5
|
import type { JSX } from 'react';
|
|
5
6
|
import type { ClientEditorConfig } from '../lexical/config/types.js';
|
|
6
7
|
import type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js';
|
|
7
|
-
import type { Transformer } from '../packages/@lexical/markdown/index.js';
|
|
8
8
|
import type { FeatureClientSchemaMap } from '../types/index.js';
|
|
9
9
|
import type { ToolbarGroup } from './toolbars/types.js';
|
|
10
10
|
export type FeatureProviderProviderClient<UnSanitizedClientFeatureProps = undefined, ClientFeatureProps = UnSanitizedClientFeatureProps> = (props: BaseClientFeatureProps<ClientFeatureProps>) => FeatureProviderClient<ClientFeatureProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesClient.d.ts","sourceRoot":"","sources":["../../src/features/typesClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,cAAc,EACf,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,GAAG,EAAE,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,GAAG,CAAC,CAAC,CAAA;AAE9E,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAEnF,MAAM,MAAM,uBAAuB,GAAG;IACpC,uCAAuC;IACvC,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,cAAc,EAAE,cAAc,EAAE,CAAA;IAChC,oBAAoB,EAAE,WAAW,EAAE,CAAA;IAEnC;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;IAChC,SAAS,EAAE;QACT;;;;;WAKG;QACH,aAAa,EAAE,KAAK,CAClB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;YAAE,MAAM,EAAE,aAAa,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,KAAK,cAAc,EAAE,CAC9F,CAAA;QACD;;;WAGG;QACH,MAAM,EAAE,cAAc,EAAE,CAAA;KACzB,CAAA;CACF,GAAG,QAAQ,CACV,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,cAAc,GAAG,eAAe,CAAC,CAC/F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesClient.js","names":[],"sources":["../../src/features/typesClient.ts"],"sourcesContent":["import type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n TextFormatType,\n} from 'lexical'\nimport type { ClientConfig, RichTextFieldClient } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport type { ClientEditorConfig } from '../lexical/config/types.js'\nimport type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport type { Transformer } from '../packages/@lexical/markdown/index.js'\nimport type { FeatureClientSchemaMap } from '../types/index.js'\nimport type { ToolbarGroup } from './toolbars/types.js'\n\nexport type FeatureProviderProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = (props: BaseClientFeatureProps<ClientFeatureProps>) => FeatureProviderClient<ClientFeatureProps>\n\n/**\n * No dependencies => Features need to be sorted on the server first, then sent to client in right order\n */\nexport type FeatureProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: BaseClientFeatureProps<UnSanitizedClientFeatureProps>\n feature:\n | ((props: {\n config: ClientConfig\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ClientFeatureProviderMap\n field?: RichTextFieldClient\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedClientFeatureMap\n schemaPath: string\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ClientEditorConfig\n }) => ClientFeature<ClientFeatureProps>)\n | ClientFeature<ClientFeatureProps>\n}\n\nexport type PluginComponent<ClientFeatureProps = any> = React.FC<{\n clientProps: ClientFeatureProps\n}>\nexport type PluginComponentWithAnchor<ClientFeatureProps = any> = React.FC<{\n anchorElem: HTMLElement\n clientProps: ClientFeatureProps\n}>\n\n/**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\nexport type SanitizedPlugin =\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor\n desktopOnly?: boolean\n key: string\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'aboveContainer'\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'belowContainer'\n }\n\nexport type ClientFeature<ClientFeatureProps> = {\n /**\n * The text formats which are enabled by this feature.\n */\n enableFormats?: TextFormatType[]\n markdownTransformers?: (\n | ((props: {\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n allTransformers: Transformer[]\n }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'aboveContainer' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor<ClientFeatureProps>\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n Component: PluginComponent<ClientFeatureProps>\n position: 'belowContainer' // Determines at which position the Component will be added.\n }\n >\n /**\n * Client Features can register their own providers, which will be nested below the EditorConfigProvider\n */\n providers?: Array<React.FC<{ children: JSX.Element }>>\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n sanitizedClientFeatureProps?: BaseClientFeatureProps<ClientFeatureProps>\n slashMenu?: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups?: ({\n editor,\n queryString,\n }: {\n editor: LexicalEditor\n queryString: string\n }) => SlashMenuGroup[]\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups?: SlashMenuGroup[]\n }\n /**\n * An opt-in, classic fixed toolbar which stays at the top of the editor\n */\n toolbarFixed?: {\n groups: ToolbarGroup[]\n }\n /**\n * The default, floating toolbar which appears when you select text.\n */\n toolbarInline?: {\n /**\n * Array of toolbar groups / sections. Each section can contain multiple toolbar items.\n */\n groups: ToolbarGroup[]\n }\n}\n\nexport type BaseClientFeatureProps<ClientFeatureProps> = ClientFeatureProps extends undefined\n ? {\n featureKey: string\n order: number\n }\n : {\n featureKey: string\n order: number\n } & ClientFeatureProps\n\nexport type ResolvedClientFeature<ClientFeatureProps> = {\n key: string\n order: number\n} & ClientFeature<ClientFeatureProps>\n\nexport type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<any>>\n\nexport type ClientFeatureProviderMap = Map<string, FeatureProviderClient<any, any>>\n\nexport type SanitizedClientFeatures = {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n enabledFormats: TextFormatType[]\n markdownTransformers: Transformer[]\n\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<SanitizedPlugin>\n slashMenu: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups: Array<\n ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => SlashMenuGroup[]\n >\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups: SlashMenuGroup[]\n }\n} & Required<\n Pick<ResolvedClientFeature<unknown>, 'nodes' | 'providers' | 'toolbarFixed' | 'toolbarInline'>\n>\n"],"mappings":"AAuNA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"typesClient.js","names":[],"sources":["../../src/features/typesClient.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n TextFormatType,\n} from 'lexical'\nimport type { ClientConfig, RichTextFieldClient } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport type { ClientEditorConfig } from '../lexical/config/types.js'\nimport type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport type { FeatureClientSchemaMap } from '../types/index.js'\nimport type { ToolbarGroup } from './toolbars/types.js'\n\nexport type FeatureProviderProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = (props: BaseClientFeatureProps<ClientFeatureProps>) => FeatureProviderClient<ClientFeatureProps>\n\n/**\n * No dependencies => Features need to be sorted on the server first, then sent to client in right order\n */\nexport type FeatureProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: BaseClientFeatureProps<UnSanitizedClientFeatureProps>\n feature:\n | ((props: {\n config: ClientConfig\n featureClientImportMap: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ClientFeatureProviderMap\n field?: RichTextFieldClient\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedClientFeatureMap\n schemaPath: string\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ClientEditorConfig\n }) => ClientFeature<ClientFeatureProps>)\n | ClientFeature<ClientFeatureProps>\n}\n\nexport type PluginComponent<ClientFeatureProps = any> = React.FC<{\n clientProps: ClientFeatureProps\n}>\nexport type PluginComponentWithAnchor<ClientFeatureProps = any> = React.FC<{\n anchorElem: HTMLElement\n clientProps: ClientFeatureProps\n}>\n\n/**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\nexport type SanitizedPlugin =\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor\n desktopOnly?: boolean\n key: string\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'aboveContainer'\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'belowContainer'\n }\n\nexport type ClientFeature<ClientFeatureProps> = {\n /**\n * The text formats which are enabled by this feature.\n */\n enableFormats?: TextFormatType[]\n markdownTransformers?: (\n | ((props: {\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n allTransformers: Transformer[]\n }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'aboveContainer' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor<ClientFeatureProps>\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n Component: PluginComponent<ClientFeatureProps>\n position: 'belowContainer' // Determines at which position the Component will be added.\n }\n >\n /**\n * Client Features can register their own providers, which will be nested below the EditorConfigProvider\n */\n providers?: Array<React.FC<{ children: JSX.Element }>>\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n sanitizedClientFeatureProps?: BaseClientFeatureProps<ClientFeatureProps>\n slashMenu?: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups?: ({\n editor,\n queryString,\n }: {\n editor: LexicalEditor\n queryString: string\n }) => SlashMenuGroup[]\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups?: SlashMenuGroup[]\n }\n /**\n * An opt-in, classic fixed toolbar which stays at the top of the editor\n */\n toolbarFixed?: {\n groups: ToolbarGroup[]\n }\n /**\n * The default, floating toolbar which appears when you select text.\n */\n toolbarInline?: {\n /**\n * Array of toolbar groups / sections. Each section can contain multiple toolbar items.\n */\n groups: ToolbarGroup[]\n }\n}\n\nexport type BaseClientFeatureProps<ClientFeatureProps> = ClientFeatureProps extends undefined\n ? {\n featureKey: string\n order: number\n }\n : {\n featureKey: string\n order: number\n } & ClientFeatureProps\n\nexport type ResolvedClientFeature<ClientFeatureProps> = {\n key: string\n order: number\n} & ClientFeature<ClientFeatureProps>\n\nexport type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<any>>\n\nexport type ClientFeatureProviderMap = Map<string, FeatureProviderClient<any, any>>\n\nexport type SanitizedClientFeatures = {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n enabledFormats: TextFormatType[]\n markdownTransformers: Transformer[]\n\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<SanitizedPlugin>\n slashMenu: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups: Array<\n ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => SlashMenuGroup[]\n >\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups: SlashMenuGroup[]\n }\n} & Required<\n Pick<ResolvedClientFeature<unknown>, 'nodes' | 'providers' | 'toolbarFixed' | 'toolbarInline'>\n>\n"],"mappings":"AAuNA","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { Transformer } from '@lexical/markdown';
|
|
1
2
|
import type { GenericLanguages, I18nClient } from '@payloadcms/translations';
|
|
2
3
|
import type { JSONSchema4 } from 'json-schema';
|
|
3
4
|
import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
4
5
|
import type { Field, FieldSchemaMap, FieldsToJSONSchemaArgs, ImportMapGenerators, JsonObject, PayloadComponent, PayloadRequest, PopulateType, ReplaceAny, RequestContext, RichTextField, RichTextHooks, SanitizedConfig, TypedFallbackLocale, ValidateOptions, ValidationFieldError } from 'payload';
|
|
5
6
|
import type { ServerEditorConfig } from '../lexical/config/types.js';
|
|
6
|
-
import type { Transformer } from '../packages/@lexical/markdown/index.js';
|
|
7
7
|
import type { LexicalRichTextField } from '../types/index.js';
|
|
8
8
|
import type { ElementNodeSchemaFn } from '../types/jsonSchemaHelpers.js';
|
|
9
9
|
import type { BaseClientFeatureProps } from './typesClient.js';
|