From ae6dd0009ba9613ec253c6672f96bf93bb655137 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 21 Aug 2026 11:12:12 +0500 Subject: [PATCH] editor: add localStorage toggle for block virtualization on mobile --- .../editor-mobile/src/components/editor.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx index ccbf5afd5..c56aadf17 100644 --- a/packages/editor-mobile/src/components/editor.tsx +++ b/packages/editor-mobile/src/components/editor.tsx @@ -51,6 +51,28 @@ import Title from "./title"; globalThis.toBlobURL = toBlobURL as typeof globalThis.toBlobURL; +const VIRTUALIZATION_KEY = "nn:virtualization"; + +function isVirtualizationEnabled(): boolean { + try { + return localStorage.getItem(VIRTUALIZATION_KEY) === "true"; + } catch (e) { + return false; + } +} + +// Dev/test toggle: flip block virtualization on/off and reload the editor so the +// new setting takes effect. Callable from the WebView console or over CDP. +(globalThis as unknown as { setVirtualization?: (on: boolean) => void }).setVirtualization = + (on: boolean) => { + try { + localStorage.setItem(VIRTUALIZATION_KEY, on ? "true" : "false"); + } catch (e) { + /* ignore */ + } + location.reload(); + }; + let didCallOnLoad = false; const Tiptap = ({ @@ -258,7 +280,8 @@ const Tiptap = ({ dateFormat: settings.dateFormat, timeFormat: settings.timeFormat as "12-hour" | "24-hour" | undefined, dayFormat: settings.dayFormat, - enableInputRules: settings.markdownShortcuts + enableInputRules: settings.markdownShortcuts, + virtualization: isVirtualizationEnabled() }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [