@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.
Files changed (86) hide show
  1. package/dist/{build-B0GJXy8I.js → build-BHFGY8eF.js} +1 -1
  2. package/dist/{check-CuDIWsPT.js → check-UEBmDfT_.js} +3 -3
  3. package/dist/cli/bin.js +10 -6
  4. package/dist/{config-CAZ7Z_va.js → config-B_pdNbYg.js} +1166 -591
  5. package/dist/{context-PWAh9qbf.js → context-BM9_-u9P.js} +1 -1
  6. package/dist/{dev-CYqppXDI.js → dev-DX3QMIRi.js} +1 -1
  7. package/dist/{diagram-CCaUUnRe.js → diagram-BK4jTZr4.js} +146 -146
  8. package/dist/diff-DayvbXfX.js +44 -0
  9. package/dist/{export-1JtO2OMC.js → export-BPsXj1i6.js} +3 -3
  10. package/dist/{import-CsrdBOZ8.js → import-71wlAsrd.js} +2 -2
  11. package/dist/index.d.ts +53 -2
  12. package/dist/index.js +457 -18
  13. package/dist/ops/index.d.ts +72 -17
  14. package/dist/ops/index.js +3 -3
  15. package/dist/{ops-B2y9BMpk.js → ops-BUo67DaP.js} +642 -124
  16. package/dist/{preview-DW3PM-JV.js → preview-D3m1-gUL.js} +1 -1
  17. package/dist/{sdk-BqU6mwD_.d.ts → sdk-CpDEGRIo.d.ts} +2 -0
  18. package/dist/vite/index.js +1 -1
  19. package/package.json +2 -2
  20. package/skills/doc-authoring/SKILL.md +9 -4
  21. package/skills/doc-authoring/references/pagination.md +1 -1
  22. package/skills/doc-authoring/references/tables-and-charts.md +18 -1
  23. package/src/app/components/browser/browser-ui.tsx +105 -0
  24. package/src/app/components/chart.tsx +239 -0
  25. package/src/app/components/command-palette.tsx +284 -0
  26. package/src/app/components/design-panel/design-panel.tsx +22 -20
  27. package/src/app/components/design-panel/design-provider.tsx +4 -2
  28. package/src/app/components/diagram.tsx +11 -1
  29. package/src/app/components/doc-assets.tsx +6 -5
  30. package/src/app/components/doc-search.tsx +12 -10
  31. package/src/app/components/doc-sidebar.tsx +24 -18
  32. package/src/app/components/flow-page.tsx +2 -0
  33. package/src/app/components/inspector/format-section.tsx +434 -0
  34. package/src/app/components/inspector/inspector.tsx +310 -89
  35. package/src/app/components/inspector/use-style-edits.ts +210 -0
  36. package/src/app/components/language-toggle.tsx +38 -0
  37. package/src/app/components/palette-items.ts +128 -0
  38. package/src/app/components/panel/edit-save-card.tsx +4 -2
  39. package/src/app/components/panel/fields.tsx +100 -9
  40. package/src/app/components/panel/save-card.tsx +18 -10
  41. package/src/app/components/sidebar/folder-item.tsx +10 -8
  42. package/src/app/components/sidebar/icon-picker.tsx +3 -1
  43. package/src/app/components/sidebar/sidebar.tsx +44 -13
  44. package/src/app/components/theme-toggle.tsx +5 -3
  45. package/src/app/components/ui/menu.tsx +5 -0
  46. package/src/app/lib/agent-bridge.ts +8 -2
  47. package/src/app/lib/chart.test.ts +108 -0
  48. package/src/app/lib/chart.ts +343 -0
  49. package/src/app/lib/doc-preview.tsx +0 -10
  50. package/src/app/lib/docs.ts +3 -0
  51. package/src/app/lib/docx/from-dom.ts +11 -11
  52. package/src/app/lib/docx/ooxml.test.ts +25 -9
  53. package/src/app/lib/docx/ooxml.ts +58 -37
  54. package/src/app/lib/export-docx.ts +13 -8
  55. package/src/app/lib/flow.ts +1 -1
  56. package/src/app/lib/i18n-ja/browser.ts +88 -0
  57. package/src/app/lib/i18n-ja/doc.ts +65 -0
  58. package/src/app/lib/i18n-ja/index.ts +5 -0
  59. package/src/app/lib/i18n-ja/panels.ts +151 -0
  60. package/src/app/lib/i18n-ko/browser.ts +87 -0
  61. package/src/app/lib/i18n-ko/doc.ts +65 -0
  62. package/src/app/lib/i18n-ko/index.ts +5 -0
  63. package/src/app/lib/i18n-ko/panels.ts +148 -0
  64. package/src/app/lib/i18n-zh-cn/browser.ts +84 -0
  65. package/src/app/lib/i18n-zh-cn/doc.ts +64 -0
  66. package/src/app/lib/i18n-zh-cn/index.ts +5 -0
  67. package/src/app/lib/i18n-zh-cn/panels.ts +143 -0
  68. package/src/app/lib/i18n-zh-tw/browser.ts +84 -0
  69. package/src/app/lib/i18n-zh-tw/doc.ts +64 -0
  70. package/src/app/lib/i18n-zh-tw/index.ts +5 -0
  71. package/src/app/lib/i18n-zh-tw/panels.ts +144 -0
  72. package/src/app/lib/i18n.test.ts +24 -0
  73. package/src/app/lib/i18n.tsx +109 -0
  74. package/src/app/lib/inspector/format.ts +156 -0
  75. package/src/app/lib/outline.ts +23 -0
  76. package/src/app/lib/page-range.test.ts +10 -1
  77. package/src/app/lib/page-range.ts +26 -0
  78. package/src/app/lib/sdk.ts +2 -0
  79. package/src/app/main.tsx +4 -1
  80. package/src/app/routes/assets.tsx +193 -132
  81. package/src/app/routes/doc.tsx +668 -310
  82. package/src/app/routes/home-shell.tsx +115 -88
  83. package/src/app/routes/home.tsx +200 -67
  84. package/src/app/routes/themes.tsx +42 -35
  85. package/src/app/styles.css +84 -5
  86. package/src/app/virtual.d.ts +1 -0
@@ -1,5 +1,17 @@
1
- import { Check, Copy, FileIcon, Loader2, Trash2, Upload } from 'lucide-react';
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(`"${file.name}" already exists in ${scope}. Replace it?`);
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
- <div>
69
- <header className="border-border border-b px-8 py-6">
70
- <h1 className="font-medium text-lg tracking-tight">Assets</h1>
71
- <p className="mt-1 text-muted-foreground text-sm">
72
- Images and fonts documents can import. Global files live in{' '}
73
- <code className="font-mono">assets/</code>; per-document files in{' '}
74
- <code className="font-mono">docs/&lt;id&gt;/assets/</code>.
75
- </p>
76
- </header>
77
-
78
- <div className="flex flex-wrap items-center gap-2 px-8 pt-6">
79
- {scopes.map((s) => (
80
- <button
81
- key={s}
82
- type="button"
83
- onClick={() => setScope(s)}
84
- className={cn(
85
- 'rounded-full border px-3 py-1 text-xs transition-colors',
86
- s === scope
87
- ? 'border-transparent bg-primary text-primary-foreground'
88
- : 'border-border text-muted-foreground hover:bg-accent hover:text-foreground',
89
- )}
90
- >
91
- {s === GLOBAL_SCOPE ? 'Global' : s}
92
- </button>
93
- ))}
94
- </div>
95
-
96
- <div className="px-8 py-6">
97
- {/* biome-ignore lint/a11y/noStaticElementInteractions: drop target is an enhancement — the "Choose files" button is the keyboard path */}
98
- <div
99
- onDragOver={(e) => {
100
- e.preventDefault();
101
- setDragging(true);
102
- }}
103
- onDragLeave={() => setDragging(false)}
104
- onDrop={onDrop}
105
- className={cn(
106
- 'flex items-center justify-between gap-4 rounded-lg border border-dashed px-5 py-4 transition-colors',
107
- dragging ? 'border-primary bg-accent' : 'border-border',
108
- )}
109
- >
110
- <div className="text-sm">
111
- <p className="font-medium">Drop files to upload</p>
112
- <p className="mt-0.5 text-muted-foreground text-xs">
113
- Up to 25 MB each · png, jpg, svg, webp, pdf, woff2, csv…
114
- </p>
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
- <button
117
- type="button"
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 className="mt-3 rounded-md border border-border bg-muted px-3 py-2 text-xs">{error}</p>
139
- )}
140
-
141
- {assets === null ? (
142
- <div className="grid place-items-center py-16">
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
- </div>
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 (!window.confirm(`Delete "${asset.name}"? This removes the file from disk.`)) return;
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 className="relative grid h-32 place-items-center overflow-hidden rounded-md border border-border bg-muted">
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-2"
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
- <button
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
- </button>
233
- <p className="mt-0.5 text-[11px] text-muted-foreground">{formatBytes(asset.size)}</p>
234
- </div>
235
-
236
- <div className="flex items-center gap-1">
237
- <button
238
- type="button"
239
- onClick={copyImport}
240
- title={importSnippet(asset)}
241
- className="flex flex-1 items-center justify-center gap-1 rounded-md border border-border px-2 py-1 text-[11px] transition-colors hover:bg-accent"
242
- >
243
- {copied ? <Check className="size-3" /> : <Copy className="size-3" />}
244
- {copied ? 'Copied' : 'Import'}
245
- </button>
246
- <button
247
- type="button"
248
- onClick={remove}
249
- aria-label={`Delete ${asset.name}`}
250
- className="flex size-6 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
251
- >
252
- <Trash2 className="size-3" />
253
- </button>
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
  );