From e9dcfe814851cdc0e19115d0b986849e2e18bf98 Mon Sep 17 00:00:00 2001 From: Joschua Becker Date: Sun, 1 Feb 2026 10:59:10 +0100 Subject: [PATCH 1/3] fix: added transmitter for ctrl + s --- src/App.tsx | 21 +++++++++++++++++++++ vite.config.ts | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 527f3d0..9666e55 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,6 @@ import { Excalidraw } from "@excalidraw/excalidraw"; import type { ExcalidrawElement } from "@excalidraw/excalidraw/element/types"; +import { useEffect, useRef } from "react"; type AppProps = { initialElements?: ExcalidrawElement[]; @@ -7,6 +8,25 @@ type AppProps = { }; function App({ initialElements = [], isReadonly = false }: AppProps) { + const elementsRef = useRef(initialElements); + + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if ((event.ctrlKey || event.metaKey) && event.key === "s") { + event.preventDefault(); + window.parent.postMessage({ + type: "not3/draw/save", + payload: elementsRef.current, + }, "*"); + } + }; + + window.addEventListener("keydown", handleKeyDown); + return () => { + window.removeEventListener("keydown", handleKeyDown); + }; + }, []); + return ( <>
@@ -31,6 +51,7 @@ function App({ initialElements = [], isReadonly = false }: AppProps) { viewModeEnabled={isReadonly} // eslint-disable-next-line @typescript-eslint/no-unused-vars onChange={(excalidrawElements, _appState, _files) => { + elementsRef.current = excalidrawElements; window.parent.postMessage({ type: "not3/draw/change", payload: excalidrawElements, diff --git a/vite.config.ts b/vite.config.ts index 1b630a0..ca8cae2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,4 +8,7 @@ export default defineConfig({ define: { "process.env.IS_PREACT": JSON.stringify("true"), }, + server: { + allowedHosts: true, + }, }) From 6bfb79b142f5990ca8e97d6574c48c18746419fe Mon Sep 17 00:00:00 2001 From: Joschua Becker Date: Sun, 1 Feb 2026 11:27:48 +0100 Subject: [PATCH 2/3] fix: missing toLowerCase for event.key Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 9666e55..3366b07 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,7 +12,7 @@ function App({ initialElements = [], isReadonly = false }: AppProps) { useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { - if ((event.ctrlKey || event.metaKey) && event.key === "s") { + if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "s") { event.preventDefault(); window.parent.postMessage({ type: "not3/draw/save", From a3cb88194bee87b42b71fa043e92876e1c4fa54a Mon Sep 17 00:00:00 2001 From: Joschua Becker Date: Sun, 1 Feb 2026 11:53:54 +0100 Subject: [PATCH 3/3] fix: sync elementsRef with useEffect Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/App.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 3366b07..369214d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -10,6 +10,10 @@ type AppProps = { function App({ initialElements = [], isReadonly = false }: AppProps) { const elementsRef = useRef(initialElements); + useEffect(() => { + elementsRef.current = initialElements; + }, [initialElements]); + useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === "s") {