@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
@@ -1,140 +1,92 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, inject, toRefs } from 'vue';
3
- import {
4
- AlertTriangle,
5
- Archive,
6
- ArrowDownToLine,
7
- ArrowLeft,
8
- ArrowRight,
9
- ArrowUpRight,
10
- Bot,
11
- CalendarDays,
12
- Check,
13
- CheckCheck,
14
- ChevronDown,
15
- ChevronLeft,
16
- ChevronRight,
17
- Clock3,
18
- FileText,
19
- GitFork,
20
- History,
21
- List,
22
- ListTodo,
23
- ListTree,
24
- LockKeyhole,
25
- MessageSquare,
26
- MessageSquareDiff,
27
- MoreHorizontal,
28
- MoveHorizontal,
29
- PanelLeftOpen,
30
- Pin,
31
- Plus,
32
- Puzzle,
33
- Redo2,
34
- RefreshCw,
35
- Repeat2,
36
- Search,
37
- Trash2,
38
- Undo2,
39
- X,
40
- } from 'lucide-vue-next';
41
- import ShortcutHint from '@tano/editor/shortcut-hint';
42
- import type { ExternalSlashCommand } from '@tano/editor/slash-commands';
43
- import type {
44
- ExternalCodeBlockRenderer,
45
- ExternalEditorDecoration,
46
- } from '@tano/editor/external-decorations';
47
- import { vSurfaceMotion } from '@tano/editor/surface-motion';
48
- import { pluginRecord } from '@tano/protocol';
49
- import { createPluginUiSandbox } from '../../plugins/ui-sandbox';
50
- import { isFeatureEnabled } from '../../features';
51
- import { vOutlineMotion } from '../../documents/outline-motion';
3
+ import { PanelLeftOpen } from 'lucide-vue-next';
4
+ import { fileHandlers, parentPath, relativeWorkspaceReference } from '@tano/protocol';
5
+ import { ASSISTANT_TAB_ID, openAssistantPage } from '../../assistant/navigation';
6
+ import { isTableTab, tableFileId } from '../../data-tables/data-tables';
7
+ import { GRAPH_TAB_ID } from '../../documents/document-graph';
8
+ import { t } from '../../i18n/i18n';
9
+ import { MAIL_TAB_ID } from '../../mail/types';
10
+ import { CALENDAR_TAB_ID } from '../../plans/calendar';
11
+ import { mobile } from '../../platform/platform';
12
+ import { PLUGINS_TAB_ID } from '../../plugins/workspace-plugins';
13
+ import { SETTINGS_TAB_ID } from '../../settings/settings-tab';
52
14
  import { layoutPanes } from '../pane-layout';
15
+ import { isEmptyPaneFallback } from '../pane-registry';
53
16
  import { useWindowContext } from '../../windows/context';
54
17
  import {
55
18
  AssistantPanel,
56
19
  CalendarView,
57
- CalloutIconPicker,
58
20
  DataTablePage,
59
- DocumentComments,
60
- EditorTools,
61
21
  MailWorkspaceView,
62
- MarkdownEditor,
63
- PluginInstaller,
64
22
  RelationGraph,
65
- SourceEditor,
66
23
  TemplateLibrary,
67
24
  } from '../workbench-async-components';
68
- import { workbenchContextKey } from '../workbench-context';
25
+ import {
26
+ workbenchDocumentsKey,
27
+ workbenchModalsKey,
28
+ workbenchPrefsKey,
29
+ workbenchShellKey,
30
+ workbenchTreeMenusKey,
31
+ } from '../workbench-context';
69
32
  import AssistantLauncher from '../../assistant/components/AssistantLauncher.vue';
70
33
  import AttachmentPreview from '../../files/components/AttachmentPreview.vue';
71
- import ButtonVisibilityGroup from './ButtonVisibilityGroup.vue';
72
34
  import DesktopTabs from '../../tabs/components/DesktopTabs.vue';
73
- import DocumentExportMenu from '../../documents/components/DocumentExportMenu.vue';
74
- import DocumentGlobalMenu from '../../documents/components/DocumentGlobalMenu.vue';
35
+ import DocumentInspector from '../../documents/components/DocumentInspector.vue';
75
36
  import DocumentLoading from '../../documents/components/DocumentLoading.vue';
76
- import DocumentOutline from '../../documents/components/DocumentOutline.vue';
77
- import DocumentPrintButton from '../../documents/components/DocumentPrintButton.vue';
78
- import DocumentScrollbar from '../../documents/components/DocumentScrollbar.vue';
79
- import DocumentStarter from '../../documents/components/DocumentStarter.vue';
80
- import DocumentStatus from '../../documents/components/DocumentStatus.vue';
81
- import DocumentSuggestions from '../../documents/components/DocumentSuggestions.vue';
82
- import DocumentTitle from '../../documents/components/DocumentTitle.vue';
37
+ import DocumentPane from '../../documents/components/DocumentPane.vue';
83
38
  import EmptyEditor from '../../documents/components/EmptyEditor.vue';
84
39
  import FolderView from '../../files/components/FolderView.vue';
85
- import LayoutDocumentChrome from './LayoutDocumentChrome.vue';
86
- import MarkdownRevealToggle from '../../documents/components/MarkdownRevealToggle.vue';
87
- import PageDisplayOptions from './PageDisplayOptions.vue';
88
- import PageSearch from './PageSearch.vue';
40
+ import PaneTopbar from './PaneTopbar.vue';
89
41
  import PluginDetailPage from '../../plugins/components/PluginDetailPage.vue';
90
- import PluginDocumentSlot from '../../plugins/components/PluginDocumentSlot.vue';
91
- import PluginMenu from '../../plugins/components/PluginMenu.vue';
42
+ import PluginsTabPage from '../../plugins/components/PluginsTabPage.vue';
92
43
  import PluginSurface from '../../plugins/components/PluginSurface.vue';
93
44
  import PluginView from '../../plugins/components/PluginView.vue';
94
- import PluginViewHeader from '../../plugins/components/PluginViewHeader.vue';
95
45
  import { resolveOverlayTabView } from '../../plugins/overlay-mapping';
96
- import SourceCodeIcon from '../../documents/components/SourceCodeIcon.vue';
97
46
  import WorkbenchSettings from '../../settings/components/WorkbenchSettings.vue';
98
- import WorkspaceBreadcrumb from './WorkspaceBreadcrumb.vue';
99
47
  import WorkspacePanes from './WorkspacePanes.vue';
48
+ import type { DocumentTab } from '../../stores/workspace-types';
100
49
 
101
50
  const windowContext = useWindowContext();
102
51
  const isAuxiliaryWindow = windowContext.id !== 'main';
103
52
  function dragPaneWindow(event: MouseEvent) {
104
53
  if (event.button === 0 && event.detail === 1) void windowContext.native?.startDragging();
105
54
  }
106
- function maximizePaneWindow() { void windowContext.native?.toggleMaximize(); }
55
+ function maximizePaneWindow() {
56
+ void windowContext.native?.toggleMaximize();
57
+ }
58
+
59
+ const shell = inject(workbenchShellKey);
60
+ const prefs = inject(workbenchPrefsKey);
61
+ const documents = inject(workbenchDocumentsKey);
62
+ const treeMenus = inject(workbenchTreeMenusKey);
63
+ const modals = inject(workbenchModalsKey);
64
+ if (!shell || !prefs || !documents || !treeMenus || !modals) {
65
+ throw new Error('Workbench context is required');
66
+ }
107
67
 
108
- const context = inject(workbenchContextKey);
109
- if (!context) throw new Error('Workbench context is required');
110
68
  const {
69
+ native,
111
70
  workspace,
112
71
  startupPending,
113
72
  filesPending,
114
73
  compactPanes: mainCompactPanes,
115
- tabsEnabled,
116
- native,
117
- mobile,
118
74
  sidebar,
119
- t,
120
- shortcuts,
121
75
  toggleSidebar,
122
76
  sessionPending,
123
- tabFileDrag,
124
- assistantTab,
125
- fileDragEnd,
126
77
  store,
127
78
  createNewDocument,
128
79
  detachTab,
129
80
  assistant,
130
81
  assistantPanelMounted,
131
82
  assistantHosts,
132
- ASSISTANT_TAB_ID,
83
+ assistantTab,
133
84
  openReference,
134
- revealAssistantSelection,
135
85
  openSettings,
136
86
  extensions,
137
87
  extensionActions,
88
+ extensionViews,
89
+ viewActions,
138
90
  templateLibraryOpen,
139
91
  templatePaneId,
140
92
  templateSource,
@@ -143,1479 +95,373 @@ const {
143
95
  openEntry,
144
96
  openBreadcrumbDirectory,
145
97
  setAssistantHost,
146
- topbarVisibilityItems,
147
- GRAPH_TAB_ID,
148
- closeButtonVisibilityMenus,
149
- canNavigatePage,
150
- navigatePage,
151
- CALENDAR_TAB_ID,
152
- paneButterflyScope,
153
- treeDocumentIcons,
154
- loadTreeDocumentIcon,
155
- pluginViewHeader,
156
- pluginPreviewStatus,
157
- paneDocumentStatus,
158
- attachmentStatus,
159
- currentAttachmentStatus,
160
- PLUGINS_TAB_ID,
161
- extensionViews,
162
- settingsTabView,
163
- MAIL_TAB_ID,
164
98
  mailEnabled,
165
- mailTabView,
99
+ paneButterflyScope,
166
100
  touchLayout,
167
- showOutline,
168
- touchOutlineOpen,
169
101
  attachments,
170
- isTableTab,
171
- calendarToolItems,
172
- calendarPeriod,
102
+ plans,
103
+ calendarScope,
173
104
  calendarDate,
174
- moveCalendarPeriod,
175
- calendarModeOpen,
176
- calendarModeLabel,
177
- calendarModeOptions,
178
105
  calendarMode,
179
106
  selectCalendarMode,
180
- openPlanArchive,
181
- documentSuggestions,
182
- editing,
183
- suggestionModeBusy,
184
- toggleSuggestionMode,
185
- documentToolItems,
186
- revealMarkdown,
187
- paneSource,
188
- shortcutAriaLabel,
189
- shortcutKeys,
190
- setPaneSource,
191
- menu,
192
- toggleDocumentMenu,
193
- documentMenuTriggerKeydown,
194
- documentMenuKeydown,
195
- openPaneSearch,
196
- shortcutHint,
197
- editorReadonly,
198
- documentUndoAvailable,
199
- undoDocument,
200
- documentRedoAvailable,
201
- redoDocument,
202
- canAddDocumentProperty,
203
- addDocumentProperty,
204
- paneComments,
205
- openDocumentDiscussion,
206
- paneReadonly,
207
- referenceGraphOpened,
208
- showReferenceGraph,
209
- limitPageWidth,
210
- pageWidthWritable,
211
- setLimitPageWidth,
212
- workspaceLocked,
213
- pageLocked,
214
- togglePageLock,
215
- historyPage,
216
- historyPanel,
217
- editorPreferences,
218
- showPageTitle,
219
- showDocumentProperties,
220
- showAllLineNumbers,
221
- togglePageOption,
222
- toggleWorkspaceLock,
223
- exportBusy,
224
- exportDocument,
225
- printBusy,
226
- printActiveDocument,
227
- sessionBlocksFileMutation,
228
- removeDocument,
229
- tableFileId,
230
- openAssistant,
231
- parentPath,
232
- calendarScope,
233
- plans,
234
107
  showCalendarDay,
235
108
  showCalendarMonth,
236
109
  showPlanEvent,
237
- openAssistantPage,
238
- viewActions,
239
- SETTINGS_TAB_ID,
240
110
  createPluginObject,
111
+ updateLock,
112
+ busy,
113
+ } = toRefs(shell);
114
+ const {
115
+ tabsEnabled,
116
+ shortcuts,
117
+ limitPageWidth,
241
118
  selectedVisualFontFamily,
242
119
  visualFontSize,
243
- setPaneSearch,
244
- paneSourceEditors,
245
- paneEditors,
246
- paneSearchRevisions,
247
- setPaneElement,
248
- toolbarMode,
249
- scheduleActiveHeading,
250
- appearance,
251
- assistantTaskActive,
252
- beginSelectionTodo,
253
- paneEditorScrolls,
254
- paneSelections,
255
- defaultSelectionContext,
256
- showSourceTodo,
257
- selectedDiff,
258
- showModal,
259
- sourceFontSize,
260
- openPageContextMenu,
261
- safeRemoteImage,
262
- uploadFile,
263
- resourceRevision,
264
- renameDocumentTitle,
265
- insertBlockBelowTitle,
266
- commentAnchors,
267
- paneEditorReady,
268
- paneSourceSelections,
269
- insertSourceFiles,
270
- setPaneEditor,
271
- openDocumentLink,
272
- openWikiLink,
273
- openBlankBlockAssistant,
274
- startDocumentDraft,
275
- quickInitialize,
276
- chooseInitialTemplate,
277
- showDocumentDiscussion,
278
- setPaneComments,
279
- discussWithAssistant,
280
- capturePaneCommentSelection,
281
- focusPaneComment,
282
- paneCommentGeometry,
283
- paneScrolls,
120
+ developerMode,
121
+ } = toRefs(prefs);
122
+ const {
123
+ revealAssistantSelection,
124
+ showOutline,
125
+ touchOutlineOpen,
126
+ openAssistant,
284
127
  receiveAttachmentStatus,
285
- updateLock,
286
- busy,
287
- fileHandlers,
288
- relativeWorkspaceReference,
289
- outlineOnLeft,
290
- hoverOutline,
291
- outlinePinned,
292
- outlinePosition,
293
- openOutlineContextMenu,
294
- releaseOutlinePointerFocus,
295
- outlineAutoCollapse,
296
- outlineSearchOpen,
297
- toggleOutlineSearch,
298
- toggleOutlinePin,
299
- outlineSearch,
300
- visibleOutline,
301
- jumpToHeading,
302
- outline,
303
- activeHeading,
304
- localNative,
305
- agentPanel,
306
- activities,
307
- uiLocale,
308
- vButterflyPerch,
309
- } = toRefs(context);
310
- const documentEditorPreferences = computed(() => isFeatureEnabled('markdownSpacingAutocomplete')
311
- ? editorPreferences.value
312
- : { ...editorPreferences.value, completeTextSpacing: false });
128
+ } = toRefs(documents);
129
+ const { tabFileDrag, fileDragEnd, treeDocumentIcons, loadTreeDocumentIcon } = toRefs(treeMenus);
130
+ const { showModal } = toRefs(modals);
313
131
 
314
- function activeOverlayTabView(activeTabId: string) {
315
- if (!workspace.value) return null;
316
- return resolveOverlayTabView(activeTabId, {
317
- safeMode: store.value.overlaySnapshot?.safeMode,
318
- homeTabView: store.value.pluginHomeTabView,
319
- newTabView: store.value.pluginNewTabView,
320
- });
321
- }
322
132
  const compactPanes = computed(() => !isAuxiliaryWindow && mainCompactPanes.value);
323
- // The fullscreen host is shared across windows; only its owner may mount the panel.
324
133
  const ownsFullscreenAssistant = computed(() => {
325
134
  const layout = store.value.windowLayouts[windowContext.id]?.layout;
326
- return !!layout && layoutPanes(layout).some(pane => pane.id === assistant.value.fullscreenPaneId);
135
+ return !!layout && layoutPanes(layout).some((pane) => pane.id === assistant.value.fullscreenPaneId);
327
136
  });
137
+ const extensionViewIds = computed(() => extensionViews.value.map((view) => view.id));
328
138
  const documentSidebarViews = computed(() =>
329
139
  store.value.pluginViews.filter((view) => view.location === 'documentSidebar'),
330
140
  );
331
141
  const activeDocumentSidebarView = computed(() =>
332
142
  documentSidebarViews.value.find((view) => view.key === store.value.activeDocumentPluginSidebar),
333
143
  );
334
- function selectDocumentPluginSidebar(key: string) {
335
- store.value.activeDocumentPluginSidebar = key;
336
- const view = documentSidebarViews.value.find((item) => item.key === key);
337
- if (view) {
338
- try {
339
- store.value.openPluginView(view.pluginId, view.id);
340
- } catch {
341
- /* Ignore if workspace is switching. */
342
- }
343
- }
344
- }
345
- function editorPluginSlashCommands(fileId: string): ExternalSlashCommand[] {
346
- const ws = workspace.value;
347
- if (!ws) return [];
348
- return store.value.pluginSlashCommands.map((cmd) => ({
349
- id: cmd.key,
350
- label: cmd.label,
351
- marker: cmd.pluginName,
352
- keywords: [...(cmd.keywords ?? []), cmd.pluginName, cmd.id].join(' '),
353
- description: cmd.description,
354
- execute: () => {
355
- void store.value
356
- .interactWithPlugin({
357
- workspaceId: ws.id,
358
- pluginId: cmd.pluginId,
359
- instanceId: cmd.instanceId,
360
- kind: 'command',
361
- name: cmd.command,
362
- payload: { workspaceId: ws.id, fileId, source: 'slash' },
363
- })
364
- .catch((error) => store.value.report(String(error)));
365
- },
366
- }));
367
- }
368
- function editorPluginDecorations(fileId: string): ExternalEditorDecoration[] {
369
- const ws = workspace.value;
370
- if (!ws) return [];
371
- return store.value.pluginDecorationsFor(fileId).map((item) => ({
372
- key: item.key,
373
- from: item.from,
374
- to: item.to,
375
- tone: item.tone,
376
- badge: item.badge,
377
- tooltip: item.tooltip,
378
- ...(item.command
379
- ? {
380
- onClick: () => {
381
- void store.value
382
- .interactWithPlugin({
383
- workspaceId: ws.id,
384
- pluginId: item.pluginId,
385
- instanceId: item.instanceId,
386
- kind: 'command',
387
- name: item.command!,
388
- payload: {
389
- workspaceId: ws.id,
390
- fileId,
391
- source: 'decoration',
392
- decorationId: item.id,
393
- from: item.from,
394
- to: item.to,
395
- },
396
- })
397
- .catch((error) => store.value.report(String(error)));
398
- },
399
- }
400
- : {}),
401
- }));
144
+
145
+ function activeOverlayTabView(activeTabId: string) {
146
+ if (!workspace.value) return null;
147
+ return resolveOverlayTabView(activeTabId, {
148
+ safeMode: store.value.overlaySnapshot?.safeMode,
149
+ homeTabView: store.value.pluginHomeTabView,
150
+ newTabView: store.value.pluginNewTabView,
151
+ });
402
152
  }
403
- const codeBlockRendererCache = new Map<
404
- string,
405
- { source: readonly unknown[]; list: ExternalCodeBlockRenderer[] }
406
- >();
407
- function editorPluginCodeBlockRenderers(fileId: string): ExternalCodeBlockRenderer[] {
408
- const ws = workspace.value;
409
- const source = store.value.pluginCodeBlockRenderers;
410
- if (!ws || !source.length) return [];
411
- const cacheKey = `${ws.id}:${fileId}`;
412
- const cached = codeBlockRendererCache.get(cacheKey);
413
- if (cached && cached.source === source) return cached.list;
414
- const list: ExternalCodeBlockRenderer[] = source.map((renderer) => ({
415
- id: `${renderer.key}:${renderer.instanceId}`,
416
- languages: renderer.languages,
417
- label: renderer.label ?? renderer.pluginName,
418
- height: renderer.height,
419
- mount(container, context) {
420
- const workspaceId = ws.id;
421
- const diagnostic = (level: string, message: string) => {
422
- void store.value
423
- .interactWithPlugin({
424
- workspaceId,
425
- pluginId: renderer.pluginId,
426
- instanceId: renderer.instanceId,
427
- name: renderer.view,
428
- kind: 'diagnostic',
429
- payload: { level, message },
430
- })
431
- .catch(() => {});
432
- };
433
- const buildState = (ctx: { language: string; source: string; readonly: boolean }) => ({
434
- kind: 'codeBlock',
435
- fileId,
436
- language: ctx.language,
437
- source: ctx.source,
438
- readonly: ctx.readonly,
439
- });
440
- const sandbox = createPluginUiSandbox(
441
- container,
442
- renderer.bundle,
443
- buildState(context),
444
- async (payload) => {
445
- if (
446
- pluginRecord(payload) &&
447
- payload.type === 'codeBlock.updateSource' &&
448
- typeof payload.source === 'string' &&
449
- payload.source.length <= 200 * 1024 &&
450
- !context.readonly
451
- ) {
452
- context.updateSource(payload.source);
453
- return;
454
- }
455
- await store.value.interactWithPlugin({
456
- workspaceId,
457
- pluginId: renderer.pluginId,
458
- instanceId: renderer.instanceId,
459
- name: renderer.view,
460
- kind: 'message',
461
- payload: { fileId, language: context.language, payload },
462
- });
463
- },
464
- (cause) => {
465
- diagnostic('error', cause);
466
- },
467
- diagnostic,
468
- );
469
- return {
470
- update(nextContext) {
471
- sandbox.update(buildState(nextContext));
472
- },
473
- dispose() {
474
- sandbox.dispose();
475
- },
476
- };
477
- },
478
- }));
479
- codeBlockRendererCache.set(cacheKey, { source, list });
480
- if (codeBlockRendererCache.size > 32) {
481
- codeBlockRendererCache.delete(codeBlockRendererCache.keys().next().value!);
482
- }
483
- return list;
153
+
154
+ function showEmptyPaneFallback(activeId: string, tab?: DocumentTab) {
155
+ return isEmptyPaneFallback({
156
+ activeId,
157
+ hasWorkspace: !!workspace.value,
158
+ startupPending: startupPending.value,
159
+ mailEnabled: mailEnabled.value,
160
+ extensionViewIds: extensionViewIds.value,
161
+ tab,
162
+ });
484
163
  }
485
164
  </script>
486
165
 
487
166
  <template>
488
- <WorkspacePanes
489
- v-if="workspace || startupPending || filesPending"
490
- :loading="filesPending"
167
+ <WorkspacePanes
168
+ v-if="workspace || startupPending || filesPending"
169
+ :loading="filesPending"
170
+ :compact="compactPanes"
171
+ :tabs-enabled="tabsEnabled"
172
+ :class="{ 'workspace-native-tabs': tabsEnabled && !compactPanes }"
173
+ >
174
+ <template #tabs="{ pane, rect }">
175
+ <div v-if="!compactPanes" class="workspace-tabbar" :data-tab-pane-id="pane.id">
176
+ <button
177
+ v-if="
178
+ native &&
179
+ !mobile &&
180
+ !isAuxiliaryWindow &&
181
+ !sidebar &&
182
+ rect.top === 0 &&
183
+ rect.left === 0
184
+ "
185
+ class="desktop-sidebar-toggle icon-button"
186
+ type="button"
187
+ :aria-label="t('展开侧栏')"
188
+ :data-tooltip="t('展开侧栏')"
189
+ :data-tooltip-shortcut="shortcuts.toggleSidebar"
190
+ @click="toggleSidebar"
191
+ >
192
+ <PanelLeftOpen :size="16" :stroke-width="1.6" />
193
+ </button>
194
+ <DesktopTabs
195
+ :loading="sessionPending"
196
+ :pane-id="pane.id"
197
+ :show-navigation="rect.top === 0 && rect.left === 0"
198
+ :detachable="native && !mobile"
199
+ :file-drag="tabFileDrag"
200
+ :assistant-tab="assistantTab"
201
+ @files-dropped="fileDragEnd"
202
+ @new-tab="
203
+ store.focusPane(pane.id);
204
+ store.createBlankTab();
205
+ "
206
+ @new-document="
207
+ store.focusPane(pane.id);
208
+ createNewDocument();
209
+ "
210
+ @detach-tab="detachTab"
211
+ />
212
+ <div
213
+ v-if="native && !mobile"
214
+ v-show="rect.top === 0"
215
+ class="workspace-window-drag"
216
+ :title="t('拖动窗口')"
217
+ @mousedown="dragPaneWindow"
218
+ @dblclick="maximizePaneWindow"
219
+ />
220
+ </div>
221
+ </template>
222
+ <template #sidebar>
223
+ <AssistantPanel
224
+ v-if="
225
+ assistant.available &&
226
+ assistantPanelMounted &&
227
+ (assistant.displayMode !== 'fullscreen' || ownsFullscreenAssistant)
228
+ "
491
229
  :compact="compactPanes"
492
- :tabs-enabled="tabsEnabled"
493
- :class="{ 'workspace-native-tabs': tabsEnabled && !compactPanes }"
230
+ :toggle-shortcut="shortcuts.toggleAssistant"
231
+ :fullscreen-target="assistantHosts.get(assistant.fullscreenPaneId ?? '')"
232
+ :navigation-visible="store.activeId === ASSISTANT_TAB_ID"
233
+ @show-navigation="sidebar = true"
234
+ @open-reference="openReference"
235
+ @reveal-selection="revealAssistantSelection"
236
+ @open-settings="openSettings('assistant')"
237
+ @closed="assistantPanelMounted = assistant.opened"
494
238
  >
495
- <template #tabs="{ pane, rect }">
496
- <div v-if="!compactPanes" class="workspace-tabbar" :data-tab-pane-id="pane.id">
239
+ <template #quota>
240
+ <component
241
+ :is="extensions.regions['assistant-quota']"
242
+ v-if="extensions.regions['assistant-quota']"
243
+ :actions="extensionActions"
244
+ />
245
+ </template>
246
+ </AssistantPanel>
247
+ </template>
248
+ <template #default="{ pane, document: active, tab }">
249
+ <TemplateLibrary
250
+ v-if="templateLibraryOpen && pane.id === templatePaneId && workspace"
251
+ :key="workspace.id"
252
+ :source="templateSource"
253
+ :initialize="templateInitialization"
254
+ :demo-label="store.isDemo ? workspaceStatusLabel : undefined"
255
+ @close="templateLibraryOpen = false"
256
+ @open-file="(file) => { store.focusPane(pane.id); openEntry(file); }"
257
+ @open-directory="(path) => { store.focusPane(pane.id); templateLibraryOpen = false; void openBreadcrumbDirectory(path); }"
258
+ >
259
+ <template #navigation>
260
+ <div v-if="!sidebar && !(native && !mobile && workspace)" class="topbar-navigation">
497
261
  <button
498
- v-if="
499
- native &&
500
- !mobile &&
501
- !isAuxiliaryWindow &&
502
- !sidebar &&
503
- rect.top === 0 &&
504
- rect.left === 0
505
- "
506
- class="desktop-sidebar-toggle icon-button"
507
262
  type="button"
263
+ class="icon-button"
508
264
  :aria-label="t('展开侧栏')"
509
- :data-tooltip="t('展开侧栏')" :data-tooltip-shortcut="shortcuts.toggleSidebar"
265
+ :data-tooltip="t('展开侧栏')"
266
+ :data-tooltip-shortcut="shortcuts.toggleSidebar"
510
267
  @click="toggleSidebar"
511
268
  >
512
269
  <PanelLeftOpen :size="16" :stroke-width="1.6" />
513
270
  </button>
514
- <DesktopTabs
515
- :loading="sessionPending"
516
- :pane-id="pane.id"
517
- :show-navigation="rect.top === 0 && rect.left === 0"
518
- :detachable="native && !mobile"
519
- :file-drag="tabFileDrag"
520
- :assistant-tab="assistantTab"
521
- @files-dropped="fileDragEnd"
522
- @new-tab="
523
- store.focusPane(pane.id);
524
- store.createBlankTab();
525
- "
526
- @new-document="
527
- store.focusPane(pane.id);
528
- createNewDocument();
529
- "
530
- @detach-tab="detachTab"
531
- />
532
- <div
533
- v-if="native && !mobile"
534
- v-show="rect.top === 0"
535
- class="workspace-window-drag"
536
- :title="t('拖动窗口')"
537
- @mousedown="dragPaneWindow"
538
- @dblclick="maximizePaneWindow"
539
- />
540
271
  </div>
541
272
  </template>
542
- <template #sidebar>
543
- <AssistantPanel
544
- v-if="assistant.available && assistantPanelMounted && (assistant.displayMode !== 'fullscreen' || ownsFullscreenAssistant)"
545
- :compact="compactPanes"
546
- :toggle-shortcut="shortcuts.toggleAssistant"
547
- :fullscreen-target="assistantHosts.get(assistant.fullscreenPaneId ?? '')"
548
- :navigation-visible="store.activeId === ASSISTANT_TAB_ID"
549
- @show-navigation="sidebar = true"
550
- @open-reference="openReference"
551
- @reveal-selection="revealAssistantSelection"
552
- @open-settings="openSettings('assistant')"
553
- @closed="assistantPanelMounted = assistant.opened"
554
- >
555
- <template #quota>
556
- <component :is="extensions.regions['assistant-quota']" v-if="extensions.regions['assistant-quota']" :actions="extensionActions" />
557
- </template>
558
- </AssistantPanel>
559
- </template>
560
- <template #default="{ pane, document: active, tab }">
273
+ </TemplateLibrary>
274
+ <div
275
+ :id="`assistant-fullscreen-${pane.id}`"
276
+ :ref="(el) => setAssistantHost(pane.id, el)"
277
+ v-show="assistant.isFullscreenTab(pane.activeId) && !(templateLibraryOpen && pane.id === templatePaneId)"
278
+ class="assistant-fullscreen-host workspace-card"
279
+ />
280
+ <div
281
+ v-show="!assistant.isFullscreenTab(pane.activeId) && !(templateLibraryOpen && pane.id === templatePaneId)"
282
+ class="workspace-page-content"
283
+ :class="{ 'workspace-card': tabsEnabled && !compactPanes }"
284
+ >
285
+ <PaneTopbar
286
+ v-if="!isAuxiliaryWindow || pane.activeId === CALENDAR_TAB_ID || tab?.pluginView"
287
+ :pane="pane"
288
+ :active="active"
289
+ :tab="tab"
290
+ :is-auxiliary-window="isAuxiliaryWindow"
291
+ />
292
+ <div class="workspace-page-body" :class="{ 'workspace-card': !(tabsEnabled && !compactPanes) }">
293
+ <KeepAlive v-if="pane.tabs.includes(GRAPH_TAB_ID)">
294
+ <RelationGraph
295
+ v-if="workspace && pane.activeId === GRAPH_TAB_ID"
296
+ :key="`${workspace.id}:${workspace.path}`"
297
+ :open-in-new-tab="tabsEnabled"
298
+ :controls-target="isAuxiliaryWindow ? undefined : `#graph-controls-${pane.id}`"
299
+ />
300
+ </KeepAlive>
561
301
 
562
- <TemplateLibrary
563
- v-if="templateLibraryOpen && pane.id === templatePaneId && workspace"
564
- :key="workspace.id"
565
- :source="templateSource"
566
- :initialize="templateInitialization"
567
- :demo-label="store.isDemo ? workspaceStatusLabel : undefined"
568
- @close="templateLibraryOpen = false"
569
- @open-file="(file) => { store.focusPane(pane.id); openEntry(file); }"
570
- @open-directory="(path) => { store.focusPane(pane.id); templateLibraryOpen = false; void openBreadcrumbDirectory(path); }"
571
- >
572
- <template #navigation>
573
- <div v-if="!sidebar && !(native && !mobile && workspace)" class="topbar-navigation">
574
- <button type="button" class="icon-button" :aria-label="t('展开侧栏')" :data-tooltip="t('展开侧栏')" :data-tooltip-shortcut="shortcuts.toggleSidebar" @click="toggleSidebar"><PanelLeftOpen :size="16" :stroke-width="1.6" /></button>
575
- </div>
576
- </template>
577
- </TemplateLibrary>
578
- <div
579
- :id="`assistant-fullscreen-${pane.id}`"
580
- :ref="(el) => setAssistantHost(pane.id, el)"
581
- v-show="assistant.isFullscreenTab(pane.activeId) && !(templateLibraryOpen && pane.id === templatePaneId)"
582
- class="assistant-fullscreen-host workspace-card"
302
+ <div v-if="workspace && isTableTab(pane.activeId)" class="data-table-assistant-page">
303
+ <DataTablePage
304
+ :key="`${workspace.id}:${pane.activeId}`"
305
+ :table-id="tableFileId(pane.activeId)"
306
+ :touch-layout="touchLayout"
307
+ :comment-author="extensions.commentAuthor?.() ?? { id: 'local', name: t('本机用户') }"
308
+ :controls-target="isAuxiliaryWindow ? undefined : `#data-table-controls-${pane.id}`"
309
+ />
310
+ <AssistantLauncher
311
+ v-if="assistant.available && !assistant.opened"
312
+ :scope="paneButterflyScope(pane.id, pane.activeId)"
313
+ :shortcut="shortcuts.toggleAssistant"
314
+ :context-label="t('聊聊这张数据表')"
315
+ :busy="assistant.busy || assistant.applying"
316
+ @open="openAssistant(pane.id, pane.activeId, { forcePanel: true })"
317
+ />
318
+ </div>
319
+ <FolderView
320
+ v-if="workspace && tab?.directory"
321
+ :directory="tab.directory"
322
+ :entries="workspace.files"
323
+ :folder-home-file-name="store.workspaceSettings.folderHomeFileName"
324
+ :document-icons="treeDocumentIcons"
325
+ :load-document-icon="loadTreeDocumentIcon"
326
+ @open="(file) => { store.focusPane(pane.id); void openEntry(file); }"
327
+ @up="() => { store.focusPane(pane.id); void openBreadcrumbDirectory(parentPath(tab.directory!.path)); }"
328
+ />
329
+ <CalendarView
330
+ v-if="workspace && pane.activeId === CALENDAR_TAB_ID"
331
+ :loading="calendarScope === 'workspace' && store.workspaceLoading.objects"
332
+ :date="calendarDate"
333
+ :mode="calendarMode"
334
+ :records="plans.recordsFor(calendarScope)"
335
+ @select-mode="selectCalendarMode"
336
+ @visible-month="calendarDate = $event"
337
+ @visible-year="calendarDate = $event"
338
+ @visible-timeline="calendarDate = $event"
339
+ @select-date="showCalendarDay"
340
+ @select-month="showCalendarMonth"
341
+ @select-event="showPlanEvent"
583
342
  />
584
- <div v-show="!assistant.isFullscreenTab(pane.activeId) && !(templateLibraryOpen && pane.id === templatePaneId)" class="workspace-page-content"
585
- :class="{ 'workspace-card': tabsEnabled && !compactPanes }">
586
- <ButtonVisibilityGroup
587
- v-if="!isAuxiliaryWindow || pane.activeId === CALENDAR_TAB_ID || tab?.pluginView"
588
- v-slot="{ isVisible }"
589
- :items="
590
- topbarVisibilityItems(pane.activeId, !!active, pane.id === store.activePaneId)
591
- "
592
- preference-key="tano.preference.documentHiddenTools"
593
- tag="header"
594
- :group-class="pane.activeId === GRAPH_TAB_ID ? 'topbar graph-topbar' : 'topbar'"
595
- :label="pane.activeId === GRAPH_TAB_ID ? t('图谱顶部栏') : t('文档顶部栏')"
596
- :menu-label="t('顶部栏显示设置')"
597
- @open="closeButtonVisibilityMenus"
598
- >
599
- <div
600
- v-if="
601
- (native && !tabsEnabled && (isVisible('back') || isVisible('forward'))) ||
602
- (!sidebar && !(native && !mobile && workspace))
603
- "
604
- class="topbar-navigation"
605
- role="group"
606
- :aria-label="pane.activeId === GRAPH_TAB_ID ? t('图谱导航') : t('文档导航')"
607
- >
608
- <button
609
- v-if="!sidebar && !(native && !mobile && workspace)"
610
- type="button"
611
- class="icon-button"
612
- :aria-label="t('展开侧栏')"
613
- :data-tooltip="t('展开侧栏')" :data-tooltip-shortcut="shortcuts.toggleSidebar"
614
- @click="toggleSidebar"
615
- >
616
- <PanelLeftOpen :size="16" :stroke-width="1.6" />
617
- </button>
618
- <button
619
- v-if="native && !tabsEnabled && isVisible('back')"
620
- type="button"
621
- class="icon-button"
622
- :aria-label="t('后退')"
623
- :data-tooltip="t('后退')"
624
- :disabled="!canNavigatePage(-1)"
625
- @click="navigatePage(-1)"
626
- >
627
- <ArrowLeft :size="16" :stroke-width="1.6" />
628
- </button>
629
- <button
630
- v-if="native && !tabsEnabled && isVisible('forward')"
631
- type="button"
632
- class="icon-button"
633
- :aria-label="t('前进')"
634
- :data-tooltip="t('前进')"
635
- :disabled="!canNavigatePage(1)"
636
- @click="navigatePage(1)"
637
- >
638
- <ArrowRight :size="16" :stroke-width="1.6" />
639
- </button>
640
- </div>
641
- <WorkspaceBreadcrumb
642
- :loading="filesPending"
643
- :perch="{ id: `breadcrumb:${paneButterflyScope(pane.id, pane.activeId)}`, scope: paneButterflyScope(pane.id, pane.activeId), label: t('面包屑'), kind: 'component' }"
644
- v-if="
645
- isVisible('breadcrumb') &&
646
- pane.activeId !== CALENDAR_TAB_ID &&
647
- pane.activeId !== GRAPH_TAB_ID
648
- "
649
- :workspace-id="workspace?.id"
650
- :workspace-name="workspace?.name ?? 'Tano'"
651
- :workspace-icon="store.workspaceSettings.icon"
652
- :workspace-mode="store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local'"
653
- :entries="workspace?.files ?? []"
654
- :folder-home-file-name="store.workspaceSettings.folderHomeFileName"
655
- :document-icons="treeDocumentIcons"
656
- :load-document-icon="loadTreeDocumentIcon"
657
- :path="tab?.path"
658
- :directory="!!tab?.directory"
659
- :demo-label="store.isDemo ? workspaceStatusLabel : undefined"
660
- :read-only="workspace?.readOnly"
661
- @open="(file) => { store.focusPane(pane.id); openEntry(file); }"
662
- @open-directory="(path) => { store.focusPane(pane.id); void openBreadcrumbDirectory(path); }"
663
- >
664
- <template #status>
665
- <DocumentStatus v-if="tab?.pluginView && isVisible('document-status')"
666
- :document-key="`${workspace?.id}:${tab.pluginView.pluginId}:${tab.pluginView.id}:${pluginViewHeader(store.pluginRuntime, tab.pluginView)?.title}`"
667
- :items="pluginPreviewStatus(store.pluginRuntime, tab.pluginView)" />
668
- <DocumentStatus v-if="active && isVisible('document-status')" :document-key="`${workspace?.id}:${active.id}`" :items="paneDocumentStatus(active)">
669
- <component :is="extensions.regions['document-status-details']"
670
- v-if="pane.id === store.activePaneId && extensions.regions['document-status-details']" :actions="extensionActions" />
671
- </DocumentStatus>
672
- <DocumentStatus v-else-if="tab?.attachment && isVisible('document-status')" :document-key="`${workspace?.id}:${tab.attachment.id}`" :items="attachmentStatus(pane.id, tab.attachment)">
673
- <button v-if="currentAttachmentStatus(pane.id, tab.attachment)?.retry" :disabled="currentAttachmentStatus(pane.id, tab.attachment)?.retryDisabled" @click="currentAttachmentStatus(pane.id, tab.attachment)?.retry?.()">{{ t('重试') }}</button>
674
- </DocumentStatus>
675
- </template>
676
- <template v-if="tab?.pluginDetail"><ChevronRight :size="12" /><Puzzle :size="14" /><span class="breadcrumb-current">{{ tab.pluginDetail.name }}</span></template>
677
- <template v-if="tab?.pluginView"><ChevronRight :size="12" /><Puzzle :size="14" /><span class="breadcrumb-current" :title="pluginViewHeader(store.pluginRuntime, tab.pluginView)?.title">{{ pluginViewHeader(store.pluginRuntime, tab.pluginView)?.title || tab.pluginView.label }}</span></template>
678
- <template v-if="pane.activeId === PLUGINS_TAB_ID"
679
- ><ChevronRight :size="12" /><Puzzle :size="14" /><span class="breadcrumb-current"
680
- >{{ t('插件') }}</span
681
- ></template
682
- ><template
683
- v-for="view in [...extensionViews, settingsTabView, ...(mailEnabled ? [mailTabView] : [])].filter((view) => view.id === pane.activeId)"
684
- :key="view.id"
685
- ><component :is="view.icon" :size="14" /><span
686
- class="breadcrumb-current"
687
- >{{ view.label }}</span
688
- ></template
689
- >
690
- </WorkspaceBreadcrumb>
691
- <DocumentStatus v-if="(active || tab?.attachment) && !isVisible('breadcrumb') && isVisible('document-status')"
692
- :document-key="`${workspace?.id}:${active?.id ?? tab?.attachment?.id}`" :items="active ? paneDocumentStatus(active) : attachmentStatus(pane.id, tab?.attachment)">
693
- <component v-if="active && pane.id === store.activePaneId && extensions.regions['document-status-details']" :is="extensions.regions['document-status-details']"
694
- :actions="extensionActions" />
695
- <button v-if="!active && currentAttachmentStatus(pane.id, tab?.attachment)?.retry" :disabled="currentAttachmentStatus(pane.id, tab?.attachment)?.retryDisabled" @click="currentAttachmentStatus(pane.id, tab?.attachment)?.retry?.()">{{ t('重试') }}</button>
696
- </DocumentStatus>
697
- <div class="topbar-right">
698
- <PluginViewHeader v-if="tab?.pluginView && workspace" :view="tab.pluginView" :workspace-id="workspace.id"
699
- :runtime="store.pluginRuntime.find(item => item.id === tab.pluginView?.pluginId)" :execute="store.interactWithPlugin" />
700
- <button v-if="active && touchLayout && showOutline" type="button" class="icon-button"
701
- :aria-label="t('文档大纲')" :aria-expanded="touchOutlineOpen"
702
- @click="touchOutlineOpen = !touchOutlineOpen">
703
- <List :size="18" />
704
- </button>
705
- <button
706
- v-if="tab?.attachment && attachments && isVisible('attachment-export')"
707
- type="button"
708
- class="topbar-attachment-action"
709
- :aria-label="t('导出附件')"
710
- :data-tooltip="t('导出附件副本')"
711
- @click="
712
- attachments
713
- .exportAttachment(workspace!.id, tab.attachment.path)
714
- .catch(store.report)
715
- "
716
- >
717
- <ArrowDownToLine :size="16" /><span>{{ t('导出') }}</span>
718
- </button>
719
- <div :id="`attachment-controls-${pane.id}`" class="attachment-controls-host" v-show="!!tab?.attachment" />
720
- <component
721
- :is="extensions.regions['editing-status']"
722
- v-if="
723
- isVisible('editing-status') &&
724
- pane.id === store.activePaneId &&
725
- extensions.regions['editing-status']
726
- "
727
- :actions="extensionActions"
728
- />
729
- <span
730
- v-if="
731
- workspaceStatusLabel &&
732
- (!store.isDemo ||
733
- !isVisible('breadcrumb') ||
734
- pane.activeId === CALENDAR_TAB_ID ||
735
- pane.activeId === GRAPH_TAB_ID)
736
- "
737
- :class="store.isDemo ? 'demo-badge' : 'local-badge'"
738
- :title="store.isDemo ? t('浏览器演示 · 数据仅保存在本浏览器') : undefined"
739
- >
740
- <LockKeyhole v-if="workspace?.readOnly" :size="14" />
741
- {{ workspaceStatusLabel }}
742
- </span>
743
- <div
744
- :id="`graph-controls-${pane.id}`"
745
- v-show="pane.activeId === GRAPH_TAB_ID"
746
- class="graph-toolbar-host"
747
- />
748
- <div
749
- v-if="isTableTab(pane.activeId)"
750
- :id="`data-table-controls-${pane.id}`"
751
- />
752
- <div
753
- v-if="
754
- pane.activeId === CALENDAR_TAB_ID &&
755
- calendarToolItems.some((item) => isVisible(item.id))
756
- "
757
- class="calendar-topbar-controls"
758
- role="group"
759
- :aria-label="t('日历导航')"
760
- >
761
- <span v-if="isVisible('calendar-period')" class="calendar-topbar-period">{{
762
- calendarPeriod
763
- }}</span>
764
- <button
765
- v-if="isVisible('calendar-today')"
766
- type="button"
767
- class="calendar-topbar-today"
768
- @click="calendarDate = new Date()"
769
- >
770
- {{ t('今天') }}
771
- </button>
772
- <button
773
- v-if="isVisible('calendar-previous')"
774
- type="button"
775
- class="icon-button"
776
- :aria-label="t('上一时段')"
777
- :data-tooltip="t('上一时段')"
778
- @click="moveCalendarPeriod(-1)"
779
- >
780
- <ChevronLeft :size="17" />
781
- </button>
782
- <button
783
- v-if="isVisible('calendar-next')"
784
- type="button"
785
- class="icon-button"
786
- :aria-label="t('下一时段')"
787
- :data-tooltip="t('下一时段')"
788
- @click="moveCalendarPeriod(1)"
789
- >
790
- <ChevronRight :size="17" />
791
- </button>
792
- <div
793
- v-if="isVisible('calendar-mode')"
794
- class="calendar-view-picker"
795
- @keydown.esc.stop.prevent="calendarModeOpen = false"
796
- >
797
- <button
798
- type="button"
799
- class="calendar-topbar-mode"
800
- :aria-label="t('切换日历视图')"
801
- :data-tooltip="t('Ctrl + 滚轮:切换日历视图')"
802
- aria-haspopup="menu"
803
- :aria-expanded="calendarModeOpen"
804
- @click="calendarModeOpen = !calendarModeOpen"
805
- >
806
- {{ calendarModeLabel }}<ChevronDown :size="14" />
807
- </button>
808
- <div v-surface-motion="'App:4'"
809
- v-if="calendarModeOpen"
810
- class="calendar-view-menu"
811
- role="menu"
812
- :aria-label="t('日历视图')"
813
- >
814
- <button
815
- v-for="option in calendarModeOptions"
816
- :key="option.mode"
817
- type="button"
818
- role="menuitemradio"
819
- :aria-checked="calendarMode === option.mode"
820
- @click="selectCalendarMode(option.mode)"
821
- >
822
- {{ option.label }}<Check v-if="calendarMode === option.mode" :size="15" />
823
- </button>
824
- </div>
825
- </div>
826
- <button
827
- v-if="isVisible('calendar-events')"
828
- type="button"
829
- class="calendar-topbar-events"
830
- :data-tooltip="t('查看和恢复已归档事项')"
831
- @click="openPlanArchive"
832
- >
833
- <Archive :size="15" />{{ t('已归档') }}
834
- </button>
835
- </div>
836
- <div v-if="active && documentSuggestions.get(active.id)?.mode && !editing.isManaging(active.id)"
837
- class="suggestion-mode-badge" role="status" :aria-label="t('建议模式已开启')">
838
- <MessageSquareDiff :size="14" /><span>{{ t('建议模式') }}</span>
839
- <button type="button" :aria-label="t('退出建议模式')" :data-tooltip="t('退出建议模式')"
840
- :disabled="suggestionModeBusy || documentSuggestions.get(active.id)?.reviewing"
841
- @click="toggleSuggestionMode(active.id)"><X :size="14" /></button>
842
- </div>
843
- <template v-if="active">
844
- <div
845
- v-if="documentToolItems.some((item) => isVisible(item.id))"
846
- class="document-tool-buttons"
847
- >
848
- <MarkdownRevealToggle
849
- v-if="isVisible('markdown-reveal')"
850
- v-model="revealMarkdown"
851
- :source="paneSource(pane.activeId)"
852
- :shortcut="shortcuts.toggleMarkdownReveal"
853
- />
854
- <button
855
- v-if="isVisible('source-mode')"
856
- type="button"
857
- class="icon-button source-mode-button"
858
- :class="{ active: paneSource(pane.activeId) }"
859
- :disabled="
860
- editing.isManaging(pane.activeId) ||
861
- (pane.id === store.activePaneId && editing.activeBusy)
862
- "
863
- :aria-label="paneSource(pane.activeId) ? t('返回编辑') : t('切换源码模式')"
864
- :aria-pressed="paneSource(pane.activeId)"
865
- :aria-keyshortcuts="shortcutAriaLabel(shortcuts.toggleSource) || undefined"
866
- :data-tooltip-shortcut="shortcutKeys(shortcuts.toggleSource)[0]"
867
- :data-tooltip="
868
- editing.isManaging(pane.activeId)
869
- ? t('当前编辑扩展不支持切换源码模式')
870
- : paneSource(pane.activeId)
871
- ? t('返回编辑')
872
- : t('切换源码模式')
873
- "
874
- @click="setPaneSource(pane.activeId, !paneSource(pane.activeId))"
875
- >
876
- <SourceCodeIcon :size="17" :off="!paneSource(pane.activeId)" />
877
- </button>
878
- </div>
879
- <div class="menu-wrap">
880
- <button
881
- class="icon-button"
882
- :aria-label="t('文档操作')"
883
- v-butterfly-perch="{ id: `document-actions:${paneButterflyScope(pane.id, pane.activeId)}`, scope: paneButterflyScope(pane.id, pane.activeId), label: t('文档操作按钮'), kind: 'component' }"
884
- :aria-expanded="menu && pane.id === store.activePaneId"
885
- @click="toggleDocumentMenu"
886
- @keydown="documentMenuTriggerKeydown"
887
- >
888
- <MoreHorizontal :size="19" />
889
- </button>
890
- <div v-surface-motion="'App:5'"
891
- v-if="menu && pane.id === store.activePaneId"
892
- :ref="(el) => { context.documentMenuElement = (el as HTMLElement | null) ?? undefined; }"
893
- class="dropdown compact-action-menu document-dropdown"
894
- @keydown="documentMenuKeydown"
895
- >
896
- <PluginMenu location="document" :file-id="active.id" @selected="menu = false" />
897
- <button type="button" @click="openPaneSearch(pane.id)">
898
- <Search :size="15" />{{ t('页内搜索') }}<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('pageSearch')" /></span>
899
- </button>
900
- <button type="button" @click="openPaneSearch(pane.id, true)">
901
- <Repeat2 :size="15" />{{ t('查找与替换') }}<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('pageReplace')" /></span>
902
- </button>
903
- <button
904
- type="button"
905
- :disabled="editorReadonly || !documentUndoAvailable"
906
- @click="undoDocument"
907
- >
908
- <Undo2 :size="15" />{{ t('撤销') }}<kbd class="menu-shortcut" aria-hidden="true"><ShortcutHint :label="shortcutHint('undo')" /></kbd>
909
- </button>
910
- <button
911
- type="button"
912
- :disabled="editorReadonly || !documentRedoAvailable"
913
- @click="redoDocument"
914
- >
915
- <Redo2 :size="15" />{{ t('重做') }}<kbd class="menu-shortcut" aria-hidden="true"><ShortcutHint :label="shortcutHint('redo')" /></kbd>
916
- </button>
917
- <button
918
- @click="
919
- menu = false;
920
- store.flush();
921
- "
922
- >
923
- <CheckCheck :size="15" />{{ t('立即保存') }}<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('save')" /></span>
924
- </button>
925
- <div class="menu-divider" role="separator" />
926
- <button type="button" :disabled="!canAddDocumentProperty" @click="addDocumentProperty">
927
- <Plus :size="15" />{{ t('添加文档属性') }}
928
- </button>
929
- <button type="button"
930
- :disabled="editorReadonly || !!editing.active || editing.activeBusy || !paneComments.has(store.activePaneId)"
931
- @click="openDocumentDiscussion">
932
- <MessageSquare :size="15" />{{ t('发起讨论') }}
933
- </button>
934
- <button type="button"
935
- :disabled="suggestionModeBusy || (!documentSuggestions.get(active.id)?.mode && (paneReadonly(active) || editing.isManaging(active.id) || editing.activeBusy)) || documentSuggestions.get(active.id)?.loading || documentSuggestions.get(active.id)?.reviewing"
936
- @click="toggleSuggestionMode(active.id)">
937
- <MessageSquareDiff :size="15" />{{ documentSuggestions.get(active.id)?.mode ? t('退出建议模式') : t('建议编辑') }}
938
- </button>
939
- <div class="menu-divider" role="separator" />
940
- <button
941
- type="button"
942
- aria-haspopup="dialog"
943
- :aria-expanded="referenceGraphOpened"
944
- @click="showReferenceGraph(pane.id, active!)"
945
- >
946
- <GitFork :size="15" />{{ t('查看关系图谱') }}
947
- </button>
948
- <button
949
- type="button"
950
- class="page-toggle-menu-item"
951
- role="switch"
952
- :aria-checked="!limitPageWidth"
953
- :aria-busy="store.capabilitySaving || undefined"
954
- :disabled="!pageWidthWritable"
955
- :data-tooltip="t('切换页面内容宽度')"
956
- @click="setLimitPageWidth(!limitPageWidth)"
957
- >
958
- <MoveHorizontal :size="15" />{{ t('全宽') }}<span
959
- class="menu-switch"
960
- :class="{ on: !limitPageWidth }"
961
- aria-hidden="true"
962
- ><span
963
- /></span>
964
- </button>
965
- <button
966
- type="button"
967
- class="page-toggle-menu-item"
968
- role="switch"
969
- :aria-checked="workspaceLocked || pageLocked"
970
- :disabled="workspaceLocked"
971
- :data-tooltip="workspaceLocked ? t('请先关闭工作区锁定,再修改页面锁定') : pageLocked ? t('退出阅读模式') : t('锁定后进入阅读模式')"
972
- @click="togglePageLock"
973
- >
974
- <LockKeyhole :size="15" />{{ t('锁定页面') }}<span
975
- class="menu-switch"
976
- :class="{ on: workspaceLocked || pageLocked }"
977
- aria-hidden="true"
978
- ><span
979
- /></span>
980
- </button>
981
- <div class="menu-divider" role="separator" />
982
- <button
983
- v-if="extensions.historyEnabled && extensions.historyView"
984
- @click="
985
- menu = false;
986
- historyPage = 'versions';
987
- historyPanel = true;
988
- "
989
- >
990
- <Archive :size="15" />{{ t('版本历史') }}<span class="menu-beta">Beta</span>
991
- </button>
992
- <button
993
- @click="
994
- menu = false;
995
- historyPage = 'updates';
996
- historyPanel = true;
997
- "
998
- >
999
- <Clock3 :size="15" />{{ t('更新历史') }}
1000
- </button>
1001
- <DocumentGlobalMenu>
1002
- <PageDisplayOptions :workspace-locked="workspaceLocked" :workspace-available="!!workspace"
1003
- :auto-spacing="editorPreferences.autoSpacing ?? false"
1004
- :show-page-title="showPageTitle"
1005
- :show-document-properties="showDocumentProperties"
1006
- :show-outline="showOutline"
1007
- :show-all-line-numbers="showAllLineNumbers"
1008
- :auxiliary-window="!!isAuxiliaryWindow"
1009
- :source="paneSource(store.activeId)"
1010
- @toggle="togglePageOption" @toggle-workspace-lock="toggleWorkspaceLock" />
1011
- </DocumentGlobalMenu>
1012
- <DocumentExportMenu :disabled="exportBusy" @select="exportDocument" />
1013
- <DocumentPrintButton :busy="printBusy" :shortcut="shortcuts.print" @select="printActiveDocument" />
1014
- <div class="menu-divider" role="separator" />
1015
- <button
1016
- class="danger-text"
1017
- :disabled="
1018
- editorReadonly ||
1019
- sessionBlocksFileMutation(pane.activeId) ||
1020
- (pane.id === store.activePaneId && editing.activeBusy)
1021
- "
1022
- @click="removeDocument()"
1023
- >
1024
- <Trash2 :size="15" />{{
1025
- store.isDemo
1026
- ? t('删除演示文档')
1027
- : store.isWeb
1028
- ? t('删除在线文档')
1029
- : t('移入回收站')
1030
- }}
1031
- </button>
1032
- </div>
1033
- </div>
1034
- </template>
1035
- </div>
1036
- </ButtonVisibilityGroup>
1037
- <!-- Everything below the top bar (display: contents unless it is the card).
1038
- .workspace-card marks the element that is the page's card where a layout draws cards (islands):
1039
- with native tab strips the top bar belongs to the card, so the card is the whole page content;
1040
- otherwise the top bar sits on the desk and the card is this body. -->
1041
- <div class="workspace-page-body" :class="{ 'workspace-card': !(tabsEnabled && !compactPanes) }">
1042
- <KeepAlive v-if="pane.tabs.includes(GRAPH_TAB_ID)">
1043
- <RelationGraph
1044
- v-if="workspace && pane.activeId === GRAPH_TAB_ID"
1045
- :key="`${workspace.id}:${workspace.path}`"
1046
- :open-in-new-tab="tabsEnabled"
1047
- :controls-target="isAuxiliaryWindow ? undefined : `#graph-controls-${pane.id}`"
1048
- />
1049
- </KeepAlive>
1050
343
 
1051
- <div v-if="workspace && isTableTab(pane.activeId)" class="data-table-assistant-page">
1052
- <DataTablePage
1053
- :key="`${workspace.id}:${pane.activeId}`"
1054
- :table-id="tableFileId(pane.activeId)"
1055
- :touch-layout="touchLayout"
1056
- :comment-author="extensions.commentAuthor?.() ?? { id: 'local', name: t('本机用户') }"
1057
- :controls-target="isAuxiliaryWindow ? undefined : `#data-table-controls-${pane.id}`"
1058
- />
1059
- <AssistantLauncher
1060
- v-if="assistant.available && !assistant.opened"
1061
- :scope="paneButterflyScope(pane.id, pane.activeId)"
1062
- :shortcut="shortcuts.toggleAssistant"
1063
- :context-label="t('聊聊这张数据表')"
1064
- :busy="assistant.busy || assistant.applying"
1065
- @open="openAssistant(pane.id, pane.activeId, { forcePanel: true })"
1066
- />
1067
- </div>
1068
- <FolderView v-if="workspace && tab?.directory" :directory="tab.directory" :entries="workspace.files"
1069
- :folder-home-file-name="store.workspaceSettings.folderHomeFileName"
1070
- :document-icons="treeDocumentIcons" :load-document-icon="loadTreeDocumentIcon"
1071
- @open="(file) => { store.focusPane(pane.id); void openEntry(file); }"
1072
- @up="() => { store.focusPane(pane.id); void openBreadcrumbDirectory(parentPath(tab.directory!.path)); }" />
1073
- <CalendarView
1074
- v-if="workspace && pane.activeId === CALENDAR_TAB_ID"
1075
- :loading="calendarScope === 'workspace' && store.workspaceLoading.objects"
1076
- :date="calendarDate"
1077
- :mode="calendarMode"
1078
- :records="plans.recordsFor(calendarScope)"
1079
- @select-mode="selectCalendarMode"
1080
- @visible-month="calendarDate = $event"
1081
- @visible-year="calendarDate = $event"
1082
- @visible-timeline="calendarDate = $event"
1083
- @select-date="showCalendarDay"
1084
- @select-month="showCalendarMonth"
1085
- @select-event="showPlanEvent"
344
+ <main v-if="pane.activeId === ASSISTANT_TAB_ID" class="assistant-page-placeholder">
345
+ <button @click="openAssistantPage(store, assistant)">{{ t('打开助手') }}</button>
346
+ </main>
347
+ <template v-for="view in extensionViews" :key="view.id">
348
+ <component
349
+ v-if="pane.activeId === view.id"
350
+ :is="view.component"
351
+ :actions="viewActions[view.id]"
1086
352
  />
353
+ </template>
1087
354
 
1088
- <main v-if="pane.activeId === ASSISTANT_TAB_ID" class="assistant-page-placeholder"><button @click="openAssistantPage(store, assistant)">{{ t('打开助手') }}</button></main>
1089
- <template v-for="view in extensionViews" :key="view.id">
1090
- <component
1091
- v-if="pane.activeId === view.id"
1092
- :is="view.component"
1093
- :actions="viewActions[view.id]"
1094
- />
1095
- </template>
355
+ <WorkbenchSettings v-if="pane.activeId === SETTINGS_TAB_ID" tabbed />
356
+ <MailWorkspaceView v-else-if="mailEnabled && pane.activeId === MAIL_TAB_ID" />
357
+ <PluginDetailPage
358
+ v-if="tab?.pluginDetail"
359
+ :plugin-id="tab.pluginDetail.id"
360
+ :developer-mode="developerMode"
361
+ />
362
+ <PluginView v-else-if="pane.activeId.startsWith('plugin:')" :view-key="pane.activeId" />
363
+ <PluginsTabPage
364
+ v-if="workspace && pane.tabs.includes(PLUGINS_TAB_ID)"
365
+ v-show="pane.activeId === PLUGINS_TAB_ID"
366
+ :workspace="workspace"
367
+ :object-references-enabled="store.capabilities.features.objectReferences"
368
+ :developer-mode="developerMode"
369
+ :extensions="extensions"
370
+ :extension-actions="extensionActions"
371
+ @enable-developer-mode="developerMode = true"
372
+ @create-object="createPluginObject"
373
+ />
1096
374
 
1097
- <WorkbenchSettings v-if="pane.activeId === SETTINGS_TAB_ID" tabbed />
1098
- <MailWorkspaceView v-else-if="mailEnabled && pane.activeId === MAIL_TAB_ID" />
1099
- <PluginDetailPage v-if="tab?.pluginDetail" :plugin-id="tab.pluginDetail.id" />
1100
- <PluginView v-else-if="pane.activeId.startsWith('plugin:')" :view-key="pane.activeId" />
1101
- <main
1102
- v-if="workspace && pane.tabs.includes(PLUGINS_TAB_ID)"
1103
- v-show="pane.activeId === PLUGINS_TAB_ID"
1104
- class="plugins-tab-page"
375
+ <DocumentLoading
376
+ v-if="
377
+ (!active && sessionPending) ||
378
+ store.restoringDocuments[pane.activeId] ||
379
+ store.openingDocuments[pane.id]?.tabId === pane.activeId
380
+ "
381
+ :unlimited="!limitPageWidth"
382
+ :touch="touchLayout"
383
+ :style="{
384
+ '--tano-prose-font-family': selectedVisualFontFamily,
385
+ '--tano-prose-font-size': `${visualFontSize}px`,
386
+ }"
387
+ />
388
+ <DocumentPane
389
+ v-else-if="active"
390
+ :pane="pane"
391
+ :active="active"
392
+ :is-auxiliary-window="isAuxiliaryWindow"
393
+ />
394
+ <AttachmentPreview
395
+ v-else-if="workspace && pane.activeId.startsWith('attachment:')"
396
+ status-managed
397
+ @status="receiveAttachmentStatus(pane.id, $event)"
398
+ :read-only="!!workspace.readOnly || updateLock || busy"
399
+ :controls-target="isAuxiliaryWindow ? undefined : `#attachment-controls-${pane.id}`"
400
+ :file="tab?.attachment"
401
+ :workspace-id="workspace.id"
402
+ :url="
403
+ attachments &&
404
+ tab?.attachment &&
405
+ fileHandlers.resolve(tab.attachment.path).preview !== 'office'
406
+ ? attachments.imageUrl(
407
+ workspace,
408
+ '',
409
+ relativeWorkspaceReference('', tab.attachment.path),
410
+ )
411
+ : null
412
+ "
413
+ />
414
+ <main
415
+ v-else-if="showEmptyPaneFallback(pane.activeId, tab)"
416
+ class="workspace-no-tabs"
417
+ :class="{ 'workspace-no-tabs-loading': sessionPending }"
418
+ >
419
+ <DocumentLoading
420
+ v-if="sessionPending"
421
+ :unlimited="!limitPageWidth"
422
+ :touch="touchLayout"
423
+ :style="{
424
+ '--tano-prose-font-family': selectedVisualFontFamily,
425
+ '--tano-prose-font-size': `${visualFontSize}px`,
426
+ }"
427
+ />
428
+ <div
429
+ v-else-if="workspace && activeOverlayTabView(pane.activeId)"
430
+ class="plugin-overlay-tab-host"
1105
431
  >
1106
- <div class="plugins-tab-content">
1107
- <p v-if="!store.capabilities.features.objectReferences" class="tool-level-notice">
1108
- {{ t('「工作区对象与引用」已关闭,插件对象和关系暂时只读。可在工作区设置中重新启用。') }}
1109
- </p>
1110
- <p v-else-if="workspace.readOnly" class="tool-level-notice">
1111
- {{ t('此工作区为只读,无法修改对象和关系。') }}
1112
- </p>
1113
- <PluginInstaller @create-object="createPluginObject">
1114
- <template v-if="extensions.regions['plugin-forge']" #forge="{ canPublish, openPublishing }">
1115
- <component
1116
- :is="extensions.regions['plugin-forge']"
1117
- :actions="extensionActions"
1118
- :can-publish="canPublish"
1119
- @open-publishing="openPublishing"
1120
- />
1121
- </template>
1122
- <template v-if="extensions.regions['plugin-publishing']" #publishing>
1123
- <component :is="extensions.regions['plugin-publishing']" :actions="extensionActions" />
1124
- </template>
1125
- </PluginInstaller>
1126
- </div>
1127
- </main>
1128
-
1129
- <DocumentLoading v-if="(!active && sessionPending) || store.restoringDocuments[pane.activeId] || store.openingDocuments[pane.id]?.tabId === pane.activeId" :unlimited="!limitPageWidth" :touch="touchLayout" :style="{ '--tano-prose-font-family': selectedVisualFontFamily, '--tano-prose-font-size': `${visualFontSize}px` }" />
1130
- <template v-else-if="active">
1131
- <PageSearch
1132
- :shortcuts="shortcuts"
1133
- :key="`search:${active.id}`"
1134
- :ref="(el) => setPaneSearch(pane.id, el)"
1135
- :editor="
1136
- paneSource(pane.activeId)
1137
- ? paneSourceEditors.get(pane.id)
1138
- : paneEditors.get(pane.id)
432
+ <PluginSurface
433
+ :key="`${workspace.id}:${activeOverlayTabView(pane.activeId)!.key}`"
434
+ :view="activeOverlayTabView(pane.activeId)!"
435
+ :workspace-id="workspace.id"
436
+ :runtime="
437
+ store.pluginRuntime.find(
438
+ (runtime) => runtime.id === activeOverlayTabView(pane.activeId)!.pluginId,
439
+ )
1139
440
  "
1140
- :content="active.content"
1141
- :readonly="paneReadonly(active!)"
1142
- :revision="paneSearchRevisions[pane.id]"
441
+ :execute="store.interactWithPlugin"
1143
442
  />
1144
- <div :key="active.id" class="document-scroll-shell" :class="{ 'has-assistant-launcher': assistant.available }">
1145
- <div
1146
- :id="`document-scroll-${pane.id}`"
1147
- :ref="(el) => setPaneElement('scroll', pane.id, el)"
1148
- class="document-layout"
1149
- :data-toolbar-dock="
1150
- pane.id === store.activePaneId &&
1151
- !paneSource(pane.activeId) &&
1152
- !paneReadonly(active!)
1153
- ? toolbarMode
1154
- : undefined
1155
- "
1156
- @scroll.passive="scheduleActiveHeading"
1157
- >
1158
- <main class="document-main">
1159
- <LayoutDocumentChrome :layout="appearance.layout" :path="active.path" />
1160
- <EditorTools
1161
- :shortcuts="shortcuts"
1162
- v-model:mode="toolbarMode"
1163
- :assistant="assistant.available"
1164
- :assistant-disabled="assistantTaskActive()"
1165
- @assistant="openAssistant(pane.id, active!.id)"
1166
- annotation
1167
- :todo="
1168
- store.capabilities.features.objectReferences &&
1169
- !paneReadonly(active!) &&
1170
- !editing.isManaging(active!.id)
1171
- "
1172
- @todo="beginSelectionTodo(pane.id, active!.id)"
1173
- @annotation="paneComments.get(pane.id)?.beginAnnotation()"
1174
- :active="pane.id === store.activePaneId"
1175
- :editor-element="paneEditorScrolls.get(pane.id)"
1176
- :features="store.capabilities.features"
1177
- :context="paneSelections[pane.id] ?? defaultSelectionContext"
1178
- :source="paneSource(pane.activeId)"
1179
- :disabled="paneReadonly(active!)"
1180
- @command="(name, value) => paneEditors.get(pane.id)?.command(name, value)"
1181
- >
1182
- <template v-if="isAuxiliaryWindow || showSourceTodo(pane.id, active!)" #trailing>
1183
- <button
1184
- v-if="showSourceTodo(pane.id, active!)"
1185
- type="button"
1186
- class="icon-button"
1187
- :aria-label="t('从选区创建任务或事件')"
1188
- :data-tooltip="t('从选区创建任务或事件')"
1189
- @mousedown.prevent
1190
- @click="beginSelectionTodo(pane.id, active!.id)"
1191
- >
1192
- <ListTodo :size="17" />
1193
- </button>
1194
- <ButtonVisibilityGroup
1195
- v-if="isAuxiliaryWindow"
1196
- v-slot="{ isVisible }"
1197
- :items="documentToolItems"
1198
- preference-key="tano.preference.documentHiddenTools"
1199
- group-class="detached-editor-actions document-tool-buttons"
1200
- :label="t('文档工具')"
1201
- :menu-label="t('文档工具按钮显示设置')"
1202
- @open="closeButtonVisibilityMenus"
1203
- >
1204
- <MarkdownRevealToggle
1205
- v-if="isVisible('markdown-reveal')"
1206
- v-model="revealMarkdown"
1207
- :source="paneSource(pane.activeId)"
1208
- :shortcut="shortcuts.toggleMarkdownReveal"
1209
- />
1210
- <button
1211
- v-if="isVisible('source-mode')"
1212
- type="button"
1213
- class="icon-button"
1214
- :class="{ active: paneSource(pane.activeId) }"
1215
- :disabled="!!editing.active || editing.activeBusy"
1216
- :aria-label="paneSource(pane.activeId) ? t('返回编辑') : t('切换源码模式')"
1217
- :aria-pressed="paneSource(pane.activeId)"
1218
- :aria-keyshortcuts="shortcutAriaLabel(shortcuts.toggleSource) || undefined"
1219
- :data-tooltip-shortcut="shortcutKeys(shortcuts.toggleSource)[0]"
1220
- :data-tooltip="paneSource(pane.activeId) ? t('返回编辑') : t('切换源码模式')"
1221
- @click="setPaneSource(pane.activeId, !paneSource(pane.activeId))"
1222
- >
1223
- <SourceCodeIcon :size="17" :off="!paneSource(pane.activeId)" />
1224
- </button>
1225
- </ButtonVisibilityGroup>
1226
- </template>
1227
- </EditorTools>
1228
-
1229
- <component
1230
- :is="extensions.regions['editing-panel']"
1231
- v-if="pane.id === store.activePaneId && extensions.regions['editing-panel']"
1232
- :actions="extensionActions"
1233
- />
1234
- <p v-if="active.creating && !active.error" class="creation-status" role="status">
1235
- {{ t('正在创建… 可以继续编辑') }}
1236
- </p>
1237
- <div v-if="active.conflict" class="conflict-banner" role="alert">
1238
- <AlertTriangle :size="19" />
1239
- <div>
1240
- <strong>{{ t('这一页有两份新的想法') }}</strong>
1241
- <p>
1242
- {{ t('外部修改与你的修改重叠。你的内容已保存为 conflict 副本,原文件保留外部版本。') }}
1243
- </p>
1244
- <button @click="store.resolveConflict(active!, true)">
1245
- {{ t('打开我的副本') }} <ArrowUpRight :size="14" /></button
1246
- ><button @click="store.resolveConflict(active!, false)">
1247
- {{ t('载入磁盘版本') }}
1248
- </button>
1249
- <button
1250
- @click="
1251
- selectedDiff = {
1252
- title: active.path,
1253
- before: active.conflict.disk.content,
1254
- after: active.content,
1255
- beforeLabel: t('磁盘版本'),
1256
- afterLabel: t('我的副本'),
1257
- }
1258
- "
1259
- >
1260
- {{ t('比较两个版本') }}
1261
- </button>
1262
- </div>
1263
- </div>
1264
- <div
1265
- v-else-if="active.missing || active.error"
1266
- class="conflict-banner"
1267
- role="alert"
1268
- >
1269
- <AlertTriangle :size="19" />
1270
- <div>
1271
- <strong>{{
1272
- active.missing ? t('文件已在工作文件夹中移除') : active.creating ? t('文档尚未创建成功') : t('这次保存没有完成')
1273
- }}</strong>
1274
- <p>
1275
- {{
1276
- active.error ?? t('编辑器中的内容仍然保留,你可以把它另存为一个新文档。')
1277
- }}
1278
- </p>
1279
- <button @click="showModal('saveAs')">
1280
- {{ t('另存副本') }} <ArrowUpRight :size="14" /></button
1281
- ><button v-if="!active.missing" @click="store.flush()">{{ t('重试保存') }}</button>
1282
- </div>
1283
- </div>
1284
- <div
1285
- :ref="(el) => setPaneElement('editor', pane.id, el)"
1286
- class="editor-scroll"
1287
- :style="{
1288
- '--tano-prose-font-family': selectedVisualFontFamily,
1289
- '--tano-prose-font-size': `${visualFontSize}px`,
1290
- '--tano-source-font-size': `${sourceFontSize}px`,
1291
- }"
1292
- :class="{
1293
- 'source-view': paneSource(pane.activeId),
1294
- 'conflicted-editor': active.conflict,
1295
- 'width-unlimited': !limitPageWidth,
1296
- }"
1297
- tabindex="-1"
1298
- @mousedown.self="
1299
- !paneSource(pane.activeId) &&
1300
- paneEditors.get(pane.id)?.focusTrailingParagraph($event)
1301
- "
1302
- @contextmenu="openPageContextMenu"
1303
- >
1304
- <DocumentSuggestions v-slot="suggestions" :document="active" :readonly="paneReadonly(active!)"
1305
- :source="paneSource(pane.activeId)"
1306
- :managed="!!editing.active" :author="extensions.commentAuthor?.() ?? { id: 'local', name: t('本机用户') }">
1307
- <PluginDocumentSlot
1308
- v-if="workspace && pane.id === store.activePaneId"
1309
- location="documentHeader"
1310
- :views="store.pluginViews"
1311
- :runtimes="store.pluginRuntime"
1312
- :workspace-id="workspace.id"
1313
- :execute="store.interactWithPlugin"
1314
- />
1315
- <DocumentTitle
1316
- v-if="workspace && showPageTitle"
1317
- :key="`${workspace.id}:${active.id}`"
1318
- :workspace-id="workspace.id"
1319
- :document-id="active.id"
1320
- :path="store.displayPath(active)"
1321
- :title-source="store.workspaceSettings.pageTitleSource"
1322
- :model-value="suggestions.content"
1323
- :files="workspace.files"
1324
- :mode="store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local'"
1325
- :resolve-image="(reference) => attachments ? attachments.imageUrl(workspace, active!.path, reference) : safeRemoteImage(reference)"
1326
- :upload-cover="attachments && !store.isDemo ? (file) => uploadFile(file, true, active) : undefined"
1327
- :resource-revision="resourceRevision"
1328
- :readonly="
1329
- suggestions.readonly ||
1330
- suggestions.suggesting ||
1331
- active.missing ||
1332
- sessionBlocksFileMutation(active.id) ||
1333
- editing.activeBusy
1334
- "
1335
- :rename="renameDocumentTitle"
1336
- @update:model-value="suggestions.edit($event)"
1337
- @enter="insertBlockBelowTitle"
1338
- @comment="paneComments.get(pane.id)?.showDiscussion()"
1339
- />
1340
- <SourceEditor :reference-targets="store.referenceTargets" :capabilities="store.capabilities" :preferences="documentEditorPreferences" :suggestion-marks="suggestions.sourceMarks" :translate="t"
1341
- :show-all-line-numbers="showAllLineNumbers"
1342
- v-if="paneSource(pane.activeId)"
1343
- :key="active.id"
1344
- :content-revision="suggestions.viewKey"
1345
- :ref="(el) => setPaneElement('source', pane.id, el)"
1346
- :model-value="suggestions.content"
1347
- :readonly="suggestions.readonly"
1348
- :local-native="!!attachments && !suggestions.suggesting"
1349
- :comment-anchors="commentAnchors[active.id]"
1350
- @ready="paneEditorReady(pane.id, active!.id, true)"
1351
- @selection-change="paneSourceSelections[pane.id] = $event"
1352
- @update:model-value="suggestions.edit($event)"
1353
- @files="
1354
- (files, requireImage, position) =>
1355
- insertSourceFiles(files, position, requireImage, active, pane.id)
1356
- "
1357
- />
1358
- <MarkdownEditor :shortcut-hints="{ delete: shortcutHint('deleteBlock'), 'move-up': shortcutHint('moveBlockUp'), 'move-down': shortcutHint('moveBlockDown'), indent: shortcutHint('indentBlock'), outdent: shortcutHint('outdentBlock') }" :suggestion-marks="suggestions.richMarks" :transform-change="suggestions.transformChange"
1359
- v-else
1360
- :custom-callout-icon="CalloutIconPicker"
1361
- :slash-commands="editorPluginSlashCommands(active.id)"
1362
- :decorations="editorPluginDecorations(active.id)"
1363
- :code-block-renderers="editorPluginCodeBlockRenderers(active.id)"
1364
- :content-revision="suggestions.viewKey"
1365
- :key="`${active.id}:${active.id === store.active?.id ? (editing.active?.key ?? 'local') : 'local'}`"
1366
- :ref="(el) => setPaneEditor(pane.id, el)"
1367
- :document-id="active.id"
1368
- :readonly="suggestions.readonly"
1369
- :open-links-on-tap="touchLayout"
1370
- :reveal-markdown="suggestions.suggesting ? false : revealMarkdown"
1371
- :show-document-properties="showDocumentProperties"
1372
- :capabilities="store.capabilities"
1373
- :reference-targets="store.referenceTargets"
1374
- :preferences="documentEditorPreferences"
1375
- :translate="t"
1376
- :extension="
1377
- active.id === store.active?.id ? editing.active?.extension : undefined
1378
- "
1379
- :model-value="suggestions.content"
1380
- :table-layouts="active.tableLayout?.file.tables"
1381
- :comment-anchors="commentAnchors[active.id]"
1382
- :resolve-image="
1383
- (reference) =>
1384
- attachments
1385
- ? attachments.imageUrl(workspace, active!.path, reference)
1386
- : safeRemoteImage(reference)
1387
- "
1388
- :resource-revision="resourceRevision"
1389
- :import-file="
1390
- attachments && !suggestions.suggesting ? (file, image) => uploadFile(file, image, active) : undefined
1391
- "
1392
- @update:model-value="suggestions.edit($event)"
1393
- @table-layout-change="!suggestions.suggesting && store.editTableLayout(active!.id, $event)"
1394
- @error="store.report"
1395
- @ready="paneEditorReady(pane.id, active!.id, false)"
1396
- @search-change="
1397
- paneSearchRevisions[pane.id] = (paneSearchRevisions[pane.id] ?? 0) + 1
1398
- "
1399
- @open-link="
1400
- (reference, newTab) => openDocumentLink(reference, newTab, active!.path)
1401
- "
1402
- @open-wiki-link="openWikiLink"
1403
- @open-reference="openReference"
1404
- @edit-source="setPaneSource(pane.activeId, true)"
1405
- @selection-change="paneSelections[pane.id] = $event"
1406
- @blank-block-ai="openBlankBlockAssistant(pane.id, active!.id)"
1407
- >
1408
- <template v-if="!suggestions.suggesting && !active.missing && !active.conflict && !active.error" #empty-document>
1409
- <DocumentStarter :assistant="assistant.available" :assistant-busy="assistant.busy || assistant.applying || assistant.loading"
1410
- @draft="startDocumentDraft(pane.id, active!.id)"
1411
- @initialize="quickInitialize(pane.id, active!.id, $event)"
1412
- @template="chooseInitialTemplate(pane.id, active!.id)" />
1413
- </template>
1414
- </MarkdownEditor>
1415
- <PluginDocumentSlot
1416
- v-if="workspace && pane.id === store.activePaneId"
1417
- location="documentFooter"
1418
- :views="store.pluginViews"
1419
- :runtimes="store.pluginRuntime"
1420
- :workspace-id="workspace.id"
1421
- :execute="store.interactWithPlugin"
1422
- />
1423
- <DocumentComments
1424
- v-if="workspace"
1425
- v-model:discussion-visible="showDocumentDiscussion"
1426
- :ref="(el) => setPaneComments(pane.id, el)"
1427
- :workspace-id="workspace.id"
1428
- :document="active"
1429
- :assistant="assistant.available"
1430
- @assistant="discussWithAssistant(pane.id, active!.id, $event)"
1431
- :readonly="suggestions.readonly"
1432
- :author="extensions.commentAuthor?.() ?? { id: 'local', name: t('本机用户') }"
1433
- :capture-selection="() => capturePaneCommentSelection(pane.id, active!.id)"
1434
- :focus-anchor="(anchor) => focusPaneComment(pane.id, active!.id, anchor)"
1435
- :editor-element="paneEditorScrolls.get(pane.id)"
1436
- :geometry="(anchors) => paneCommentGeometry(pane.id, active!.id, anchors)"
1437
- @annotations="commentAnchors[active!.id] = $event"
1438
- />
1439
- </DocumentSuggestions>
1440
- </div>
1441
- </main>
1442
- </div>
1443
- <DocumentScrollbar v-if="!touchLayout" :scroll-element="paneScrolls.get(pane.id)" />
1444
- <AssistantLauncher
1445
- v-if="assistant.available && !assistant.opened"
1446
- :scope="paneButterflyScope(pane.id, active!.id)"
1447
- :shortcut="shortcuts.toggleAssistant"
1448
- :busy="assistant.busy || assistant.applying"
1449
- @open="openAssistant(pane.id, active!.id, { forcePanel: true })"
1450
- />
1451
- </div>
1452
- </template>
1453
-
1454
- <AttachmentPreview
1455
- v-else-if="workspace && pane.activeId.startsWith('attachment:')"
1456
- status-managed
1457
- @status="receiveAttachmentStatus(pane.id, $event)"
1458
- :read-only="!!workspace.readOnly || updateLock || busy"
1459
- :controls-target="isAuxiliaryWindow ? undefined : `#attachment-controls-${pane.id}`"
1460
- :file="tab?.attachment"
1461
- :workspace-id="workspace.id"
1462
- :url="
1463
- attachments && tab?.attachment && fileHandlers.resolve(tab.attachment.path).preview !== 'office'
1464
- ? attachments.imageUrl(
1465
- workspace,
1466
- '',
1467
- relativeWorkspaceReference('', tab.attachment.path),
1468
- )
1469
- : null
1470
- "
443
+ </div>
444
+ <EmptyEditor
445
+ v-else
446
+ :create-disabled="busy || !workspace || workspace.readOnly || updateLock"
447
+ @create="createNewDocument"
448
+ @open="showModal('newTab')"
449
+ @search="showModal('search')"
1471
450
  />
1472
- <main
1473
- v-else-if="
1474
- (workspace || startupPending) &&
1475
- pane.activeId !== GRAPH_TAB_ID &&
1476
- pane.activeId !== PLUGINS_TAB_ID &&
1477
- pane.activeId !== CALENDAR_TAB_ID &&
1478
- pane.activeId !== SETTINGS_TAB_ID &&
1479
- (!mailEnabled || pane.activeId !== MAIL_TAB_ID) &&
1480
- !isTableTab(pane.activeId) &&
1481
- !pane.activeId.startsWith('plugin:') &&
1482
- !tab?.directory &&
1483
- !tab?.pluginView &&
1484
- !extensionViews.find((view) => view.id === pane.activeId)
1485
- "
1486
- class="workspace-no-tabs"
1487
- :class="{ 'workspace-no-tabs-loading': sessionPending }"
1488
- >
1489
- <DocumentLoading v-if="sessionPending" :unlimited="!limitPageWidth" :touch="touchLayout" :style="{ '--tano-prose-font-family': selectedVisualFontFamily, '--tano-prose-font-size': `${visualFontSize}px` }" />
1490
- <div
1491
- v-else-if="workspace && activeOverlayTabView(pane.activeId)"
1492
- class="plugin-overlay-tab-host"
1493
- >
1494
- <PluginSurface
1495
- :key="`${workspace.id}:${activeOverlayTabView(pane.activeId)!.key}`"
1496
- :view="activeOverlayTabView(pane.activeId)!"
1497
- :workspace-id="workspace.id"
1498
- :runtime="store.pluginRuntime.find((runtime) => runtime.id === activeOverlayTabView(pane.activeId)!.pluginId)"
1499
- :execute="store.interactWithPlugin"
1500
- />
1501
- </div>
1502
- <EmptyEditor v-else
1503
- :create-disabled="busy || !workspace || workspace.readOnly || updateLock"
1504
- @create="createNewDocument"
1505
- @open="showModal('newTab')"
1506
- @search="showModal('search')"
1507
- />
1508
- </main>
451
+ </main>
1509
452
 
1510
- <aside
1511
- v-if="
1512
- active &&
1513
- !(assistant.opened && assistant.displayMode === 'sidebar') &&
1514
- !isAuxiliaryWindow &&
1515
- pane.id === store.activePaneId &&
1516
- (activeDocumentSidebarView || (showOutline && (!touchLayout || touchOutlineOpen)))
1517
- "
1518
- v-outline-motion
1519
- class="inspector"
1520
- :style="!activeDocumentSidebarView ? outlinePosition : undefined"
1521
- :class="{
1522
- 'inspector-outline': !activeDocumentSidebarView,
1523
- 'inspector-outline-left': !activeDocumentSidebarView && outlineOnLeft,
1524
- 'inspector-hover-outline':
1525
- !activeDocumentSidebarView && !touchLayout && hoverOutline && !outlinePinned,
1526
- 'inspector-activity': !!activeDocumentSidebarView,
1527
- }"
1528
- :aria-label="
1529
- activeDocumentSidebarView
1530
- ? `${activeDocumentSidebarView.pluginName} · ${activeDocumentSidebarView.label}`
1531
- : t('文档目录')
1532
- "
1533
- @contextmenu="openOutlineContextMenu"
1534
- @pointerleave="releaseOutlinePointerFocus"
1535
- >
1536
- <div class="inspector-surface">
1537
- <div v-if="activeDocumentSidebarView || documentSidebarViews.length" class="inspector-tabs">
1538
- <button
1539
- :class="{ active: !activeDocumentSidebarView }"
1540
- @click="store.activeDocumentPluginSidebar = ''"
1541
- ><List :size="14" />{{ t('大纲') }}</button>
1542
- <button
1543
- v-for="docView in documentSidebarViews"
1544
- :key="docView.key"
1545
- :class="{ active: activeDocumentSidebarView?.key === docView.key }"
1546
- @click="selectDocumentPluginSidebar(docView.key)"
1547
- >
1548
- <Puzzle :size="14" />{{ docView.label }}
1549
- </button>
1550
- </div>
1551
- <PluginSurface
1552
- v-if="activeDocumentSidebarView && workspace"
1553
- :key="`${workspace.id}:${activeDocumentSidebarView.key}`"
1554
- :view="activeDocumentSidebarView"
1555
- :workspace-id="workspace.id"
1556
- :runtime="store.pluginRuntime.find((rt) => rt.id === activeDocumentSidebarView!.pluginId)"
1557
- :execute="store.interactWithPlugin"
1558
- compact
1559
- />
1560
- <template v-else>
1561
- <div class="outline-controls">
1562
- <span>{{ t('文档大纲') }}</span>
1563
- <button v-if="touchLayout" type="button" class="outline-control" :aria-label="t('关闭文档大纲')"
1564
- @click="touchOutlineOpen = false"><X :size="18" /></button>
1565
- <button
1566
- class="outline-control"
1567
- :class="{ active: outlineAutoCollapse }"
1568
- type="button"
1569
- :aria-label="t('自动折叠大纲')"
1570
- :data-tooltip="t('自动折叠大纲')"
1571
- :aria-pressed="outlineAutoCollapse"
1572
- @click="outlineAutoCollapse = !outlineAutoCollapse"
1573
- >
1574
- <ListTree :size="15" />
1575
- </button>
1576
- <button
1577
- class="outline-control"
1578
- :class="{ active: outlineSearchOpen }"
1579
- type="button"
1580
- :aria-label="t('搜索大纲标题')"
1581
- :data-tooltip="t('搜索大纲标题')"
1582
- :aria-expanded="outlineSearchOpen"
1583
- @click="toggleOutlineSearch"
1584
- >
1585
- <Search :size="15" />
1586
- </button>
1587
- <button
1588
- v-if="hoverOutline"
1589
- class="outline-control"
1590
- :class="{ active: outlinePinned }"
1591
- type="button"
1592
- :aria-label="outlinePinned ? t('取消固定大纲') : t('固定大纲')"
1593
- :data-tooltip="outlinePinned ? t('取消固定大纲') : t('固定大纲')"
1594
- :aria-pressed="outlinePinned"
1595
- @click="toggleOutlinePin"
1596
- >
1597
- <Pin :size="15" :fill="outlinePinned ? 'currentColor' : 'none'" />
1598
- </button>
1599
- </div>
1600
- <div v-if="outlineSearchOpen" class="outline-search">
1601
- <Search :size="14" aria-hidden="true" />
1602
- <input
1603
- :ref="(el) => { context.outlineSearchInput = (el as HTMLInputElement | null) ?? undefined; }"
1604
- v-model="outlineSearch"
1605
- type="search"
1606
- :aria-label="t('搜索当前文档标题')"
1607
- :placeholder="t('搜索标题')"
1608
- autocomplete="off"
1609
- @keydown.enter="visibleOutline[0] && jumpToHeading(visibleOutline[0].index, true)"
1610
- @keydown.esc.stop.prevent="toggleOutlineSearch"
1611
- />
1612
- </div>
1613
- <DocumentOutline :items="visibleOutline" :has-headings="!!outline.length" :active-index="activeHeading" @select="jumpToHeading($event, true)" />
1614
- </template>
1615
- </div>
1616
- </aside>
1617
- </div>
1618
- </div>
1619
- </template>
1620
- </WorkspacePanes>
453
+ <DocumentInspector
454
+ v-if="
455
+ active &&
456
+ !(assistant.opened && assistant.displayMode === 'sidebar') &&
457
+ !isAuxiliaryWindow &&
458
+ pane.id === store.activePaneId &&
459
+ (activeDocumentSidebarView ||
460
+ (showOutline && (!touchLayout || touchOutlineOpen)))
461
+ "
462
+ />
463
+ </div>
464
+ </div>
465
+ </template>
466
+ </WorkspacePanes>
1621
467
  </template>