Vanessa il y a 4 ans
Parent
commit
6bc8c07f36
2 fichiers modifiés avec 15 ajouts et 9 suppressions
  1. 2 0
      CHANGELOG.md
  2. 13 9
      src/ts/ir/process.ts

+ 2 - 0
CHANGELOG.md

@@ -88,6 +88,8 @@
 
 ### v3.7.3 / 2020-12-xx
 
+* [848](https://github.com/Vanessa219/vditor/issues/848) 即时渲染模式下FireFox浏览器光标问题 `修复缺陷`
+* [847](https://github.com/Vanessa219/vditor/issues/847) 即时渲染状态下 Firefox 删除线出错 `修复缺陷`
 * [858](https://github.com/Vanessa219/vditor/issues/858) 预览模式下应禁用工具栏上传按钮 `修复缺陷`
 * [849](https://github.com/Vanessa219/vditor/issues/849) 固定工具栏模式下点击全屏打开后导航栏位置异常 `修复缺陷`
 * [855](https://github.com/Vanessa219/vditor/issues/855) 添加全屏 z-index 设置 `引入特性`

+ 13 - 9
src/ts/ir/process.ts

@@ -185,22 +185,26 @@ export const processToolbar = (vditor: IVditor, actionBtn: Element, prefix: stri
             if (range.toString() === "") {
                 html = `${prefix}<wbr>${suffix}`;
             } else {
-                html = `${prefix}${range.toString()}<wbr>${suffix}`;
+                if (commandName === "code" || commandName === "table") {
+                    html = `${prefix}${range.toString()}<wbr>${suffix}`;
+                } else {
+                    html = `${prefix}${range.toString()}${suffix}<wbr>`;
+                }
+                range.deleteContents();
             }
             if (commandName === "table" || commandName === "code") {
-                html = "\n" + html;
-                actionBtn.classList.add("vditor-menu--disabled");
-            } else {
-                actionBtn.classList.add("vditor-menu--current");
+                html = "\n" + html + "\n\n";
             }
-            document.execCommand("insertHTML", false, html);
+
+            const spanElement = document.createElement("span");
+            spanElement.innerHTML = html;
+            range.insertNode(spanElement);
+            input(vditor, range);
+
             if (commandName === "table") {
                 range.selectNodeContents(getSelection().getRangeAt(0).startContainer.parentElement);
                 setSelectionFocus(range);
             }
-            if (commandName !== "code" && commandName !== "inline-code") {
-                useHighlight = false;
-            }
         } else if (commandName === "check" || commandName === "list" || commandName === "ordered-list") {
             listToggle(vditor, range, commandName, false);
             useHighlight = false;