Explorar el Código

:bug: fix https://github.com/siyuan-note/siyuan/issues/5690

Vanessa hace 2 años
padre
commit
b61dfc2a7f
Se han modificado 3 ficheros con 11 adiciones y 2 borrados
  1. 1 0
      app/src/config/about.ts
  2. 1 0
      app/src/mobile/util/menu.ts
  3. 9 2
      app/src/protyle/wysiwyg/enter.ts

+ 1 - 0
app/src/config/about.ts

@@ -299,6 +299,7 @@ export const about = {
             confirmDialog("⚠️ " + window.siyuan.languages.resetRepo, window.siyuan.languages.resetRepoTip, () => {
                 fetchPost("/api/repo/resetRepo", {}, () => {
                     window.siyuan.config.repo.key = "";
+                    window.siyuan.config.sync.enabled = false;
                     importKeyElement.parentElement.classList.remove("fn__none");
                     importKeyElement.parentElement.nextElementSibling.classList.add("fn__none");
                 });

+ 1 - 0
app/src/mobile/util/menu.ts

@@ -372,6 +372,7 @@ ${accountHTML}
                         confirmDialog(window.siyuan.languages.remove, "", () => {
                             fetchPost("/api/repo/resetRepo", {}, () => {
                                 window.siyuan.config.repo.key = "";
+                                window.siyuan.config.sync.enabled = false;
                                 importKeyElement.parentElement.classList.remove("fn__none");
                                 importKeyElement.parentElement.nextElementSibling.classList.add("fn__none");
                             });

+ 9 - 2
app/src/protyle/wysiwyg/enter.ts

@@ -130,7 +130,10 @@ const listEnter = (protyle: IProtyle, blockElement: HTMLElement, range: Range) =
         removeEmptyNode(newElement);
         return true;
     }
-
+    if (range.toString() === "" && range.startContainer.nodeType === 3 && range.startContainer.textContent === Constants.ZWSP && range.startOffset === 0) {
+        // 图片后的零宽空格前回车 https://github.com/siyuan-note/siyuan/issues/5690
+        range.setStart(range.startContainer, 1);
+    }
     range.insertNode(document.createElement("wbr"));
     const listItemHTML = listItemElement.outerHTML;
     const html = listItemElement.parentElement.outerHTML;
@@ -212,7 +215,7 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
     // 代码块
     const trimStartText = editableElement.innerHTML.trimStart();
     if (trimStartText.startsWith("```") || trimStartText.startsWith("···") || trimStartText.startsWith("~~~") ||
-            trimStartText.indexOf("\n```") > -1 || trimStartText.indexOf("\n~~~") > -1 || trimStartText.indexOf("\n···") > -1) {
+        trimStartText.indexOf("\n```") > -1 || trimStartText.indexOf("\n~~~") > -1 || trimStartText.indexOf("\n···") > -1) {
         if (trimStartText.indexOf("\n") === -1 && trimStartText.replace(/·|~/g, "`").replace(/^`{3,}/g, "").indexOf("`") > -1) {
             // ```test` 不处理,正常渲染为段落块
         } else {
@@ -354,6 +357,10 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
         removeEmptyNode(newElement);
         return true;
     }
+    if (range.toString() === "" && range.startContainer.nodeType === 3 && range.startContainer.textContent === Constants.ZWSP && range.startOffset === 0) {
+        // 图片后的零宽空格前回车 https://github.com/siyuan-note/siyuan/issues/5690
+        range.setStart(range.startContainer, 1);
+    }
     range.insertNode(document.createElement("wbr"));
     const html = blockElement.outerHTML;
     if (range.toString() !== "") {