From 78d3bc2d826339b778af4cb91b6be78e0def64ca Mon Sep 17 00:00:00 2001 From: TC Date: Mon, 22 Jun 2026 17:17:16 +1000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20cleanup=20spacing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.ts | 6 ++++++ src/renderer/App.tsx | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/index.ts b/src/main/index.ts index 038207d..f6eaf32 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -137,6 +137,12 @@ function buildAppMenu(win: BrowserWindow): void { { type: 'separator' }, { role: 'selectAll' }, { type: 'separator' }, + { + label: 'Clean Up Spacing', + accelerator: 'CmdOrCtrl+Shift+K', + click: () => send(win, 'cleanupSpacing') + }, + { type: 'separator' }, { label: 'Find / Replace', accelerator: 'CmdOrCtrl+F', diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 9ac7290..9a63a7c 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -139,6 +139,21 @@ export default function App(): JSX.Element { } } else if (action === 'exportProjectPDF') { setExportOpen(true) + } else if (action === 'cleanupSpacing') { + const view = currentEditorView + if (!view) return + const { from, to } = view.state.selection.main + const hasSelection = from !== to + const start = hasSelection ? from : 0 + const end = hasSelection ? to : view.state.doc.length + const text = view.state.doc.sliceString(start, end) + const cleaned = text.replace(/\n\n+/g, '\n') + if (cleaned !== text) { + view.dispatch(view.state.update({ + changes: { from: start, to: end, insert: cleaned }, + userEvent: 'input' + })) + } } }