@lincyaw/workbench 0.2.0-rc.65 → 0.2.0-rc.67
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/package.json +4 -4
- package/src/document-session.ts +11 -5
- package/src/messages.ts +12 -10
- package/src/panels/DocumentView.tsx +6 -3
- package/src/panels/HistoryPanel.tsx +31 -1
- package/src/panels/SourceDocumentPanel.tsx +4 -21
- package/src/styles.css +5 -2
- package/src/workbench.ts +4 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/workbench",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.67",
|
|
4
4
|
"description": "Presmium's workbench panels in React (the documents, a document edited on its rendered page with comments and version history) with the workspace service's client and the preview protocol's workbench side; @lincyaw/dsh places them in presmium studio (experimental)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@tiptap/pm": "3.32.0",
|
|
56
56
|
"katex": "0.18.10",
|
|
57
57
|
"react-resizable-panels": "4.14.5",
|
|
58
|
-
"@lincyaw/design": "1.0.0-rc.
|
|
59
|
-
"@lincyaw/kernel": "1.0.0-rc.
|
|
58
|
+
"@lincyaw/design": "1.0.0-rc.67",
|
|
59
|
+
"@lincyaw/kernel": "1.0.0-rc.67"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"react": "^18.3.1",
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
"@types/react-dom": "18.3.7",
|
|
68
68
|
"react": "^18.3.1",
|
|
69
69
|
"react-dom": "^18.3.1",
|
|
70
|
-
"@lincyaw/compiler": "1.0.0-rc.
|
|
70
|
+
"@lincyaw/compiler": "1.0.0-rc.67"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/document-session.ts
CHANGED
|
@@ -782,21 +782,27 @@ export class DocumentSession {
|
|
|
782
782
|
}
|
|
783
783
|
|
|
784
784
|
async forgetDraft(value: DocumentDraftReference, request?: DocumentDraftOperation): Promise<boolean | void> {
|
|
785
|
+
return this.forgetDrafts([value], request)
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/** Retire only the displayed revisions together; another tab's newer input stays recoverable. */
|
|
789
|
+
async forgetDrafts(values: readonly DocumentDraftReference[], request?: DocumentDraftOperation): Promise<boolean | void> {
|
|
785
790
|
const slot = this.#active === undefined ? undefined : this.#slots.get(this.#active)
|
|
786
|
-
if (!slot?.state.identity || !slot.state.content || slot.state.recovering || slot.flight || slot.assetFlight || slot.state.composing || this.#disposed) return
|
|
791
|
+
if (!values.length || !slot?.state.identity || !slot.state.content || slot.state.recovering || slot.flight || slot.assetFlight || slot.state.composing || this.#disposed) return
|
|
787
792
|
const identity = slot.state.identity, documentId = slot.state.content.id, input = slot.input, read = slot.read
|
|
788
793
|
const operation = slot.recoveryOperation = (slot.recoveryOperation ?? 0) + 1
|
|
789
794
|
const current = () => { this.#checkOperation(request); return !this.#disposed && this.#active === slot.state.directory && this.#slots.get(slot.state.directory) === slot && slot.state.identity === identity && slot.input === input && slot.read === read && slot.recoveryOperation === operation && !slot.state.composing && !slot.flight && !slot.assetFlight }
|
|
790
795
|
slot.state = { ...slot.state, recovering: true }; this.#emit(slot)
|
|
791
796
|
try {
|
|
792
797
|
this.#checkOperation(request)
|
|
793
|
-
const
|
|
798
|
+
const records = (await slot.drafts.read(identity, documentId, request?.signal)).records
|
|
799
|
+
const candidates = values.map(value => records.find(record => record.id === value.id && record.revision === value.revision && record.token === value.token))
|
|
794
800
|
if (!current()) return
|
|
795
801
|
this.#checkOperation(request)
|
|
796
|
-
if (candidate?.owned && candidate.id === slot.draft?.id) return
|
|
797
|
-
if (!candidate) slot.state = { ...slot.state, recoveryChanged: true }
|
|
802
|
+
if (candidates.some(candidate => candidate?.owned && candidate.id === slot.draft?.id)) return
|
|
803
|
+
if (candidates.some(candidate => !candidate)) slot.state = { ...slot.state, recoveryChanged: true }
|
|
798
804
|
else {
|
|
799
|
-
const settled = await slot.drafts.settle(identity,
|
|
805
|
+
const settled = await slot.drafts.settle(identity, values, request && { ...request, guard: () => { if (!current()) throw new Error('client-body-drafts-changed') } })
|
|
800
806
|
if (!current()) return
|
|
801
807
|
slot.persistFailure = !settled
|
|
802
808
|
slot.state = { ...slot.state, recoveryChanged: false, storageFailure: Boolean(slot.persistFailure || slot.legacyFailure === 'write') }
|
package/src/messages.ts
CHANGED
|
@@ -111,14 +111,13 @@ const zh = {
|
|
|
111
111
|
narrationAutosave: '自动保存;切换步骤会保留未完成的草稿。',
|
|
112
112
|
narrationDiscard: '放弃草稿',
|
|
113
113
|
narrationRecoveryUnavailable: '浏览器无法在本机保留草稿。草稿仍在本次会话中,请保存后再关闭窗口。',
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
documentDrafts: '本地草稿',
|
|
115
|
+
documentDraftName: (index: number) => `草稿 ${index}`,
|
|
116
|
+
documentDraftDiscardAll: '全部放弃',
|
|
117
117
|
documentDraftRestore: '恢复草稿',
|
|
118
|
-
documentDraftChanged: '
|
|
118
|
+
documentDraftChanged: '本地草稿已更新,请查看最新列表。',
|
|
119
119
|
documentDraftUnreadable: '部分本地草稿无法读取。',
|
|
120
120
|
documentDraftBackingUp: '正在备份…',
|
|
121
|
-
documentDraftOption: (index: number, date: string, source: 'durable' | 'rescue') => `${date} · ${source === 'rescue' ? '临时副本' : '草稿'} ${index}`,
|
|
122
121
|
narrationCompositionInterrupted: '输入法组字未完成,草稿已保留。请检查文字后保存或继续编辑。',
|
|
123
122
|
narrationRefresh: '讲稿已写入,但画面尚未完成更新。草稿已保留,请等待预览恢复后重试。',
|
|
124
123
|
narrationDuring: '与动画同步',
|
|
@@ -246,6 +245,8 @@ const zh = {
|
|
|
246
245
|
formattedEdit: '这一处带有格式或特殊内容,不能直接修改文字。要用 AI 改写吗?',
|
|
247
246
|
rewriteEdit: '用 AI 改写',
|
|
248
247
|
versionHistory: '版本历史',
|
|
248
|
+
historyWithDrafts: (count: number) => `版本历史(${count} 份本地草稿)`,
|
|
249
|
+
historySavedVersions: '已保存版本',
|
|
249
250
|
historyNewer: '较新版本',
|
|
250
251
|
historyOlder: '更早版本',
|
|
251
252
|
exportPane: '导出',
|
|
@@ -480,14 +481,13 @@ const en: WorkbenchMessages = {
|
|
|
480
481
|
narrationAutosave: 'Saved automatically. Switching steps keeps unfinished drafts.',
|
|
481
482
|
narrationDiscard: 'Discard Draft',
|
|
482
483
|
narrationRecoveryUnavailable: 'This browser can’t keep drafts on this device. Your draft stays in this session; save before closing the window.',
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
484
|
+
documentDrafts: 'Local Drafts',
|
|
485
|
+
documentDraftName: (index: number) => `Draft ${index}`,
|
|
486
|
+
documentDraftDiscardAll: 'Discard All',
|
|
486
487
|
documentDraftRestore: 'Recover Draft',
|
|
487
|
-
documentDraftChanged: '
|
|
488
|
+
documentDraftChanged: 'Drafts on this device changed. Check the updated list.',
|
|
488
489
|
documentDraftUnreadable: 'Couldn’t read some drafts on this device.',
|
|
489
490
|
documentDraftBackingUp: 'Backing up…',
|
|
490
|
-
documentDraftOption: (index: number, date: string, source: 'durable' | 'rescue') => `${date} · ${source === 'rescue' ? 'Temporary copy' : 'Draft'} ${index}`,
|
|
491
491
|
narrationCompositionInterrupted: 'Typing with the input method was interrupted. Your draft is kept; review it before saving, or keep editing.',
|
|
492
492
|
narrationRefresh: 'The script was written, but the preview has not updated yet. Your draft is kept; retry after the preview recovers.',
|
|
493
493
|
narrationDuring: 'During animation',
|
|
@@ -615,6 +615,8 @@ const en: WorkbenchMessages = {
|
|
|
615
615
|
formattedEdit: 'This text has formatting or special content and can’t be edited directly. Rewrite it with AI?',
|
|
616
616
|
rewriteEdit: 'Rewrite with AI',
|
|
617
617
|
versionHistory: 'Version History',
|
|
618
|
+
historyWithDrafts: (count: number) => `Version History (${count} local ${count === 1 ? 'draft' : 'drafts'})`,
|
|
619
|
+
historySavedVersions: 'Saved Versions',
|
|
618
620
|
historyNewer: 'Newer versions',
|
|
619
621
|
historyOlder: 'Older versions',
|
|
620
622
|
exportPane: 'Export',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
|
|
2
2
|
import type { ReactNode, RefObject } from 'react'
|
|
3
|
-
import { PmButton, PmDialog, PmIconButton, PmMenu, PmNotice, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
3
|
+
import { PmBadge, PmButton, PmDialog, PmIcon, PmIconButton, PmMenu, PmNotice, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
4
4
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
5
|
import { failureReason, timeAgo } from '../messages.ts'
|
|
6
6
|
import { SHORTCUTS } from '../shortcuts.ts'
|
|
@@ -364,6 +364,8 @@ function DocumentToolbar({ presentButton, framed, onBack, actions, aside, naviga
|
|
|
364
364
|
const history = useWorkbenchState(state => state.history)
|
|
365
365
|
const editorHistory = useWorkbenchState(state => state.editorHistory)
|
|
366
366
|
const dirty = useWorkbenchState(state => Boolean(state.authoring?.dirty))
|
|
367
|
+
const draftCount = useWorkbenchState(state => state.authoring?.recoveryDrafts?.length ?? 0)
|
|
368
|
+
const draftReadFailure = useWorkbenchState(state => Boolean(state.authoring?.recoveryReadFailure))
|
|
367
369
|
const busy = useWorkbenchState(state => state.isHistoryBusy || state.isHistoryPreparing || Boolean(state.isCreatingPage) || Boolean(state.isEditingPage || state.authoring?.composing) || isAgentChanging(state))
|
|
368
370
|
const timingDrafts = useWorkbenchState(state => state.hasDocumentTimingDrafts)
|
|
369
371
|
const preparing = useWorkbenchState(state => Boolean(state.isPreparingPresentation))
|
|
@@ -376,6 +378,7 @@ function DocumentToolbar({ presentButton, framed, onBack, actions, aside, naviga
|
|
|
376
378
|
const undoDisabled = Boolean(capabilities?.readOnly || !editorHistory?.undo && (editorHistory?.field || !history?.undo && !dirty) || busy)
|
|
377
379
|
const redoDisabled = Boolean(capabilities?.readOnly || !editorHistory?.redo && (editorHistory?.field || dirty || !history?.redo) || busy)
|
|
378
380
|
const commentsLabel = openComments ? `${t.comments} (${openComments})` : t.comments
|
|
381
|
+
const historyLabel = draftReadFailure ? `${t.versionHistory} · ${t.documentDraftUnreadable}` : draftCount ? t.historyWithDrafts(draftCount) : t.versionHistory
|
|
379
382
|
return (
|
|
380
383
|
<PmToolbar className={framed ? 'pmw-toolbar' : 'pmw-toolbar pmw-toolbar--document'} label={t.commands}>
|
|
381
384
|
{!framed && <div className="pmw-toolbar__document">
|
|
@@ -394,7 +397,7 @@ function DocumentToolbar({ presentButton, framed, onBack, actions, aside, naviga
|
|
|
394
397
|
{capabilities?.narration !== false && <PmToolbarButton asChild><PmIconButton small icon="captions" label={t.documentNarration} hint={t.documentNarrationHint} aria-pressed={aside === 'narration'} disabled={!hasStep} onClick={() => onAside('narration')} /></PmToolbarButton>}
|
|
395
398
|
</>}
|
|
396
399
|
{!compactCommands && <PmToolbarButton asChild><PmIconButton small icon="comment" label={commentsLabel} aria-pressed={aside === 'comments'} onClick={() => onAside('comments')} /></PmToolbarButton>}
|
|
397
|
-
{!narrow && <PmToolbarButton asChild><PmIconButton small icon="versions" label={
|
|
400
|
+
{!narrow && <span className="pmw-toolbar__history"><PmToolbarButton asChild><PmIconButton small icon="versions" label={historyLabel} aria-pressed={aside === 'history'} onClick={() => onAside('history')} /></PmToolbarButton>{(draftCount > 0 || draftReadFailure) && <PmBadge tone={draftReadFailure ? 'warn' : 'neutral'}>{draftCount || <PmIcon name="warning" />}</PmBadge>}</span>}
|
|
398
401
|
<span className="pmw-toolbar__divider" aria-hidden="true" />
|
|
399
402
|
<PmToolbarButton asChild><PmIconButton small icon="eye" label={t.readDocument} disabled={blocked || changingView} onClick={onRead} /></PmToolbarButton>
|
|
400
403
|
<PmToolbarButton asChild><PmIconButton ref={presentButton} small icon="slides" label={t.present} hint={preparing || changingView ? t.presentationPreparing : timingDrafts ? t.timingDraftPending : blocked ? t.presentationPending : t.presentHint} loading={preparing || changingView} disabled={blocked || changingView} onClick={onPresent} /></PmToolbarButton>
|
|
@@ -408,7 +411,7 @@ function DocumentToolbar({ presentButton, framed, onBack, actions, aside, naviga
|
|
|
408
411
|
] : [],
|
|
409
412
|
...capabilities?.production !== false ? [{ id: 'production', label: p.title, icon: 'arrange' as const, disabled: busy || !hasStep || changingView }] : [],
|
|
410
413
|
...capabilities?.narration !== false ? [{ id: 'narration', label: t.documentNarration, icon: 'captions' as const, disabled: !hasStep }] : [],
|
|
411
|
-
{ id: 'history', label:
|
|
414
|
+
{ id: 'history', label: historyLabel, icon: 'versions' },
|
|
412
415
|
]} onSelect={id => { if (id === 'undo') void workbench.undo(); else if (id === 'redo') void workbench.redo(); else if (id === 'production') onProduction(); else onAside(id as DocumentAside) }} />}
|
|
413
416
|
</PmToolbar>
|
|
414
417
|
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasRole } from '@lincyaw/kernel'
|
|
1
2
|
import type { HistoryRevision } from '@lincyaw/kernel'
|
|
2
3
|
import { PmBadge, PmButton, PmEmpty, PmIcon, PmIconButton, PmNotice } from '../components.tsx'
|
|
3
4
|
import type { IconName } from '@lincyaw/design'
|
|
@@ -26,11 +27,15 @@ export function HistoryPanel({ onClose, revisionAction }: HistoryPanelProps) {
|
|
|
26
27
|
const workbench = useWorkbench()
|
|
27
28
|
const history = useWorkbenchState(state => state.history)
|
|
28
29
|
const outside = useWorkbenchState(state => state.outside)
|
|
30
|
+
const source = useWorkbenchState(state => state.authoring)
|
|
29
31
|
const changing = useWorkbenchState(state => state.isHistoryBusy || state.isHistoryPreparing || isAgentChanging(state))
|
|
30
|
-
const busy = changing || revisionAction?.pendingRevision !== undefined
|
|
32
|
+
const busy = changing || revisionAction?.pendingRevision !== undefined || Boolean(source?.recovering)
|
|
31
33
|
const readOnly = workbench.client.capabilities?.readOnly === true
|
|
32
34
|
const locale = useWorkbenchState(state => state.locale)
|
|
33
35
|
const memberId = useWorkbenchState(state => state.authoring?.member?.id)
|
|
36
|
+
const drafts = source?.recoveryDrafts ?? []
|
|
37
|
+
const draftBusy = busy || readOnly || Boolean(source?.member && !hasRole(source.member, 'editor'))
|
|
38
|
+
|| !source?.identity || Boolean(source.loading || source.saving || source.composing || source.recovering)
|
|
34
39
|
const revisions = history?.revisions ?? []
|
|
35
40
|
// Undoing and redoing are not versions of their own: they mark the change they act on.
|
|
36
41
|
const changes = revisions.filter(revision => !revision.reverts)
|
|
@@ -48,6 +53,31 @@ export function HistoryPanel({ onClose, revisionAction }: HistoryPanelProps) {
|
|
|
48
53
|
<PmButton small disabled={busy} onClick={() => void workbench.recordOutsideChanges()}>{t.recordOutside}</PmButton>
|
|
49
54
|
</PmNotice>
|
|
50
55
|
)}
|
|
56
|
+
{source?.recoveryReadFailure && <PmNotice tone="warn">{t.documentDraftUnreadable}</PmNotice>}
|
|
57
|
+
{source?.recoveryChanged && <PmNotice tone="accent">{t.documentDraftChanged}</PmNotice>}
|
|
58
|
+
{drafts.length > 0 && <section className="pmw-history-group" aria-labelledby="pmw-history-drafts">
|
|
59
|
+
<header className="pmw-history-group__header">
|
|
60
|
+
<h3 id="pmw-history-drafts" className="pmw-pane__title">{t.documentDrafts} <PmBadge>{drafts.length}</PmBadge></h3>
|
|
61
|
+
{drafts.length > 1 && <PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) workbench.forgetDocumentDrafts(drafts, source.identity) }}>{t.documentDraftDiscardAll}</PmButton>}
|
|
62
|
+
</header>
|
|
63
|
+
<ol className="pmw-versions">
|
|
64
|
+
{drafts.map((draft, index) => <li key={JSON.stringify([draft.id, draft.revision, draft.token])} className="pmw-version">
|
|
65
|
+
<span className="pmw-version__icon" aria-hidden="true"><PmIcon name="edit" /></span>
|
|
66
|
+
<div className="pmw-version__body">
|
|
67
|
+
<p className="pmw-version__summary">{t.documentDraftName(index + 1)}</p>
|
|
68
|
+
<p className="pmw-version__meta">
|
|
69
|
+
<span>{t.unsaved}</span><span>·</span>
|
|
70
|
+
<time dateTime={new Date(draft.updatedAt).toISOString()} title={new Date(draft.updatedAt).toLocaleString(locale)}>{timeAgo(new Date(draft.updatedAt).toISOString(), locale)}</time>
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
<div className="pmw-version__actions">
|
|
74
|
+
<PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) void workbench.recoverDocumentDraft(draft, source.identity) }}>{t.documentDraftRestore}</PmButton>
|
|
75
|
+
<PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) workbench.forgetDocumentDrafts([draft], source.identity) }}>{t.narrationDiscard}</PmButton>
|
|
76
|
+
</div>
|
|
77
|
+
</li>)}
|
|
78
|
+
</ol>
|
|
79
|
+
</section>}
|
|
80
|
+
{drafts.length > 0 && <div className="pmw-history-group__header"><h3 className="pmw-pane__title">{t.historySavedVersions}</h3></div>}
|
|
51
81
|
{changes.length === 0
|
|
52
82
|
? <PmEmpty icon="versions">{t.noHistory}</PmEmpty>
|
|
53
83
|
: (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useEffect, useRef
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
2
|
import { hasRole } from '@lincyaw/kernel'
|
|
3
|
-
import { PmButton, PmNotice,
|
|
3
|
+
import { PmButton, PmNotice, PmSkeleton } from '../components.tsx'
|
|
4
4
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
5
|
import { DocumentEditor } from '../document-editor/DocumentEditor.tsx'
|
|
6
6
|
import { DOCUMENT_EDITOR_MESSAGES } from '../document-editor/messages.ts'
|
|
@@ -29,12 +29,6 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
|
|
|
29
29
|
const bodyEditor = useRef<NativeDocumentEditor>()
|
|
30
30
|
const editingPosition = useRef<{ nativeBlockId: string, sectionId: string, position: number, editor: NativeDocumentEditor, identity: string, reset: number | undefined }>()
|
|
31
31
|
const cancelReading = useRef<() => void>()
|
|
32
|
-
const [selectedDraft, setSelectedDraft] = useState('')
|
|
33
|
-
const drafts = source?.recoveryDrafts ?? []
|
|
34
|
-
const draftKey = (value: { id: string, revision: number, token: string }) => JSON.stringify([value.id, value.revision, value.token])
|
|
35
|
-
const draft = drafts.find(value => draftKey(value) === selectedDraft)
|
|
36
|
-
useEffect(() => { setSelectedDraft('') }, [source?.identity])
|
|
37
|
-
const recoveryDisabled = readOnly || source?.saving || source?.composing || source?.recovering
|
|
38
32
|
useEffect(() => {
|
|
39
33
|
const element = container.current
|
|
40
34
|
if (element && source?.identity && source.content) return workbench.editing.attachViewport(element, source.identity)
|
|
@@ -154,20 +148,9 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
|
|
|
154
148
|
const error = source?.error === 'document-version-changed' || source?.error === 'document-identity-changed' ? messages.conflict
|
|
155
149
|
: source?.error ? messages.saveFailure : undefined
|
|
156
150
|
return <section ref={container} className="pmw-source-document" aria-label={t.documentEditor} aria-busy={source?.loading || undefined}>
|
|
157
|
-
{Boolean(positionFailure || source?.storageFailure || source?.
|
|
151
|
+
{Boolean(positionFailure || source?.storageFailure || source?.restored || error) && <div className="pmw-source-document__notices">
|
|
158
152
|
{positionFailure && <PmNotice tone="warn">{t.documentPositionRemoved}</PmNotice>}
|
|
159
|
-
{
|
|
160
|
-
{Boolean(drafts.length || source?.recoveryChanged) && <PmNotice tone="accent"><div className="pmw-source-document__recovery">
|
|
161
|
-
<span>{source?.recoveryChanged ? t.documentDraftChanged : t.documentDraftFound}</span>
|
|
162
|
-
<PmSelect label={t.documentDraftSelect} value={draft ? selectedDraft : ''} disabled={Boolean(recoveryDisabled)} onChange={event => setSelectedDraft(event.currentTarget.value)}>
|
|
163
|
-
<option value="">{t.documentDraftChoose}</option>
|
|
164
|
-
{drafts.map((value, index) => <option key={draftKey(value)} value={draftKey(value)}>{t.documentDraftOption(index + 1, new Intl.DateTimeFormat(locale, { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(value.updatedAt), value.source)}</option>)}
|
|
165
|
-
</PmSelect>
|
|
166
|
-
<div className="pmw-source-document__recovery-actions">
|
|
167
|
-
<PmButton small variant="primary" disabled={!draft || Boolean(recoveryDisabled)} onClick={() => { if (draft && source?.identity) void workbench.recoverDocumentDraft(draft, source.identity) }}>{t.documentDraftRestore}</PmButton>
|
|
168
|
-
<PmButton small disabled={!draft || Boolean(recoveryDisabled)} onClick={() => { if (draft && source?.identity) workbench.forgetDocumentDraft(draft, source.identity) }}>{t.narrationDiscard}</PmButton>
|
|
169
|
-
</div>
|
|
170
|
-
</div></PmNotice>}
|
|
153
|
+
{source?.storageFailure && <PmNotice tone="warn">{t.narrationRecoveryUnavailable}</PmNotice>}
|
|
171
154
|
{source?.restored && !error && <PmNotice tone="accent"><span>{messages.restored}</span><span className="pmw-notice__actions"><PmButton small onClick={() => void workbench.retryDocument()}>{t.retry}</PmButton><PmButton small onClick={() => void workbench.discardDocument()}>{t.narrationDiscard}</PmButton></span></PmNotice>}
|
|
172
155
|
{error && <PmNotice tone="danger"><span>{error}</span><span className="pmw-notice__actions"><PmButton small onClick={() => void workbench.retryDocument()}>{t.retry}</PmButton>{source?.dirty && <PmButton small onClick={() => void workbench.discardDocument()}>{t.narrationDiscard}</PmButton>}</span></PmNotice>}
|
|
173
156
|
</div>}
|
package/src/styles.css
CHANGED
|
@@ -721,6 +721,11 @@
|
|
|
721
721
|
justify-self: start;
|
|
722
722
|
}
|
|
723
723
|
|
|
724
|
+
.pmw-version__actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: var(--pm-space-2); }
|
|
725
|
+
.pmw-history-group { display: grid; gap: var(--pm-space-2); }
|
|
726
|
+
.pmw-history-group__header { display: flex; align-items: center; gap: var(--pm-space-2); padding-inline: var(--pm-space-3); }
|
|
727
|
+
.pmw-toolbar__history { display: inline-flex; align-items: center; gap: var(--pm-space-1); }
|
|
728
|
+
|
|
724
729
|
/* Above the video: its file. */
|
|
725
730
|
|
|
726
731
|
|
|
@@ -921,8 +926,6 @@
|
|
|
921
926
|
.pmw-document__source[hidden] { display: none; }
|
|
922
927
|
.pmw-source-document { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: var(--pm-space-5); background: var(--pm-color-canvas); }
|
|
923
928
|
.pmw-source-document__notices { position: sticky; inset-block-start: 0; z-index: var(--pm-z-site-header); display: grid; gap: var(--pm-space-3); margin-block-end: var(--pm-space-3); }
|
|
924
|
-
.pmw-source-document__recovery { display: grid; gap: var(--pm-space-2); min-width: 0; }
|
|
925
|
-
.pmw-source-document__recovery-actions { display: flex; flex-wrap: wrap; gap: var(--pm-space-2); }
|
|
926
929
|
.pmw-source-document__diagnostics { margin-block-end: var(--pm-space-3); }
|
|
927
930
|
/* Its end margin is the editor's own end area, which fills the rest of the sheet and takes the presses below the last block. */
|
|
928
931
|
.pmw-source-document__sheet { display: flex; flex-direction: column; max-width: var(--pm-sheet-width); min-height: 100%; margin-inline: auto; padding-block-start: var(--pm-space-4); background: var(--pm-color-surface); box-shadow: var(--pm-shadow-page); }
|
package/src/workbench.ts
CHANGED
|
@@ -1163,7 +1163,10 @@ export class Workbench {
|
|
|
1163
1163
|
return this.#state.authoring?.identity === identity && !isAgentChanging(this.#state) ? this.#documentSession.recoverDraft(value).then(() => {}) : Promise.resolve()
|
|
1164
1164
|
}
|
|
1165
1165
|
forgetDocumentDraft(value: DocumentDraftReference, identity: string): void {
|
|
1166
|
-
|
|
1166
|
+
this.forgetDocumentDrafts([value], identity)
|
|
1167
|
+
}
|
|
1168
|
+
forgetDocumentDrafts(values: readonly DocumentDraftReference[], identity: string): void {
|
|
1169
|
+
if (this.#state.authoring?.identity === identity && !isAgentChanging(this.#state)) void this.#documentSession.forgetDrafts(values)
|
|
1167
1170
|
}
|
|
1168
1171
|
documentError(error: Error): void { this.#set({ save: { kind: 'failed', message: error.message } }) }
|
|
1169
1172
|
async flushPendingEdits(signal?: AbortSignal): Promise<void> {
|