You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the $convertToMarkdownString_function from @lexical/markdown, the Link and AutoLink nodes do not correctly convert.
expected output [link](https://payloadcms.com) actual output link
if the Link and AutoLink nodes from @lexical/link are subbed into the headless editor nodes, the the actual output changes to [link](undefined)
To Reproduce
run the "local API example" test in test/_community/int.spec.ts of the linked reproduction
A richtext field with lexical editor was added to the posts collection. The richtext field has a field hook to convert the lexical state to markdown and attach it to context. A collection AfterChangeHook adds the markdown value to the returned document to make the markdown value available to test against.
OR (follow the steps from the docs and then try to convert a link)
Lexical => Markdown
Export content from the Lexical editor into Markdown format using these steps:
Import your current editor state into the headless editor.
Convert and fetch the resulting markdown string.
Here's the code for it:
import{$convertToMarkdownString}from'@lexical/markdown'import{sanitizeEditorConfig}from'@payloadcms/richtext-lexical'importtype{SerializedEditorState}from"lexical"constyourSanitizedEditorConfig=sanitizeEditorConfig(yourEditorConfig)// <= your editor config hereconstyourEditorState: SerializedEditorState// <= your current editor state here// Import editor state into your headless editortry{headlessEditor.setEditorState(headlessEditor.parseEditorState(yourEditorState))// This should commit the editor state immediately}catch(e){logger.error({err: e},'ERROR parsing editor state')}// Export to markdownletmarkdown: stringheadlessEditor.getEditorState().read(()=>{markdown=$convertToMarkdownString(yourSanitizedEditorConfig?.features?.markdownTransformers)})
Link to reproduction
https://github.com/TMRRWinc/PayloadLexicalLinkConvertToMarkdownIssue
Describe the Bug
When using the $convertToMarkdownString_function from @lexical/markdown, the Link and AutoLink nodes do not correctly convert.
expected output
[link](https://payloadcms.com)
actual outputlink
if the Link and AutoLink nodes from @lexical/link are subbed into the headless editor nodes, the the actual output changes to
[link](undefined)
To Reproduce
run the "local API example" test in test/_community/int.spec.ts of the linked reproduction
A richtext field with lexical editor was added to the posts collection. The richtext field has a field hook to convert the lexical state to markdown and attach it to context. A collection AfterChangeHook adds the markdown value to the returned document to make the markdown value available to test against.
OR (follow the steps from the docs and then try to convert a link)
Lexical => Markdown
Export content from the Lexical editor into Markdown format using these steps:
Here's the code for it:
Payload Version
2.18.3
Adapters and Plugins
db-mongodb, @payload/richtext-lexical, @lexical/headless, @lexical/markdown
The text was updated successfully, but these errors were encountered: