@tano.page/workbench 0.14.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.
Files changed (248) hide show
  1. package/package.json +50 -16
  2. package/src/App.vue +82 -752
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/agent-identities.ts +1 -97
  17. package/src/assistant/agent-task-context.ts +1 -54
  18. package/src/assistant/attachments.ts +1 -1
  19. package/src/assistant/completion.ts +1 -61
  20. package/src/assistant/components/AssistantChangeList.vue +98 -21
  21. package/src/assistant/components/AssistantPanel.vue +425 -8
  22. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  23. package/src/assistant/connection-actions.ts +237 -0
  24. package/src/assistant/document-mentions.ts +1 -33
  25. package/src/assistant/engine.ts +1 -532
  26. package/src/assistant/execution.ts +6 -33
  27. package/src/assistant/files.ts +5 -13
  28. package/src/assistant/hash.ts +1 -4
  29. package/src/assistant/inbox.ts +1 -148
  30. package/src/assistant/language.ts +10 -37
  31. package/src/assistant/mention-autocomplete.ts +69 -0
  32. package/src/assistant/plugin-bridge-builder.ts +146 -0
  33. package/src/assistant/prompts.ts +1 -58
  34. package/src/assistant/proposal-actions.ts +336 -0
  35. package/src/assistant/results.ts +20 -86
  36. package/src/assistant/store.ts +167 -327
  37. package/src/assistant/structures.ts +1 -155
  38. package/src/assistant/tasks.ts +8 -96
  39. package/src/assistant/tool-rules.ts +1 -7
  40. package/src/assistant/workspace-bridge.ts +1 -1
  41. package/src/composables/use-document-actions.ts +38 -20
  42. package/src/composables/use-file-tree-controller.ts +7 -12
  43. package/src/composables/use-workbench-help.ts +177 -0
  44. package/src/composables/use-workbench-history.ts +2 -4
  45. package/src/composables/use-workbench-lifecycle.ts +249 -0
  46. package/src/composables/use-workbench-modals.ts +6 -1
  47. package/src/composables/use-workbench-outline.ts +0 -5
  48. package/src/composables/use-workbench-settings.ts +185 -0
  49. package/src/composables/use-workbench-shortcuts.ts +40 -1021
  50. package/src/composables/use-workbench-views.ts +325 -0
  51. package/src/data-tables/data-tables.ts +1 -2
  52. package/src/documents/components/DocumentActionMenu.vue +279 -0
  53. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  54. package/src/documents/components/DocumentInspector.vue +168 -0
  55. package/src/documents/components/DocumentPane.vue +482 -0
  56. package/src/documents/description-merge.ts +1 -9
  57. package/src/features.ts +1 -0
  58. package/src/files/components/FileMetadataPanel.vue +49 -15
  59. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  60. package/src/fonts/Inter-Latin.woff2 +0 -0
  61. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  62. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  63. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  64. package/src/help/help-milestones.ts +3 -5
  65. package/src/i18n/locale-catalogs.ts +7 -6
  66. package/src/i18n/locale-registry.ts +8 -6
  67. package/src/i18n/locales/de-DE.json +371 -3
  68. package/src/i18n/locales/en-US.json +371 -2
  69. package/src/i18n/locales/es-ES.json +371 -3
  70. package/src/i18n/locales/ja-JP.json +370 -2
  71. package/src/i18n/locales/zh-TW.json +370 -2
  72. package/src/mail/components/MailAccountDialog.vue +450 -0
  73. package/src/mail/components/MailComposerDialog.vue +326 -0
  74. package/src/mail/components/MailProviderIcon.vue +30 -0
  75. package/src/mail/components/MailWorkspaceView.vue +821 -0
  76. package/src/mail/components/SidebarMail.vue +134 -0
  77. package/src/mail/mail-avatar.ts +17 -0
  78. package/src/mail/mail-bridge.ts +68 -0
  79. package/src/mail/mail-calendar.ts +208 -0
  80. package/src/mail/mail-markdown.ts +195 -0
  81. package/src/mail/types.ts +226 -0
  82. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  83. package/src/objects/content-references.ts +6 -56
  84. package/src/objects/wiki-links.ts +1 -48
  85. package/src/objects/workspace-objects.ts +3 -4
  86. package/src/plan-sync/types.ts +6 -3
  87. package/src/plans/calendar-interaction.ts +194 -0
  88. package/src/plans/calendar.ts +65 -9
  89. package/src/plans/components/CalendarAgendaView.vue +165 -0
  90. package/src/plans/components/CalendarDayPopover.vue +172 -39
  91. package/src/plans/components/CalendarFilterBar.vue +128 -0
  92. package/src/plans/components/CalendarMonthView.vue +224 -0
  93. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  94. package/src/plans/components/CalendarTimelineView.vue +517 -0
  95. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  96. package/src/plans/components/CalendarView.vue +264 -748
  97. package/src/plans/components/CalendarYearView.vue +138 -0
  98. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  99. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  100. package/src/plans/components/PlanDateField.vue +6 -4
  101. package/src/plans/components/PlanDetailPanel.vue +227 -32
  102. package/src/plans/components/PlanEventList.vue +16 -4
  103. package/src/plans/components/SidebarPlan.vue +22 -15
  104. package/src/plans/components/TaskRepeatControls.vue +169 -30
  105. package/src/plans/components/calendar-shared.css +192 -0
  106. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  107. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  108. package/src/plans/local-reminders.ts +149 -0
  109. package/src/plans/personal-plans.ts +10 -1
  110. package/src/plans/plan-date.ts +8 -1
  111. package/src/plans/plan-migration.ts +95 -0
  112. package/src/plans/recurrence.ts +95 -0
  113. package/src/plans/task-repeat.ts +8 -8
  114. package/src/plans/timeline-layout.ts +92 -0
  115. package/src/plugins/assistant-bridge.ts +520 -0
  116. package/src/plugins/attachment-reader.ts +3 -1
  117. package/src/plugins/cache-storage.ts +42 -2
  118. package/src/plugins/components/PluginAutomations.vue +3 -3
  119. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  120. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  121. package/src/plugins/components/PluginConnections.vue +1 -1
  122. package/src/plugins/components/PluginCustomView.vue +2 -2
  123. package/src/plugins/components/PluginDetailPage.vue +136 -57
  124. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  125. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  126. package/src/plugins/components/PluginExplorer.vue +21 -25
  127. package/src/plugins/components/PluginImportDialog.vue +410 -0
  128. package/src/plugins/components/PluginInstaller.vue +273 -288
  129. package/src/plugins/components/PluginListItem.vue +3 -0
  130. package/src/plugins/components/PluginMaintenance.vue +37 -34
  131. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  132. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  133. package/src/plugins/components/PluginSettingsForm.vue +112 -0
  134. package/src/plugins/components/PluginStatusBar.vue +161 -0
  135. package/src/plugins/components/PluginSurface.vue +18 -6
  136. package/src/plugins/components/PluginUiDialog.vue +452 -0
  137. package/src/plugins/components/PluginsTabPage.vue +61 -0
  138. package/src/plugins/components/plugin-center.css +5 -0
  139. package/src/plugins/data.ts +9 -86
  140. package/src/plugins/editor-plugin-adapters.ts +169 -0
  141. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  142. package/src/plugins/excalidraw/manifest.json +12 -1
  143. package/src/plugins/host.ts +662 -43
  144. package/src/plugins/native.ts +2 -10
  145. package/src/plugins/overlay-mapping.ts +125 -0
  146. package/src/plugins/packages.ts +73 -1
  147. package/src/plugins/plugin-data.ts +2 -3
  148. package/src/plugins/plugin-permissions.ts +57 -0
  149. package/src/plugins/plugin-rpc-router.ts +558 -0
  150. package/src/plugins/plugin-sdk.ts +1 -94
  151. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  152. package/src/plugins/policy.ts +53 -3
  153. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  154. package/src/plugins/presentation-preview/manifest.json +2 -1
  155. package/src/plugins/queries.ts +1 -73
  156. package/src/plugins/sandbox.ts +15 -1
  157. package/src/plugins/use-plugin-actions.ts +67 -20
  158. package/src/plugins/user-plugins.ts +254 -0
  159. package/src/plugins/view-header.ts +2 -7
  160. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  161. package/src/plugins/word-preview/manifest.json +13 -1
  162. package/src/plugins/workbench.ts +175 -2
  163. package/src/plugins/worker.js +105 -8
  164. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  165. package/src/plugins/workspace-plugins.ts +212 -21
  166. package/src/runtime.ts +103 -4
  167. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  168. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  169. package/src/settings/components/SettingsPanel.vue +8 -3
  170. package/src/settings/components/WorkbenchSettings.vue +20 -7
  171. package/src/settings/components/settings-context.ts +1 -1
  172. package/src/settings/components/settings-search.ts +2 -3
  173. package/src/settings/settings-tab.ts +1 -0
  174. package/src/shell/command-palette.ts +3 -3
  175. package/src/shell/components/EditorToolbar.vue +8 -9
  176. package/src/shell/components/EditorTools.vue +1 -5
  177. package/src/shell/components/PaneTopbar.vue +393 -0
  178. package/src/shell/components/SelectionToolbar.vue +0 -2
  179. package/src/shell/components/SidebarNavigation.vue +22 -2
  180. package/src/shell/components/WorkbenchContextMenus.vue +58 -34
  181. package/src/shell/components/WorkbenchModals.vue +47 -62
  182. package/src/shell/components/WorkbenchPanes.vue +371 -1342
  183. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  184. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  185. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  186. package/src/shell/pane-registry.ts +69 -0
  187. package/src/shell/use-surface-dismissal.ts +219 -0
  188. package/src/shell/use-workbench-commands.ts +599 -0
  189. package/src/shell/use-workbench-keybindings.ts +337 -0
  190. package/src/shell/use-workbench.ts +531 -1153
  191. package/src/shell/workbench-async-components.ts +14 -5
  192. package/src/shell/workbench-context.ts +30 -3
  193. package/src/stores/mail.ts +414 -0
  194. package/src/stores/plan-sync.ts +2 -1
  195. package/src/stores/plans.ts +2 -9
  196. package/src/stores/workspace-document-io.ts +807 -0
  197. package/src/stores/workspace-file-ops.ts +1 -1
  198. package/src/stores/workspace-knowledge.ts +2 -114
  199. package/src/stores/workspace-lifecycle.ts +459 -0
  200. package/src/stores/workspace-plugins-state.ts +254 -259
  201. package/src/stores/workspace-session.ts +287 -0
  202. package/src/stores/workspace-tabs-layout.ts +6 -44
  203. package/src/stores/workspace-types.ts +50 -0
  204. package/src/stores/workspace.ts +184 -1363
  205. package/src/styles/agent-diff-modals.css +0 -7
  206. package/src/styles/dark-theme.css +3 -3
  207. package/src/styles/inspector.css +0 -59
  208. package/src/styles/layout-themes.css +346 -0
  209. package/src/styles/mail.css +1568 -0
  210. package/src/styles/mobile.css +2 -2
  211. package/src/styles/recent-and-media.css +0 -17
  212. package/src/styles/theme-contract.css +3 -3
  213. package/src/styles/workbench-shell.css +110 -17
  214. package/src/styles/workspace-states.css +9 -33
  215. package/src/styles.css +0 -1
  216. package/src/tabs/components/DesktopTabs.vue +19 -14
  217. package/src/tabs/components/NewTabPicker.vue +10 -4
  218. package/src/tabs/tab-label.ts +0 -1
  219. package/src/windows/AuxiliaryWindows.vue +2 -2
  220. package/src/windows/use-window-event-bridge.ts +152 -0
  221. package/src/workspace/components/TemplateLibrary.vue +1 -1
  222. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  223. package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
  224. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  225. package/src/workspace/workspace-comments.ts +11 -151
  226. package/src/workspace/workspace-welcome.ts +1 -1
  227. package/src/assistant/locales/de-DE.json +0 -126
  228. package/src/assistant/locales/en-US.json +0 -126
  229. package/src/assistant/locales/es-ES.json +0 -126
  230. package/src/assistant/locales/ja-JP.json +0 -126
  231. package/src/assistant/locales/zh-CN.json +0 -126
  232. package/src/assistant/locales/zh-TW.json +0 -126
  233. package/src/assistant/task-prompts.json +0 -39
  234. package/src/documents/components/FormulaMenu.vue +0 -50
  235. package/src/files/components/FileDatabasePage.vue +0 -152
  236. package/src/files/components/FolderHomeIcon.vue +0 -12
  237. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  238. package/src/objects/components/ObjectPanel.vue +0 -554
  239. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  240. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  241. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  242. package/src/styles/object-panel.css +0 -163
  243. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  244. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  245. package/src/workspace/welcome-slogans.ts +0 -11
  246. package/src/workspace/workspace-git.ts +0 -35
  247. package/src/workspace/workspace-sync.ts +0 -46
  248. package/src/workspace/workspace-views.ts +0 -48
@@ -1,33 +1,25 @@
1
- import { computed, onBeforeUnmount, onMounted, watch, type Ref } from 'vue';
2
- import { storeToRefs } from 'pinia';
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 { t } from '../i18n/i18n';
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
- isSidebarToggleShortcut,
23
- matchesShortcut,
24
- type ShortcutBindings,
25
- } from '../shell/shortcuts';
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 type { MarkdownEditor } from '../shell/workbench-async-components';
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>;
@@ -69,7 +61,8 @@ export interface WorkbenchShortcutsDeps {
69
61
  commandPaletteOpened: Ref<boolean>;
70
62
  importPanel: Ref<boolean>;
71
63
  agentPanel: Ref<boolean>;
72
- objectPanel: Ref<boolean>;
64
+ objectDetail: Ref<unknown>;
65
+ planArchiveOpen: Ref<boolean>;
73
66
  recyclePanel: Ref<boolean>;
74
67
  historyPanel: Ref<boolean>;
75
68
  historyPage: Ref<'versions' | 'updates'>;
@@ -92,7 +85,7 @@ export interface WorkbenchShortcutsDeps {
92
85
  selectedEntries: Ref<FileEntry[]>;
93
86
  showModal: (kind: 'newTab' | 'search' | 'delete' | 'saveAs', target?: FileEntry) => void;
94
87
  createNewDocument: () => Promise<void>;
95
- createNewEntry: (kind: 'document' | 'folder', parent?: string) => Promise<void>;
88
+ createNewEntry: (kind: 'document' | 'folder' | 'table', parent?: string) => Promise<void>;
96
89
  detachTab: (id: string) => Promise<void>;
97
90
  openImport: () => void;
98
91
  openTemplateLibrary: () => void;
@@ -110,7 +103,6 @@ export interface WorkbenchShortcutsDeps {
110
103
  toggleWorkspaceMenu: () => void;
111
104
  selectModule: (id: string) => void;
112
105
  openCalendar: (date?: Date) => void;
113
- openSystemSync: (event?: Event) => void;
114
106
  openSettings: (page?: SettingsPageId) => void;
115
107
  closeFileContextMenu: (restoreFocus?: boolean) => void;
116
108
  closeDirectoryContextMenu: () => void;
@@ -128,1003 +120,30 @@ export interface WorkbenchShortcutsDeps {
128
120
  }
129
121
 
130
122
  export function useWorkbenchShortcuts(deps: WorkbenchShortcutsDeps) {
131
- const {
132
- store,
133
- assistant,
134
- updates,
135
- extensions,
136
- editing,
137
- auxiliaryWindows,
138
- mainWindow,
139
- activeWindow,
140
- isAuxiliaryWindow,
141
- compactPanes,
142
- sidebar,
143
- sidebarView,
144
- navigationContext,
145
- shortcuts,
146
- updateLock,
147
- editorReadonly,
148
- source,
149
- revealMarkdown,
150
- pageLocked,
151
- workspaceLocked,
152
- limitPageWidth,
153
- pageWidthWritable,
154
- showOutline,
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
- objectPanel,
172
- recyclePanel,
173
- historyPanel,
174
- historyPage,
175
- referenceGraphOpened,
176
- templateLibraryOpen,
177
- touchOutlineOpen,
178
- calendarModeOpen,
179
- selectedDiff,
180
- selectionTodo,
181
- modal,
182
- modalBusy,
183
- fileContextMenu,
184
- directoryContextMenu,
185
- workspaceEntryContextMenu,
186
- pageContextMenu,
187
- outlineContextMenu,
188
- fileTree,
189
- selectedEntryIds,
190
- selectionAnchorId,
191
- selectedEntries,
192
- showModal,
193
- createNewDocument,
194
- createNewEntry,
195
- detachTab,
196
- openImport,
197
- openTemplateLibrary,
198
- exportDocument,
199
- printActiveDocument,
200
- openPaneSearch,
201
- undoDocument,
202
- redoDocument,
203
- toggleAssistant,
204
- togglePageLock,
205
- setLimitPageWidth,
206
- openDocumentDiscussion,
207
- toggleSidebar,
208
- selectContext,
209
- toggleWorkspaceMenu,
210
- selectModule,
211
- openCalendar,
212
- openSystemSync,
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.import',
335
- category: t('文档'),
336
- get label() {
337
- return t('导入文档');
338
- },
339
- available: writableWorkspace,
340
- run: openImport,
341
- },
342
- {
343
- id: 'workbench.templates',
344
- category: t('文档'),
345
- get label() {
346
- return t('文档模板');
347
- },
348
- available: writableWorkspace,
349
- run: openTemplateLibrary,
350
- },
351
- ...(['markdown', 'docx', 'pdf', 'html', 'png'] as const).map((format) => ({
352
- id: `workbench.export.${format}`,
353
- category: t('导出'),
354
- label: { markdown: 'Markdown', docx: 'Word', pdf: 'PDF', html: 'HTML', png: t('图片') }[
355
- format
356
- ],
357
- keywords: format,
358
- available: hasDocument && !exportBusy.value,
359
- run: () => exportDocument(format),
360
- })),
361
- {
362
- id: 'workbench.print',
363
- category: t('文档'),
364
- get label() {
365
- return t('打印文档');
366
- },
367
- shortcut: shortcuts.value.print,
368
- available: hasDocument && !printBusy.value,
369
- run: printActiveDocument,
370
- },
371
- {
372
- id: 'workbench.find',
373
- category: t('编辑'),
374
- get label() {
375
- return t('页内搜索');
376
- },
377
- shortcut: shortcuts.value.pageSearch,
378
- available: standardEditor,
379
- run: () => openPaneSearch(),
380
- },
381
- {
382
- id: 'workbench.replace',
383
- category: t('编辑'),
384
- get label() {
385
- return t('查找与替换');
386
- },
387
- shortcut: shortcuts.value.pageReplace,
388
- available: editable,
389
- run: () => openPaneSearch(store.activePaneId, true),
390
- },
391
- {
392
- id: 'workbench.undo',
393
- category: t('编辑'),
394
- get label() {
395
- return t('撤销');
396
- },
397
- available: editable && documentUndoAvailable.value,
398
- run: undoDocument,
399
- },
400
- {
401
- id: 'workbench.redo',
402
- category: t('编辑'),
403
- get label() {
404
- return t('重做');
405
- },
406
- available: editable && documentRedoAvailable.value,
407
- run: redoDocument,
408
- },
409
- ...editorPaletteCommands({
410
- editable: editable && !!editor.value,
411
- source: source.value,
412
- context: paneSelections[store.activePaneId] ?? defaultSelectionContext,
413
- features: store.capabilities.features,
414
- run: (name, value) => editor.value?.command(name, value),
415
- }),
416
- {
417
- id: 'workbench.source',
418
- category: t('视图'),
419
- label: source.value ? t('返回可视化编辑') : t('切换源码模式'),
420
- shortcut: shortcuts.value.toggleSource,
421
- available: standardEditor,
422
- keywords: 'Markdown source',
423
- run: () => {
424
- source.value = !source.value;
425
- },
426
- },
427
- {
428
- id: 'workbench.markdown-reveal',
429
- category: t('视图'),
430
- get label() {
431
- return t('光标展开源码');
432
- },
433
- shortcut: shortcuts.value.toggleMarkdownReveal,
434
- available: standardEditor && !source.value,
435
- keywords: 'Markdown source cursor',
436
- run: () => {
437
- revealMarkdown.value = !revealMarkdown.value;
438
- },
439
- },
440
- {
441
- id: 'workbench.assistant',
442
- category: t('视图'),
443
- get label() {
444
- return t('打开或关闭同页助手');
445
- },
446
- shortcut: shortcuts.value.toggleAssistant,
447
- available: !!workspace.value && assistant.available,
448
- run: toggleAssistant,
449
- },
450
- {
451
- id: 'workbench.reading',
452
- category: t('视图'),
453
- label: pageLocked.value ? t('退出阅读模式') : t('进入阅读模式'),
454
- available: hasDocument && !workspaceLocked.value,
455
- keywords: t('锁定页面 解锁'),
456
- run: togglePageLock,
457
- },
458
- {
459
- id: 'workbench.width',
460
- category: t('视图'),
461
- label: limitPageWidth.value ? t('展开页面全宽') : t('限制页面宽度'),
462
- available: hasDocument && pageWidthWritable.value,
463
- run: () => setLimitPageWidth(!limitPageWidth.value),
464
- },
465
- {
466
- id: 'workbench.outline',
467
- category: t('视图'),
468
- label: showOutline.value ? t('隐藏文档目录') : t('显示文档目录'),
469
- available: hasDocument,
470
- keywords: t('大纲'),
471
- run: () => {
472
- showOutline.value = !showOutline.value;
473
- },
474
- },
475
- {
476
- id: 'workbench.properties',
477
- category: t('视图'),
478
- label: showDocumentProperties.value ? t('隐藏文档属性') : t('显示文档属性'),
479
- available: hasDocument,
480
- run: () => {
481
- showDocumentProperties.value = !showDocumentProperties.value;
482
- },
483
- },
484
- {
485
- id: 'workbench.discussion',
486
- category: t('文档'),
487
- get label() {
488
- return t('发起讨论');
489
- },
490
- keywords: t('文档讨论 评论'),
491
- available: editable,
492
- run: openDocumentDiscussion,
493
- },
494
- {
495
- id: 'workbench.sidebar',
496
- category: t('视图'),
497
- label: sidebar.value ? t('收起侧栏') : t('展开侧栏'),
498
- shortcut: shortcuts.value.toggleSidebar,
499
- available: !isAuxiliaryWindow,
500
- run: toggleSidebar,
501
- },
502
- {
503
- id: 'workbench.home',
504
- category: t('导航'),
505
- get label() {
506
- return t('切换到主页');
507
- },
508
- available: !isAuxiliaryWindow,
509
- run: () => {
510
- selectContext('home');
511
- sidebar.value = true;
512
- },
513
- },
514
- {
515
- id: 'workbench.switch-workspace',
516
- category: t('导航'),
517
- get label() {
518
- return t('切换工作区');
519
- },
520
- available: !isAuxiliaryWindow,
521
- run: () => {
522
- sidebar.value = true;
523
- toggleWorkspaceMenu();
524
- },
525
- },
526
- ...(extensions.commands ?? []),
527
- {
528
- id: 'workbench.repository',
529
- category: t('工作区'),
530
- get label() {
531
- return t('打开仓库');
532
- },
533
- available: !isAuxiliaryWindow,
534
- run: () => {
535
- sidebar.value = true;
536
- sidebarView.value = 'repository';
537
- },
538
- },
539
- {
540
- id: 'workbench.plan',
541
- category: t('工作区'),
542
- get label() {
543
- return t('打开计划');
544
- },
545
- available: !isAuxiliaryWindow && store.workspaceSettings.showPlan,
546
- run: () => {
547
- sidebar.value = true;
548
- selectModule('plan');
549
- },
550
- },
551
- {
552
- id: 'workbench.calendar',
553
- category: t('工作区'),
554
- get label() {
555
- return t('打开日历');
556
- },
557
- available: store.workspaceSettings.showPlan,
558
- run: () => openCalendar(),
559
- },
560
- {
561
- id: 'workbench.graph',
562
- category: t('工作区'),
563
- get label() {
564
- return t('打开关系图谱');
565
- },
566
- available: store.workspaceSettings.showGraph,
567
- run: () => store.openGraphTab(),
568
- },
569
- // Dev-only prototype; the native command is compiled out of release builds.
570
- {
571
- id: 'workbench.git',
572
- category: t('工作区'),
573
- label: 'Git 与同步',
574
- keywords: 'Git 状态 差异 提交 历史 同步',
575
- available: native && !mobile && !!workspace.value && !store.isWeb,
576
- run: () => openSystemSync(),
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,
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
- objectPanel,
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
- : selectionTodo.value
952
- ? () => {
953
- selectionTodo.value = undefined;
954
- }
955
- : layer
956
- ? () => {
957
- layer.value = false;
958
- }
959
- : compactPanes.value && sidebar.value
960
- ? () => {
961
- sidebar.value = false;
962
- }
963
- : assistant.opened
964
- ? () => {
965
- assistant.opened = false;
966
- }
967
- : canNavigatePage(-1)
968
- ? () => navigatePage(-1)
969
- : undefined;
970
- if (dismiss) {
971
- event.preventDefault();
972
- dismiss();
973
- }
974
- }
975
-
976
- async function mobileVisibility() {
977
- try {
978
- await handleMobileVisibility({
979
- mobile,
980
- hasWorkspace: !!workspace.value,
981
- visibilityState: document.visibilityState,
982
- flushWorkspace: () => store.flush(),
983
- flushEditing: () => editing.flush(),
984
- refreshWorkspace: () => store.refresh(),
985
- synchronize: () => extensions.refresh(),
986
- });
987
- } catch (reason) {
988
- store.report(reason);
989
- }
990
- }
991
-
992
- function outsideClick(event: MouseEvent) {
993
- const target = event.target as HTMLElement;
994
- if (!target.closest('.calendar-view-picker')) calendarModeOpen.value = false;
995
- if (!target.closest('.file-context-menu')) closeFileContextMenu();
996
- if (!target.closest('.directory-context-menu')) closeDirectoryContextMenu();
997
- if (!target.closest('.workspace-entry-context-menu')) closeWorkspaceEntryContextMenu();
998
- if (!target.closest('.page-context-menu')) closePageContextMenu();
999
- if (!target.closest('.outline-context-menu')) closeOutlineContextMenu();
1000
- if (!target.closest('.dropdown, .menu-wrap, .sidebar-bottom')) {
1001
- menu.value = false;
1002
- workspaceMenu.value = false;
1003
- }
1004
- }
1005
-
1006
- function dismissFileContextMenu() {
1007
- closeFileContextMenu();
1008
- }
1009
-
1010
- function outsideContextMenu(event: MouseEvent) {
1011
- if (!(event.target as HTMLElement).closest('.tree-row')) closeFileContextMenu();
1012
- if (!event.defaultPrevented && !(event.target as HTMLElement).closest('.directory-context-menu'))
1013
- closeDirectoryContextMenu();
1014
- if (
1015
- !event.defaultPrevented &&
1016
- !(event.target as HTMLElement).closest('.workspace-entry-context-menu')
1017
- )
1018
- closeWorkspaceEntryContextMenu();
1019
- if (!event.defaultPrevented) {
1020
- closePageContextMenu();
1021
- closeOutlineContextMenu();
1022
- }
1023
- }
1024
-
1025
- function dismissPageContextMenu() {
1026
- closePageContextMenu();
1027
- }
1028
-
1029
- function bindAuxiliaryEvents(context: WindowContext) {
1030
- const focus = () => {
1031
- activeWindow.value = context;
1032
- const paneId = store.windowLayouts[context.id]?.activePaneId;
1033
- if (paneId) store.focusPane(paneId);
1034
- };
1035
- const handlers: [string, EventListener, boolean][] = [
1036
- ['focus', focus, true],
1037
- ['pointerdown', focus, true],
1038
- ['keydown', routeConfiguredEditorShortcut as EventListener, true],
1039
- ['keydown', handleWorkbenchShortcut as EventListener, true],
1040
- ['keydown', handlePageSearchShortcut as EventListener, true],
1041
- ['keydown', keydown as EventListener, false],
1042
- ['click', outsideClick as EventListener, false],
1043
- ['contextmenu', outsideContextMenu as EventListener, false],
1044
- ['scroll', dismissPageContextMenu, true],
1045
- ['scroll', closeOutlineContextMenu, true],
1046
- ['resize', dismissPageContextMenu, false],
1047
- ['resize', closeOutlineContextMenu, false],
1048
- ];
1049
- for (const [name, handler, capture] of handlers)
1050
- context.window.addEventListener(name, handler, capture);
1051
- const stopMotion = installInteractionMotion(context.document);
1052
- return () => {
1053
- for (const [name, handler, capture] of handlers)
1054
- context.window.removeEventListener(name, handler, capture);
1055
- stopMotion();
1056
- if (activeWindow.value === context) activeWindow.value = mainWindow;
1057
- };
1058
- }
1059
-
1060
- const auxiliaryEventDisposers = new Map<string, () => void>();
1061
- watch(
1062
- () => [...auxiliaryWindows.entries.values()],
1063
- (entries) => {
1064
- for (const [id, dispose] of auxiliaryEventDisposers) {
1065
- if (!entries.some((entry) => entry.id === id)) {
1066
- dispose();
1067
- auxiliaryEventDisposers.delete(id);
1068
- }
1069
- }
1070
- for (const entry of entries) {
1071
- if (!auxiliaryEventDisposers.has(entry.id))
1072
- auxiliaryEventDisposers.set(entry.id, bindAuxiliaryEvents(entry.context));
1073
- }
1074
- },
1075
- { flush: 'sync' },
1076
- );
1077
-
1078
- const focusMain = () => {
1079
- activeWindow.value = mainWindow;
1080
- const paneId = store.windowLayouts.main.activePaneId;
1081
- if (paneId) store.focusPane(paneId);
1082
- };
1083
- window.addEventListener('focus', focusMain);
1084
- window.addEventListener('pointerdown', focusMain, true);
1085
-
1086
- onMounted(() => {
1087
- window.addEventListener('keydown', handleWorkbenchShortcut, true);
1088
- window.addEventListener('keydown', keydown);
1089
- window.addEventListener('keydown', handlePageSearchShortcut, true);
1090
- window.addEventListener('beforeunload', beforeUnload);
1091
- window.addEventListener('click', outsideClick);
1092
- window.addEventListener('contextmenu', outsideContextMenu);
1093
- window.addEventListener('scroll', dismissFileContextMenu, true);
1094
- window.addEventListener('scroll', closeDirectoryContextMenu, true);
1095
- window.addEventListener('scroll', dismissPageContextMenu, true);
1096
- window.addEventListener('scroll', closeOutlineContextMenu, true);
1097
- window.addEventListener('resize', dismissFileContextMenu);
1098
- window.addEventListener('resize', closeDirectoryContextMenu);
1099
- window.addEventListener('resize', dismissPageContextMenu);
1100
- window.addEventListener('resize', closeOutlineContextMenu);
1101
- if (!isAuxiliaryWindow) window.addEventListener('resize', constrainSidebarToViewport);
1102
- document.addEventListener('visibilitychange', mobileVisibility);
1103
- window.addEventListener('tano:back', mobileBack);
1104
- });
1105
-
1106
- onBeforeUnmount(() => {
1107
- window.removeEventListener('focus', focusMain);
1108
- window.removeEventListener('pointerdown', focusMain, true);
1109
- for (const dispose of auxiliaryEventDisposers.values()) dispose();
1110
- auxiliaryEventDisposers.clear();
1111
- window.removeEventListener('keydown', handleWorkbenchShortcut, true);
1112
- window.removeEventListener('keydown', keydown);
1113
- window.removeEventListener('keydown', handlePageSearchShortcut, true);
1114
- window.removeEventListener('beforeunload', beforeUnload);
1115
- window.removeEventListener('click', outsideClick);
1116
- window.removeEventListener('contextmenu', outsideContextMenu);
1117
- window.removeEventListener('scroll', dismissFileContextMenu, true);
1118
- window.removeEventListener('scroll', closeDirectoryContextMenu, true);
1119
- window.removeEventListener('scroll', dismissPageContextMenu, true);
1120
- window.removeEventListener('scroll', closeOutlineContextMenu, true);
1121
- window.removeEventListener('resize', dismissFileContextMenu);
1122
- window.removeEventListener('resize', closeDirectoryContextMenu);
1123
- window.removeEventListener('resize', dismissPageContextMenu);
1124
- window.removeEventListener('resize', closeOutlineContextMenu);
1125
- window.removeEventListener('resize', constrainSidebarToViewport);
1126
- document.removeEventListener('visibilitychange', mobileVisibility);
1127
- 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,
1128
147
  });
1129
148
 
1130
149
  return {