@@ -357,15 +356,35 @@ export const editor = {
},
bindEvent: () => {
const fontFamilyElement = editor.element.querySelector("#fontFamily") as HTMLSelectElement;
- if (fontFamilyElement.tagName === "SELECT") {
- let fontFamilyHTML = `
`;
+ fontFamilyElement.addEventListener("click", () => {
fetchPost("/api/system/getSysFonts", {}, (response) => {
- response.data.forEach((item: string) => {
- fontFamilyHTML += `
`;
+ const fontMenu = new Menu();
+ fontMenu.addItem({
+ iconHTML: "",
+ checked: window.siyuan.config.editor.fontFamily === "",
+ label: `
${window.siyuan.languages.default}
`,
+ click: () => {
+ fontFamilyElement.value = "";
+ }
});
- fontFamilyElement.innerHTML = fontFamilyHTML;
+ response.data.forEach((item: string) => {
+ fontMenu.addItem({
+ iconHTML: "",
+ checked: window.siyuan.config.editor.fontFamily === item,
+ label: `
${item}
`,
+ click: () => {
+ fontFamilyElement.value = item;
+ }
+ });
+ });
+ const rect = fontFamilyElement.getBoundingClientRect();
+ fontMenu.open({
+ x: rect.left,
+ y: rect.bottom
+ })
});
- }
+ })
+
editor.element.querySelector("#clearHistory").addEventListener("click", () => {
confirmDialog(window.siyuan.languages.clearHistory, window.siyuan.languages.confirmClearHistory, () => {
fetchPost("/api/history/clearWorkspaceHistory", {});