@lincyaw/workbench 0.2.0-rc.121 → 0.2.0-rc.123
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/StepProductionEditor.tsx +13 -8
- package/src/components.tsx +24 -4
- package/src/context.tsx +30 -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/DocumentStepNarration.tsx +4 -2
- 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 +352 -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-session.ts +5 -3
- package/src/document-tree.ts +271 -0
- package/src/import-messages.ts +1 -1
- package/src/index.ts +6 -1
- package/src/knowledge-components.tsx +574 -0
- package/src/knowledge.css +354 -0
- package/src/messages.ts +12 -0
- package/src/panels/DocumentPeekPanel.tsx +190 -0
- package/src/panels/DocumentView.tsx +46 -23
- package/src/panels/DocumentVoiceField.tsx +3 -2
- package/src/panels/HomePanel.tsx +12 -3
- package/src/panels/MaterialsDialog.tsx +67 -0
- 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 +109 -0
- package/src/panels/WorkspaceSidebar.tsx +331 -0
- package/src/styles.css +20 -0
- package/src/tree-messages.ts +345 -0
- package/src/workbench-state.ts +21 -0
- package/src/workbench.ts +76 -3
- package/src/workspace-client.ts +35 -1
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/** The document tree, references, synced blocks and the trash (docs/glossary.md, docs/studio.md). */
|
|
2
|
+
export const DOCUMENT_TREE_MESSAGES = {
|
|
3
|
+
'zh-CN': {
|
|
4
|
+
sidebar: '工作区',
|
|
5
|
+
search: '搜索文稿与正文',
|
|
6
|
+
searchShortcut: 'Ctrl+K',
|
|
7
|
+
home: '主页',
|
|
8
|
+
recent: '最近打开',
|
|
9
|
+
documents: '文稿',
|
|
10
|
+
tree: '文稿树',
|
|
11
|
+
newDocument: '新建文稿',
|
|
12
|
+
newChild: '新建子文稿',
|
|
13
|
+
newChildIn: (title: string) => `在“${title}”下新建子文稿`,
|
|
14
|
+
more: (title: string) => `“${title}”的更多操作`,
|
|
15
|
+
expand: (title: string) => `展开“${title}”`,
|
|
16
|
+
collapse: (title: string) => `折叠“${title}”`,
|
|
17
|
+
untitled: '未命名文稿',
|
|
18
|
+
renameField: '文稿标题',
|
|
19
|
+
rename: '重命名…',
|
|
20
|
+
duplicate: '创建副本',
|
|
21
|
+
moveTo: '移动到…',
|
|
22
|
+
trash: '回收站',
|
|
23
|
+
moveToTrash: '移到回收站',
|
|
24
|
+
documentCount: (count: number) => `${count} 份文稿`,
|
|
25
|
+
treeLoading: '正在加载文稿…',
|
|
26
|
+
treeEmpty: '还没有文稿。',
|
|
27
|
+
treeFailed: '无法加载文稿树,请重试。',
|
|
28
|
+
retry: '重试',
|
|
29
|
+
treeIssue: '这份文稿的上级无效,暂时显示在顶层。',
|
|
30
|
+
upgradePending: (count: number) => `${count} 份文稿等待升级。升级后才能打开与编辑它们;每份文稿的升级都记入版本历史。`,
|
|
31
|
+
upgrade: '升级',
|
|
32
|
+
upgraded: (count: number) => `已升级 ${count} 份文稿。`,
|
|
33
|
+
openSidebar: '打开文稿树',
|
|
34
|
+
closeSidebar: '关闭文稿树',
|
|
35
|
+
location: '位置',
|
|
36
|
+
undo: '撤消',
|
|
37
|
+
close: '关闭',
|
|
38
|
+
movedUnder: (title: string, parent: string) => `“${title}”已移到“${parent}”下`,
|
|
39
|
+
movedToTop: (title: string) => `“${title}”已移到顶层`,
|
|
40
|
+
trashed: (title: string) => `“${title}”已移到回收站`,
|
|
41
|
+
duplicated: (title: string) => `已创建“${title}”`,
|
|
42
|
+
purgedConverted: (count: number) => `引用它的 ${count} 个同步块已转为副本。`,
|
|
43
|
+
openFailed: '无法打开文稿。它可能已被删除或移到回收站。',
|
|
44
|
+
operationFailed: (reason: string) => `无法完成操作。${reason}`,
|
|
45
|
+
failureGeneric: '请稍后重试。',
|
|
46
|
+
failures: {
|
|
47
|
+
'tree.not-found': '文稿已不存在,请刷新后重试。',
|
|
48
|
+
'tree.cycle': '不能把文稿移到它自己的子文稿下。',
|
|
49
|
+
'tree.trash-not-found': '回收站中已没有这份文稿。',
|
|
50
|
+
'tree.title-empty': '请输入标题。',
|
|
51
|
+
} as Record<string, string>,
|
|
52
|
+
searchTitle: '搜索',
|
|
53
|
+
searchField: '标题或正文',
|
|
54
|
+
searchPlaceholder: '输入标题或正文中的文字',
|
|
55
|
+
searching: '正在搜索…',
|
|
56
|
+
searchEmpty: '没有找到匹配的文稿。',
|
|
57
|
+
searchFailed: '无法搜索,请重试。',
|
|
58
|
+
searchResults: (count: number) => `${count} 个结果`,
|
|
59
|
+
contentMatch: (excerpt: string) => `正文:${excerpt}`,
|
|
60
|
+
recentEmpty: '还没有打开过文稿。',
|
|
61
|
+
trashTitle: '回收站',
|
|
62
|
+
trashEmpty: '回收站是空的。',
|
|
63
|
+
trashHint: '移到回收站的文稿连同其子文稿保存在这里,可以还原。',
|
|
64
|
+
restore: '还原',
|
|
65
|
+
restored: (title: string) => `已还原“${title}”`,
|
|
66
|
+
restoredToTop: (title: string, parent: 'trashed' | 'missing') => parent === 'trashed' ? `已还原“${title}”。它的上级文稿在回收站中,所以放在了顶层。` : `已还原“${title}”。它原来的上级文稿已不存在,所以放在了顶层。`,
|
|
67
|
+
parentTrashed: '上级文稿也在回收站中,单独还原时放在顶层',
|
|
68
|
+
deletePermanently: '永久删除…',
|
|
69
|
+
deletePermanentlyTitle: '永久删除',
|
|
70
|
+
deleteConfirm: (title: string) => `永久删除“${title}”及其子文稿?此操作无法撤消。`,
|
|
71
|
+
deleteSynced: '其他文稿中来自它的同步块会先转为副本,保留当前内容;指向它的引用将显示为已删除。',
|
|
72
|
+
deleteAction: '删除',
|
|
73
|
+
cancel: '取消',
|
|
74
|
+
deletedAt: (time: string) => `删除于 ${time}`,
|
|
75
|
+
childCount: (count: number) => `含 ${count} 份子文稿`,
|
|
76
|
+
moveTitle: (title: string) => `移动“${title}”`,
|
|
77
|
+
moveTarget: '移到',
|
|
78
|
+
topLevel: '顶层',
|
|
79
|
+
move: '移动',
|
|
80
|
+
outline: '目录',
|
|
81
|
+
references: '引用',
|
|
82
|
+
rail: '右栏',
|
|
83
|
+
citedBy: '引用了本文',
|
|
84
|
+
outgoing: '本文引用',
|
|
85
|
+
syncedBlocks: '同步块',
|
|
86
|
+
citedByCount: (count: number) => `被 ${count} 篇文稿引用`,
|
|
87
|
+
noCitations: '还没有文稿引用本文。',
|
|
88
|
+
noOutgoing: '本文还没有引用其他文稿。',
|
|
89
|
+
noSynced: '本文没有同步块。',
|
|
90
|
+
referencesLoading: '正在加载引用…',
|
|
91
|
+
referencesFailed: '无法加载引用,请重试。',
|
|
92
|
+
referencesUnavailable: '这个工作区不提供引用信息。',
|
|
93
|
+
referencesSummary: (incoming: number, outgoing: number) => `引用了本文 ${incoming} 篇 · 本文引用 ${outgoing} 篇`,
|
|
94
|
+
missingTarget: '已删除',
|
|
95
|
+
trashedTarget: '在回收站中',
|
|
96
|
+
syncedLabel: '同步块',
|
|
97
|
+
referenceLabel: '引用',
|
|
98
|
+
placeCount: (count: number) => `${count} 处`,
|
|
99
|
+
placeIndex: (index: number) => `第 ${index} 处`,
|
|
100
|
+
previewLabel: '文稿预览',
|
|
101
|
+
previewLoading: '正在加载预览…',
|
|
102
|
+
previewFailed: '无法加载预览。',
|
|
103
|
+
previewMeta: (pages: number, steps: number, citedBy: number) => `${pages} 页 · ${steps} 步 · 被 ${citedBy} 篇文稿引用`,
|
|
104
|
+
previewMissing: '这份文稿已删除。',
|
|
105
|
+
previewTrashed: '这份文稿在回收站中。',
|
|
106
|
+
open: '打开',
|
|
107
|
+
openOnSide: '在右侧打开',
|
|
108
|
+
peekLabel: '右侧的文稿',
|
|
109
|
+
peekLoading: '正在加载文稿…',
|
|
110
|
+
peekFailed: '无法加载这份文稿。',
|
|
111
|
+
peekEmpty: '这份文稿还没有内容。',
|
|
112
|
+
missingDocument: '文稿已删除',
|
|
113
|
+
linkHeading: (query: string) => query ? `链接到文稿 · 输入“${query}”` : '链接到文稿',
|
|
114
|
+
createChildAndLink: (query: string) => `新建子文稿“${query}”并链接`,
|
|
115
|
+
pickerHint: '↑↓ 选择 · Enter 插入 · Esc 关闭',
|
|
116
|
+
linkToDocument: '链接到文稿',
|
|
117
|
+
linkToDocumentHint: '插入指向另一份文稿、页面或内容块的引用',
|
|
118
|
+
linkAliases: '链接|引用|文稿',
|
|
119
|
+
syncedBlock: '同步块',
|
|
120
|
+
syncedBlockHint: '显示另一份文稿中的内容块,只在原处修改',
|
|
121
|
+
syncedAliases: '同步|嵌入',
|
|
122
|
+
childDocument: '子文稿',
|
|
123
|
+
childDocumentHint: '在本文稿下新建子文稿,并在这里链接它',
|
|
124
|
+
childAliases: '子文稿|新建',
|
|
125
|
+
syncedFrom: '同步自',
|
|
126
|
+
editOriginal: '编辑原文',
|
|
127
|
+
convertToCopy: '转为副本',
|
|
128
|
+
converted: '已转为副本。',
|
|
129
|
+
sourceTrashed: '原文稿在回收站中 · 显示的是它当前的内容',
|
|
130
|
+
sourceMissing: '原内容已不存在',
|
|
131
|
+
syncedLoading: '正在加载同步块…',
|
|
132
|
+
syncedFailed: '无法加载同步块的内容。',
|
|
133
|
+
syncedEmpty: '原内容块没有文字。',
|
|
134
|
+
syncedComponent: (title: string) => `组件:${title}`,
|
|
135
|
+
insertSynced: '插入同步块',
|
|
136
|
+
chooseDocument: '文稿',
|
|
137
|
+
chooseBlock: '内容块',
|
|
138
|
+
noBlocks: '这份文稿没有可同步的内容块。',
|
|
139
|
+
insert: '插入',
|
|
140
|
+
copySyncedLink: '复制同步块链接',
|
|
141
|
+
linkCopied: '已复制同步块链接。粘贴到另一份文稿即可插入同步块。',
|
|
142
|
+
copyFailed: '无法复制链接,请重试。',
|
|
143
|
+
blankDocument: '空白文稿',
|
|
144
|
+
blankDocumentHint: '从标题开始写,随时添加页面和动画',
|
|
145
|
+
importHint: '把已有的文件转成文稿',
|
|
146
|
+
fromMaterials: '从来源材料写作',
|
|
147
|
+
fromMaterialsHint: '选择 PDF、Word、PowerPoint、图片或文本文件,由 AI 写成一份新文稿',
|
|
148
|
+
fromMaterialsNeedsModel: 'AI 助手还没有模型。设置模型之后,AI 才能根据来源材料写文稿。',
|
|
149
|
+
materialsDescription: 'Presmium 新建一份文稿,把来源材料保存在它的文件夹中,再发送给 AI,由它根据材料写出标题、页面与正文。写好之前可以随时在对话中补充要求。',
|
|
150
|
+
materialsChoose: '选择文件',
|
|
151
|
+
materialsSelected: (count: number) => `已选择 ${count} 个文件`,
|
|
152
|
+
materialsLimits: (files: number, mebibytes: number) => `最多 ${files} 个文件,合计 ${mebibytes} MiB。`,
|
|
153
|
+
materialsNote: '想要怎样的文稿(可选)',
|
|
154
|
+
materialsNotePlaceholder: '例如:给研究生的 20 分钟报告,每页一个要点',
|
|
155
|
+
materialsSubmit: '新建并发送给 AI',
|
|
156
|
+
materialsSent: '已新建文稿,AI 正在根据来源材料写作。',
|
|
157
|
+
materialsNotSent: '已新建文稿并保存了来源材料,但请求没有发给 AI。',
|
|
158
|
+
materialsFailed: '无法保存来源材料。新建的文稿已移到回收站,请重试。',
|
|
159
|
+
materialsLimit: (files: number, mebibytes: number) => `来源材料超过 ${files} 个文件或合计 ${mebibytes} MiB 的限制,请减少文件后重试。`,
|
|
160
|
+
brokenReferences: (places: number, documents: number) => `${places} 处引用的目标已删除或在回收站中${documents > 1 ? `,分布在 ${documents} 份文稿中` : ''}。`,
|
|
161
|
+
brokenSynced: (places: number, documents: number) => `${places} 个同步块的原内容已删除或在回收站中${documents > 1 ? `,分布在 ${documents} 份文稿中` : ''}。`,
|
|
162
|
+
needsAttention: '需要处理',
|
|
163
|
+
treeIssues: (count: number) => `${count} 份文稿的上级无效,暂时显示在顶层。请把它们移到正确的位置。`,
|
|
164
|
+
show: '查看',
|
|
165
|
+
trashCount: (count: number) => `回收站中有 ${count} 份文稿`,
|
|
166
|
+
allDocuments: '全部文稿',
|
|
167
|
+
pages: (count: number) => `${count} 页`,
|
|
168
|
+
inheritedFrom: (name: string) => `继承自“${name}”`,
|
|
169
|
+
inheritedWorkspace: '继承自工作区默认设置',
|
|
170
|
+
override: '改写',
|
|
171
|
+
useInherited: '使用继承值',
|
|
172
|
+
},
|
|
173
|
+
en: {
|
|
174
|
+
sidebar: 'Workspace',
|
|
175
|
+
search: 'Search Documents',
|
|
176
|
+
searchShortcut: 'Ctrl+K',
|
|
177
|
+
home: 'Home',
|
|
178
|
+
recent: 'Recent',
|
|
179
|
+
documents: 'Documents',
|
|
180
|
+
tree: 'Document Tree',
|
|
181
|
+
newDocument: 'New Document',
|
|
182
|
+
newChild: 'New Child Document',
|
|
183
|
+
newChildIn: (title: string) => `New Child Document in “${title}”`,
|
|
184
|
+
more: (title: string) => `More Actions for “${title}”`,
|
|
185
|
+
expand: (title: string) => `Expand “${title}”`,
|
|
186
|
+
collapse: (title: string) => `Collapse “${title}”`,
|
|
187
|
+
untitled: 'Untitled document',
|
|
188
|
+
renameField: 'Document title',
|
|
189
|
+
rename: 'Rename…',
|
|
190
|
+
duplicate: 'Make a Copy',
|
|
191
|
+
moveTo: 'Move To…',
|
|
192
|
+
trash: 'Trash',
|
|
193
|
+
moveToTrash: 'Move to Trash',
|
|
194
|
+
documentCount: (count: number) => `${count} ${count === 1 ? 'document' : 'documents'}`,
|
|
195
|
+
treeLoading: 'Loading documents…',
|
|
196
|
+
treeEmpty: 'No documents yet.',
|
|
197
|
+
treeFailed: 'Couldn’t load the document tree. Try again.',
|
|
198
|
+
retry: 'Retry',
|
|
199
|
+
treeIssue: 'This document’s parent isn’t valid, so it’s shown at the top level for now.',
|
|
200
|
+
upgradePending: (count: number) => `${count} ${count === 1 ? 'document is' : 'documents are'} waiting for the upgrade. Upgrade to open and edit them; each document’s upgrade is recorded in its history.`,
|
|
201
|
+
upgrade: 'Upgrade',
|
|
202
|
+
upgraded: (count: number) => `Upgraded ${count} ${count === 1 ? 'document' : 'documents'}.`,
|
|
203
|
+
openSidebar: 'Open Document Tree',
|
|
204
|
+
closeSidebar: 'Close Document Tree',
|
|
205
|
+
location: 'Location',
|
|
206
|
+
undo: 'Undo',
|
|
207
|
+
close: 'Close',
|
|
208
|
+
movedUnder: (title: string, parent: string) => `Moved “${title}” under “${parent}”.`,
|
|
209
|
+
movedToTop: (title: string) => `Moved “${title}” to the top level.`,
|
|
210
|
+
trashed: (title: string) => `Moved “${title}” to the trash.`,
|
|
211
|
+
duplicated: (title: string) => `Created “${title}”.`,
|
|
212
|
+
purgedConverted: (count: number) => `Converted ${count} synced ${count === 1 ? 'block' : 'blocks'} from it to copies.`,
|
|
213
|
+
openFailed: 'Couldn’t open the document. It may have been deleted or moved to the trash.',
|
|
214
|
+
operationFailed: (reason: string) => `Couldn’t complete the operation. ${reason}`,
|
|
215
|
+
failureGeneric: 'Try again later.',
|
|
216
|
+
failures: {
|
|
217
|
+
'tree.not-found': 'The document no longer exists. Refresh and try again.',
|
|
218
|
+
'tree.cycle': 'A document can’t move under its own child document.',
|
|
219
|
+
'tree.trash-not-found': 'The document is no longer in the trash.',
|
|
220
|
+
'tree.title-empty': 'Enter a title.',
|
|
221
|
+
} as Record<string, string>,
|
|
222
|
+
searchTitle: 'Search',
|
|
223
|
+
searchField: 'Title or text',
|
|
224
|
+
searchPlaceholder: 'Type a title or text from a document',
|
|
225
|
+
searching: 'Searching…',
|
|
226
|
+
searchEmpty: 'No matching documents.',
|
|
227
|
+
searchFailed: 'Couldn’t search. Try again.',
|
|
228
|
+
searchResults: (count: number) => `${count} ${count === 1 ? 'result' : 'results'}`,
|
|
229
|
+
contentMatch: (excerpt: string) => `Text: ${excerpt}`,
|
|
230
|
+
recentEmpty: 'You haven’t opened any documents yet.',
|
|
231
|
+
trashTitle: 'Trash',
|
|
232
|
+
trashEmpty: 'The trash is empty.',
|
|
233
|
+
trashHint: 'Documents moved to the trash stay here with their child documents until you restore or delete them.',
|
|
234
|
+
restore: 'Restore',
|
|
235
|
+
restored: (title: string) => `Restored “${title}”.`,
|
|
236
|
+
restoredToTop: (title: string, parent: 'trashed' | 'missing') => parent === 'trashed' ? `Restored “${title}” to the top level because its parent document is in the trash.` : `Restored “${title}” to the top level because its parent document no longer exists.`,
|
|
237
|
+
parentTrashed: 'Its parent document is also in the trash; restored alone, it goes to the top level',
|
|
238
|
+
deletePermanently: 'Delete Permanently…',
|
|
239
|
+
deletePermanentlyTitle: 'Delete Permanently',
|
|
240
|
+
deleteConfirm: (title: string) => `Delete “${title}” and its child documents permanently? You can’t undo this.`,
|
|
241
|
+
deleteSynced: 'Synced blocks from it in other documents become copies first and keep their current content; references to it show as deleted.',
|
|
242
|
+
deleteAction: 'Delete',
|
|
243
|
+
cancel: 'Cancel',
|
|
244
|
+
deletedAt: (time: string) => `Deleted ${time}`,
|
|
245
|
+
childCount: (count: number) => `With ${count} child ${count === 1 ? 'document' : 'documents'}`,
|
|
246
|
+
moveTitle: (title: string) => `Move “${title}”`,
|
|
247
|
+
moveTarget: 'Move to',
|
|
248
|
+
topLevel: 'Top level',
|
|
249
|
+
move: 'Move',
|
|
250
|
+
outline: 'Outline',
|
|
251
|
+
references: 'References',
|
|
252
|
+
rail: 'Right Pane',
|
|
253
|
+
citedBy: 'Cited By',
|
|
254
|
+
outgoing: 'References',
|
|
255
|
+
syncedBlocks: 'Synced Blocks',
|
|
256
|
+
citedByCount: (count: number) => `Cited by ${count} ${count === 1 ? 'document' : 'documents'}`,
|
|
257
|
+
noCitations: 'No documents cite this one yet.',
|
|
258
|
+
noOutgoing: 'This document doesn’t reference other documents yet.',
|
|
259
|
+
noSynced: 'This document has no synced blocks.',
|
|
260
|
+
referencesLoading: 'Loading references…',
|
|
261
|
+
referencesFailed: 'Couldn’t load the references. Try again.',
|
|
262
|
+
referencesUnavailable: 'This workspace doesn’t provide references.',
|
|
263
|
+
referencesSummary: (incoming: number, outgoing: number) => `Cited by ${incoming} · References ${outgoing}`,
|
|
264
|
+
missingTarget: 'Deleted',
|
|
265
|
+
trashedTarget: 'In the trash',
|
|
266
|
+
syncedLabel: 'Synced block',
|
|
267
|
+
referenceLabel: 'Reference',
|
|
268
|
+
placeCount: (count: number) => `${count} places`,
|
|
269
|
+
placeIndex: (index: number) => `place ${index}`,
|
|
270
|
+
previewLabel: 'Document preview',
|
|
271
|
+
previewLoading: 'Loading preview…',
|
|
272
|
+
previewFailed: 'Couldn’t load the preview.',
|
|
273
|
+
previewMeta: (pages: number, steps: number, citedBy: number) => `${pages} ${pages === 1 ? 'page' : 'pages'} · ${steps} ${steps === 1 ? 'step' : 'steps'} · cited by ${citedBy} ${citedBy === 1 ? 'document' : 'documents'}`,
|
|
274
|
+
previewMissing: 'This document was deleted.',
|
|
275
|
+
previewTrashed: 'This document is in the trash.',
|
|
276
|
+
open: 'Open',
|
|
277
|
+
openOnSide: 'Open on the Side',
|
|
278
|
+
peekLabel: 'Document on the Side',
|
|
279
|
+
peekLoading: 'Loading the document…',
|
|
280
|
+
peekFailed: 'Couldn’t load this document.',
|
|
281
|
+
peekEmpty: 'This document has no content yet.',
|
|
282
|
+
missingDocument: 'Deleted document',
|
|
283
|
+
linkHeading: (query: string) => query ? `Link to Document · “${query}”` : 'Link to Document',
|
|
284
|
+
createChildAndLink: (query: string) => `New Child Document “${query}” and Link`,
|
|
285
|
+
pickerHint: '↑↓ to choose · Enter to insert · Esc to close',
|
|
286
|
+
linkToDocument: 'Link to Document',
|
|
287
|
+
linkToDocumentHint: 'A reference to another document, a page, or a content block',
|
|
288
|
+
linkAliases: 'link|reference|document',
|
|
289
|
+
syncedBlock: 'Synced Block',
|
|
290
|
+
syncedBlockHint: 'A content block from another document, edited only there',
|
|
291
|
+
syncedAliases: 'synced|embed|transclude',
|
|
292
|
+
childDocument: 'Child Document',
|
|
293
|
+
childDocumentHint: 'A new document under this one, linked here',
|
|
294
|
+
childAliases: 'child|new document',
|
|
295
|
+
syncedFrom: 'Synced from',
|
|
296
|
+
editOriginal: 'Edit Original',
|
|
297
|
+
convertToCopy: 'Convert to Copy',
|
|
298
|
+
converted: 'Converted to a copy.',
|
|
299
|
+
sourceTrashed: 'The original document is in the trash · showing its current content',
|
|
300
|
+
sourceMissing: 'The original no longer exists',
|
|
301
|
+
syncedLoading: 'Loading synced block…',
|
|
302
|
+
syncedFailed: 'Couldn’t load the synced block’s content.',
|
|
303
|
+
syncedEmpty: 'The original content block has no text.',
|
|
304
|
+
syncedComponent: (title: string) => `Component: ${title}`,
|
|
305
|
+
insertSynced: 'Insert Synced Block',
|
|
306
|
+
chooseDocument: 'Document',
|
|
307
|
+
chooseBlock: 'Content block',
|
|
308
|
+
noBlocks: 'This document has no content blocks to sync.',
|
|
309
|
+
insert: 'Insert',
|
|
310
|
+
copySyncedLink: 'Copy Synced Block Link',
|
|
311
|
+
linkCopied: 'Copied the synced block link. Paste it into another document to insert a synced block.',
|
|
312
|
+
copyFailed: 'Couldn’t copy the link. Try again.',
|
|
313
|
+
blankDocument: 'Blank Document',
|
|
314
|
+
blankDocumentHint: 'Start from a title and add pages and animations as you go',
|
|
315
|
+
importHint: 'Turn files you already have into documents',
|
|
316
|
+
fromMaterials: 'Write from Source Material',
|
|
317
|
+
fromMaterialsHint: 'Choose PDF, Word, PowerPoint, picture, or text files, and the AI writes a new document from them',
|
|
318
|
+
fromMaterialsNeedsModel: 'The AI Assistant has no model yet. Set one up, and the AI can write documents from source material.',
|
|
319
|
+
materialsDescription: 'Presmium creates a new document, keeps your source material in its folder, and has the AI write the title, pages, and text from it. You can add to the request in the chat at any time.',
|
|
320
|
+
materialsChoose: 'Choose Files',
|
|
321
|
+
materialsSelected: (count: number) => `${count} ${count === 1 ? 'file' : 'files'} selected`,
|
|
322
|
+
materialsLimits: (files: number, mebibytes: number) => `Up to ${files} files and ${mebibytes} MiB in total.`,
|
|
323
|
+
materialsNote: 'What you want (optional)',
|
|
324
|
+
materialsNotePlaceholder: 'For example: a 20-minute talk for graduate students, one point per page',
|
|
325
|
+
materialsSubmit: 'Create and Send to AI',
|
|
326
|
+
materialsSent: 'Created the document. The AI is writing it from your source material.',
|
|
327
|
+
materialsNotSent: 'Created the document and kept the source material, but the request didn’t reach the AI.',
|
|
328
|
+
materialsFailed: 'Couldn’t save the source material. The new document was moved to the trash. Try again.',
|
|
329
|
+
materialsLimit: (files: number, mebibytes: number) => `The source material is over the limit of ${files} files or ${mebibytes} MiB in total. Choose fewer files and try again.`,
|
|
330
|
+
brokenReferences: (places: number, documents: number) => `${places} ${places === 1 ? 'reference points' : 'references point'} to content that was deleted or is in the trash${documents > 1 ? `, in ${documents} documents` : ''}.`,
|
|
331
|
+
brokenSynced: (places: number, documents: number) => `${places} ${places === 1 ? 'synced block shows' : 'synced blocks show'} content that was deleted or is in the trash${documents > 1 ? `, in ${documents} documents` : ''}.`,
|
|
332
|
+
needsAttention: 'Needs Attention',
|
|
333
|
+
treeIssues: (count: number) => `${count} ${count === 1 ? 'document has an invalid parent and is' : 'documents have an invalid parent and are'} shown at the top level for now. Move them where they belong.`,
|
|
334
|
+
show: 'Show',
|
|
335
|
+
trashCount: (count: number) => `${count} ${count === 1 ? 'document' : 'documents'} in the trash`,
|
|
336
|
+
allDocuments: 'All Documents',
|
|
337
|
+
pages: (count: number) => `${count} ${count === 1 ? 'page' : 'pages'}`,
|
|
338
|
+
inheritedFrom: (name: string) => `Inherited from “${name}”`,
|
|
339
|
+
inheritedWorkspace: 'Inherited from the workspace defaults',
|
|
340
|
+
override: 'Override',
|
|
341
|
+
useInherited: 'Use Inherited Value',
|
|
342
|
+
},
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export type DocumentTreeMessages = typeof DOCUMENT_TREE_MESSAGES['en']
|
package/src/workbench-state.ts
CHANGED
|
@@ -66,6 +66,23 @@ export interface WorkbenchState {
|
|
|
66
66
|
isDark: boolean
|
|
67
67
|
documents?: DocumentsAnswer
|
|
68
68
|
documentsFailure?: string
|
|
69
|
+
/** The workspace's document tree and trash; `documentTreeFailure` is `tree-unavailable` when the host has none. */
|
|
70
|
+
documentTree?: import('@lincyaw/kernel/contracts').DocumentTree
|
|
71
|
+
documentTreeFailure?: string
|
|
72
|
+
isDocumentTreeLoading?: boolean
|
|
73
|
+
isDocumentTreeBusy?: boolean
|
|
74
|
+
/** The document whose title is being edited in the tree (a new one starts so). */
|
|
75
|
+
renamingDocument?: string
|
|
76
|
+
/** Documents opened recently in this browser, the latest first. */
|
|
77
|
+
recentDocuments?: import('./document-tree.ts').RecentDocument[]
|
|
78
|
+
/** What needs attention across the workspace: references and synced blocks whose target is gone or in the trash. */
|
|
79
|
+
workspaceAttention?: import('@lincyaw/kernel/contracts').WorkspaceAttention
|
|
80
|
+
/** Changes when cached reference previews and synced block sources are forgotten. */
|
|
81
|
+
documentLinksGeneration?: number
|
|
82
|
+
/** The document (and its page or block) shown read-only in the right pane beside the open one. */
|
|
83
|
+
documentPeek?: import('./document-tree.ts').DocumentPlace
|
|
84
|
+
/** The one message at the bottom that says what an operation did. */
|
|
85
|
+
toast?: import('./knowledge-components.tsx').ToastMessage
|
|
69
86
|
/** The workspace's routes answer 404: `@lincyaw/dsh` is turned off on the plugins page. */
|
|
70
87
|
isBundleDisabled?: boolean
|
|
71
88
|
document?: string
|
|
@@ -125,6 +142,10 @@ export interface WorkbenchState {
|
|
|
125
142
|
isHistoryBusy: boolean
|
|
126
143
|
isAsking: boolean
|
|
127
144
|
askFailure?: string
|
|
145
|
+
/** A conversation's agent takes requests (`onAgentRequest`). */
|
|
146
|
+
canAskAgent?: boolean
|
|
147
|
+
/** Whether the agent has a model to run with, as the host says (`setAgentReadiness`); unknown until it does. */
|
|
148
|
+
agentReadiness?: 'ready' | 'missing' | 'unknown'
|
|
128
149
|
/** What the document can be made into, and its builds and exports (the author's and the AI's). */
|
|
129
150
|
jobs?: JobsAnswer
|
|
130
151
|
jobsFailure?: string
|
package/src/workbench.ts
CHANGED
|
@@ -43,6 +43,8 @@ import { ProductionPlayback } from './production-playback.ts'
|
|
|
43
43
|
import type { ProductionBinding, ProductionPlan, ProductionPlaybackCommand, ProductionPlaybackState } from '@lincyaw/kernel'
|
|
44
44
|
import { workspaceClient, WorkspaceServerError } from './workspace-client.ts'
|
|
45
45
|
import type { WorkspaceClient } from './workspace-client.ts'
|
|
46
|
+
import { DocumentTreeActions } from './document-tree.ts'
|
|
47
|
+
import { DOCUMENT_TREE_MESSAGES } from './tree-messages.ts'
|
|
46
48
|
import type { AuthoringClientAction, AuthoringClientActionType, AuthoringClientActionResult, AuthoringClientSnapshot } from '@lincyaw/kernel'
|
|
47
49
|
import { PRODUCTION_PLAYBACK_RATES } from '@lincyaw/kernel'
|
|
48
50
|
|
|
@@ -88,6 +90,7 @@ const DOCUMENT_RESET = {
|
|
|
88
90
|
review: undefined, history: undefined, outside: undefined, historyFailure: undefined, isHistoryBusy: false, askFailure: undefined,
|
|
89
91
|
jobs: undefined, jobsFailure: undefined, jobPreparing: undefined,
|
|
90
92
|
voiceoverJobs: undefined, voiceoverJobsFailure: undefined, voiceoverCacheRefresh: undefined,
|
|
93
|
+
documentPeek: undefined,
|
|
91
94
|
} satisfies Partial<WorkbenchState>
|
|
92
95
|
|
|
93
96
|
/** A free directory for a new document called `title`, beside most of the existing ones. */
|
|
@@ -116,6 +119,8 @@ export class Workbench {
|
|
|
116
119
|
readonly production: DocumentProduction
|
|
117
120
|
#removedDocumentPosition?: { identity: string, documentId: string, sectionId: string, stepId?: string, version: string, fingerprint: string, scope: number, generation: number, token: string }
|
|
118
121
|
readonly editing: DocumentEditing
|
|
122
|
+
readonly tree: DocumentTreeActions
|
|
123
|
+
#pendingPlace?: { document: string | undefined, section: string, block?: string }
|
|
119
124
|
#state: WorkbenchState
|
|
120
125
|
readonly #listeners = new Set<Listener>()
|
|
121
126
|
readonly #clientControls = new Set<AuthoringClientControls>()
|
|
@@ -134,6 +139,7 @@ export class Workbench {
|
|
|
134
139
|
readonly #voiceover: VoiceoverJobs
|
|
135
140
|
readonly #askers = new Set<(request: AgentRequest) => Promise<AgentAnswer | void>>()
|
|
136
141
|
readonly #drafters = new Set<(draft: AgentDraft) => void | Promise<void>>()
|
|
142
|
+
#openAgentSetup?: () => void
|
|
137
143
|
readonly #previewSinks = new Set<PreviewSink>()
|
|
138
144
|
readonly #playbackKeys = new Set<(command: PlaybackKey) => void>()
|
|
139
145
|
#unsubscribeIr?: () => void
|
|
@@ -226,6 +232,7 @@ export class Workbench {
|
|
|
226
232
|
...selected ? { stepId: selected } : {}, version: previous.version, fingerprint: previous.fingerprint, scope, generation, token: this.#state.documentPositionToken }
|
|
227
233
|
}
|
|
228
234
|
this.editing.finishOpening()
|
|
235
|
+
this.#applyPendingPlace()
|
|
229
236
|
// Native insertion can select a page before the source actor receives that new entity.
|
|
230
237
|
if (position && previous && previous.identity === authoring.identity && !previous.content?.sections[position.section]
|
|
231
238
|
&& authoring.content?.sections[position.section]) this.editing.saveReturnPoint()
|
|
@@ -243,6 +250,7 @@ export class Workbench {
|
|
|
243
250
|
flush: signal => this.flushPendingEdits(signal), goToSection: section => this.goToSection(section),
|
|
244
251
|
rememberStep: (directory, section, step) => { this.#selectedSteps.set(`${directory}\0${section}`, step) },
|
|
245
252
|
canAskAnimation: () => this.#drafters.size > 0, askAnimation: place => this.draftAnimation(place) })
|
|
253
|
+
this.tree = new DocumentTreeActions({ client: this.client, store, open: (dir, focus) => this.openDocument(dir, focus ? { focus } : {}), reveal: (section, block) => this.#revealInDocument(section, block) })
|
|
246
254
|
this.#diagnostics = new DocumentDiagnostics(this.client, store)
|
|
247
255
|
this.#jobs = new DocumentJobs(this.client, store)
|
|
248
256
|
this.#voiceover = new VoiceoverJobs(this.client, store, (job, signal) => this.#refreshVoiceover(job, signal))
|
|
@@ -348,7 +356,24 @@ export class Workbench {
|
|
|
348
356
|
/** The host's way to hand a request to the conversation's agent. */
|
|
349
357
|
onAgentRequest = (asker: (request: AgentRequest) => Promise<AgentAnswer | void>): (() => void) => {
|
|
350
358
|
this.#askers.add(asker)
|
|
351
|
-
|
|
359
|
+
this.#set({ canAskAgent: true })
|
|
360
|
+
return () => {
|
|
361
|
+
this.#askers.delete(asker)
|
|
362
|
+
this.#set({ canAskAgent: this.#askers.size > 0 })
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** The host's word on whether the agent has a model to run with, and its way to open the model setup. */
|
|
367
|
+
setAgentReadiness(readiness: 'ready' | 'missing' | 'unknown', openSetup?: () => void): void {
|
|
368
|
+
this.#openAgentSetup = openSetup
|
|
369
|
+
if (this.#state.agentReadiness !== readiness) this.#set({ agentReadiness: readiness })
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** Opens the host's model setup; false when the host offers none. */
|
|
373
|
+
openAgentSetup(): boolean {
|
|
374
|
+
if (!this.#openAgentSetup) return false
|
|
375
|
+
this.#openAgentSetup()
|
|
376
|
+
return true
|
|
352
377
|
}
|
|
353
378
|
|
|
354
379
|
/** The host's way to put a request in the conversation's composer for the author to finish; nothing is sent. */
|
|
@@ -436,6 +461,8 @@ export class Workbench {
|
|
|
436
461
|
}
|
|
437
462
|
|
|
438
463
|
async loadDocuments(): Promise<void> {
|
|
464
|
+
// With tree events the tree is read once and then on each change; without them, with the document list.
|
|
465
|
+
if (!this.client.subscribeTree || !this.#state.documentTree) void this.tree.load()
|
|
439
466
|
try {
|
|
440
467
|
this.#set({ documents: await this.client.readDocuments(), documentsFailure: undefined, isBundleDisabled: false })
|
|
441
468
|
} catch (error) {
|
|
@@ -467,6 +494,33 @@ export class Workbench {
|
|
|
467
494
|
return answer
|
|
468
495
|
}
|
|
469
496
|
|
|
497
|
+
/**
|
|
498
|
+
* A new document written by the AI from the author's source material: creates it at the end of the top level, keeps
|
|
499
|
+
* the files in its folder, opens it and hands the conversation's agent the request. A document whose files could not
|
|
500
|
+
* be added goes to the trash again. Answers the new document's ID and whether the request was sent.
|
|
501
|
+
*/
|
|
502
|
+
async writeFromMaterials(files: readonly File[], note: string, signal?: AbortSignal): Promise<{ document: string, asked: boolean }> {
|
|
503
|
+
if (!this.client.addDocumentMaterials || !this.tree.available) throw new Error('document-materials-unavailable')
|
|
504
|
+
const roots = this.#state.documentTree?.roots
|
|
505
|
+
const created = await this.client.operateTree!({ type: 'create', title: DOCUMENT_TREE_MESSAGES[this.#state.locale].untitled, parent: null, after: roots?.at(-1) ?? null }, signal)
|
|
506
|
+
const id = created.created
|
|
507
|
+
if (!id) throw new Error('document-materials-unavailable')
|
|
508
|
+
await Promise.all([this.tree.load(), this.loadDocuments()])
|
|
509
|
+
const dir = this.tree.dirOf(id)
|
|
510
|
+
let added: string[]
|
|
511
|
+
try {
|
|
512
|
+
if (dir === undefined) throw new Error('document-materials-document')
|
|
513
|
+
added = (await this.client.addDocumentMaterials(dir, files, signal)).files
|
|
514
|
+
} catch (error) {
|
|
515
|
+
await this.tree.operate({ type: 'trash', id }).catch(() => undefined)
|
|
516
|
+
throw error
|
|
517
|
+
}
|
|
518
|
+
this.#record('document.materials', { 'presmium.document': id, 'presmium.files': added.join('\n') })
|
|
519
|
+
await this.tree.openPlace({ document: id })
|
|
520
|
+
const asked = await this.askAgent(this.#messages.materialsRequest(added, note), [])
|
|
521
|
+
return { document: id, asked }
|
|
522
|
+
}
|
|
523
|
+
|
|
470
524
|
/** Upgrades the workspace's documents to the current format, then refreshes the document list. */
|
|
471
525
|
async migrateWorkspace(): Promise<import('@lincyaw/kernel').WorkspaceMigrationAnswer> {
|
|
472
526
|
if (!this.client.migrateWorkspace) throw new Error('workspace-migrate-unavailable')
|
|
@@ -509,6 +563,7 @@ export class Workbench {
|
|
|
509
563
|
this.#set({ ...DOCUMENT_RESET, document: dir, previewRenderer: 'web', webView: 'document' })
|
|
510
564
|
this.editing.beginOpening(dir, options.focus, options.fallbackReturnPoint)
|
|
511
565
|
this.#record('document.open')
|
|
566
|
+
this.tree.visited(this.tree.idOf(dir))
|
|
512
567
|
this.#diagnostics.subscribe(dir)
|
|
513
568
|
// Authoring is ready from source JSON; compilation and preview are independent.
|
|
514
569
|
const [opened] = await Promise.all([this.#documentSession.open(dir, options.expectedIdentity, options.signal), this.#readFocus(dir, options.signal), this.#history.read(dir, options.signal)])
|
|
@@ -1380,6 +1435,21 @@ export class Workbench {
|
|
|
1380
1435
|
documentNavigation: { section: sectionId, block: blockId, request: randomUUID() } })
|
|
1381
1436
|
}
|
|
1382
1437
|
|
|
1438
|
+
/** Shows a page, or a block on it, of the open document once its content is there (a reference followed from elsewhere). */
|
|
1439
|
+
#revealInDocument(section: string, block?: string): void {
|
|
1440
|
+
this.#pendingPlace = { document: this.#state.document, section, ...block ? { block } : {} }
|
|
1441
|
+
this.#applyPendingPlace()
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
#applyPendingPlace(): void {
|
|
1445
|
+
const place = this.#pendingPlace, content = this.#state.authoring?.content
|
|
1446
|
+
if (!place || place.document !== this.#state.document || !content) return
|
|
1447
|
+
this.#pendingPlace = undefined
|
|
1448
|
+
if (!content.sections[place.section]) return
|
|
1449
|
+
this.#set({ position: { section: place.section, step: 0, trail: [], view: 'document' }, documentPositionFailure: undefined,
|
|
1450
|
+
documentNavigation: { section: place.section, ...place.block && content.blocks[place.block] ? { block: place.block } : {}, request: randomUUID() } })
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1383
1453
|
observeDocumentSection(section: string): void {
|
|
1384
1454
|
if (this.#state.webView !== 'document' || !this.#state.authoring?.content?.sections[section]) return
|
|
1385
1455
|
if (this.#state.documentPositionFailure) this.#set({ documentPositionFailure: undefined })
|
|
@@ -1641,8 +1711,10 @@ export class Workbench {
|
|
|
1641
1711
|
this.#record('shortcut', { 'presmium.command': report.command })
|
|
1642
1712
|
if (report.command === 'dismiss') {
|
|
1643
1713
|
if (this.#state.pointer) this.point(undefined)
|
|
1644
|
-
|
|
1645
|
-
|
|
1714
|
+
// A preview's keys come from inside the page (a block preview in the editor): they reach the editor's history only,
|
|
1715
|
+
// never a saved version, which the toolbar's Undo and Redo take back.
|
|
1716
|
+
} else if (report.command === 'undo') this.editing.nativeHistory('undo')
|
|
1717
|
+
else if (report.command === 'redo') this.editing.nativeHistory('redo')
|
|
1646
1718
|
else if (report.command === 'save') void this.flushPendingEdits().catch(() => {})
|
|
1647
1719
|
else for (const listener of this.#playbackKeys) listener(report.command)
|
|
1648
1720
|
break
|
|
@@ -1685,6 +1757,7 @@ export class Workbench {
|
|
|
1685
1757
|
this.#stopSubscriptions()
|
|
1686
1758
|
this.#diagnostics.dispose()
|
|
1687
1759
|
this.#documentSession.dispose()
|
|
1760
|
+
this.tree.dispose()
|
|
1688
1761
|
this.#commentDrafts.close()
|
|
1689
1762
|
this.#componentPropertyDrafts.close()
|
|
1690
1763
|
this.production.dispose()
|
package/src/workspace-client.ts
CHANGED
|
@@ -15,6 +15,9 @@ import type { DocumentImageImport, DocumentImageImportAnswer } from '@lincyaw/ke
|
|
|
15
15
|
import type { ProductionAssetAnswer, ProductionAssetQuery, ProductionMediaQuery, ProductionPlan, ProductionPlanQuery } from '@lincyaw/kernel'
|
|
16
16
|
import type { DocumentTranscriptionRequest, TranscriptionCapabilities, TranscriptionTask, TranscriptionListAnswer, TranscriptionRevision, TranscriptionCancellation, TranscriptionAdoptionDraft, TranscriptionAdoptionPlan, TranscriptionAdoptionApply, TranscriptionAdoptionAnswer } from '@lincyaw/kernel'
|
|
17
17
|
import { randomUUID } from '@lincyaw/kernel'
|
|
18
|
+
import type { ReferenceTarget } from '@lincyaw/kernel'
|
|
19
|
+
// The contract's DocumentTree is the workspace's answer; the kernel's root also names its own tree builder DocumentTree.
|
|
20
|
+
import type { DocumentLinks, DocumentPreview, DocumentSearchHit, DocumentTree, EmbedSource, TreeOperation, TreeOperationResult, WorkspaceAttention } from '@lincyaw/kernel/contracts'
|
|
18
21
|
|
|
19
22
|
/** A change of the host's pending approvals that this author may answer. */
|
|
20
23
|
export type ApprovalEvent =
|
|
@@ -80,8 +83,21 @@ export interface WorkspaceClient {
|
|
|
80
83
|
subscribeRequests?(listener: (event: WorkspaceRequestEvent) => void): () => void
|
|
81
84
|
readDocuments(document?: string): Promise<DocumentsAnswer>
|
|
82
85
|
importDocuments?(files: readonly File[], signal?: AbortSignal): Promise<import('@lincyaw/kernel').DocumentImportAnswer>
|
|
86
|
+
/** Keeps the files as the document's source material, in its folder, recorded as one revision. */
|
|
87
|
+
addDocumentMaterials?(document: string, files: readonly File[], signal?: AbortSignal): Promise<import('@lincyaw/kernel').DocumentMaterialsAnswer>
|
|
83
88
|
/** Converts the workspace's documents to the current format, one revision per document. */
|
|
84
89
|
migrateWorkspace?(): Promise<import('@lincyaw/kernel').WorkspaceMigrationAnswer>
|
|
90
|
+
/** The workspace's document tree and trash (absent for a host without one). */
|
|
91
|
+
readTree?(signal?: AbortSignal): Promise<DocumentTree>
|
|
92
|
+
operateTree?(operation: TreeOperation, signal?: AbortSignal): Promise<TreeOperationResult>
|
|
93
|
+
readDocumentLinks?(id: string, signal?: AbortSignal): Promise<DocumentLinks>
|
|
94
|
+
searchDocuments?(query: string, limit?: number, signal?: AbortSignal): Promise<DocumentSearchHit[]>
|
|
95
|
+
readDocumentPreview?(target: ReferenceTarget, signal?: AbortSignal): Promise<DocumentPreview>
|
|
96
|
+
readEmbedSource?(source: { document: string, block: string }, signal?: AbortSignal): Promise<EmbedSource>
|
|
97
|
+
/** References and synced blocks across the workspace whose target is gone or in the trash. */
|
|
98
|
+
readAttention?(signal?: AbortSignal): Promise<WorkspaceAttention>
|
|
99
|
+
/** Each change of the workspace's document tree (created, moved, renamed, trashed, restored), and of what `readAttention` answers. */
|
|
100
|
+
subscribeTree?(changed: (kind: 'tree' | 'attention') => void, failed?: () => void): () => void
|
|
85
101
|
planProjectChange(request: ProjectPlanRequest): Promise<ProjectPlan>
|
|
86
102
|
operateDocument(operation: ProjectOperation, planned?: ProjectPlan): Promise<OperationAnswer>
|
|
87
103
|
readSource(document: string, path: string): Promise<SourceAnswer>
|
|
@@ -205,7 +221,7 @@ export function workspaceClient(base = 'api/presmium/', subscription?: Workspace
|
|
|
205
221
|
const path = target.pathname.slice(prefix.length)
|
|
206
222
|
const method = (init?.method ?? 'GET').toUpperCase()
|
|
207
223
|
if (client.capabilities?.readOnly && !['GET', 'HEAD', 'OPTIONS'].includes(method)
|
|
208
|
-
&& /^(?:documents?(?:\/|$)|source(?:\/|$)|project\/|pages\/|history\/|revisions\/|review(?:\/|$))/.test(path)) throw new WorkspaceServerError(403, { error: 'permission-denied' })
|
|
224
|
+
&& /^(?:documents?(?:\/|$)|tree\/|source(?:\/|$)|project\/|pages\/|history\/|revisions\/|review(?:\/|$))/.test(path)) throw new WorkspaceServerError(403, { error: 'permission-denied' })
|
|
209
225
|
if (path === 'telemetry' || (path === 'diagnostics' || path === 'diagnostics/authoring') && method === 'POST') return fetch(address, { credentials: 'same-origin', ...init })
|
|
210
226
|
const document = target.searchParams.get('document') ?? undefined
|
|
211
227
|
const requestId = ++requestSequence
|
|
@@ -379,7 +395,25 @@ export function workspaceClient(base = 'api/presmium/', subscription?: Workspace
|
|
|
379
395
|
for (const file of files) body.append('files', file, file.name)
|
|
380
396
|
return call(url('documents/import'), { method: 'POST', body, signal })
|
|
381
397
|
},
|
|
398
|
+
addDocumentMaterials: (document, files, signal) => {
|
|
399
|
+
const body = new FormData()
|
|
400
|
+
for (const file of files) body.append('files', file, file.name)
|
|
401
|
+
return call(url('document/materials', document), { method: 'POST', body, signal })
|
|
402
|
+
},
|
|
382
403
|
migrateWorkspace: () => call(url('workspace/migrate'), { method: 'POST' }),
|
|
404
|
+
readTree: signal => call(url('tree'), { signal }),
|
|
405
|
+
operateTree: (operation, signal) => post(url('tree/operation'), operation, signal),
|
|
406
|
+
readDocumentLinks: (id, signal) => call(url('document/links', undefined, { id }), { signal }),
|
|
407
|
+
searchDocuments: (q, limit = 20, signal) => call(url('documents/search', undefined, { q, limit: String(limit) }), { signal }),
|
|
408
|
+
readDocumentPreview: (target, signal) => call(url('document/preview', undefined, { id: target.document, ...target.section ? { section: target.section } : {}, ...target.block ? { block: target.block } : {} }), { signal }),
|
|
409
|
+
readEmbedSource: async (source, signal) => {
|
|
410
|
+
const answer = await call<EmbedSource>(url('embed/source', undefined, { document: source.document, block: source.block }), { signal })
|
|
411
|
+
// Asset URLs are relative to the workspace routes; the editor loads them from any page.
|
|
412
|
+
const routes = new URL(base, globalThis.document.baseURI)
|
|
413
|
+
return answer.assets ? { ...answer, assets: Object.fromEntries(Object.entries(answer.assets).map(([id, address]) => [id, new URL(address, routes).href])) } : answer
|
|
414
|
+
},
|
|
415
|
+
readAttention: signal => call(url('tree/attention'), { signal }),
|
|
416
|
+
subscribeTree: (changed, failed) => subscribe<{ type?: string }>(url('tree/events', ''), 'tree', data => changed(data?.type === 'attention' ? 'attention' : 'tree'), failed),
|
|
383
417
|
readSource: (document, path) => call(url('source', document, { path })),
|
|
384
418
|
saveSource: (document, path, content, base, message) => post(url('source', document), { path, content, base, ...message ? { message } : {} }),
|
|
385
419
|
saveSourceTransaction: (document, changes, message) => post(url('source/transaction', document), { changes, ...message ? { message } : {} }),
|