From 111d819f92d8bafd001437780bb6b40e549239b5 Mon Sep 17 00:00:00 2001 From: Yuri Karamian Date: Mon, 17 Aug 2026 19:55:00 +0200 Subject: [PATCH] fix: improve editor accessibility --- src/lib/components/Editor.svelte | 157 +++++++++++++++---------------- 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 7909c53..c8ccd3f 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -3697,6 +3697,27 @@ requestAnimationFrame(() => el.focus()); } + function closeFromOverlay(event: MouseEvent, close: () => void) { + if (event.target === event.currentTarget) close(); + } + + function closeOnEscape(event: KeyboardEvent, close: () => void) { + if (event.key === 'Escape') close(); + } + + function closeFormattingDropdowns() { + headingDropdown = false; + colorDropdown = false; + highlightDropdown = false; + tablePickerOpen = false; + alignDropdown = false; + insertDropdown = false; + } + + function handleFormattingBarClick(event: MouseEvent) { + if (!(event.target as Element).closest('.fmt-dropdown')) closeFormattingDropdowns(); + } + // ── In-note search functions ── let noteSearchTimer: ReturnType | null = null; @@ -6238,7 +6259,7 @@ > -
{ closeLinkContextMenu(); handleEditorClick(e); }}>
+
{ closeLinkContextMenu(); handleEditorClick(e); }} onkeydown={(e) => { if (e.key === 'Escape') closeLinkContextMenu(); }}>
{:else} {#if $sourceMode} @@ -6342,7 +6363,7 @@ {:else} -
{ closeLinkContextMenu(); handleEditorClick(e); }} oncontextmenu={handleEditorContextMenu}>
+
{ closeLinkContextMenu(); handleEditorClick(e); }} onkeydown={(e) => { if (e.key === 'Escape') closeLinkContextMenu(); }} oncontextmenu={handleEditorContextMenu}>
{/if} {/if} @@ -6358,7 +6379,7 @@ - {#if insertDropdown} - -
e.stopPropagation()}> +
{#if headingDropdown} - -
e.stopPropagation()}> +
@@ -6722,8 +6741,7 @@ {#if insertDropdown} - -
e.stopPropagation()}> +
{#if headingDropdown} - -
e.stopPropagation()}> +
@@ -6790,8 +6807,7 @@ {#if colorDropdown} - -
e.stopPropagation()}> +
{#each textColors as color} {#if tablePickerOpen} - -
e.stopPropagation()}> +
{#each Array(8) as _, r} {#each Array(10) as _, c} - -
tablePickerHover = { rows: r + 1, cols: c + 1 }} onclick={() => insertTable(r + 1, c + 1)} - >
+ > {/each} {/each}
@@ -6900,8 +6916,7 @@ {#if highlightDropdown} - -
e.stopPropagation()}> +
{#each highlightColors as color} {#if alignDropdown} - -
e.stopPropagation()}> +
@@ -7339,8 +7349,8 @@ {#if mathModal} -
-
e.stopPropagation()} role="dialog" aria-label="Math editor"> +
closeFromOverlay(e, cancelMathModal)} onkeydown={(e) => closeOnEscape(e, cancelMathModal)}> +