Liyuan Li 5 years ago
parent
commit
6f824b95e2
3 changed files with 9 additions and 7 deletions
  1. 4 4
      CHANGELOG.md
  2. 3 3
      src/ts/preview/index.ts
  3. 2 0
      types/index.d.ts

+ 4 - 4
CHANGELOG.md

@@ -82,13 +82,11 @@
 * [346](https://github.com/Vanessa219/vditor/issues/346) 内容主题推荐(长期有效) `改进功能`
 * [721](https://github.com/Vanessa219/vditor/issues/721) 所见即所得模式加入划词评论 `引入特性`
 
-### v3.6.1 / 2020-10-xx
+### v3.6.1 / 2020-11-xx
 
+* [808](https://github.com/Vanessa219/vditor/issues/808) options.preview.actions 添加的自定义 tooltip `改进功能`
 * [802](https://github.com/Vanessa219/vditor/issues/802) 粘贴后需滚动到粘贴内容的末尾 `改进功能`
 * [806](https://github.com/Vanessa219/vditor/pull/806) 修复201不算成功的问题  `改进功能`
-
-### v3.6.0 / 2020-10-27
-
 * [786](https://github.com/Vanessa219/vditor/issues/786) 数学公式块预览开关 `引入特性`
 * [800](https://github.com/Vanessa219/vditor/issues/800) WG 模式代码块预览开关问题 `修复缺陷`
 * [801](https://github.com/Vanessa219/vditor/issues/801) 编辑器拖拽问题 `修复缺陷`
@@ -97,6 +95,8 @@
 * [784](https://github.com/Vanessa219/vditor/issues/784) 从 WPS 粘贴时标题转 Markdown 优化 `改进功能`
 * [781](https://github.com/Vanessa219/vditor/issues/781) 增加 `linkPrefix` 用于强制对链接目标地址添加前缀 `引入特性`
 * [780](https://github.com/Vanessa219/vditor/pull/780) linkToImg支持自定义format `引入特性`
+* 文档修改
+  * 3.6.1 `options.preview.actions` 添加 `tooltip` 
 
 ### v3.5.5 / 2020-10-12
 

+ 3 - 3
src/ts/preview/index.ts

@@ -44,7 +44,7 @@ export class Preview {
         for (let i = 0; i < actions.length; i++) {
             const action = actions[i];
             if (typeof action === "object") {
-                actionHtml.push(`<button type="button" data-type="${action.key}" class="${action.className}">${action.text}</button>`);
+                actionHtml.push(`<button type="button" data-type="${action.key}" class="${action.className}"${action.tooltip ? ` aria-label="${action.tooltip}"` : ""}">${action.text}</button>`);
                 continue;
             }
             switch (action) {
@@ -189,8 +189,8 @@ export class Preview {
             cdn: vditor.options.cdn,
             math: vditor.options.preview.math,
         });
-        mermaidRender(vditor.preview.element.lastElementChild as HTMLElement,  vditor.options.cdn);
-        flowchartRender(vditor.preview.element.lastElementChild as HTMLElement,  vditor.options.cdn);
+        mermaidRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);
+        flowchartRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);
         graphvizRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);
         chartRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);
         mindmapRender(vditor.preview.element.lastElementChild as HTMLElement, vditor.options.cdn);

+ 2 - 0
types/index.d.ts

@@ -402,6 +402,8 @@ interface IPreviewActionCustom {
     text: string;
     /** 按钮 className 值 */
     className?: string;
+    /** 按钮提示信息 */
+    tooltip?: string;
     /** 点击回调 */
     click: (key: string) => void;
 }