Vanessa219 / vditor

♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
https://b3log.org/vditor
MIT License
8.25k stars 852 forks source link

mermaid 图表渲染自适应 #1574

Closed Sharang-heng closed 6 months ago

Sharang-heng commented 6 months ago
import { useEffect, useState } from "react";
import Vditor from "vditor";
import "vditor/dist/index.css";

const App = () => {
  const [vd, setVd] = useState<Vditor>();
  useEffect(() => {
    const vditor = new Vditor("vditor", {
      after: () => {
        vditor.setValue("`\`\`\`mermaid
gantt
title 开发项目计划
dateFormat  YYYY-MM-DD
section 平台开发
a平台     :active, a1, 2023-01-01, 1d
b平台    :after a1  , 2023-01-01, 3d
c平台    :after a1, 2023-01-04, 3d\`\`\``);        setVd(vditor);
      },
    });
    // Clear the effect
    return () => {
      vd?.destroy();
      setVd(undefined);
    };
  }, []);
  return <div id="vditor" className="vditor" />;
};

export default App; image

Vanessa219 commented 6 months ago

这个是由于宽度不够,编辑器宽一点就可以了

image
Sharang-heng commented 6 months ago

能不能做个自适应优化一下,而且这个时间轴也很奇怪

Vanessa219 commented 6 months ago

好的,下个版本改进