@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.
- package/package.json +35 -14
- package/src/App.vue +68 -797
- 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/AssistantPanel.vue +1 -1
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -585
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/language.ts +10 -37
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -65
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/store.ts +87 -554
- package/src/assistant/structures.ts +1 -157
- package/src/assistant/tasks.ts +8 -94
- package/src/assistant/tool-rules.ts +1 -7
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +37 -1022
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- 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/files/components/FileMetadataPanel.vue +49 -15
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +23 -1
- package/src/i18n/locales/en-US.json +23 -1
- package/src/i18n/locales/es-ES.json +23 -1
- package/src/i18n/locales/ja-JP.json +23 -1
- package/src/i18n/locales/zh-TW.json +23 -1
- package/src/mail/components/MailAccountDialog.vue +1 -0
- package/src/mail/components/MailComposerDialog.vue +1 -0
- package/src/mail/components/MailWorkspaceView.vue +1 -0
- package/src/mail/components/SidebarMail.vue +1 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +2 -3
- package/src/plans/calendar.ts +2 -2
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- 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 +162 -2106
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- 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/plugins/components/PluginDetailPage.vue +10 -6
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginExplorer.vue +6 -4
- package/src/plugins/components/PluginImportDialog.vue +1 -1
- package/src/plugins/components/PluginInstaller.vue +269 -178
- package/src/plugins/components/PluginMaintenance.vue +37 -49
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginSettingsForm.vue +2 -1
- 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/plugin-data.ts +2 -3
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -260
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/queries.ts +1 -75
- package/src/plugins/view-header.ts +2 -7
- package/src/runtime.ts +3 -2
- 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/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/WorkbenchContextMenus.vue +37 -26
- package/src/shell/components/WorkbenchModals.vue +22 -18
- package/src/shell/components/WorkbenchPanes.vue +358 -1512
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- 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 +488 -1081
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +1 -1
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +71 -599
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +1 -1
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +163 -1345
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -11
- 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/WorkspaceIconPicker.vue +5 -4
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/assistant/locales/de-DE.json +0 -129
- package/src/assistant/locales/en-US.json +0 -129
- package/src/assistant/locales/es-ES.json +0 -129
- package/src/assistant/locales/ja-JP.json +0 -129
- package/src/assistant/locales/zh-CN.json +0 -129
- package/src/assistant/locales/zh-TW.json +0 -129
- package/src/assistant/task-prompts.json +0 -39
package/src/styles.css
CHANGED
|
@@ -28,7 +28,7 @@ import { useWorkspaceStore, type DocumentTab } from '../../stores/workspace';
|
|
|
28
28
|
import { appearanceText } from '../../documents/document-appearance';
|
|
29
29
|
import { useWindowContext } from '../../windows/context';
|
|
30
30
|
import type { DetachedDropPoint } from '../../windows/position';
|
|
31
|
-
import {
|
|
31
|
+
import { workbenchPrefsKey } from '../../shell/workbench-context';
|
|
32
32
|
import { useDesktopTabLayout } from '../../composables/use-desktop-tab-layout';
|
|
33
33
|
import { useDesktopTabDrag } from '../../composables/use-desktop-tab-drag';
|
|
34
34
|
import { useDesktopTabMenu } from '../../composables/use-desktop-tab-menu';
|
|
@@ -38,14 +38,20 @@ import ButtonVisibilityGroup from '../../shell/components/ButtonVisibilityGroup.
|
|
|
38
38
|
import WorkspaceIcon from '../../workspace/components/WorkspaceIcon.vue';
|
|
39
39
|
import ResourceIcon from '../../files/components/ResourceIcon.vue';
|
|
40
40
|
|
|
41
|
-
const props =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
41
|
+
const props = withDefaults(
|
|
42
|
+
defineProps<{
|
|
43
|
+
loading?: boolean;
|
|
44
|
+
detachable?: boolean;
|
|
45
|
+
paneId?: string;
|
|
46
|
+
showNavigation?: boolean;
|
|
47
|
+
fileDrag?: { workspaceId: string; ids: readonly string[] };
|
|
48
|
+
assistantTab?: { id: string; title: string };
|
|
49
|
+
developerMode?: boolean;
|
|
50
|
+
}>(),
|
|
51
|
+
{
|
|
52
|
+
developerMode: undefined,
|
|
53
|
+
},
|
|
54
|
+
);
|
|
49
55
|
|
|
50
56
|
const emit = defineEmits<{
|
|
51
57
|
'new-tab': [];
|
|
@@ -55,8 +61,10 @@ const emit = defineEmits<{
|
|
|
55
61
|
}>();
|
|
56
62
|
|
|
57
63
|
const store = useWorkspaceStore();
|
|
58
|
-
const
|
|
59
|
-
const canOpenDevtools = computed(
|
|
64
|
+
const workbenchPrefs = inject(workbenchPrefsKey, null);
|
|
65
|
+
const canOpenDevtools = computed(
|
|
66
|
+
() => !!nativeOs && !mobile && (props.developerMode ?? workbenchPrefs?.developerMode === true),
|
|
67
|
+
);
|
|
60
68
|
const windowContext = useWindowContext();
|
|
61
69
|
|
|
62
70
|
const navigationItems = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, inject, watch } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { workbenchShellKey } from '../shell/workbench-context';
|
|
4
4
|
import { layoutPanes } from '../shell/pane-layout';
|
|
5
5
|
import AppTooltip from '../shell/components/AppTooltip.vue';
|
|
6
6
|
import WorkbenchSettings from '../settings/components/WorkbenchSettings.vue';
|
|
@@ -8,7 +8,7 @@ import DesktopWindow from '../shell/components/DesktopWindow.vue';
|
|
|
8
8
|
import WorkbenchPanes from '../shell/components/WorkbenchPanes.vue';
|
|
9
9
|
import WindowScope from './WindowScope.vue';
|
|
10
10
|
|
|
11
|
-
const workbench = inject(
|
|
11
|
+
const workbench = inject(workbenchShellKey);
|
|
12
12
|
if (!workbench) throw new Error('Workbench context is required');
|
|
13
13
|
const entries = computed(() => [...workbench.auxiliaryWindows.entries.values()]);
|
|
14
14
|
watch(() => entries.value.map(entry => {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, watch, type Ref } from 'vue';
|
|
2
|
+
import { installInteractionMotion } from '@tano/editor/motion';
|
|
3
|
+
import type { useWorkspaceStore } from '../stores/workspace';
|
|
4
|
+
import type { WindowContext } from './context';
|
|
5
|
+
import type { useAuxiliaryWindows } from './manager';
|
|
6
|
+
|
|
7
|
+
export interface WindowEventBridgeDeps {
|
|
8
|
+
store: ReturnType<typeof useWorkspaceStore>;
|
|
9
|
+
auxiliaryWindows: ReturnType<typeof useAuxiliaryWindows>;
|
|
10
|
+
mainWindow: WindowContext;
|
|
11
|
+
activeWindow: Ref<WindowContext>;
|
|
12
|
+
isAuxiliaryWindow: boolean;
|
|
13
|
+
routeConfiguredEditorShortcut: (event: KeyboardEvent) => void;
|
|
14
|
+
handleWorkbenchShortcut: (event: KeyboardEvent) => void;
|
|
15
|
+
handlePageSearchShortcut: (event: KeyboardEvent) => void;
|
|
16
|
+
keydown: (event: KeyboardEvent) => void;
|
|
17
|
+
beforeUnload: (event: BeforeUnloadEvent) => void;
|
|
18
|
+
outsideClick: (event: MouseEvent) => void;
|
|
19
|
+
outsideContextMenu: (event: MouseEvent) => void;
|
|
20
|
+
dismissFileContextMenu: () => void;
|
|
21
|
+
closeDirectoryContextMenu: () => void;
|
|
22
|
+
dismissPageContextMenu: () => void;
|
|
23
|
+
closeOutlineContextMenu: () => void;
|
|
24
|
+
constrainSidebarToViewport: () => void;
|
|
25
|
+
mobileVisibility: () => Promise<void>;
|
|
26
|
+
mobileBack: (event: Event) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useWindowEventBridge(deps: WindowEventBridgeDeps) {
|
|
30
|
+
const {
|
|
31
|
+
store,
|
|
32
|
+
auxiliaryWindows,
|
|
33
|
+
mainWindow,
|
|
34
|
+
activeWindow,
|
|
35
|
+
isAuxiliaryWindow,
|
|
36
|
+
routeConfiguredEditorShortcut,
|
|
37
|
+
handleWorkbenchShortcut,
|
|
38
|
+
handlePageSearchShortcut,
|
|
39
|
+
keydown,
|
|
40
|
+
beforeUnload,
|
|
41
|
+
outsideClick,
|
|
42
|
+
outsideContextMenu,
|
|
43
|
+
dismissFileContextMenu,
|
|
44
|
+
closeDirectoryContextMenu,
|
|
45
|
+
dismissPageContextMenu,
|
|
46
|
+
closeOutlineContextMenu,
|
|
47
|
+
constrainSidebarToViewport,
|
|
48
|
+
mobileVisibility,
|
|
49
|
+
mobileBack,
|
|
50
|
+
} = deps;
|
|
51
|
+
|
|
52
|
+
function bindAuxiliaryEvents(context: WindowContext) {
|
|
53
|
+
const focus = () => {
|
|
54
|
+
activeWindow.value = context;
|
|
55
|
+
const paneId = store.windowLayouts[context.id]?.activePaneId;
|
|
56
|
+
if (paneId) store.focusPane(paneId);
|
|
57
|
+
};
|
|
58
|
+
const handlers: [string, EventListener, boolean][] = [
|
|
59
|
+
['focus', focus, true],
|
|
60
|
+
['pointerdown', focus, true],
|
|
61
|
+
['keydown', routeConfiguredEditorShortcut as EventListener, true],
|
|
62
|
+
['keydown', handleWorkbenchShortcut as EventListener, true],
|
|
63
|
+
['keydown', handlePageSearchShortcut as EventListener, true],
|
|
64
|
+
['keydown', keydown as EventListener, false],
|
|
65
|
+
['click', outsideClick as EventListener, false],
|
|
66
|
+
['contextmenu', outsideContextMenu as EventListener, false],
|
|
67
|
+
['scroll', dismissPageContextMenu, true],
|
|
68
|
+
['scroll', closeOutlineContextMenu, true],
|
|
69
|
+
['resize', dismissPageContextMenu, false],
|
|
70
|
+
['resize', closeOutlineContextMenu, false],
|
|
71
|
+
];
|
|
72
|
+
for (const [name, handler, capture] of handlers)
|
|
73
|
+
context.window.addEventListener(name, handler, capture);
|
|
74
|
+
const stopMotion = installInteractionMotion(context.document);
|
|
75
|
+
return () => {
|
|
76
|
+
for (const [name, handler, capture] of handlers)
|
|
77
|
+
context.window.removeEventListener(name, handler, capture);
|
|
78
|
+
stopMotion();
|
|
79
|
+
if (activeWindow.value === context) activeWindow.value = mainWindow;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const auxiliaryEventDisposers = new Map<string, () => void>();
|
|
84
|
+
watch(
|
|
85
|
+
() => [...auxiliaryWindows.entries.values()],
|
|
86
|
+
(entries) => {
|
|
87
|
+
for (const [id, dispose] of auxiliaryEventDisposers) {
|
|
88
|
+
if (!entries.some((entry) => entry.id === id)) {
|
|
89
|
+
dispose();
|
|
90
|
+
auxiliaryEventDisposers.delete(id);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (!auxiliaryEventDisposers.has(entry.id))
|
|
95
|
+
auxiliaryEventDisposers.set(entry.id, bindAuxiliaryEvents(entry.context));
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{ flush: 'sync' },
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const focusMain = () => {
|
|
102
|
+
activeWindow.value = mainWindow;
|
|
103
|
+
const paneId = store.windowLayouts.main.activePaneId;
|
|
104
|
+
if (paneId) store.focusPane(paneId);
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener('focus', focusMain);
|
|
107
|
+
window.addEventListener('pointerdown', focusMain, true);
|
|
108
|
+
|
|
109
|
+
onMounted(() => {
|
|
110
|
+
window.addEventListener('keydown', handleWorkbenchShortcut, true);
|
|
111
|
+
window.addEventListener('keydown', keydown);
|
|
112
|
+
window.addEventListener('keydown', handlePageSearchShortcut, true);
|
|
113
|
+
window.addEventListener('beforeunload', beforeUnload);
|
|
114
|
+
window.addEventListener('click', outsideClick);
|
|
115
|
+
window.addEventListener('contextmenu', outsideContextMenu);
|
|
116
|
+
window.addEventListener('scroll', dismissFileContextMenu, true);
|
|
117
|
+
window.addEventListener('scroll', closeDirectoryContextMenu, true);
|
|
118
|
+
window.addEventListener('scroll', dismissPageContextMenu, true);
|
|
119
|
+
window.addEventListener('scroll', closeOutlineContextMenu, true);
|
|
120
|
+
window.addEventListener('resize', dismissFileContextMenu);
|
|
121
|
+
window.addEventListener('resize', closeDirectoryContextMenu);
|
|
122
|
+
window.addEventListener('resize', dismissPageContextMenu);
|
|
123
|
+
window.addEventListener('resize', closeOutlineContextMenu);
|
|
124
|
+
if (!isAuxiliaryWindow) window.addEventListener('resize', constrainSidebarToViewport);
|
|
125
|
+
document.addEventListener('visibilitychange', mobileVisibility);
|
|
126
|
+
window.addEventListener('tano:back', mobileBack);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
onBeforeUnmount(() => {
|
|
130
|
+
window.removeEventListener('focus', focusMain);
|
|
131
|
+
window.removeEventListener('pointerdown', focusMain, true);
|
|
132
|
+
for (const dispose of auxiliaryEventDisposers.values()) dispose();
|
|
133
|
+
auxiliaryEventDisposers.clear();
|
|
134
|
+
window.removeEventListener('keydown', handleWorkbenchShortcut, true);
|
|
135
|
+
window.removeEventListener('keydown', keydown);
|
|
136
|
+
window.removeEventListener('keydown', handlePageSearchShortcut, true);
|
|
137
|
+
window.removeEventListener('beforeunload', beforeUnload);
|
|
138
|
+
window.removeEventListener('click', outsideClick);
|
|
139
|
+
window.removeEventListener('contextmenu', outsideContextMenu);
|
|
140
|
+
window.removeEventListener('scroll', dismissFileContextMenu, true);
|
|
141
|
+
window.removeEventListener('scroll', closeDirectoryContextMenu, true);
|
|
142
|
+
window.removeEventListener('scroll', dismissPageContextMenu, true);
|
|
143
|
+
window.removeEventListener('scroll', closeOutlineContextMenu, true);
|
|
144
|
+
window.removeEventListener('resize', dismissFileContextMenu);
|
|
145
|
+
window.removeEventListener('resize', closeDirectoryContextMenu);
|
|
146
|
+
window.removeEventListener('resize', dismissPageContextMenu);
|
|
147
|
+
window.removeEventListener('resize', closeOutlineContextMenu);
|
|
148
|
+
window.removeEventListener('resize', constrainSidebarToViewport);
|
|
149
|
+
document.removeEventListener('visibilitychange', mobileVisibility);
|
|
150
|
+
window.removeEventListener('tano:back', mobileBack);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
@@ -171,7 +171,7 @@ onMounted(async () => {
|
|
|
171
171
|
<div v-else class="template-custom-empty"><Files :size="26" /><div><strong>{{ t('把常用的内容,留作下一次的起点') }}</strong><p>{{ t('将文档保存为模板,在这个工作区重复使用。') }}</p></div><button class="template-button" :disabled="disabled" @click="edit(true)"><Plus :size="15" />{{ t('创建模板') }}</button></div>
|
|
172
172
|
</section>
|
|
173
173
|
<div v-if="!visibleBuiltins.length && !visibleCustom.length && (query.trim() || !['all', 'custom'].includes(category))" class="template-no-results" role="status"><Search :size="28" /><h2>{{ t('没有找到匹配的模板') }}</h2><p>{{ t('试试其他关键词,或查看全部模板。') }}</p><button class="template-button" @click="query = ''; category = 'all'">{{ t('查看全部模板') }}</button></div>
|
|
174
|
-
<p class="template-library-note">{{ t('内置模板与当前工作区模板
|
|
174
|
+
<p class="template-library-note">{{ t('内置模板与当前工作区模板') }}</p>
|
|
175
175
|
</template>
|
|
176
176
|
|
|
177
177
|
<template v-else-if="mode === 'edit'">
|
|
@@ -24,9 +24,10 @@ const props = withDefaults(defineProps<{
|
|
|
24
24
|
label?: string;
|
|
25
25
|
triggerClass?: string;
|
|
26
26
|
align?: 'start' | 'end';
|
|
27
|
+
allowIcons?: boolean;
|
|
27
28
|
allowUpload?: boolean;
|
|
28
29
|
extraTab?: WorkspaceIconPickerExtraTab;
|
|
29
|
-
}>(), { align: 'end', allowUpload: true });
|
|
30
|
+
}>(), { align: 'end', allowIcons: true, allowUpload: true });
|
|
30
31
|
const label = computed(() => props.label ?? t('工作区图标'));
|
|
31
32
|
const emit = defineEmits<{ select: [value: string]; upload: []; pasteImage: [file: File]; 'update:open': [value: boolean] }>();
|
|
32
33
|
const pickerId = useId();
|
|
@@ -46,7 +47,7 @@ const baseTabs = [
|
|
|
46
47
|
] as const;
|
|
47
48
|
const visibleTabs = computed(() => [
|
|
48
49
|
...(props.extraTab ? [{ id: props.extraTab.id, label: props.extraTab.label }] : []),
|
|
49
|
-
...baseTabs.filter(item => props.allowUpload || item.id !== 'upload'),
|
|
50
|
+
...baseTabs.filter(item => (props.allowIcons || item.id !== 'icons') && (props.allowUpload || item.id !== 'upload')),
|
|
50
51
|
]);
|
|
51
52
|
type Tab = string;
|
|
52
53
|
const tab = ref<Tab>('emoji');
|
|
@@ -118,8 +119,8 @@ async function toggle() {
|
|
|
118
119
|
if (props.disabled) return;
|
|
119
120
|
if (open.value) { close(); return; }
|
|
120
121
|
if (props.extraTab?.matches?.(props.icon)) tab.value = props.extraTab.id;
|
|
121
|
-
else if (props.icon.startsWith('icon:')) tab.value = 'icons';
|
|
122
|
-
else if ((!props.icon || props.icon.startsWith('data:')) && props.extraTab?.defaultOpen) tab.value = props.extraTab.id;
|
|
122
|
+
else if (props.allowIcons && props.icon.startsWith('icon:')) tab.value = 'icons';
|
|
123
|
+
else if ((!props.icon || props.icon.startsWith('data:') || (!props.allowIcons && props.icon.startsWith('icon:'))) && props.extraTab?.defaultOpen) tab.value = props.extraTab.id;
|
|
123
124
|
else tab.value = 'emoji';
|
|
124
125
|
query.value = ''; focusedIcon.value = '';
|
|
125
126
|
anchorRect = trigger.value?.getBoundingClientRect();
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inject, toRefs } from 'vue';
|
|
3
|
+
import {
|
|
4
|
+
ArrowDownToLine,
|
|
5
|
+
Check,
|
|
6
|
+
ChevronDown,
|
|
7
|
+
ChevronUp,
|
|
8
|
+
CircleHelp,
|
|
9
|
+
Files,
|
|
10
|
+
FolderOpen,
|
|
11
|
+
FolderPlus,
|
|
12
|
+
House,
|
|
13
|
+
Search,
|
|
14
|
+
Trash2,
|
|
15
|
+
} from 'lucide-vue-next';
|
|
16
|
+
import ShortcutHint from '@tano/editor/shortcut-hint';
|
|
17
|
+
import { vSurfaceMotion } from '@tano/editor/surface-motion';
|
|
18
|
+
import { t } from '../../i18n/i18n';
|
|
19
|
+
import { mobile } from '../../platform/platform';
|
|
20
|
+
import PluginMenu from '../../plugins/components/PluginMenu.vue';
|
|
21
|
+
import OpenWorkspaceIcon from '../../shell/components/OpenWorkspaceIcon.vue';
|
|
22
|
+
import WorkspaceMenuLayout from '../../shell/components/WorkspaceMenuLayout.vue';
|
|
23
|
+
import {
|
|
24
|
+
workbenchModalsKey,
|
|
25
|
+
workbenchPrefsKey,
|
|
26
|
+
workbenchShellKey,
|
|
27
|
+
workbenchTreeMenusKey,
|
|
28
|
+
} from '../../shell/workbench-context';
|
|
29
|
+
import WorkspaceIcon from './WorkspaceIcon.vue';
|
|
30
|
+
|
|
31
|
+
const shell = inject(workbenchShellKey);
|
|
32
|
+
const prefs = inject(workbenchPrefsKey);
|
|
33
|
+
const treeMenus = inject(workbenchTreeMenusKey);
|
|
34
|
+
const modals = inject(workbenchModalsKey);
|
|
35
|
+
if (!shell || !prefs || !treeMenus || !modals) throw new Error('Workbench context is required');
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
workspace,
|
|
39
|
+
store,
|
|
40
|
+
busy,
|
|
41
|
+
filesPending,
|
|
42
|
+
navigationContext,
|
|
43
|
+
workspaceMenu,
|
|
44
|
+
toggleWorkspaceMenu,
|
|
45
|
+
selectContext,
|
|
46
|
+
extensions,
|
|
47
|
+
extensionActions,
|
|
48
|
+
openImport,
|
|
49
|
+
openTemplateLibrary,
|
|
50
|
+
openSettings,
|
|
51
|
+
updates,
|
|
52
|
+
createNewWorkspace,
|
|
53
|
+
} = toRefs(shell);
|
|
54
|
+
const { shortcutHint } = toRefs(prefs);
|
|
55
|
+
const { workspaceDropdownContextMenu, openWorkspaceEntryContextMenu } = toRefs(treeMenus);
|
|
56
|
+
const { commandPaletteOpened, recyclePanel } = toRefs(modals);
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<div class="workspace-picker-wrap">
|
|
61
|
+
<button
|
|
62
|
+
class="workspace-picker"
|
|
63
|
+
:aria-expanded="workspaceMenu"
|
|
64
|
+
aria-controls="workspace-menu"
|
|
65
|
+
:aria-label="
|
|
66
|
+
filesPending
|
|
67
|
+
? t('正在打开工作区…')
|
|
68
|
+
: t('切换上下文:{0}', [
|
|
69
|
+
navigationContext === 'home' ? t('主页') : (workspace?.name ?? t('选择工作区')),
|
|
70
|
+
])
|
|
71
|
+
"
|
|
72
|
+
:data-tooltip="
|
|
73
|
+
filesPending
|
|
74
|
+
? t('正在打开工作区…')
|
|
75
|
+
: navigationContext === 'home'
|
|
76
|
+
? t('主页')
|
|
77
|
+
: (workspace?.name ?? t('选择工作区'))
|
|
78
|
+
"
|
|
79
|
+
@click="toggleWorkspaceMenu"
|
|
80
|
+
@contextmenu.stop.prevent="toggleWorkspaceMenu"
|
|
81
|
+
>
|
|
82
|
+
<span class="workspace-avatar">
|
|
83
|
+
<House v-if="navigationContext === 'home'" :size="15" />
|
|
84
|
+
<WorkspaceIcon
|
|
85
|
+
v-else
|
|
86
|
+
:icon="store.workspaceSettings.icon"
|
|
87
|
+
:mode="store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local'"
|
|
88
|
+
:size="15"
|
|
89
|
+
/>
|
|
90
|
+
</span>
|
|
91
|
+
<span class="workspace-picker-text">
|
|
92
|
+
<span v-if="filesPending" class="tano-skeleton-bar" />
|
|
93
|
+
<strong v-else>{{
|
|
94
|
+
navigationContext === 'home' ? t('主页') : (workspace?.name ?? t('选择工作区'))
|
|
95
|
+
}}</strong>
|
|
96
|
+
</span>
|
|
97
|
+
<component :is="workspaceMenu ? ChevronUp : ChevronDown" :size="12" />
|
|
98
|
+
</button>
|
|
99
|
+
<div
|
|
100
|
+
v-surface-motion="'App:3'"
|
|
101
|
+
v-if="workspaceMenu"
|
|
102
|
+
id="workspace-menu"
|
|
103
|
+
class="dropdown compact-action-menu sidebar-popover workspace-dropdown"
|
|
104
|
+
data-surface-role="popover"
|
|
105
|
+
@contextmenu.stop.prevent="workspaceDropdownContextMenu"
|
|
106
|
+
>
|
|
107
|
+
<button
|
|
108
|
+
class="context-menu-item"
|
|
109
|
+
type="button"
|
|
110
|
+
:aria-current="navigationContext === 'home' ? 'true' : undefined"
|
|
111
|
+
@click="selectContext('home')"
|
|
112
|
+
>
|
|
113
|
+
<House :size="16" /><span class="recent-name">{{ t('主页') }}</span>
|
|
114
|
+
<Check v-if="navigationContext === 'home'" :size="15" />
|
|
115
|
+
</button>
|
|
116
|
+
<div class="menu-divider" />
|
|
117
|
+
<PluginMenu location="workspace" @selected="workspaceMenu = false" />
|
|
118
|
+
<component
|
|
119
|
+
:is="extensions.regions['workspace-menu-layout'] ?? WorkspaceMenuLayout"
|
|
120
|
+
:navigation-context="navigationContext"
|
|
121
|
+
@select-workspace="selectContext('workspace')"
|
|
122
|
+
:actions="extensionActions"
|
|
123
|
+
>
|
|
124
|
+
<template v-if="extensions.regions['workspace-settings']" #settings>
|
|
125
|
+
<component :is="extensions.regions['workspace-settings']" :actions="extensionActions" />
|
|
126
|
+
</template>
|
|
127
|
+
<template #default>
|
|
128
|
+
<button
|
|
129
|
+
role="menuitem"
|
|
130
|
+
@click="
|
|
131
|
+
workspaceMenu = false;
|
|
132
|
+
commandPaletteOpened = true;
|
|
133
|
+
"
|
|
134
|
+
>
|
|
135
|
+
<Search :size="16" />{{ t('命令中心') }}
|
|
136
|
+
<span class="menu-shortcut"><ShortcutHint :label="shortcutHint('commandPalette')" /></span>
|
|
137
|
+
</button>
|
|
138
|
+
<component
|
|
139
|
+
:is="extensions.regions['workspace-settings']"
|
|
140
|
+
v-if="
|
|
141
|
+
extensions.regions['workspace-menu-layout'] &&
|
|
142
|
+
extensions.regions['workspace-settings']
|
|
143
|
+
"
|
|
144
|
+
:actions="extensionActions"
|
|
145
|
+
/>
|
|
146
|
+
<button
|
|
147
|
+
v-if="workspace"
|
|
148
|
+
role="menuitem"
|
|
149
|
+
:disabled="workspace.readOnly || busy"
|
|
150
|
+
@click="openImport"
|
|
151
|
+
>
|
|
152
|
+
<ArrowDownToLine :size="16" />{{ t('导入') }}
|
|
153
|
+
</button>
|
|
154
|
+
<button
|
|
155
|
+
v-if="workspace"
|
|
156
|
+
role="menuitem"
|
|
157
|
+
:disabled="workspace.readOnly || busy"
|
|
158
|
+
@click="
|
|
159
|
+
workspaceMenu = false;
|
|
160
|
+
openTemplateLibrary();
|
|
161
|
+
"
|
|
162
|
+
>
|
|
163
|
+
<Files :size="16" />{{ t('文档模板') }}
|
|
164
|
+
</button>
|
|
165
|
+
<button role="menuitem" @click="openSettings('about')">
|
|
166
|
+
<CircleHelp :size="16" />{{ t('关于 Tano / 同页')
|
|
167
|
+
}}{{ updates.state.candidate ? t(' · 有新版本') : '' }}
|
|
168
|
+
</button>
|
|
169
|
+
<div v-if="extensions.regions['account-note']" class="menu-divider" />
|
|
170
|
+
<component
|
|
171
|
+
:is="extensions.regions['account-note']"
|
|
172
|
+
v-if="extensions.regions['account-note']"
|
|
173
|
+
:actions="extensionActions"
|
|
174
|
+
/>
|
|
175
|
+
<div
|
|
176
|
+
v-if="
|
|
177
|
+
extensions.regions['mode-switch'] ||
|
|
178
|
+
(mobile && workspace) ||
|
|
179
|
+
extensions.regions['workspace-history'] ||
|
|
180
|
+
extensions.regions['sign-out']
|
|
181
|
+
"
|
|
182
|
+
class="menu-divider"
|
|
183
|
+
/>
|
|
184
|
+
<component
|
|
185
|
+
:is="extensions.regions['mode-switch']"
|
|
186
|
+
v-if="extensions.regions['mode-switch']"
|
|
187
|
+
:actions="extensionActions"
|
|
188
|
+
/>
|
|
189
|
+
<button
|
|
190
|
+
v-if="mobile && workspace"
|
|
191
|
+
role="menuitem"
|
|
192
|
+
@click="
|
|
193
|
+
workspaceMenu = false;
|
|
194
|
+
recyclePanel = true;
|
|
195
|
+
"
|
|
196
|
+
>
|
|
197
|
+
<Trash2 :size="16" />{{ t('手机回收站') }}
|
|
198
|
+
</button>
|
|
199
|
+
<component
|
|
200
|
+
:is="extensions.regions['workspace-history']"
|
|
201
|
+
v-if="extensions.regions['workspace-history']"
|
|
202
|
+
:actions="extensionActions"
|
|
203
|
+
/>
|
|
204
|
+
<component
|
|
205
|
+
:is="extensions.regions['sign-out']"
|
|
206
|
+
v-if="extensions.regions['sign-out']"
|
|
207
|
+
:actions="extensionActions"
|
|
208
|
+
/>
|
|
209
|
+
</template>
|
|
210
|
+
<template #workspaces>
|
|
211
|
+
<button
|
|
212
|
+
class="context-menu-item"
|
|
213
|
+
v-if="
|
|
214
|
+
workspace &&
|
|
215
|
+
!store.recent.some((item) => item.id === workspace?.id) &&
|
|
216
|
+
!extensions.regions['workspace-menu-layout']
|
|
217
|
+
"
|
|
218
|
+
type="button"
|
|
219
|
+
:data-workspace-entry-id="workspace.id"
|
|
220
|
+
:aria-current="navigationContext === 'workspace' ? 'true' : undefined"
|
|
221
|
+
@click="selectContext('workspace')"
|
|
222
|
+
>
|
|
223
|
+
<WorkspaceIcon
|
|
224
|
+
:icon="store.workspaceSettings.icon"
|
|
225
|
+
:mode="store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local'"
|
|
226
|
+
:size="16"
|
|
227
|
+
/><span class="recent-name">{{ workspace.name }}</span>
|
|
228
|
+
<Check v-if="navigationContext === 'workspace'" :size="15" />
|
|
229
|
+
</button>
|
|
230
|
+
<component
|
|
231
|
+
v-if="extensions.regions['workspace-menu']"
|
|
232
|
+
:is="extensions.regions['workspace-menu']"
|
|
233
|
+
:actions="extensionActions"
|
|
234
|
+
/>
|
|
235
|
+
<template v-else>
|
|
236
|
+
<button
|
|
237
|
+
v-if="store.isDemo || mobile"
|
|
238
|
+
:disabled="busy"
|
|
239
|
+
@click="
|
|
240
|
+
workspaceMenu = false;
|
|
241
|
+
store.isDemo && workspace ? openSettings('about') : store.openWorkspace();
|
|
242
|
+
"
|
|
243
|
+
>
|
|
244
|
+
<FolderOpen :size="16" />{{
|
|
245
|
+
store.isDemo
|
|
246
|
+
? workspace
|
|
247
|
+
? t('了解演示存储')
|
|
248
|
+
: t('打开演示工作区')
|
|
249
|
+
: t('打开默认手机空间')
|
|
250
|
+
}}
|
|
251
|
+
</button>
|
|
252
|
+
|
|
253
|
+
<button v-if="mobile" :disabled="busy" @click="createNewWorkspace">
|
|
254
|
+
<FolderPlus :size="16" />{{ t('新建手机空间') }}
|
|
255
|
+
</button>
|
|
256
|
+
<template v-if="store.recent.length || (!store.isDemo && !mobile)">
|
|
257
|
+
<div v-if="store.isDemo || mobile" class="menu-divider" />
|
|
258
|
+
<div class="workspace-recent-heading">
|
|
259
|
+
<span class="recent-label">{{
|
|
260
|
+
store.isDemo ? t('最近工作空间') : t('本地工作区')
|
|
261
|
+
}}</span>
|
|
262
|
+
<button
|
|
263
|
+
v-if="!store.isDemo && !mobile"
|
|
264
|
+
type="button"
|
|
265
|
+
class="workspace-recent-open"
|
|
266
|
+
:aria-label="t('打开新的本地文件夹')"
|
|
267
|
+
:data-tooltip="t('打开新的本地文件夹')"
|
|
268
|
+
:disabled="busy"
|
|
269
|
+
@click="
|
|
270
|
+
workspaceMenu = false;
|
|
271
|
+
store.openWorkspace();
|
|
272
|
+
"
|
|
273
|
+
>
|
|
274
|
+
<OpenWorkspaceIcon :size="16" />
|
|
275
|
+
</button>
|
|
276
|
+
</div>
|
|
277
|
+
<button
|
|
278
|
+
class="context-menu-item"
|
|
279
|
+
v-for="item in store.recent.slice(0, 5)"
|
|
280
|
+
:key="item.id"
|
|
281
|
+
:data-tooltip="item.path"
|
|
282
|
+
:disabled="busy"
|
|
283
|
+
:aria-current="
|
|
284
|
+
navigationContext === 'workspace' && item.id === workspace?.id
|
|
285
|
+
? 'true'
|
|
286
|
+
: undefined
|
|
287
|
+
"
|
|
288
|
+
:data-workspace-entry-id="item.id"
|
|
289
|
+
@mousedown.right.stop.prevent="openWorkspaceEntryContextMenu(item, $event)"
|
|
290
|
+
@contextmenu.stop.prevent="openWorkspaceEntryContextMenu(item, $event)"
|
|
291
|
+
@click="
|
|
292
|
+
workspaceMenu = false;
|
|
293
|
+
item.id === workspace?.id
|
|
294
|
+
? selectContext('workspace')
|
|
295
|
+
: store.openWorkspace(item.path);
|
|
296
|
+
"
|
|
297
|
+
>
|
|
298
|
+
<span class="workspace-list-avatar">
|
|
299
|
+
<WorkspaceIcon
|
|
300
|
+
:icon="item.id === workspace?.id ? store.workspaceSettings.icon : item.icon"
|
|
301
|
+
:mode="store.isDemo ? 'demo' : store.isWeb ? 'web' : 'local'"
|
|
302
|
+
:size="16"
|
|
303
|
+
/>
|
|
304
|
+
</span>
|
|
305
|
+
<span class="recent-name">{{ item.name }}</span>
|
|
306
|
+
<Check
|
|
307
|
+
v-if="navigationContext === 'workspace' && item.id === workspace?.id"
|
|
308
|
+
:size="15"
|
|
309
|
+
/>
|
|
310
|
+
</button>
|
|
311
|
+
</template>
|
|
312
|
+
</template>
|
|
313
|
+
</template>
|
|
314
|
+
</component>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
</template>
|