@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
@@ -0,0 +1,325 @@
1
+ import { computed, ref, watch, type Ref } from 'vue';
2
+ import { Bot, Mail, Settings2 } from 'lucide-vue-next';
3
+ import { ASSISTANT_TAB_ID } from '../assistant/navigation';
4
+ import { GRAPH_TAB_ID } from '../documents/document-graph';
5
+ import { isFeatureEnabled } from '../features';
6
+ import type { AttachmentService } from '../files/attachments';
7
+ import { t } from '../i18n/i18n';
8
+ import { MAIL_TAB_ID } from '../mail/types';
9
+ import { CALENDAR_TAB_ID } from '../plans/calendar';
10
+ import { mobile } from '../platform/platform';
11
+ import type { WorkbenchExtensions, WorkbenchViewTab } from '../runtime';
12
+ import { SETTINGS_TAB_ID } from '../settings/settings-tab';
13
+ import type { SettingsPageId } from '../settings/settings-window';
14
+ import {
15
+ resolvePluginSidebar,
16
+ useWorkbenchNavigation,
17
+ type WorkspaceSidebarView,
18
+ } from '../shell/workbench-navigation';
19
+ import type { usePlanStore } from '../stores/plans';
20
+ import type { useWorkspaceStore } from '../stores/workspace';
21
+ import { native } from '../workspace/adapter';
22
+ import { useWorkbenchCalendar } from './use-workbench-calendar';
23
+
24
+ export interface WorkbenchViewsDeps {
25
+ store: ReturnType<typeof useWorkspaceStore>;
26
+ plans: ReturnType<typeof usePlanStore>;
27
+ extensions: WorkbenchExtensions;
28
+ attachments?: AttachmentService;
29
+ isAuxiliaryWindow: boolean;
30
+ compactPanes: Ref<boolean>;
31
+ sidebar: Ref<boolean>;
32
+ workspaceMenu: Ref<boolean>;
33
+ openSettings: (page?: SettingsPageId) => void;
34
+ }
35
+
36
+ export function useWorkbenchViews(deps: WorkbenchViewsDeps) {
37
+ const {
38
+ store,
39
+ plans,
40
+ extensions,
41
+ attachments,
42
+ isAuxiliaryWindow,
43
+ compactPanes,
44
+ sidebar,
45
+ workspaceMenu,
46
+ openSettings,
47
+ } = deps;
48
+
49
+ const extensionViews = extensions.views ?? [];
50
+ const settingsTabView: WorkbenchViewTab = {
51
+ id: SETTINGS_TAB_ID,
52
+ get label() {
53
+ return t('设置');
54
+ },
55
+ icon: Settings2,
56
+ scope: 'account',
57
+ detachable: true,
58
+ };
59
+ const mailEnabled = isFeatureEnabled('desktopMailClient') && native && !mobile;
60
+ const mailTabView: WorkbenchViewTab = {
61
+ id: MAIL_TAB_ID,
62
+ get label() {
63
+ return t('邮箱');
64
+ },
65
+ icon: Mail,
66
+ scope: 'account',
67
+ detachable: false,
68
+ };
69
+
70
+ store.registerViews([
71
+ ...extensionViews,
72
+ settingsTabView,
73
+ ...(mailEnabled ? [mailTabView] : []),
74
+ { id: ASSISTANT_TAB_ID, label: t('助手'), icon: Bot },
75
+ ]);
76
+
77
+ const activeExtensionView = computed(() =>
78
+ extensionViews.find((view) => view.id === store.activeId),
79
+ );
80
+ watch(
81
+ activeExtensionView,
82
+ (view) => {
83
+ if (view?.collapseSidebarOnOpen) sidebar.value = false;
84
+ },
85
+ { immediate: true },
86
+ );
87
+
88
+ const navigation = useWorkbenchNavigation(
89
+ () => store.workspace?.id,
90
+ isAuxiliaryWindow
91
+ ? undefined
92
+ : {
93
+ getItem: (key) => localStorage.getItem(key),
94
+ setItem: (key, value) => localStorage.setItem(key, value),
95
+ },
96
+ );
97
+ const { context: navigationContext, module: navigationModule, workspaceView, sidebarView } =
98
+ navigation;
99
+ let personalPlanScope: typeof plans.view = 'all';
100
+
101
+ watch(
102
+ [navigationContext, navigationModule],
103
+ ([context, module]) => {
104
+ if (context === 'workspace' && module === 'plan') navigation.selectWorkspaceView('events');
105
+ },
106
+ { immediate: true },
107
+ );
108
+
109
+ const homeContent = ref<string>();
110
+ const homeExtension = computed(() =>
111
+ extensionViews.find((view) => view.id === homeContent.value),
112
+ );
113
+
114
+ const calendar = useWorkbenchCalendar({
115
+ store,
116
+ plans,
117
+ navigationContext,
118
+ navigationModule,
119
+ sidebarView,
120
+ homeContent,
121
+ compactPanes,
122
+ sidebar,
123
+ selectModule: (id) => selectModule(id),
124
+ });
125
+
126
+ function selectContext(context: 'home' | 'workspace') {
127
+ calendar.rememberCalendar();
128
+ if (navigationContext.value === 'home') personalPlanScope = plans.view;
129
+ navigation.selectContext(context);
130
+ plans.view = navigationContext.value === 'home' ? personalPlanScope : 'workspace';
131
+ calendar.restoreCalendar();
132
+ workspaceMenu.value = false;
133
+ }
134
+ watch(navigationContext, (context) => {
135
+ plans.view = context === 'home' ? personalPlanScope : 'workspace';
136
+ });
137
+
138
+ function selectWorkspaceView(id: string) {
139
+ calendar.rememberCalendar();
140
+ if (navigationContext.value === 'home') personalPlanScope = plans.view;
141
+ navigation.selectWorkspaceView(id as WorkspaceSidebarView);
142
+ calendar.restoreCalendar();
143
+ if (id === 'events') plans.view = 'workspace';
144
+ }
145
+
146
+ function selectModule(id: string) {
147
+ calendar.rememberCalendar();
148
+ if (navigationContext.value === 'home') personalPlanScope = plans.view;
149
+ if (id === 'plan' && navigationContext.value === 'workspace')
150
+ navigation.selectWorkspaceView('events');
151
+ else navigation.selectModule(id);
152
+ calendar.restoreCalendar();
153
+ plans.view = navigationContext.value === 'home' ? personalPlanScope : 'workspace';
154
+ sidebar.value = true;
155
+ }
156
+
157
+ watch(
158
+ () => store.activePluginSidebar,
159
+ (key) => {
160
+ if (key) {
161
+ sidebarView.value = `plugin-sidebar:${key}`;
162
+ sidebar.value = true;
163
+ }
164
+ },
165
+ );
166
+ watch(
167
+ [
168
+ () => store.workspaceLoading.plugins || store.installedPluginWorkspace !== store.workspace?.id,
169
+ () => store.pluginViews,
170
+ sidebarView,
171
+ ],
172
+ ([loading, views, current]) => {
173
+ const resolved = resolvePluginSidebar(current, loading, views);
174
+ if (resolved !== current) sidebarView.value = resolved;
175
+ },
176
+ );
177
+ watch(sidebarView, (current) => {
178
+ if (store.activePluginSidebar && current !== `plugin-sidebar:${store.activePluginSidebar}`)
179
+ store.activePluginSidebar = '';
180
+ });
181
+ watch(
182
+ () => store.pluginSettingsRequest,
183
+ (request) => {
184
+ if (request) openSettings(request.key);
185
+ },
186
+ );
187
+
188
+ function openExtensionView(id: string) {
189
+ if (navigationContext.value === 'home') personalPlanScope = plans.view;
190
+ calendar.rememberCalendar();
191
+ if (extensionViews.find((view) => view.id === id)?.sidebar) navigation.openInHome(id);
192
+ else navigation.selectContext('home');
193
+ calendar.restoreCalendar();
194
+ if (!store.workspace) homeContent.value = id;
195
+ else store.openViewTab(id);
196
+ if (compactPanes.value) sidebar.value = false;
197
+ }
198
+
199
+ const viewActions = Object.fromEntries(
200
+ extensionViews.map((view) => [
201
+ view.id,
202
+ {
203
+ open: () => {
204
+ openExtensionView(view.id);
205
+ if (compactPanes.value) sidebar.value = false;
206
+ },
207
+ showSidebar: () => {
208
+ selectModule(view.id);
209
+ sidebar.value = true;
210
+ },
211
+ },
212
+ ]),
213
+ );
214
+
215
+ function openMail() {
216
+ if (!mailEnabled) return;
217
+ if (navigationContext.value === 'home') personalPlanScope = plans.view;
218
+ calendar.rememberCalendar();
219
+ navigation.openInHome(MAIL_TAB_ID);
220
+ calendar.restoreCalendar();
221
+ if (!store.workspace) homeContent.value = MAIL_TAB_ID;
222
+ else store.openViewTab(MAIL_TAB_ID);
223
+ if (compactPanes.value) sidebar.value = false;
224
+ }
225
+ watch(
226
+ () => navigation.homeModule.value,
227
+ (mod) => {
228
+ if (!mailEnabled && mod === MAIL_TAB_ID) navigation.homeModule.value = 'plan';
229
+ },
230
+ { immediate: true },
231
+ );
232
+
233
+ const sidebarNavigationItems = computed(() => [
234
+ { id: 'plan', get label() { return t('计划'); } },
235
+ ...(mailEnabled ? [{ id: MAIL_TAB_ID, get label() { return t('邮箱'); } }] : []),
236
+ ...extensionViews
237
+ .filter((view) => view.sidebar)
238
+ .map((view) => ({ id: view.id, label: view.label })),
239
+ ]);
240
+
241
+ const sidebarHeaderItems = computed(() => [
242
+ ...(navigationModule.value === 'workspace'
243
+ ? [
244
+ { id: 'search', get label() { return t('查找文档'); } },
245
+ ...(store.workspaceSettings.showGraph
246
+ ? [{ id: 'graph', get label() { return t('关系图谱'); } }]
247
+ : []),
248
+ ]
249
+ : []),
250
+ ...extensionViews
251
+ .filter((view) => view.header)
252
+ .map((view) => ({ id: view.id, label: view.label })),
253
+ ]);
254
+
255
+ const repositoryActionItems = computed(() => [
256
+ { id: 'create', get label() { return t('新建文档'); } },
257
+ { id: 'folder', get label() { return t('新建文件夹'); } },
258
+ ]);
259
+
260
+ const documentToolItems = [
261
+ { id: 'markdown-reveal', get label() { return t('光标展开源码'); } },
262
+ { id: 'source-mode', get label() { return t('源码模式'); } },
263
+ ];
264
+
265
+ const topbarItems = [{ id: 'breadcrumb', get label() { return t('面包屑'); } }];
266
+
267
+ const calendarToolItems = [
268
+ { id: 'calendar-period', get label() { return t('日历日期'); } },
269
+ { id: 'calendar-today', get label() { return t('今天'); } },
270
+ { id: 'calendar-previous', get label() { return t('上一时段'); } },
271
+ { id: 'calendar-next', get label() { return t('下一时段'); } },
272
+ { id: 'calendar-mode', get label() { return t('日历视图'); } },
273
+ { id: 'calendar-events', get label() { return t('已归档事项'); } },
274
+ ];
275
+
276
+ function topbarVisibilityItems(tabId: string, hasDocument: boolean, activePane: boolean) {
277
+ return [
278
+ ...topbarItems.filter(
279
+ (item) => item.id !== 'breadcrumb' || (tabId !== CALENDAR_TAB_ID && tabId !== GRAPH_TAB_ID),
280
+ ),
281
+ ...(hasDocument || tabId.startsWith('attachment:')
282
+ ? [{ id: 'document-status', get label() { return t('文章状态'); } }]
283
+ : []),
284
+ ...(activePane && extensions.regions['editing-status']
285
+ ? [{ id: 'editing-status', get label() { return t('同步状态'); } }]
286
+ : []),
287
+ ...(tabId === CALENDAR_TAB_ID ? calendarToolItems : []),
288
+ ...(tabId.startsWith('attachment:') && attachments
289
+ ? [{ id: 'attachment-export', get label() { return t('导出附件'); } }]
290
+ : []),
291
+ ...(hasDocument ? documentToolItems : []),
292
+ ].map((item, index, items) => ({
293
+ ...item,
294
+ separatorBefore: items[index - 1]?.id === 'document-status',
295
+ }));
296
+ }
297
+
298
+ return {
299
+ extensionViews,
300
+ settingsTabView,
301
+ mailEnabled,
302
+ mailTabView,
303
+ activeExtensionView,
304
+ navigation,
305
+ navigationContext,
306
+ navigationModule,
307
+ workspaceView,
308
+ sidebarView,
309
+ getPersonalPlanScope: () => personalPlanScope,
310
+ homeContent,
311
+ homeExtension,
312
+ calendar,
313
+ selectContext,
314
+ selectWorkspaceView,
315
+ selectModule,
316
+ viewActions,
317
+ openMail,
318
+ sidebarNavigationItems,
319
+ sidebarHeaderItems,
320
+ repositoryActionItems,
321
+ documentToolItems,
322
+ calendarToolItems,
323
+ topbarVisibilityItems,
324
+ };
325
+ }
@@ -10,14 +10,13 @@ import type {
10
10
  DataValue,
11
11
  DataView,
12
12
  } from '@tano/protocol';
13
- export const TABLES_TAB_ID = 'tables';
14
13
  export const tableTabId = (id: string) => `table:${id}`;
15
14
  // A table may be opened more than once from the file context menu. Keep the
16
15
  // file id at the start of the tab id so routes and persisted table state still
17
16
  // resolve to the same table, while the optional suffix gives each tab its own
18
17
  // identity.
19
18
  export const tableFileId = (id: string) => id.slice(6).split(':', 1)[0] ?? '';
20
- export const isTableTab = (id: string) => id === TABLES_TAB_ID || /^table:[0-9a-f]{6}(?::[a-z0-9-]+)?$/.test(id);
19
+ export const isTableTab = (id: string) => /^table:[0-9a-f]{6}(?::[a-z0-9-]+)?$/.test(id);
21
20
  export const tableItemId = () => crypto.randomUUID().replaceAll('-', '');
22
21
  export const copyTable = <T>(value: T): T => JSON.parse(JSON.stringify(value));
23
22
  export function newDataView(name = '全部记录'): DataView {
@@ -0,0 +1,279 @@
1
+ <script setup lang="ts">
2
+ import { inject, toRefs } from 'vue';
3
+ import {
4
+ Archive,
5
+ CheckCheck,
6
+ Clock3,
7
+ GitFork,
8
+ LockKeyhole,
9
+ MessageSquare,
10
+ MessageSquareDiff,
11
+ MoreHorizontal,
12
+ MoveHorizontal,
13
+ Plus,
14
+ Redo2,
15
+ Repeat2,
16
+ Search,
17
+ Trash2,
18
+ Undo2,
19
+ } from 'lucide-vue-next';
20
+ import ShortcutHint from '@tano/editor/shortcut-hint';
21
+ import { vSurfaceMotion } from '@tano/editor/surface-motion';
22
+ import { t } from '../../i18n/i18n';
23
+ import type { OpenDocument } from '../../stores/workspace-types';
24
+ import {
25
+ workbenchDocumentsKey,
26
+ workbenchModalsKey,
27
+ workbenchPrefsKey,
28
+ workbenchShellKey,
29
+ } from '../../shell/workbench-context';
30
+ import DocumentExportMenu from './DocumentExportMenu.vue';
31
+ import DocumentGlobalMenu from './DocumentGlobalMenu.vue';
32
+ import DocumentPrintButton from './DocumentPrintButton.vue';
33
+ import PageDisplayOptions from '../../shell/components/PageDisplayOptions.vue';
34
+ import PluginMenu from '../../plugins/components/PluginMenu.vue';
35
+
36
+ defineProps<{
37
+ paneId: string;
38
+ paneActiveId: string;
39
+ active: OpenDocument;
40
+ isAuxiliaryWindow: boolean;
41
+ }>();
42
+
43
+ const shell = inject(workbenchShellKey);
44
+ const prefs = inject(workbenchPrefsKey);
45
+ const documents = inject(workbenchDocumentsKey);
46
+ const modals = inject(workbenchModalsKey);
47
+ if (!shell || !prefs || !documents || !modals) throw new Error('Workbench context is required');
48
+
49
+ const { workspace, store, extensions, paneButterflyScope, vButterflyPerch } = toRefs(shell);
50
+ const {
51
+ shortcuts,
52
+ shortcutHint,
53
+ limitPageWidth,
54
+ pageWidthWritable,
55
+ setLimitPageWidth,
56
+ workspaceLocked,
57
+ pageLocked,
58
+ togglePageLock,
59
+ editorPreferences,
60
+ showPageTitle,
61
+ showDocumentProperties,
62
+ showAllLineNumbers,
63
+ toggleWorkspaceLock,
64
+ } = toRefs(prefs);
65
+ const {
66
+ menu,
67
+ setDocumentMenuElement,
68
+ toggleDocumentMenu,
69
+ documentMenuTriggerKeydown,
70
+ documentMenuKeydown,
71
+ openPaneSearch,
72
+ editorReadonly,
73
+ documentUndoAvailable,
74
+ documentRedoAvailable,
75
+ undoDocument,
76
+ redoDocument,
77
+ canAddDocumentProperty,
78
+ addDocumentProperty,
79
+ editing,
80
+ paneComments,
81
+ openDocumentDiscussion,
82
+ suggestionModeBusy,
83
+ documentSuggestions,
84
+ paneReadonly,
85
+ toggleSuggestionMode,
86
+ referenceGraphOpened,
87
+ showReferenceGraph,
88
+ showOutline,
89
+ paneSource,
90
+ togglePageOption,
91
+ exportBusy,
92
+ exportDocument,
93
+ printBusy,
94
+ printActiveDocument,
95
+ sessionBlocksFileMutation,
96
+ } = toRefs(documents);
97
+ const { historyPage, historyPanel, removeDocument } = toRefs(modals);
98
+ </script>
99
+
100
+ <template>
101
+ <div class="menu-wrap">
102
+ <button
103
+ class="icon-button"
104
+ :aria-label="t('文档操作')"
105
+ v-butterfly-perch="{
106
+ id: `document-actions:${paneButterflyScope(paneId, paneActiveId)}`,
107
+ scope: paneButterflyScope(paneId, paneActiveId),
108
+ label: t('文档操作按钮'),
109
+ kind: 'component',
110
+ }"
111
+ :aria-expanded="menu && paneId === store.activePaneId"
112
+ @click="toggleDocumentMenu"
113
+ @keydown="documentMenuTriggerKeydown"
114
+ >
115
+ <MoreHorizontal :size="19" />
116
+ </button>
117
+ <div
118
+ v-surface-motion="'App:5'"
119
+ v-if="menu && paneId === store.activePaneId"
120
+ :ref="setDocumentMenuElement"
121
+ class="dropdown compact-action-menu document-dropdown"
122
+ data-surface-role="popover"
123
+ @keydown="documentMenuKeydown"
124
+ >
125
+ <PluginMenu location="document" :file-id="active.id" @selected="menu = false" />
126
+ <button type="button" @click="openPaneSearch(paneId)">
127
+ <Search :size="15" />{{ t('页内搜索') }}<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('pageSearch')" /></span>
128
+ </button>
129
+ <button type="button" @click="openPaneSearch(paneId, true)">
130
+ <Repeat2 :size="15" />{{ t('查找与替换') }}<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('pageReplace')" /></span>
131
+ </button>
132
+ <button
133
+ type="button"
134
+ :disabled="editorReadonly || !documentUndoAvailable"
135
+ @click="undoDocument"
136
+ >
137
+ <Undo2 :size="15" />{{ t('撤销') }}<kbd class="menu-shortcut" aria-hidden="true"><ShortcutHint :label="shortcutHint('undo')" /></kbd>
138
+ </button>
139
+ <button
140
+ type="button"
141
+ :disabled="editorReadonly || !documentRedoAvailable"
142
+ @click="redoDocument"
143
+ >
144
+ <Redo2 :size="15" />{{ t('重做') }}<kbd class="menu-shortcut" aria-hidden="true"><ShortcutHint :label="shortcutHint('redo')" /></kbd>
145
+ </button>
146
+ <button
147
+ @click="
148
+ menu = false;
149
+ store.flush();
150
+ "
151
+ >
152
+ <CheckCheck :size="15" />{{ t('立即保存') }}<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('save')" /></span>
153
+ </button>
154
+ <div class="menu-divider" role="separator" />
155
+ <button type="button" :disabled="!canAddDocumentProperty" @click="addDocumentProperty">
156
+ <Plus :size="15" />{{ t('添加文档属性') }}
157
+ </button>
158
+ <button
159
+ type="button"
160
+ :disabled="editorReadonly || !!editing.active || editing.activeBusy || !paneComments.has(store.activePaneId)"
161
+ @click="openDocumentDiscussion"
162
+ >
163
+ <MessageSquare :size="15" />{{ t('发起讨论') }}
164
+ </button>
165
+ <button
166
+ type="button"
167
+ :disabled="
168
+ suggestionModeBusy ||
169
+ (!documentSuggestions.get(active.id)?.mode &&
170
+ (paneReadonly(active) || editing.isManaging(active.id) || editing.activeBusy)) ||
171
+ documentSuggestions.get(active.id)?.loading ||
172
+ documentSuggestions.get(active.id)?.reviewing
173
+ "
174
+ @click="toggleSuggestionMode(active.id)"
175
+ >
176
+ <MessageSquareDiff :size="15" />{{
177
+ documentSuggestions.get(active.id)?.mode ? t('退出建议模式') : t('建议编辑')
178
+ }}
179
+ </button>
180
+ <div class="menu-divider" role="separator" />
181
+ <button
182
+ type="button"
183
+ aria-haspopup="dialog"
184
+ :aria-expanded="referenceGraphOpened"
185
+ @click="showReferenceGraph(paneId, active)"
186
+ >
187
+ <GitFork :size="15" />{{ t('查看关系图谱') }}
188
+ </button>
189
+ <button
190
+ type="button"
191
+ class="page-toggle-menu-item"
192
+ role="switch"
193
+ :aria-checked="!limitPageWidth"
194
+ :aria-busy="store.capabilitySaving || undefined"
195
+ :disabled="!pageWidthWritable"
196
+ :data-tooltip="t('切换页面内容宽度')"
197
+ @click="setLimitPageWidth(!limitPageWidth)"
198
+ >
199
+ <MoveHorizontal :size="15" />{{ t('全宽') }}<span
200
+ class="menu-switch"
201
+ :class="{ on: !limitPageWidth }"
202
+ aria-hidden="true"
203
+ ><span
204
+ /></span>
205
+ </button>
206
+ <button
207
+ type="button"
208
+ class="page-toggle-menu-item"
209
+ role="switch"
210
+ :aria-checked="workspaceLocked || pageLocked"
211
+ :disabled="workspaceLocked"
212
+ :data-tooltip="workspaceLocked ? t('请先关闭工作区锁定,再修改页面锁定') : pageLocked ? t('退出阅读模式') : t('锁定后进入阅读模式')"
213
+ @click="togglePageLock"
214
+ >
215
+ <LockKeyhole :size="15" />{{ t('锁定页面') }}<span
216
+ class="menu-switch"
217
+ :class="{ on: workspaceLocked || pageLocked }"
218
+ aria-hidden="true"
219
+ ><span
220
+ /></span>
221
+ </button>
222
+ <div class="menu-divider" role="separator" />
223
+ <button
224
+ v-if="extensions.historyEnabled && extensions.historyView"
225
+ @click="
226
+ menu = false;
227
+ historyPage = 'versions';
228
+ historyPanel = true;
229
+ "
230
+ >
231
+ <Archive :size="15" />{{ t('版本历史') }}<span class="menu-beta">Beta</span>
232
+ </button>
233
+ <button
234
+ @click="
235
+ menu = false;
236
+ historyPage = 'updates';
237
+ historyPanel = true;
238
+ "
239
+ >
240
+ <Clock3 :size="15" />{{ t('更新历史') }}
241
+ </button>
242
+ <DocumentGlobalMenu>
243
+ <PageDisplayOptions
244
+ :workspace-locked="workspaceLocked"
245
+ :workspace-available="!!workspace"
246
+ :auto-spacing="editorPreferences.autoSpacing ?? false"
247
+ :show-page-title="showPageTitle"
248
+ :show-document-properties="showDocumentProperties"
249
+ :show-outline="showOutline"
250
+ :show-all-line-numbers="showAllLineNumbers"
251
+ :auxiliary-window="isAuxiliaryWindow"
252
+ :source="paneSource(store.activeId)"
253
+ @toggle="togglePageOption"
254
+ @toggle-workspace-lock="toggleWorkspaceLock"
255
+ />
256
+ </DocumentGlobalMenu>
257
+ <DocumentExportMenu :disabled="exportBusy" @select="exportDocument" />
258
+ <DocumentPrintButton :busy="printBusy" :shortcut="shortcuts.print" @select="printActiveDocument" />
259
+ <div class="menu-divider" role="separator" />
260
+ <button
261
+ class="danger-text"
262
+ :disabled="
263
+ editorReadonly ||
264
+ sessionBlocksFileMutation(paneActiveId) ||
265
+ (paneId === store.activePaneId && editing.activeBusy)
266
+ "
267
+ @click="removeDocument()"
268
+ >
269
+ <Trash2 :size="15" />{{
270
+ store.isDemo
271
+ ? t('删除演示文档')
272
+ : store.isWeb
273
+ ? t('删除在线文档')
274
+ : t('移入回收站')
275
+ }}
276
+ </button>
277
+ </div>
278
+ </div>
279
+ </template>
@@ -36,7 +36,7 @@ const emit = defineEmits<{
36
36
  close: [];
37
37
  diff: [value: { title: string; before: string; after: string }];
38
38
  }>();
39
- const page = ref<Page>(props.initialPage ?? 'versions');
39
+ const page = ref<Page>(props.historyView ? (props.initialPage ?? 'versions') : 'updates');
40
40
  const firstNav = ref<HTMLButtonElement>();
41
41
  const originalFocus = document.activeElement as HTMLElement | null;
42
42
 
@@ -84,6 +84,7 @@ onBeforeUnmount(() => originalFocus?.focus());
84
84
  </div>
85
85
  <nav>
86
86
  <button
87
+ v-if="historyView"
87
88
  ref="firstNav"
88
89
  :class="{ active: page === 'versions' }"
89
90
  :aria-current="page === 'versions' ? 'page' : undefined"
@@ -94,6 +95,7 @@ onBeforeUnmount(() => originalFocus?.focus());
94
95
  <small>Beta</small>
95
96
  </button>
96
97
  <button
98
+ :ref="(el) => { if (!historyView) firstNav = (el as HTMLButtonElement | null) ?? undefined; }"
97
99
  :class="{ active: page === 'updates' }"
98
100
  :aria-current="page === 'updates' ? 'page' : undefined"
99
101
  @click="page = 'updates'"