mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
8a1bf4c833
commit
5c14d38dfd
1 changed files with 30 additions and 0 deletions
|
|
@ -4,6 +4,9 @@ import {scrollEvent} from "../scroll/event";
|
||||||
import {isMobile} from "../../util/functions";
|
import {isMobile} from "../../util/functions";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
|
import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
|
||||||
|
import {isMac} from "../util/compatibility";
|
||||||
|
import {setInlineStyle} from "../../util/assets";
|
||||||
|
import {fetchPost} from "../../util/fetch";
|
||||||
|
|
||||||
export const initUI = (protyle: IProtyle) => {
|
export const initUI = (protyle: IProtyle) => {
|
||||||
protyle.contentElement = document.createElement("div");
|
protyle.contentElement = document.createElement("div");
|
||||||
|
|
@ -70,6 +73,33 @@ export const initUI = (protyle: IProtyle) => {
|
||||||
embedBlockElement.firstElementChild.classList.toggle("protyle-icons--show");
|
embedBlockElement.firstElementChild.classList.toggle("protyle-icons--show");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let wheelTimeout: number
|
||||||
|
const isMacOS = isMac()
|
||||||
|
protyle.contentElement.addEventListener("mousewheel", (event: WheelEvent) => {
|
||||||
|
if ((isMacOS && !event.metaKey) || (!isMacOS && !event.ctrlKey) || event.deltaX !== 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
if (event.deltaY < 0) {
|
||||||
|
if (window.siyuan.config.editor.fontSize < 72) {
|
||||||
|
window.siyuan.config.editor.fontSize++;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (event.deltaY > 0) {
|
||||||
|
if (window.siyuan.config.editor.fontSize > 9) {
|
||||||
|
window.siyuan.config.editor.fontSize--
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setInlineStyle();
|
||||||
|
clearTimeout(wheelTimeout);
|
||||||
|
wheelTimeout = window.setTimeout(() => {
|
||||||
|
fetchPost("/api/setting/setEditor", window.siyuan.config.editor);
|
||||||
|
}, Constants.TIMEOUT_LOAD);
|
||||||
|
}, {passive: false});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addLoading = (protyle: IProtyle) => {
|
export const addLoading = (protyle: IProtyle) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue