Browse Source

:bug: 导出预览模式点击块引转换后的脚注跳转不正确 Fix https://github.com/siyuan-note/siyuan/issues/5700

Liang Ding 2 years ago
parent
commit
02c2c529bd
1 changed files with 8 additions and 0 deletions
  1. 8 0
      app/src/protyle/preview/index.ts

+ 8 - 0
app/src/protyle/preview/index.ts

@@ -37,6 +37,14 @@ export class Preview {
         previewElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
             if (event.target.tagName === "A") {
                 const linkAddress = event.target.getAttribute("href");
+                if (linkAddress.startsWith("#")) {
+                    // 导出预览模式点击块引转换后的脚注跳转不正确 https://github.com/siyuan-note/siyuan/issues/5700
+                    // 对于超链接锚点不做任何处理
+                    event.stopPropagation();
+                    event.preventDefault();
+                    return
+                }
+
                 if (isMobile()) {
                     openByMobile(linkAddress);
                     event.stopPropagation();