Skip to content

Commit

Permalink
💄 fix #828
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Nov 25, 2020
1 parent 57f67f8 commit a40685c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
* [open issues](https://github.com/Vanessa219/vditor/issues)
* [346](https://github.com/Vanessa219/vditor/issues/346) 内容主题推荐(长期有效) `改进功能`

### v3.7.0 / 2020-11-xx

* [828](https://github.com/Vanessa219/vditor/issues/828) 为 Vditor.preview 添加 mode 设置 `修复缺陷`
* 文档修改
* 3.7.0
* `preview` 静态方法添加 `mode` 配置

### v3.6.6 / 2020-11-23

* [824](https://github.com/Vanessa219/vditor/issues/824) 流程图大小可自适应 & 居中 `引入特性`
Expand Down
9 changes: 5 additions & 4 deletions src/ts/markdown/previewRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const mergeOptions = (options?: IPreviewOptions) => {
lang: "zh_CN",
markdown: Constants.MARKDOWN_OPTIONS,
math: Constants.MATH_OPTIONS,
mode: "light",
speech: {
enable: false,
},
Expand Down Expand Up @@ -71,7 +72,7 @@ export const md2html = (mdText: string, options?: IPreviewOptions) => {
};

export const previewRender = async (previewElement: HTMLDivElement, markdown: string, options?: IPreviewOptions) => {
const mergedOptions = mergeOptions(options);
const mergedOptions: IPreviewOptions = mergeOptions(options);
let html = await md2html(markdown, mergedOptions);
if (mergedOptions.transform) {
html = mergedOptions.transform(html);
Expand All @@ -88,11 +89,11 @@ export const previewRender = async (previewElement: HTMLDivElement, markdown: st
cdn: mergedOptions.cdn,
math: mergedOptions.math,
});
mermaidRender(previewElement, mergedOptions.cdn, mergedOptions.options.theme);
mermaidRender(previewElement, mergedOptions.cdn, mergedOptions.mode);
flowchartRender(previewElement, mergedOptions.cdn);
graphvizRender(previewElement, mergedOptions.cdn);
chartRender(previewElement, mergedOptions.cdn, mergedOptions.options.theme);
mindmapRender(previewElement, mergedOptions.cdn, mergedOptions.options.theme);
chartRender(previewElement, mergedOptions.cdn, mergedOptions.mode);
mindmapRender(previewElement, mergedOptions.cdn, mergedOptions.mode);
abcRender(previewElement, mergedOptions.cdn);
mediaRender(previewElement);
if (mergedOptions.speech.enable) {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ interface IPreviewActionCustom {
}

interface IPreviewOptions {
mode: "dark" | "light";
customEmoji?: IObject;
lang?: (keyof II18n);
lazyLoadImage?: string;
Expand Down

0 comments on commit a40685c

Please sign in to comment.