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 @@ + + + {#each LINES[value] as [x1, x2], i} + + {/each} + 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} + (open = false)} aria-label={t().common.close}> + + + + + + + + + {#each rows as { style: s, depth } (s.name)} + + (selected = s.name)} + > + {s.name} + {#if isAbstractStyle(s.name)}{t().styles.abstract} + {:else if !s.builtin}{t().styles.custom}{/if} + + + {/each} + + + + + {style.name} + + {t().styles.parent} + putStyle({ ...style, parent: e.currentTarget.value || null })}> + — + {#each parentOptions as name}{name}{/each} + + + + {t().styles.font} + edit({ text: { fontFamily: e.currentTarget.value || undefined } })} + > + {inherited(resolved.text.fontFamily) || '—'} + {#each fontOptions as font} + {font} + {/each} + + + + + {t().styles.size} + edit({ text: { fontSizePt: num(e.currentTarget.value) } })} /> + + {t().styles.color} + edit({ text: { color: e.currentTarget.value.toUpperCase() } })} /> + + + + + edit({ text: { bold: e.currentTarget.checked } })} />{t().styles.bold} + edit({ text: { italic: e.currentTarget.checked } })} />{t().styles.italic} + edit({ text: { underline: e.currentTarget.checked } })} />{t().styles.underline} + edit({ text: { strike: e.currentTarget.checked } })} />{t().styles.strike} + + + + {t().styles.alignment} + + {#each ALIGNMENTS as a} + edit({ para: { textAlign: style.para.textAlign === a ? undefined : a } })} + > + + + {/each} + + + + + {t().styles.spaceBefore} + edit({ para: { spaceBefore: num(e.currentTarget.value) } })} /> + + {t().styles.spaceAfter} + edit({ para: { spaceAfter: num(e.currentTarget.value) } })} /> + + {t().styles.indent} + edit({ para: { indent: num(e.currentTarget.value) } })} /> + + + + + + + + + + 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} + { stylesOpen = false; managerOpen = true; }}> + {t().styles.manage} + {/if} @@ -341,6 +346,8 @@ {/if} + +