@payloadcms/richtext-lexical 4.0.0-internal.011fd46 → 4.0.0-internal.17c142b
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/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -0
- package/dist/cell/rscEntry.d.ts.map +1 -1
- package/dist/cell/rscEntry.js +5 -5
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/Field-VW7ZGT6K.js +2 -0
- package/dist/exports/client/Field-VW7ZGT6K.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-4EIYXZ6H.js +12 -0
- package/dist/exports/client/chunk-4EIYXZ6H.js.map +7 -0
- package/dist/exports/client/{chunk-CUFJGFNW.js → chunk-ESITTE3C.js} +2 -2
- package/dist/exports/client/{chunk-CUFJGFNW.js.map → chunk-ESITTE3C.js.map} +2 -2
- package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +25 -27
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/rsc.browser.d.ts +11 -0
- package/dist/exports/server/rsc.browser.d.ts.map +1 -0
- package/dist/exports/server/rsc.browser.js +10 -0
- package/dist/exports/server/rsc.browser.js.map +1 -0
- 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/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.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 +2 -1
- 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 +1 -3
- 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/field/clientEntry.d.ts +29 -0
- package/dist/field/clientEntry.d.ts.map +1 -0
- package/dist/field/clientEntry.js +86 -0
- package/dist/field/clientEntry.js.map +1 -0
- package/dist/field/index.css +9 -12
- package/dist/field/index.js +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +2 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -6
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +36 -2
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +22 -7
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +5 -1
- package/dist/lexical/config/client/loader.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-proxy/@lexical-markdown.d.ts +1 -40
- package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -1
- package/dist/lexical-proxy/@lexical-markdown.js +1 -56
- package/dist/lexical-proxy/@lexical-markdown.js.map +1 -1
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +1 -0
- package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js +160 -0
- package/dist/packages/@lexical/markdown/LexicalMarkdownHardLineBreak.spec.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts +14 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.js +220 -0
- package/dist/packages/@lexical/markdown/MarkdownExport.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts +19 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.js +199 -0
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts +11 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js +304 -0
- package/dist/packages/@lexical/markdown/MarkdownShortcuts.js.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts +173 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js +352 -0
- package/dist/packages/@lexical/markdown/MarkdownTransformers.js.map +1 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts +22 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js +91 -0
- package/dist/packages/@lexical/markdown/importTextFormatTransformer.js.map +1 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts +21 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js +54 -0
- package/dist/packages/@lexical/markdown/importTextMatchTransformer.js.map +1 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.d.ts +18 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.js +54 -0
- package/dist/packages/@lexical/markdown/importTextTransformers.js.map +1 -0
- package/dist/packages/@lexical/markdown/index.d.ts +29 -0
- package/dist/packages/@lexical/markdown/index.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/index.js +39 -0
- package/dist/packages/@lexical/markdown/index.js.map +1 -0
- package/dist/packages/@lexical/markdown/utils.d.ts +34 -0
- package/dist/packages/@lexical/markdown/utils.d.ts.map +1 -0
- package/dist/packages/@lexical/markdown/utils.js +267 -0
- package/dist/packages/@lexical/markdown/utils.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +2 -1
- package/dist/utilities/buildInitialState.d.ts.map +1 -1
- package/dist/utilities/buildInitialState.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +7 -3
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/package.json +26 -21
- package/dist/exports/client/Field-VQX3RNMF.js +0 -2
- package/dist/exports/client/Field-VQX3RNMF.js.map +0 -7
- package/dist/exports/client/chunk-X3D4LZS7.js +0 -2
- package/dist/exports/client/chunk-X3D4LZS7.js.map +0 -7
- package/dist/exports/client/componentInline-DV4EGOWU.js +0 -2
- package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts +0 -28
- package/dist/lexical/utils/markdown/normalizeMarkdown.d.ts.map +0 -1
- package/dist/lexical/utils/markdown/normalizeMarkdown.js +0 -95
- package/dist/lexical/utils/markdown/normalizeMarkdown.js.map +0 -1
- package/dist/lexical-proxy/@lexical-markdown.spec.js +0 -89
- package/dist/lexical-proxy/@lexical-markdown.spec.js.map +0 -1
- /package/dist/exports/client/{componentInline-DV4EGOWU.js.map → componentInline-H24N7GUG.js.map} +0 -0
|
@@ -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 '../../../packages/@lexical/markdown/MarkdownTransformers.js'\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 '../../packages/@lexical/markdown/MarkdownTransformers.js';
|
|
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;AAQH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAA;AACpG,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 { $createTextNode, $isTextNode } from 'lexical'\n\nimport type { TextMatchTransformer } from '../../packages/@lexical/markdown/MarkdownTransformers.js'\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;AAEA,SAASA,eAAe,QAAqB;AAK7C,SAASC,WAAW,QAAQ;AAC5B,SAASC,eAAe,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAevD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;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 '../../packages/@lexical/markdown/index.js';
|
|
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 '@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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;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 '../../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,EA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;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":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAA;AAIrG,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 { $isListNode, ListItemNode, ListNode } from '@lexical/list'\n\nimport type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js'\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":"AAAA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAIpD,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 '../../../packages/@lexical/markdown/MarkdownTransformers.js';
|
|
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":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAA;AAIrG,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 { $isListNode, ListItemNode, ListNode } from '@lexical/list'\n\nimport type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js'\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":"AAAA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAIpD,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';
|
|
3
2
|
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,WAAW,EAAE,MAAM,SAAS,CAAA;AAI1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAA;AAKrG,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 {
|
|
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\nimport type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js'\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;AAKA,SAASA,mBAAmB,EAAEC,eAAe,EAAEC,eAAe,EAAEC,WAAW,QAAQ;AAInF;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,CAACN,QAAA;MAClB;MACAP,UAAA,CAAWc,MAAM;IACnB,OAAO,IAAIlB,WAAA,CAAYO,YAAA,KAAiBA,YAAA,CAAaM,WAAW,OAAOV,QAAA,EAAU;MAC/EI,YAAA,CAAaU,MAAM,CAACN,QAAA;MACpBP,UAAA,CAAWc,MAAM;IACnB,OAAO;MACL,MAAMC,IAAA,GAAOrB,eAAA,CAAgB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I,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 '../../../packages/@lexical/markdown/MarkdownTransformers.js';
|
|
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":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAA;AAIrG,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 { $isListNode, ListItemNode, ListNode } from '@lexical/list'\n\nimport type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js'\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":"AAAA,SAASA,WAAW,EAAEC,YAAY,EAAEC,QAAQ,QAAQ;AAIpD,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,CAyFf"}
|
|
@@ -114,9 +114,7 @@ export function useToolbarStates(editor, groups) {
|
|
|
114
114
|
}, [editor]);
|
|
115
115
|
useEffect(() => {
|
|
116
116
|
void runDeprioritized(updateStates);
|
|
117
|
-
const listener = () =>
|
|
118
|
-
void runDeprioritized(updateStates);
|
|
119
|
-
};
|
|
117
|
+
const listener = () => runDeprioritized(updateStates);
|
|
120
118
|
const cleanup = mergeRegister(editor.registerUpdateListener(listener));
|
|
121
119
|
document.addEventListener('mouseup', listener);
|
|
122
120
|
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 = () =>
|
|
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,EAAE;MAClBC,WAAA,EAAa,EAAE;MACfC,YAAA,EAAc;MACdV;IACF;EACF;EA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Me,OAAA,GAAUpD,aAAA,CAAc4B,MAAA,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';
|
|
2
1
|
import type { Klass, LexicalEditor, LexicalNode, LexicalNodeReplacement, TextFormatType } from 'lexical';
|
|
3
2
|
import type { ClientConfig, RichTextFieldClient } from 'payload';
|
|
4
3
|
import type React from 'react';
|
|
5
4
|
import type { JSX } from 'react';
|
|
6
5
|
import type { ClientEditorConfig } from '../lexical/config/types.js';
|
|
7
6
|
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,
|
|
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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,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 { 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
|
+
{"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,9 +1,9 @@
|
|
|
1
|
-
import type { Transformer } from '@lexical/markdown';
|
|
2
1
|
import type { GenericLanguages, I18nClient } from '@payloadcms/translations';
|
|
3
2
|
import type { JSONSchema4 } from 'json-schema';
|
|
4
3
|
import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
5
4
|
import type { Field, FieldSchemaMap, FieldsToJSONSchemaArgs, ImportMapGenerators, JsonObject, PayloadComponent, PayloadRequest, PopulateType, ReplaceAny, RequestContext, RichTextField, RichTextHooks, SanitizedConfig, TypedFallbackLocale, ValidateOptions, ValidationFieldError } from 'payload';
|
|
6
5
|
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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACrB,MAA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BAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.js","names":[],"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type { GenericLanguages, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Field,\n FieldSchemaMap,\n FieldsToJSONSchemaArgs,\n ImportMapGenerators,\n JsonObject,\n PayloadComponent,\n PayloadRequest,\n PopulateType,\n ReplaceAny,\n RequestContext,\n RichTextField,\n RichTextHooks,\n SanitizedConfig,\n TypedFallbackLocale,\n ValidateOptions,\n ValidationFieldError,\n} from 'payload'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextField } from '../types/index.js'\nimport type { ElementNodeSchemaFn } from '../types/jsonSchemaHelpers.js'\nimport type { BaseClientFeatureProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = (args: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: LexicalRichTextField\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n parentIsLocalized: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: TypedFallbackLocale\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n populateArg?: PopulateType\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n previousNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: ValidationFieldError[]\n mergeLocaleActions: (() => Promise<void> | void)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n previousNode: T\n\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n/** Arguments passed to each node's `jsonSchema` function. */\nexport type JSONSchemaArgs = {\n elementNodeSchema: ElementNodeSchemaFn\n field: LexicalRichTextField\n /** TS name of the node union - use in `tsType` annotations. */\n nodeUnionName: string\n} & Pick<\n FieldsToJSONSchemaArgs,\n | 'collectionIDFieldTypes'\n | 'config'\n | 'i18n'\n | 'interfaceNameDefinitions'\n | 'typeStringDefinitions'\n>\n\nexport type JSONSchemaFn = (args: JSONSchemaArgs) => JSONSchema4\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate, run hooks, and generate component import maps for them\n */\n getSubFields?: (args: {\n /**\n * Optional. If not provided, all possible sub-fields should be returned.\n */\n node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req?: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * Returns the JSON Schema for this node, plus optional standalone TS\n * source for helper types its `tsType` annotations reference. Nodes\n * without this function are omitted from the strictly-typed union.\n */\n jsonSchema?: JSONSchemaFn\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n /**\n * Adds payload components to the importMap.\n *\n * If an object is provided, the imported components will automatically be made available to the client feature, keyed by the object's keys.\n */\n componentImports?:\n | {\n [key: string]: PayloadComponent\n }\n | ImportMapGenerators[0]\n | PayloadComponent[]\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18nClient\n props: ServerProps\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap | null\n hooks?: RichTextHooks\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: (\n | ((props: { allNodes: Array<NodeWithHooks>; allTransformers: Transformer[] }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks: RichTextHooks\n markdownTransformers: Transformer[]\n nodeHooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>\n"],"mappings":"AA2WA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"typesServer.js","names":[],"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { GenericLanguages, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Field,\n FieldSchemaMap,\n FieldsToJSONSchemaArgs,\n ImportMapGenerators,\n JsonObject,\n PayloadComponent,\n PayloadRequest,\n PopulateType,\n ReplaceAny,\n RequestContext,\n RichTextField,\n RichTextHooks,\n SanitizedConfig,\n TypedFallbackLocale,\n ValidateOptions,\n ValidationFieldError,\n} from 'payload'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { Transformer } from '../packages/@lexical/markdown/index.js'\nimport type { LexicalRichTextField } from '../types/index.js'\nimport type { ElementNodeSchemaFn } from '../types/jsonSchemaHelpers.js'\nimport type { BaseClientFeatureProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = (args: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: LexicalRichTextField\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n parentIsLocalized: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: TypedFallbackLocale\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n populateArg?: PopulateType\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n previousNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: ValidationFieldError[]\n mergeLocaleActions: (() => Promise<void> | void)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n previousNode: T\n\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n/** Arguments passed to each node's `jsonSchema` function. */\nexport type JSONSchemaArgs = {\n elementNodeSchema: ElementNodeSchemaFn\n field: LexicalRichTextField\n /** TS name of the node union - use in `tsType` annotations. */\n nodeUnionName: string\n} & Pick<\n FieldsToJSONSchemaArgs,\n | 'collectionIDFieldTypes'\n | 'config'\n | 'i18n'\n | 'interfaceNameDefinitions'\n | 'typeStringDefinitions'\n>\n\nexport type JSONSchemaFn = (args: JSONSchemaArgs) => JSONSchema4\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate, run hooks, and generate component import maps for them\n */\n getSubFields?: (args: {\n /**\n * Optional. If not provided, all possible sub-fields should be returned.\n */\n node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req?: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * Returns the JSON Schema for this node, plus optional standalone TS\n * source for helper types its `tsType` annotations reference. Nodes\n * without this function are omitted from the strictly-typed union.\n */\n jsonSchema?: JSONSchemaFn\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n /**\n * Adds payload components to the importMap.\n *\n * If an object is provided, the imported components will automatically be made available to the client feature, keyed by the object's keys.\n */\n componentImports?:\n | {\n [key: string]: PayloadComponent\n }\n | ImportMapGenerators[0]\n | PayloadComponent[]\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18nClient\n props: ServerProps\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap | null\n hooks?: RichTextHooks\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: (\n | ((props: { allNodes: Array<NodeWithHooks>; allTransformers: Transformer[] }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks: RichTextHooks\n markdownTransformers: Transformer[]\n nodeHooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>\n"],"mappings":"AA2WA","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ElementTransformer } from '
|
|
1
|
+
import type { ElementTransformer } from '../../../packages/@lexical/markdown/MarkdownTransformers.js';
|
|
2
2
|
export declare const UploadMarkdownTransformer: ElementTransformer;
|
|
3
3
|
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/upload/server/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAA;AAWrG,eAAO,MAAM,yBAAyB,EAAE,kBAwDvC,CAAA"}
|