From d25fe7287480c7b7abb24aa73e2eb7be39644755 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 15 Aug 2022 18:15:50 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5644 --- app/src/protyle/header/Background.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts index 82998ea8d..c79b1c25d 100644 --- a/app/src/protyle/header/Background.ts +++ b/app/src/protyle/header/Background.ts @@ -80,7 +80,7 @@ export class Background { } uploadFiles(protyle, event.target.files, event.target, (responseText) => { const response = JSON.parse(responseText); - const style = `background-image:url(${response.data.succMap[Object.keys(response.data.succMap)[0]]})`; + const style = `background-image:url("${response.data.succMap[Object.keys(response.data.succMap)[0]]}")`; this.ial["title-img"] = Lute.EscapeHTMLStr(style); this.render(this.ial, protyle.block.rootID); fetchPost("/api/attr/setBlockAttrs", { @@ -111,7 +111,7 @@ export class Background { iconElements[1].classList.add("fn__none"); iconElements[2].classList.add("fn__none"); if (type === "confirm") { - const style = Lute.EscapeHTMLStr(`background-image:url(${this.imgElement.getAttribute("src")});object-position:${this.imgElement.style.objectPosition}`); + const style = Lute.EscapeHTMLStr(`background-image:url("${this.imgElement.getAttribute("src")}");object-position:${this.imgElement.style.objectPosition}`); this.ial["title-img"] = style; fetchPost("/api/attr/setBlockAttrs", { id: protyle.block.rootID, @@ -334,9 +334,9 @@ export class Background { this.imgElement.classList.remove("fn__none"); // 历史数据解析:background-image: url(\"assets/沙发背景墙11-20220418171700-w6vilzt.jpeg\"); background-position: center -254px; background-size: cover; background-repeat: no-repeat; min-height: 30vh this.imgElement.setAttribute("style", Lute.UnEscapeHTMLStr(img)); - const position = this.imgElement.style.backgroundPosition || this.imgElement.style.objectPosition; - const url = this.imgElement.style.backgroundImage?.replace(/^url\(["']?/, "").replace(/["']?\)$/, ""); if (img.indexOf("url(") > -1) { + const position = this.imgElement.style.backgroundPosition || this.imgElement.style.objectPosition; + const url = this.imgElement.style.backgroundImage?.replace(/^url\(["']?/, "").replace(/["']?\)$/, ""); this.imgElement.removeAttribute("style"); this.imgElement.setAttribute("src", url); this.imgElement.style.objectPosition = position;