@open-document/core 0.17.0 → 0.17.2
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-BzNZnIhF.js → build-CryLx-8O.js} +1 -1
- package/dist/{check-C7kxlAFW.js → check-BU86QFnH.js} +3 -3
- package/dist/cli/bin.js +12 -12
- package/dist/{context-CFPnmNCR.js → context-DHCqEAue.js} +2 -2
- package/dist/{deploy-gcp-BUiSuqz7.js → deploy-gcp-bbxQT0gf.js} +1 -1
- package/dist/{dev-BUo7OESU.js → dev-Dmi2PnqI.js} +1 -1
- package/dist/{diff-B950T0O6.js → diff-HVSJapV4.js} +2 -2
- package/dist/{export-CHN1CiGv.js → export-CDobz0UO.js} +3 -3
- package/dist/{import-CLSnIxvN.js → import-BUHNpf-a.js} +3 -3
- package/dist/{open-doc-plugin-DnX5usgI.js → open-doc-plugin-DE1sJXK_.js} +3 -2
- package/dist/ops/index.js +2 -2
- package/dist/{ops-BgbM5Irm.js → ops-DKEhE_su.js} +1 -1
- package/dist/{preview-BVwVqS-I.js → preview-Do-31RB6.js} +1 -1
- package/dist/{proofread-BpR_3GZz.js → proofread-C0crhm3C.js} +3 -3
- package/dist/{session-DmbXf3u7.js → session-CcIBEiIB.js} +181 -112
- package/dist/{templates-BsWxs7oo.js → templates-hcl2pb6n.js} +3 -3
- package/dist/{translations-CW5OVM0L.js → translations-x2NwYrcj.js} +2 -2
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
- package/skills/doc-authoring/SKILL.md +10 -12
- package/src/app/components/agent/agent-dock.tsx +1 -1
- package/src/app/components/agent/transcript.tsx +2 -4
- package/src/app/components/browser/browser-ui.tsx +8 -2
- package/src/app/components/comments/comments-panel.tsx +9 -5
- package/src/app/components/doc-assets.tsx +9 -5
- package/src/app/components/panel/panel-shell.tsx +3 -1
- package/src/app/components/sidebar/sidebar.tsx +2 -1
- package/src/app/lib/ask.ts +113 -0
- package/src/app/lib/clipboard.ts +26 -0
- package/src/app/lib/export-pdf.ts +18 -0
- package/src/app/lib/i18n-ja/browser.ts +1 -0
- package/src/app/lib/i18n-ja/doc.ts +9 -0
- package/src/app/lib/i18n-ko/browser.ts +1 -0
- package/src/app/lib/i18n-ko/doc.ts +7 -0
- package/src/app/lib/i18n-zh-cn/browser.ts +1 -0
- package/src/app/lib/i18n-zh-cn/doc.ts +7 -0
- package/src/app/lib/i18n-zh-tw/browser.ts +1 -0
- package/src/app/lib/i18n-zh-tw/doc.ts +7 -0
- package/src/app/routes/assets.tsx +19 -12
- package/src/app/routes/doc.tsx +218 -64
- package/src/app/routes/home.tsx +27 -19
- package/src/app/virtual.d.ts +1 -1
|
@@ -10,6 +10,16 @@ This skill is the **technical reference** for everything inside `docs/<id>/index
|
|
|
10
10
|
- `create-doc` owns "draft a new document" — it asks the scoping questions, then delegates the *how* to this skill.
|
|
11
11
|
- Any ad-hoc edit (fix a table, retitle a section, adjust margins) should also read this first.
|
|
12
12
|
|
|
13
|
+
## Changing an existing document
|
|
14
|
+
|
|
15
|
+
Change the lines that change, not the file; most requests touch a few, even big-sounding ones:
|
|
16
|
+
|
|
17
|
+
- **A title, a sentence, a table row, one style**: edit those lines (your edit tool, or `edit_document` over MCP). Reports run 800–2000 lines: find the part first (`grep -n ": DocPage = "` or `outline_document`) and read ~150 lines around it.
|
|
18
|
+
- **A new look** (other colours, fonts or spacing): change the `design` const or its theme, not every element. A quoted value turned into a token or constant loses its quotes: `color: '#1A1A1A'` becomes `color: 'var(--od-ink)'` or `color: INK`, never `color: 'INK'`.
|
|
19
|
+
- **A variant** ("a shorter version of X"): duplicate the document, then edit the copy.
|
|
20
|
+
- **Write the whole file** only for a new document, or when more than half of its lines change (a new structure). Rewriting a long file is slow, and every copied line can break.
|
|
21
|
+
- **Renumbering costs**: a section inserted among numbered headings ("3.2") means editing every later one; prefer appending.
|
|
22
|
+
|
|
13
23
|
## Primitive references
|
|
14
24
|
|
|
15
25
|
Read the matching reference **before** using a primitive:
|
|
@@ -296,18 +306,6 @@ export const meta: DocMeta = {
|
|
|
296
306
|
export default [Cover, Section] satisfies DocPage[];
|
|
297
307
|
```
|
|
298
308
|
|
|
299
|
-
## Editing an existing document
|
|
300
|
-
|
|
301
|
-
A finished report commonly runs 800–2000 lines. When you only need one page, **don't read the whole file** — locate it first:
|
|
302
|
-
|
|
303
|
-
```bash
|
|
304
|
-
grep -n ": DocPage = " docs/<id>/index.tsx
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
Then `Read` with `offset` + `limit` (~150 lines covers a page plus its helpers). Read the whole file only for cross-page work (renumbering sections, palette audit, reordering).
|
|
308
|
-
|
|
309
|
-
**Renumbering is a real cost.** If sections are numbered ("3.2 Findings"), inserting a page means editing every downstream heading. Prefer appending, or use unnumbered headings when the document is still churning.
|
|
310
|
-
|
|
311
309
|
## Prose discipline
|
|
312
310
|
|
|
313
311
|
A document is not a slide deck. Long-form copy is the point — but it still has rules:
|
|
@@ -56,7 +56,7 @@ export function AgentDockFrame({ children }: { children: ReactNode }) {
|
|
|
56
56
|
return (
|
|
57
57
|
<div
|
|
58
58
|
data-agent-dock
|
|
59
|
-
className="relative flex h-full max-w-[60vw] shrink-0 border-border border-l bg-sidebar"
|
|
59
|
+
className="relative flex h-full max-w-[60vw] shrink-0 border-border border-l bg-sidebar max-md:absolute max-md:inset-y-0 max-md:right-0 max-md:z-40 max-md:w-[min(24rem,calc(100%-2.5rem))]! max-md:max-w-none max-md:shadow-2xl"
|
|
60
60
|
style={{ width }}
|
|
61
61
|
>
|
|
62
62
|
<ResizeHandle
|
|
@@ -6,6 +6,7 @@ import { format, plural, useLocale } from '@/lib/use-locale';
|
|
|
6
6
|
import { cn } from '@/lib/utils';
|
|
7
7
|
import { checkFixPrompt, stripDocSlug } from '../../../agent/prompt';
|
|
8
8
|
import type { AgentItem, AgentQuestion, AgentSession, RespondPayload } from '../../../agent/types';
|
|
9
|
+
import { copyText } from '../../lib/clipboard';
|
|
9
10
|
import { AgentMarkdown } from './agent-markdown';
|
|
10
11
|
|
|
11
12
|
export function Transcript({
|
|
@@ -178,10 +179,7 @@ function CopyButton({ text }: { text: string }) {
|
|
|
178
179
|
<ActionButton
|
|
179
180
|
label={copied ? t.agent.copied : t.agent.copyMessage}
|
|
180
181
|
onClick={() => {
|
|
181
|
-
|
|
182
|
-
() => setCopied(true),
|
|
183
|
-
() => {},
|
|
184
|
-
);
|
|
182
|
+
void copyText(text).then((ok) => ok && setCopied(true));
|
|
185
183
|
}}
|
|
186
184
|
>
|
|
187
185
|
{copied ? <Check /> : <Copy />}
|
|
@@ -74,7 +74,9 @@ export function PageHeader({
|
|
|
74
74
|
children?: ReactNode;
|
|
75
75
|
}) {
|
|
76
76
|
return (
|
|
77
|
-
|
|
77
|
+
// A container, so the actions fold by the room the page has, not the window:
|
|
78
|
+
// the sidebar takes part of a wide window and none of a narrow one.
|
|
79
|
+
<header className="@container mb-8">
|
|
78
80
|
<div className="flex flex-wrap items-center justify-between gap-4">
|
|
79
81
|
<div className="min-w-0">
|
|
80
82
|
<h1 className="flex items-center gap-2.5 font-medium text-lg tracking-tight">
|
|
@@ -90,7 +92,11 @@ export function PageHeader({
|
|
|
90
92
|
<p className="mt-1 max-w-2xl text-muted-foreground text-sm">{description}</p>
|
|
91
93
|
)}
|
|
92
94
|
</div>
|
|
93
|
-
{actions &&
|
|
95
|
+
{actions && (
|
|
96
|
+
<div className="flex w-full min-w-0 items-center gap-2 @2xl:w-auto @2xl:flex-none">
|
|
97
|
+
{actions}
|
|
98
|
+
</div>
|
|
99
|
+
)}
|
|
94
100
|
</div>
|
|
95
101
|
{children && <div className="mt-5">{children}</div>}
|
|
96
102
|
</header>
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
X,
|
|
9
9
|
} from 'lucide-react';
|
|
10
10
|
import { useState } from 'react';
|
|
11
|
+
import { copyText } from '../../lib/clipboard';
|
|
11
12
|
import { useLocale, useT } from '../../lib/i18n';
|
|
13
|
+
import { toast } from '../../lib/toast';
|
|
12
14
|
import { PanelIconButton, PanelShell } from '../panel/panel-shell';
|
|
13
15
|
import type { CommentsState, DocComment } from './use-comments';
|
|
14
16
|
|
|
@@ -189,11 +191,13 @@ export function CommentsPanel({
|
|
|
189
191
|
const comments = state.status === 'ready' ? state.comments : [];
|
|
190
192
|
|
|
191
193
|
const copy = async () => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
194
|
+
const command = `/apply-comments docs/${docId}`;
|
|
195
|
+
if (!(await copyText(command))) {
|
|
196
|
+
toast.error(t('Copying is blocked here'), { description: command });
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
setCopied(true);
|
|
200
|
+
window.setTimeout(() => setCopied(false), 1600);
|
|
197
201
|
};
|
|
198
202
|
|
|
199
203
|
return (
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
isPreviewable,
|
|
9
9
|
listAssets,
|
|
10
10
|
} from '../lib/assets';
|
|
11
|
+
import { copyText } from '../lib/clipboard';
|
|
11
12
|
import { useT } from '../lib/i18n';
|
|
13
|
+
import { toast } from '../lib/toast';
|
|
12
14
|
import { cn } from '../lib/utils';
|
|
13
15
|
|
|
14
16
|
type Group = { scope: string; label: string; assets: Asset[] };
|
|
@@ -44,11 +46,13 @@ export function DocAssets({ docId }: { docId: string }) {
|
|
|
44
46
|
}, [load]);
|
|
45
47
|
|
|
46
48
|
const copyImport = async (asset: Asset) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
49
|
+
const snippet = importSnippet(asset);
|
|
50
|
+
if (!(await copyText(snippet))) {
|
|
51
|
+
toast.error(t('Copying is blocked here'), { description: snippet });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setCopied(true);
|
|
55
|
+
setTimeout(() => setCopied(false), 1200);
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
if (groups === null) {
|
|
@@ -26,7 +26,9 @@ export function PanelShell({
|
|
|
26
26
|
<aside
|
|
27
27
|
ref={panelRef}
|
|
28
28
|
aria-label={label}
|
|
29
|
-
|
|
29
|
+
// Below md there is no room beside the pages: the panel floats over them
|
|
30
|
+
// instead of squeezing them to a sliver.
|
|
31
|
+
className="od-panel-in flex w-72 flex-none flex-col border-border border-l bg-background max-md:absolute max-md:inset-y-0 max-md:right-0 max-md:z-40 max-md:w-[min(18rem,calc(100%-2.5rem))] max-md:shadow-2xl"
|
|
30
32
|
>
|
|
31
33
|
<header className="flex h-10 flex-none items-center justify-between gap-2 border-border border-b px-3">
|
|
32
34
|
<div className="flex min-w-0 items-center gap-2">{header}</div>
|
|
@@ -251,7 +251,8 @@ export function Sidebar({
|
|
|
251
251
|
<div className="flex items-center justify-between gap-2 px-4 py-3 text-[11px] text-muted-foreground">
|
|
252
252
|
<span>
|
|
253
253
|
v{config.version}
|
|
254
|
-
|
|
254
|
+
{/* Only a core run from a checkout says so; an npm install shows its version alone. */}
|
|
255
|
+
{config.fromSource && <span className="ml-2 font-mono">dev</span>}
|
|
255
256
|
</span>
|
|
256
257
|
<div className="-mr-1.5 flex items-center gap-0.5">
|
|
257
258
|
<LanguageToggle />
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirm and prompt drawn in the page instead of `window.confirm` / `window.prompt`.
|
|
3
|
+
* A sandboxed frame without `allow-modals` (VS Code's webviews, editor panels that
|
|
4
|
+
* frame the viewer) never shows the browser's own boxes: `confirm` answers false and
|
|
5
|
+
* `prompt` null at once, so Delete and Rename silently did nothing there. A `<dialog>`
|
|
6
|
+
* in the DOM works in any frame. Built straight into the DOM, like `toast`, so a
|
|
7
|
+
* caller in an event handler needs no React state; the answer comes back as a promise.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
type Labels = { ok: string; cancel: string; destructive?: boolean };
|
|
11
|
+
|
|
12
|
+
function open(
|
|
13
|
+
build: (dialog: HTMLDialogElement, done: (value: string | null) => void) => void,
|
|
14
|
+
): Promise<string | null> {
|
|
15
|
+
if (typeof document === 'undefined') return Promise.resolve(null);
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const dialog = document.createElement('dialog');
|
|
18
|
+
dialog.className =
|
|
19
|
+
'm-auto w-[min(400px,calc(100vw-32px))] rounded-xl border border-border bg-background p-4 text-foreground text-sm shadow-2xl backdrop:bg-black/40';
|
|
20
|
+
let settled = false;
|
|
21
|
+
const done = (value: string | null) => {
|
|
22
|
+
if (settled) return;
|
|
23
|
+
settled = true;
|
|
24
|
+
if (dialog.open) dialog.close();
|
|
25
|
+
dialog.remove();
|
|
26
|
+
resolve(value);
|
|
27
|
+
};
|
|
28
|
+
// Escape, or the browser closing it: the same as Cancel.
|
|
29
|
+
dialog.addEventListener('cancel', (event) => {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
done(null);
|
|
32
|
+
});
|
|
33
|
+
dialog.addEventListener('close', () => done(null));
|
|
34
|
+
build(dialog, done);
|
|
35
|
+
document.body.append(dialog);
|
|
36
|
+
if (typeof dialog.showModal === 'function') dialog.showModal();
|
|
37
|
+
else dialog.setAttribute('open', '');
|
|
38
|
+
(
|
|
39
|
+
dialog.querySelector('input') ?? dialog.querySelector<HTMLButtonElement>('[data-ok]')
|
|
40
|
+
)?.focus();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function buttons(labels: Labels, onOk: () => void, onCancel: () => void): HTMLElement {
|
|
45
|
+
const row = document.createElement('div');
|
|
46
|
+
row.className = 'mt-4 flex justify-end gap-2';
|
|
47
|
+
const cancel = document.createElement('button');
|
|
48
|
+
cancel.type = 'button';
|
|
49
|
+
cancel.className =
|
|
50
|
+
'h-9 rounded-md px-4 text-sm transition-colors hover:bg-accent focus-visible:outline-2 focus-visible:outline-foreground/60';
|
|
51
|
+
cancel.textContent = labels.cancel;
|
|
52
|
+
cancel.addEventListener('click', onCancel);
|
|
53
|
+
const ok = document.createElement('button');
|
|
54
|
+
ok.type = 'submit';
|
|
55
|
+
ok.dataset.ok = '';
|
|
56
|
+
ok.className = `h-9 rounded-md px-4 text-sm transition-opacity hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground/60 ${
|
|
57
|
+
labels.destructive ? 'bg-destructive text-white' : 'bg-primary text-primary-foreground'
|
|
58
|
+
}`;
|
|
59
|
+
ok.textContent = labels.ok;
|
|
60
|
+
ok.addEventListener('click', onOk);
|
|
61
|
+
row.append(cancel, ok);
|
|
62
|
+
return row;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Asks a yes/no question; true only when the OK button is pressed. */
|
|
66
|
+
export async function askConfirm(message: string, labels: Labels): Promise<boolean> {
|
|
67
|
+
const answer = await open((dialog, done) => {
|
|
68
|
+
dialog.setAttribute('role', 'alertdialog');
|
|
69
|
+
const text = document.createElement('p');
|
|
70
|
+
text.className = 'whitespace-pre-wrap leading-relaxed';
|
|
71
|
+
text.textContent = message;
|
|
72
|
+
dialog.append(
|
|
73
|
+
text,
|
|
74
|
+
buttons(
|
|
75
|
+
labels,
|
|
76
|
+
() => done('ok'),
|
|
77
|
+
() => done(null),
|
|
78
|
+
),
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
return answer === 'ok';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Asks for a line of text, starting from `value`; null when cancelled. */
|
|
85
|
+
export function askText(label: string, value: string, labels: Labels): Promise<string | null> {
|
|
86
|
+
return open((dialog, done) => {
|
|
87
|
+
const form = document.createElement('form');
|
|
88
|
+
form.method = 'dialog';
|
|
89
|
+
const caption = document.createElement('label');
|
|
90
|
+
caption.className = 'block font-medium';
|
|
91
|
+
caption.textContent = label;
|
|
92
|
+
const input = document.createElement('input');
|
|
93
|
+
input.type = 'text';
|
|
94
|
+
input.value = value;
|
|
95
|
+
input.className =
|
|
96
|
+
'mt-2 h-9 w-full rounded-md border border-border bg-transparent px-3 text-sm outline-none focus:border-foreground/40';
|
|
97
|
+
caption.append(input);
|
|
98
|
+
form.append(
|
|
99
|
+
caption,
|
|
100
|
+
buttons(
|
|
101
|
+
labels,
|
|
102
|
+
() => {},
|
|
103
|
+
() => done(null),
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
form.addEventListener('submit', (event) => {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
done(input.value);
|
|
109
|
+
});
|
|
110
|
+
dialog.append(form);
|
|
111
|
+
queueMicrotask(() => input.select());
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts text on the clipboard, or says it could not. A frame without the
|
|
3
|
+
* `clipboard-write` permission (VS Code's webviews, editor panels that frame the
|
|
4
|
+
* viewer) refuses `navigator.clipboard`; the older selection copy still works
|
|
5
|
+
* there in most hosts, so it is the fallback before giving up.
|
|
6
|
+
*/
|
|
7
|
+
export async function copyText(text: string): Promise<boolean> {
|
|
8
|
+
try {
|
|
9
|
+
await navigator.clipboard.writeText(text);
|
|
10
|
+
return true;
|
|
11
|
+
} catch {}
|
|
12
|
+
const area = document.createElement('textarea');
|
|
13
|
+
area.value = text;
|
|
14
|
+
area.setAttribute('readonly', '');
|
|
15
|
+
area.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;';
|
|
16
|
+
const focused = document.activeElement as HTMLElement | null;
|
|
17
|
+
document.body.append(area);
|
|
18
|
+
area.select();
|
|
19
|
+
let copied = false;
|
|
20
|
+
try {
|
|
21
|
+
copied = document.execCommand('copy');
|
|
22
|
+
} catch {}
|
|
23
|
+
area.remove();
|
|
24
|
+
focused?.focus?.();
|
|
25
|
+
return copied;
|
|
26
|
+
}
|
|
@@ -193,6 +193,14 @@ export async function mountPrintCopy(
|
|
|
193
193
|
return { root, dispose };
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
/** The page is in a frame that may not print; the caller can make the PDF another way. */
|
|
197
|
+
export class PrintBlockedError extends Error {
|
|
198
|
+
constructor() {
|
|
199
|
+
super('printing is blocked in this frame');
|
|
200
|
+
this.name = 'PrintBlockedError';
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
196
204
|
export async function exportDocAsPdf(
|
|
197
205
|
doc: DocModule,
|
|
198
206
|
docId: string,
|
|
@@ -206,8 +214,18 @@ export async function exportDocAsPdf(
|
|
|
206
214
|
|
|
207
215
|
try {
|
|
208
216
|
onProgress?.({ phase: 'printing', current: total, total, percent: 99 });
|
|
217
|
+
// A frame without `allow-modals` ignores print() without a word: no beforeprint, no
|
|
218
|
+
// afterprint, and the export would wait for a dialog that never opens.
|
|
219
|
+
let started = false;
|
|
220
|
+
const onBefore = () => {
|
|
221
|
+
started = true;
|
|
222
|
+
};
|
|
223
|
+
window.addEventListener('beforeprint', onBefore, { once: true });
|
|
209
224
|
const printDone = waitForAfterPrint();
|
|
210
225
|
window.print();
|
|
226
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
227
|
+
window.removeEventListener('beforeprint', onBefore);
|
|
228
|
+
if (!started) throw new PrintBlockedError();
|
|
211
229
|
await printDone;
|
|
212
230
|
} finally {
|
|
213
231
|
onProgress?.({ phase: 'done', current: total, total, percent: 100 });
|
|
@@ -62,8 +62,17 @@ export const DOC: Record<string, string> = {
|
|
|
62
62
|
'Actual size (100%)': '実際のサイズ (100%)',
|
|
63
63
|
'Link copied': 'リンクをコピーしました',
|
|
64
64
|
'Copy link': 'リンクをコピー',
|
|
65
|
+
More: 'その他',
|
|
65
66
|
Record: 'レコード',
|
|
66
67
|
'Previous record': '前のレコード',
|
|
67
68
|
'Next record': '次のレコード',
|
|
68
69
|
Certificate: '修了証',
|
|
70
|
+
'Copying is blocked here': 'ここではコピーできません',
|
|
71
|
+
'This window cannot print': 'このウィンドウでは印刷できません',
|
|
72
|
+
'Open the document in a browser to save a PDF.':
|
|
73
|
+
'PDF を保存するには、ブラウザでドキュメントを開いてください。',
|
|
74
|
+
'Could not make the PDF': 'PDF を作成できませんでした',
|
|
75
|
+
'Saved the whole document': 'ドキュメント全体を保存しました',
|
|
76
|
+
'This window cannot print a page range.':
|
|
77
|
+
'このウィンドウではページ範囲を指定して印刷できません。',
|
|
69
78
|
};
|
|
@@ -62,8 +62,15 @@ export const DOC: Record<string, string> = {
|
|
|
62
62
|
'Actual size (100%)': '실제 크기 (100%)',
|
|
63
63
|
'Link copied': '링크 복사됨',
|
|
64
64
|
'Copy link': '링크 복사',
|
|
65
|
+
More: '더 보기',
|
|
65
66
|
Record: '레코드',
|
|
66
67
|
'Previous record': '이전 레코드',
|
|
67
68
|
'Next record': '다음 레코드',
|
|
68
69
|
Certificate: '수료증',
|
|
70
|
+
'Copying is blocked here': '여기서는 복사할 수 없습니다',
|
|
71
|
+
'This window cannot print': '이 창에서는 인쇄할 수 없습니다',
|
|
72
|
+
'Open the document in a browser to save a PDF.': 'PDF로 저장하려면 브라우저에서 문서를 여세요.',
|
|
73
|
+
'Could not make the PDF': 'PDF를 만들 수 없습니다',
|
|
74
|
+
'Saved the whole document': '문서 전체를 저장했습니다',
|
|
75
|
+
'This window cannot print a page range.': '이 창에서는 일부 페이지만 인쇄할 수 없습니다.',
|
|
69
76
|
};
|
|
@@ -61,8 +61,15 @@ export const DOC: Record<string, string> = {
|
|
|
61
61
|
'Actual size (100%)': '实际大小 (100%)',
|
|
62
62
|
'Link copied': '已复制链接',
|
|
63
63
|
'Copy link': '复制链接',
|
|
64
|
+
More: '更多',
|
|
64
65
|
Record: '数据行',
|
|
65
66
|
'Previous record': '上一条数据',
|
|
66
67
|
'Next record': '下一条数据',
|
|
67
68
|
Certificate: '证书',
|
|
69
|
+
'Copying is blocked here': '此处无法复制',
|
|
70
|
+
'This window cannot print': '此窗口无法打印',
|
|
71
|
+
'Open the document in a browser to save a PDF.': '请在浏览器中打开文档以保存 PDF。',
|
|
72
|
+
'Could not make the PDF': '无法生成 PDF',
|
|
73
|
+
'Saved the whole document': '已保存整份文档',
|
|
74
|
+
'This window cannot print a page range.': '此窗口无法只打印部分页面。',
|
|
68
75
|
};
|
|
@@ -61,8 +61,15 @@ export const DOC: Record<string, string> = {
|
|
|
61
61
|
'Actual size (100%)': '實際大小 (100%)',
|
|
62
62
|
'Link copied': '已複製連結',
|
|
63
63
|
'Copy link': '複製連結',
|
|
64
|
+
More: '更多',
|
|
64
65
|
Record: '資料列',
|
|
65
66
|
'Previous record': '上一筆資料',
|
|
66
67
|
'Next record': '下一筆資料',
|
|
67
68
|
Certificate: '證書',
|
|
69
|
+
'Copying is blocked here': '這裡無法複製',
|
|
70
|
+
'This window cannot print': '這個視窗無法列印',
|
|
71
|
+
'Open the document in a browser to save a PDF.': '請在瀏覽器打開文件來儲存 PDF。',
|
|
72
|
+
'Could not make the PDF': '無法產生 PDF',
|
|
73
|
+
'Saved the whole document': '已儲存整份文件',
|
|
74
|
+
'This window cannot print a page range.': '這個視窗無法只列印部分頁面。',
|
|
68
75
|
};
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { type DragEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
13
|
import { CARD_GRID, EmptyState, PageHeader } from '../components/browser/browser-ui';
|
|
14
14
|
import { Menu, MenuItem, MenuSeparator } from '../components/ui/menu';
|
|
15
|
+
import { askConfirm, askText } from '../lib/ask';
|
|
15
16
|
import {
|
|
16
17
|
type Asset,
|
|
17
18
|
deleteAsset,
|
|
@@ -23,6 +24,7 @@ import {
|
|
|
23
24
|
renameAsset,
|
|
24
25
|
uploadAsset,
|
|
25
26
|
} from '../lib/assets';
|
|
27
|
+
import { copyText } from '../lib/clipboard';
|
|
26
28
|
import { docIds } from '../lib/docs';
|
|
27
29
|
import { useT } from '../lib/i18n';
|
|
28
30
|
import { cn } from '../lib/utils';
|
|
@@ -60,8 +62,9 @@ export function AssetsPage() {
|
|
|
60
62
|
for (const file of Array.from(files)) {
|
|
61
63
|
let result = await uploadAsset(scope, file);
|
|
62
64
|
if (!result.ok && result.error === 'asset exists') {
|
|
63
|
-
const replace =
|
|
65
|
+
const replace = await askConfirm(
|
|
64
66
|
t('"{name}" already exists in {scope}. Replace it?', { name: file.name, scope }),
|
|
67
|
+
{ ok: t('Replace'), cancel: t('Cancel') },
|
|
65
68
|
);
|
|
66
69
|
if (!replace) continue;
|
|
67
70
|
result = await uploadAsset(scope, file, { overwrite: true });
|
|
@@ -199,17 +202,20 @@ function AssetCard({
|
|
|
199
202
|
const [copied, setCopied] = useState(false);
|
|
200
203
|
|
|
201
204
|
const copyImport = async () => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} catch (err) {
|
|
207
|
-
onError(String((err as Error).message));
|
|
205
|
+
const snippet = importSnippet(asset);
|
|
206
|
+
if (!(await copyText(snippet))) {
|
|
207
|
+
onError(`${t('Copying is blocked here')}: ${snippet}`);
|
|
208
|
+
return;
|
|
208
209
|
}
|
|
210
|
+
setCopied(true);
|
|
211
|
+
setTimeout(() => setCopied(false), 1200);
|
|
209
212
|
};
|
|
210
213
|
|
|
211
214
|
const rename = async () => {
|
|
212
|
-
const next =
|
|
215
|
+
const next = await askText(t('New file name'), asset.name, {
|
|
216
|
+
ok: t('Rename'),
|
|
217
|
+
cancel: t('Cancel'),
|
|
218
|
+
});
|
|
213
219
|
if (!next || next === asset.name) return;
|
|
214
220
|
const result = await renameAsset(scope, asset.name, next);
|
|
215
221
|
if (!result.ok) onError(`${asset.name}: ${result.error}`);
|
|
@@ -217,10 +223,11 @@ function AssetCard({
|
|
|
217
223
|
};
|
|
218
224
|
|
|
219
225
|
const remove = async () => {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
226
|
+
const yes = await askConfirm(
|
|
227
|
+
t('Delete "{name}"? This removes the file from disk.', { name: asset.name }),
|
|
228
|
+
{ ok: t('Delete'), cancel: t('Cancel'), destructive: true },
|
|
229
|
+
);
|
|
230
|
+
if (!yes) return;
|
|
224
231
|
const result = await deleteAsset(scope, asset.name);
|
|
225
232
|
if (!result.ok) onError(`${asset.name}: ${result.error}`);
|
|
226
233
|
onChanged();
|