@tano.page/workbench 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +35 -14
- package/src/App.vue +68 -797
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantPanel.vue +1 -1
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -585
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/language.ts +10 -37
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -65
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/store.ts +87 -554
- package/src/assistant/structures.ts +1 -157
- package/src/assistant/tasks.ts +8 -94
- package/src/assistant/tool-rules.ts +1 -7
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +37 -1022
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +23 -1
- package/src/i18n/locales/en-US.json +23 -1
- package/src/i18n/locales/es-ES.json +23 -1
- package/src/i18n/locales/ja-JP.json +23 -1
- package/src/i18n/locales/zh-TW.json +23 -1
- package/src/mail/components/MailAccountDialog.vue +1 -0
- package/src/mail/components/MailComposerDialog.vue +1 -0
- package/src/mail/components/MailWorkspaceView.vue +1 -0
- package/src/mail/components/SidebarMail.vue +1 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +2 -3
- package/src/plans/calendar.ts +2 -2
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +162 -2106
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plugins/components/PluginDetailPage.vue +10 -6
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginExplorer.vue +6 -4
- package/src/plugins/components/PluginImportDialog.vue +1 -1
- package/src/plugins/components/PluginInstaller.vue +269 -178
- package/src/plugins/components/PluginMaintenance.vue +37 -49
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginSettingsForm.vue +2 -1
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -260
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/queries.ts +1 -75
- package/src/plugins/view-header.ts +2 -7
- package/src/runtime.ts +3 -2
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/WorkbenchContextMenus.vue +37 -26
- package/src/shell/components/WorkbenchModals.vue +22 -18
- package/src/shell/components/WorkbenchPanes.vue +358 -1512
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +488 -1081
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +1 -1
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +71 -599
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +1 -1
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +163 -1345
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -11
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/assistant/locales/de-DE.json +0 -129
- package/src/assistant/locales/en-US.json +0 -129
- package/src/assistant/locales/es-ES.json +0 -129
- package/src/assistant/locales/ja-JP.json +0 -129
- package/src/assistant/locales/zh-CN.json +0 -129
- package/src/assistant/locales/zh-TW.json +0 -129
- package/src/assistant/task-prompts.json +0 -39
|
@@ -1,33 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { isElement } from '@tano/editor/dom-realm';
|
|
4
|
-
import { installInteractionMotion } from '@tano/editor/motion';
|
|
5
|
-
import { defaultSelectionContext, type EditorSelectionContext } from '@tano/editor/selection-context';
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
import type { EditorSelectionContext } from '@tano/editor/selection-context';
|
|
6
3
|
import type { FileEntry } from '@tano/protocol';
|
|
7
|
-
import { native } from '../workspace/adapter';
|
|
8
4
|
import type { useAssistantStore } from '../assistant/store';
|
|
9
|
-
import { editorPaletteCommands, type WorkbenchCommand } from '../shell/command-palette';
|
|
10
|
-
import type FileTree from '../files/components/FileTree.vue';
|
|
11
|
-
import type PageSearch from '../shell/components/PageSearch.vue';
|
|
12
|
-
import { configuredEditorShortcuts } from '../shell/configured-editor-shortcuts';
|
|
13
5
|
import type { DocumentExportFormat } from '../documents/document-export';
|
|
14
|
-
import
|
|
15
|
-
import { handleMobileVisibility } from '../shell/mobile-lifecycle';
|
|
16
|
-
import { mobile } from '../platform/platform';
|
|
17
|
-
import { pluginShortcutCommand } from '../plugins/workbench';
|
|
18
|
-
import type { WorkbenchExtensions } from '../runtime';
|
|
6
|
+
import type FileTree from '../files/components/FileTree.vue';
|
|
19
7
|
import type { SelectionTodoSession } from '../plans/selection-todo';
|
|
8
|
+
import type { WorkbenchExtensions } from '../runtime';
|
|
20
9
|
import type { SettingsPageId } from '../settings/settings-window';
|
|
21
|
-
import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} from '../shell/
|
|
10
|
+
import type PageSearch from '../shell/components/PageSearch.vue';
|
|
11
|
+
import type { ShortcutBindings } from '../shell/shortcuts';
|
|
12
|
+
import { useSurfaceDismissal } from '../shell/use-surface-dismissal';
|
|
13
|
+
import { useWorkbenchCommands } from '../shell/use-workbench-commands';
|
|
14
|
+
import { useWorkbenchKeybindings } from '../shell/use-workbench-keybindings';
|
|
15
|
+
import type { MarkdownEditor } from '../shell/workbench-async-components';
|
|
26
16
|
import type { useUpdatesStore } from '../stores/updates';
|
|
27
17
|
import type { useWorkspaceStore } from '../stores/workspace';
|
|
28
18
|
import type { WindowContext } from '../windows/context';
|
|
29
19
|
import type { useAuxiliaryWindows } from '../windows/manager';
|
|
30
|
-
import
|
|
20
|
+
import { useWindowEventBridge } from '../windows/use-window-event-bridge';
|
|
21
|
+
|
|
22
|
+
export { runWorkbenchCommandOrPlugin } from '../shell/use-workbench-commands';
|
|
31
23
|
|
|
32
24
|
export interface WorkbenchShortcutsDeps {
|
|
33
25
|
store: ReturnType<typeof useWorkspaceStore>;
|
|
@@ -128,1007 +120,30 @@ export interface WorkbenchShortcutsDeps {
|
|
|
128
120
|
}
|
|
129
121
|
|
|
130
122
|
export function useWorkbenchShortcuts(deps: WorkbenchShortcutsDeps) {
|
|
131
|
-
const {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
auxiliaryWindows,
|
|
138
|
-
mainWindow,
|
|
139
|
-
activeWindow,
|
|
140
|
-
isAuxiliaryWindow,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
showDocumentProperties,
|
|
156
|
-
editor,
|
|
157
|
-
paneEditors,
|
|
158
|
-
paneEditorScrolls,
|
|
159
|
-
paneSearches,
|
|
160
|
-
paneSelections,
|
|
161
|
-
documentUndoAvailable,
|
|
162
|
-
documentRedoAvailable,
|
|
163
|
-
exportBusy,
|
|
164
|
-
printBusy,
|
|
165
|
-
menu,
|
|
166
|
-
workspaceMenu,
|
|
167
|
-
settingsPanel,
|
|
168
|
-
commandPaletteOpened,
|
|
169
|
-
importPanel,
|
|
170
|
-
agentPanel,
|
|
171
|
-
objectDetail,
|
|
172
|
-
planArchiveOpen,
|
|
173
|
-
recyclePanel,
|
|
174
|
-
historyPanel,
|
|
175
|
-
historyPage,
|
|
176
|
-
referenceGraphOpened,
|
|
177
|
-
templateLibraryOpen,
|
|
178
|
-
touchOutlineOpen,
|
|
179
|
-
calendarModeOpen,
|
|
180
|
-
selectedDiff,
|
|
181
|
-
selectionTodo,
|
|
182
|
-
modal,
|
|
183
|
-
modalBusy,
|
|
184
|
-
fileContextMenu,
|
|
185
|
-
directoryContextMenu,
|
|
186
|
-
workspaceEntryContextMenu,
|
|
187
|
-
pageContextMenu,
|
|
188
|
-
outlineContextMenu,
|
|
189
|
-
fileTree,
|
|
190
|
-
selectedEntryIds,
|
|
191
|
-
selectionAnchorId,
|
|
192
|
-
selectedEntries,
|
|
193
|
-
showModal,
|
|
194
|
-
createNewDocument,
|
|
195
|
-
createNewEntry,
|
|
196
|
-
detachTab,
|
|
197
|
-
openImport,
|
|
198
|
-
openTemplateLibrary,
|
|
199
|
-
exportDocument,
|
|
200
|
-
printActiveDocument,
|
|
201
|
-
openPaneSearch,
|
|
202
|
-
undoDocument,
|
|
203
|
-
redoDocument,
|
|
204
|
-
toggleAssistant,
|
|
205
|
-
togglePageLock,
|
|
206
|
-
setLimitPageWidth,
|
|
207
|
-
openDocumentDiscussion,
|
|
208
|
-
toggleSidebar,
|
|
209
|
-
selectContext,
|
|
210
|
-
toggleWorkspaceMenu,
|
|
211
|
-
selectModule,
|
|
212
|
-
openCalendar,
|
|
213
|
-
openSettings,
|
|
214
|
-
closeFileContextMenu,
|
|
215
|
-
closeDirectoryContextMenu,
|
|
216
|
-
closeWorkspaceEntryContextMenu,
|
|
217
|
-
closePageContextMenu,
|
|
218
|
-
closeOutlineContextMenu,
|
|
219
|
-
fileMutationDisabled,
|
|
220
|
-
directoryHasManagedFile,
|
|
221
|
-
startTreeRename,
|
|
222
|
-
removeDocuments,
|
|
223
|
-
selectActiveFileInTree,
|
|
224
|
-
canNavigatePage,
|
|
225
|
-
navigatePage,
|
|
226
|
-
constrainSidebarToViewport,
|
|
227
|
-
} = deps;
|
|
228
|
-
const { workspace, active, busy, openingWorkspace } = storeToRefs(store);
|
|
229
|
-
|
|
230
|
-
const workbenchCommands = computed<WorkbenchCommand[]>(() => {
|
|
231
|
-
const hasDocument = !!active.value;
|
|
232
|
-
const writableWorkspace =
|
|
233
|
-
!!workspace.value && !workspace.value.readOnly && !busy.value && !updateLock.value;
|
|
234
|
-
const standardEditor = hasDocument && !editing.active && !editing.activeBusy;
|
|
235
|
-
const editable = standardEditor && !editorReadonly.value && !active.value?.missing;
|
|
236
|
-
return [
|
|
237
|
-
{
|
|
238
|
-
id: 'workbench.search',
|
|
239
|
-
category: t('文档'),
|
|
240
|
-
get label() {
|
|
241
|
-
return t('查找文档');
|
|
242
|
-
},
|
|
243
|
-
shortcut: shortcuts.value.findDocument,
|
|
244
|
-
available: !busy.value,
|
|
245
|
-
run: () => showModal('search'),
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
id: 'workbench.open',
|
|
249
|
-
category: t('文档'),
|
|
250
|
-
get label() {
|
|
251
|
-
return t('打开文档');
|
|
252
|
-
},
|
|
253
|
-
shortcut: shortcuts.value.openDocument,
|
|
254
|
-
available: !busy.value,
|
|
255
|
-
run: () => showModal('newTab'),
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
id: 'workbench.new',
|
|
259
|
-
category: t('文档'),
|
|
260
|
-
get label() {
|
|
261
|
-
return t('新建文档');
|
|
262
|
-
},
|
|
263
|
-
shortcut: shortcuts.value.newDocument,
|
|
264
|
-
available: writableWorkspace,
|
|
265
|
-
run: createNewDocument,
|
|
266
|
-
},
|
|
267
|
-
// Opens a blank tab in its own window. It shares the current workspace; an independent
|
|
268
|
-
// window with its own workspace would need a second app instance and is not supported.
|
|
269
|
-
{
|
|
270
|
-
id: 'workbench.new-window',
|
|
271
|
-
category: t('文档'),
|
|
272
|
-
get label() {
|
|
273
|
-
return t('新建窗口');
|
|
274
|
-
},
|
|
275
|
-
available:
|
|
276
|
-
native &&
|
|
277
|
-
!mobile &&
|
|
278
|
-
!isAuxiliaryWindow &&
|
|
279
|
-
!!workspace.value &&
|
|
280
|
-
!busy.value &&
|
|
281
|
-
!updateLock.value,
|
|
282
|
-
run: () => {
|
|
283
|
-
const id = store.createBlankTab();
|
|
284
|
-
if (id) return detachTab(id);
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
id: 'workbench.reveal',
|
|
289
|
-
category: t('文档'),
|
|
290
|
-
get label() {
|
|
291
|
-
return t('在资源管理器中显示');
|
|
292
|
-
},
|
|
293
|
-
available: native && !mobile && !isAuxiliaryWindow && !!workspace.value && !store.isWeb,
|
|
294
|
-
run: () => store.reveal(),
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
id: 'workbench.open-folder',
|
|
298
|
-
category: t('文档'),
|
|
299
|
-
get label() {
|
|
300
|
-
return t('打开文件夹');
|
|
301
|
-
},
|
|
302
|
-
available: !isAuxiliaryWindow && !busy.value && !updateLock.value,
|
|
303
|
-
run: () => store.openWorkspace(),
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
id: 'workbench.save',
|
|
307
|
-
category: t('文档'),
|
|
308
|
-
get label() {
|
|
309
|
-
return t('立即保存');
|
|
310
|
-
},
|
|
311
|
-
shortcut: shortcuts.value.save,
|
|
312
|
-
available: hasDocument && !busy.value && !updateLock.value,
|
|
313
|
-
run: () => store.flush(),
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
id: 'workbench.saveAs',
|
|
317
|
-
category: t('文档'),
|
|
318
|
-
get label() {
|
|
319
|
-
return t('另存副本');
|
|
320
|
-
},
|
|
321
|
-
available: standardEditor && writableWorkspace,
|
|
322
|
-
run: () => showModal('saveAs'),
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
id: 'workbench.folder',
|
|
326
|
-
category: t('文档'),
|
|
327
|
-
get label() {
|
|
328
|
-
return t('新建文件夹');
|
|
329
|
-
},
|
|
330
|
-
available: writableWorkspace,
|
|
331
|
-
run: () => createNewEntry('folder'),
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
id: 'workbench.table',
|
|
335
|
-
category: t('文档'),
|
|
336
|
-
get label() {
|
|
337
|
-
return t('新建数据表');
|
|
338
|
-
},
|
|
339
|
-
available: writableWorkspace,
|
|
340
|
-
run: () => createNewEntry('table'),
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
id: 'workbench.import',
|
|
344
|
-
category: t('文档'),
|
|
345
|
-
get label() {
|
|
346
|
-
return t('导入文档');
|
|
347
|
-
},
|
|
348
|
-
available: writableWorkspace,
|
|
349
|
-
run: openImport,
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
id: 'workbench.templates',
|
|
353
|
-
category: t('文档'),
|
|
354
|
-
get label() {
|
|
355
|
-
return t('文档模板');
|
|
356
|
-
},
|
|
357
|
-
available: writableWorkspace,
|
|
358
|
-
run: openTemplateLibrary,
|
|
359
|
-
},
|
|
360
|
-
...(['markdown', 'docx', 'pdf', 'html', 'png'] as const).map((format) => ({
|
|
361
|
-
id: `workbench.export.${format}`,
|
|
362
|
-
category: t('导出'),
|
|
363
|
-
label: { markdown: 'Markdown', docx: 'Word', pdf: 'PDF', html: 'HTML', png: t('图片') }[
|
|
364
|
-
format
|
|
365
|
-
],
|
|
366
|
-
keywords: format,
|
|
367
|
-
available: hasDocument && !exportBusy.value,
|
|
368
|
-
run: () => exportDocument(format),
|
|
369
|
-
})),
|
|
370
|
-
{
|
|
371
|
-
id: 'workbench.print',
|
|
372
|
-
category: t('文档'),
|
|
373
|
-
get label() {
|
|
374
|
-
return t('打印文档');
|
|
375
|
-
},
|
|
376
|
-
shortcut: shortcuts.value.print,
|
|
377
|
-
available: hasDocument && !printBusy.value,
|
|
378
|
-
run: printActiveDocument,
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
id: 'workbench.find',
|
|
382
|
-
category: t('编辑'),
|
|
383
|
-
get label() {
|
|
384
|
-
return t('页内搜索');
|
|
385
|
-
},
|
|
386
|
-
shortcut: shortcuts.value.pageSearch,
|
|
387
|
-
available: standardEditor,
|
|
388
|
-
run: () => openPaneSearch(),
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
id: 'workbench.replace',
|
|
392
|
-
category: t('编辑'),
|
|
393
|
-
get label() {
|
|
394
|
-
return t('查找与替换');
|
|
395
|
-
},
|
|
396
|
-
shortcut: shortcuts.value.pageReplace,
|
|
397
|
-
available: editable,
|
|
398
|
-
run: () => openPaneSearch(store.activePaneId, true),
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
id: 'workbench.undo',
|
|
402
|
-
category: t('编辑'),
|
|
403
|
-
get label() {
|
|
404
|
-
return t('撤销');
|
|
405
|
-
},
|
|
406
|
-
available: editable && documentUndoAvailable.value,
|
|
407
|
-
run: undoDocument,
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
id: 'workbench.redo',
|
|
411
|
-
category: t('编辑'),
|
|
412
|
-
get label() {
|
|
413
|
-
return t('重做');
|
|
414
|
-
},
|
|
415
|
-
available: editable && documentRedoAvailable.value,
|
|
416
|
-
run: redoDocument,
|
|
417
|
-
},
|
|
418
|
-
...editorPaletteCommands({
|
|
419
|
-
editable: editable && !!editor.value,
|
|
420
|
-
source: source.value,
|
|
421
|
-
context: paneSelections[store.activePaneId] ?? defaultSelectionContext,
|
|
422
|
-
features: store.capabilities.features,
|
|
423
|
-
run: (name, value) => editor.value?.command(name, value),
|
|
424
|
-
}),
|
|
425
|
-
{
|
|
426
|
-
id: 'workbench.source',
|
|
427
|
-
category: t('视图'),
|
|
428
|
-
label: source.value ? t('返回可视化编辑') : t('切换源码模式'),
|
|
429
|
-
shortcut: shortcuts.value.toggleSource,
|
|
430
|
-
available: standardEditor,
|
|
431
|
-
keywords: 'Markdown source',
|
|
432
|
-
run: () => {
|
|
433
|
-
source.value = !source.value;
|
|
434
|
-
},
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
id: 'workbench.markdown-reveal',
|
|
438
|
-
category: t('视图'),
|
|
439
|
-
get label() {
|
|
440
|
-
return t('光标展开源码');
|
|
441
|
-
},
|
|
442
|
-
shortcut: shortcuts.value.toggleMarkdownReveal,
|
|
443
|
-
available: standardEditor && !source.value,
|
|
444
|
-
keywords: 'Markdown source cursor',
|
|
445
|
-
run: () => {
|
|
446
|
-
revealMarkdown.value = !revealMarkdown.value;
|
|
447
|
-
},
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
id: 'workbench.assistant',
|
|
451
|
-
category: t('视图'),
|
|
452
|
-
get label() {
|
|
453
|
-
return t('打开或关闭同页助手');
|
|
454
|
-
},
|
|
455
|
-
shortcut: shortcuts.value.toggleAssistant,
|
|
456
|
-
available: !!workspace.value && assistant.available,
|
|
457
|
-
run: toggleAssistant,
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
id: 'workbench.reading',
|
|
461
|
-
category: t('视图'),
|
|
462
|
-
label: pageLocked.value ? t('退出阅读模式') : t('进入阅读模式'),
|
|
463
|
-
available: hasDocument && !workspaceLocked.value,
|
|
464
|
-
keywords: t('锁定页面 解锁'),
|
|
465
|
-
run: togglePageLock,
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
id: 'workbench.width',
|
|
469
|
-
category: t('视图'),
|
|
470
|
-
label: limitPageWidth.value ? t('展开页面全宽') : t('限制页面宽度'),
|
|
471
|
-
available: hasDocument && pageWidthWritable.value,
|
|
472
|
-
run: () => setLimitPageWidth(!limitPageWidth.value),
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
id: 'workbench.outline',
|
|
476
|
-
category: t('视图'),
|
|
477
|
-
label: showOutline.value ? t('隐藏文档目录') : t('显示文档目录'),
|
|
478
|
-
available: hasDocument,
|
|
479
|
-
keywords: t('大纲'),
|
|
480
|
-
run: () => {
|
|
481
|
-
showOutline.value = !showOutline.value;
|
|
482
|
-
},
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
id: 'workbench.properties',
|
|
486
|
-
category: t('视图'),
|
|
487
|
-
label: showDocumentProperties.value ? t('隐藏文档属性') : t('显示文档属性'),
|
|
488
|
-
available: hasDocument,
|
|
489
|
-
run: () => {
|
|
490
|
-
showDocumentProperties.value = !showDocumentProperties.value;
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
id: 'workbench.discussion',
|
|
495
|
-
category: t('文档'),
|
|
496
|
-
get label() {
|
|
497
|
-
return t('发起讨论');
|
|
498
|
-
},
|
|
499
|
-
keywords: t('文档讨论 评论'),
|
|
500
|
-
available: editable,
|
|
501
|
-
run: openDocumentDiscussion,
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
id: 'workbench.sidebar',
|
|
505
|
-
category: t('视图'),
|
|
506
|
-
label: sidebar.value ? t('收起侧栏') : t('展开侧栏'),
|
|
507
|
-
shortcut: shortcuts.value.toggleSidebar,
|
|
508
|
-
available: !isAuxiliaryWindow,
|
|
509
|
-
run: toggleSidebar,
|
|
510
|
-
},
|
|
511
|
-
{
|
|
512
|
-
id: 'workbench.home',
|
|
513
|
-
category: t('导航'),
|
|
514
|
-
get label() {
|
|
515
|
-
return t('切换到主页');
|
|
516
|
-
},
|
|
517
|
-
available: !isAuxiliaryWindow,
|
|
518
|
-
run: () => {
|
|
519
|
-
selectContext('home');
|
|
520
|
-
sidebar.value = true;
|
|
521
|
-
},
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
id: 'workbench.switch-workspace',
|
|
525
|
-
category: t('导航'),
|
|
526
|
-
get label() {
|
|
527
|
-
return t('切换工作区');
|
|
528
|
-
},
|
|
529
|
-
available: !isAuxiliaryWindow,
|
|
530
|
-
run: () => {
|
|
531
|
-
sidebar.value = true;
|
|
532
|
-
toggleWorkspaceMenu();
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
...(extensions.commands ?? []),
|
|
536
|
-
{
|
|
537
|
-
id: 'workbench.repository',
|
|
538
|
-
category: t('工作区'),
|
|
539
|
-
get label() {
|
|
540
|
-
return t('打开仓库');
|
|
541
|
-
},
|
|
542
|
-
available: !isAuxiliaryWindow,
|
|
543
|
-
run: () => {
|
|
544
|
-
sidebar.value = true;
|
|
545
|
-
sidebarView.value = 'repository';
|
|
546
|
-
},
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
id: 'workbench.plan',
|
|
550
|
-
category: t('工作区'),
|
|
551
|
-
get label() {
|
|
552
|
-
return t('打开计划');
|
|
553
|
-
},
|
|
554
|
-
available: !isAuxiliaryWindow && store.workspaceSettings.showPlan,
|
|
555
|
-
run: () => {
|
|
556
|
-
sidebar.value = true;
|
|
557
|
-
selectModule('plan');
|
|
558
|
-
},
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
id: 'workbench.calendar',
|
|
562
|
-
category: t('工作区'),
|
|
563
|
-
get label() {
|
|
564
|
-
return t('打开日历');
|
|
565
|
-
},
|
|
566
|
-
available: store.workspaceSettings.showPlan,
|
|
567
|
-
run: () => openCalendar(),
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
id: 'workbench.graph',
|
|
571
|
-
category: t('工作区'),
|
|
572
|
-
get label() {
|
|
573
|
-
return t('打开关系图谱');
|
|
574
|
-
},
|
|
575
|
-
available: store.workspaceSettings.showGraph,
|
|
576
|
-
run: () => store.openGraphTab(),
|
|
577
|
-
},
|
|
578
|
-
{
|
|
579
|
-
id: 'workbench.plugins',
|
|
580
|
-
category: t('工作区'),
|
|
581
|
-
get label() {
|
|
582
|
-
return t('打开插件中心');
|
|
583
|
-
},
|
|
584
|
-
available: store.workspaceSettings.showPlugins,
|
|
585
|
-
run: () => store.openPluginsTab(),
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
id: 'workbench.updates',
|
|
589
|
-
category: t('历史'),
|
|
590
|
-
get label() {
|
|
591
|
-
return t('文档更新历史');
|
|
592
|
-
},
|
|
593
|
-
available: hasDocument,
|
|
594
|
-
run: () => {
|
|
595
|
-
historyPage.value = 'updates';
|
|
596
|
-
historyPanel.value = true;
|
|
597
|
-
},
|
|
598
|
-
},
|
|
599
|
-
{
|
|
600
|
-
id: 'workbench.versions',
|
|
601
|
-
category: t('历史'),
|
|
602
|
-
get label() {
|
|
603
|
-
return t('文档版本历史');
|
|
604
|
-
},
|
|
605
|
-
available: hasDocument && !!extensions.historyEnabled && !!extensions.historyView,
|
|
606
|
-
run: () => {
|
|
607
|
-
historyPage.value = 'versions';
|
|
608
|
-
historyPanel.value = true;
|
|
609
|
-
},
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
id: 'workbench.settings',
|
|
613
|
-
category: t('设置'),
|
|
614
|
-
get label() {
|
|
615
|
-
return t('外观设置');
|
|
616
|
-
},
|
|
617
|
-
keywords: t('打开设置'),
|
|
618
|
-
run: () => openSettings('appearance'),
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
id: 'workbench.settings.editing',
|
|
622
|
-
category: t('设置'),
|
|
623
|
-
get label() {
|
|
624
|
-
return t('编辑设置');
|
|
625
|
-
},
|
|
626
|
-
run: () => openSettings('editing'),
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
id: 'workbench.settings.shortcuts',
|
|
630
|
-
category: t('设置'),
|
|
631
|
-
get label() {
|
|
632
|
-
return t('快捷键');
|
|
633
|
-
},
|
|
634
|
-
run: () => openSettings('shortcuts'),
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
id: 'workbench.settings.workspace',
|
|
638
|
-
category: t('设置'),
|
|
639
|
-
get label() {
|
|
640
|
-
return t('工作区设置');
|
|
641
|
-
},
|
|
642
|
-
available: navigationContext.value === 'workspace' && !!workspace.value,
|
|
643
|
-
run: () => openSettings('workspace'),
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
id: 'workbench.settings.about',
|
|
647
|
-
category: t('设置'),
|
|
648
|
-
get label() {
|
|
649
|
-
return t('关于同页');
|
|
650
|
-
},
|
|
651
|
-
run: () => openSettings('about'),
|
|
652
|
-
},
|
|
653
|
-
{
|
|
654
|
-
id: 'workbench.check-updates',
|
|
655
|
-
category: t('设置'),
|
|
656
|
-
get label() {
|
|
657
|
-
return t('检查更新');
|
|
658
|
-
},
|
|
659
|
-
available: native && !mobile && !updateLock.value && !updates.state.busy,
|
|
660
|
-
run: () => {
|
|
661
|
-
openSettings('about');
|
|
662
|
-
return updates.check();
|
|
663
|
-
},
|
|
664
|
-
},
|
|
665
|
-
];
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
const routeConfiguredEditorShortcut = configuredEditorShortcuts(
|
|
669
|
-
() => shortcuts.value,
|
|
670
|
-
() => !settingsPanel.value && !modal.value && !commandPaletteOpened.value && !updateLock.value,
|
|
671
|
-
() => paneEditorScrolls.get(store.activePaneId),
|
|
672
|
-
(id) => {
|
|
673
|
-
const action = (
|
|
674
|
-
{
|
|
675
|
-
deleteBlock: 'delete',
|
|
676
|
-
moveBlockUp: 'move-up',
|
|
677
|
-
moveBlockDown: 'move-down',
|
|
678
|
-
indentBlock: 'indent',
|
|
679
|
-
outdentBlock: 'outdent',
|
|
680
|
-
} as Record<string, string>
|
|
681
|
-
)[id];
|
|
682
|
-
if (action) paneEditors.get(store.activePaneId)?.blockShortcut(action);
|
|
683
|
-
},
|
|
684
|
-
);
|
|
685
|
-
// Register during setup, before child editors install their native capture handlers.
|
|
686
|
-
window.addEventListener('keydown', routeConfiguredEditorShortcut, true);
|
|
687
|
-
onBeforeUnmount(() => window.removeEventListener('keydown', routeConfiguredEditorShortcut, true));
|
|
688
|
-
|
|
689
|
-
function handleWorkbenchShortcut(event: KeyboardEvent) {
|
|
690
|
-
if (openingWorkspace.value) return;
|
|
691
|
-
if (
|
|
692
|
-
event.defaultPrevented ||
|
|
693
|
-
importPanel.value ||
|
|
694
|
-
settingsPanel.value ||
|
|
695
|
-
commandPaletteOpened.value ||
|
|
696
|
-
updateLock.value ||
|
|
697
|
-
modal.value
|
|
698
|
-
)
|
|
699
|
-
return;
|
|
700
|
-
let action: (() => void) | undefined;
|
|
701
|
-
const standardEditor = !!active.value && !editing.active && !editing.activeBusy;
|
|
702
|
-
if (
|
|
703
|
-
activeWindow.value.id === 'main' &&
|
|
704
|
-
workspace.value &&
|
|
705
|
-
isSidebarToggleShortcut(event, shortcuts.value)
|
|
706
|
-
)
|
|
707
|
-
action = toggleSidebar;
|
|
708
|
-
else if (matchesShortcut(event, 'save', shortcuts.value))
|
|
709
|
-
action = () => {
|
|
710
|
-
void store.flush();
|
|
711
|
-
};
|
|
712
|
-
else if (active.value && matchesShortcut(event, 'print', shortcuts.value))
|
|
713
|
-
action = () => {
|
|
714
|
-
void printActiveDocument();
|
|
715
|
-
};
|
|
716
|
-
else if (standardEditor && matchesShortcut(event, 'toggleSource', shortcuts.value))
|
|
717
|
-
action = () => {
|
|
718
|
-
source.value = !source.value;
|
|
719
|
-
};
|
|
720
|
-
else if (
|
|
721
|
-
standardEditor &&
|
|
722
|
-
!source.value &&
|
|
723
|
-
matchesShortcut(event, 'toggleMarkdownReveal', shortcuts.value)
|
|
724
|
-
)
|
|
725
|
-
action = () => {
|
|
726
|
-
revealMarkdown.value = !revealMarkdown.value;
|
|
727
|
-
};
|
|
728
|
-
else if (
|
|
729
|
-
workspace.value &&
|
|
730
|
-
assistant.available &&
|
|
731
|
-
matchesShortcut(event, 'toggleAssistant', shortcuts.value)
|
|
732
|
-
)
|
|
733
|
-
action = toggleAssistant;
|
|
734
|
-
else if (matchesShortcut(event, 'findDocument', shortcuts.value))
|
|
735
|
-
action = () => showModal('search');
|
|
736
|
-
else if (workspace.value && matchesShortcut(event, 'openDocument', shortcuts.value))
|
|
737
|
-
action = () => showModal('newTab');
|
|
738
|
-
else if (workspace.value && matchesShortcut(event, 'newDocument', shortcuts.value))
|
|
739
|
-
action = () => {
|
|
740
|
-
void createNewDocument();
|
|
741
|
-
};
|
|
742
|
-
else if (workspace.value && matchesShortcut(event, 'commandPalette', shortcuts.value))
|
|
743
|
-
action = () => {
|
|
744
|
-
commandPaletteOpened.value = true;
|
|
745
|
-
};
|
|
746
|
-
if (!action && workspace.value) {
|
|
747
|
-
const command = pluginShortcutCommand(event, store.pluginCommands, shortcuts.value);
|
|
748
|
-
if (command)
|
|
749
|
-
action = () => {
|
|
750
|
-
void store
|
|
751
|
-
.interactWithPlugin({
|
|
752
|
-
workspaceId: workspace.value!.id,
|
|
753
|
-
pluginId: command.pluginId,
|
|
754
|
-
instanceId: command.instanceId,
|
|
755
|
-
kind: 'command',
|
|
756
|
-
name: command.id,
|
|
757
|
-
payload: { workspaceId: workspace.value!.id, fileId: store.active?.id },
|
|
758
|
-
})
|
|
759
|
-
.catch(store.report);
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
if (!action) return;
|
|
763
|
-
event.preventDefault();
|
|
764
|
-
event.stopPropagation();
|
|
765
|
-
action();
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
function handlePageSearchShortcut(event: KeyboardEvent) {
|
|
769
|
-
if (openingWorkspace.value) return;
|
|
770
|
-
if (
|
|
771
|
-
importPanel.value ||
|
|
772
|
-
settingsPanel.value ||
|
|
773
|
-
commandPaletteOpened.value ||
|
|
774
|
-
updateLock.value ||
|
|
775
|
-
modal.value ||
|
|
776
|
-
event.isComposing ||
|
|
777
|
-
event.keyCode === 229 ||
|
|
778
|
-
event.defaultPrevented
|
|
779
|
-
)
|
|
780
|
-
return;
|
|
781
|
-
const search = paneSearches.get(store.activePaneId);
|
|
782
|
-
if (!search) return;
|
|
783
|
-
const find = matchesShortcut(event, 'pageSearch', shortcuts.value);
|
|
784
|
-
const replace = matchesShortcut(event, 'pageReplace', shortcuts.value);
|
|
785
|
-
if (find || replace) {
|
|
786
|
-
event.preventDefault();
|
|
787
|
-
event.stopPropagation();
|
|
788
|
-
openPaneSearch(store.activePaneId, replace);
|
|
789
|
-
} else if (
|
|
790
|
-
search.isOpen() &&
|
|
791
|
-
!(isElement(event.target) && event.target.closest('.page-search')) &&
|
|
792
|
-
(matchesShortcut(event, 'closeSearch', shortcuts.value) ||
|
|
793
|
-
matchesShortcut(event, 'nextMatchFromEditor', shortcuts.value) ||
|
|
794
|
-
matchesShortcut(event, 'previousMatchFromEditor', shortcuts.value))
|
|
795
|
-
) {
|
|
796
|
-
event.preventDefault();
|
|
797
|
-
event.stopPropagation();
|
|
798
|
-
if (matchesShortcut(event, 'closeSearch', shortcuts.value)) search.close();
|
|
799
|
-
else
|
|
800
|
-
search.navigate(matchesShortcut(event, 'previousMatchFromEditor', shortcuts.value) ? -1 : 1);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
function keydown(event: KeyboardEvent) {
|
|
805
|
-
const { document } = activeWindow.value;
|
|
806
|
-
if (openingWorkspace.value) return;
|
|
807
|
-
if (importPanel.value) return;
|
|
808
|
-
if (settingsPanel.value) {
|
|
809
|
-
if (event.key === 'Escape') settingsPanel.value = false;
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
if (event.key === 'Escape' && fileContextMenu.value) {
|
|
813
|
-
event.preventDefault();
|
|
814
|
-
closeFileContextMenu(true);
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
if (event.key === 'Escape' && directoryContextMenu.value) {
|
|
818
|
-
event.preventDefault();
|
|
819
|
-
closeDirectoryContextMenu();
|
|
820
|
-
return;
|
|
821
|
-
}
|
|
822
|
-
if (event.key === 'Escape' && outlineContextMenu.value) {
|
|
823
|
-
event.preventDefault();
|
|
824
|
-
closeOutlineContextMenu();
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
if (updateLock.value && event.key !== 'Tab') {
|
|
828
|
-
if (event.key === 'Escape' || event.ctrlKey || event.metaKey) event.preventDefault();
|
|
829
|
-
return;
|
|
830
|
-
}
|
|
831
|
-
const treeRow = (event.target as HTMLElement | null)?.closest<HTMLElement>(
|
|
832
|
-
'.tree-scroll .tree-row[data-entry-id]',
|
|
833
|
-
);
|
|
834
|
-
if (treeRow && !modal.value) {
|
|
835
|
-
if (event.key === 'F2') {
|
|
836
|
-
event.preventDefault();
|
|
837
|
-
const file = workspace.value?.files.find((entry) => entry.id === treeRow.dataset.entryId);
|
|
838
|
-
if (
|
|
839
|
-
file &&
|
|
840
|
-
!fileMutationDisabled(file) &&
|
|
841
|
-
!directoryHasManagedFile(file) &&
|
|
842
|
-
(!store.isWeb || file.kind === 'file')
|
|
843
|
-
)
|
|
844
|
-
startTreeRename(file);
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'a') {
|
|
848
|
-
event.preventDefault();
|
|
849
|
-
selectedEntryIds.value = new Set(fileTree.value?.getVisibleIds() ?? []);
|
|
850
|
-
selectionAnchorId.value = treeRow.dataset.entryId ?? null;
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
if (event.key === 'Delete' && selectedEntries.value.length) {
|
|
854
|
-
event.preventDefault();
|
|
855
|
-
void removeDocuments([...selectedEntries.value]);
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
if (event.key === 'Escape' && selectedEntryIds.value.size) {
|
|
859
|
-
event.preventDefault();
|
|
860
|
-
selectActiveFileInTree();
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
if (event.key === 'Escape' && !modalBusy.value) {
|
|
865
|
-
modal.value = '';
|
|
866
|
-
menu.value = false;
|
|
867
|
-
workspaceMenu.value = false;
|
|
868
|
-
if (compactPanes.value) sidebar.value = false;
|
|
869
|
-
}
|
|
870
|
-
if (event.key === 'Tab' && modal.value) {
|
|
871
|
-
const targets = [
|
|
872
|
-
...document.querySelectorAll<HTMLElement>(
|
|
873
|
-
':is(.modal, .search-modal) :is(button:not(:disabled), input, a)',
|
|
874
|
-
),
|
|
875
|
-
];
|
|
876
|
-
const first = targets[0];
|
|
877
|
-
const last = targets.at(-1);
|
|
878
|
-
if (event.shiftKey && document.activeElement === first) {
|
|
879
|
-
event.preventDefault();
|
|
880
|
-
last?.focus();
|
|
881
|
-
} else if (!event.shiftKey && document.activeElement === last) {
|
|
882
|
-
event.preventDefault();
|
|
883
|
-
first?.focus();
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
function beforeUnload(event: BeforeUnloadEvent) {
|
|
889
|
-
if (store.pending) {
|
|
890
|
-
event.preventDefault();
|
|
891
|
-
event.returnValue = '';
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
function mobileBack(event: Event) {
|
|
896
|
-
// Android's system back first dismisses the current surface, then navigates.
|
|
897
|
-
// Keep in-flight mutations mounted until their normal completion path runs.
|
|
898
|
-
const dialog = document.querySelector<HTMLDialogElement>('dialog[open]');
|
|
899
|
-
if (dialog) {
|
|
900
|
-
event.preventDefault();
|
|
901
|
-
dialog.dispatchEvent(new Event('cancel', { cancelable: true }));
|
|
902
|
-
return;
|
|
903
|
-
}
|
|
904
|
-
const layer = [
|
|
905
|
-
agentPanel,
|
|
906
|
-
planArchiveOpen,
|
|
907
|
-
recyclePanel,
|
|
908
|
-
historyPanel,
|
|
909
|
-
referenceGraphOpened,
|
|
910
|
-
commandPaletteOpened,
|
|
911
|
-
templateLibraryOpen,
|
|
912
|
-
touchOutlineOpen,
|
|
913
|
-
].find((opened) => opened.value);
|
|
914
|
-
const dismiss =
|
|
915
|
-
modalBusy.value || updateLock.value || busy.value
|
|
916
|
-
? () => {}
|
|
917
|
-
: fileContextMenu.value
|
|
918
|
-
? () => closeFileContextMenu(true)
|
|
919
|
-
: directoryContextMenu.value
|
|
920
|
-
? closeDirectoryContextMenu
|
|
921
|
-
: workspaceEntryContextMenu.value
|
|
922
|
-
? closeWorkspaceEntryContextMenu
|
|
923
|
-
: pageContextMenu.value
|
|
924
|
-
? closePageContextMenu
|
|
925
|
-
: outlineContextMenu.value
|
|
926
|
-
? closeOutlineContextMenu
|
|
927
|
-
: menu.value
|
|
928
|
-
? () => {
|
|
929
|
-
menu.value = false;
|
|
930
|
-
}
|
|
931
|
-
: workspaceMenu.value
|
|
932
|
-
? () => {
|
|
933
|
-
workspaceMenu.value = false;
|
|
934
|
-
}
|
|
935
|
-
: modal.value
|
|
936
|
-
? () => {
|
|
937
|
-
modal.value = '';
|
|
938
|
-
}
|
|
939
|
-
: settingsPanel.value
|
|
940
|
-
? () => {
|
|
941
|
-
settingsPanel.value = false;
|
|
942
|
-
}
|
|
943
|
-
: importPanel.value
|
|
944
|
-
? () => {
|
|
945
|
-
importPanel.value = false;
|
|
946
|
-
}
|
|
947
|
-
: selectedDiff.value
|
|
948
|
-
? () => {
|
|
949
|
-
selectedDiff.value = undefined;
|
|
950
|
-
}
|
|
951
|
-
: objectDetail.value
|
|
952
|
-
? () => {
|
|
953
|
-
objectDetail.value = undefined;
|
|
954
|
-
}
|
|
955
|
-
: selectionTodo.value
|
|
956
|
-
? () => {
|
|
957
|
-
selectionTodo.value = undefined;
|
|
958
|
-
}
|
|
959
|
-
: layer
|
|
960
|
-
? () => {
|
|
961
|
-
layer.value = false;
|
|
962
|
-
}
|
|
963
|
-
: compactPanes.value && sidebar.value
|
|
964
|
-
? () => {
|
|
965
|
-
sidebar.value = false;
|
|
966
|
-
}
|
|
967
|
-
: assistant.opened
|
|
968
|
-
? () => {
|
|
969
|
-
assistant.opened = false;
|
|
970
|
-
}
|
|
971
|
-
: canNavigatePage(-1)
|
|
972
|
-
? () => navigatePage(-1)
|
|
973
|
-
: undefined;
|
|
974
|
-
if (dismiss) {
|
|
975
|
-
event.preventDefault();
|
|
976
|
-
dismiss();
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
async function mobileVisibility() {
|
|
981
|
-
try {
|
|
982
|
-
await handleMobileVisibility({
|
|
983
|
-
mobile,
|
|
984
|
-
hasWorkspace: !!workspace.value,
|
|
985
|
-
visibilityState: document.visibilityState,
|
|
986
|
-
flushWorkspace: () => store.flush(),
|
|
987
|
-
flushEditing: () => editing.flush(),
|
|
988
|
-
refreshWorkspace: () => store.refresh(),
|
|
989
|
-
synchronize: () => extensions.refresh(),
|
|
990
|
-
});
|
|
991
|
-
} catch (reason) {
|
|
992
|
-
store.report(reason);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
function outsideClick(event: MouseEvent) {
|
|
997
|
-
const target = event.target as HTMLElement;
|
|
998
|
-
if (!target.closest('.calendar-view-picker')) calendarModeOpen.value = false;
|
|
999
|
-
if (!target.closest('.file-context-menu')) closeFileContextMenu();
|
|
1000
|
-
if (!target.closest('.directory-context-menu')) closeDirectoryContextMenu();
|
|
1001
|
-
if (!target.closest('.workspace-entry-context-menu')) closeWorkspaceEntryContextMenu();
|
|
1002
|
-
if (!target.closest('.page-context-menu')) closePageContextMenu();
|
|
1003
|
-
if (!target.closest('.outline-context-menu')) closeOutlineContextMenu();
|
|
1004
|
-
if (!target.closest('.dropdown, .menu-wrap, .sidebar-bottom')) {
|
|
1005
|
-
menu.value = false;
|
|
1006
|
-
workspaceMenu.value = false;
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
function dismissFileContextMenu() {
|
|
1011
|
-
closeFileContextMenu();
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
function outsideContextMenu(event: MouseEvent) {
|
|
1015
|
-
if (!(event.target as HTMLElement).closest('.tree-row')) closeFileContextMenu();
|
|
1016
|
-
if (!event.defaultPrevented && !(event.target as HTMLElement).closest('.directory-context-menu'))
|
|
1017
|
-
closeDirectoryContextMenu();
|
|
1018
|
-
if (
|
|
1019
|
-
!event.defaultPrevented &&
|
|
1020
|
-
!(event.target as HTMLElement).closest('.workspace-entry-context-menu')
|
|
1021
|
-
)
|
|
1022
|
-
closeWorkspaceEntryContextMenu();
|
|
1023
|
-
if (!event.defaultPrevented) {
|
|
1024
|
-
closePageContextMenu();
|
|
1025
|
-
closeOutlineContextMenu();
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
function dismissPageContextMenu() {
|
|
1030
|
-
closePageContextMenu();
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
function bindAuxiliaryEvents(context: WindowContext) {
|
|
1034
|
-
const focus = () => {
|
|
1035
|
-
activeWindow.value = context;
|
|
1036
|
-
const paneId = store.windowLayouts[context.id]?.activePaneId;
|
|
1037
|
-
if (paneId) store.focusPane(paneId);
|
|
1038
|
-
};
|
|
1039
|
-
const handlers: [string, EventListener, boolean][] = [
|
|
1040
|
-
['focus', focus, true],
|
|
1041
|
-
['pointerdown', focus, true],
|
|
1042
|
-
['keydown', routeConfiguredEditorShortcut as EventListener, true],
|
|
1043
|
-
['keydown', handleWorkbenchShortcut as EventListener, true],
|
|
1044
|
-
['keydown', handlePageSearchShortcut as EventListener, true],
|
|
1045
|
-
['keydown', keydown as EventListener, false],
|
|
1046
|
-
['click', outsideClick as EventListener, false],
|
|
1047
|
-
['contextmenu', outsideContextMenu as EventListener, false],
|
|
1048
|
-
['scroll', dismissPageContextMenu, true],
|
|
1049
|
-
['scroll', closeOutlineContextMenu, true],
|
|
1050
|
-
['resize', dismissPageContextMenu, false],
|
|
1051
|
-
['resize', closeOutlineContextMenu, false],
|
|
1052
|
-
];
|
|
1053
|
-
for (const [name, handler, capture] of handlers)
|
|
1054
|
-
context.window.addEventListener(name, handler, capture);
|
|
1055
|
-
const stopMotion = installInteractionMotion(context.document);
|
|
1056
|
-
return () => {
|
|
1057
|
-
for (const [name, handler, capture] of handlers)
|
|
1058
|
-
context.window.removeEventListener(name, handler, capture);
|
|
1059
|
-
stopMotion();
|
|
1060
|
-
if (activeWindow.value === context) activeWindow.value = mainWindow;
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
const auxiliaryEventDisposers = new Map<string, () => void>();
|
|
1065
|
-
watch(
|
|
1066
|
-
() => [...auxiliaryWindows.entries.values()],
|
|
1067
|
-
(entries) => {
|
|
1068
|
-
for (const [id, dispose] of auxiliaryEventDisposers) {
|
|
1069
|
-
if (!entries.some((entry) => entry.id === id)) {
|
|
1070
|
-
dispose();
|
|
1071
|
-
auxiliaryEventDisposers.delete(id);
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
for (const entry of entries) {
|
|
1075
|
-
if (!auxiliaryEventDisposers.has(entry.id))
|
|
1076
|
-
auxiliaryEventDisposers.set(entry.id, bindAuxiliaryEvents(entry.context));
|
|
1077
|
-
}
|
|
1078
|
-
},
|
|
1079
|
-
{ flush: 'sync' },
|
|
1080
|
-
);
|
|
1081
|
-
|
|
1082
|
-
const focusMain = () => {
|
|
1083
|
-
activeWindow.value = mainWindow;
|
|
1084
|
-
const paneId = store.windowLayouts.main.activePaneId;
|
|
1085
|
-
if (paneId) store.focusPane(paneId);
|
|
1086
|
-
};
|
|
1087
|
-
window.addEventListener('focus', focusMain);
|
|
1088
|
-
window.addEventListener('pointerdown', focusMain, true);
|
|
1089
|
-
|
|
1090
|
-
onMounted(() => {
|
|
1091
|
-
window.addEventListener('keydown', handleWorkbenchShortcut, true);
|
|
1092
|
-
window.addEventListener('keydown', keydown);
|
|
1093
|
-
window.addEventListener('keydown', handlePageSearchShortcut, true);
|
|
1094
|
-
window.addEventListener('beforeunload', beforeUnload);
|
|
1095
|
-
window.addEventListener('click', outsideClick);
|
|
1096
|
-
window.addEventListener('contextmenu', outsideContextMenu);
|
|
1097
|
-
window.addEventListener('scroll', dismissFileContextMenu, true);
|
|
1098
|
-
window.addEventListener('scroll', closeDirectoryContextMenu, true);
|
|
1099
|
-
window.addEventListener('scroll', dismissPageContextMenu, true);
|
|
1100
|
-
window.addEventListener('scroll', closeOutlineContextMenu, true);
|
|
1101
|
-
window.addEventListener('resize', dismissFileContextMenu);
|
|
1102
|
-
window.addEventListener('resize', closeDirectoryContextMenu);
|
|
1103
|
-
window.addEventListener('resize', dismissPageContextMenu);
|
|
1104
|
-
window.addEventListener('resize', closeOutlineContextMenu);
|
|
1105
|
-
if (!isAuxiliaryWindow) window.addEventListener('resize', constrainSidebarToViewport);
|
|
1106
|
-
document.addEventListener('visibilitychange', mobileVisibility);
|
|
1107
|
-
window.addEventListener('tano:back', mobileBack);
|
|
1108
|
-
});
|
|
1109
|
-
|
|
1110
|
-
onBeforeUnmount(() => {
|
|
1111
|
-
window.removeEventListener('focus', focusMain);
|
|
1112
|
-
window.removeEventListener('pointerdown', focusMain, true);
|
|
1113
|
-
for (const dispose of auxiliaryEventDisposers.values()) dispose();
|
|
1114
|
-
auxiliaryEventDisposers.clear();
|
|
1115
|
-
window.removeEventListener('keydown', handleWorkbenchShortcut, true);
|
|
1116
|
-
window.removeEventListener('keydown', keydown);
|
|
1117
|
-
window.removeEventListener('keydown', handlePageSearchShortcut, true);
|
|
1118
|
-
window.removeEventListener('beforeunload', beforeUnload);
|
|
1119
|
-
window.removeEventListener('click', outsideClick);
|
|
1120
|
-
window.removeEventListener('contextmenu', outsideContextMenu);
|
|
1121
|
-
window.removeEventListener('scroll', dismissFileContextMenu, true);
|
|
1122
|
-
window.removeEventListener('scroll', closeDirectoryContextMenu, true);
|
|
1123
|
-
window.removeEventListener('scroll', dismissPageContextMenu, true);
|
|
1124
|
-
window.removeEventListener('scroll', closeOutlineContextMenu, true);
|
|
1125
|
-
window.removeEventListener('resize', dismissFileContextMenu);
|
|
1126
|
-
window.removeEventListener('resize', closeDirectoryContextMenu);
|
|
1127
|
-
window.removeEventListener('resize', dismissPageContextMenu);
|
|
1128
|
-
window.removeEventListener('resize', closeOutlineContextMenu);
|
|
1129
|
-
window.removeEventListener('resize', constrainSidebarToViewport);
|
|
1130
|
-
document.removeEventListener('visibilitychange', mobileVisibility);
|
|
1131
|
-
window.removeEventListener('tano:back', mobileBack);
|
|
123
|
+
const { workbenchCommands } = useWorkbenchCommands(deps);
|
|
124
|
+
const keybindings = useWorkbenchKeybindings(deps);
|
|
125
|
+
const dismissal = useSurfaceDismissal(deps);
|
|
126
|
+
|
|
127
|
+
useWindowEventBridge({
|
|
128
|
+
store: deps.store,
|
|
129
|
+
auxiliaryWindows: deps.auxiliaryWindows,
|
|
130
|
+
mainWindow: deps.mainWindow,
|
|
131
|
+
activeWindow: deps.activeWindow,
|
|
132
|
+
isAuxiliaryWindow: deps.isAuxiliaryWindow,
|
|
133
|
+
routeConfiguredEditorShortcut: keybindings.routeConfiguredEditorShortcut,
|
|
134
|
+
handleWorkbenchShortcut: keybindings.handleWorkbenchShortcut,
|
|
135
|
+
handlePageSearchShortcut: keybindings.handlePageSearchShortcut,
|
|
136
|
+
keydown: keybindings.keydown,
|
|
137
|
+
beforeUnload: dismissal.beforeUnload,
|
|
138
|
+
outsideClick: dismissal.outsideClick,
|
|
139
|
+
outsideContextMenu: dismissal.outsideContextMenu,
|
|
140
|
+
dismissFileContextMenu: dismissal.dismissFileContextMenu,
|
|
141
|
+
closeDirectoryContextMenu: deps.closeDirectoryContextMenu,
|
|
142
|
+
dismissPageContextMenu: dismissal.dismissPageContextMenu,
|
|
143
|
+
closeOutlineContextMenu: deps.closeOutlineContextMenu,
|
|
144
|
+
constrainSidebarToViewport: deps.constrainSidebarToViewport,
|
|
145
|
+
mobileVisibility: dismissal.mobileVisibility,
|
|
146
|
+
mobileBack: dismissal.mobileBack,
|
|
1132
147
|
});
|
|
1133
148
|
|
|
1134
149
|
return {
|