浏览代码

:art: fix https://github.com/Vanessa219/vditor/issues/1542

Vanessa 1 年之前
父节点
当前提交
bdb025e03e
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. 1 0
      CHANGELOG.md
  2. 16 0
      src/ts/wysiwyg/highlightToolbarWYSIWYG.ts

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@
 
 ### v3.9.9 / 2024-01
 
+* [wysiwyg 模式下通过输入框修改元素属性时触发 input ](https://github.com/Vanessa219/vditor/issues/1542) `改进功能`
 * [自定义渲染器支持](https://github.com/Vanessa219/vditor/issues/1540) `引入特性`
 
 ### v3.9.8 / 2023-12-26

+ 16 - 0
src/ts/wysiwyg/highlightToolbarWYSIWYG.ts

@@ -32,6 +32,7 @@ import {
 import {afterRenderEvent} from "./afterRenderEvent";
 import {removeBlockElement} from "./processKeydown";
 import {renderToc} from "../util/toc";
+import {getMarkdown} from "../markdown/getMarkdown";
 
 export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
     clearTimeout(vditor.wysiwyg.hlToolbarTimeoutId);
@@ -280,6 +281,9 @@ export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
                         }
                     }
                 }
+                if (typeof vditor.options.input === "function") {
+                    vditor.options.input(getMarkdown(vditor));
+                }
             };
 
             const setAlign = (type: string) => {
@@ -574,6 +578,9 @@ export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
                 if (input.value.trim() !== "") {
                     footnotesRefElement.setAttribute("data-footnotes-label", input.value);
                 }
+                if (typeof vditor.options.input === "function") {
+                    vditor.options.input(getMarkdown(vditor));
+                }
             };
             input.onkeydown = (event) => {
                 if (event.isComposing) {
@@ -708,6 +715,9 @@ export const highlightToolbarWYSIWYG = (vditor: IVditor) => {
             input.value = headingElement.getAttribute("data-id") || "";
             input.oninput = () => {
                 headingElement.setAttribute("data-id", input.value);
+                if (typeof vditor.options.input === "function") {
+                    vditor.options.input(getMarkdown(vditor));
+                }
             };
             input.onkeydown = (event) => {
                 if (event.isComposing) {
@@ -802,6 +812,9 @@ export const genLinkRefPopover = (vditor: IVditor, linkRefElement: HTMLElement,
         if (input1.value.trim() !== "") {
             linkRefElement.setAttribute("data-link-label", input1.value);
         }
+        if (typeof vditor.options.input === "function") {
+            vditor.options.input(getMarkdown(vditor));
+        }
     };
 
     const inputWrap = document.createElement("span");
@@ -1055,6 +1068,9 @@ export const genImagePopover = (event: Event, vditor: IVditor) => {
         imgElement.setAttribute("src", inputElement.value);
         imgElement.setAttribute("alt", alt.value);
         imgElement.setAttribute("title", title.value);
+        if (typeof vditor.options.input === "function") {
+            vditor.options.input(getMarkdown(vditor));
+        }
     };
 
     const inputWrap = document.createElement("span");