@open-document/core 0.9.1 → 0.11.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-B0GJXy8I.js → build-BHFGY8eF.js} +1 -1
- package/dist/{check-CuDIWsPT.js → check-UEBmDfT_.js} +3 -3
- package/dist/cli/bin.js +10 -6
- package/dist/{config-CAZ7Z_va.js → config-B_pdNbYg.js} +1166 -591
- package/dist/{context-PWAh9qbf.js → context-BM9_-u9P.js} +1 -1
- package/dist/{dev-CYqppXDI.js → dev-DX3QMIRi.js} +1 -1
- package/dist/{diagram-CCaUUnRe.js → diagram-BK4jTZr4.js} +146 -146
- package/dist/diff-DayvbXfX.js +44 -0
- package/dist/{export-1JtO2OMC.js → export-BPsXj1i6.js} +3 -3
- package/dist/{import-CsrdBOZ8.js → import-71wlAsrd.js} +2 -2
- package/dist/index.d.ts +53 -2
- package/dist/index.js +457 -18
- package/dist/ops/index.d.ts +72 -17
- package/dist/ops/index.js +3 -3
- package/dist/{ops-B2y9BMpk.js → ops-BUo67DaP.js} +642 -124
- package/dist/{preview-DW3PM-JV.js → preview-D3m1-gUL.js} +1 -1
- package/dist/{sdk-BqU6mwD_.d.ts → sdk-CpDEGRIo.d.ts} +2 -0
- package/dist/vite/index.js +1 -1
- package/package.json +2 -2
- package/skills/doc-authoring/SKILL.md +9 -4
- package/skills/doc-authoring/references/pagination.md +1 -1
- package/skills/doc-authoring/references/tables-and-charts.md +18 -1
- package/src/app/components/browser/browser-ui.tsx +105 -0
- package/src/app/components/chart.tsx +239 -0
- package/src/app/components/command-palette.tsx +284 -0
- package/src/app/components/design-panel/design-panel.tsx +22 -20
- package/src/app/components/design-panel/design-provider.tsx +4 -2
- package/src/app/components/diagram.tsx +11 -1
- package/src/app/components/doc-assets.tsx +6 -5
- package/src/app/components/doc-search.tsx +12 -10
- package/src/app/components/doc-sidebar.tsx +24 -18
- package/src/app/components/flow-page.tsx +2 -0
- package/src/app/components/inspector/format-section.tsx +434 -0
- package/src/app/components/inspector/inspector.tsx +310 -89
- package/src/app/components/inspector/use-style-edits.ts +210 -0
- package/src/app/components/language-toggle.tsx +38 -0
- package/src/app/components/palette-items.ts +128 -0
- package/src/app/components/panel/edit-save-card.tsx +4 -2
- package/src/app/components/panel/fields.tsx +100 -9
- package/src/app/components/panel/save-card.tsx +18 -10
- package/src/app/components/sidebar/folder-item.tsx +10 -8
- package/src/app/components/sidebar/icon-picker.tsx +3 -1
- package/src/app/components/sidebar/sidebar.tsx +44 -13
- package/src/app/components/theme-toggle.tsx +5 -3
- package/src/app/components/ui/menu.tsx +5 -0
- package/src/app/lib/agent-bridge.ts +8 -2
- package/src/app/lib/chart.test.ts +108 -0
- package/src/app/lib/chart.ts +343 -0
- package/src/app/lib/doc-preview.tsx +0 -10
- package/src/app/lib/docs.ts +3 -0
- package/src/app/lib/docx/from-dom.ts +11 -11
- package/src/app/lib/docx/ooxml.test.ts +25 -9
- package/src/app/lib/docx/ooxml.ts +58 -37
- package/src/app/lib/export-docx.ts +13 -8
- package/src/app/lib/flow.ts +1 -1
- package/src/app/lib/i18n-ja/browser.ts +88 -0
- package/src/app/lib/i18n-ja/doc.ts +65 -0
- package/src/app/lib/i18n-ja/index.ts +5 -0
- package/src/app/lib/i18n-ja/panels.ts +151 -0
- package/src/app/lib/i18n-ko/browser.ts +87 -0
- package/src/app/lib/i18n-ko/doc.ts +65 -0
- package/src/app/lib/i18n-ko/index.ts +5 -0
- package/src/app/lib/i18n-ko/panels.ts +148 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +84 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +64 -0
- package/src/app/lib/i18n-zh-cn/index.ts +5 -0
- package/src/app/lib/i18n-zh-cn/panels.ts +143 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +84 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +64 -0
- package/src/app/lib/i18n-zh-tw/index.ts +5 -0
- package/src/app/lib/i18n-zh-tw/panels.ts +144 -0
- package/src/app/lib/i18n.test.ts +24 -0
- package/src/app/lib/i18n.tsx +109 -0
- package/src/app/lib/inspector/format.ts +156 -0
- package/src/app/lib/outline.ts +23 -0
- package/src/app/lib/page-range.test.ts +10 -1
- package/src/app/lib/page-range.ts +26 -0
- package/src/app/lib/sdk.ts +2 -0
- package/src/app/main.tsx +4 -1
- package/src/app/routes/assets.tsx +193 -132
- package/src/app/routes/doc.tsx +668 -310
- package/src/app/routes/home-shell.tsx +115 -88
- package/src/app/routes/home.tsx +200 -67
- package/src/app/routes/themes.tsx +42 -35
- package/src/app/styles.css +84 -5
- package/src/app/virtual.d.ts +1 -0
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Check,
|
|
3
|
+
Copy,
|
|
4
|
+
FileIcon,
|
|
5
|
+
Image as ImageIcon,
|
|
6
|
+
Loader2,
|
|
7
|
+
MoreHorizontal,
|
|
8
|
+
PencilLine,
|
|
9
|
+
Trash2,
|
|
10
|
+
Upload,
|
|
11
|
+
} from 'lucide-react';
|
|
2
12
|
import { type DragEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { CARD_GRID, EmptyState, PageHeader } from '../components/browser/browser-ui';
|
|
14
|
+
import { Menu, MenuItem, MenuSeparator } from '../components/ui/menu';
|
|
3
15
|
import {
|
|
4
16
|
type Asset,
|
|
5
17
|
deleteAsset,
|
|
@@ -12,9 +24,11 @@ import {
|
|
|
12
24
|
uploadAsset,
|
|
13
25
|
} from '../lib/assets';
|
|
14
26
|
import { docIds } from '../lib/docs';
|
|
27
|
+
import { useT } from '../lib/i18n';
|
|
15
28
|
import { cn } from '../lib/utils';
|
|
16
29
|
|
|
17
30
|
export function AssetsPage() {
|
|
31
|
+
const t = useT();
|
|
18
32
|
const scopes = useMemo(() => [GLOBAL_SCOPE, ...[...docIds].sort()], []);
|
|
19
33
|
const [scope, setScope] = useState<string>(GLOBAL_SCOPE);
|
|
20
34
|
const [assets, setAssets] = useState<Asset[] | null>(null);
|
|
@@ -46,7 +60,9 @@ export function AssetsPage() {
|
|
|
46
60
|
for (const file of Array.from(files)) {
|
|
47
61
|
let result = await uploadAsset(scope, file);
|
|
48
62
|
if (!result.ok && result.error === 'asset exists') {
|
|
49
|
-
const replace = window.confirm(
|
|
63
|
+
const replace = window.confirm(
|
|
64
|
+
t('"{name}" already exists in {scope}. Replace it?', { name: file.name, scope }),
|
|
65
|
+
);
|
|
50
66
|
if (!replace) continue;
|
|
51
67
|
result = await uploadAsset(scope, file, { overwrite: true });
|
|
52
68
|
}
|
|
@@ -55,7 +71,7 @@ export function AssetsPage() {
|
|
|
55
71
|
await refresh(scope);
|
|
56
72
|
setBusy(false);
|
|
57
73
|
},
|
|
58
|
-
[scope, refresh],
|
|
74
|
+
[scope, refresh, t],
|
|
59
75
|
);
|
|
60
76
|
|
|
61
77
|
const onDrop = (e: DragEvent<HTMLDivElement>) => {
|
|
@@ -65,101 +81,105 @@ export function AssetsPage() {
|
|
|
65
81
|
};
|
|
66
82
|
|
|
67
83
|
return (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
84
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: dropping files is an enhancement — "Choose files" is the keyboard path
|
|
85
|
+
<div
|
|
86
|
+
onDragOver={(e) => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
setDragging(true);
|
|
89
|
+
}}
|
|
90
|
+
onDragLeave={(e) => {
|
|
91
|
+
if (e.currentTarget.contains(e.relatedTarget as Node | null)) return;
|
|
92
|
+
setDragging(false);
|
|
93
|
+
}}
|
|
94
|
+
onDrop={onDrop}
|
|
95
|
+
className={cn(
|
|
96
|
+
'min-h-[60vh] rounded-lg outline-2 outline-offset-8 transition-colors',
|
|
97
|
+
dragging ? 'outline-dashed outline-primary/50' : 'outline-transparent',
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
<PageHeader
|
|
101
|
+
title={t('Assets')}
|
|
102
|
+
icon={ImageIcon}
|
|
103
|
+
count={assets?.length}
|
|
104
|
+
actions={
|
|
105
|
+
<>
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
onClick={() => inputRef.current?.click()}
|
|
109
|
+
disabled={busy}
|
|
110
|
+
className="flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs transition-opacity hover:opacity-90 disabled:opacity-60"
|
|
111
|
+
>
|
|
112
|
+
{busy ? (
|
|
113
|
+
<Loader2 className="size-3.5 animate-spin" />
|
|
114
|
+
) : (
|
|
115
|
+
<Upload className="size-3.5" />
|
|
116
|
+
)}
|
|
117
|
+
{t('Upload')}
|
|
118
|
+
</button>
|
|
119
|
+
<input
|
|
120
|
+
ref={inputRef}
|
|
121
|
+
type="file"
|
|
122
|
+
multiple
|
|
123
|
+
hidden
|
|
124
|
+
onChange={(e) => {
|
|
125
|
+
if (e.target.files?.length) void upload(e.target.files);
|
|
126
|
+
e.target.value = '';
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
129
|
+
</>
|
|
130
|
+
}
|
|
131
|
+
>
|
|
132
|
+
<fieldset className="flex flex-wrap items-center gap-3">
|
|
133
|
+
<legend className="sr-only">{t('Folder')}</legend>
|
|
134
|
+
<div className="flex max-w-full gap-0.5 overflow-x-auto rounded-md bg-muted p-0.5">
|
|
135
|
+
{scopes.map((s) => (
|
|
136
|
+
<button
|
|
137
|
+
key={s}
|
|
138
|
+
type="button"
|
|
139
|
+
aria-pressed={s === scope}
|
|
140
|
+
onClick={() => setScope(s)}
|
|
141
|
+
className={cn(
|
|
142
|
+
'h-7 flex-none whitespace-nowrap rounded px-3 text-xs text-muted-foreground transition-colors hover:text-foreground',
|
|
143
|
+
s === scope && 'bg-background text-foreground shadow-sm',
|
|
144
|
+
)}
|
|
145
|
+
>
|
|
146
|
+
{s === GLOBAL_SCOPE ? t('Project') : s}
|
|
147
|
+
</button>
|
|
148
|
+
))}
|
|
115
149
|
</div>
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
onClick={() => inputRef.current?.click()}
|
|
119
|
-
disabled={busy}
|
|
120
|
-
className="flex flex-none items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-primary-foreground text-xs transition-opacity hover:opacity-90 disabled:opacity-60"
|
|
121
|
-
>
|
|
122
|
-
{busy ? <Loader2 className="size-3.5 animate-spin" /> : <Upload className="size-3.5" />}
|
|
123
|
-
Choose files
|
|
124
|
-
</button>
|
|
125
|
-
<input
|
|
126
|
-
ref={inputRef}
|
|
127
|
-
type="file"
|
|
128
|
-
multiple
|
|
129
|
-
hidden
|
|
130
|
-
onChange={(e) => {
|
|
131
|
-
if (e.target.files?.length) void upload(e.target.files);
|
|
132
|
-
e.target.value = '';
|
|
133
|
-
}}
|
|
134
|
-
/>
|
|
135
|
-
</div>
|
|
136
|
-
|
|
150
|
+
<p className="text-muted-foreground text-xs">{t('Drop files here to upload')}</p>
|
|
151
|
+
</fieldset>
|
|
137
152
|
{error && (
|
|
138
|
-
<p
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
<Loader2 className="size-4 animate-spin text-muted-foreground" />
|
|
144
|
-
</div>
|
|
145
|
-
) : assets.length === 0 ? (
|
|
146
|
-
<p className="py-16 text-center text-muted-foreground text-sm">
|
|
147
|
-
No assets in {scope === GLOBAL_SCOPE ? 'the global folder' : scope} yet.
|
|
153
|
+
<p
|
|
154
|
+
role="alert"
|
|
155
|
+
className="mt-3 rounded-md border border-border bg-muted px-3 py-2 text-xs"
|
|
156
|
+
>
|
|
157
|
+
{error}
|
|
148
158
|
</p>
|
|
149
|
-
) : (
|
|
150
|
-
<div className="mt-6 grid gap-5 [grid-template-columns:repeat(auto-fill,minmax(180px,1fr))]">
|
|
151
|
-
{assets.map((asset) => (
|
|
152
|
-
<AssetCard
|
|
153
|
-
key={asset.name}
|
|
154
|
-
asset={asset}
|
|
155
|
-
scope={scope}
|
|
156
|
-
onChanged={() => refresh(scope)}
|
|
157
|
-
onError={setError}
|
|
158
|
-
/>
|
|
159
|
-
))}
|
|
160
|
-
</div>
|
|
161
159
|
)}
|
|
162
|
-
</
|
|
160
|
+
</PageHeader>
|
|
161
|
+
|
|
162
|
+
{assets === null ? (
|
|
163
|
+
<div className="grid place-items-center py-16">
|
|
164
|
+
<Loader2 className="size-4 animate-spin text-muted-foreground" />
|
|
165
|
+
</div>
|
|
166
|
+
) : assets.length === 0 ? (
|
|
167
|
+
<EmptyState icon={ImageIcon} title={t('No assets yet')}>
|
|
168
|
+
{t('Drop images here or choose Upload.')}
|
|
169
|
+
</EmptyState>
|
|
170
|
+
) : (
|
|
171
|
+
<div className={CARD_GRID}>
|
|
172
|
+
{assets.map((asset) => (
|
|
173
|
+
<AssetCard
|
|
174
|
+
key={asset.name}
|
|
175
|
+
asset={asset}
|
|
176
|
+
scope={scope}
|
|
177
|
+
onChanged={() => refresh(scope)}
|
|
178
|
+
onError={setError}
|
|
179
|
+
/>
|
|
180
|
+
))}
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
163
183
|
</div>
|
|
164
184
|
);
|
|
165
185
|
}
|
|
@@ -175,6 +195,7 @@ function AssetCard({
|
|
|
175
195
|
onChanged: () => void;
|
|
176
196
|
onError: (message: string) => void;
|
|
177
197
|
}) {
|
|
198
|
+
const t = useT();
|
|
178
199
|
const [copied, setCopied] = useState(false);
|
|
179
200
|
|
|
180
201
|
const copyImport = async () => {
|
|
@@ -188,7 +209,7 @@ function AssetCard({
|
|
|
188
209
|
};
|
|
189
210
|
|
|
190
211
|
const rename = async () => {
|
|
191
|
-
const next = window.prompt('New file name', asset.name);
|
|
212
|
+
const next = window.prompt(t('New file name'), asset.name);
|
|
192
213
|
if (!next || next === asset.name) return;
|
|
193
214
|
const result = await renameAsset(scope, asset.name, next);
|
|
194
215
|
if (!result.ok) onError(`${asset.name}: ${result.error}`);
|
|
@@ -196,61 +217,101 @@ function AssetCard({
|
|
|
196
217
|
};
|
|
197
218
|
|
|
198
219
|
const remove = async () => {
|
|
199
|
-
if (
|
|
220
|
+
if (
|
|
221
|
+
!window.confirm(t('Delete "{name}"? This removes the file from disk.', { name: asset.name }))
|
|
222
|
+
)
|
|
223
|
+
return;
|
|
200
224
|
const result = await deleteAsset(scope, asset.name);
|
|
201
225
|
if (!result.ok) onError(`${asset.name}: ${result.error}`);
|
|
202
226
|
onChanged();
|
|
203
227
|
};
|
|
204
228
|
|
|
205
229
|
return (
|
|
206
|
-
<div className="flex flex-col gap-2">
|
|
207
|
-
<div
|
|
230
|
+
<div className="group flex flex-col gap-2.5">
|
|
231
|
+
<div
|
|
232
|
+
className={cn(
|
|
233
|
+
'grid aspect-[4/3] place-items-center overflow-hidden rounded-md ring-1 ring-border',
|
|
234
|
+
isPreviewable(asset.mime) ? 'bg-paper' : 'bg-muted',
|
|
235
|
+
)}
|
|
236
|
+
>
|
|
208
237
|
{isPreviewable(asset.mime) ? (
|
|
209
238
|
<img
|
|
210
239
|
src={asset.url}
|
|
211
240
|
alt={asset.name}
|
|
212
|
-
className="max-h-full max-w-full object-contain p-
|
|
241
|
+
className="max-h-full max-w-full object-contain p-3"
|
|
213
242
|
/>
|
|
214
243
|
) : (
|
|
215
244
|
<FileIcon className="size-6 text-muted-foreground" />
|
|
216
245
|
)}
|
|
217
|
-
{asset.unused && (
|
|
218
|
-
<span className="absolute top-1.5 left-1.5 rounded-full bg-background/90 px-1.5 py-0.5 text-[10px] text-muted-foreground">
|
|
219
|
-
unused
|
|
220
|
-
</span>
|
|
221
|
-
)}
|
|
222
246
|
</div>
|
|
223
247
|
|
|
248
|
+
{/* The name gets the full width — a file name broken mid-extension
|
|
249
|
+
reads as a different file — and the actions sit beside the facts. */}
|
|
224
250
|
<div className="min-w-0">
|
|
225
|
-
<
|
|
226
|
-
type="button"
|
|
227
|
-
onClick={rename}
|
|
228
|
-
title="Rename"
|
|
229
|
-
className="block w-full truncate text-left text-xs hover:underline"
|
|
230
|
-
>
|
|
251
|
+
<p className="line-clamp-2 font-medium text-sm leading-snug [overflow-wrap:anywhere]">
|
|
231
252
|
{asset.name}
|
|
232
|
-
</
|
|
233
|
-
<
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
</p>
|
|
254
|
+
<div className="mt-0.5 flex items-center gap-1">
|
|
255
|
+
<p className="min-w-0 flex-1 truncate text-muted-foreground text-xs">
|
|
256
|
+
{formatBytes(asset.size)}
|
|
257
|
+
{asset.unused ? t(' · unused') : ''}
|
|
258
|
+
</p>
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
onClick={copyImport}
|
|
262
|
+
aria-label={t('Copy the import line for {name}', { name: asset.name })}
|
|
263
|
+
title={importSnippet(asset)}
|
|
264
|
+
className="flex size-7 flex-none items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
|
|
265
|
+
>
|
|
266
|
+
{copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
|
|
267
|
+
</button>
|
|
268
|
+
<Menu
|
|
269
|
+
trigger={(props) => (
|
|
270
|
+
<button
|
|
271
|
+
type="button"
|
|
272
|
+
aria-label={t('{name} options', { name: asset.name })}
|
|
273
|
+
className="flex size-7 flex-none items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground aria-expanded:bg-accent"
|
|
274
|
+
{...props}
|
|
275
|
+
>
|
|
276
|
+
<MoreHorizontal className="size-3.5" />
|
|
277
|
+
</button>
|
|
278
|
+
)}
|
|
279
|
+
>
|
|
280
|
+
{(close) => (
|
|
281
|
+
<>
|
|
282
|
+
<MenuItem
|
|
283
|
+
onClick={() => {
|
|
284
|
+
close();
|
|
285
|
+
void copyImport();
|
|
286
|
+
}}
|
|
287
|
+
>
|
|
288
|
+
<Copy className="size-3.5" />
|
|
289
|
+
{t('Copy import line')}
|
|
290
|
+
</MenuItem>
|
|
291
|
+
<MenuItem
|
|
292
|
+
onClick={() => {
|
|
293
|
+
close();
|
|
294
|
+
void rename();
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
<PencilLine className="size-3.5" />
|
|
298
|
+
{t('Rename')}
|
|
299
|
+
</MenuItem>
|
|
300
|
+
<MenuSeparator />
|
|
301
|
+
<MenuItem
|
|
302
|
+
destructive
|
|
303
|
+
onClick={() => {
|
|
304
|
+
close();
|
|
305
|
+
void remove();
|
|
306
|
+
}}
|
|
307
|
+
>
|
|
308
|
+
<Trash2 className="size-3.5" />
|
|
309
|
+
{t('Delete')}
|
|
310
|
+
</MenuItem>
|
|
311
|
+
</>
|
|
312
|
+
)}
|
|
313
|
+
</Menu>
|
|
314
|
+
</div>
|
|
254
315
|
</div>
|
|
255
316
|
</div>
|
|
256
317
|
);
|