Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Prevent font toolbar label overlap and excess spacing https://github.com/siyuan-note/siyuan/issues/19226

Daniel45791d16c961
diff --git a/app/src/assets/scss/protyle/_toolbar.scss b/app/src/assets/scss/protyle/_toolbar.scss
index 0d79b87987..b5c9a5bc3e 100644
--- a/app/src/assets/scss/protyle/_toolbar.scss
+++ b/app/src/assets/scss/protyle/_toolbar.scss
@@ -64,10 +64,31 @@
}
&__font {
+ display: inline-flex;
+ align-items: center;
+ flex-shrink: 0;
+ gap: 6px;
font-size: 12px;
max-width: 96px;
- overflow: hidden;
- text-overflow: ellipsis;
+
+ &[data-type="font-family"] {
+ max-width: 120px;
+ }
+
+ &-label {
+ flex: 0 1 auto;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ text-align: left;
+ }
+
+ svg {
+ flex-shrink: 0;
+ width: 8px;
+ height: 8px;
+ }
}
}
diff --git a/app/src/protyle/toolbar/fontControls.ts b/app/src/protyle/toolbar/fontControls.ts
index e056ecdc2e..2bd71b8baa 100644
--- a/app/src/protyle/toolbar/fontControls.ts
+++ b/app/src/protyle/toolbar/fontControls.ts
@@ -100,17 +100,21 @@ export const createFontSizePicker = (protyle: IProtyle, onApply: (size: string)
};
export const updateFontControls = (protyle: IProtyle) => {
+ const setLabel = (button: HTMLButtonElement, label: string, name: string) => {
+ button.querySelector(".protyle-toolbar__font-label").textContent = label;
+ button.setAttribute("aria-label", `${window.siyuan.languages[name]} ${label}`);
+ };
const familyButton = protyle.toolbar.element.querySelector<HTMLButtonElement>('[data-type="font-family"]');
const sizeButton = protyle.toolbar.element.querySelector<HTMLButtonElement>('[data-type="font-size"]');
if (familyButton) {
const state = getInlineFontFamilyState(protyle, getFontNodeElements(protyle));
- familyButton.textContent = getInlineFontFamilyLabel(state);
+ setLabel(familyButton, getInlineFontFamilyLabel(state), "fontFamily");
familyButton.disabled = state.disabled;
}
if (sizeButton) {
const state = getFontSizeState(protyle);
- sizeButton.textContent = state.mixed ? window.siyuan.languages.mixed : state.fontSize.endsWith("em") ?
- `${Math.round(parseFloat(state.fontSize) * 100)}%` : state.fontSize;
+ setLabel(sizeButton, state.mixed ? window.siyuan.languages.mixed : state.fontSize.endsWith("em") ?
+ `${Math.round(parseFloat(state.fontSize) * 100)}%` : state.fontSize, "fontSize");
sizeButton.disabled = state.disabled;
}
};
@@ -119,7 +123,8 @@ export class FontControl extends ToolbarItem {
constructor(protyle: IProtyle, item: IMenuItem) {
super(protyle, item);
this.element.classList.add("protyle-toolbar__font");
- this.element.textContent = window.siyuan.languages[item.lang];
+ this.element.innerHTML = '<span class="protyle-toolbar__font-label"></span><svg aria-hidden="true"><use xlink:href="#iconDown"></use></svg>';
+ this.element.querySelector(".protyle-toolbar__font-label").textContent = window.siyuan.languages[item.lang];
this.element.setAttribute("aria-haspopup", "true");
this.element.addEventListener("mousedown", event => event.preventDefault());
this.element.addEventListener("click", () => {