feat: the Paragraph and Tabs dialogs, and a picture's alt text
Word puts the deep paragraph settings behind a dialog, and so do we — it is the only place the four text-flow attrs can be set: widow/orphan control, keep with next, keep lines together, page break before. All four already round-tripped with nothing to change them. The Tabs dialog types a stop exactly where the ruler can only drag one, and is the only way to give it a leader. Alt text becomes editable rather than just inherited from the file name.
This commit is contained in:
1 parent
0d8f396c23
commit
23f234a237
9 files changed
+467
-6
No files matched your search
@@ -838,6 +838,7 @@
|
||||
{zoom}
|
||||
onZoom={setZoom}
|
||||
onDebugDump={import.meta.env.DEV ? handleDebugDump : undefined}
|
||||
bind:tabIntervalCm
|
||||
bind:pageMargins
|
||||
bind:pageOrientation
|
||||
bind:pageFormat
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
<script lang="ts">
|
||||
import type { Editor } from '@tiptap/core';
|
||||
import { uniformBlockAttr } from '../utils/selectionFormat';
|
||||
import { t } from '../i18n/i18n.svelte';
|
||||
|
||||
// Word's Paragraph dialog. Indents and spacing duplicate the ribbon's fields on
|
||||
// purpose; the second tab is the only place the text-flow attrs can be set.
|
||||
let { open = $bindable(false), editor, tick, onTabs }: {
|
||||
open?: boolean;
|
||||
editor: Editor | null;
|
||||
tick: number;
|
||||
onTabs?: () => void;
|
||||
} = $props();
|
||||
|
||||
let dialogEl = $state<HTMLDialogElement | null>(null);
|
||||
let pane = $state<'indents' | 'breaks'>('indents');
|
||||
|
||||
$effect(() => {
|
||||
const el = dialogEl;
|
||||
if (!el) return;
|
||||
if (open && !el.open) el.showModal();
|
||||
else if (!open && el.open) el.close();
|
||||
});
|
||||
|
||||
const ALIGNS = ['left', 'center', 'right', 'justify'] as const;
|
||||
|
||||
let align = $derived(tick >= 0 && editor ? (ALIGNS.find((a) => editor!.isActive({ textAlign: a })) ?? '') : '');
|
||||
let indent = $derived(read('indent', 0));
|
||||
let indentRight = $derived(read('indentRight', 0));
|
||||
let indentFirst = $derived(read('indentFirst', 0));
|
||||
let spaceBefore = $derived(read('spaceBefore', 0));
|
||||
let spaceAfter = $derived(read('spaceAfter', 0));
|
||||
let lineHeight = $derived(read('lineHeight', '1'));
|
||||
|
||||
let breakBefore = $derived(read<string | null>('breakBefore', null) === 'page');
|
||||
// widowControl is on unless a paragraph turned it off; the other two are off unless set.
|
||||
let widowControl = $derived(read<boolean | null>('widowControl', null) !== false);
|
||||
let keepNext = $derived(read<boolean | null>('keepNext', null) === true);
|
||||
let keepLines = $derived(read<boolean | null>('keepLines', null) === true);
|
||||
|
||||
function read<T>(attr: string, fallback: T): T | '' {
|
||||
if (tick < 0 || !editor) return fallback;
|
||||
return uniformBlockAttr<T>(editor.state, attr, fallback);
|
||||
}
|
||||
|
||||
// Every block in the selection takes the value, whichever node type it is.
|
||||
function setAttr(attr: string, value: unknown) {
|
||||
if (!editor) return;
|
||||
const chain = editor.chain().focus();
|
||||
for (const type of ['paragraph', 'heading']) {
|
||||
if (editor.schema.nodes[type]) chain.updateAttributes(type, { [attr]: value });
|
||||
}
|
||||
chain.run();
|
||||
}
|
||||
|
||||
function setNumber(attr: string, raw: string) {
|
||||
const v = parseFloat(raw.replace(',', '.'));
|
||||
if (!isNaN(v)) setAttr(attr, v);
|
||||
}
|
||||
|
||||
const num = (v: number | '') => (v === '' ? '' : String(Math.round((v as number) * 100) / 100));
|
||||
|
||||
const FLOW: { attr: string; on: () => boolean; label: () => string; set: (v: boolean) => void }[] = [
|
||||
{ attr: 'widowControl', on: () => widowControl, label: () => t().paragraphDialog.widowControl, set: (v) => setAttr('widowControl', v ? null : false) },
|
||||
{ attr: 'keepNext', on: () => keepNext, label: () => t().paragraphDialog.keepNext, set: (v) => setAttr('keepNext', v || null) },
|
||||
{ attr: 'keepLines', on: () => keepLines, label: () => t().paragraphDialog.keepLines, set: (v) => setAttr('keepLines', v || null) },
|
||||
{ attr: 'breakBefore', on: () => breakBefore, label: () => t().paragraphDialog.pageBreakBefore, set: (v) => setAttr('breakBefore', v ? 'page' : null) },
|
||||
];
|
||||
</script>
|
||||
|
||||
<dialog bind:this={dialogEl} onclose={() => (open = false)} onclick={(e) => e.target === dialogEl && (open = false)} aria-label={t().paragraphDialog.title}>
|
||||
<div class="body">
|
||||
<h2>{t().paragraphDialog.title}</h2>
|
||||
|
||||
<div class="tabs" role="tablist">
|
||||
<button role="tab" class:active={pane === 'indents'} aria-selected={pane === 'indents'} onclick={() => (pane = 'indents')}>{t().paragraphDialog.indentsTab}</button>
|
||||
<button role="tab" class:active={pane === 'breaks'} aria-selected={pane === 'breaks'} onclick={() => (pane = 'breaks')}>{t().paragraphDialog.breaksTab}</button>
|
||||
</div>
|
||||
|
||||
{#if pane === 'indents'}
|
||||
<label class="row">
|
||||
<span>{t().align.section}</span>
|
||||
<select value={align} onchange={(e) => editor?.chain().focus().setTextAlign((e.currentTarget as HTMLSelectElement).value as never).run()}>
|
||||
{#each ALIGNS as a}<option value={a}>{t().align[a]}</option>{/each}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<div class="grid">
|
||||
<label class="row"><span>{t().ribbon.indentLeft}</span><input type="text" inputmode="decimal" value={num(indent)} onchange={(e) => setNumber('indent', (e.currentTarget as HTMLInputElement).value)} /><em>cm</em></label>
|
||||
<label class="row"><span>{t().ribbon.indentRight}</span><input type="text" inputmode="decimal" value={num(indentRight)} onchange={(e) => setNumber('indentRight', (e.currentTarget as HTMLInputElement).value)} /><em>cm</em></label>
|
||||
<label class="row"><span>{t().ruler.firstLineIndent}</span><input type="text" inputmode="decimal" value={num(indentFirst)} onchange={(e) => setNumber('indentFirst', (e.currentTarget as HTMLInputElement).value)} /><em>cm</em></label>
|
||||
<span></span>
|
||||
<label class="row"><span>{t().ribbon.spaceBefore}</span><input type="text" inputmode="decimal" value={num(spaceBefore)} onchange={(e) => setNumber('spaceBefore', (e.currentTarget as HTMLInputElement).value)} /><em>pt</em></label>
|
||||
<label class="row"><span>{t().ribbon.spaceAfter}</span><input type="text" inputmode="decimal" value={num(spaceAfter)} onchange={(e) => setNumber('spaceAfter', (e.currentTarget as HTMLInputElement).value)} /><em>pt</em></label>
|
||||
</div>
|
||||
|
||||
<label class="row">
|
||||
<span>{t().toolbarExpanded.lineSpacing}</span>
|
||||
<select value={String(lineHeight)} onchange={(e) => editor?.chain().focus().setLineHeight((e.currentTarget as HTMLSelectElement).value).run()}>
|
||||
{#each ['1', '1.15', '1.5', '2'] as h}<option value={h}>{h === '1' ? t().toolbarExpanded.lineSingle : h === '2' ? t().toolbarExpanded.lineDouble : h}</option>{/each}
|
||||
</select>
|
||||
</label>
|
||||
{:else}
|
||||
<div class="flow">
|
||||
{#each FLOW as f}
|
||||
<label class="check">
|
||||
<input type="checkbox" checked={f.on()} onchange={(e) => f.set((e.currentTarget as HTMLInputElement).checked)} />
|
||||
<span>{f.label()}</span>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
<p class="hint">{t().paragraphDialog.flowHint}</p>
|
||||
{/if}
|
||||
|
||||
<div class="actions">
|
||||
<button class="secondary" onclick={() => { open = false; onTabs?.(); }}>{t().paragraphDialog.tabsButton}</button>
|
||||
<span class="spacer"></span>
|
||||
<button class="primary" onclick={() => (open = false)}>{t().common.close}</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
dialog {
|
||||
/* The global reset zeroes every margin, which also takes the auto centring a
|
||||
modal <dialog> gets by default. */
|
||||
margin: auto;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 420px;
|
||||
padding: 18px 20px 16px;
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
h2 { font-size: 1rem; }
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.tabs button {
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 6px 12px;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: var(--color-text-muted);
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tabs button.active { color: var(--color-text); border-bottom-color: var(--color-primary); }
|
||||
|
||||
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
|
||||
|
||||
.row { display: flex; align-items: center; gap: 8px; }
|
||||
.row > span { flex: 1; color: var(--color-text-muted); }
|
||||
.row em { font-style: normal; color: var(--color-text-muted); }
|
||||
|
||||
.row input, .row select {
|
||||
width: 72px;
|
||||
height: 26px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
padding: 0 6px;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.row select { width: 130px; }
|
||||
.row input { text-align: right; }
|
||||
|
||||
.flow { display: flex; flex-direction: column; gap: 8px; }
|
||||
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
|
||||
|
||||
.hint { color: var(--color-text-muted); font-size: 0.78rem; }
|
||||
|
||||
.actions { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
|
||||
.spacer { flex: 1; }
|
||||
|
||||
.actions button {
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
padding: 5px 14px;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.actions button:hover { background: var(--color-btn-hover); }
|
||||
|
||||
.actions .primary {
|
||||
background: var(--color-primary);
|
||||
border-color: var(--color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,170 @@
|
||||
<script lang="ts">
|
||||
import type { Editor } from '@tiptap/core';
|
||||
import { activeTabStops, LEADER_CHARS, type TabAlign, type TabStop } from '../editor/extensions/tabStops';
|
||||
import { DEFAULT_TAB_INTERVAL_CM } from '../storage/tabInterval';
|
||||
import { t } from '../i18n/i18n.svelte';
|
||||
|
||||
// Word's Tabs dialog. The ruler can already place and drag a stop; only here can
|
||||
// one be typed exactly, and only here can it be given a leader.
|
||||
let { open = $bindable(false), editor, tick, tabIntervalCm = $bindable(DEFAULT_TAB_INTERVAL_CM) }: {
|
||||
open?: boolean;
|
||||
editor: Editor | null;
|
||||
tick: number;
|
||||
tabIntervalCm?: number;
|
||||
} = $props();
|
||||
|
||||
let dialogEl = $state<HTMLDialogElement | null>(null);
|
||||
let newPos = $state('');
|
||||
let newAlign = $state<TabAlign>('left');
|
||||
let newLeader = $state<string>('');
|
||||
|
||||
$effect(() => {
|
||||
const el = dialogEl;
|
||||
if (!el) return;
|
||||
if (open && !el.open) el.showModal();
|
||||
else if (!open && el.open) el.close();
|
||||
});
|
||||
|
||||
let stops = $derived.by<TabStop[]>(() => {
|
||||
if (tick < 0 || !editor) return [];
|
||||
return activeTabStops(editor.state)?.stops ?? [];
|
||||
});
|
||||
|
||||
const ALIGNS: TabAlign[] = ['left', 'center', 'right', 'decimal'];
|
||||
|
||||
function write(next: TabStop[]) {
|
||||
editor?.chain().focus().setTabStops([...next].sort((a, b) => a.pos - b.pos)).run();
|
||||
}
|
||||
|
||||
function add() {
|
||||
const pos = parseFloat(newPos.replace(',', '.'));
|
||||
if (isNaN(pos) || pos <= 0) return;
|
||||
write([...stops.filter((s) => s.pos !== pos), { pos, align: newAlign, leader: newLeader || null }]);
|
||||
newPos = '';
|
||||
}
|
||||
|
||||
const fmt = (v: number) => (Math.round(v * 100) / 100).toString().replace('.', ',');
|
||||
</script>
|
||||
|
||||
<dialog bind:this={dialogEl} onclose={() => (open = false)} onclick={(e) => e.target === dialogEl && (open = false)} aria-label={t().tabsDialog.title}>
|
||||
<div class="body">
|
||||
<h2>{t().tabsDialog.title}</h2>
|
||||
|
||||
<div class="list" role="list">
|
||||
{#if stops.length === 0}
|
||||
<p class="empty">{t().tabsDialog.none}</p>
|
||||
{/if}
|
||||
{#each stops as s (s.pos)}
|
||||
<div class="stop" role="listitem">
|
||||
<span class="pos">{fmt(s.pos)} cm</span>
|
||||
<select value={s.align} onchange={(e) => write(stops.map((x) => (x.pos === s.pos ? { ...x, align: (e.currentTarget as HTMLSelectElement).value as TabAlign } : x)))}>
|
||||
{#each ALIGNS as a}<option value={a}>{t().ruler.tabType[a]}</option>{/each}
|
||||
</select>
|
||||
<select value={s.leader ?? ''} onchange={(e) => write(stops.map((x) => (x.pos === s.pos ? { ...x, leader: (e.currentTarget as HTMLSelectElement).value || null } : x)))}>
|
||||
<option value="">{t().tabsDialog.noLeader}</option>
|
||||
{#each LEADER_CHARS as c}<option value={c}>{c.repeat(6)}</option>{/each}
|
||||
</select>
|
||||
<button class="remove" onclick={() => write(stops.filter((x) => x.pos !== s.pos))} title={t().common.remove} aria-label={t().common.remove}>×</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<div class="stop new">
|
||||
<input type="text" inputmode="decimal" bind:value={newPos} placeholder={t().tabsDialog.position} onkeydown={(e) => e.key === 'Enter' && add()} />
|
||||
<select bind:value={newAlign}>{#each ALIGNS as a}<option value={a}>{t().ruler.tabType[a]}</option>{/each}</select>
|
||||
<select bind:value={newLeader}>
|
||||
<option value="">{t().tabsDialog.noLeader}</option>
|
||||
{#each LEADER_CHARS as c}<option value={c}>{c.repeat(6)}</option>{/each}
|
||||
</select>
|
||||
<button class="add" onclick={add}>{t().common.insert}</button>
|
||||
</div>
|
||||
|
||||
<label class="row">
|
||||
<span>{t().tabsDialog.defaultInterval}</span>
|
||||
<input
|
||||
type="text"
|
||||
inputmode="decimal"
|
||||
value={fmt(tabIntervalCm)}
|
||||
onchange={(e) => {
|
||||
const v = parseFloat((e.currentTarget as HTMLInputElement).value.replace(',', '.'));
|
||||
if (!isNaN(v) && v >= 0.05 && v <= 10) tabIntervalCm = v;
|
||||
}}
|
||||
/>
|
||||
<em>cm</em>
|
||||
</label>
|
||||
|
||||
<div class="actions">
|
||||
<span class="spacer"></span>
|
||||
<button class="primary" onclick={() => (open = false)}>{t().common.close}</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
dialog {
|
||||
/* The global reset zeroes every margin, which also takes the auto centring a
|
||||
modal <dialog> gets by default. */
|
||||
margin: auto;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 0;
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
|
||||
|
||||
.body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
width: 440px;
|
||||
padding: 18px 20px 16px;
|
||||
font-family: var(--font-sans);
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
h2 { font-size: 1rem; }
|
||||
|
||||
.list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
|
||||
.empty { color: var(--color-text-muted); }
|
||||
|
||||
.stop { display: flex; align-items: center; gap: 8px; }
|
||||
.stop .pos { width: 72px; text-align: right; }
|
||||
|
||||
.new { border-top: 1px solid var(--color-border); padding-top: 10px; }
|
||||
|
||||
.row { display: flex; align-items: center; gap: 8px; }
|
||||
.row > span { flex: 1; color: var(--color-text-muted); }
|
||||
.row em { font-style: normal; color: var(--color-text-muted); }
|
||||
|
||||
input, select, .add, .remove {
|
||||
height: 26px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--color-surface);
|
||||
color: var(--color-text);
|
||||
padding: 0 6px;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
input { width: 72px; text-align: right; }
|
||||
select { flex: 1; min-width: 0; }
|
||||
.add, .remove { cursor: pointer; }
|
||||
.remove { width: 26px; padding: 0; color: var(--color-text-muted); }
|
||||
.add:hover, .remove:hover { background: var(--color-btn-hover); }
|
||||
|
||||
.actions { display: flex; align-items: center; gap: 8px; }
|
||||
.spacer { flex: 1; }
|
||||
|
||||
.actions button {
|
||||
border: 1px solid var(--color-primary);
|
||||
border-radius: var(--radius);
|
||||
background: var(--color-primary);
|
||||
color: #fff;
|
||||
padding: 5px 14px;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
@@ -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<Orientation>('portrait'),
|
||||
pageFormat = $bindable<PageFormat>('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 @@
|
||||
|
||||
<div class="ribbon-body">
|
||||
{#if tab === 'home'}
|
||||
<HomeTab {editor} {tick} bind:showFormattingMarks {onManageStyles} {onFind} />
|
||||
<HomeTab {editor} {tick} bind:showFormattingMarks {onManageStyles} {onFind} onParagraphDialog={() => (paragraphDialogOpen = true)} />
|
||||
{:else if tab === 'insert'}
|
||||
<InsertTab {editor} {tick} {hfActive} {pageMargins} {pageOrientation} {pageFormat} {onEditZone} {onManageTableStyles} />
|
||||
{:else if tab === 'layout'}
|
||||
<LayoutTab {editor} {tick} {hfActive} bind:pageMargins bind:pageOrientation bind:pageFormat />
|
||||
<LayoutTab {editor} {tick} {hfActive} bind:pageMargins bind:pageOrientation bind:pageFormat onParagraphDialog={() => (paragraphDialogOpen = true)} />
|
||||
{:else if tab === 'references'}
|
||||
<ReferencesTab {editor} {tick} {hfActive} />
|
||||
{: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}
|
||||
</div>
|
||||
|
||||
<ParagraphDialog bind:open={paragraphDialogOpen} {editor} {tick} onTabs={() => (tabsDialogOpen = true)} />
|
||||
<TabsDialog bind:open={tabsDialogOpen} {editor} {tick} bind:tabIntervalCm />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
|
||||
// Word's Picture Format and Shape Format: the same wrap modes, plus a shape's
|
||||
// own fill, outline and kind.
|
||||
let { editor, which, wrap, shapeKind, fillColor, strokeColor, strokeWidthPt }: {
|
||||
let { editor, which, wrap, alt = '', shapeKind, fillColor, strokeColor, strokeWidthPt }: {
|
||||
editor: Editor | null;
|
||||
which: 'picture' | 'shape';
|
||||
wrap: WrapMode;
|
||||
alt?: string;
|
||||
shapeKind?: ShapeKind;
|
||||
fillColor?: string | null;
|
||||
strokeColor?: string | null;
|
||||
@@ -44,6 +45,24 @@
|
||||
{/each}
|
||||
</RibbonGroup>
|
||||
|
||||
{#if which === 'picture'}
|
||||
<div class="ribbon-sep"></div>
|
||||
|
||||
<!-- The alt text has always ridden along in both formats, filled in from the
|
||||
file name and never editable. -->
|
||||
<RibbonGroup label={t().ribbon.groups.accessibility}>
|
||||
<label class="field alt">
|
||||
<span>{t().ribbon.altText}</span>
|
||||
<input
|
||||
type="text"
|
||||
value={alt}
|
||||
placeholder={t().ribbon.altTextHint}
|
||||
onchange={(e) => editor?.chain().focus().updateAttributes('image', { alt: (e.currentTarget as HTMLInputElement).value }).run()}
|
||||
/>
|
||||
</label>
|
||||
</RibbonGroup>
|
||||
{/if}
|
||||
|
||||
{#if which === 'shape'}
|
||||
<div class="ribbon-sep"></div>
|
||||
|
||||
@@ -143,4 +162,6 @@
|
||||
}
|
||||
|
||||
.field input:focus { outline: none; border-color: var(--w-accent); }
|
||||
|
||||
.alt input { width: 200px; text-align: left; }
|
||||
</style>
|
||||
@@ -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 @@
|
||||
|
||||
<div class="ribbon-sep"></div>
|
||||
|
||||
<RibbonGroup label={t().ribbon.groups.paragraph}>
|
||||
<RibbonGroup label={t().ribbon.groups.paragraph} onLauncher={onParagraphDialog} launcherTitle={t().paragraphDialog.title}>
|
||||
<div class="rb-rows">
|
||||
<div class="rb-row">
|
||||
<div class="rb-menu-wrap" use:clickOutside={'bullets'}>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
pageMargins = $bindable(DEFAULT_MARGINS),
|
||||
pageOrientation = $bindable<Orientation>('portrait'),
|
||||
pageFormat = $bindable<PageFormat>('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 @@
|
||||
|
||||
<!-- Absolute indent and spacing: the ruler can drag these, but only here can a
|
||||
value be typed. -->
|
||||
<RibbonGroup label={t().ribbon.groups.paragraph}>
|
||||
<RibbonGroup label={t().ribbon.groups.paragraph} onLauncher={onParagraphDialog} launcherTitle={t().paragraphDialog.title}>
|
||||
<div class="field-grid">
|
||||
<label class="field">
|
||||
<span>{t().ribbon.indentLeft}</span>
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in new issue
Block a user