From d518e4de4edf0d729b54578f54a1866cb5ff389c Mon Sep 17 00:00:00 2001 From: Alexandre Vazquez Date: Tue, 1 Jul 2025 19:55:45 +0200 Subject: [PATCH] Fix editor sync on blur --- frontend/src/App.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index f91e6820..6ccb151f 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -8,7 +8,11 @@ function stripParamBlock(text) { const start = text.indexOf(PARAM_START); const end = text.indexOf(PARAM_END); if (start !== -1 && end !== -1 && end > start) { - return text.slice(0, start) + text.slice(end + PARAM_END.length); + let before = text.slice(0, start); + let after = text.slice(end + PARAM_END.length); + if (before.endsWith("\n")) before = before.slice(0, -1); + if (after.startsWith("\n")) after = after.slice(1); + return before + after; } return text; } @@ -41,6 +45,7 @@ export default function App() { const [xslt, setXslt] = useState( `\n\n\n\n`, ); + const [editorFocused, setEditorFocused] = useState(false); const [result, setResult] = useState(""); const [version, setVersion] = useState("1.0"); const [error, setError] = useState(""); @@ -205,8 +210,10 @@ export default function App() { setXslt(stripParamBlock(v || ""))} + onFocus={() => setEditorFocused(true)} + onBlur={() => setEditorFocused(false)} options={{ minimap: { enabled: false } }} />