Ver Fonte

:rotating_light:

Vanessa há 2 anos atrás
pai
commit
17a8d4fac2

+ 3 - 0
app/src/asset/renderAssets.ts

@@ -2,6 +2,9 @@ import {Constants} from "../constants";
 import {pathPosix} from "../util/pathName";
 
 export const renderAssetsPreview = (pathString: string) => {
+    if (!pathString) {
+        return "";
+    }
     const type = pathPosix().extname(pathString).toLowerCase();
     if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
         return `<img style="max-height: 100%" src="${pathString}">`;

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

@@ -763,7 +763,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
         click() {
             protyle.toolbar.setInlineMark(protyle, "link", "remove");
         }
-    })
+    });
     window.siyuan.menus.menu.append(new MenuItem({
         label: window.siyuan.languages.turnInto,
         icon: "iconRefresh",

+ 5 - 5
app/src/protyle/toolbar/index.ts

@@ -1041,14 +1041,14 @@ export class Toolbar {
 </div>`;
             const listElement = this.subElement.querySelector(".b3-list");
             const previewElement = this.subElement.firstElementChild.lastElementChild;
-            previewTemplate(listElement.firstElementChild.getAttribute("data-value"), previewElement, protyle.block.parentID)
+            previewTemplate(listElement.firstElementChild.getAttribute("data-value"), previewElement, protyle.block.parentID);
             listElement.addEventListener("mouseover", (event) => {
                 const target = event.target as HTMLElement;
                 const hoverItemElement = hasClosestByClassName(target, "b3-list-item");
                 if (!hoverItemElement) {
                     return;
                 }
-                previewTemplate(hoverItemElement.getAttribute("data-value"), previewElement, protyle.block.parentID)
+                previewTemplate(hoverItemElement.getAttribute("data-value"), previewElement, protyle.block.parentID);
             });
             const inputElement = this.subElement.querySelector("input");
             inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
@@ -1056,11 +1056,11 @@ export class Toolbar {
                 if (event.isComposing) {
                     return;
                 }
-                const isEmpty = !this.subElement.querySelector(".b3-list-item")
+                const isEmpty = !this.subElement.querySelector(".b3-list-item");
                 if (!isEmpty) {
                     const currentElement = upDownHint(listElement, event);
                     if (currentElement) {
-                        previewTemplate(currentElement.getAttribute("data-value"), previewElement, protyle.block.parentID)
+                        previewTemplate(currentElement.getAttribute("data-value"), previewElement, protyle.block.parentID);
                     }
                 }
                 if (event.key === "Enter") {
@@ -1207,7 +1207,7 @@ export class Toolbar {
                 if (event.isComposing) {
                     return;
                 }
-                const isEmpty = !this.subElement.querySelector(".b3-list-item")
+                const isEmpty = !this.subElement.querySelector(".b3-list-item");
                 if (!isEmpty) {
                     const currentElement = upDownHint(listElement, event);
                     if (currentElement) {

+ 3 - 3
app/src/protyle/toolbar/util.ts

@@ -2,7 +2,7 @@ import {fetchPost} from "../../util/fetch";
 
 export const previewTemplate = (pathString: string, element: Element, parentId: string) => {
     if (!pathString) {
-        element.innerHTML = ""
+        element.innerHTML = "";
         return;
     }
     fetchPost("/api/template/render", {
@@ -10,5 +10,5 @@ export const previewTemplate = (pathString: string, element: Element, parentId:
         path: pathString
     }, (response) => {
         element.innerHTML = `<div class="protyle-wysiwyg" style="padding: 8px">${response.data.content.replace(/contenteditable="true"/g, "")}</div>`;
-    })
-}
+    });
+};