@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.
Files changed (118) hide show
  1. package/package.json +35 -14
  2. package/src/App.vue +68 -797
  3. package/src/assistant/agent-identities.ts +1 -97
  4. package/src/assistant/agent-task-context.ts +1 -54
  5. package/src/assistant/attachments.ts +1 -1
  6. package/src/assistant/completion.ts +1 -61
  7. package/src/assistant/components/AssistantPanel.vue +1 -1
  8. package/src/assistant/connection-actions.ts +237 -0
  9. package/src/assistant/document-mentions.ts +1 -33
  10. package/src/assistant/engine.ts +1 -585
  11. package/src/assistant/execution.ts +6 -33
  12. package/src/assistant/hash.ts +1 -4
  13. package/src/assistant/language.ts +10 -37
  14. package/src/assistant/plugin-bridge-builder.ts +146 -0
  15. package/src/assistant/prompts.ts +1 -65
  16. package/src/assistant/proposal-actions.ts +336 -0
  17. package/src/assistant/store.ts +87 -554
  18. package/src/assistant/structures.ts +1 -157
  19. package/src/assistant/tasks.ts +8 -94
  20. package/src/assistant/tool-rules.ts +1 -7
  21. package/src/composables/use-workbench-help.ts +177 -0
  22. package/src/composables/use-workbench-lifecycle.ts +249 -0
  23. package/src/composables/use-workbench-settings.ts +185 -0
  24. package/src/composables/use-workbench-shortcuts.ts +37 -1022
  25. package/src/composables/use-workbench-views.ts +325 -0
  26. package/src/documents/components/DocumentActionMenu.vue +279 -0
  27. package/src/documents/components/DocumentInspector.vue +168 -0
  28. package/src/documents/components/DocumentPane.vue +482 -0
  29. package/src/documents/description-merge.ts +1 -9
  30. package/src/files/components/FileMetadataPanel.vue +49 -15
  31. package/src/i18n/locale-catalogs.ts +7 -6
  32. package/src/i18n/locale-registry.ts +8 -6
  33. package/src/i18n/locales/de-DE.json +23 -1
  34. package/src/i18n/locales/en-US.json +23 -1
  35. package/src/i18n/locales/es-ES.json +23 -1
  36. package/src/i18n/locales/ja-JP.json +23 -1
  37. package/src/i18n/locales/zh-TW.json +23 -1
  38. package/src/mail/components/MailAccountDialog.vue +1 -0
  39. package/src/mail/components/MailComposerDialog.vue +1 -0
  40. package/src/mail/components/MailWorkspaceView.vue +1 -0
  41. package/src/mail/components/SidebarMail.vue +1 -0
  42. package/src/objects/content-references.ts +6 -56
  43. package/src/objects/wiki-links.ts +1 -48
  44. package/src/objects/workspace-objects.ts +2 -3
  45. package/src/plans/calendar.ts +2 -2
  46. package/src/plans/components/CalendarAgendaView.vue +165 -0
  47. package/src/plans/components/CalendarFilterBar.vue +128 -0
  48. package/src/plans/components/CalendarMonthView.vue +224 -0
  49. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  50. package/src/plans/components/CalendarTimelineView.vue +517 -0
  51. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  52. package/src/plans/components/CalendarView.vue +162 -2106
  53. package/src/plans/components/CalendarYearView.vue +138 -0
  54. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  55. package/src/plans/components/calendar-shared.css +192 -0
  56. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  57. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  58. package/src/plugins/components/PluginDetailPage.vue +10 -6
  59. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  60. package/src/plugins/components/PluginExplorer.vue +6 -4
  61. package/src/plugins/components/PluginImportDialog.vue +1 -1
  62. package/src/plugins/components/PluginInstaller.vue +269 -178
  63. package/src/plugins/components/PluginMaintenance.vue +37 -49
  64. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  65. package/src/plugins/components/PluginSettingsForm.vue +2 -1
  66. package/src/plugins/components/PluginsTabPage.vue +61 -0
  67. package/src/plugins/components/plugin-center.css +5 -0
  68. package/src/plugins/data.ts +9 -86
  69. package/src/plugins/editor-plugin-adapters.ts +169 -0
  70. package/src/plugins/plugin-data.ts +2 -3
  71. package/src/plugins/plugin-rpc-router.ts +558 -0
  72. package/src/plugins/plugin-sdk.ts +1 -260
  73. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  74. package/src/plugins/queries.ts +1 -75
  75. package/src/plugins/view-header.ts +2 -7
  76. package/src/runtime.ts +3 -2
  77. package/src/settings/components/SettingsPanel.vue +8 -3
  78. package/src/settings/components/WorkbenchSettings.vue +20 -7
  79. package/src/settings/components/settings-context.ts +1 -1
  80. package/src/settings/settings-tab.ts +1 -0
  81. package/src/shell/command-palette.ts +3 -3
  82. package/src/shell/components/EditorToolbar.vue +8 -9
  83. package/src/shell/components/EditorTools.vue +1 -5
  84. package/src/shell/components/PaneTopbar.vue +393 -0
  85. package/src/shell/components/SelectionToolbar.vue +0 -2
  86. package/src/shell/components/WorkbenchContextMenus.vue +37 -26
  87. package/src/shell/components/WorkbenchModals.vue +22 -18
  88. package/src/shell/components/WorkbenchPanes.vue +358 -1512
  89. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  90. package/src/shell/pane-registry.ts +69 -0
  91. package/src/shell/use-surface-dismissal.ts +219 -0
  92. package/src/shell/use-workbench-commands.ts +599 -0
  93. package/src/shell/use-workbench-keybindings.ts +337 -0
  94. package/src/shell/use-workbench.ts +488 -1081
  95. package/src/shell/workbench-context.ts +30 -3
  96. package/src/stores/workspace-document-io.ts +807 -0
  97. package/src/stores/workspace-file-ops.ts +1 -1
  98. package/src/stores/workspace-knowledge.ts +1 -1
  99. package/src/stores/workspace-lifecycle.ts +459 -0
  100. package/src/stores/workspace-plugins-state.ts +71 -599
  101. package/src/stores/workspace-session.ts +287 -0
  102. package/src/stores/workspace-tabs-layout.ts +1 -1
  103. package/src/stores/workspace-types.ts +50 -0
  104. package/src/stores/workspace.ts +163 -1345
  105. package/src/styles.css +0 -1
  106. package/src/tabs/components/DesktopTabs.vue +19 -11
  107. package/src/windows/AuxiliaryWindows.vue +2 -2
  108. package/src/windows/use-window-event-bridge.ts +152 -0
  109. package/src/workspace/components/TemplateLibrary.vue +1 -1
  110. package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
  111. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  112. package/src/assistant/locales/de-DE.json +0 -129
  113. package/src/assistant/locales/en-US.json +0 -129
  114. package/src/assistant/locales/es-ES.json +0 -129
  115. package/src/assistant/locales/ja-JP.json +0 -129
  116. package/src/assistant/locales/zh-CN.json +0 -129
  117. package/src/assistant/locales/zh-TW.json +0 -129
  118. package/src/assistant/task-prompts.json +0 -39
@@ -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
+ }
@@ -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>