@lincyaw/workbench 0.2.0-rc.120 → 0.2.0-rc.122
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/components.tsx +24 -4
- package/src/context.tsx +17 -0
- package/src/document-editor/BlockNoteSurface.tsx +4 -1
- package/src/document-editor/DocumentBlockFallback.tsx +0 -1
- package/src/document-editor/DocumentEditor.tsx +7 -1
- package/src/document-editor/authoring.tsx +15 -0
- package/src/document-editor/inline.ts +5 -0
- package/src/document-editor/insertion-place.ts +2 -2
- package/src/document-editor/messages.ts +2 -2
- package/src/document-editor/projection.ts +6 -4
- package/src/document-editor/references.tsx +332 -0
- package/src/document-editor/schema.tsx +39 -2
- package/src/document-editor/style.css +10 -0
- package/src/document-production.ts +8 -0
- package/src/document-tree.ts +239 -0
- package/src/import-messages.ts +1 -1
- package/src/index.ts +6 -1
- package/src/knowledge-components.tsx +547 -0
- package/src/knowledge.css +320 -0
- package/src/messages.ts +2 -0
- package/src/panels/DocumentView.tsx +37 -23
- package/src/panels/DocumentVoiceField.tsx +3 -2
- package/src/panels/HomePanel.tsx +12 -3
- package/src/panels/ProductionCaptionSize.tsx +8 -3
- package/src/panels/ReferencesPanel.tsx +115 -0
- package/src/panels/SourceDocumentPanel.tsx +21 -3
- package/src/panels/WorkspaceHome.tsx +93 -0
- package/src/panels/WorkspaceSidebar.tsx +331 -0
- package/src/styles.css +1 -0
- package/src/tree-messages.ts +299 -0
- package/src/workbench-state.ts +13 -0
- package/src/workbench.ts +28 -2
- package/src/workspace-client.ts +25 -1
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/* The workspace sidebar, the right pane's references and outline, and the home page: layout only; the controls are
|
|
2
|
+
the shared ones (docs/design-system.md). */
|
|
3
|
+
|
|
4
|
+
.pmw-sidebar {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: var(--pm-space-2);
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
height: 100%;
|
|
10
|
+
min-height: 0;
|
|
11
|
+
padding: var(--pm-space-3) var(--pm-space-2);
|
|
12
|
+
background: var(--pm-color-chrome);
|
|
13
|
+
color: var(--pm-color-ink);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.pmw-sidebar__header {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
gap: var(--pm-space-2);
|
|
20
|
+
padding: 0 var(--pm-space-1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.pmw-sidebar__mark {
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
flex: none;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
width: var(--pm-size-avatar);
|
|
29
|
+
height: var(--pm-size-avatar);
|
|
30
|
+
border-radius: var(--pm-radius-small);
|
|
31
|
+
background: var(--pm-color-accent);
|
|
32
|
+
color: var(--pm-color-on-accent);
|
|
33
|
+
font-size: var(--pm-text-sm);
|
|
34
|
+
font-weight: var(--pm-weight-semibold);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.pmw-sidebar__workspace {
|
|
38
|
+
display: grid;
|
|
39
|
+
flex: 1;
|
|
40
|
+
min-width: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.pmw-sidebar__name {
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
font-size: var(--pm-text-sm);
|
|
46
|
+
font-weight: var(--pm-weight-semibold);
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.pmw-sidebar__meta {
|
|
52
|
+
color: var(--pm-color-muted);
|
|
53
|
+
font-size: var(--pm-text-xs);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.pmw-sidebar__places,
|
|
57
|
+
.pmw-recent {
|
|
58
|
+
display: grid;
|
|
59
|
+
gap: var(--pm-space-px);
|
|
60
|
+
margin: 0;
|
|
61
|
+
padding: 0;
|
|
62
|
+
list-style: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.pmw-sidebar__section {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
margin-top: var(--pm-space-2);
|
|
70
|
+
padding: 0 var(--pm-space-1) 0 var(--pm-space-2);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.pmw-sidebar__heading {
|
|
74
|
+
margin: 0;
|
|
75
|
+
color: var(--pm-color-muted);
|
|
76
|
+
font-size: var(--pm-text-xs);
|
|
77
|
+
font-weight: var(--pm-weight-medium);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.pmw-sidebar__tree {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex: 1;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
min-height: 0;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.pmw-sidebar__empty {
|
|
89
|
+
padding: 0 var(--pm-space-2);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.pmw-sidebar__trash {
|
|
93
|
+
flex: none;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.pmw-recent {
|
|
97
|
+
min-width: var(--pm-popover-min-width);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.pmw-recent__item {
|
|
101
|
+
display: grid;
|
|
102
|
+
grid-template-columns: auto 1fr auto;
|
|
103
|
+
column-gap: var(--pm-space-2);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.pmw-recent__item > .pm-ui-icon {
|
|
107
|
+
grid-row: span 2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.pmw-recent__title {
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
text-overflow: ellipsis;
|
|
113
|
+
white-space: nowrap;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.pmw-recent__path {
|
|
117
|
+
grid-column: 2;
|
|
118
|
+
color: var(--pm-color-muted);
|
|
119
|
+
font-size: var(--pm-text-xs);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.pmw-recent__time {
|
|
123
|
+
grid-column: 3;
|
|
124
|
+
grid-row: 1;
|
|
125
|
+
color: var(--pm-color-muted);
|
|
126
|
+
font-size: var(--pm-text-xs);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.pmw-recent__empty {
|
|
130
|
+
margin: 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.pmw-trash {
|
|
134
|
+
display: grid;
|
|
135
|
+
gap: var(--pm-space-2);
|
|
136
|
+
margin: 0;
|
|
137
|
+
padding: 0;
|
|
138
|
+
list-style: none;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.pmw-trash__item {
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-wrap: wrap;
|
|
144
|
+
align-items: center;
|
|
145
|
+
gap: var(--pm-space-2);
|
|
146
|
+
padding: var(--pm-space-2) 0;
|
|
147
|
+
border-bottom: var(--pm-size-hairline) solid var(--pm-color-line);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.pmw-trash__text {
|
|
151
|
+
display: grid;
|
|
152
|
+
flex: 1;
|
|
153
|
+
min-width: var(--pm-menu-min-width);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.pmw-trash__meta {
|
|
157
|
+
color: var(--pm-color-muted);
|
|
158
|
+
font-size: var(--pm-text-xs);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.pmw-references {
|
|
162
|
+
display: grid;
|
|
163
|
+
grid-template-columns: minmax(0, 1fr);
|
|
164
|
+
align-content: start;
|
|
165
|
+
gap: var(--pm-space-4);
|
|
166
|
+
min-width: 0;
|
|
167
|
+
padding: var(--pm-space-3);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.pmw-references__group {
|
|
171
|
+
display: grid;
|
|
172
|
+
grid-template-columns: minmax(0, 1fr);
|
|
173
|
+
gap: var(--pm-space-2);
|
|
174
|
+
min-width: 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.pmw-references__heading {
|
|
178
|
+
margin: 0;
|
|
179
|
+
color: var(--pm-color-muted);
|
|
180
|
+
font-size: var(--pm-text-xs);
|
|
181
|
+
font-weight: var(--pm-weight-medium);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.pmw-references__list,
|
|
185
|
+
.pmw-references__links {
|
|
186
|
+
display: grid;
|
|
187
|
+
grid-template-columns: minmax(0, 1fr);
|
|
188
|
+
gap: var(--pm-space-2);
|
|
189
|
+
margin: 0;
|
|
190
|
+
padding: 0;
|
|
191
|
+
list-style: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.pmw-references__links {
|
|
195
|
+
gap: var(--pm-space-px);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.pmw-references__link:not([aria-disabled]) {
|
|
199
|
+
color: var(--pm-color-accent);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.pmw-references__title {
|
|
203
|
+
overflow: hidden;
|
|
204
|
+
text-overflow: ellipsis;
|
|
205
|
+
white-space: nowrap;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.pmw-references-summary {
|
|
209
|
+
max-width: var(--pm-sheet-width);
|
|
210
|
+
margin: var(--pm-space-4) auto var(--pm-space-8);
|
|
211
|
+
border: var(--pm-size-hairline) solid var(--pm-color-line);
|
|
212
|
+
border-radius: var(--pm-radius-control);
|
|
213
|
+
background: var(--pm-color-surface);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.pmw-references-summary__row {
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
justify-content: space-between;
|
|
220
|
+
gap: var(--pm-space-2);
|
|
221
|
+
padding: var(--pm-space-2) var(--pm-space-3);
|
|
222
|
+
color: var(--pm-color-muted);
|
|
223
|
+
font-size: var(--pm-text-sm);
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
list-style: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.pmw-references-summary__row::-webkit-details-marker {
|
|
229
|
+
display: none;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.pmw-references-summary[open] .pmw-references-summary__row > .pm-ui-icon {
|
|
233
|
+
transform: rotate(90deg);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.pmw-rail {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
height: 100%;
|
|
240
|
+
min-height: 0;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.pmw-rail__header {
|
|
244
|
+
display: flex;
|
|
245
|
+
flex: none;
|
|
246
|
+
align-items: center;
|
|
247
|
+
gap: var(--pm-space-1);
|
|
248
|
+
padding-inline-end: var(--pm-space-2);
|
|
249
|
+
border-bottom: var(--pm-size-hairline) solid var(--pm-color-line);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.pmw-rail__header > .pm-ui-tabs-root {
|
|
253
|
+
flex: 1;
|
|
254
|
+
min-width: 0;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.pmw-rail__body {
|
|
258
|
+
flex: 1;
|
|
259
|
+
min-width: 0;
|
|
260
|
+
min-height: 0;
|
|
261
|
+
overflow-x: hidden;
|
|
262
|
+
overflow-y: auto;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.pmw-rail {
|
|
266
|
+
min-width: 0;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.pmw-rail__actions {
|
|
270
|
+
display: flex;
|
|
271
|
+
justify-content: flex-end;
|
|
272
|
+
padding: var(--pm-space-2) var(--pm-space-2) 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* The page outline as a tab of the right pane fills it instead of standing at the page's start edge. */
|
|
276
|
+
.pmw-document .pmw-rail .pmw-rail__body > .pmw-navigation {
|
|
277
|
+
position: static;
|
|
278
|
+
flex: 1 1 auto;
|
|
279
|
+
width: auto;
|
|
280
|
+
height: 100%;
|
|
281
|
+
border-right: 0;
|
|
282
|
+
box-shadow: none;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.pmw-workspace-home__meta {
|
|
286
|
+
margin-top: calc(var(--pm-space-3) * -1);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.pmw-workspace-home__start {
|
|
290
|
+
display: grid;
|
|
291
|
+
grid-template-columns: repeat(auto-fill, minmax(var(--pm-menu-min-width), 1fr));
|
|
292
|
+
gap: var(--pm-space-3);
|
|
293
|
+
margin: 0;
|
|
294
|
+
padding: 0;
|
|
295
|
+
list-style: none;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.pmw-workspace-home__start .pm-ui-card {
|
|
299
|
+
height: 100%;
|
|
300
|
+
gap: var(--pm-space-2);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.pmw-workspace-home__attention {
|
|
304
|
+
display: grid;
|
|
305
|
+
gap: var(--pm-space-2);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.pmw-workspace-home__path,
|
|
309
|
+
.pmw-workspace-home__time {
|
|
310
|
+
flex: none;
|
|
311
|
+
color: var(--pm-color-muted);
|
|
312
|
+
font-size: var(--pm-text-xs);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.pmw-workspace-home__path {
|
|
316
|
+
flex: 1;
|
|
317
|
+
overflow: hidden;
|
|
318
|
+
text-overflow: ellipsis;
|
|
319
|
+
white-space: nowrap;
|
|
320
|
+
}
|
package/src/messages.ts
CHANGED
|
@@ -321,6 +321,7 @@ const zh = {
|
|
|
321
321
|
historyFailureReasons: {
|
|
322
322
|
'history-target-changed': '版本历史已变化,这一更改不再是下一步可撤消或恢复的更改。请查看最新的历史后重试。',
|
|
323
323
|
'history-conflict': '这次更改之后,相关内容又被修改过,或有尚未记入版本的修改,无法自动撤消。',
|
|
324
|
+
'history-format-boundary': '这一版本是文稿格式的升级(或文稿的创建),无法撤消或还原到它之前:之前的版本是旧格式,当前版本无法打开。',
|
|
324
325
|
'history-source-changed': '文稿已在别处修改,请查看最新的历史后重试。',
|
|
325
326
|
'history-snapshot-changed': '版本历史已变化,请查看最新的历史后重试。',
|
|
326
327
|
'history-revision-not-found': '找不到这个版本,它可能已不在当前历史中。',
|
|
@@ -693,6 +694,7 @@ const en: WorkbenchMessages = {
|
|
|
693
694
|
historyFailureReasons: {
|
|
694
695
|
'history-target-changed': 'Version History changed; this change is no longer the next one to undo or redo. Review the latest history and try again.',
|
|
695
696
|
'history-conflict': 'The content was changed again after this change, or has changes not yet saved as a version, so it can’t be undone automatically.',
|
|
697
|
+
'history-format-boundary': 'This version upgraded the document’s format (or created the document), so it can’t be undone or restored to an earlier version: those are in the earlier format, which this version can’t open.',
|
|
696
698
|
'history-source-changed': 'The document changed elsewhere. Review the latest history and try again.',
|
|
697
699
|
'history-snapshot-changed': 'Version History changed. Review the latest history and try again.',
|
|
698
700
|
'history-revision-not-found': 'Couldn’t find this version; it may no longer be in the current history.',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
2
|
import { useContainerLayout } from '../container-layout.ts'
|
|
3
3
|
import type { ReactNode, RefObject } from 'react'
|
|
4
|
-
import { PmBadge, PmButton, PmDialog, PmIcon, PmIconButton, PmMenu, PmNotice, PmPanelHeader, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
5
|
-
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
4
|
+
import { PmBadge, PmButton, PmDialog, PmIcon, PmIconButton, PmMenu, PmNotice, PmPanelHeader, PmSkeleton, PmSortableList, PmTabs, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
5
|
+
import { useMessages, useTreeMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
6
|
+
import { ReferencesPanel, ReferencesSummary } from './ReferencesPanel.tsx'
|
|
6
7
|
import { failureReason, timeAgo } from '../messages.ts'
|
|
7
8
|
import { SHORTCUTS } from '../shortcuts.ts'
|
|
8
9
|
import { DocumentOutline, DocumentWordCounter } from '../outline.ts'
|
|
@@ -18,9 +19,14 @@ import { PageDeleteDialog } from './PageDeleteDialog.tsx'
|
|
|
18
19
|
import { SourceDocumentPanel } from './SourceDocumentPanel.tsx'
|
|
19
20
|
import { DocumentNarrationPanel } from './DocumentNarrationPanel.tsx'
|
|
20
21
|
|
|
21
|
-
export type DocumentAside = 'comments' | 'history' | 'export' | 'narration'
|
|
22
|
+
export type DocumentAside = 'outline' | 'references' | 'comments' | 'history' | 'export' | 'narration'
|
|
23
|
+
/** The right pane's tabs: the page outline, the references and the comments. */
|
|
24
|
+
const RAIL_TABS: readonly DocumentAside[] = ['outline', 'references', 'comments']
|
|
25
|
+
const isRail = (aside: DocumentAside | null): aside is 'outline' | 'references' | 'comments' => aside !== null && RAIL_TABS.includes(aside)
|
|
22
26
|
|
|
23
27
|
const isTyping = (target: EventTarget | null) => target instanceof HTMLElement && (target.isContentEditable || target.closest('input, textarea, select, [contenteditable]') !== null)
|
|
28
|
+
// Keys pressed in the document's page (the editor, its references, synced blocks and previews) belong to the editor.
|
|
29
|
+
const inDocument = (target: EventTarget | null) => target instanceof Element && target.closest('.pmw-document__source') !== null
|
|
24
30
|
|
|
25
31
|
// Esc belongs to the topmost dialog or menu first; only then does it leave the presentation.
|
|
26
32
|
const hasOpenLayer = () => document.querySelector('[role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]') !== null
|
|
@@ -41,27 +47,23 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
41
47
|
const presentButton = useRef<HTMLButtonElement>(null)
|
|
42
48
|
const [commentsPortal, setCommentsPortal] = useState<HTMLDivElement | null>(null)
|
|
43
49
|
const t = useMessages()
|
|
50
|
+
const tt = useTreeMessages()
|
|
44
51
|
const document = useWorkbenchState(state => state.document)
|
|
45
52
|
const sourceIdentity = useWorkbenchState(state => state.authoring?.identity)
|
|
46
53
|
const view = useWorkbenchState(state => state.webView)
|
|
47
54
|
const previousView = useRef({ document, workspace, view, active })
|
|
48
55
|
const currentScope = useRef({ document, active })
|
|
49
56
|
currentScope.current = { document, active }
|
|
50
|
-
const [navigation, setNavigation] = useState(false)
|
|
51
57
|
const container = useContainerLayout(), { roomy, narrow } = container
|
|
52
58
|
const previousRoomy = useRef<boolean>()
|
|
59
|
+
// A roomy layout opens with the outline in the right pane; where the pane would cover the page it starts closed.
|
|
53
60
|
useEffect(() => {
|
|
54
61
|
if (!container.measured) return
|
|
55
|
-
if (!roomy)
|
|
56
|
-
else if (previousRoomy.current === undefined)
|
|
62
|
+
if (!roomy) setAside(current => isRail(current) ? null : current)
|
|
63
|
+
else if (previousRoomy.current === undefined) setAside(current => current ?? 'outline')
|
|
57
64
|
previousRoomy.current = roomy
|
|
58
65
|
}, [roomy, container.measured])
|
|
59
|
-
|
|
60
|
-
const [navigationDocument, setNavigationDocument] = useState(document)
|
|
61
|
-
if (navigationDocument !== document) {
|
|
62
|
-
setNavigationDocument(document)
|
|
63
|
-
if (navigation && !roomy) setNavigation(false)
|
|
64
|
-
}
|
|
66
|
+
const navigation = isRail(aside)
|
|
65
67
|
const compilePresentation = async (ready?: () => void, forReading = false, signal?: AbortSignal, deadline?: number): Promise<void> => {
|
|
66
68
|
if (preparing.current || workbench.getState().isPreparingPresentation) return
|
|
67
69
|
preparing.current = true
|
|
@@ -153,7 +155,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
153
155
|
transition.current++; exiting.current = undefined
|
|
154
156
|
setWorkspace('document')
|
|
155
157
|
setChangingView(false); setViewFailure(undefined)
|
|
156
|
-
setAside(null)
|
|
158
|
+
setAside(current => isRail(current) && roomy ? current : null)
|
|
157
159
|
}, [document])
|
|
158
160
|
useEffect(() => { if (!active) { transition.current++; exiting.current = undefined; setChangingView(false) } }, [active])
|
|
159
161
|
useEffect(() => () => { transition.current++ }, [])
|
|
@@ -181,7 +183,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
181
183
|
if (!event.repeat) void workbench.flushPendingEdits().catch(() => {})
|
|
182
184
|
}
|
|
183
185
|
const keys = (event: KeyboardEvent) => {
|
|
184
|
-
if (event.defaultPrevented || isTyping(event.target) || !(event.ctrlKey || event.metaKey) || event.altKey) return
|
|
186
|
+
if (event.defaultPrevented || isTyping(event.target) || inDocument(event.target) || !(event.ctrlKey || event.metaKey) || event.altKey) return
|
|
185
187
|
const key = event.key.toLowerCase()
|
|
186
188
|
if (key === 'z' && !event.shiftKey) {
|
|
187
189
|
event.preventDefault()
|
|
@@ -224,15 +226,24 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
224
226
|
workbench.setMode('viewing')
|
|
225
227
|
workbench.setWebView('present')
|
|
226
228
|
setWorkspace('presentation')
|
|
227
|
-
})} onNavigation={() =>
|
|
229
|
+
})} onNavigation={() => setAside(current => isRail(current) ? null : 'outline')} onAside={next => setAside(current => (current === next ? null : next))} />}
|
|
228
230
|
{viewFailure && <PmNotice tone="danger">{viewFailure}</PmNotice>}
|
|
229
231
|
<DocumentNotices />
|
|
230
232
|
<div className="pmw-document__body" role="region" aria-label={producing ? PRODUCTION_MESSAGES[workbench.getState().locale].title : presenting ? t.presentationPreview : reading ? t.readDocument : t.documentEditor}>
|
|
231
|
-
{
|
|
232
|
-
<div className="pmw-document__main"><div className="pmw-document__source" hidden={presenting || producing || reading}><SourceDocumentPanel commentsPortal={commentsPortal} onCommentDraftRestore={() => setAside(current => current === 'comments' ? null : current)} onOpenComments={() => setAside('comments')} /></div>{producing && <ProductionPanel actions={actions} active={active} closing={changingView} onClose={() => void exitPresent()} />}{presenting && <PreviewPanel presentation active={active} onPresentationAction={action => { if (action === 'refresh') void compilePresentation(); else void exitPresent() }} />}{reading && <PreviewPanel active={active} />}</div>
|
|
233
|
+
<div className="pmw-document__main"><div className="pmw-document__source" hidden={presenting || producing || reading}><SourceDocumentPanel commentsPortal={commentsPortal} onCommentDraftRestore={() => setAside(current => current === 'comments' ? null : current)} onOpenComments={() => setAside('comments')} after={narrow ? <ReferencesSummary /> : undefined} /></div>{producing && <ProductionPanel actions={actions} active={active} closing={changingView} onClose={() => void exitPresent()} />}{presenting && <PreviewPanel presentation active={active} onPresentationAction={action => { if (action === 'refresh') void compilePresentation(); else void exitPresent() }} />}{reading && <PreviewPanel active={active} />}</div>
|
|
233
234
|
{!presenting && !producing && !reading && aside && (
|
|
234
|
-
<aside className="pmw-document__aside pm-ui-block-editor" aria-label={{ narration: t.documentNarration, comments: t.comments, export: t.exportPane, history: t.versionHistory }[aside]}>
|
|
235
|
-
{aside
|
|
235
|
+
<aside className="pmw-document__aside pm-ui-block-editor" aria-label={{ outline: tt.outline, references: tt.references, narration: t.documentNarration, comments: t.comments, export: t.exportPane, history: t.versionHistory }[aside]}>
|
|
236
|
+
{isRail(aside) ? <section className="pmw-pane pmw-rail">
|
|
237
|
+
<div className="pmw-rail__header">
|
|
238
|
+
<PmTabs variant="dock" value={aside} label={tt.rail} tabs={[{ value: 'outline', label: tt.outline }, { value: 'references', label: tt.references }, { value: 'comments', label: t.comments }]} onValueChange={value => setAside(value as DocumentAside)} />
|
|
239
|
+
<PmIconButton small icon="close" label={t.close} onClick={() => setAside(null)} />
|
|
240
|
+
</div>
|
|
241
|
+
<div className="pmw-rail__body">
|
|
242
|
+
{aside === 'outline' && <NavigationPane embedded onClose={() => setAside(null)} onSelect={() => { if (!roomy) setAside(null) }} />}
|
|
243
|
+
{aside === 'references' && <ReferencesPanel />}
|
|
244
|
+
{aside === 'comments' && <div ref={setCommentsPortal} />}
|
|
245
|
+
</div>
|
|
246
|
+
</section> : aside === 'narration' ? <DocumentNarrationPanel onClose={() => setAside(null)} /> : aside === 'export' ? <ExportPanel documentOnly onClose={() => setAside(null)} /> : <HistoryPanel onClose={() => setAside(null)} revisionAction={historyRevisionAction} />}
|
|
236
247
|
</aside>
|
|
237
248
|
)}
|
|
238
249
|
</div>
|
|
@@ -242,7 +253,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
242
253
|
}
|
|
243
254
|
|
|
244
255
|
/** The document's sections, or its slides: where the preview is, and a click to go to another. */
|
|
245
|
-
function NavigationPane({ onClose, onSelect }: { onClose(): void, onSelect(): void }) {
|
|
256
|
+
function NavigationPane({ embedded, onClose, onSelect }: { embedded?: boolean, onClose(): void, onSelect(): void }) {
|
|
246
257
|
const t = useMessages()
|
|
247
258
|
const workbench = useWorkbench()
|
|
248
259
|
const outline = useMemo(() => new DocumentOutline(), [])
|
|
@@ -287,10 +298,12 @@ function NavigationPane({ onClose, onSelect }: { onClose(): void, onSelect(): vo
|
|
|
287
298
|
}
|
|
288
299
|
return (
|
|
289
300
|
<nav className="pmw-navigation" aria-label={t.navigation}>
|
|
290
|
-
<
|
|
301
|
+
{embedded ? editing && <div className="pmw-rail__actions">
|
|
302
|
+
<PmButton small variant="ghost" icon="plus" loading={creating} disabled={!canCreate || pageBusy || !items.length} onClick={() => { if (workbench.editing.createPage()) onSelect() }}>{t.newPage}</PmButton>
|
|
303
|
+
</div> : <PmPanelHeader className="pmw-pane__header" title={editing ? t.pages : slides ? t.renderers.slides : t.navigation} actions={<>
|
|
291
304
|
{editing && <PmIconButton icon="plus" label={t.newPage} small loading={creating} disabled={!canCreate || pageBusy || !items.length} onClick={() => { if (workbench.editing.createPage()) onSelect() }} />}
|
|
292
305
|
<PmIconButton icon="close" label={t.closeNavigation} small onClick={onClose} />
|
|
293
|
-
</>} />
|
|
306
|
+
</>} />}
|
|
294
307
|
{failure && !renaming && !deleting && <PmNotice tone="danger">{failure}</PmNotice>}
|
|
295
308
|
{items.length === 0 && loading ? <div className="pmw-navigation__empty"><PmSkeleton shape="list" label={t.loadingPages} /></div>
|
|
296
309
|
: items.length === 0
|
|
@@ -348,6 +361,7 @@ function StatusBar() {
|
|
|
348
361
|
|
|
349
362
|
function DocumentToolbar({ narrow, presentButton, framed, onBack, actions, aside, navigation, changingView, onProduction, onRead, onPresent, onNavigation, onAside }: { narrow: boolean, presentButton: RefObject<HTMLButtonElement>, framed: boolean, onBack?(): void, actions?: ReactNode, aside: DocumentAside | null, navigation: boolean, changingView: boolean, onProduction(): void, onRead(): void, onPresent(): void, onNavigation(): void, onAside(aside: DocumentAside): void }) {
|
|
350
363
|
const t = useMessages()
|
|
364
|
+
const tt = useTreeMessages()
|
|
351
365
|
const workbench = useWorkbench()
|
|
352
366
|
const p = PRODUCTION_MESSAGES[useWorkbenchState(state => state.locale)]
|
|
353
367
|
const title = useWorkbenchState(state => state.authoring?.content?.metadata.title ?? state.documents?.documents.find(doc => doc.dir === state.document)?.title ?? '')
|
|
@@ -374,7 +388,7 @@ function DocumentToolbar({ narrow, presentButton, framed, onBack, actions, aside
|
|
|
374
388
|
<PmToolbarButton asChild><PmIconButton icon="arrow-left" label={t.back} small onClick={() => onBack ? onBack() : workbench.closeDocument()} /></PmToolbarButton>
|
|
375
389
|
<h1 className="pmw-toolbar__title" title={title}>{title}</h1>
|
|
376
390
|
</div>}
|
|
377
|
-
<PmToolbarButton asChild><PmIconButton small icon="
|
|
391
|
+
<PmToolbarButton asChild><PmIconButton small icon="rail" label={tt.rail} aria-pressed={navigation} onClick={onNavigation} /></PmToolbarButton>
|
|
378
392
|
{!compactCommands && <>
|
|
379
393
|
<PmToolbarButton asChild><PmIconButton small icon="undo" label={t.undo} shortcut={SHORTCUTS.undo} disabled={undoDisabled} onClick={() => void workbench.undo()} /></PmToolbarButton>
|
|
380
394
|
<PmToolbarButton asChild><PmIconButton small icon="redo" label={t.redo} shortcut={SHORTCUTS.redo} disabled={redoDisabled} onClick={() => void workbench.redo()} /></PmToolbarButton>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
import { PmButton, PmField } from '../components.tsx'
|
|
3
|
-
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
3
|
+
import { useInheritedFrom, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
4
4
|
import { resolveDocumentStepVoice } from '../document-voices.ts'
|
|
5
5
|
import { PRODUCTION_MESSAGES } from '../production-messages.ts'
|
|
6
6
|
import { isAgentChanging } from '../workbench-state.ts'
|
|
@@ -14,6 +14,7 @@ export function DocumentVoiceField({ stepId, disabled = false, onGenerate }: { s
|
|
|
14
14
|
const locale = useWorkbenchState(state => state.locale)
|
|
15
15
|
const blocked = useWorkbenchState(state => Boolean(state.authoring?.loading || state.authoring?.composing) || isAgentChanging(state))
|
|
16
16
|
const [open, setOpen] = useState(false)
|
|
17
|
+
const inheritedFrom = useInheritedFrom()
|
|
17
18
|
useEffect(() => { setOpen(false) }, [source?.identity, stepId])
|
|
18
19
|
const document = source?.content, step = document?.steps[stepId], p = PRODUCTION_MESSAGES[locale]
|
|
19
20
|
if (!document || !step || !source?.identity) return null
|
|
@@ -23,7 +24,7 @@ export function DocumentVoiceField({ stepId, disabled = false, onGenerate }: { s
|
|
|
23
24
|
: voice.value?.type === 'none' ? p.none
|
|
24
25
|
: voice.value?.type === 'recording' ? recording?.title || p.recording : p.unset
|
|
25
26
|
return <>
|
|
26
|
-
<PmField group label={p.voice} hint={p.inherited[voice.inheritedFrom]}>
|
|
27
|
+
<PmField group label={p.voice} hint={voice.inheritedFrom === 'document' && !document.production.defaults.voiceSource && source.inherited?.production?.defaults?.voiceSource ? inheritedFrom : p.inherited[voice.inheritedFrom]}>
|
|
27
28
|
<span>{label}</span>
|
|
28
29
|
<div className="pmw-voice__actions">
|
|
29
30
|
<PmButton small icon="audio" disabled={disabled || blocked} onClick={() => { workbench.pauseDocumentStep(step.sectionId, stepId); workbench.stopAuditions(); setOpen(true) }}>{p.choose}</PmButton>
|
package/src/panels/HomePanel.tsx
CHANGED
|
@@ -3,7 +3,8 @@ import type { ReactNode } from 'react'
|
|
|
3
3
|
import { errorMessage } from '@lincyaw/kernel'
|
|
4
4
|
import type { DocumentSummary, ProjectPlan } from '@lincyaw/kernel'
|
|
5
5
|
import { PmButton, PmDialog, PmEmpty, PmInput, PmSelect, PmIcon, PmMenu, PmNotice } from '../components.tsx'
|
|
6
|
-
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
6
|
+
import { useMessages, useTreeMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
7
|
+
import { WorkspaceHome } from './WorkspaceHome.tsx'
|
|
7
8
|
import { contentText } from '../messages.ts'
|
|
8
9
|
import { IMPORT_MESSAGES } from '../import-messages.ts'
|
|
9
10
|
import { DocumentImportDialog } from './DocumentImportDialog.tsx'
|
|
@@ -14,7 +15,15 @@ type Editing =
|
|
|
14
15
|
|
|
15
16
|
/** The documents of the workspace: open one, make a new one, rename, copy or delete one. */
|
|
16
17
|
export function HomePanel({ actions }: { actions?: ReactNode } = {}) {
|
|
18
|
+
const workbench = useWorkbench()
|
|
19
|
+
const tree = useWorkbenchState(state => state.documentTree)
|
|
20
|
+
return workbench.tree.available && tree ? <WorkspaceHome actions={actions} /> : <DocumentListHome actions={actions} />
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A workspace without the tree routes (or before its tree is read): the flat list with its operations. */
|
|
24
|
+
function DocumentListHome({ actions }: { actions?: ReactNode }) {
|
|
17
25
|
const t = useMessages()
|
|
26
|
+
const tt = useTreeMessages()
|
|
18
27
|
const workbench = useWorkbench()
|
|
19
28
|
const answer = useWorkbenchState(state => state.documents)
|
|
20
29
|
const failure = useWorkbenchState(state => state.documentsFailure)
|
|
@@ -59,7 +68,7 @@ export function HomePanel({ actions }: { actions?: ReactNode } = {}) {
|
|
|
59
68
|
{done && <PmNotice tone="ok">{done}</PmNotice>}
|
|
60
69
|
{error && !editing && <PmNotice tone="danger">{error}</PmNotice>}
|
|
61
70
|
{answer && !answer.git && !answer.single && <PmNotice tone="warn">{t.notGit}</PmNotice>}
|
|
62
|
-
{answer?.migration && workbench.client.migrateWorkspace && <PmNotice tone="warn" action={<PmButton disabled={working} onClick={() => void run(async () => t.upgraded((await workbench.migrateWorkspace()).documents.length))}>{t.upgrade}</PmButton>}>{t.formatUpgrade}</PmNotice>}
|
|
71
|
+
{answer?.migration && workbench.client.migrateWorkspace && <PmNotice tone="warn" action={<PmButton disabled={working} onClick={() => void run(async () => t.upgraded((await workbench.migrateWorkspace()).documents.length))}>{t.upgrade}</PmButton>}>{answer.migration.documents.length ? tt.upgradePending(answer.migration.documents.length) : t.formatUpgrade}</PmNotice>}
|
|
63
72
|
<div className="pmw-home__heading-row">
|
|
64
73
|
<h2 className="pmw-home__heading">{t.allDocuments}</h2>
|
|
65
74
|
{documents.length > 6 && (
|
|
@@ -67,7 +76,7 @@ export function HomePanel({ actions }: { actions?: ReactNode } = {}) {
|
|
|
67
76
|
)}
|
|
68
77
|
</div>
|
|
69
78
|
{answer && documents.length === 0
|
|
70
|
-
? <PmEmpty icon="document" title={t.noDocuments} />
|
|
79
|
+
? !answer.migration?.documents.length && <PmEmpty icon="document" title={t.noDocuments} />
|
|
71
80
|
: shown.length === 0 && query
|
|
72
81
|
? <p className="pmw-muted">{t.noMatch}</p>
|
|
73
82
|
: (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useState } from 'react'
|
|
2
2
|
import { captionScale, CAPTION_SCALE_MAX, CAPTION_SCALE_MIN } from '@lincyaw/kernel'
|
|
3
3
|
import type { PresmiumDocument } from '@lincyaw/kernel'
|
|
4
|
-
import { PmField, PmRange } from '../components.tsx'
|
|
5
|
-
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
4
|
+
import { PmButton, PmField, PmRange } from '../components.tsx'
|
|
5
|
+
import { useInheritedFrom, useTreeMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
6
6
|
import { PRODUCTION_MESSAGES } from '../production-messages.ts'
|
|
7
7
|
|
|
8
8
|
/** The document's caption size in percent steps of ten; a released drag or a key records it once. */
|
|
@@ -10,11 +10,16 @@ export function ProductionCaptionSize({ identity, document, disabled, onChanged
|
|
|
10
10
|
const workbench = useWorkbench(), locale = useWorkbenchState(state => state.locale), p = PRODUCTION_MESSAGES[locale]
|
|
11
11
|
const [preview, setPreview] = useState<number>()
|
|
12
12
|
const percent = Math.round(captionScale(document.production) * 100)
|
|
13
|
-
|
|
13
|
+
// `document` has its inherited settings filled in; the source says whether the size is the document's own.
|
|
14
|
+
const own = useWorkbenchState(state => state.authoring?.identity === identity ? state.authoring.content?.production.captions?.scale !== undefined : true)
|
|
15
|
+
const inherits = useWorkbenchState(state => state.authoring?.identity === identity && state.authoring.inherited?.production?.captions?.scale !== undefined)
|
|
16
|
+
const inheritedFrom = useInheritedFrom(), tt = useTreeMessages()
|
|
17
|
+
return <PmField label={p.captionSize} group hint={own ? p.captionSizeHint : `${inheritedFrom} · ${p.captionSizeHint}`}>
|
|
14
18
|
<div className="pm-ui-range-row">
|
|
15
19
|
<PmRange label={p.captionSize} value={percent} min={Math.round(CAPTION_SCALE_MIN * 100)} max={Math.round(CAPTION_SCALE_MAX * 100)} step={10} disabled={disabled} valueText={value => `${Math.round(value)}%`}
|
|
16
20
|
onPreviewChange={setPreview} onValueCommit={value => { workbench.production.setCaptionScale(value / 100, identity); onChanged() }} />
|
|
17
21
|
<output>{Math.round(preview ?? percent)}%</output>
|
|
22
|
+
{own && inherits && <PmButton small variant="text" disabled={disabled} onClick={() => { workbench.production.inheritCaptionScale(identity); onChanged() }}>{tt.useInherited}</PmButton>}
|
|
18
23
|
</div>
|
|
19
24
|
</PmField>
|
|
20
25
|
}
|