@open-document/core 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-DJMLK50m.js → build-DfUfpeTR.js} +1 -1
- package/dist/{check-CUKuufBm.js → check-CHxiOkQG.js} +3 -3
- package/dist/cli/bin.js +20 -33
- package/dist/{config-CvzpyAUA.js → config-9IdbhVuT.js} +2015 -725
- package/dist/{context-B4ip7SoI.js → context-BLI1-64_.js} +2 -2
- package/dist/{dev-dnH7DTlD.js → dev-yNYKv5mm.js} +1 -1
- package/dist/{diff-QTo0A5Rx.js → diff-Bs205mOx.js} +2 -2
- package/dist/{export-BrRFrexj.js → export-tkquS5O5.js} +11 -4
- package/dist/{import-C14Vn9ER.js → import-D1hIKIr3.js} +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +63 -28
- package/dist/ops/index.d.ts +111 -2
- package/dist/ops/index.js +3 -3
- package/dist/{ops-DKidjLXP.js → ops-Dgqujq5a.js} +85 -164
- package/dist/package-version-C89gtYSk.js +36 -0
- package/dist/{preview-wKM4C6Uk.js → preview-BImdTH6K.js} +1 -1
- package/dist/{sdk-CpDEGRIo.d.ts → sdk-CHEGeINh.d.ts} +46 -1
- package/dist/templates-DT5zzqHq.js +34 -0
- package/dist/vite/index.js +1 -1
- package/package.json +2 -1
- package/skills/apply-comments/SKILL.md +3 -1
- package/skills/create-doc/SKILL.md +2 -0
- package/skills/doc-authoring/SKILL.md +2 -0
- package/src/app/components/browser/browser-ui.tsx +21 -0
- package/src/app/components/browser/new-document-dialog.tsx +208 -0
- package/src/app/components/changes/changes-overlay.tsx +68 -0
- package/src/app/components/changes/changes-panel.tsx +341 -0
- package/src/app/components/changes/use-changes.ts +85 -0
- package/src/app/components/comments/comments-overlay.tsx +50 -0
- package/src/app/components/comments/comments-panel.tsx +272 -0
- package/src/app/components/comments/use-comments.ts +61 -0
- package/src/app/components/doc-sidebar.tsx +32 -2
- package/src/app/components/inspector/field-source.tsx +41 -0
- package/src/app/components/inspector/format-section.tsx +434 -0
- package/src/app/components/inspector/inspector.tsx +311 -118
- package/src/app/components/inspector/use-style-edits.ts +210 -0
- package/src/app/components/overlay-frame.tsx +79 -0
- package/src/app/components/page-frame.tsx +4 -0
- package/src/app/components/page-placement.ts +68 -0
- package/src/app/components/panel/fields.tsx +95 -7
- package/src/app/components/record-picker.tsx +79 -0
- package/src/app/components/themes/theme-preview.tsx +5 -4
- package/src/app/lib/agent-bridge.ts +29 -1
- package/src/app/lib/docx/ooxml.test.ts +24 -1
- package/src/app/lib/docx/ooxml.ts +27 -1
- package/src/app/lib/export-docx.ts +3 -1
- package/src/app/lib/export-dom.ts +2 -1
- package/src/app/lib/export-html.ts +4 -2
- package/src/app/lib/export-image.ts +2 -1
- package/src/app/lib/flow-measure.test.ts +30 -0
- package/src/app/lib/flow-measure.ts +35 -10
- package/src/app/lib/i18n-ja/browser.ts +10 -0
- package/src/app/lib/i18n-ja/doc.ts +4 -0
- package/src/app/lib/i18n-ja/panels.ts +92 -5
- package/src/app/lib/i18n-ko/browser.ts +10 -0
- package/src/app/lib/i18n-ko/doc.ts +4 -0
- package/src/app/lib/i18n-ko/panels.ts +90 -5
- package/src/app/lib/i18n-zh-cn/browser.ts +10 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +4 -0
- package/src/app/lib/i18n-zh-cn/panels.ts +88 -5
- package/src/app/lib/i18n-zh-tw/browser.ts +10 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +4 -0
- package/src/app/lib/i18n-zh-tw/panels.ts +88 -5
- package/src/app/lib/inspector/format.ts +156 -0
- package/src/app/lib/records.test.ts +38 -0
- package/src/app/lib/records.ts +127 -0
- package/src/app/lib/sdk.ts +29 -0
- package/src/app/lib/use-doc-module.ts +7 -0
- package/src/app/lib/use-doc-pages.ts +15 -9
- package/src/app/routes/doc.tsx +274 -11
- package/src/app/routes/home.tsx +30 -5
- package/src/app/styles.css +23 -0
- package/templates/blank/index.tsx +63 -0
- package/templates/blank/template.json +6 -0
- package/templates/certificate/data/recipients.csv +4 -0
- package/templates/certificate/index.tsx +128 -0
- package/templates/certificate/template.json +6 -0
- package/templates/letter/index.tsx +106 -0
- package/templates/letter/template.json +5 -0
- package/templates/meeting-notes/index.tsx +194 -0
- package/templates/meeting-notes/template.json +6 -0
- package/templates/proposal/index.tsx +264 -0
- package/templates/proposal/template.json +6 -0
- package/templates/report/data/metrics.csv +5 -0
- package/templates/report/index.tsx +224 -0
- package/templates/report/template.json +6 -0
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AlignCenter,
|
|
3
|
+
AlignJustify,
|
|
4
|
+
AlignLeft,
|
|
5
|
+
AlignRight,
|
|
6
|
+
Bold,
|
|
7
|
+
CaseSensitive,
|
|
8
|
+
ChevronDown,
|
|
9
|
+
Italic,
|
|
10
|
+
Link2,
|
|
11
|
+
Lock,
|
|
12
|
+
type LucideIcon,
|
|
13
|
+
MoveHorizontal,
|
|
14
|
+
MoveVertical,
|
|
15
|
+
Type,
|
|
16
|
+
} from 'lucide-react';
|
|
17
|
+
import type { ReactNode } from 'react';
|
|
18
|
+
import { type Translate, useT } from '../../lib/i18n';
|
|
19
|
+
import {
|
|
20
|
+
isValidStyleValue,
|
|
21
|
+
PROP_TOKENS,
|
|
22
|
+
rgbToHex,
|
|
23
|
+
type StyleChanges,
|
|
24
|
+
type StyleInfo,
|
|
25
|
+
type StyleOrigin,
|
|
26
|
+
type StyleProp,
|
|
27
|
+
type StyleValue,
|
|
28
|
+
TOKENS,
|
|
29
|
+
tokenOf,
|
|
30
|
+
tokenValue,
|
|
31
|
+
} from '../../lib/inspector/format';
|
|
32
|
+
import { ColorField, NumberField, Section } from '../panel/fields';
|
|
33
|
+
|
|
34
|
+
/** What a key reads as right now: an unsaved change first, then the source, else inherited. */
|
|
35
|
+
type Current = { origin: StyleOrigin | null; pending: boolean };
|
|
36
|
+
|
|
37
|
+
function currentOf(prop: StyleProp, info: StyleInfo | null, pending: StyleChanges): Current {
|
|
38
|
+
if (prop in pending) {
|
|
39
|
+
const value = pending[prop];
|
|
40
|
+
if (value === null || value === undefined) return { origin: null, pending: true };
|
|
41
|
+
const token = typeof value === 'string' ? tokenOf(value) : null;
|
|
42
|
+
return {
|
|
43
|
+
origin: token ? { kind: 'token', token } : { kind: 'literal', value },
|
|
44
|
+
pending: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { origin: info?.props?.[prop] ?? null, pending: false };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Where a value comes from, for a tooltip: a shared style object, or code the panel only shows. */
|
|
51
|
+
function originNote(t: Translate, current: Current): string | undefined {
|
|
52
|
+
const origin = current.origin;
|
|
53
|
+
if (current.pending || !origin) return undefined;
|
|
54
|
+
const from = origin.from ? t('from {name}', { name: origin.from }) : null;
|
|
55
|
+
const code = origin.kind === 'code' ? t('set in code: {code}', { code: origin.code }) : null;
|
|
56
|
+
return [code, from].filter(Boolean).join(' · ') || undefined;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// One frame for a composite control, so a number and its token chip read as
|
|
60
|
+
// one field, as they are one value.
|
|
61
|
+
const BOX_CLASS =
|
|
62
|
+
'flex h-8 min-w-0 items-center rounded border border-border transition-colors focus-within:border-foreground/40';
|
|
63
|
+
|
|
64
|
+
const SELECT_CLASS =
|
|
65
|
+
'h-8 min-w-0 flex-1 cursor-pointer appearance-none bg-transparent pr-6 text-xs outline-none';
|
|
66
|
+
|
|
67
|
+
const SEGMENT_CLASS =
|
|
68
|
+
'flex h-8 min-w-8 flex-1 items-center justify-center rounded-[3px] text-foreground/70 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-foreground/60 aria-pressed:bg-accent aria-pressed:text-foreground';
|
|
69
|
+
|
|
70
|
+
// Named with the number, as one string: "Light" alone is already the theme's.
|
|
71
|
+
const WEIGHTS: Array<[number, string]> = [
|
|
72
|
+
[300, 'Light 300'],
|
|
73
|
+
[400, 'Regular 400'],
|
|
74
|
+
[500, 'Medium 500'],
|
|
75
|
+
[600, 'Semibold 600'],
|
|
76
|
+
[700, 'Bold 700'],
|
|
77
|
+
[800, 'Extrabold 800'],
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
const ALIGNS: Array<[string, string, LucideIcon]> = [
|
|
81
|
+
['left', 'Align left', AlignLeft],
|
|
82
|
+
['center', 'Align center', AlignCenter],
|
|
83
|
+
['right', 'Align right', AlignRight],
|
|
84
|
+
['justify', 'Justify', AlignJustify],
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
type Choice = 'inherit' | `token:${string}` | 'custom';
|
|
88
|
+
|
|
89
|
+
function choiceOf(prop: StyleProp, current: Current): Choice {
|
|
90
|
+
const origin = current.origin;
|
|
91
|
+
if (origin === null || (origin.from && !current.pending)) return 'inherit';
|
|
92
|
+
const group = PROP_TOKENS[prop];
|
|
93
|
+
if (origin.kind === 'token' && group && TOKENS[group].some((t) => t.token === origin.token)) {
|
|
94
|
+
return `token:${origin.token}`;
|
|
95
|
+
}
|
|
96
|
+
return 'custom';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The value's source as a choice — inherited, one of the document's tokens,
|
|
101
|
+
* or this element's own. The chip names it, so a field linked to the design
|
|
102
|
+
* panel says so without being opened; the native select under it does the
|
|
103
|
+
* choosing, and the keyboard and screen reader with it.
|
|
104
|
+
*/
|
|
105
|
+
function TokenChip({
|
|
106
|
+
label,
|
|
107
|
+
prop,
|
|
108
|
+
current,
|
|
109
|
+
compact = false,
|
|
110
|
+
onPick,
|
|
111
|
+
}: {
|
|
112
|
+
label: string;
|
|
113
|
+
prop: StyleProp;
|
|
114
|
+
current: Current;
|
|
115
|
+
/**
|
|
116
|
+
* Only an icon, for a field too narrow for a token name; `linked` keeps the
|
|
117
|
+
* name while a token is chosen, since that is the one worth reading.
|
|
118
|
+
*/
|
|
119
|
+
compact?: boolean | 'linked';
|
|
120
|
+
onPick: (value: 'inherit' | string) => void;
|
|
121
|
+
}) {
|
|
122
|
+
const t = useT();
|
|
123
|
+
const group = PROP_TOKENS[prop];
|
|
124
|
+
const tokens = group ? TOKENS[group] : [];
|
|
125
|
+
const choice = choiceOf(prop, current);
|
|
126
|
+
const origin = current.origin;
|
|
127
|
+
const linked = choice.startsWith('token:');
|
|
128
|
+
const inheritLabel =
|
|
129
|
+
origin?.from && !current.pending ? t('From {name}', { name: origin.from }) : t('Inherited');
|
|
130
|
+
const shown =
|
|
131
|
+
choice === 'inherit'
|
|
132
|
+
? origin?.from && !current.pending
|
|
133
|
+
? origin.from
|
|
134
|
+
: t('Inherited')
|
|
135
|
+
: choice === 'custom'
|
|
136
|
+
? origin?.kind === 'code'
|
|
137
|
+
? t('Code')
|
|
138
|
+
: t('Custom')
|
|
139
|
+
: t(tokens.find((entry) => `token:${entry.token}` === choice)?.label ?? 'Custom');
|
|
140
|
+
return (
|
|
141
|
+
<span
|
|
142
|
+
title={originNote(t, current) ?? (linked ? `--od-${choice.slice(6)}` : undefined)}
|
|
143
|
+
className={`relative mr-1 flex h-6 flex-none items-center gap-0.5 rounded px-1.5 text-[11px] transition-colors hover:bg-accent has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-foreground/60 ${
|
|
144
|
+
linked ? 'bg-accent text-accent-foreground' : 'text-muted-foreground'
|
|
145
|
+
}`}
|
|
146
|
+
>
|
|
147
|
+
{compact === true || (compact === 'linked' && !linked) ? (
|
|
148
|
+
<Link2 aria-hidden className="size-3.5" />
|
|
149
|
+
) : (
|
|
150
|
+
<span className="max-w-20 truncate">{shown}</span>
|
|
151
|
+
)}
|
|
152
|
+
<ChevronDown aria-hidden className="size-3 opacity-60" />
|
|
153
|
+
<select
|
|
154
|
+
aria-label={t('{label} token', { label })}
|
|
155
|
+
value={choice}
|
|
156
|
+
onChange={(e) => {
|
|
157
|
+
const next = e.target.value;
|
|
158
|
+
if (next === 'inherit') onPick('inherit');
|
|
159
|
+
else if (next.startsWith('token:')) onPick(tokenValue(next.slice(6)));
|
|
160
|
+
}}
|
|
161
|
+
className="absolute inset-0 cursor-pointer opacity-0"
|
|
162
|
+
>
|
|
163
|
+
<option value="inherit">{inheritLabel}</option>
|
|
164
|
+
{tokens.map((entry) => (
|
|
165
|
+
<option key={entry.token} value={`token:${entry.token}`}>
|
|
166
|
+
{t(entry.label)}
|
|
167
|
+
</option>
|
|
168
|
+
))}
|
|
169
|
+
{choice === 'custom' && <option value="custom">{t('Custom')}</option>}
|
|
170
|
+
</select>
|
|
171
|
+
</span>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function Segments({ label, children }: { label: string; children: ReactNode }) {
|
|
176
|
+
return (
|
|
177
|
+
<fieldset
|
|
178
|
+
aria-label={label}
|
|
179
|
+
className="m-0 flex h-9 min-w-0 items-center gap-0.5 rounded border border-border p-0.5"
|
|
180
|
+
>
|
|
181
|
+
{children}
|
|
182
|
+
</fieldset>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export type FormatSectionProps = {
|
|
187
|
+
anchor: HTMLElement;
|
|
188
|
+
/** `null` while the source is still being read. */
|
|
189
|
+
info: StyleInfo | null;
|
|
190
|
+
pending: StyleChanges;
|
|
191
|
+
onChange: (prop: StyleProp, value: StyleValue | undefined, shown: StyleOrigin | null) => void;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Typography and colour for the selected element, written into its `style` in
|
|
196
|
+
* source. Values are read from the rendered element, so what the fields show
|
|
197
|
+
* is what is printed; whether a value is a design token, a shared style
|
|
198
|
+
* object's, or code comes from the source.
|
|
199
|
+
*/
|
|
200
|
+
export function FormatSection({ anchor, info, pending, onChange }: FormatSectionProps) {
|
|
201
|
+
const t = useT();
|
|
202
|
+
const editable = info?.editable === true;
|
|
203
|
+
const cs = getComputedStyle(anchor);
|
|
204
|
+
const current = (prop: StyleProp) => currentOf(prop, info, pending);
|
|
205
|
+
const set = (prop: StyleProp, value: StyleValue | undefined) => {
|
|
206
|
+
if (value !== undefined && !isValidStyleValue(prop, value)) return;
|
|
207
|
+
onChange(prop, value, info?.props?.[prop] ?? null);
|
|
208
|
+
};
|
|
209
|
+
// Off in source when the element writes the key itself; otherwise only the
|
|
210
|
+
// unsaved change is taken back, since an inherited key is not this element's.
|
|
211
|
+
const clear = (prop: StyleProp) => {
|
|
212
|
+
const origin = info?.props?.[prop];
|
|
213
|
+
set(prop, origin && !origin.from ? null : undefined);
|
|
214
|
+
};
|
|
215
|
+
const pick = (prop: StyleProp) => (value: 'inherit' | string) =>
|
|
216
|
+
value === 'inherit' ? clear(prop) : set(prop, value);
|
|
217
|
+
|
|
218
|
+
const fontSize = Number.parseFloat(cs.fontSize) || 0;
|
|
219
|
+
const weight = Number.parseInt(cs.fontWeight, 10) || 400;
|
|
220
|
+
const italic = cs.fontStyle === 'italic';
|
|
221
|
+
const align = cs.textAlign === 'start' ? 'left' : cs.textAlign === 'end' ? 'right' : cs.textAlign;
|
|
222
|
+
const lineHeight =
|
|
223
|
+
cs.lineHeight === 'normal' || fontSize === 0
|
|
224
|
+
? 1.2
|
|
225
|
+
: Number((Number.parseFloat(cs.lineHeight) / fontSize).toFixed(2));
|
|
226
|
+
const tracking = cs.letterSpacing === 'normal' ? 0 : Number.parseFloat(cs.letterSpacing) || 0;
|
|
227
|
+
const color = rgbToHex(cs.color) ?? '';
|
|
228
|
+
const background = rgbToHex(cs.backgroundColor) ?? '';
|
|
229
|
+
|
|
230
|
+
// A refused element keeps its fields, read-only: they still say what the
|
|
231
|
+
// element is set to, and the lock says why they do not move.
|
|
232
|
+
const locked = info !== null && !editable ? t(info.reason) : null;
|
|
233
|
+
const lock = locked ? (
|
|
234
|
+
<span role="img" aria-label={locked} title={locked} className="flex text-muted-foreground">
|
|
235
|
+
<Lock className="size-3.5" />
|
|
236
|
+
</span>
|
|
237
|
+
) : undefined;
|
|
238
|
+
|
|
239
|
+
const font = current('fontFamily');
|
|
240
|
+
const fontChoice = choiceOf('fontFamily', font);
|
|
241
|
+
|
|
242
|
+
return (
|
|
243
|
+
<fieldset
|
|
244
|
+
disabled={!editable}
|
|
245
|
+
className={`m-0 min-w-0 border-0 p-0 transition-opacity ${locked ? 'opacity-50' : ''}`}
|
|
246
|
+
>
|
|
247
|
+
<Section title={t('Typography')} action={lock}>
|
|
248
|
+
<label className={`${BOX_CLASS} relative`} title={originNote(t, font)}>
|
|
249
|
+
<Type aria-hidden className="ml-2 size-3.5 flex-none text-muted-foreground" />
|
|
250
|
+
<select
|
|
251
|
+
aria-label={t('Font')}
|
|
252
|
+
value={fontChoice}
|
|
253
|
+
onChange={(e) => pick('fontFamily')(e.target.value)}
|
|
254
|
+
className={`${SELECT_CLASS} pl-2`}
|
|
255
|
+
>
|
|
256
|
+
<option value="inherit">
|
|
257
|
+
{font.origin?.from && !font.pending
|
|
258
|
+
? t('From {name}', { name: font.origin.from })
|
|
259
|
+
: t('Inherited font')}
|
|
260
|
+
</option>
|
|
261
|
+
{TOKENS.font.map((entry) => (
|
|
262
|
+
<option key={entry.token} value={`token:${entry.token}`}>
|
|
263
|
+
{t('{name} font', { name: t(entry.label) })}
|
|
264
|
+
</option>
|
|
265
|
+
))}
|
|
266
|
+
{fontChoice === 'custom' && <option value="custom">{t('Custom font')}</option>}
|
|
267
|
+
</select>
|
|
268
|
+
<ChevronDown
|
|
269
|
+
aria-hidden
|
|
270
|
+
className="pointer-events-none absolute right-2 size-3.5 text-muted-foreground"
|
|
271
|
+
/>
|
|
272
|
+
</label>
|
|
273
|
+
|
|
274
|
+
<div className={BOX_CLASS} title={originNote(t, current('fontSize'))}>
|
|
275
|
+
<NumberField
|
|
276
|
+
bare
|
|
277
|
+
label={t('Size in pixels')}
|
|
278
|
+
prefix={<CaseSensitive className="size-4" />}
|
|
279
|
+
value={Number(fontSize.toFixed(1))}
|
|
280
|
+
min={4}
|
|
281
|
+
max={400}
|
|
282
|
+
step={0.5}
|
|
283
|
+
suffix="px"
|
|
284
|
+
onChange={(value) => set('fontSize', `${value}px`)}
|
|
285
|
+
/>
|
|
286
|
+
<TokenChip
|
|
287
|
+
label={t('Size')}
|
|
288
|
+
prop="fontSize"
|
|
289
|
+
current={current('fontSize')}
|
|
290
|
+
onPick={pick('fontSize')}
|
|
291
|
+
/>
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
<div className="flex min-w-0 gap-2">
|
|
295
|
+
<label
|
|
296
|
+
className={`${BOX_CLASS} relative flex-1`}
|
|
297
|
+
title={originNote(t, current('fontWeight'))}
|
|
298
|
+
>
|
|
299
|
+
<select
|
|
300
|
+
aria-label={t('Weight')}
|
|
301
|
+
value={weight}
|
|
302
|
+
onChange={(e) => set('fontWeight', Number(e.target.value))}
|
|
303
|
+
className={`${SELECT_CLASS} pl-2`}
|
|
304
|
+
>
|
|
305
|
+
{WEIGHTS.some(([value]) => value === weight) ? null : (
|
|
306
|
+
<option value={weight}>{weight}</option>
|
|
307
|
+
)}
|
|
308
|
+
{WEIGHTS.map(([value, label]) => (
|
|
309
|
+
<option key={value} value={value}>
|
|
310
|
+
{t(label)}
|
|
311
|
+
</option>
|
|
312
|
+
))}
|
|
313
|
+
</select>
|
|
314
|
+
<ChevronDown
|
|
315
|
+
aria-hidden
|
|
316
|
+
className="pointer-events-none absolute right-2 size-3.5 text-muted-foreground"
|
|
317
|
+
/>
|
|
318
|
+
</label>
|
|
319
|
+
<Segments label={t('Emphasis')}>
|
|
320
|
+
<button
|
|
321
|
+
type="button"
|
|
322
|
+
aria-label={t('Bold')}
|
|
323
|
+
title={t('Bold')}
|
|
324
|
+
aria-pressed={weight >= 600}
|
|
325
|
+
onClick={() => set('fontWeight', weight >= 600 ? 400 : 700)}
|
|
326
|
+
className={SEGMENT_CLASS}
|
|
327
|
+
>
|
|
328
|
+
<Bold className="size-3.5" />
|
|
329
|
+
</button>
|
|
330
|
+
<button
|
|
331
|
+
type="button"
|
|
332
|
+
aria-label={t('Italic')}
|
|
333
|
+
title={t('Italic')}
|
|
334
|
+
aria-pressed={italic}
|
|
335
|
+
onClick={() => set('fontStyle', italic ? 'normal' : 'italic')}
|
|
336
|
+
className={SEGMENT_CLASS}
|
|
337
|
+
>
|
|
338
|
+
<Italic className="size-3.5" />
|
|
339
|
+
</button>
|
|
340
|
+
</Segments>
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
<Segments label={t('Alignment')}>
|
|
344
|
+
{ALIGNS.map(([value, label, Icon]) => (
|
|
345
|
+
<button
|
|
346
|
+
key={value}
|
|
347
|
+
type="button"
|
|
348
|
+
aria-label={t(label)}
|
|
349
|
+
title={t(label)}
|
|
350
|
+
aria-pressed={align === value}
|
|
351
|
+
onClick={() => set('textAlign', value)}
|
|
352
|
+
className={SEGMENT_CLASS}
|
|
353
|
+
>
|
|
354
|
+
<Icon className="size-3.5" />
|
|
355
|
+
</button>
|
|
356
|
+
))}
|
|
357
|
+
</Segments>
|
|
358
|
+
|
|
359
|
+
<div className="grid grid-cols-2 gap-2">
|
|
360
|
+
<div
|
|
361
|
+
className={BOX_CLASS}
|
|
362
|
+
title={originNote(t, current('lineHeight')) ?? t('Line height')}
|
|
363
|
+
>
|
|
364
|
+
<NumberField
|
|
365
|
+
bare
|
|
366
|
+
label={t('Line height')}
|
|
367
|
+
prefix={<MoveVertical className="size-3.5" />}
|
|
368
|
+
value={lineHeight}
|
|
369
|
+
min={0.5}
|
|
370
|
+
max={4}
|
|
371
|
+
step={0.05}
|
|
372
|
+
onChange={(value) => set('lineHeight', value)}
|
|
373
|
+
/>
|
|
374
|
+
<TokenChip
|
|
375
|
+
compact
|
|
376
|
+
label={t('Line height')}
|
|
377
|
+
prop="lineHeight"
|
|
378
|
+
current={current('lineHeight')}
|
|
379
|
+
onPick={pick('lineHeight')}
|
|
380
|
+
/>
|
|
381
|
+
</div>
|
|
382
|
+
<div
|
|
383
|
+
className={BOX_CLASS}
|
|
384
|
+
title={originNote(t, current('letterSpacing')) ?? t('Letter spacing')}
|
|
385
|
+
>
|
|
386
|
+
<NumberField
|
|
387
|
+
bare
|
|
388
|
+
label={t('Letter spacing in pixels')}
|
|
389
|
+
prefix={<MoveHorizontal className="size-3.5" />}
|
|
390
|
+
value={Number(tracking.toFixed(2))}
|
|
391
|
+
min={-20}
|
|
392
|
+
max={50}
|
|
393
|
+
step={0.1}
|
|
394
|
+
suffix="px"
|
|
395
|
+
onChange={(value) => set('letterSpacing', `${value}px`)}
|
|
396
|
+
/>
|
|
397
|
+
</div>
|
|
398
|
+
</div>
|
|
399
|
+
</Section>
|
|
400
|
+
|
|
401
|
+
<Section title={t('Color')} action={lock}>
|
|
402
|
+
<ColorField
|
|
403
|
+
label={t('Text')}
|
|
404
|
+
value={color}
|
|
405
|
+
onChange={(value) => set('color', value)}
|
|
406
|
+
trailing={
|
|
407
|
+
<TokenChip
|
|
408
|
+
compact="linked"
|
|
409
|
+
label={t('Text color')}
|
|
410
|
+
prop="color"
|
|
411
|
+
current={current('color')}
|
|
412
|
+
onPick={pick('color')}
|
|
413
|
+
/>
|
|
414
|
+
}
|
|
415
|
+
/>
|
|
416
|
+
<ColorField
|
|
417
|
+
label={t('Fill')}
|
|
418
|
+
value={background}
|
|
419
|
+
placeholder={t('None')}
|
|
420
|
+
onChange={(value) => set('background', value)}
|
|
421
|
+
trailing={
|
|
422
|
+
<TokenChip
|
|
423
|
+
compact="linked"
|
|
424
|
+
label={t('Fill')}
|
|
425
|
+
prop="background"
|
|
426
|
+
current={current('background')}
|
|
427
|
+
onPick={pick('background')}
|
|
428
|
+
/>
|
|
429
|
+
}
|
|
430
|
+
/>
|
|
431
|
+
</Section>
|
|
432
|
+
</fieldset>
|
|
433
|
+
);
|
|
434
|
+
}
|