Skip to content

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

Add global mouse position variable (#8793)

Yingyi / 颖逸4f812bcf0c67
diff --git a/app/src/boot/globalShortcut.ts b/app/src/boot/globalShortcut.ts
index d977a960b6..c6756a403c 100644
--- a/app/src/boot/globalShortcut.ts
+++ b/app/src/boot/globalShortcut.ts
@@ -106,6 +106,22 @@ export const globalShortcut = (app: App) => {
}
});
window.addEventListener("mousemove", (event: MouseEvent & { target: HTMLElement }) => {
+ // https://github.com/siyuan-note/siyuan/pull/8793
+ const coordinates = window.siyuan.coordinates ?? (window.siyuan.coordinates = {
+ pageX: 0,
+ pageY: 0,
+ clientX: 0,
+ clientY: 0,
+ screenX: 0,
+ screenY: 0,
+ });
+ coordinates.pageX = event.pageX;
+ coordinates.pageY = event.pageY;
+ coordinates.clientX = event.clientX;
+ coordinates.clientY = event.clientY;
+ coordinates.screenX = event.screenX;
+ coordinates.screenY = event.screenY;
+
if (window.siyuan.hideBreadcrumb) {
document.querySelectorAll(".protyle-breadcrumb__bar--hide").forEach(item => {
item.classList.remove("protyle-breadcrumb__bar--hide");
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 356aed17ba..f50be4c60b 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -280,6 +280,14 @@ interface ISiyuan {
ctrlIsPressed?: boolean,
altIsPressed?: boolean,
shiftIsPressed?: boolean,
+ coordinates?: {
+ pageX: number,
+ pageY: number,
+ clientX: number,
+ clientY: number,
+ screenX: number,
+ screenY: number,
+ },
menus?: import("../menus").Menus
languages?: {
[key: string]: any;