Tencent / cherry-markdown

✨ A Markdown Editor
Other
3.4k stars 388 forks source link

[Feature request] Plantuml support just like mermaid #86

Open hanye9895 opened 2 years ago

hanye9895 commented 2 years ago

For most cases, mermaid should be enough, but for some people, they would like to use plantuml

What does the proposed API look like Just like mermaid:

import Cherry from 'cherry-markdown/dist/cherry-markdown.core';

const registerPlugin = async () => {
  const [{ default: CherryPlantumlPlugin }, plantuml] = await Promise.all([
    import('cherry-markdown/src/addons/cherry-code-block-plantuml-plugin'),
    import('plantuml'),
  ]);
  Cherry.usePlugin(CherryPlantumlPlugin, {
    plantuml, // pass in plantuml object
  });
};

registerPlugin().then(() => {
  //  Plug-in registration must be done before Cherry is instantiated
  const cherryInstance = new Cherry({
    id: 'markdown-container',
    value: '# welcome to cherry editor!',
  });
});
hanye9895 commented 2 years ago

seems already done

hanye9895 commented 2 years ago

But with a further look, seems it do not contain in dist folder~

sunsonliu commented 2 years ago

@jiawei686 Do you have any ideas?

hanye9895 commented 2 years ago

@jiawei686 Do you have any ideas? It seems plantuml addons were not included in dist folder

addon issue

And here is my usage of plantuml (just like mermaid)

const [
          { default: CherryMermaidPlugin },
          { default: mermaid },
          { default: CherryPlantumlPlugin },
          { default: plantuml }
        ] = await Promise.all([
          import('cherry-markdown/dist/addons/cherry-code-block-mermaid-plugin'),
          import('mermaid'),
          import('cherry-markdown/dist/addons/cherry-code-block-plantuml-plugin'),
          import('plantuml')
        ]);
        if (!window.hasPlugin) {
          Cherry.usePlugin(CherryMermaidPlugin, {
            mermaid 
          });
          Cherry.usePlugin(CherryPlantumlPlugin, {
            plantuml
          });
          window.hasPlugin = true;
        }

So, I try to include that in the dist folder~ Or, is there another usage of plantuml without import these addons?