@open-document/core 0.16.0 → 0.17.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-BS_CoazO.js → build-BzNZnIhF.js} +1 -1
- package/dist/{check-tTjyMCrU.js → check-C7kxlAFW.js} +11 -4
- package/dist/cli/bin.js +24 -11
- package/dist/{context-Cli81dhF.js → context-CFPnmNCR.js} +1 -1
- package/dist/{dev-n222xdoE.js → dev-BUo7OESU.js} +1 -1
- package/dist/{diff-DB_qruzT.js → diff-B950T0O6.js} +2 -2
- package/dist/{export-CCFtdscQ.js → export-CHN1CiGv.js} +3 -3
- package/dist/{flow-CS5apebG.d.ts → flow-DlV3t5ML.d.ts} +24 -4
- package/dist/{import-D7k0yYZh.js → import-CLSnIxvN.js} +11 -7
- package/dist/index.d.ts +26 -2
- package/dist/index.js +55 -1
- package/dist/ops/index.d.ts +138 -4
- package/dist/ops/index.js +3 -3
- package/dist/{ops-CouYBa1O.js → ops-BgbM5Irm.js} +197 -9
- package/dist/{preview-DV0GDIsj.js → preview-BVwVqS-I.js} +1 -1
- package/dist/proofread-BpR_3GZz.js +35 -0
- package/dist/{session-Cx7Msl_F.js → session-DmbXf3u7.js} +5135 -67
- package/dist/{templates-C-7VcMMV.js → templates-BsWxs7oo.js} +3 -3
- package/dist/translations-CW5OVM0L.js +42 -0
- package/dist/vite/index.js +1 -1
- 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/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/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-ko/browser.ts +1 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +1 -0
- package/src/app/lib/i18n-zh-tw/browser.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 +26 -2
- package/src/app/routes/home.tsx +39 -5
package/src/app/routes/doc.tsx
CHANGED
|
@@ -78,6 +78,7 @@ import {
|
|
|
78
78
|
resolveSelection,
|
|
79
79
|
} from '../lib/page-range';
|
|
80
80
|
import { nextFrame, waitForFonts } from '../lib/print-ready';
|
|
81
|
+
import { markDocOpened } from '../lib/recent-docs';
|
|
81
82
|
import { getRecordState, setRecords, useRecordIndex } from '../lib/records';
|
|
82
83
|
import { scanDocument } from '../lib/scan';
|
|
83
84
|
import { pageLang, resolvePageGeometry } from '../lib/sdk';
|
|
@@ -214,7 +215,7 @@ export function Doc() {
|
|
|
214
215
|
const state = useDocModule(docId);
|
|
215
216
|
const doc = state.doc;
|
|
216
217
|
const t = useT();
|
|
217
|
-
const { setLocale } = useLocale();
|
|
218
|
+
const { locale, setLocale } = useLocale();
|
|
218
219
|
|
|
219
220
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
220
221
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
@@ -262,6 +263,7 @@ export function Doc() {
|
|
|
262
263
|
const editControlsRef = useRef<InspectorControls | null>(null);
|
|
263
264
|
const [textPending, setTextPending] = useState(0);
|
|
264
265
|
const [cardShown, setCardShown] = useState(false);
|
|
266
|
+
const [unsaved, setUnsaved] = useState(false);
|
|
265
267
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
266
268
|
const [viewMode, setViewModeState] = useState<ViewMode>(() => readViewMode(docId));
|
|
267
269
|
// The page the reader was on when the layout changed, to put back in view.
|
|
@@ -281,6 +283,27 @@ export function Doc() {
|
|
|
281
283
|
useEffect(() => () => setRecords(undefined), []);
|
|
282
284
|
|
|
283
285
|
const { pages, measuring, overflowing } = useDocPages(doc, geometry);
|
|
286
|
+
|
|
287
|
+
const loaded = Boolean(doc);
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
if (loaded && docId) markDocOpened(docId);
|
|
290
|
+
}, [loaded, docId]);
|
|
291
|
+
|
|
292
|
+
const docTitle = doc ? (doc.meta?.title ?? docId) : undefined;
|
|
293
|
+
const showPage = pages.length > 1 && !measuring;
|
|
294
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `t` keeps one identity across languages, so `locale` re-runs it
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
if (!docTitle) return;
|
|
297
|
+
const page = showPage ? ` · ${t('p. {page}', { page: currentPage })}` : '';
|
|
298
|
+
document.title = `${unsaved ? '● ' : ''}${docTitle}${page}`;
|
|
299
|
+
}, [docTitle, showPage, currentPage, unsaved, t, locale]);
|
|
300
|
+
useEffect(
|
|
301
|
+
() => () => {
|
|
302
|
+
document.title = 'open-doc';
|
|
303
|
+
},
|
|
304
|
+
[],
|
|
305
|
+
);
|
|
306
|
+
|
|
284
307
|
const recordIndex = useRecordIndex();
|
|
285
308
|
|
|
286
309
|
// Read again on every reload of the document, so what an agent just wrote
|
|
@@ -1122,7 +1145,7 @@ export function Doc() {
|
|
|
1122
1145
|
key={page.key}
|
|
1123
1146
|
index={index}
|
|
1124
1147
|
total={pages.length}
|
|
1125
|
-
geometry={geometry}
|
|
1148
|
+
geometry={page.geometry ?? geometry}
|
|
1126
1149
|
scale={scale}
|
|
1127
1150
|
design={doc.design}
|
|
1128
1151
|
lang={pageLang(doc.meta)}
|
|
@@ -1152,6 +1175,7 @@ export function Doc() {
|
|
|
1152
1175
|
textCount={textPending}
|
|
1153
1176
|
controlsRef={editControlsRef}
|
|
1154
1177
|
onShownChange={setCardShown}
|
|
1178
|
+
onUnsavedChange={setUnsaved}
|
|
1155
1179
|
/>
|
|
1156
1180
|
)}
|
|
1157
1181
|
{agentActivity && (
|
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) {
|
|
@@ -139,6 +143,15 @@ export function Home() {
|
|
|
139
143
|
})
|
|
140
144
|
.sort(compare(sort));
|
|
141
145
|
}, [sourceIds, filter, sort]);
|
|
146
|
+
// Only where it saves a search: the whole library, not filtered, and big
|
|
147
|
+
// enough that the documents in it no longer fit on one screen.
|
|
148
|
+
const recentIds = useMemo(
|
|
149
|
+
() =>
|
|
150
|
+
ctx.selectedId === ALL_DOCS_ID && !filter.trim() && docIds.length > RECENT_COUNT * 2
|
|
151
|
+
? recentAmong(readRecentDocs(), docIds, RECENT_COUNT)
|
|
152
|
+
: [],
|
|
153
|
+
[ctx.selectedId, filter],
|
|
154
|
+
);
|
|
142
155
|
const currentSort = SORTS.find((entry) => entry.key === sort) ?? SORTS[0];
|
|
143
156
|
|
|
144
157
|
const heading =
|
|
@@ -231,11 +244,32 @@ export function Home() {
|
|
|
231
244
|
{newButton && <div className="mt-4 flex justify-center">{newButton}</div>}
|
|
232
245
|
</EmptyState>
|
|
233
246
|
) : (
|
|
234
|
-
|
|
235
|
-
{
|
|
236
|
-
<
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
<>
|
|
248
|
+
{recentIds.length > 0 && (
|
|
249
|
+
<section aria-labelledby="od-recent" className="mb-10">
|
|
250
|
+
<h2 id="od-recent" className={SECTION_LABEL}>
|
|
251
|
+
{t('Recently opened')}
|
|
252
|
+
</h2>
|
|
253
|
+
<div className={CARD_GRID}>
|
|
254
|
+
{recentIds.map((id) => (
|
|
255
|
+
<DocCard key={id} docId={id} ctx={ctx} onError={setError} />
|
|
256
|
+
))}
|
|
257
|
+
</div>
|
|
258
|
+
</section>
|
|
259
|
+
)}
|
|
260
|
+
<section aria-labelledby={recentIds.length > 0 ? 'od-all' : undefined}>
|
|
261
|
+
{recentIds.length > 0 && (
|
|
262
|
+
<h2 id="od-all" className={SECTION_LABEL}>
|
|
263
|
+
{t('All documents')}
|
|
264
|
+
</h2>
|
|
265
|
+
)}
|
|
266
|
+
<div className={CARD_GRID}>
|
|
267
|
+
{visibleIds.map((id) => (
|
|
268
|
+
<DocCard key={id} docId={id} ctx={ctx} onError={setError} />
|
|
269
|
+
))}
|
|
270
|
+
</div>
|
|
271
|
+
</section>
|
|
272
|
+
</>
|
|
239
273
|
)}
|
|
240
274
|
{import.meta.env.DEV && (
|
|
241
275
|
<NewDocumentDialog open={creating} folderId={inFolder} onClose={() => setCreating(false)} />
|