Skip to content

Export image node to markdown #2212

Answered by zurfyx
erbsutil asked this question in Q&A
May 18, 2022 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

ImagePlugin (just like the toolbar) is part of the playground only, so the transformer is not exposed to NPM. We expect to make ImagePlugin as part an individual @lexical/image package in the future but only once we it's generic enough to cater most use cases and guarantee no major breaking cases in the immediate future.

For now, you may want to copy-paste this bit from the playground:

export const IMAGE: TextMatchTransformer = {
  export: (node, exportChildren, exportFormat) => {
    if (!$isImageNode(node)) {
      return null;
    }

    return `![${node.getAltText()}](${node.getSrc()})`;
  },
  importRegExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))/,
  regExp: /!(?:\[([^[]*)\])(?:\(([^(]+)\))…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@erbsutil
Comment options

Answer selected by erbsutil
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants