@open-document/core 0.16.0 → 0.17.1
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-BS_CoazO.js → build-C7nHUUXO.js} +1 -1
- package/dist/{check-tTjyMCrU.js → check--Cbkdqw3.js} +11 -4
- package/dist/cli/bin.js +25 -12
- package/dist/{context-Cli81dhF.js → context-DRXgt6Je.js} +2 -2
- package/dist/{deploy-gcp-BUiSuqz7.js → deploy-gcp-bbxQT0gf.js} +1 -1
- package/dist/{dev-n222xdoE.js → dev-D_j2ykSa.js} +1 -1
- package/dist/{diff-DB_qruzT.js → diff-C1RDK_I5.js} +2 -2
- package/dist/{export-CCFtdscQ.js → export-BFxKPa0W.js} +3 -3
- package/dist/{flow-CS5apebG.d.ts → flow-DlV3t5ML.d.ts} +24 -4
- package/dist/{import-D7k0yYZh.js → import-TLuMXkou.js} +11 -7
- package/dist/index.d.ts +26 -2
- package/dist/index.js +55 -1
- package/dist/{open-doc-plugin-DnX5usgI.js → open-doc-plugin-DE1sJXK_.js} +3 -2
- package/dist/ops/index.d.ts +138 -4
- package/dist/ops/index.js +3 -3
- package/dist/{ops-CouYBa1O.js → ops-BG9hfBwQ.js} +197 -9
- package/dist/{preview-DV0GDIsj.js → preview-rlMPuRZV.js} +1 -1
- package/dist/proofread-Dtj9OlWX.js +35 -0
- package/dist/{session-Cx7Msl_F.js → session-CPFLe6BT.js} +5148 -69
- package/dist/{templates-C-7VcMMV.js → templates-BmSuBmj3.js} +3 -3
- package/dist/translations-BmTXOhx9.js +42 -0
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
- package/skills/doc-authoring/references/pagination.md +1 -1
- package/skills/fill-form/SKILL.md +42 -0
- package/skills/fit-pages/SKILL.md +48 -0
- package/skills/import-document/SKILL.md +58 -0
- package/skills/proofread/SKILL.md +44 -0
- package/skills/refresh-report/SKILL.md +48 -0
- package/skills/sync-translation/SKILL.md +55 -0
- package/src/agent/prompt.ts +1 -1
- package/src/app/components/agent/agent-dock.tsx +1 -1
- package/src/app/components/browser/browser-ui.tsx +8 -2
- package/src/app/components/checkbox.tsx +68 -0
- package/src/app/components/doc-sidebar.tsx +5 -3
- package/src/app/components/flow-page.tsx +7 -2
- package/src/app/components/panel/edit-save-card.tsx +3 -0
- package/src/app/components/panel/panel-shell.tsx +3 -1
- package/src/app/components/sidebar/sidebar.tsx +2 -1
- package/src/app/lib/agent-bridge.ts +37 -4
- package/src/app/lib/diagnostics.ts +46 -5
- package/src/app/lib/export-docx.ts +5 -2
- package/src/app/lib/export-dom.ts +13 -0
- package/src/app/lib/export-html.ts +6 -1
- package/src/app/lib/export-image.ts +9 -4
- package/src/app/lib/export-pdf.ts +17 -4
- package/src/app/lib/flow-measure.ts +9 -5
- package/src/app/lib/flow.ts +3 -2
- package/src/app/lib/i18n-ja/browser.ts +1 -0
- package/src/app/lib/i18n-ja/doc.ts +1 -0
- package/src/app/lib/i18n-ko/browser.ts +1 -0
- package/src/app/lib/i18n-ko/doc.ts +1 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +1 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +1 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +1 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +1 -0
- package/src/app/lib/page-budget.ts +81 -0
- package/src/app/lib/proofread-script.ts +61 -0
- package/src/app/lib/proofread.ts +399 -0
- package/src/app/lib/recent-docs.ts +27 -0
- package/src/app/lib/sdk.ts +44 -2
- package/src/app/lib/text-runs.ts +83 -0
- package/src/app/lib/use-doc-pages.ts +10 -3
- package/src/app/routes/doc-preview.tsx +1 -1
- package/src/app/routes/doc.tsx +190 -54
- package/src/app/routes/home.tsx +50 -12
- package/src/app/virtual.d.ts +1 -1
package/src/app/routes/doc.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Check,
|
|
7
7
|
ChevronDown,
|
|
8
8
|
Download,
|
|
9
|
+
Ellipsis,
|
|
9
10
|
Eye,
|
|
10
11
|
FileCode2,
|
|
11
12
|
FileImage,
|
|
@@ -78,6 +79,7 @@ import {
|
|
|
78
79
|
resolveSelection,
|
|
79
80
|
} from '../lib/page-range';
|
|
80
81
|
import { nextFrame, waitForFonts } from '../lib/print-ready';
|
|
82
|
+
import { markDocOpened } from '../lib/recent-docs';
|
|
81
83
|
import { getRecordState, setRecords, useRecordIndex } from '../lib/records';
|
|
82
84
|
import { scanDocument } from '../lib/scan';
|
|
83
85
|
import { pageLang, resolvePageGeometry } from '../lib/sdk';
|
|
@@ -214,7 +216,7 @@ export function Doc() {
|
|
|
214
216
|
const state = useDocModule(docId);
|
|
215
217
|
const doc = state.doc;
|
|
216
218
|
const t = useT();
|
|
217
|
-
const { setLocale } = useLocale();
|
|
219
|
+
const { locale, setLocale } = useLocale();
|
|
218
220
|
|
|
219
221
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
220
222
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
@@ -262,6 +264,7 @@ export function Doc() {
|
|
|
262
264
|
const editControlsRef = useRef<InspectorControls | null>(null);
|
|
263
265
|
const [textPending, setTextPending] = useState(0);
|
|
264
266
|
const [cardShown, setCardShown] = useState(false);
|
|
267
|
+
const [unsaved, setUnsaved] = useState(false);
|
|
265
268
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
266
269
|
const [viewMode, setViewModeState] = useState<ViewMode>(() => readViewMode(docId));
|
|
267
270
|
// The page the reader was on when the layout changed, to put back in view.
|
|
@@ -281,6 +284,27 @@ export function Doc() {
|
|
|
281
284
|
useEffect(() => () => setRecords(undefined), []);
|
|
282
285
|
|
|
283
286
|
const { pages, measuring, overflowing } = useDocPages(doc, geometry);
|
|
287
|
+
|
|
288
|
+
const loaded = Boolean(doc);
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
if (loaded && docId) markDocOpened(docId);
|
|
291
|
+
}, [loaded, docId]);
|
|
292
|
+
|
|
293
|
+
const docTitle = doc ? (doc.meta?.title ?? docId) : undefined;
|
|
294
|
+
const showPage = pages.length > 1 && !measuring;
|
|
295
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `t` keeps one identity across languages, so `locale` re-runs it
|
|
296
|
+
useEffect(() => {
|
|
297
|
+
if (!docTitle) return;
|
|
298
|
+
const page = showPage ? ` · ${t('p. {page}', { page: currentPage })}` : '';
|
|
299
|
+
document.title = `${unsaved ? '● ' : ''}${docTitle}${page}`;
|
|
300
|
+
}, [docTitle, showPage, currentPage, unsaved, t, locale]);
|
|
301
|
+
useEffect(
|
|
302
|
+
() => () => {
|
|
303
|
+
document.title = 'open-doc';
|
|
304
|
+
},
|
|
305
|
+
[],
|
|
306
|
+
);
|
|
307
|
+
|
|
284
308
|
const recordIndex = useRecordIndex();
|
|
285
309
|
|
|
286
310
|
// Read again on every reload of the document, so what an agent just wrote
|
|
@@ -823,9 +847,13 @@ export function Doc() {
|
|
|
823
847
|
(page, zoom, layout, fullscreen), and what you do to the document
|
|
824
848
|
(search, edit, design, download). The middle rail is `auto` between
|
|
825
849
|
two equal `1fr` rails, so it sits at the true centre of the bar while
|
|
826
|
-
the title truncates before anything is overlapped.
|
|
827
|
-
|
|
828
|
-
|
|
850
|
+
the title truncates before anything is overlapped. Below xl the bar is
|
|
851
|
+
a plain row: the title takes what is left, the view controls drop out
|
|
852
|
+
by width (zoom and layout below lg, the page counter below sm), labels
|
|
853
|
+
fold to icons, and below sm Changes, Comments and Copy link move into
|
|
854
|
+
a More menu, so nothing is pushed off the edge. */}
|
|
855
|
+
<header className="flex h-12 flex-none items-center gap-2 border-b border-border px-3 xl:grid xl:grid-cols-[1fr_auto_1fr] xl:gap-3">
|
|
856
|
+
<div className="flex min-w-0 flex-1 items-center gap-1">
|
|
829
857
|
<HeaderBackLink />
|
|
830
858
|
<h1 className="truncate font-medium text-sm">{doc.meta?.title ?? docId}</h1>
|
|
831
859
|
{doc.records && doc.records.length > 0 && (
|
|
@@ -833,50 +861,56 @@ export function Doc() {
|
|
|
833
861
|
)}
|
|
834
862
|
</div>
|
|
835
863
|
|
|
836
|
-
<div className="hidden items-center gap-2 sm:flex">
|
|
864
|
+
<div className="hidden flex-none items-center gap-2 sm:flex">
|
|
837
865
|
<PageJump page={currentPage} total={pages.length} onJump={scrollToPage} />
|
|
838
|
-
<
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
<
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
866
|
+
<div className="hidden items-center gap-2 lg:flex">
|
|
867
|
+
<Divider />
|
|
868
|
+
<ZoomControl
|
|
869
|
+
scale={scale}
|
|
870
|
+
fit={manualScale === null ? zoomMode : null}
|
|
871
|
+
onStep={zoom}
|
|
872
|
+
onSet={setZoom}
|
|
873
|
+
onFit={fitTo}
|
|
874
|
+
/>
|
|
875
|
+
<Divider />
|
|
876
|
+
<fieldset className="flex items-center gap-0.5">
|
|
877
|
+
<legend className="sr-only">{t('Page layout')}</legend>
|
|
878
|
+
<IconButton
|
|
879
|
+
label={t('Continuous')}
|
|
880
|
+
active={viewMode === 'continuous'}
|
|
881
|
+
onClick={() => setViewMode('continuous')}
|
|
882
|
+
>
|
|
883
|
+
<Rows3 className="size-3.5" />
|
|
884
|
+
</IconButton>
|
|
885
|
+
<IconButton
|
|
886
|
+
label={t('Two-up')}
|
|
887
|
+
active={viewMode === 'spread'}
|
|
888
|
+
onClick={() => setViewMode('spread')}
|
|
889
|
+
>
|
|
890
|
+
<BookOpen className="size-3.5" />
|
|
891
|
+
</IconButton>
|
|
892
|
+
<IconButton
|
|
893
|
+
label={t('Grid')}
|
|
894
|
+
active={viewMode === 'grid'}
|
|
895
|
+
onClick={() => setViewMode('grid')}
|
|
896
|
+
>
|
|
897
|
+
<LayoutGrid className="size-3.5" />
|
|
898
|
+
</IconButton>
|
|
899
|
+
</fieldset>
|
|
863
900
|
<IconButton
|
|
864
|
-
label={t('
|
|
865
|
-
|
|
866
|
-
onClick={() => setViewMode('grid')}
|
|
901
|
+
label={isFullscreen ? t('Exit fullscreen (F)') : t('Fullscreen (F)')}
|
|
902
|
+
onClick={toggleFullscreen}
|
|
867
903
|
>
|
|
868
|
-
|
|
904
|
+
{isFullscreen ? (
|
|
905
|
+
<Minimize className="size-3.5" />
|
|
906
|
+
) : (
|
|
907
|
+
<Maximize className="size-3.5" />
|
|
908
|
+
)}
|
|
869
909
|
</IconButton>
|
|
870
|
-
</
|
|
871
|
-
<IconButton
|
|
872
|
-
label={isFullscreen ? t('Exit fullscreen (F)') : t('Fullscreen (F)')}
|
|
873
|
-
onClick={toggleFullscreen}
|
|
874
|
-
>
|
|
875
|
-
{isFullscreen ? <Minimize className="size-3.5" /> : <Maximize className="size-3.5" />}
|
|
876
|
-
</IconButton>
|
|
910
|
+
</div>
|
|
877
911
|
</div>
|
|
878
912
|
|
|
879
|
-
<div className="flex items-center justify-end gap-2">
|
|
913
|
+
<div className="flex flex-none items-center justify-end gap-1.5 sm:gap-2">
|
|
880
914
|
<DocSearch scrollRef={scrollRef} pagesRef={pagesRef} onFoundPage={setCurrentPage} />
|
|
881
915
|
|
|
882
916
|
{import.meta.env.DEV && (
|
|
@@ -912,10 +946,10 @@ export function Doc() {
|
|
|
912
946
|
)}
|
|
913
947
|
>
|
|
914
948
|
<Palette className="size-3.5" />
|
|
915
|
-
{t('Design')}
|
|
949
|
+
<span className="hidden lg:inline">{t('Design')}</span>
|
|
916
950
|
<kbd
|
|
917
951
|
aria-hidden
|
|
918
|
-
className="hidden rounded-sm bg-foreground/10 px-1 font-mono text-[9.5px] text-muted-foreground
|
|
952
|
+
className="hidden rounded-sm bg-foreground/10 px-1 font-mono text-[9.5px] text-muted-foreground lg:inline"
|
|
919
953
|
>
|
|
920
954
|
D
|
|
921
955
|
</kbd>
|
|
@@ -934,12 +968,12 @@ export function Doc() {
|
|
|
934
968
|
title={`${t('Changes since the last commit')} (C)`}
|
|
935
969
|
onClick={() => toggleDock('changes')}
|
|
936
970
|
className={cn(
|
|
937
|
-
'
|
|
971
|
+
'hidden flex-none sm:flex items-center gap-1.5 whitespace-nowrap rounded-md border border-border px-2.5 py-1.5 text-xs transition-colors hover:bg-accent',
|
|
938
972
|
changesOpen && 'bg-accent',
|
|
939
973
|
)}
|
|
940
974
|
>
|
|
941
975
|
<GitCompare className="size-3.5" />
|
|
942
|
-
<span className="hidden
|
|
976
|
+
<span className="hidden xl:inline">{t('Changes')}</span>
|
|
943
977
|
{changeItems.length > 0 && (
|
|
944
978
|
<span
|
|
945
979
|
aria-hidden
|
|
@@ -964,12 +998,12 @@ export function Doc() {
|
|
|
964
998
|
title={`${t('Comments')} (M)`}
|
|
965
999
|
onClick={() => toggleDock('comments')}
|
|
966
1000
|
className={cn(
|
|
967
|
-
'
|
|
1001
|
+
'hidden flex-none sm:flex items-center gap-1.5 whitespace-nowrap rounded-md border border-border px-2.5 py-1.5 text-xs transition-colors hover:bg-accent',
|
|
968
1002
|
commentsOpen && 'bg-accent',
|
|
969
1003
|
)}
|
|
970
1004
|
>
|
|
971
1005
|
<MessageSquare className="size-3.5" />
|
|
972
|
-
<span className="hidden
|
|
1006
|
+
<span className="hidden xl:inline">{t('Comments')}</span>
|
|
973
1007
|
{commentList.length > 0 && (
|
|
974
1008
|
<span
|
|
975
1009
|
aria-hidden
|
|
@@ -1000,7 +1034,29 @@ export function Doc() {
|
|
|
1000
1034
|
</button>
|
|
1001
1035
|
)}
|
|
1002
1036
|
|
|
1003
|
-
<
|
|
1037
|
+
<div className="hidden sm:contents">
|
|
1038
|
+
<CopyLink />
|
|
1039
|
+
</div>
|
|
1040
|
+
<MoreMenu
|
|
1041
|
+
changes={
|
|
1042
|
+
import.meta.env.DEV
|
|
1043
|
+
? {
|
|
1044
|
+
open: changesOpen,
|
|
1045
|
+
count: changeItems.length,
|
|
1046
|
+
toggle: () => toggleDock('changes'),
|
|
1047
|
+
}
|
|
1048
|
+
: null
|
|
1049
|
+
}
|
|
1050
|
+
comments={
|
|
1051
|
+
import.meta.env.DEV
|
|
1052
|
+
? {
|
|
1053
|
+
open: commentsOpen,
|
|
1054
|
+
count: commentList.length,
|
|
1055
|
+
toggle: () => toggleDock('comments'),
|
|
1056
|
+
}
|
|
1057
|
+
: null
|
|
1058
|
+
}
|
|
1059
|
+
/>
|
|
1004
1060
|
|
|
1005
1061
|
{/* The document browser normally carries this. A viewer mounted with
|
|
1006
1062
|
`showDocBrowser: false` never shows that shell, and without it a
|
|
@@ -1013,6 +1069,8 @@ export function Doc() {
|
|
|
1013
1069
|
<button
|
|
1014
1070
|
type="button"
|
|
1015
1071
|
disabled={download !== null}
|
|
1072
|
+
aria-label={download ? undefined : t('Download')}
|
|
1073
|
+
title={t('Download')}
|
|
1016
1074
|
className="flex flex-none items-center gap-1.5 whitespace-nowrap rounded-md bg-primary px-2.5 py-1.5 text-primary-foreground text-xs transition-opacity hover:opacity-90 disabled:opacity-70 aria-expanded:opacity-90"
|
|
1017
1075
|
{...props}
|
|
1018
1076
|
>
|
|
@@ -1023,9 +1081,11 @@ export function Doc() {
|
|
|
1023
1081
|
) : (
|
|
1024
1082
|
<Download className="size-3.5" />
|
|
1025
1083
|
)}
|
|
1026
|
-
{download
|
|
1027
|
-
|
|
1028
|
-
|
|
1084
|
+
{download ? (
|
|
1085
|
+
`${t(DOWNLOAD_LABEL[download.format])} ${Math.round(download.percent)}%`
|
|
1086
|
+
) : (
|
|
1087
|
+
<span className="hidden md:inline">{t('Download')}</span>
|
|
1088
|
+
)}
|
|
1029
1089
|
</button>
|
|
1030
1090
|
)}
|
|
1031
1091
|
>
|
|
@@ -1074,7 +1134,8 @@ export function Doc() {
|
|
|
1074
1134
|
</div>
|
|
1075
1135
|
</header>
|
|
1076
1136
|
|
|
1077
|
-
|
|
1137
|
+
{/* Positioned: below md the right dock floats over the pages from here. */}
|
|
1138
|
+
<div className="relative flex min-h-0 flex-1">
|
|
1078
1139
|
<DocSidebar
|
|
1079
1140
|
docId={docId ?? ''}
|
|
1080
1141
|
pages={pages}
|
|
@@ -1122,7 +1183,7 @@ export function Doc() {
|
|
|
1122
1183
|
key={page.key}
|
|
1123
1184
|
index={index}
|
|
1124
1185
|
total={pages.length}
|
|
1125
|
-
geometry={geometry}
|
|
1186
|
+
geometry={page.geometry ?? geometry}
|
|
1126
1187
|
scale={scale}
|
|
1127
1188
|
design={doc.design}
|
|
1128
1189
|
lang={pageLang(doc.meta)}
|
|
@@ -1152,6 +1213,7 @@ export function Doc() {
|
|
|
1152
1213
|
textCount={textPending}
|
|
1153
1214
|
controlsRef={editControlsRef}
|
|
1154
1215
|
onShownChange={setCardShown}
|
|
1216
|
+
onUnsavedChange={setUnsaved}
|
|
1155
1217
|
/>
|
|
1156
1218
|
)}
|
|
1157
1219
|
{agentActivity && (
|
|
@@ -1561,6 +1623,80 @@ function ZoomControl({
|
|
|
1561
1623
|
}
|
|
1562
1624
|
|
|
1563
1625
|
/** The page as it is — document, and the reader's place in it — on the clipboard. */
|
|
1626
|
+
type DockToggle = { open: boolean; count: number; toggle: () => void } | null;
|
|
1627
|
+
|
|
1628
|
+
/** Below sm the header has no room for Changes, Comments and Copy link; they live here. */
|
|
1629
|
+
function MoreMenu({ changes, comments }: { changes: DockToggle; comments: DockToggle }) {
|
|
1630
|
+
const t = useT();
|
|
1631
|
+
const item = 'size-4 flex-none text-muted-foreground';
|
|
1632
|
+
return (
|
|
1633
|
+
<div className="sm:hidden">
|
|
1634
|
+
<Menu
|
|
1635
|
+
className="w-48 p-1.5"
|
|
1636
|
+
trigger={(props) => (
|
|
1637
|
+
<button
|
|
1638
|
+
type="button"
|
|
1639
|
+
aria-label={t('More')}
|
|
1640
|
+
title={t('More')}
|
|
1641
|
+
className="flex size-8 flex-none items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground"
|
|
1642
|
+
{...props}
|
|
1643
|
+
>
|
|
1644
|
+
<Ellipsis className="size-4" />
|
|
1645
|
+
</button>
|
|
1646
|
+
)}
|
|
1647
|
+
>
|
|
1648
|
+
{(close) => (
|
|
1649
|
+
<>
|
|
1650
|
+
{changes && (
|
|
1651
|
+
<MenuItem
|
|
1652
|
+
active={changes.open}
|
|
1653
|
+
onClick={() => {
|
|
1654
|
+
close();
|
|
1655
|
+
changes.toggle();
|
|
1656
|
+
}}
|
|
1657
|
+
>
|
|
1658
|
+
<GitCompare className={item} />
|
|
1659
|
+
<span className="flex-1">{t('Changes')}</span>
|
|
1660
|
+
{changes.count > 0 && (
|
|
1661
|
+
<span className="font-mono text-[10px] text-muted-foreground tabular-nums">
|
|
1662
|
+
{changes.count}
|
|
1663
|
+
</span>
|
|
1664
|
+
)}
|
|
1665
|
+
</MenuItem>
|
|
1666
|
+
)}
|
|
1667
|
+
{comments && (
|
|
1668
|
+
<MenuItem
|
|
1669
|
+
active={comments.open}
|
|
1670
|
+
onClick={() => {
|
|
1671
|
+
close();
|
|
1672
|
+
comments.toggle();
|
|
1673
|
+
}}
|
|
1674
|
+
>
|
|
1675
|
+
<MessageSquare className={item} />
|
|
1676
|
+
<span className="flex-1">{t('Comments')}</span>
|
|
1677
|
+
{comments.count > 0 && (
|
|
1678
|
+
<span className="font-mono text-[10px] text-muted-foreground tabular-nums">
|
|
1679
|
+
{comments.count}
|
|
1680
|
+
</span>
|
|
1681
|
+
)}
|
|
1682
|
+
</MenuItem>
|
|
1683
|
+
)}
|
|
1684
|
+
<MenuItem
|
|
1685
|
+
onClick={() => {
|
|
1686
|
+
close();
|
|
1687
|
+
navigator.clipboard.writeText(window.location.href).catch(() => {});
|
|
1688
|
+
}}
|
|
1689
|
+
>
|
|
1690
|
+
<Link2 className={item} />
|
|
1691
|
+
<span className="flex-1">{t('Copy link')}</span>
|
|
1692
|
+
</MenuItem>
|
|
1693
|
+
</>
|
|
1694
|
+
)}
|
|
1695
|
+
</Menu>
|
|
1696
|
+
</div>
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1564
1700
|
function CopyLink() {
|
|
1565
1701
|
const t = useT();
|
|
1566
1702
|
const [copied, setCopied] = useState(false);
|
package/src/app/routes/home.tsx
CHANGED
|
@@ -37,6 +37,7 @@ import { useAgentStatus, useCreateDoc } from '../lib/agent/use-agent';
|
|
|
37
37
|
import { coverContent } from '../lib/doc-preview';
|
|
38
38
|
import { docCreatedAt, docIds, docThemes, docTitles } from '../lib/docs';
|
|
39
39
|
import { type Translate, useLocale, useT } from '../lib/i18n';
|
|
40
|
+
import { readRecentDocs, recentAmong } from '../lib/recent-docs';
|
|
40
41
|
import { pageLang, resolvePageGeometry } from '../lib/sdk';
|
|
41
42
|
import { findTheme } from '../lib/themes';
|
|
42
43
|
import { useDocModule } from '../lib/use-doc-module';
|
|
@@ -80,6 +81,9 @@ function readSort(): SortKey {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
const RECENT_COUNT = 4;
|
|
85
|
+
const SECTION_LABEL = 'mb-4 font-medium text-muted-foreground text-xs uppercase tracking-wider';
|
|
86
|
+
|
|
83
87
|
const titleOf = (id: string) => docTitles[id] ?? id;
|
|
84
88
|
|
|
85
89
|
function compare(sort: SortKey) {
|
|
@@ -108,10 +112,12 @@ export function Home() {
|
|
|
108
112
|
<button
|
|
109
113
|
type="button"
|
|
110
114
|
onClick={() => setCreating(true)}
|
|
111
|
-
|
|
115
|
+
aria-label={t('New document')}
|
|
116
|
+
title={t('New document')}
|
|
117
|
+
className="flex h-8 flex-none 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"
|
|
112
118
|
>
|
|
113
119
|
<Plus className="size-3.5" />
|
|
114
|
-
{t('New document')}
|
|
120
|
+
<span className="hidden @md:inline">{t('New document')}</span>
|
|
115
121
|
</button>
|
|
116
122
|
</>
|
|
117
123
|
);
|
|
@@ -139,6 +145,15 @@ export function Home() {
|
|
|
139
145
|
})
|
|
140
146
|
.sort(compare(sort));
|
|
141
147
|
}, [sourceIds, filter, sort]);
|
|
148
|
+
// Only where it saves a search: the whole library, not filtered, and big
|
|
149
|
+
// enough that the documents in it no longer fit on one screen.
|
|
150
|
+
const recentIds = useMemo(
|
|
151
|
+
() =>
|
|
152
|
+
ctx.selectedId === ALL_DOCS_ID && !filter.trim() && docIds.length > RECENT_COUNT * 2
|
|
153
|
+
? recentAmong(readRecentDocs(), docIds, RECENT_COUNT)
|
|
154
|
+
: [],
|
|
155
|
+
[ctx.selectedId, filter],
|
|
156
|
+
);
|
|
142
157
|
const currentSort = SORTS.find((entry) => entry.key === sort) ?? SORTS[0];
|
|
143
158
|
|
|
144
159
|
const heading =
|
|
@@ -165,11 +180,12 @@ export function Home() {
|
|
|
165
180
|
<button
|
|
166
181
|
type="button"
|
|
167
182
|
aria-label={t('Sort: {label}', { label: t(currentSort.label) })}
|
|
168
|
-
|
|
183
|
+
title={t(currentSort.label)}
|
|
184
|
+
className="flex h-8 flex-none items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs transition-colors hover:bg-accent aria-expanded:bg-accent"
|
|
169
185
|
{...props}
|
|
170
186
|
>
|
|
171
187
|
<currentSort.icon className="size-3.5 text-muted-foreground" />
|
|
172
|
-
{t(currentSort.label)}
|
|
188
|
+
<span className="hidden @lg:inline">{t(currentSort.label)}</span>
|
|
173
189
|
<ChevronDown className="size-3 text-muted-foreground" />
|
|
174
190
|
</button>
|
|
175
191
|
)}
|
|
@@ -191,7 +207,7 @@ export function Home() {
|
|
|
191
207
|
))
|
|
192
208
|
}
|
|
193
209
|
</Menu>
|
|
194
|
-
<label className="flex h-8 w-
|
|
210
|
+
<label className="flex h-8 min-w-0 flex-1 items-center gap-2 @2xl:w-56 @2xl:flex-none rounded-md border border-border bg-background px-2.5 text-xs focus-within:border-foreground focus-within:ring-2 focus-within:ring-primary/30">
|
|
195
211
|
<Search className="size-3.5 flex-none text-muted-foreground" />
|
|
196
212
|
<input
|
|
197
213
|
type="search"
|
|
@@ -231,11 +247,32 @@ export function Home() {
|
|
|
231
247
|
{newButton && <div className="mt-4 flex justify-center">{newButton}</div>}
|
|
232
248
|
</EmptyState>
|
|
233
249
|
) : (
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
<
|
|
237
|
-
|
|
238
|
-
|
|
250
|
+
<>
|
|
251
|
+
{recentIds.length > 0 && (
|
|
252
|
+
<section aria-labelledby="od-recent" className="mb-10">
|
|
253
|
+
<h2 id="od-recent" className={SECTION_LABEL}>
|
|
254
|
+
{t('Recently opened')}
|
|
255
|
+
</h2>
|
|
256
|
+
<div className={CARD_GRID}>
|
|
257
|
+
{recentIds.map((id) => (
|
|
258
|
+
<DocCard key={id} docId={id} ctx={ctx} onError={setError} />
|
|
259
|
+
))}
|
|
260
|
+
</div>
|
|
261
|
+
</section>
|
|
262
|
+
)}
|
|
263
|
+
<section aria-labelledby={recentIds.length > 0 ? 'od-all' : undefined}>
|
|
264
|
+
{recentIds.length > 0 && (
|
|
265
|
+
<h2 id="od-all" className={SECTION_LABEL}>
|
|
266
|
+
{t('All documents')}
|
|
267
|
+
</h2>
|
|
268
|
+
)}
|
|
269
|
+
<div className={CARD_GRID}>
|
|
270
|
+
{visibleIds.map((id) => (
|
|
271
|
+
<DocCard key={id} docId={id} ctx={ctx} onError={setError} />
|
|
272
|
+
))}
|
|
273
|
+
</div>
|
|
274
|
+
</section>
|
|
275
|
+
</>
|
|
239
276
|
)}
|
|
240
277
|
{import.meta.env.DEV && (
|
|
241
278
|
<NewDocumentDialog open={creating} folderId={inFolder} onClose={() => setCreating(false)} />
|
|
@@ -444,19 +481,20 @@ function DraftWithAgentButton() {
|
|
|
444
481
|
<button
|
|
445
482
|
type="button"
|
|
446
483
|
onClick={() => void start()}
|
|
484
|
+
aria-label={t.agent.createDoc}
|
|
447
485
|
title={
|
|
448
486
|
provider
|
|
449
487
|
? format(t.agent.createDocWith, { provider: provider.name })
|
|
450
488
|
: t.agent.quickCreateHint
|
|
451
489
|
}
|
|
452
|
-
className="flex h-8 items-center gap-1.5 rounded-md border border-border px-2.5 text-xs transition-colors hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/60"
|
|
490
|
+
className="flex h-8 flex-none items-center gap-1.5 rounded-md border border-border px-2.5 text-xs transition-colors hover:bg-accent focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/60"
|
|
453
491
|
>
|
|
454
492
|
{provider ? (
|
|
455
493
|
<ProviderLogo provider={provider.id} className="size-3.5" />
|
|
456
494
|
) : (
|
|
457
495
|
<Sparkles className="size-3.5" />
|
|
458
496
|
)}
|
|
459
|
-
{t.agent.createDoc}
|
|
497
|
+
<span className="hidden @lg:inline">{t.agent.createDoc}</span>
|
|
460
498
|
</button>
|
|
461
499
|
);
|
|
462
500
|
}
|
package/src/app/virtual.d.ts
CHANGED
|
@@ -26,6 +26,6 @@ declare module 'virtual:open-doc/config' {
|
|
|
26
26
|
import type { OpenDocConfig } from '../config';
|
|
27
27
|
|
|
28
28
|
type ResolvedBuild = { showDocBrowser: boolean; allowHtmlExport: boolean };
|
|
29
|
-
const config: OpenDocConfig & { build: ResolvedBuild; version: string };
|
|
29
|
+
const config: OpenDocConfig & { build: ResolvedBuild; version: string; fromSource: boolean };
|
|
30
30
|
export default config;
|
|
31
31
|
}
|