diff --git a/src/App.svelte b/src/App.svelte index 01751f7..6b2004c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -838,6 +838,7 @@ {zoom} onZoom={setZoom} onDebugDump={import.meta.env.DEV ? handleDebugDump : undefined} + bind:tabIntervalCm bind:pageMargins bind:pageOrientation bind:pageFormat diff --git a/src/lib/components/ParagraphDialog.svelte b/src/lib/components/ParagraphDialog.svelte new file mode 100644 index 0000000..c0699c4 --- /dev/null +++ b/src/lib/components/ParagraphDialog.svelte @@ -0,0 +1,213 @@ + + + (open = false)} onclick={(e) => e.target === dialogEl && (open = false)} aria-label={t().paragraphDialog.title}> + + {t().paragraphDialog.title} + + + (pane = 'indents')}>{t().paragraphDialog.indentsTab} + (pane = 'breaks')}>{t().paragraphDialog.breaksTab} + + + {#if pane === 'indents'} + + {t().align.section} + editor?.chain().focus().setTextAlign((e.currentTarget as HTMLSelectElement).value as never).run()}> + {#each ALIGNS as a}{t().align[a]}{/each} + + + + + {t().ribbon.indentLeft} setNumber('indent', (e.currentTarget as HTMLInputElement).value)} />cm + {t().ribbon.indentRight} setNumber('indentRight', (e.currentTarget as HTMLInputElement).value)} />cm + {t().ruler.firstLineIndent} setNumber('indentFirst', (e.currentTarget as HTMLInputElement).value)} />cm + + {t().ribbon.spaceBefore} setNumber('spaceBefore', (e.currentTarget as HTMLInputElement).value)} />pt + {t().ribbon.spaceAfter} setNumber('spaceAfter', (e.currentTarget as HTMLInputElement).value)} />pt + + + + {t().toolbarExpanded.lineSpacing} + editor?.chain().focus().setLineHeight((e.currentTarget as HTMLSelectElement).value).run()}> + {#each ['1', '1.15', '1.5', '2'] as h}{h === '1' ? t().toolbarExpanded.lineSingle : h === '2' ? t().toolbarExpanded.lineDouble : h}{/each} + + + {:else} + + {#each FLOW as f} + + f.set((e.currentTarget as HTMLInputElement).checked)} /> + {f.label()} + + {/each} + + {t().paragraphDialog.flowHint} + {/if} + + + { open = false; onTabs?.(); }}>{t().paragraphDialog.tabsButton} + + (open = false)}>{t().common.close} + + + + + diff --git a/src/lib/components/TabsDialog.svelte b/src/lib/components/TabsDialog.svelte new file mode 100644 index 0000000..30d5865 --- /dev/null +++ b/src/lib/components/TabsDialog.svelte @@ -0,0 +1,170 @@ + + + (open = false)} onclick={(e) => e.target === dialogEl && (open = false)} aria-label={t().tabsDialog.title}> + + {t().tabsDialog.title} + + + {#if stops.length === 0} + {t().tabsDialog.none} + {/if} + {#each stops as s (s.pos)} + + {fmt(s.pos)} cm + write(stops.map((x) => (x.pos === s.pos ? { ...x, align: (e.currentTarget as HTMLSelectElement).value as TabAlign } : x)))}> + {#each ALIGNS as a}{t().ruler.tabType[a]}{/each} + + write(stops.map((x) => (x.pos === s.pos ? { ...x, leader: (e.currentTarget as HTMLSelectElement).value || null } : x)))}> + {t().tabsDialog.noLeader} + {#each LEADER_CHARS as c}{c.repeat(6)}{/each} + + write(stops.filter((x) => x.pos !== s.pos))} title={t().common.remove} aria-label={t().common.remove}>× + + {/each} + + + + e.key === 'Enter' && add()} /> + {#each ALIGNS as a}{t().ruler.tabType[a]}{/each} + + {t().tabsDialog.noLeader} + {#each LEADER_CHARS as c}{c.repeat(6)}{/each} + + {t().common.insert} + + + + {t().tabsDialog.defaultInterval} + { + const v = parseFloat((e.currentTarget as HTMLInputElement).value.replace(',', '.')); + if (!isNaN(v) && v >= 0.05 && v <= 10) tabIntervalCm = v; + }} + /> + cm + + + + + (open = false)}>{t().common.close} + + + + + diff --git a/src/lib/components/ribbon/Ribbon.svelte b/src/lib/components/ribbon/Ribbon.svelte index 52e159a..186eff9 100644 --- a/src/lib/components/ribbon/Ribbon.svelte +++ b/src/lib/components/ribbon/Ribbon.svelte @@ -13,6 +13,8 @@ import TableTabs from './tabs/TableTabs.svelte'; import FrameTabs from './tabs/FrameTabs.svelte'; import UiLanguagePicker from '../UiLanguagePicker.svelte'; + import ParagraphDialog from '../ParagraphDialog.svelte'; + import TabsDialog from '../TabsDialog.svelte'; import { clickOutside, isMenuOpen, toggleMenu, closeMenu } from './menu.svelte'; import { t } from '../../i18n/i18n.svelte'; import { withShortcut } from '../../i18n/shortcut'; @@ -24,6 +26,7 @@ import type { PageFormat } from '../../storage/pageFormat'; import type { HfZone } from '../../storage/headerFooter'; import type { DocumentLanguage } from '../../storage/documentLanguage'; + import { DEFAULT_TAB_INTERVAL_CM } from '../../storage/tabInterval'; let { editor, @@ -37,6 +40,7 @@ zoom = 100, onZoom, onDebugDump, + tabIntervalCm = $bindable(DEFAULT_TAB_INTERVAL_CM), pageMargins = $bindable(DEFAULT_MARGINS), pageOrientation = $bindable('portrait'), pageFormat = $bindable('A4'), @@ -63,6 +67,7 @@ zoom?: number; onZoom?: (value: number) => void; onDebugDump?: () => void; + tabIntervalCm?: number; pageMargins?: PageMargins; pageOrientation?: Orientation; pageFormat?: PageFormat; @@ -122,6 +127,8 @@ }); let docNameSizerWidth = $state(0); + let paragraphDialogOpen = $state(false); + let tabsDialogOpen = $state(false); function run(fn?: () => void) { closeMenu(); @@ -254,11 +261,11 @@ {#if tab === 'home'} - + (paragraphDialogOpen = true)} /> {:else if tab === 'insert'} {:else if tab === 'layout'} - + (paragraphDialogOpen = true)} /> {:else if tab === 'references'} {:else if tab === 'review'} @@ -272,6 +279,7 @@ {editor} which={tab === 'pictureFormat' ? 'picture' : 'shape'} wrap={(frameAttrs?.wrap ?? 'inline') as never} + alt={(frameAttrs?.alt ?? '') as string} shapeKind={frameAttrs?.shapeKind as never} fillColor={frameAttrs?.fillColor as string | null} strokeColor={frameAttrs?.strokeColor as string | null} @@ -279,6 +287,9 @@ /> {/if} + + (tabsDialogOpen = true)} /> + diff --git a/src/lib/components/ribbon/tabs/HomeTab.svelte b/src/lib/components/ribbon/tabs/HomeTab.svelte index b7e7d90..a8692fd 100644 --- a/src/lib/components/ribbon/tabs/HomeTab.svelte +++ b/src/lib/components/ribbon/tabs/HomeTab.svelte @@ -25,12 +25,13 @@ import { withShortcut } from '../../../i18n/shortcut'; import { shortcutHint, type ShortcutId } from '../../../editor/shortcuts'; - let { editor, tick, showFormattingMarks = $bindable(false), onManageStyles, onFind }: { + let { editor, tick, showFormattingMarks = $bindable(false), onManageStyles, onFind, onParagraphDialog }: { editor: Editor | null; tick: number; showFormattingMarks?: boolean; onManageStyles?: (family: StyleFamily) => void; onFind?: (mode: 'find' | 'replace') => void; + onParagraphDialog?: () => void; } = $props(); let sheet = $derived(styleSheet()); @@ -240,7 +241,7 @@ - + diff --git a/src/lib/components/ribbon/tabs/LayoutTab.svelte b/src/lib/components/ribbon/tabs/LayoutTab.svelte index 8d0dc12..383848e 100644 --- a/src/lib/components/ribbon/tabs/LayoutTab.svelte +++ b/src/lib/components/ribbon/tabs/LayoutTab.svelte @@ -17,6 +17,7 @@ pageMargins = $bindable(DEFAULT_MARGINS), pageOrientation = $bindable('portrait'), pageFormat = $bindable('A4'), + onParagraphDialog, }: { editor: Editor | null; tick: number; @@ -24,6 +25,7 @@ pageMargins?: PageMargins; pageOrientation?: Orientation; pageFormat?: PageFormat; + onParagraphDialog?: () => void; } = $props(); const FORMATS = Object.keys(PAGE_FORMAT_CM) as PageFormat[]; @@ -195,7 +197,7 @@ - + {t().ribbon.indentLeft} diff --git a/src/lib/i18n/locales/de.ts b/src/lib/i18n/locales/de.ts index 3ca4d27..0a3f715 100644 --- a/src/lib/i18n/locales/de.ts +++ b/src/lib/i18n/locales/de.ts @@ -441,6 +441,24 @@ const de: Messages = { done: 'Fertig', doneTitle: 'Bearbeiten der Kopf-/Fußzeile beenden', }, + paragraphDialog: { + title: 'Absatz', + indentsTab: 'Einzüge und Abstände', + breaksTab: 'Zeilen- und Seitenumbruch', + widowControl: 'Absatzkontrolle', + keepNext: 'Nicht vom nächsten Absatz trennen', + keepLines: 'Zeilen nicht trennen', + pageBreakBefore: 'Seitenumbruch oberhalb', + flowHint: 'Diese Optionen bestimmen, wo der Absatz über Seiten getrennt werden darf.', + tabsButton: 'Tabstopps…', + }, + tabsDialog: { + title: 'Tabstopps', + none: 'Dieser Absatz hat keine Tabstopps', + position: 'Position', + noLeader: 'Kein Füllzeichen', + defaultInterval: 'Standardtabstopps', + }, ribbon: { tabs: { file: 'Datei', @@ -483,6 +501,7 @@ const de: Messages = { cellSize: 'Zellengröße', arrange: 'Anordnen', shapeStyles: 'Formenarten', + accessibility: 'Barrierefreiheit', editing: 'Bearbeiten', }, case: { @@ -532,6 +551,8 @@ const de: Messages = { tocMaxLevel: 'Tiefste angezeigte Ebene', debugDump: 'Dump', cellMargins: 'Zellenränder', + altText: 'Alternativtext', + altTextHint: 'Das Bild beschreiben', chrome: { title: 'Symbolleisten-Stil', ribbon: 'Menüband', diff --git a/src/lib/i18n/locales/en.ts b/src/lib/i18n/locales/en.ts index b1b233b..f1b11dd 100644 --- a/src/lib/i18n/locales/en.ts +++ b/src/lib/i18n/locales/en.ts @@ -445,6 +445,24 @@ const en = { done: 'Done', doneTitle: 'Finish editing the header/footer', }, + paragraphDialog: { + title: 'Paragraph', + indentsTab: 'Indents and spacing', + breaksTab: 'Line and page breaks', + widowControl: 'Widow/orphan control', + keepNext: 'Keep with next', + keepLines: 'Keep lines together', + pageBreakBefore: 'Page break before', + flowHint: 'These control where the paragraph may be split across pages.', + tabsButton: 'Tabs…', + }, + tabsDialog: { + title: 'Tabs', + none: 'No tab stops on this paragraph', + position: 'Position', + noLeader: 'No leader', + defaultInterval: 'Default tab stops', + }, ribbon: { tabs: { file: 'File', @@ -487,6 +505,7 @@ const en = { cellSize: 'Cell Size', arrange: 'Arrange', shapeStyles: 'Shape Styles', + accessibility: 'Accessibility', editing: 'Editing', }, case: { @@ -536,6 +555,8 @@ const en = { tocMaxLevel: 'Deepest level shown', debugDump: 'Dump', cellMargins: 'Cell margins', + altText: 'Alt text', + altTextHint: 'Describe the image', chrome: { title: 'Toolbar style', ribbon: 'Ribbon',
{t().paragraphDialog.flowHint}
{t().tabsDialog.none}