diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss index bc488b829..8205b902d 100644 --- a/app/src/assets/scss/protyle/_wysiwyg.scss +++ b/app/src/assets/scss/protyle/_wysiwyg.scss @@ -615,6 +615,10 @@ max-width: 25vw; } } + + .b3-tooltips::after { + max-width: var(--b3-width-protyle-wysiwyg); + } } &--animate { diff --git a/app/src/assets/template/app/index.tpl b/app/src/assets/template/app/index.tpl index a8972a3c1..e6ae93591 100644 --- a/app/src/assets/template/app/index.tpl +++ b/app/src/assets/template/app/index.tpl @@ -4,7 +4,6 @@ - diff --git a/app/src/assets/template/app/window.tpl b/app/src/assets/template/app/window.tpl index fd64eb9db..726b89ec4 100644 --- a/app/src/assets/template/app/window.tpl +++ b/app/src/assets/template/app/window.tpl @@ -7,7 +7,6 @@ -
diff --git a/app/src/assets/template/desktop/index.tpl b/app/src/assets/template/desktop/index.tpl index f295998e7..49f629c21 100644 --- a/app/src/assets/template/desktop/index.tpl +++ b/app/src/assets/template/desktop/index.tpl @@ -8,7 +8,6 @@ - diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.ts index 8655bf873..78118b414 100644 --- a/app/src/protyle/ui/initUI.ts +++ b/app/src/protyle/ui/initUI.ts @@ -296,34 +296,40 @@ export const setPadding = (protyle: IProtyle) => { padding: 0 }; } - const oldLeft = parseInt(protyle.wysiwyg.element.style.paddingLeft); + const oldLeft = parseInt(protyle.wysiwyg.element.style.paddingLeft || "0"); const padding = getPadding(protyle); - const left = padding.left; - const right = padding.right; + const paddingLeft = padding.left; + const paddingRight = padding.right; + + const protyleWidth = protyle.element.clientWidth; + const scrollbarWidth = protyle.contentElement.offsetWidth - protyle.contentElement.clientWidth; + const contentWidth = protyleWidth - scrollbarWidth; + + const wysiwygOldWidth = parseInt(protyle.wysiwyg.element.getAttribute("data-realwidth") || "0"); + const wysiwygNewWidth = contentWidth - paddingLeft - paddingRight; + + // https://github.com/siyuan-note/siyuan/issues/15021 + protyle.element.style.setProperty("--b3-width-protyle", protyleWidth + "px"); + protyle.element.style.setProperty("--b3-width-protyle-content", contentWidth + "px"); + protyle.element.style.setProperty("--b3-width-protyle-wysiwyg", wysiwygNewWidth.toString() + "px"); + protyle.wysiwyg.element.setAttribute("data-realwidth", wysiwygNewWidth.toString()); + if (protyle.options.backlinkData) { - protyle.wysiwyg.element.style.padding = `4px ${right}px 4px ${left}px`; + protyle.wysiwyg.element.style.padding = `4px ${paddingRight}px 4px ${paddingLeft}px`; } else { - protyle.wysiwyg.element.style.padding = `${padding.top}px ${right}px ${padding.bottom}px ${left}px`; + protyle.wysiwyg.element.style.padding = `${padding.top}px ${paddingRight}px ${padding.bottom}px ${paddingLeft}px`; } if (protyle.options.render.background) { - protyle.background.element.querySelector(".protyle-background__ia").setAttribute("style", `margin-left:${left}px;margin-right:${right}px`); + protyle.background.element.querySelector(".protyle-background__ia").setAttribute("style", `margin-left:${paddingLeft}px;margin-right:${paddingRight}px`); } if (protyle.options.render.title) { // pc 端 文档名 attr 过长和添加标签等按钮重合 - protyle.title.element.style.margin = `16px ${right}px 0 ${left}px`; + protyle.title.element.style.margin = `16px ${paddingRight}px 0 ${paddingLeft}px`; } - if (window.siyuan.config.editor.displayBookmarkIcon) { - const editorAttrElement = document.getElementById("editorAttr"); - if (editorAttrElement) { - editorAttrElement.innerHTML = `.protyle-wysiwyg--attr .b3-tooltips::after { max-width: ${protyle.wysiwyg.element.clientWidth - left - right}px; }`; - } - } - const oldWidth = protyle.wysiwyg.element.getAttribute("data-realwidth"); - const newWidth = protyle.wysiwyg.element.clientWidth - parseInt(protyle.wysiwyg.element.style.paddingLeft) - parseInt(protyle.wysiwyg.element.style.paddingRight); - protyle.wysiwyg.element.setAttribute("data-realwidth", newWidth.toString()); + return { - width: Math.abs(parseInt(oldWidth) - newWidth), - padding: Math.abs(oldLeft - parseInt(protyle.wysiwyg.element.style.paddingLeft)) + width: Math.abs(wysiwygOldWidth - wysiwygNewWidth), + padding: Math.abs(oldLeft - paddingLeft) }; }; diff --git a/kernel/conf/editor.go b/kernel/conf/editor.go index d07d7e840..deda1cd2e 100644 --- a/kernel/conf/editor.go +++ b/kernel/conf/editor.go @@ -27,7 +27,7 @@ type Editor struct { CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换 CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行 CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字 - DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示书签图标 + DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标 DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标 GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟 HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数