From c250f7d7901d737ed95714a6d8ede27fb77e3f61 Mon Sep 17 00:00:00 2001 From: dev Date: Thu, 28 May 2026 02:27:42 +0200 Subject: [PATCH] fix(words): close 12 type-drift errors from F2/F3/COLOR sprints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the toggle-group structural migration `npm run check` still had 12 pre-existing errors. All from the active Words sprint (post-2026-05 F2/F3/COLOR work), not introduced by this session. Closes them to restore green check: - soma words.svelte: thread `onUploadImage` through the Provider opts (was required-undefined in WordsOpts but missing from the create() call). - eidos words-toolbar-family-menu.svelte + words.svelte: add 'insert-image' label to COMMAND_LABELS (the Record required full coverage). - eidos words.svelte: hoist the `leafItem` snippet out of to template root level. Snippets defined INSIDE a component element are passed as named props in Svelte 5; this one was meant as a local helper. Also kills the "Expression too complex" error at the Provider tag — the leafItem prop was bloating the union. - eidos words-drawer.svelte: extract 5 inline button-config arrays to typed `as const satisfies readonly { id: WordsCommandName; ... }[]` constants (FORMAT_MARKS, TEXT_ALIGN_ACTIONS, CELL_TONE_ACTIONS, CELL_VERTICAL_ACTIONS, CELL_TEXT_ALIGN_ACTIONS). The inline literals were inferring `id: string`, breaking `runCommand` and `activeMarks.includes`. Result: npm run check 16 → 0 errors. Tests 658/658 pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../components/words/words-drawer.svelte | 77 +++++++++++-------- .../words/words-toolbar-family-menu.svelte | 1 + src/uix/eidos/components/words/words.svelte | 73 ++++++++++-------- .../components/words/components/words.svelte | 4 +- 4 files changed, 91 insertions(+), 64 deletions(-) diff --git a/src/uix/eidos/components/words/words-drawer.svelte b/src/uix/eidos/components/words/words-drawer.svelte index 3db89467b..383a11d46 100644 --- a/src/uix/eidos/components/words/words-drawer.svelte +++ b/src/uix/eidos/components/words/words-drawer.svelte @@ -39,7 +39,9 @@ DrawerSnippetProps, DrawerProps, ProviderSnippetProps, - WordsDrawerMode + WordsDrawerMode, + WordsCommandName, + WordsMark } from '$soma/components/words'; import { SvelteMap } from 'svelte/reactivity'; @@ -159,6 +161,45 @@ const found = marks.find((m) => m.startsWith(`${prefix}:`)); return found ? found.slice(prefix.length + 1) : ''; } + + // Typed catalogs for drawer action buttons. `as const` narrows + // `id` to its literal type so it satisfies the canonical unions + // (WordsMark for inline marks; WordsCommandName for runCommand). + // Without this, an inline array literal infers `id: string` and + // runCommand / activeMarks.includes reject the call. + const FORMAT_MARKS = [ + { id: 'bold', label: 'B', title: 'Bold' }, + { id: 'italic', label: 'I', title: 'Italic' }, + { id: 'underline', label: 'U', title: 'Underline' }, + { id: 'strike', label: 'S', title: 'Strikethrough' }, + { id: 'code', label: '<>', title: 'Inline code' } + ] as const satisfies readonly { id: WordsMark & WordsCommandName; label: string; title: string }[]; + + const TEXT_ALIGN_ACTIONS = [ + { id: 'align-left', label: '⫷', title: 'Left' }, + { id: 'align-center', label: '☰', title: 'Center' }, + { id: 'align-right', label: '⫸', title: 'Right' }, + { id: 'align-justify', label: '☷', title: 'Justify' } + ] as const satisfies readonly { id: WordsCommandName; label: string; title: string }[]; + + const CELL_TONE_ACTIONS = [ + { id: 'table-cell-tone-default', label: 'Plain' }, + { id: 'table-cell-tone-muted', label: 'Muted' }, + { id: 'table-cell-tone-accent', label: 'Accent' } + ] as const satisfies readonly { id: WordsCommandName; label: string }[]; + + const CELL_VERTICAL_ACTIONS = [ + { id: 'table-cell-vertical-top', label: '⬆ Top' }, + { id: 'table-cell-vertical-middle', label: '◆ Mid' }, + { id: 'table-cell-vertical-bottom', label: '⬇ Bot' } + ] as const satisfies readonly { id: WordsCommandName; label: string }[]; + + const CELL_TEXT_ALIGN_ACTIONS = [ + { id: 'align-left', label: '⫷' }, + { id: 'align-center', label: '☰' }, + { id: 'align-right', label: '⫸' }, + { id: 'align-justify', label: '☷' } + ] as const satisfies readonly { id: WordsCommandName; label: string }[]; @@ -356,13 +397,7 @@ {#snippet formatPanel(s: ProviderSnippetProps)}
- {#each [ - { id: 'bold', label: 'B', title: 'Bold' }, - { id: 'italic', label: 'I', title: 'Italic' }, - { id: 'underline', label: 'U', title: 'Underline' }, - { id: 'strike', label: 'S', title: 'Strikethrough' }, - { id: 'code', label: '<>', title: 'Inline code' } - ] as mark (mark.id)} + {#each FORMAT_MARKS as mark (mark.id)}
- {#each [ - { id: 'align-left', label: '⫷', title: 'Left' }, - { id: 'align-center', label: '☰', title: 'Center' }, - { id: 'align-right', label: '⫸', title: 'Right' }, - { id: 'align-justify', label: '☷', title: 'Justify' } - ] as a (a.id)} + {#each TEXT_ALIGN_ACTIONS as a (a.id)}
- {#each [ - { id: 'table-cell-tone-default', label: 'Plain' }, - { id: 'table-cell-tone-muted', label: 'Muted' }, - { id: 'table-cell-tone-accent', label: 'Accent' } - ] as t (t.id)} + {#each CELL_TONE_ACTIONS as t (t.id)}