Skip to content

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

907 B
Raw Blame
import {isInMobileApp} from "../../protyle/util/compatibility";
import {getFrontend} from "../../util/functions";
import {appearanceConfigApi} from "./appearanceRuntime";

export const isMenuMouseScrollAvailable = () =>
    !isInMobileApp() && ["desktop", "desktop-window", "browser-desktop"].includes(getFrontend());

export const isMenuMouseScrollEnabled = () =>
    isMenuMouseScrollAvailable() && window.siyuan.config.appearance?.menuMouseScroll === true;

export const syncMenuMouseScroll = () => {
    document.querySelectorAll<HTMLInputElement>('input[id="menuMouseScroll"]').forEach(input => {
        input.checked = isMenuMouseScrollEnabled();
    });
};

export const setMenuMouseScrollEnabled = (enabled: boolean) => {
    if (!isMenuMouseScrollAvailable() || window.siyuan.config.readonly || window.siyuan.isPublish) return;
    return appearanceConfigApi.patch("menuMouseScroll", enabled);
};