Liyuan Li 5 ani în urmă
părinte
comite
ff49ba7cbe
2 a modificat fișierele cu 7 adăugiri și 6 ștergeri
  1. 1 0
      CHANGELOG.md
  2. 6 6
      src/ts/ir/process.ts

+ 1 - 0
CHANGELOG.md

@@ -68,6 +68,7 @@
 
 ### v3.3.11 / 2020-07-xx
 
+* [616](https://github.com/Vanessa219/vditor/pull/616) fix: safari下选中文字添加标题文字会消失 `修复缺陷`
 * [615](https://github.com/Vanessa219/vditor/issues/615) 即时渲染模式下在safari中光标位置跳动 `修复缺陷`
 
 ### v3.3.10 / 2020-07-20

+ 6 - 6
src/ts/ir/process.ts

@@ -80,14 +80,14 @@ export const processHeading = (vditor: IVditor, value: string) => {
     if (headingElement) {
         if (value === "") {
             const headingMarkerElement = headingElement.querySelector(".vditor-ir__marker--heading");
-            const selection = window.getSelection();
-            selection.selectAllChildren(headingMarkerElement)
+            range.selectNodeContents(headingMarkerElement);
+            setSelectionFocus(range);
             document.execCommand("delete");
         } else {
-            const html = value + headingElement.innerText;
-            const selection = window.getSelection();
-            selection.selectAllChildren(headingElement)
-            document.execCommand("insertHTML", false, html);
+            range.selectNodeContents(headingElement);
+            range.collapse(true);
+            setSelectionFocus(range);
+            document.execCommand("insertHTML", false, value);
         }
         highlightToolbarIR(vditor);
         renderToc(vditor);