@open-document/core 0.11.0 → 0.13.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-BHFGY8eF.js → build-CbgIk6bA.js} +1 -1
- package/dist/{check-UEBmDfT_.js → check-BTroj-5Z.js} +3 -3
- package/dist/cli/bin.js +58 -34
- package/dist/config-BWtOZ1jc.d.ts +45 -0
- package/dist/{config-B_pdNbYg.js → config-DKKNIbvO.js} +1458 -983
- package/dist/{context-BM9_-u9P.js → context-DXNP8v9I.js} +3 -2
- package/dist/deploy-gcp-BUiSuqz7.js +758 -0
- package/dist/{dev-DX3QMIRi.js → dev-YXumw5iX.js} +1 -1
- package/dist/{diagram-BK4jTZr4.js → diagram-CKf3ptOE.js} +293 -13
- package/dist/{diff-DayvbXfX.js → diff-CTFfU4Tz.js} +2 -2
- package/dist/{export-BPsXj1i6.js → export-D2QLtF84.js} +11 -4
- package/dist/flow-CS5apebG.d.ts +252 -0
- package/dist/{import-71wlAsrd.js → import-CcmrFetU.js} +3 -2
- package/dist/index.d.ts +155 -59
- package/dist/index.js +945 -104
- package/dist/open-doc-plugin-DnX5usgI.js +320 -0
- package/dist/ops/index.d.ts +112 -3
- package/dist/ops/index.js +3 -3
- package/dist/{ops-BUo67DaP.js → ops-DmEecq1k.js} +86 -164
- package/dist/package-version-C89gtYSk.js +36 -0
- package/dist/{preview-D3m1-gUL.js → preview-_mHpBhMk.js} +1 -1
- package/dist/templates-MMblHwmT.js +34 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +2 -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 +17 -16
- package/skills/doc-authoring/references/long-form.md +43 -2
- package/skills/doc-authoring/references/pagination.md +14 -2
- package/skills/doc-authoring/references/tables-and-charts.md +21 -17
- 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/callout.tsx +101 -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/chart.tsx +191 -33
- package/src/app/components/code-block.tsx +249 -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/data-table.tsx +146 -18
- package/src/app/components/doc-sidebar.tsx +32 -2
- package/src/app/components/flow-page.tsx +57 -8
- package/src/app/components/inspector/field-source.tsx +41 -0
- package/src/app/components/inspector/inspector.tsx +64 -65
- package/src/app/components/numbering.tsx +226 -12
- package/src/app/components/overlay-frame.tsx +79 -0
- package/src/app/components/page-frame.tsx +46 -0
- package/src/app/components/page-placement.ts +68 -0
- 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/chart.test.ts +15 -0
- package/src/app/lib/chart.ts +134 -9
- package/src/app/lib/diagnostics.ts +45 -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 +17 -3
- package/src/app/lib/export-html.ts +4 -2
- package/src/app/lib/export-image.ts +2 -1
- package/src/app/lib/export-pdf.ts +9 -1
- package/src/app/lib/flow-measure.test.ts +30 -0
- package/src/app/lib/flow-measure.ts +68 -14
- package/src/app/lib/flow.test.ts +20 -1
- package/src/app/lib/flow.ts +120 -20
- 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 +40 -0
- 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 +39 -0
- 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 +38 -0
- 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 +38 -0
- package/src/app/lib/labels.ts +29 -10
- package/src/app/lib/records.test.ts +38 -0
- package/src/app/lib/records.ts +127 -0
- package/src/app/lib/sdk.ts +35 -0
- package/src/app/lib/use-doc-module.ts +7 -0
- package/src/app/lib/use-doc-pages.ts +38 -17
- package/src/app/routes/doc.tsx +275 -13
- 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
- package/dist/config-P61niZMf.d.ts +0 -24
- package/dist/sdk-CpDEGRIo.d.ts +0 -138
package/src/app/routes/doc.tsx
CHANGED
|
@@ -11,12 +11,14 @@ import {
|
|
|
11
11
|
FileImage,
|
|
12
12
|
FileText,
|
|
13
13
|
FileType2,
|
|
14
|
+
GitCompare,
|
|
14
15
|
Hash,
|
|
15
16
|
Image,
|
|
16
17
|
LayoutGrid,
|
|
17
18
|
Link2,
|
|
18
19
|
Loader2,
|
|
19
20
|
Maximize,
|
|
21
|
+
MessageSquare,
|
|
20
22
|
Minimize,
|
|
21
23
|
Minus,
|
|
22
24
|
MoveHorizontal,
|
|
@@ -29,7 +31,13 @@ import {
|
|
|
29
31
|
import { useTheme } from 'next-themes';
|
|
30
32
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
31
33
|
import { Link, useNavigate, useParams } from 'react-router-dom';
|
|
34
|
+
import { ChangesOverlay, elementsOf } from '../components/changes/changes-overlay';
|
|
35
|
+
import { ChangesPanel } from '../components/changes/changes-panel';
|
|
36
|
+
import { type ChangeItem, itemsOf, useChanges } from '../components/changes/use-changes';
|
|
32
37
|
import { CommandPaletteProvider, type PaletteItem } from '../components/command-palette';
|
|
38
|
+
import { CommentsOverlay } from '../components/comments/comments-overlay';
|
|
39
|
+
import { CommentsPanel } from '../components/comments/comments-panel';
|
|
40
|
+
import { type DocComment, useComments } from '../components/comments/use-comments';
|
|
33
41
|
import { DesignPanel } from '../components/design-panel/design-panel';
|
|
34
42
|
import { DesignProvider } from '../components/design-panel/design-provider';
|
|
35
43
|
import { DocSearch } from '../components/doc-search';
|
|
@@ -37,8 +45,10 @@ import { DocSidebar } from '../components/doc-sidebar';
|
|
|
37
45
|
import { HistoryProvider } from '../components/history-provider';
|
|
38
46
|
import { Inspector, type InspectorControls } from '../components/inspector/inspector';
|
|
39
47
|
import { PageFrame } from '../components/page-frame';
|
|
48
|
+
import { elementsAtLoc, usePlacement } from '../components/page-placement';
|
|
40
49
|
import { browserItems } from '../components/palette-items';
|
|
41
50
|
import { EditSaveCard } from '../components/panel/edit-save-card';
|
|
51
|
+
import { RecordPicker } from '../components/record-picker';
|
|
42
52
|
import { ThemeToggle } from '../components/theme-toggle';
|
|
43
53
|
import { Menu, MenuItem } from '../components/ui/menu';
|
|
44
54
|
import { useAgentBridge } from '../lib/agent-bridge';
|
|
@@ -55,8 +65,9 @@ import {
|
|
|
55
65
|
resolveSelection,
|
|
56
66
|
} from '../lib/page-range';
|
|
57
67
|
import { nextFrame, waitForFonts } from '../lib/print-ready';
|
|
68
|
+
import { getRecordState, setRecords, useRecordIndex } from '../lib/records';
|
|
58
69
|
import { scanDocument } from '../lib/scan';
|
|
59
|
-
import { resolvePageGeometry } from '../lib/sdk';
|
|
70
|
+
import { pageLang, resolvePageGeometry } from '../lib/sdk';
|
|
60
71
|
import { useDocModule } from '../lib/use-doc-module';
|
|
61
72
|
import { useDocPages } from '../lib/use-doc-pages';
|
|
62
73
|
import { cn } from '../lib/utils';
|
|
@@ -203,8 +214,18 @@ export function Doc() {
|
|
|
203
214
|
const [downloaded, setDownloaded] = useState<DownloadFormat | null>(null);
|
|
204
215
|
const [selection, setSelection] = useState<PageSelection>({ kind: 'all' });
|
|
205
216
|
const [customRange, setCustomRange] = useState('');
|
|
206
|
-
|
|
207
|
-
|
|
217
|
+
// One dock on the right, one panel in it at a time; the element panel takes
|
|
218
|
+
// it back whenever an element is picked.
|
|
219
|
+
const [dock, setDock] = useState<'design' | 'changes' | 'comments' | null>(null);
|
|
220
|
+
const designOpen = dock === 'design';
|
|
221
|
+
const changesOpen = dock === 'changes';
|
|
222
|
+
const commentsOpen = dock === 'comments';
|
|
223
|
+
const toggleDock = useCallback(
|
|
224
|
+
(panel: 'design' | 'changes' | 'comments') =>
|
|
225
|
+
setDock((open) => (open === panel ? null : panel)),
|
|
226
|
+
[],
|
|
227
|
+
);
|
|
228
|
+
const closeDock = useCallback(() => setDock(null), []);
|
|
208
229
|
const [editing, setEditingState] = useState(readEditing);
|
|
209
230
|
// The dev server reloads every open viewer when a document is added or
|
|
210
231
|
// removed anywhere in the workspace. Edit mode is per tab and survives that.
|
|
@@ -227,10 +248,99 @@ export function Doc() {
|
|
|
227
248
|
const jumpedRef = useRef<number | null>(null);
|
|
228
249
|
|
|
229
250
|
const geometry = useMemo(() => resolvePageGeometry(doc?.meta), [doc?.meta]);
|
|
251
|
+
// The rows this document prints for. Set before the pages measure, and kept
|
|
252
|
+
// on the same row across a reload — an edit should not jump the preview
|
|
253
|
+
// back to the first one. `?record=` opens on a given row.
|
|
254
|
+
useLayoutEffect(() => {
|
|
255
|
+
const fromUrl = Number(new URLSearchParams(window.location.search).get('record'));
|
|
256
|
+
const keep = getRecordState().records.length > 0 ? getRecordState().index : fromUrl - 1;
|
|
257
|
+
setRecords(doc?.records, Number.isFinite(keep) ? keep : 0);
|
|
258
|
+
}, [doc]);
|
|
259
|
+
useEffect(() => () => setRecords(undefined), []);
|
|
260
|
+
|
|
230
261
|
const { pages, measuring, overflowing } = useDocPages(doc, geometry);
|
|
262
|
+
const recordIndex = useRecordIndex();
|
|
263
|
+
|
|
264
|
+
// Read again on every reload of the document, so what an agent just wrote
|
|
265
|
+
// shows up in the count and on the page without being asked for.
|
|
266
|
+
const changes = useChanges(docId, doc, import.meta.env.DEV);
|
|
267
|
+
const changeItems = useMemo(() => itemsOf(changes.state), [changes.state]);
|
|
268
|
+
const changeTargets = useMemo(
|
|
269
|
+
() =>
|
|
270
|
+
changeItems.map((item) => ({
|
|
271
|
+
id: item.hunk.id,
|
|
272
|
+
locs: item.hunk.targets.map((target) => target.loc),
|
|
273
|
+
})),
|
|
274
|
+
[changeItems],
|
|
275
|
+
);
|
|
276
|
+
const placement = usePlacement(changesOpen ? scrollRef.current : null, changeTargets);
|
|
277
|
+
const changedPages = useMemo(() => new Set([...placement.values()].flat()), [placement]);
|
|
278
|
+
|
|
279
|
+
const comments = useComments(docId, doc, import.meta.env.DEV);
|
|
280
|
+
const commentList = useMemo(
|
|
281
|
+
() => (comments.state.status === 'ready' ? comments.state.comments : []),
|
|
282
|
+
[comments.state],
|
|
283
|
+
);
|
|
284
|
+
const commentTargets = useMemo(
|
|
285
|
+
() =>
|
|
286
|
+
commentList.map((comment) => ({ id: comment.id, locs: comment.loc ? [comment.loc] : [] })),
|
|
287
|
+
[commentList],
|
|
288
|
+
);
|
|
289
|
+
const commentPlacement = usePlacement(commentsOpen ? scrollRef.current : null, commentTargets);
|
|
290
|
+
const commentPages = useMemo(
|
|
291
|
+
() => new Set([...commentPlacement.values()].flat()),
|
|
292
|
+
[commentPlacement],
|
|
293
|
+
);
|
|
294
|
+
const [activeComment, setActiveComment] = useState<string | null>(null);
|
|
295
|
+
const selectComment = useCallback((comment: DocComment) => {
|
|
296
|
+
setActiveComment(comment.id);
|
|
297
|
+
const container = scrollRef.current;
|
|
298
|
+
const first = container && comment.loc ? elementsAtLoc(container, comment.loc)[0] : undefined;
|
|
299
|
+
first?.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
300
|
+
}, []);
|
|
301
|
+
// "New comment" is a picking state: the panel stays, the page waits for an
|
|
302
|
+
// element, and the element panel then opens on the note, focused. Pressing
|
|
303
|
+
// it again, or Esc, cancels.
|
|
304
|
+
const [commentFirst, setCommentFirst] = useState(false);
|
|
305
|
+
const [picking, setPicking] = useState(false);
|
|
306
|
+
const startComment = useCallback(() => {
|
|
307
|
+
if (picking) {
|
|
308
|
+
setPicking(false);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
setCommentFirst(true);
|
|
312
|
+
setPicking(true);
|
|
313
|
+
setEditing(true);
|
|
314
|
+
}, [picking, setEditing]);
|
|
315
|
+
const pickElement = useCallback(() => {
|
|
316
|
+
setDock(null);
|
|
317
|
+
setPicking(false);
|
|
318
|
+
}, []);
|
|
319
|
+
const cancelPick = useCallback(() => setPicking(false), []);
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
if (!editing) {
|
|
322
|
+
setCommentFirst(false);
|
|
323
|
+
setPicking(false);
|
|
324
|
+
}
|
|
325
|
+
}, [editing]);
|
|
326
|
+
const [activeChange, setActiveChange] = useState<string | null>(null);
|
|
327
|
+
const selectChange = useCallback((item: ChangeItem) => {
|
|
328
|
+
setActiveChange(item.hunk.id);
|
|
329
|
+
const container = scrollRef.current;
|
|
330
|
+
const first = container ? elementsOf(container, item)[0]?.el : undefined;
|
|
331
|
+
first?.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
|
332
|
+
}, []);
|
|
231
333
|
const outline = useDocOutline();
|
|
232
334
|
|
|
233
|
-
useAgentBridge({
|
|
335
|
+
useAgentBridge({
|
|
336
|
+
docId: docId ?? '',
|
|
337
|
+
doc,
|
|
338
|
+
pages,
|
|
339
|
+
geometry,
|
|
340
|
+
measuring,
|
|
341
|
+
oversized: overflowing,
|
|
342
|
+
record: recordIndex,
|
|
343
|
+
});
|
|
234
344
|
|
|
235
345
|
const clamp = (value: number) => Math.max(MIN_SCALE, Math.min(MAX_SCALE, value));
|
|
236
346
|
// Every fit is of the unit the mode lays side by side — a sheet, a spread,
|
|
@@ -538,7 +648,27 @@ export function Doc() {
|
|
|
538
648
|
hint: 'D',
|
|
539
649
|
keywords: 'design colours fonts',
|
|
540
650
|
icon: Palette,
|
|
541
|
-
run: () =>
|
|
651
|
+
run: () => toggleDock('design'),
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
id: 'changes',
|
|
655
|
+
group: t('Actions'),
|
|
656
|
+
label: changesOpen
|
|
657
|
+
? t('Close the changes panel')
|
|
658
|
+
: t('Show changes since the last commit'),
|
|
659
|
+
hint: 'C',
|
|
660
|
+
keywords: 'changes diff git review agent revert',
|
|
661
|
+
icon: GitCompare,
|
|
662
|
+
run: () => toggleDock('changes'),
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
id: 'comments',
|
|
666
|
+
group: t('Actions'),
|
|
667
|
+
label: commentsOpen ? t('Close the comments panel') : t('Show comments'),
|
|
668
|
+
hint: 'M',
|
|
669
|
+
keywords: 'comments review notes agent',
|
|
670
|
+
icon: MessageSquare,
|
|
671
|
+
run: () => toggleDock('comments'),
|
|
542
672
|
},
|
|
543
673
|
);
|
|
544
674
|
}
|
|
@@ -558,14 +688,16 @@ export function Doc() {
|
|
|
558
688
|
// page" from node_modules/.open-doc/current.json. See vite/current-plugin.ts.
|
|
559
689
|
useEffect(() => {
|
|
560
690
|
if (!import.meta.hot) return;
|
|
561
|
-
|
|
691
|
+
// Not while the flow sections are still being measured: the page count
|
|
692
|
+
// then is the unpaginated one, and an agent reading it would act on it.
|
|
693
|
+
if (!docId || !doc || pages.length === 0 || measuring) return;
|
|
562
694
|
import.meta.hot.send('open-doc:current', {
|
|
563
695
|
docId,
|
|
564
696
|
pageIndex: currentPage - 1,
|
|
565
697
|
totalPages: pages.length,
|
|
566
698
|
docTitle: doc.meta?.title ?? docId,
|
|
567
699
|
});
|
|
568
|
-
}, [docId, doc, currentPage, pages.length]);
|
|
700
|
+
}, [docId, doc, currentPage, pages.length, measuring]);
|
|
569
701
|
|
|
570
702
|
useEffect(() => {
|
|
571
703
|
const onKeyDown = (e: KeyboardEvent) => {
|
|
@@ -577,12 +709,18 @@ export function Doc() {
|
|
|
577
709
|
toggleFullscreen();
|
|
578
710
|
} else if (import.meta.env.DEV && (e.key === 'd' || e.key === 'D')) {
|
|
579
711
|
e.preventDefault();
|
|
580
|
-
|
|
712
|
+
toggleDock('design');
|
|
713
|
+
} else if (import.meta.env.DEV && (e.key === 'c' || e.key === 'C')) {
|
|
714
|
+
e.preventDefault();
|
|
715
|
+
toggleDock('changes');
|
|
716
|
+
} else if (import.meta.env.DEV && (e.key === 'm' || e.key === 'M')) {
|
|
717
|
+
e.preventDefault();
|
|
718
|
+
toggleDock('comments');
|
|
581
719
|
}
|
|
582
720
|
};
|
|
583
721
|
window.addEventListener('keydown', onKeyDown);
|
|
584
722
|
return () => window.removeEventListener('keydown', onKeyDown);
|
|
585
|
-
}, [toggleFullscreen]);
|
|
723
|
+
}, [toggleFullscreen, toggleDock]);
|
|
586
724
|
|
|
587
725
|
if (state.status === 'error') {
|
|
588
726
|
return (
|
|
@@ -623,6 +761,9 @@ export function Doc() {
|
|
|
623
761
|
<div className="flex min-w-0 items-center gap-1">
|
|
624
762
|
<HeaderBackLink />
|
|
625
763
|
<h1 className="truncate font-medium text-sm">{doc.meta?.title ?? docId}</h1>
|
|
764
|
+
{doc.records && doc.records.length > 0 && (
|
|
765
|
+
<RecordPicker records={doc.records} labelKey={doc.meta?.recordLabel} />
|
|
766
|
+
)}
|
|
626
767
|
</div>
|
|
627
768
|
|
|
628
769
|
<div className="hidden items-center gap-2 sm:flex">
|
|
@@ -697,7 +838,7 @@ export function Doc() {
|
|
|
697
838
|
aria-label={t('Design')}
|
|
698
839
|
aria-keyshortcuts="D"
|
|
699
840
|
title={t('Design tokens (D)')}
|
|
700
|
-
onClick={() =>
|
|
841
|
+
onClick={() => toggleDock('design')}
|
|
701
842
|
className={cn(
|
|
702
843
|
'flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs transition-colors hover:bg-accent',
|
|
703
844
|
designOpen && 'bg-accent',
|
|
@@ -713,6 +854,66 @@ export function Doc() {
|
|
|
713
854
|
</kbd>
|
|
714
855
|
</button>
|
|
715
856
|
)}
|
|
857
|
+
{import.meta.env.DEV && (
|
|
858
|
+
<button
|
|
859
|
+
type="button"
|
|
860
|
+
aria-pressed={changesOpen}
|
|
861
|
+
aria-label={
|
|
862
|
+
changeItems.length > 0
|
|
863
|
+
? t('Changes ({count})', { count: changeItems.length })
|
|
864
|
+
: t('Changes')
|
|
865
|
+
}
|
|
866
|
+
aria-keyshortcuts="C"
|
|
867
|
+
title={`${t('Changes since the last commit')} (C)`}
|
|
868
|
+
onClick={() => toggleDock('changes')}
|
|
869
|
+
className={cn(
|
|
870
|
+
'flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs transition-colors hover:bg-accent',
|
|
871
|
+
changesOpen && 'bg-accent',
|
|
872
|
+
)}
|
|
873
|
+
>
|
|
874
|
+
<GitCompare className="size-3.5" />
|
|
875
|
+
<span className="hidden lg:inline">{t('Changes')}</span>
|
|
876
|
+
{changeItems.length > 0 && (
|
|
877
|
+
<span
|
|
878
|
+
aria-hidden
|
|
879
|
+
className="min-w-4 rounded-full px-1 text-center font-mono text-[10px] text-background tabular-nums"
|
|
880
|
+
style={{ background: 'var(--change-changed)' }}
|
|
881
|
+
>
|
|
882
|
+
{changeItems.length}
|
|
883
|
+
</span>
|
|
884
|
+
)}
|
|
885
|
+
</button>
|
|
886
|
+
)}
|
|
887
|
+
{import.meta.env.DEV && (
|
|
888
|
+
<button
|
|
889
|
+
type="button"
|
|
890
|
+
aria-pressed={commentsOpen}
|
|
891
|
+
aria-label={
|
|
892
|
+
commentList.length > 0
|
|
893
|
+
? t('Comments ({count})', { count: commentList.length })
|
|
894
|
+
: t('Comments')
|
|
895
|
+
}
|
|
896
|
+
aria-keyshortcuts="M"
|
|
897
|
+
title={`${t('Comments')} (M)`}
|
|
898
|
+
onClick={() => toggleDock('comments')}
|
|
899
|
+
className={cn(
|
|
900
|
+
'flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs transition-colors hover:bg-accent',
|
|
901
|
+
commentsOpen && 'bg-accent',
|
|
902
|
+
)}
|
|
903
|
+
>
|
|
904
|
+
<MessageSquare className="size-3.5" />
|
|
905
|
+
<span className="hidden lg:inline">{t('Comments')}</span>
|
|
906
|
+
{commentList.length > 0 && (
|
|
907
|
+
<span
|
|
908
|
+
aria-hidden
|
|
909
|
+
className="min-w-4 rounded-full px-1 text-center font-mono text-[10px] text-white tabular-nums"
|
|
910
|
+
style={{ background: 'var(--comment-pin)' }}
|
|
911
|
+
>
|
|
912
|
+
{commentList.length}
|
|
913
|
+
</span>
|
|
914
|
+
)}
|
|
915
|
+
</button>
|
|
916
|
+
)}
|
|
716
917
|
|
|
717
918
|
<CopyLink />
|
|
718
919
|
|
|
@@ -794,11 +995,14 @@ export function Doc() {
|
|
|
794
995
|
pages={pages}
|
|
795
996
|
geometry={geometry}
|
|
796
997
|
design={doc.design}
|
|
998
|
+
lang={pageLang(doc.meta)}
|
|
797
999
|
currentPage={currentPage}
|
|
798
1000
|
entries={outline}
|
|
799
1001
|
activeId={activeOutlineId}
|
|
800
1002
|
onSelectPage={scrollToPage}
|
|
801
1003
|
onSelectEntry={scrollToEntry}
|
|
1004
|
+
{...(changesOpen ? { changedPages } : {})}
|
|
1005
|
+
{...(commentsOpen ? { commentPages } : {})}
|
|
802
1006
|
/>
|
|
803
1007
|
<div className="relative flex min-w-0 flex-1">
|
|
804
1008
|
<div
|
|
@@ -836,12 +1040,28 @@ export function Doc() {
|
|
|
836
1040
|
geometry={geometry}
|
|
837
1041
|
scale={scale}
|
|
838
1042
|
design={doc.design}
|
|
1043
|
+
lang={pageLang(doc.meta)}
|
|
1044
|
+
watermark={doc.meta?.watermark}
|
|
839
1045
|
>
|
|
840
1046
|
{page.content}
|
|
841
1047
|
</PageFrame>
|
|
842
1048
|
))}
|
|
843
1049
|
</div>
|
|
844
1050
|
</div>
|
|
1051
|
+
{commentsOpen && scrollRef.current && (
|
|
1052
|
+
<CommentsOverlay
|
|
1053
|
+
container={scrollRef.current}
|
|
1054
|
+
comments={commentList}
|
|
1055
|
+
activeId={activeComment}
|
|
1056
|
+
/>
|
|
1057
|
+
)}
|
|
1058
|
+
{changesOpen && scrollRef.current && (
|
|
1059
|
+
<ChangesOverlay
|
|
1060
|
+
container={scrollRef.current}
|
|
1061
|
+
items={changeItems}
|
|
1062
|
+
activeId={activeChange}
|
|
1063
|
+
/>
|
|
1064
|
+
)}
|
|
845
1065
|
{import.meta.env.DEV && docId && (
|
|
846
1066
|
<EditSaveCard
|
|
847
1067
|
textCount={textPending}
|
|
@@ -858,8 +1078,11 @@ export function Doc() {
|
|
|
858
1078
|
key={docId}
|
|
859
1079
|
docId={docId}
|
|
860
1080
|
containerRef={scrollRef}
|
|
861
|
-
panelHidden={
|
|
862
|
-
onPick={
|
|
1081
|
+
panelHidden={dock !== null}
|
|
1082
|
+
onPick={pickElement}
|
|
1083
|
+
commentFirst={commentFirst}
|
|
1084
|
+
picking={picking}
|
|
1085
|
+
onCancelPick={cancelPick}
|
|
863
1086
|
quiet={cardShown}
|
|
864
1087
|
onExit={() => setEditing(false)}
|
|
865
1088
|
exitRef={leaveEditRef}
|
|
@@ -867,7 +1090,46 @@ export function Doc() {
|
|
|
867
1090
|
onPendingChange={setTextPending}
|
|
868
1091
|
/>
|
|
869
1092
|
)}
|
|
870
|
-
{designOpen && <DesignPanel onClose={
|
|
1093
|
+
{designOpen && <DesignPanel onClose={closeDock} />}
|
|
1094
|
+
{commentsOpen && docId && (
|
|
1095
|
+
<CommentsPanel
|
|
1096
|
+
docId={docId}
|
|
1097
|
+
state={comments.state}
|
|
1098
|
+
placement={commentPlacement}
|
|
1099
|
+
excerpts={
|
|
1100
|
+
new Map(
|
|
1101
|
+
commentList.map((comment) => {
|
|
1102
|
+
const el =
|
|
1103
|
+
scrollRef.current && comment.loc
|
|
1104
|
+
? elementsAtLoc(scrollRef.current, comment.loc)[0]
|
|
1105
|
+
: undefined;
|
|
1106
|
+
const text = (el?.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
1107
|
+
return [comment.id, text.length > 90 ? `${text.slice(0, 89)}…` : text];
|
|
1108
|
+
}),
|
|
1109
|
+
)
|
|
1110
|
+
}
|
|
1111
|
+
activeId={activeComment}
|
|
1112
|
+
onSelect={selectComment}
|
|
1113
|
+
onResolve={comments.resolve}
|
|
1114
|
+
onNew={startComment}
|
|
1115
|
+
picking={picking}
|
|
1116
|
+
onClose={closeDock}
|
|
1117
|
+
/>
|
|
1118
|
+
)}
|
|
1119
|
+
{changesOpen && (
|
|
1120
|
+
<ChangesPanel
|
|
1121
|
+
state={changes.state}
|
|
1122
|
+
items={changeItems}
|
|
1123
|
+
placement={placement}
|
|
1124
|
+
since={changes.since}
|
|
1125
|
+
revisions={changes.revisions}
|
|
1126
|
+
activeId={activeChange}
|
|
1127
|
+
onSince={changes.setSince}
|
|
1128
|
+
onSelect={selectChange}
|
|
1129
|
+
onRevert={changes.revert}
|
|
1130
|
+
onClose={closeDock}
|
|
1131
|
+
/>
|
|
1132
|
+
)}
|
|
871
1133
|
</div>
|
|
872
1134
|
</div>
|
|
873
1135
|
</CommandPaletteProvider>
|
package/src/app/routes/home.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
MoreHorizontal,
|
|
13
13
|
Palette,
|
|
14
14
|
PencilLine,
|
|
15
|
+
Plus,
|
|
15
16
|
Search,
|
|
16
17
|
Trash2,
|
|
17
18
|
} from 'lucide-react';
|
|
@@ -21,9 +22,11 @@ import {
|
|
|
21
22
|
CARD_GRID,
|
|
22
23
|
CardText,
|
|
23
24
|
EmptyState,
|
|
25
|
+
fitInCard,
|
|
24
26
|
PageHeader,
|
|
25
27
|
useCardWidth,
|
|
26
28
|
} from '../components/browser/browser-ui';
|
|
29
|
+
import { NewDocumentDialog } from '../components/browser/new-document-dialog';
|
|
27
30
|
import { PageFrame } from '../components/page-frame';
|
|
28
31
|
import { DOC_DND_MIME } from '../components/sidebar/folder-item';
|
|
29
32
|
import { ALL_DOCS_ID, DRAFT_ID } from '../components/sidebar/sidebar';
|
|
@@ -31,7 +34,7 @@ import { Menu, MenuItem, MenuSeparator } from '../components/ui/menu';
|
|
|
31
34
|
import { coverContent } from '../lib/doc-preview';
|
|
32
35
|
import { docCreatedAt, docIds, docThemes, docTitles } from '../lib/docs';
|
|
33
36
|
import { type Translate, useLocale, useT } from '../lib/i18n';
|
|
34
|
-
import { resolvePageGeometry } from '../lib/sdk';
|
|
37
|
+
import { pageLang, resolvePageGeometry } from '../lib/sdk';
|
|
35
38
|
import { findTheme } from '../lib/themes';
|
|
36
39
|
import { useDocModule } from '../lib/use-doc-module';
|
|
37
40
|
import type { HomeOutletContext } from './home-shell';
|
|
@@ -92,6 +95,19 @@ export function Home() {
|
|
|
92
95
|
const [error, setError] = useState<string | null>(null);
|
|
93
96
|
const [sort, setSortState] = useState<SortKey>(readSort);
|
|
94
97
|
const [filter, setFilter] = useState('');
|
|
98
|
+
const [creating, setCreating] = useState(false);
|
|
99
|
+
const inFolder =
|
|
100
|
+
ctx.selectedId !== ALL_DOCS_ID && ctx.selectedId !== DRAFT_ID ? ctx.selectedId : null;
|
|
101
|
+
const newButton = import.meta.env.DEV && (
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
onClick={() => setCreating(true)}
|
|
105
|
+
className="flex h-8 items-center gap-1.5 rounded-md bg-primary px-2.5 text-primary-foreground text-xs transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/60"
|
|
106
|
+
>
|
|
107
|
+
<Plus className="size-3.5" />
|
|
108
|
+
{t('New document')}
|
|
109
|
+
</button>
|
|
110
|
+
);
|
|
95
111
|
|
|
96
112
|
const setSort = (next: SortKey) => {
|
|
97
113
|
setSortState(next);
|
|
@@ -134,7 +150,7 @@ export function Home() {
|
|
|
134
150
|
}
|
|
135
151
|
count={sourceIds.length}
|
|
136
152
|
actions={
|
|
137
|
-
sourceIds.length > 0
|
|
153
|
+
sourceIds.length > 0 ? (
|
|
138
154
|
<>
|
|
139
155
|
<Menu
|
|
140
156
|
placement="bottom-end"
|
|
@@ -179,7 +195,10 @@ export function Home() {
|
|
|
179
195
|
className="min-w-0 flex-1 bg-transparent outline-none placeholder:text-muted-foreground"
|
|
180
196
|
/>
|
|
181
197
|
</label>
|
|
198
|
+
{newButton}
|
|
182
199
|
</>
|
|
200
|
+
) : (
|
|
201
|
+
newButton
|
|
183
202
|
)
|
|
184
203
|
}
|
|
185
204
|
>
|
|
@@ -202,6 +221,7 @@ export function Home() {
|
|
|
202
221
|
{ctx.selectedId === ALL_DOCS_ID
|
|
203
222
|
? t('Ask your agent to write a document, and it appears here.')
|
|
204
223
|
: t('Drag a document onto this folder, or use Move to on its card.')}
|
|
224
|
+
{newButton && <div className="mt-4 flex justify-center">{newButton}</div>}
|
|
205
225
|
</EmptyState>
|
|
206
226
|
) : (
|
|
207
227
|
<div className={CARD_GRID}>
|
|
@@ -210,6 +230,9 @@ export function Home() {
|
|
|
210
230
|
))}
|
|
211
231
|
</div>
|
|
212
232
|
)}
|
|
233
|
+
{import.meta.env.DEV && (
|
|
234
|
+
<NewDocumentDialog open={creating} folderId={inFolder} onClose={() => setCreating(false)} />
|
|
235
|
+
)}
|
|
213
236
|
</div>
|
|
214
237
|
);
|
|
215
238
|
}
|
|
@@ -230,7 +253,7 @@ function DocCard({
|
|
|
230
253
|
const state = useDocModule(docId);
|
|
231
254
|
const doc = state.doc;
|
|
232
255
|
const geometry = resolvePageGeometry(doc?.meta);
|
|
233
|
-
const scale = cardWidth
|
|
256
|
+
const { frameHeight, scale } = fitInCard(cardWidth, geometry);
|
|
234
257
|
const cover = coverContent(doc);
|
|
235
258
|
const theme = findTheme(docThemes[docId]);
|
|
236
259
|
const title = doc?.meta?.title ?? docId;
|
|
@@ -259,8 +282,9 @@ function DocCard({
|
|
|
259
282
|
>
|
|
260
283
|
<Link to={`/d/${docId}`}>
|
|
261
284
|
<div
|
|
262
|
-
|
|
263
|
-
|
|
285
|
+
data-od-card-frame
|
|
286
|
+
className="flex items-center justify-center overflow-hidden rounded-md bg-canvas ring-1 ring-border transition-shadow group-hover:shadow-lg"
|
|
287
|
+
style={{ width: cardWidth, height: frameHeight }}
|
|
264
288
|
>
|
|
265
289
|
{cover ? (
|
|
266
290
|
<PageFrame
|
|
@@ -269,6 +293,7 @@ function DocCard({
|
|
|
269
293
|
geometry={geometry}
|
|
270
294
|
scale={scale}
|
|
271
295
|
design={doc?.design}
|
|
296
|
+
lang={pageLang(doc?.meta)}
|
|
272
297
|
flat
|
|
273
298
|
>
|
|
274
299
|
{cover}
|
package/src/app/styles.css
CHANGED
|
@@ -35,6 +35,13 @@
|
|
|
35
35
|
--primary: oklch(0.185 0 0);
|
|
36
36
|
--primary-foreground: oklch(0.985 0 0);
|
|
37
37
|
--border: oklch(0.9 0 0);
|
|
38
|
+
/* Changes since a revision: added, rewritten, taken out. They mark the
|
|
39
|
+
paper as well as the chrome, so they stay readable on white either way. */
|
|
40
|
+
--change-added: oklch(0.58 0.15 150);
|
|
41
|
+
--change-changed: oklch(0.68 0.15 70);
|
|
42
|
+
--change-removed: oklch(0.58 0.2 25);
|
|
43
|
+
/* A reviewer's note pinned to the page. */
|
|
44
|
+
--comment-pin: oklch(0.55 0.19 265);
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
.dark {
|
|
@@ -49,6 +56,10 @@
|
|
|
49
56
|
--primary: oklch(0.97 0 0);
|
|
50
57
|
--primary-foreground: oklch(0.16 0 0);
|
|
51
58
|
--border: oklch(0.28 0 0);
|
|
59
|
+
--change-added: oklch(0.7 0.15 150);
|
|
60
|
+
--change-changed: oklch(0.78 0.14 75);
|
|
61
|
+
--change-removed: oklch(0.68 0.19 25);
|
|
62
|
+
--comment-pin: oklch(0.68 0.16 265);
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
/* The dock's content arrives from the edge it docks against. Opacity only
|
|
@@ -123,6 +134,18 @@
|
|
|
123
134
|
font-size: var(--od-size-body, 14px);
|
|
124
135
|
line-height: var(--od-leading, 1.55);
|
|
125
136
|
color: var(--od-text, #16181d);
|
|
137
|
+
/* Chinese, Japanese and Korean set as they are meant to be: no closing
|
|
138
|
+
* punctuation or small kana at the start of a line (kinsoku), and an
|
|
139
|
+
* eighth of an em between a CJK character and a Latin letter or digit
|
|
140
|
+
* where the author left no space. Both do nothing to text in other
|
|
141
|
+
* scripts. They need the sheet's `lang` (meta.lang) to pick the right
|
|
142
|
+
* rules and glyphs. */
|
|
143
|
+
line-break: strict;
|
|
144
|
+
text-autospace: normal;
|
|
145
|
+
}
|
|
146
|
+
/* Japanese headings break between phrases, not inside a word. */
|
|
147
|
+
:is([data-od-page], [data-od-measure]) :where(h1, h2, h3, h4, h5, h6):lang(ja) {
|
|
148
|
+
word-break: auto-phrase;
|
|
126
149
|
}
|
|
127
150
|
:is([data-od-page], [data-od-measure]) :where(h1, h2, h3, h4, h5, h6) {
|
|
128
151
|
font-family: var(
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DesignSystem,
|
|
3
|
+
type DocEntry,
|
|
4
|
+
type DocMeta,
|
|
5
|
+
flow,
|
|
6
|
+
useDocPageCount,
|
|
7
|
+
useDocPageNumber,
|
|
8
|
+
} from '@open-document/core';
|
|
9
|
+
import type { CSSProperties } from 'react';
|
|
10
|
+
|
|
11
|
+
export const meta: DocMeta = {
|
|
12
|
+
title: 'Untitled document',
|
|
13
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const design: DesignSystem = {
|
|
17
|
+
palette: {
|
|
18
|
+
bg: '#ffffff',
|
|
19
|
+
text: '#16181d',
|
|
20
|
+
muted: '#6b7280',
|
|
21
|
+
accent: '#1d4ed8',
|
|
22
|
+
rule: '#e4e7ec',
|
|
23
|
+
},
|
|
24
|
+
fonts: {
|
|
25
|
+
heading: '-apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',
|
|
26
|
+
body: '-apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',
|
|
27
|
+
mono: 'ui-monospace, "SF Mono", Menlo, monospace',
|
|
28
|
+
},
|
|
29
|
+
typeScale: { title: 40, h1: 24, h2: 17, h3: 14, body: 12.5, caption: 10 },
|
|
30
|
+
margin: 72,
|
|
31
|
+
leading: 1.6,
|
|
32
|
+
radius: 6,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const h1: CSSProperties = { fontSize: 'var(--od-size-h1)', fontWeight: 650, margin: '0 0 12px' };
|
|
36
|
+
const p: CSSProperties = { margin: '0 0 10px' };
|
|
37
|
+
|
|
38
|
+
const Footer = () => (
|
|
39
|
+
<div
|
|
40
|
+
style={{
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
left: 'var(--od-margin)',
|
|
43
|
+
right: 'var(--od-margin)',
|
|
44
|
+
bottom: 36,
|
|
45
|
+
textAlign: 'right',
|
|
46
|
+
fontSize: 'var(--od-size-caption)',
|
|
47
|
+
color: 'var(--od-muted)',
|
|
48
|
+
fontVariantNumeric: 'tabular-nums',
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{useDocPageNumber()} / {useDocPageCount()}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const Body = flow(
|
|
56
|
+
<>
|
|
57
|
+
<h1 style={h1}>Untitled document</h1>
|
|
58
|
+
<p style={p}>Start writing here.</p>
|
|
59
|
+
</>,
|
|
60
|
+
{ footer: Footer },
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export default [Body] satisfies DocEntry[];
|