From 603f4df905daab4d34b80e1aae4129d6639dde83 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Thu, 30 Jul 2026 01:18:23 +0200 Subject: [PATCH] feat: paragraph style manager ui --- src/lib/components/AlignButton.svelte | 57 +-- src/lib/components/AlignIcon.svelte | 21 + src/lib/components/StyleManagerDialog.svelte | 470 +++++++++++++++++++ src/lib/components/Toolbar.svelte | 15 + src/lib/editor/extensions.ts | 4 +- src/lib/export/docx.ts | 6 +- src/lib/export/odt.ts | 12 +- src/lib/i18n/locales/de.ts | 25 + src/lib/i18n/locales/en.ts | 25 + src/lib/import/docx.ts | 3 +- src/lib/import/odt.ts | 10 +- src/lib/styles/sheet.svelte.ts | 45 +- src/lib/styles/styleSheet.ts | 114 ++++- tests/unit/style-resolve.test.ts | 42 +- 14 files changed, 773 insertions(+), 76 deletions(-) create mode 100644 src/lib/components/AlignIcon.svelte create mode 100644 src/lib/components/StyleManagerDialog.svelte diff --git a/src/lib/components/AlignButton.svelte b/src/lib/components/AlignButton.svelte index 533055d..48db38a 100644 --- a/src/lib/components/AlignButton.svelte +++ b/src/lib/components/AlignButton.svelte @@ -1,11 +1,12 @@ + + diff --git a/src/lib/components/StyleManagerDialog.svelte b/src/lib/components/StyleManagerDialog.svelte new file mode 100644 index 0000000..d735edb --- /dev/null +++ b/src/lib/components/StyleManagerDialog.svelte @@ -0,0 +1,470 @@ + + + (open = false)} + onclick={(e) => { if (e.target === dialogEl) open = false; }} + aria-label={t().styles.title} +> +
+
+

{t().styles.title}

+ +
+ +
+
    + {#each rows as { style: s, depth } (s.name)} +
  • + +
  • + {/each} +
+ +
+ +
{style.name}
+ + + + + +
+ + +
+ +
+ + + + +
+ +
+ {t().styles.alignment} +
+ {#each ALIGNMENTS as a} + + {/each} +
+
+ +
+ + + +
+
+
+ +
+ + + + {#if style.builtin} + + {:else} + + + {/if} +
+
+
+ + diff --git a/src/lib/components/Toolbar.svelte b/src/lib/components/Toolbar.svelte index f1e84e8..3de9b91 100644 --- a/src/lib/components/Toolbar.svelte +++ b/src/lib/components/Toolbar.svelte @@ -9,6 +9,7 @@ import { blockStyleName } from '../editor/extensions/paragraphStyle'; import { DEFAULT_STYLE, resolveStyle, styleOrder } from '../styles/styleSheet'; import { styleSheet } from '../styles/sheet.svelte'; + import StyleManagerDialog from './StyleManagerDialog.svelte'; import { t } from '../i18n/i18n.svelte'; import { withShortcut } from '../i18n/shortcut'; @@ -42,6 +43,7 @@ } let stylesOpen = $state(false); + let managerOpen = $state(false); // $derived re-evaluates whenever `tick` changes (i.e. on every TipTap transaction) let isHeading = $derived(tick >= 0 && !!editor?.isActive('heading')); @@ -209,6 +211,9 @@ {styleLabel(s.name)} {/each} + {/if} @@ -341,6 +346,8 @@ {/if} + +