@tano.page/workbench 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +50 -16
- package/src/App.vue +82 -752
- package/src/appearance/appearance.ts +14 -4
- package/src/appearance/components/ThemePresetPreview.vue +52 -8
- package/src/appearance/interface-font.ts +99 -0
- package/src/appearance/theme.ts +26 -10
- package/src/appearance/use-interface-font.ts +30 -0
- package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
- package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
- package/src/assets/mail-provider-icons/gmail.svg +1 -0
- package/src/assets/mail-provider-icons/icloud.svg +12 -0
- package/src/assets/mail-provider-icons/netease-126.svg +5 -0
- package/src/assets/mail-provider-icons/netease-163.svg +5 -0
- package/src/assets/mail-provider-icons/qq.svg +9 -0
- package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantChangeList.vue +98 -21
- package/src/assistant/components/AssistantPanel.vue +425 -8
- package/src/assistant/components/PluginToolProposalCard.vue +235 -0
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -532
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/files.ts +5 -13
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/inbox.ts +1 -148
- package/src/assistant/language.ts +10 -37
- package/src/assistant/mention-autocomplete.ts +69 -0
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -58
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/results.ts +20 -86
- package/src/assistant/store.ts +167 -327
- package/src/assistant/structures.ts +1 -155
- package/src/assistant/tasks.ts +8 -96
- package/src/assistant/tool-rules.ts +1 -7
- package/src/assistant/workspace-bridge.ts +1 -1
- package/src/composables/use-document-actions.ts +38 -20
- package/src/composables/use-file-tree-controller.ts +7 -12
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-history.ts +2 -4
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-modals.ts +6 -1
- package/src/composables/use-workbench-outline.ts +0 -5
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +40 -1021
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/data-tables/data-tables.ts +1 -2
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentHistoryPanel.vue +3 -1
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/features.ts +1 -0
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
- package/src/fonts/Inter-Latin.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
- package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
- package/src/help/help-milestones.ts +3 -5
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +371 -3
- package/src/i18n/locales/en-US.json +371 -2
- package/src/i18n/locales/es-ES.json +371 -3
- package/src/i18n/locales/ja-JP.json +370 -2
- package/src/i18n/locales/zh-TW.json +370 -2
- package/src/mail/components/MailAccountDialog.vue +450 -0
- package/src/mail/components/MailComposerDialog.vue +326 -0
- package/src/mail/components/MailProviderIcon.vue +30 -0
- package/src/mail/components/MailWorkspaceView.vue +821 -0
- package/src/mail/components/SidebarMail.vue +134 -0
- package/src/mail/mail-avatar.ts +17 -0
- package/src/mail/mail-bridge.ts +68 -0
- package/src/mail/mail-calendar.ts +208 -0
- package/src/mail/mail-markdown.ts +195 -0
- package/src/mail/types.ts +226 -0
- package/src/objects/components/ObjectDetailModal.vue +1001 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +3 -4
- package/src/plan-sync/types.ts +6 -3
- package/src/plans/calendar-interaction.ts +194 -0
- package/src/plans/calendar.ts +65 -9
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarDayPopover.vue +172 -39
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +264 -748
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanArchiveDialog.vue +295 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/PlanDateField.vue +6 -4
- package/src/plans/components/PlanDetailPanel.vue +227 -32
- package/src/plans/components/PlanEventList.vue +16 -4
- package/src/plans/components/SidebarPlan.vue +22 -15
- package/src/plans/components/TaskRepeatControls.vue +169 -30
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plans/local-reminders.ts +149 -0
- package/src/plans/personal-plans.ts +10 -1
- package/src/plans/plan-date.ts +8 -1
- package/src/plans/plan-migration.ts +95 -0
- package/src/plans/recurrence.ts +95 -0
- package/src/plans/task-repeat.ts +8 -8
- package/src/plans/timeline-layout.ts +92 -0
- package/src/plugins/assistant-bridge.ts +520 -0
- package/src/plugins/attachment-reader.ts +3 -1
- package/src/plugins/cache-storage.ts +42 -2
- package/src/plugins/components/PluginAutomations.vue +3 -3
- package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
- package/src/plugins/components/PluginChangeSummary.vue +16 -3
- package/src/plugins/components/PluginConnections.vue +1 -1
- package/src/plugins/components/PluginCustomView.vue +2 -2
- package/src/plugins/components/PluginDetailPage.vue +136 -57
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginDocumentSlot.vue +63 -0
- package/src/plugins/components/PluginExplorer.vue +21 -25
- package/src/plugins/components/PluginImportDialog.vue +410 -0
- package/src/plugins/components/PluginInstaller.vue +273 -288
- package/src/plugins/components/PluginListItem.vue +3 -0
- package/src/plugins/components/PluginMaintenance.vue +37 -34
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginRuntimePanel.vue +3 -3
- package/src/plugins/components/PluginSettingsForm.vue +112 -0
- package/src/plugins/components/PluginStatusBar.vue +161 -0
- package/src/plugins/components/PluginSurface.vue +18 -6
- package/src/plugins/components/PluginUiDialog.vue +452 -0
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
- package/src/plugins/excalidraw/manifest.json +12 -1
- package/src/plugins/host.ts +662 -43
- package/src/plugins/native.ts +2 -10
- package/src/plugins/overlay-mapping.ts +125 -0
- package/src/plugins/packages.ts +73 -1
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-permissions.ts +57 -0
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -94
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/policy.ts +53 -3
- package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/presentation-preview/manifest.json +2 -1
- package/src/plugins/queries.ts +1 -73
- package/src/plugins/sandbox.ts +15 -1
- package/src/plugins/use-plugin-actions.ts +67 -20
- package/src/plugins/user-plugins.ts +254 -0
- package/src/plugins/view-header.ts +2 -7
- package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
- package/src/plugins/word-preview/manifest.json +13 -1
- package/src/plugins/workbench.ts +175 -2
- package/src/plugins/worker.js +105 -8
- package/src/plugins/workspace-plugin-runtime.ts +23 -7
- package/src/plugins/workspace-plugins.ts +212 -21
- package/src/runtime.ts +103 -4
- package/src/settings/components/SettingsAppearancePage.vue +46 -0
- package/src/settings/components/SettingsDocumentsPage.vue +0 -1
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/components/settings-search.ts +2 -3
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/SidebarNavigation.vue +22 -2
- package/src/shell/components/WorkbenchContextMenus.vue +58 -34
- package/src/shell/components/WorkbenchModals.vue +47 -62
- package/src/shell/components/WorkbenchPanes.vue +371 -1342
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
- package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +531 -1153
- package/src/shell/workbench-async-components.ts +14 -5
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/mail.ts +414 -0
- package/src/stores/plan-sync.ts +2 -1
- package/src/stores/plans.ts +2 -9
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +2 -114
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +254 -259
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +6 -44
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +184 -1363
- package/src/styles/agent-diff-modals.css +0 -7
- package/src/styles/dark-theme.css +3 -3
- package/src/styles/inspector.css +0 -59
- package/src/styles/layout-themes.css +346 -0
- package/src/styles/mail.css +1568 -0
- package/src/styles/mobile.css +2 -2
- package/src/styles/recent-and-media.css +0 -17
- package/src/styles/theme-contract.css +3 -3
- package/src/styles/workbench-shell.css +110 -17
- package/src/styles/workspace-states.css +9 -33
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -14
- package/src/tabs/components/NewTabPicker.vue +10 -4
- package/src/tabs/tab-label.ts +0 -1
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
- package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/workspace/workspace-comments.ts +11 -151
- package/src/workspace/workspace-welcome.ts +1 -1
- package/src/assistant/locales/de-DE.json +0 -126
- package/src/assistant/locales/en-US.json +0 -126
- package/src/assistant/locales/es-ES.json +0 -126
- package/src/assistant/locales/ja-JP.json +0 -126
- package/src/assistant/locales/zh-CN.json +0 -126
- package/src/assistant/locales/zh-TW.json +0 -126
- package/src/assistant/task-prompts.json +0 -39
- package/src/documents/components/FormulaMenu.vue +0 -50
- package/src/files/components/FileDatabasePage.vue +0 -152
- package/src/files/components/FolderHomeIcon.vue +0 -12
- package/src/objects/components/ObjectDatabasePage.vue +0 -100
- package/src/objects/components/ObjectPanel.vue +0 -554
- package/src/plans/components/PersonalPlanDialog.vue +0 -105
- package/src/shell/components/WorkspaceViewPage.vue +0 -127
- package/src/shell/components/WorkspaceViewTab.vue +0 -24
- package/src/styles/object-panel.css +0 -163
- package/src/workspace/components/GitInspectionPanel.vue +0 -35
- package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
- package/src/workspace/welcome-slogans.ts +0 -11
- package/src/workspace/workspace-git.ts +0 -35
- package/src/workspace/workspace-sync.ts +0 -46
- package/src/workspace/workspace-views.ts +0 -48
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { computed, watch, type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
import {
|
|
3
|
+
type FileEntry,
|
|
4
|
+
type FileRegistry,
|
|
5
|
+
type FileSnapshot,
|
|
6
|
+
type Workspace,
|
|
7
|
+
type WorkspaceAdapter,
|
|
8
|
+
type WorkspaceLayout,
|
|
9
|
+
type WorkspaceSession,
|
|
10
|
+
} from '@tano/protocol';
|
|
11
|
+
import type { createDataTableController } from '../data-tables/data-table-controller';
|
|
12
|
+
import { isTableTab, tableFileId, tableTabId } from '../data-tables/data-tables';
|
|
13
|
+
import type { useDocumentIndex } from '../documents/document-index';
|
|
14
|
+
import { documentDirty as dirty, type OpenDocument } from '../documents/document-session';
|
|
15
|
+
import { layoutPanes, restoreLayout } from '../shell/pane-layout';
|
|
16
|
+
import { SessionJournal } from '../shell/session-journal';
|
|
17
|
+
import type { createWorkspaceTabsLayout } from './workspace-tabs-layout';
|
|
18
|
+
import type { Activity, WorkspaceLoadingState } from './workspace-types';
|
|
19
|
+
|
|
20
|
+
export interface WorkspaceSessionDeps {
|
|
21
|
+
adapter: WorkspaceAdapter;
|
|
22
|
+
workspace: Ref<Workspace | null>;
|
|
23
|
+
fileRegistry: Ref<FileRegistry | null>;
|
|
24
|
+
documents: Ref<OpenDocument[]>;
|
|
25
|
+
documentIndex: ReturnType<typeof useDocumentIndex>;
|
|
26
|
+
dataTables: ReturnType<typeof createDataTableController>;
|
|
27
|
+
tabsLayout: ReturnType<typeof createWorkspaceTabsLayout>;
|
|
28
|
+
tabIds: Ref<string[]>;
|
|
29
|
+
tabAliases: Ref<Map<string, string>>;
|
|
30
|
+
activeId: Ref<string>;
|
|
31
|
+
workspaceLoading: Ref<WorkspaceLoadingState>;
|
|
32
|
+
restoringDocuments: Ref<Record<string, string>>;
|
|
33
|
+
sessionError: Ref<string>;
|
|
34
|
+
dataTableFileId: (id: string) => string;
|
|
35
|
+
loadWorkspacePart: (part: keyof WorkspaceLoadingState, load: () => Promise<unknown>) => Promise<void>;
|
|
36
|
+
readOpenDocument: (file: FileEntry) => Promise<OpenDocument>;
|
|
37
|
+
openInternal: (file: FileEntry, replaceId?: string, current?: () => boolean) => Promise<void>;
|
|
38
|
+
hydrateDocumentLayout: (doc: OpenDocument) => Promise<void>;
|
|
39
|
+
reconcile: (doc: OpenDocument, snapshot: FileSnapshot) => Promise<void>;
|
|
40
|
+
saveInternal: (doc: OpenDocument) => Promise<void>;
|
|
41
|
+
activity: (label: string, detail: string, kind: Activity['kind'], change?: Activity['change']) => void;
|
|
42
|
+
report: (error: unknown) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function createWorkspaceSession(deps: WorkspaceSessionDeps) {
|
|
46
|
+
const {
|
|
47
|
+
adapter,
|
|
48
|
+
workspace,
|
|
49
|
+
fileRegistry,
|
|
50
|
+
documents,
|
|
51
|
+
documentIndex,
|
|
52
|
+
dataTables,
|
|
53
|
+
tabsLayout,
|
|
54
|
+
tabIds,
|
|
55
|
+
tabAliases,
|
|
56
|
+
activeId,
|
|
57
|
+
workspaceLoading,
|
|
58
|
+
restoringDocuments,
|
|
59
|
+
sessionError,
|
|
60
|
+
dataTableFileId,
|
|
61
|
+
loadWorkspacePart,
|
|
62
|
+
readOpenDocument,
|
|
63
|
+
openInternal,
|
|
64
|
+
hydrateDocumentLayout,
|
|
65
|
+
reconcile,
|
|
66
|
+
saveInternal,
|
|
67
|
+
activity,
|
|
68
|
+
report,
|
|
69
|
+
} = deps;
|
|
70
|
+
|
|
71
|
+
let sessionReady = false;
|
|
72
|
+
let sessionBlocked = false;
|
|
73
|
+
|
|
74
|
+
const journal = new SessionJournal(
|
|
75
|
+
(id, session) => adapter.saveSession!(id, session),
|
|
76
|
+
(error) => {
|
|
77
|
+
sessionError.value =
|
|
78
|
+
error === undefined
|
|
79
|
+
? ''
|
|
80
|
+
: `恢复草稿未写入:${String(error)}。文档仍会尝试正常保存。`;
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// Track only recoverable fields. Saving/error flags, undo stacks and plugin
|
|
85
|
+
// state must not traverse/rewrite every open document on the input path.
|
|
86
|
+
const recoveryDocuments = new WeakMap<
|
|
87
|
+
OpenDocument,
|
|
88
|
+
ComputedRef<WorkspaceSession['documents'][number]>
|
|
89
|
+
>();
|
|
90
|
+
const mainTabIds = computed(() =>
|
|
91
|
+
layoutPanes(tabsLayout.layout.value).flatMap((pane) => pane.tabs),
|
|
92
|
+
);
|
|
93
|
+
const sessionDocuments = computed(() =>
|
|
94
|
+
documents.value
|
|
95
|
+
.filter((doc) => mainTabIds.value.some((id) => tabsLayout.tabTarget(id) === doc.id))
|
|
96
|
+
.map((doc) => {
|
|
97
|
+
let snapshot = recoveryDocuments.get(doc);
|
|
98
|
+
if (!snapshot) {
|
|
99
|
+
snapshot = computed(() => ({
|
|
100
|
+
id: doc.id,
|
|
101
|
+
path: doc.path,
|
|
102
|
+
...(dirty(doc) ? { draft: { content: doc.content, base: { ...doc.base } } } : {}),
|
|
103
|
+
}));
|
|
104
|
+
recoveryDocuments.set(doc, snapshot);
|
|
105
|
+
}
|
|
106
|
+
return snapshot.value;
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
const sessionTables = computed(() =>
|
|
110
|
+
dataTables
|
|
111
|
+
.drafts()
|
|
112
|
+
.filter((draft) =>
|
|
113
|
+
mainTabIds.value.some(
|
|
114
|
+
(id) => tableFileId(tabsLayout.tabTarget(id)) === (draft.fileId ?? draft.id),
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
const sessionLayout = computed(
|
|
119
|
+
() => JSON.parse(JSON.stringify(tabsLayout.layout.value)) as WorkspaceLayout,
|
|
120
|
+
);
|
|
121
|
+
const sessionPayload = computed<WorkspaceSession>(() => ({
|
|
122
|
+
version: 1,
|
|
123
|
+
activeId:
|
|
124
|
+
layoutPanes(tabsLayout.layout.value).find(
|
|
125
|
+
(pane) => pane.id === tabsLayout.windowLayouts.value.main.activePaneId,
|
|
126
|
+
)?.activeId ?? '',
|
|
127
|
+
tabs: [...new Set(mainTabIds.value.map(tabsLayout.tabTarget))],
|
|
128
|
+
layout: sessionLayout.value,
|
|
129
|
+
dataTables: sessionTables.value,
|
|
130
|
+
documents: sessionDocuments.value,
|
|
131
|
+
}));
|
|
132
|
+
|
|
133
|
+
function queueSession() {
|
|
134
|
+
if (!sessionReady || sessionBlocked || !workspace.value || !adapter.saveSession) return;
|
|
135
|
+
journal.enqueue(workspace.value.id, sessionPayload.value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const stopSessionWatch = watch(sessionPayload, queueSession, {
|
|
139
|
+
flush: 'sync',
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
async function openInitialDocument(file: FileEntry) {
|
|
143
|
+
restoringDocuments.value = { ...restoringDocuments.value, [file.id]: file.path };
|
|
144
|
+
tabIds.value = [file.id];
|
|
145
|
+
activeId.value = file.id;
|
|
146
|
+
workspaceLoading.value.session = false;
|
|
147
|
+
try {
|
|
148
|
+
await openInternal(file);
|
|
149
|
+
} finally {
|
|
150
|
+
delete restoringDocuments.value[file.id];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function restoreSession(
|
|
155
|
+
saved: WorkspaceSession,
|
|
156
|
+
tablesReady: Promise<void>,
|
|
157
|
+
objectsReady: Promise<void>,
|
|
158
|
+
) {
|
|
159
|
+
tabAliases.value = new Map();
|
|
160
|
+
const remapped = new Map<string, string>();
|
|
161
|
+
const pendingDocs = saved.documents.flatMap((tab) => {
|
|
162
|
+
const file = fileRegistry.value?.get(tab.id) ?? fileRegistry.value?.at(tab.path);
|
|
163
|
+
if (!file && !tab.draft) return [];
|
|
164
|
+
const id = file?.id ?? tab.id;
|
|
165
|
+
remapped.set(tab.id, id);
|
|
166
|
+
return [{ tab, file, id }];
|
|
167
|
+
});
|
|
168
|
+
restoringDocuments.value = Object.fromEntries(
|
|
169
|
+
pendingDocs.map(({ tab, file, id }) => [id, file?.path ?? tab.path]),
|
|
170
|
+
);
|
|
171
|
+
const planned = new Set(pendingDocs.map(({ id }) => id));
|
|
172
|
+
const requested = (saved.tabs ?? []).map((id) => remapped.get(id) ?? id);
|
|
173
|
+
tabIds.value = [
|
|
174
|
+
...new Set([
|
|
175
|
+
...requested.filter(
|
|
176
|
+
(id) =>
|
|
177
|
+
planned.has(id) ||
|
|
178
|
+
tabsLayout.isUtilityTab(id) ||
|
|
179
|
+
id.startsWith('plugin:'),
|
|
180
|
+
),
|
|
181
|
+
...planned,
|
|
182
|
+
]),
|
|
183
|
+
];
|
|
184
|
+
const restoredActive = remapped.get(saved.activeId) ?? saved.activeId;
|
|
185
|
+
tabsLayout.layout.value = restoreLayout(saved.layout, tabIds.value, remapped);
|
|
186
|
+
tabsLayout.activePaneId.value =
|
|
187
|
+
tabsLayout.panes.value.find((pane) => pane.tabs.includes(restoredActive))?.id ??
|
|
188
|
+
tabsLayout.panes.value[0].id;
|
|
189
|
+
activeId.value = tabIds.value.includes(restoredActive)
|
|
190
|
+
? restoredActive
|
|
191
|
+
: (tabIds.value[0] ?? '');
|
|
192
|
+
workspaceLoading.value.session = false;
|
|
193
|
+
|
|
194
|
+
const visible = new Set(tabsLayout.panes.value.map((pane) => pane.activeId));
|
|
195
|
+
const tableRecovery = (async () => {
|
|
196
|
+
await tablesReady;
|
|
197
|
+
if (saved.dataTables?.length) {
|
|
198
|
+
workspaceLoading.value.tables = true;
|
|
199
|
+
await loadWorkspacePart('tables', () => dataTables.restore(saved.dataTables!));
|
|
200
|
+
}
|
|
201
|
+
})();
|
|
202
|
+
|
|
203
|
+
const restoreDocument = async ({ tab, file, id }: (typeof pendingDocs)[number]) => {
|
|
204
|
+
try {
|
|
205
|
+
if (!tab.draft) {
|
|
206
|
+
if (file) {
|
|
207
|
+
const doc = await readOpenDocument(file);
|
|
208
|
+
if (!documentIndex.byId.value.has(id)) documents.value.push(doc);
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const doc: OpenDocument = {
|
|
213
|
+
id: file?.id ?? tab.id,
|
|
214
|
+
path: file?.path ?? tab.path,
|
|
215
|
+
content: tab.draft.content,
|
|
216
|
+
base: tab.draft.base,
|
|
217
|
+
saving: false,
|
|
218
|
+
creating: file?.pendingCreation,
|
|
219
|
+
missing: !file,
|
|
220
|
+
};
|
|
221
|
+
if (!doc.creating) await hydrateDocumentLayout(doc);
|
|
222
|
+
documents.value.push(doc);
|
|
223
|
+
activity('已恢复未保存草稿', doc.path, 'file');
|
|
224
|
+
if (file) {
|
|
225
|
+
try {
|
|
226
|
+
if (!doc.creating) await reconcile(doc, await adapter.read(file.path));
|
|
227
|
+
await saveInternal(documentIndex.byId.value.get(doc.id)!);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
doc.error = String(error);
|
|
230
|
+
report(error);
|
|
231
|
+
}
|
|
232
|
+
} else doc.error = '原文件已不存在,恢复草稿已保留,请另存副本';
|
|
233
|
+
} catch (error) {
|
|
234
|
+
report(error);
|
|
235
|
+
} finally {
|
|
236
|
+
delete restoringDocuments.value[id];
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const priority = (id: string) => (id === restoredActive ? 2 : Number(visible.has(id)));
|
|
241
|
+
const queue = [...pendingDocs].sort((a, b) => priority(b.id) - priority(a.id));
|
|
242
|
+
const worker = async () => {
|
|
243
|
+
for (let next = queue.shift(); next; next = queue.shift()) await restoreDocument(next);
|
|
244
|
+
};
|
|
245
|
+
await Promise.all([
|
|
246
|
+
tableRecovery,
|
|
247
|
+
objectsReady,
|
|
248
|
+
...Array.from({ length: Math.min(4, queue.length) }, worker),
|
|
249
|
+
]);
|
|
250
|
+
|
|
251
|
+
for (const id of saved.tabs ?? [])
|
|
252
|
+
if (isTableTab(id))
|
|
253
|
+
remapped.set(id, tableTabId(dataTableFileId(tableFileId(id))));
|
|
254
|
+
const byId = new Map(documents.value.map((doc) => [doc.id, doc]));
|
|
255
|
+
documents.value = pendingDocs
|
|
256
|
+
.map(({ id }) => byId.get(id))
|
|
257
|
+
.filter((doc): doc is OpenDocument => !!doc);
|
|
258
|
+
const restored = saved.tabs
|
|
259
|
+
?.map((id) => remapped.get(id) ?? id)
|
|
260
|
+
.filter(
|
|
261
|
+
(id) =>
|
|
262
|
+
tabsLayout.isUtilityTab(id) || documents.value.some((doc) => doc.id === id),
|
|
263
|
+
);
|
|
264
|
+
tabIds.value = [...new Set([...(restored ?? []), ...documents.value.map((doc) => doc.id)])];
|
|
265
|
+
const currentActive = remapped.get(activeId.value) ?? activeId.value;
|
|
266
|
+
tabsLayout.layout.value = restoreLayout(tabsLayout.layout.value, tabIds.value, remapped);
|
|
267
|
+
tabsLayout.activePaneId.value =
|
|
268
|
+
tabsLayout.panes.value.find((pane) => pane.tabs.includes(currentActive))?.id ??
|
|
269
|
+
tabsLayout.panes.value[0].id;
|
|
270
|
+
activeId.value = tabIds.value.includes(currentActive)
|
|
271
|
+
? currentActive
|
|
272
|
+
: (tabIds.value[0] ?? '');
|
|
273
|
+
for (const tabId of tabIds.value) tabsLayout.ensureTabNavigation(tabId, tabId);
|
|
274
|
+
tabsLayout.touchNavigation();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
journal,
|
|
279
|
+
isReady: () => sessionReady,
|
|
280
|
+
setReady: (ready: boolean) => { sessionReady = ready; },
|
|
281
|
+
setBlocked: (blocked: boolean) => { sessionBlocked = blocked; },
|
|
282
|
+
queueSession,
|
|
283
|
+
stopSessionWatch,
|
|
284
|
+
openInitialDocument,
|
|
285
|
+
restoreSession,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
@@ -17,7 +17,7 @@ import { recordHelpCompleted } from '../help/help-checklist';
|
|
|
17
17
|
import { t } from '../i18n/i18n';
|
|
18
18
|
import { dockLayout, layoutPanes, reconcileLayout, type PaneDrop } from '../shell/pane-layout';
|
|
19
19
|
import { bundledPluginCatalog } from '../plugins/plugin-catalog';
|
|
20
|
-
import {
|
|
20
|
+
import { isPluginPreviewTab, type PluginWorkbenchView } from '../plugins/workbench';
|
|
21
21
|
import type { WorkbenchViewTab } from '../runtime';
|
|
22
22
|
import { useTabNavigation } from '../tabs/tab-navigation';
|
|
23
23
|
import {
|
|
@@ -28,8 +28,7 @@ import {
|
|
|
28
28
|
type WindowLayouts,
|
|
29
29
|
} from '../windows/layout';
|
|
30
30
|
import { PLUGINS_TAB_ID, type InstalledObjectPlugin } from '../plugins/workspace-plugins';
|
|
31
|
-
import type {
|
|
32
|
-
import type { DocumentTab } from './workspace';
|
|
31
|
+
import type { DocumentTab } from './workspace-types';
|
|
33
32
|
|
|
34
33
|
export interface WorkspaceTabsLayoutDeps {
|
|
35
34
|
workspace: Ref<Workspace | null>;
|
|
@@ -37,7 +36,6 @@ export interface WorkspaceTabsLayoutDeps {
|
|
|
37
36
|
documents: Ref<OpenDocument[]>;
|
|
38
37
|
documentIndex: ReturnType<typeof useDocumentIndex>;
|
|
39
38
|
dataTables: ReturnType<typeof createDataTableController>;
|
|
40
|
-
workspaceViews: Ref<WorkspaceViewRecord[]>;
|
|
41
39
|
installedPlugins: Ref<InstalledObjectPlugin[]>;
|
|
42
40
|
pluginViews: Ref<PluginWorkbenchView[]>;
|
|
43
41
|
activePluginSidebar: Ref<string>;
|
|
@@ -48,7 +46,6 @@ export interface WorkspaceTabsLayoutDeps {
|
|
|
48
46
|
tables: boolean;
|
|
49
47
|
plugins: boolean;
|
|
50
48
|
objects: boolean;
|
|
51
|
-
views: boolean;
|
|
52
49
|
relations: boolean;
|
|
53
50
|
capabilities: boolean;
|
|
54
51
|
}>;
|
|
@@ -79,7 +76,6 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
79
76
|
documents,
|
|
80
77
|
documentIndex,
|
|
81
78
|
dataTables,
|
|
82
|
-
workspaceViews,
|
|
83
79
|
installedPlugins,
|
|
84
80
|
pluginViews,
|
|
85
81
|
activePluginSidebar,
|
|
@@ -99,15 +95,6 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
99
95
|
} = deps;
|
|
100
96
|
|
|
101
97
|
const views = shallowRef<ReadonlyMap<string, WorkbenchViewTab>>(new Map());
|
|
102
|
-
const workspaceViewTabPrefix = 'workspace-view:';
|
|
103
|
-
const workspaceViewTabId = (id: string) => `${workspaceViewTabPrefix}${id}`;
|
|
104
|
-
const workspaceViewId = (id: string) =>
|
|
105
|
-
id.startsWith(workspaceViewTabPrefix) ? id.slice(workspaceViewTabPrefix.length) : undefined;
|
|
106
|
-
const isWorkspaceViewTab = (id: string) => !!workspaceViewId(id);
|
|
107
|
-
const hasWorkspaceViewTab = (id: string) => {
|
|
108
|
-
const viewId = workspaceViewId(id);
|
|
109
|
-
return viewId !== undefined && workspaceViews.value.some((record) => record.view.id === viewId);
|
|
110
|
-
};
|
|
111
98
|
const isDirectoryTab = (id: string) => id.startsWith('directory:');
|
|
112
99
|
function directoryForTab(id: string) {
|
|
113
100
|
if (!isDirectoryTab(id)) return undefined;
|
|
@@ -126,8 +113,6 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
126
113
|
? (installedPlugins.value.find((item) => `plugin:${item.manifest.id}` === id)?.manifest ??
|
|
127
114
|
bundledPluginCatalog.find((item) => `plugin:${item.manifest.id}` === id)?.manifest)
|
|
128
115
|
: undefined;
|
|
129
|
-
const wordPreviewTab = pluginViewKey('word-preview', 'document');
|
|
130
|
-
const presentationPreviewTab = pluginViewKey('presentation-preview', 'slides');
|
|
131
116
|
const attachmentForTab = (id: string) =>
|
|
132
117
|
id.startsWith('attachment:') ? fileRegistry.value?.get(id.slice('attachment:'.length)) : undefined;
|
|
133
118
|
const isNavigationPage = (id: string) =>
|
|
@@ -136,10 +121,8 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
136
121
|
id === GRAPH_TAB_ID ||
|
|
137
122
|
id === PLUGINS_TAB_ID ||
|
|
138
123
|
isTableTab(id) ||
|
|
139
|
-
hasWorkspaceViewTab(id) ||
|
|
140
124
|
id.startsWith('attachment:') ||
|
|
141
|
-
id
|
|
142
|
-
id === presentationPreviewTab;
|
|
125
|
+
isPluginPreviewTab(id, installedPlugins.value);
|
|
143
126
|
const isBuiltinTab = (id: string) =>
|
|
144
127
|
isDirectoryTab(id) ||
|
|
145
128
|
id.startsWith('blank:') ||
|
|
@@ -148,8 +131,7 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
148
131
|
id === GRAPH_TAB_ID ||
|
|
149
132
|
id === PLUGINS_TAB_ID ||
|
|
150
133
|
id === CALENDAR_TAB_ID ||
|
|
151
|
-
isTableTab(id)
|
|
152
|
-
hasWorkspaceViewTab(id);
|
|
134
|
+
isTableTab(id);
|
|
153
135
|
const isUtilityTab = (id: string) =>
|
|
154
136
|
isBuiltinTab(id) ||
|
|
155
137
|
views.value.has(id) ||
|
|
@@ -393,7 +375,7 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
393
375
|
busy: () => busy.value,
|
|
394
376
|
available: (id) => {
|
|
395
377
|
if (id.startsWith('attachment:')) return !!attachmentForTab(id);
|
|
396
|
-
if (id
|
|
378
|
+
if (isPluginPreviewTab(id, installedPlugins.value))
|
|
397
379
|
return pluginViews.value.some((view) => view.key === id);
|
|
398
380
|
const file = fileRegistry.value?.get(id);
|
|
399
381
|
return (
|
|
@@ -455,18 +437,6 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
455
437
|
if (!definitions.some((view) => view.location === 'sidebar' && view.key === activePluginSidebar.value))
|
|
456
438
|
activePluginSidebar.value = '';
|
|
457
439
|
});
|
|
458
|
-
watch(workspaceViews, (definitions) => {
|
|
459
|
-
if (workspaceLoading.value.views) return;
|
|
460
|
-
const keys = new Set(definitions.map((record) => workspaceViewTabId(record.view.id)));
|
|
461
|
-
const remaining = tabIds.value.filter((id) => !isWorkspaceViewTab(id) || keys.has(id));
|
|
462
|
-
if (remaining.length !== tabIds.value.length) {
|
|
463
|
-
for (const id of tabIds.value) if (!remaining.includes(id)) removeTabNavigation(id);
|
|
464
|
-
tabIds.value = remaining;
|
|
465
|
-
if (isWorkspaceViewTab(activeId.value) && !keys.has(activeId.value))
|
|
466
|
-
activeId.value = tabIds.value[0] ?? '';
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
|
|
470
440
|
const active = computed(() => documentIndex.byId.value.get(tabTarget(activeId.value)));
|
|
471
441
|
const tabs = computed<DocumentTab[]>(() =>
|
|
472
442
|
tabIds.value.map((id) => {
|
|
@@ -483,9 +453,6 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
483
453
|
: undefined;
|
|
484
454
|
const tablePath = tableFile ? displayPath(tableFile) : table?.path;
|
|
485
455
|
const directory = directoryForTab(targetId);
|
|
486
|
-
const workspaceView = workspaceViews.value.find(
|
|
487
|
-
(record) => workspaceViewTabId(record.view.id) === targetId,
|
|
488
|
-
);
|
|
489
456
|
return {
|
|
490
457
|
id,
|
|
491
458
|
pluginDetail: pluginDetailManifest(targetId),
|
|
@@ -499,13 +466,12 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
499
466
|
? displayPath(attachment)
|
|
500
467
|
: tableFile
|
|
501
468
|
? displayPath(tableFile)
|
|
502
|
-
: (
|
|
469
|
+
: (tablePath ?? (attachmentPreview ? '附件不可用' : '')))),
|
|
503
470
|
blank: id.startsWith('blank:'),
|
|
504
471
|
graph: id === GRAPH_TAB_ID,
|
|
505
472
|
plugins: id === PLUGINS_TAB_ID,
|
|
506
473
|
calendar: id === CALENDAR_TAB_ID,
|
|
507
474
|
view: views.value.get(id),
|
|
508
|
-
workspaceView,
|
|
509
475
|
pluginView: pluginViews.value.find((view) => view.key === id && view.location === 'tab'),
|
|
510
476
|
document,
|
|
511
477
|
attachmentPreview,
|
|
@@ -643,11 +609,7 @@ export function createWorkspaceTabsLayout(deps: WorkspaceTabsLayoutDeps) {
|
|
|
643
609
|
|
|
644
610
|
return {
|
|
645
611
|
views,
|
|
646
|
-
workspaceViewTabId,
|
|
647
|
-
isWorkspaceViewTab,
|
|
648
612
|
pluginDetailManifest,
|
|
649
|
-
wordPreviewTab,
|
|
650
|
-
presentationPreviewTab,
|
|
651
613
|
attachmentForTab,
|
|
652
614
|
isNavigationPage,
|
|
653
615
|
isUtilityTab,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { FileEntry, PluginManifest } from '@tano/protocol';
|
|
2
|
+
import type { OpenDocument } from '../documents/document-session';
|
|
3
|
+
import type { PluginWorkbenchView } from '../plugins/workbench';
|
|
4
|
+
import type { WorkbenchViewTab } from '../runtime';
|
|
5
|
+
|
|
6
|
+
export type { OpenDocument } from '../documents/document-session';
|
|
7
|
+
|
|
8
|
+
export interface DocumentTab {
|
|
9
|
+
id: string;
|
|
10
|
+
path: string;
|
|
11
|
+
blank: boolean;
|
|
12
|
+
graph: boolean;
|
|
13
|
+
plugins: boolean;
|
|
14
|
+
calendar: boolean;
|
|
15
|
+
view?: WorkbenchViewTab;
|
|
16
|
+
directory?: { path: string; name: string; missing: boolean };
|
|
17
|
+
pluginView?: PluginWorkbenchView;
|
|
18
|
+
pluginDetail?: PluginManifest;
|
|
19
|
+
document?: OpenDocument;
|
|
20
|
+
attachmentPreview: boolean;
|
|
21
|
+
attachment?: FileEntry;
|
|
22
|
+
dataTable?: { name: string; dirty: boolean; icon?: string };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface Activity {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
detail: string;
|
|
29
|
+
time: number;
|
|
30
|
+
kind: 'external' | 'save' | 'conflict' | 'file';
|
|
31
|
+
change?: { before: string; after: string };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface WorkspaceLoadingState {
|
|
35
|
+
files: boolean;
|
|
36
|
+
session: boolean;
|
|
37
|
+
settings: boolean;
|
|
38
|
+
tables: boolean;
|
|
39
|
+
plugins: boolean;
|
|
40
|
+
objects: boolean;
|
|
41
|
+
relations: boolean;
|
|
42
|
+
capabilities: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface WorkspaceLifecycleHooks {
|
|
46
|
+
beforeSwitch?: () => Promise<void>;
|
|
47
|
+
beforeWorkspaceChange?: () => Promise<void>;
|
|
48
|
+
afterSwitch?: () => Promise<void>;
|
|
49
|
+
beforeCloseDocument?: (id: string) => Promise<void>;
|
|
50
|
+
}
|