An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Restore large document scrolling performance https://github.com/siyuan-note/siyuan/issues/18849
Danielb2b2db5fbce0
diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scssindex 65060270ed..4c2b710d4f 100644--- a/app/src/assets/scss/protyle/_wysiwyg.scss+++ b/app/src/assets/scss/protyle/_wysiwyg.scss@@ -7,11 +7,6 @@user-select: auto;overflow-x: clip;- &.protyle--image-animation-paused,- .protyle--image-animation-paused & {- image-animation: paused;- }-&--empty:empty::before {color: var(--b3-empty-color);content: attr(placeholder);diff --git a/app/src/boot/globalEvent/event.ts b/app/src/boot/globalEvent/event.tsindex 0b5d696e08..ece99fee9a 100644--- a/app/src/boot/globalEvent/event.ts+++ b/app/src/boot/globalEvent/event.ts@@ -17,7 +17,6 @@ import {fetchPost} from "../../util/fetch";import {initHarmonyTextSelectionMenu} from "../../util/harmonyTextSelectionMenu";import {clearDragTipGhost, hideDragTip} from "../../protyle/util/dragTip";import {formatPainter} from "../../protyle/toolbar/FormatPainter";-import {pauseImageAnimation, resumeImageAnimation} from "../../protyle/util/imageAnimation";const KANBAN_GROUP_DRAG_TYPE = `${Constants.SIYUAN_DROP_GUTTER}NodeAttributeView${Constants.ZWSP}Group${Constants.ZWSP}`.toLowerCase();@@ -251,7 +250,6 @@ export const initWindowEvent = (app: App) => {});window.addEventListener("blur", () => {- pauseImageAnimation(document.body);window.siyuan.ctrlIsPressed = false;window.siyuan.shiftIsPressed = false;window.siyuan.altIsPressed = false;@@ -261,10 +259,6 @@ export const initWindowEvent = (app: App) => {/// #endif});- window.addEventListener("focus", () => {- resumeImageAnimation(document.body, Constants.TIMEOUT_INPUT);- });-window.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {globalClick(event);});diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.tsindex 6ac04da03a..bab20d05fc 100644--- a/app/src/layout/Wnd.ts+++ b/app/src/layout/Wnd.ts@@ -42,7 +42,6 @@ import {hideAllElements} from "../protyle/ui/hideElements";import {focusByOffset, getSelectionOffset} from "../protyle/util/selection";import {Custom} from "./dock/Custom";import type {App} from "../index";-import {pauseImageAnimation, resumeImageAnimation} from "../protyle/util/imageAnimation";import {unicode2Emoji} from "../emoji";import {closeWindow} from "../window/closeWin";import {newCenterEmptyTab, resizeTabs, setTabPosition} from "./tabUtil";@@ -541,12 +540,10 @@ export class Wnd {}}item.panelElement.classList.remove("fn__none");- resumeImageAnimation(item.panelElement, Constants.TIMEOUT_INPUT);}currentTab = item;} else {item.headElement?.classList.remove("item--focus");- pauseImageAnimation(item.panelElement);if (!item.panelElement.classList.contains("fn__none")) {// 必须现判断,否则会触发 observer.observe(this.element, {attributeFilter: ["class"]}); 导致 https://ld246.com/article/1641198819303item.panelElement.classList.add("fn__none");diff --git a/app/src/protyle/scroll/event.ts b/app/src/protyle/scroll/event.tsindex a08589246c..22fe786006 100644--- a/app/src/protyle/scroll/event.ts+++ b/app/src/protyle/scroll/event.ts@@ -4,13 +4,11 @@ import {isMobile} from "../../util/functions";import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";import {stickyRow} from "../render/av/row";import {trimAVRowsSync} from "../render/av/virtualScroll";-import {pauseImageAnimationTemporarily} from "../util/imageAnimation";let getIndexTimeout: number;const avScrollPending = new WeakSet<HTMLElement>();export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => {element.addEventListener("scroll", () => {- pauseImageAnimationTemporarily(protyle.wysiwyg.element, Constants.TIMEOUT_INPUT);const elementRect = element.getBoundingClientRect();if (!protyle.toolbar.element.classList.contains("fn__none")) {const initY = protyle.toolbar.element.getAttribute("data-inity").split(Constants.ZWSP);diff --git a/app/src/protyle/util/imageAnimation.test.ts b/app/src/protyle/util/imageAnimation.test.tsdeleted file mode 100644index e97e45406d..0000000000--- a/app/src/protyle/util/imageAnimation.test.ts+++ /dev/null@@ -1,75 +0,0 @@-import {describe, it} from "node:test";-import * as assert from "node:assert/strict";-import {- createImageAnimationController,- IMAGE_ANIMATION_PAUSED_CLASS,-} from "./imageAnimation";--const createElement = () => {- const classes = new Set<string>();- return {- element: {- classList: {- add: (name: string) => classes.add(name),- contains: (name: string) => classes.has(name),- remove: (name: string) => classes.delete(name),- },- } as unknown as HTMLElement,- hasClass: (name: string) => classes.has(name),- };-};--const createScheduler = () => {- let nextID = 0;- const callbacks = new Map<number, () => void>();- return {- clearTimer: (id: number) => callbacks.delete(id),- runAll: () => {- const pendingCallbacks = Array.from(callbacks.values());- callbacks.clear();- pendingCallbacks.forEach(callback => callback());- },- setTimer: (callback: () => void) => {- nextID++;- callbacks.set(nextID, callback);- return nextID;- },- };-};--describe("imageAnimationController", () => {- it("pauses immediately and resumes after the scheduled delay", () => {- const scheduler = createScheduler();- const controller = createImageAnimationController(scheduler.setTimer, scheduler.clearTimer);- const target = createElement();-- controller.pauseTemporarily(target.element, 256);-- assert.equal(target.hasClass(IMAGE_ANIMATION_PAUSED_CLASS), true);- scheduler.runAll();- assert.equal(target.hasClass(IMAGE_ANIMATION_PAUSED_CLASS), false);- });-- it("cancels a scheduled resume when the element pauses again", () => {- const scheduler = createScheduler();- const controller = createImageAnimationController(scheduler.setTimer, scheduler.clearTimer);- const target = createElement();-- controller.pauseTemporarily(target.element, 256);- controller.pause(target.element);- scheduler.runAll();-- assert.equal(target.hasClass(IMAGE_ANIMATION_PAUSED_CLASS), true);- });-- it("resumes immediately when no delay is requested", () => {- const scheduler = createScheduler();- const controller = createImageAnimationController(scheduler.setTimer, scheduler.clearTimer);- const target = createElement();-- controller.pause(target.element);- controller.resume(target.element, 0);-- assert.equal(target.hasClass(IMAGE_ANIMATION_PAUSED_CLASS), false);- });-});diff --git a/app/src/protyle/util/imageAnimation.ts b/app/src/protyle/util/imageAnimation.tsdeleted file mode 100644index a8b81da77c..0000000000--- a/app/src/protyle/util/imageAnimation.ts+++ /dev/null@@ -1,58 +0,0 @@-export const IMAGE_ANIMATION_PAUSED_CLASS = "protyle--image-animation-paused";--export const createImageAnimationController = <T>(- setTimer: (callback: () => void, delay: number) => T,- clearTimer: (timer: T) => void,-) => {- const resumeTimers = new WeakMap<HTMLElement, T>();-- const cancelResume = (element: HTMLElement) => {- const timer = resumeTimers.get(element);- if (typeof timer === "undefined") {- return;- }- clearTimer(timer);- resumeTimers.delete(element);- };-- const pause = (element: HTMLElement) => {- cancelResume(element);- element.classList.add(IMAGE_ANIMATION_PAUSED_CLASS);- };-- const resume = (element: HTMLElement, delay: number) => {- cancelResume(element);- if (!element.classList.contains(IMAGE_ANIMATION_PAUSED_CLASS)) {- return;- }- if (delay <= 0) {- element.classList.remove(IMAGE_ANIMATION_PAUSED_CLASS);- return;- }- const timer = setTimer(() => {- resumeTimers.delete(element);- element.classList.remove(IMAGE_ANIMATION_PAUSED_CLASS);- }, delay);- resumeTimers.set(element, timer);- };-- const pauseTemporarily = (element: HTMLElement, delay: number) => {- pause(element);- resume(element, delay);- };-- return {- pause,- pauseTemporarily,- resume,- };-};--const imageAnimationController = createImageAnimationController(- (callback, delay) => globalThis.setTimeout(callback, delay),- (timer) => globalThis.clearTimeout(timer),-);--export const pauseImageAnimation = imageAnimationController.pause;-export const pauseImageAnimationTemporarily = imageAnimationController.pauseTemporarily;-export const resumeImageAnimation = imageAnimationController.resume;