From 982dfc95c9db7842f36fba11c0e7399b3a5a1fdc Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 8 Mar 2023 20:22:05 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/7606 --- app/src/assets/scss/component/_typography.scss | 8 +++++++- app/src/menus/protyle.ts | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/assets/scss/component/_typography.scss b/app/src/assets/scss/component/_typography.scss index 6d4e4c2e7..8dc1bc305 100644 --- a/app/src/assets/scss/component/_typography.scss +++ b/app/src/assets/scss/component/_typography.scss @@ -398,11 +398,17 @@ } .img { - display: initial; // inline-block 会导致 https://ld246.com/article/1677809509055 + // inline-block 会导致 https://ld246.com/article/1677809509055 + // initial 会导致 https://ld246.com/article/1678257197581?r=88250 + display: inline-block; text-align: center; vertical-align: top; // https://ld246.com/article/1647522074722 margin: 0 auto; + &:not([style]) { + display: initial; + } + & > span:nth-child(2) { max-width: calc(100% - 10px); position: relative; diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index f0254249c..6a66e2c89 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -964,9 +964,19 @@ const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement: label, click() { nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); - assetElement.style.width = label === window.siyuan.languages.default ? "" : label; - imgElement.style.width = label === window.siyuan.languages.default ? "" : "10000px"; - assetElement.style.maxWidth = label === window.siyuan.languages.default ? (imgElement.clientWidth + 10) + "px" : ""; + if (label === window.siyuan.languages.default) { + if (assetElement.style.display === "block") { + assetElement.style.width = ""; + assetElement.style.maxWidth = ""; + } else { + assetElement.removeAttribute("style") + } + imgElement.removeAttribute("style") + } else { + assetElement.style.width = label; + assetElement.style.maxWidth = ""; + imgElement.style.width = "10000px"; + } updateTransaction(protyle, id, nodeElement.outerHTML, html); focusBlock(nodeElement); }