瀏覽代碼

:art: fix https://github.com/siyuan-note/siyuan/issues/7609

Vanessa 2 年之前
父節點
當前提交
bbd1333f93
共有 6 個文件被更改,包括 16 次插入12 次删除
  1. 4 4
      app/src/ai/actions.ts
  2. 1 1
      app/src/ai/chat.ts
  3. 4 4
      app/src/layout/Tab.ts
  4. 2 2
      app/src/menus/protyle.ts
  5. 1 1
      app/src/mobile/util/MobileBackFoward.ts
  6. 4 0
      app/src/util/escape.ts

+ 4 - 4
app/src/ai/actions.ts

@@ -6,10 +6,10 @@ import {Dialog} from "../dialog";
 import {isMobile} from "../util/functions";
 
 export const AIActions = (elements: Element[], protyle: IProtyle) => {
-    const ids: string[] = []
+    const ids: string[] = [];
     elements.forEach(item => {
-        ids.push(item.getAttribute("data-node-id"))
-    })
+        ids.push(item.getAttribute("data-node-id"));
+    });
     window.siyuan.menus.menu.append(new MenuItem({
         icon: "iconSparkles",
         label: window.siyuan.languages.ai,
@@ -136,4 +136,4 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
             }
         }]
     }).element);
-}
+};

+ 1 - 1
app/src/ai/chat.ts

@@ -36,4 +36,4 @@ export const AIChat = (protyle:IProtyle) => {
             insertHTML(`${inputElement.value}${respContent}`, protyle, true);
         });
     });
-}
+};

+ 4 - 4
app/src/layout/Tab.ts

@@ -4,7 +4,7 @@ import {Model} from "./Model";
 import {Editor} from "../editor";
 import {hasClosestByTag} from "../protyle/util/hasClosest";
 import {Constants} from "../constants";
-import {escapeHtml} from "../util/escape";
+import {escapeGreat, escapeHtml} from "../util/escape";
 import {unicode2Emoji} from "../emoji";
 import {fetchPost} from "../util/fetch";
 import {showTooltip} from "../dialog/tooltip";
@@ -63,9 +63,9 @@ export class Tab {
                         id
                     }, (response) => {
                         if (!this.headElement.getAttribute("aria-label")) {
-                            showTooltip(escapeHtml(response.data), this.headElement);
+                            showTooltip(escapeGreat(response.data), this.headElement);
                         }
-                        this.headElement.setAttribute("aria-label", escapeHtml(response.data));
+                        this.headElement.setAttribute("aria-label", escapeGreat(response.data));
                     });
                 }
             });
@@ -79,7 +79,7 @@ export class Tab {
                 const tabElement = hasClosestByTag(event.target, "LI");
                 if (tabElement) {
                     event.dataTransfer.setData("text/html", tabElement.outerHTML);
-                    const modeJSON = {id:this.id};
+                    const modeJSON = {id: this.id};
                     layoutToJSON(this, modeJSON);
                     event.dataTransfer.setData(Constants.SIYUAN_DROP_TAB, JSON.stringify(modeJSON));
                     event.dataTransfer.dropEffect = "move";

+ 2 - 2
app/src/menus/protyle.ts

@@ -969,9 +969,9 @@ const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement:
                     assetElement.style.width = "";
                     assetElement.style.maxWidth = "";
                 } else {
-                    assetElement.removeAttribute("style")
+                    assetElement.removeAttribute("style");
                 }
-                imgElement.removeAttribute("style")
+                imgElement.removeAttribute("style");
             } else {
                 assetElement.style.width = label;
                 assetElement.style.maxWidth = "";

+ 1 - 1
app/src/mobile/util/MobileBackFoward.ts

@@ -111,7 +111,7 @@ export const goForward = () => {
 export const goBack = () => {
     if (window.JSAndroid) {
         if (window.siyuan.menus.menu.element.classList.contains("b3-menu--fullscreen") && !window.siyuan.menus.menu.element.classList.contains("fn__none")) {
-            window.siyuan.menus.menu.element.dispatchEvent(new CustomEvent("click", {detail: "back"}))
+            window.siyuan.menus.menu.element.dispatchEvent(new CustomEvent("click", {detail: "back"}));
             return;
         } else if (window.siyuan.backStack.length < 1) {
             window.JSAndroid.returnDesktop();

+ 4 - 0
app/src/util/escape.ts

@@ -2,6 +2,10 @@ export const escapeHtml = (html: string) => {
     return html.replace(/&/g, "&amp;").replace(/</g, "&lt;");
 };
 
+export const escapeGreat = (html: string) => {
+    return html.replace(/</g, "&lt;");
+};
+
 export const escapeAttr = (html: string) => {
     return html.replace(/"/g, "&quot;").replace(/'/g, "&apos;");
 };