From 2c9ba1f03d4483926ec14142c8cbfe1220e14379 Mon Sep 17 00:00:00 2001 From: Frederic Cabassut Date: Mon, 9 Mar 2026 23:37:38 +0100 Subject: [PATCH] fix: toolbar buttons now reactively show active formatting state All isActive() and getAttributes() calls in the template were not reading the tick prop, so Svelte 5 never re-evaluated them when the editor state changed. Extracted isActive() and getAttrs() helpers that consume tick to establish the reactive dependency. Co-Authored-By: Claude Opus 4.6 --- src/lib/components/FormattingToolbar.svelte | 57 +++++++++++---------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/lib/components/FormattingToolbar.svelte b/src/lib/components/FormattingToolbar.svelte index c307093..5a0e850 100644 --- a/src/lib/components/FormattingToolbar.svelte +++ b/src/lib/components/FormattingToolbar.svelte @@ -38,6 +38,9 @@ function canUndo() { void tick; return editor?.can().chain().focus().undo().run() ?? false; } function canRedo() { void tick; return editor?.can().chain().focus().redo().run() ?? false; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function isActive(nameOrAttrs: any, attrs?: Record): boolean { void tick; return editor?.isActive(nameOrAttrs, attrs) ?? false; } + function getAttrs(type: string) { void tick; return editor?.getAttributes(type) ?? {}; } let openDropdown: string | null = $state(null); let linkUrl: string = $state(''); @@ -141,7 +144,7 @@ - {#if editor?.isActive('table')} + {#if isActive('table')}