@tano.page/workbench 0.14.0 → 0.15.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 +21 -8
- package/src/App.vue +76 -17
- 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/components/AssistantChangeList.vue +98 -21
- package/src/assistant/components/AssistantPanel.vue +424 -7
- package/src/assistant/components/PluginToolProposalCard.vue +235 -0
- package/src/assistant/engine.ts +56 -3
- package/src/assistant/files.ts +5 -13
- package/src/assistant/inbox.ts +1 -148
- package/src/assistant/locales/de-DE.json +4 -1
- package/src/assistant/locales/en-US.json +4 -1
- package/src/assistant/locales/es-ES.json +4 -1
- package/src/assistant/locales/ja-JP.json +4 -1
- package/src/assistant/locales/zh-CN.json +4 -1
- package/src/assistant/locales/zh-TW.json +4 -1
- package/src/assistant/mention-autocomplete.ts +69 -0
- package/src/assistant/prompts.ts +7 -0
- package/src/assistant/results.ts +20 -86
- package/src/assistant/store.ts +319 -12
- package/src/assistant/structures.ts +7 -5
- package/src/assistant/tasks.ts +3 -5
- 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-history.ts +2 -4
- package/src/composables/use-workbench-modals.ts +6 -1
- package/src/composables/use-workbench-outline.ts +0 -5
- package/src/composables/use-workbench-shortcuts.ts +26 -22
- package/src/data-tables/data-tables.ts +1 -2
- package/src/documents/components/DocumentHistoryPanel.vue +3 -1
- package/src/features.ts +1 -0
- 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/locales/de-DE.json +349 -3
- package/src/i18n/locales/en-US.json +349 -2
- package/src/i18n/locales/es-ES.json +349 -3
- package/src/i18n/locales/ja-JP.json +348 -2
- package/src/i18n/locales/zh-TW.json +348 -2
- package/src/mail/components/MailAccountDialog.vue +449 -0
- package/src/mail/components/MailComposerDialog.vue +325 -0
- package/src/mail/components/MailProviderIcon.vue +30 -0
- package/src/mail/components/MailWorkspaceView.vue +820 -0
- package/src/mail/components/SidebarMail.vue +133 -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/workspace-objects.ts +1 -1
- package/src/plan-sync/types.ts +6 -3
- package/src/plans/calendar-interaction.ts +194 -0
- package/src/plans/calendar.ts +63 -7
- package/src/plans/components/CalendarDayPopover.vue +172 -39
- package/src/plans/components/CalendarView.vue +1736 -276
- package/src/plans/components/PlanArchiveDialog.vue +295 -0
- 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/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 +129 -54
- package/src/plugins/components/PluginDocumentSlot.vue +63 -0
- package/src/plugins/components/PluginExplorer.vue +15 -21
- package/src/plugins/components/PluginImportDialog.vue +410 -0
- package/src/plugins/components/PluginInstaller.vue +39 -145
- package/src/plugins/components/PluginListItem.vue +3 -0
- package/src/plugins/components/PluginMaintenance.vue +21 -6
- package/src/plugins/components/PluginRuntimePanel.vue +3 -3
- package/src/plugins/components/PluginSettingsForm.vue +111 -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/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-permissions.ts +57 -0
- package/src/plugins/plugin-sdk.ts +174 -8
- 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 +3 -1
- 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/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 +101 -3
- package/src/settings/components/SettingsAppearancePage.vue +46 -0
- package/src/settings/components/SettingsDocumentsPage.vue +0 -1
- package/src/settings/components/settings-search.ts +2 -3
- package/src/shell/components/SidebarNavigation.vue +22 -2
- package/src/shell/components/WorkbenchContextMenus.vue +21 -8
- package/src/shell/components/WorkbenchModals.vue +27 -46
- package/src/shell/components/WorkbenchPanes.vue +267 -84
- package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
- package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
- package/src/shell/use-workbench.ts +116 -145
- package/src/shell/workbench-async-components.ts +14 -5
- 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-knowledge.ts +1 -113
- package/src/stores/workspace-plugins-state.ts +537 -14
- package/src/stores/workspace-tabs-layout.ts +5 -43
- package/src/stores/workspace.ts +69 -66
- 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 +1 -1
- package/src/tabs/components/DesktopTabs.vue +0 -3
- package/src/tabs/components/NewTabPicker.vue +10 -4
- package/src/tabs/tab-label.ts +0 -1
- package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
- package/src/workspace/components/WorkspaceIconPicker.vue +28 -6
- package/src/workspace/workspace-comments.ts +11 -151
- package/src/workspace/workspace-welcome.ts +1 -1
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tano.page/workbench",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/App.vue",
|
|
@@ -9,11 +9,25 @@
|
|
|
9
9
|
"./plugins/data": "./src/plugins/plugin-data.ts",
|
|
10
10
|
"./plugins/catalog": "./src/plugins/catalog.ts",
|
|
11
11
|
"./plugins/native": "./src/plugins/native.ts",
|
|
12
|
+
"./plugins/packages": "./src/plugins/packages.ts",
|
|
13
|
+
"./plugins/sandbox": "./src/plugins/sandbox.ts",
|
|
14
|
+
"./assistant/browser-inbox": "./src/assistant/browser-inbox.ts",
|
|
15
|
+
"./assistant/connection-brand-icons": "./src/assistant/connection-brand-icons.ts",
|
|
16
|
+
"./assistant/hash": "./src/assistant/hash.ts",
|
|
17
|
+
"./assistant/language": "./src/assistant/language.ts",
|
|
18
|
+
"./assistant/model-icons": "./src/assistant/model-icons.ts",
|
|
19
|
+
"./assistant/navigation": "./src/assistant/navigation.ts",
|
|
20
|
+
"./assistant/store": "./src/assistant/store.ts",
|
|
21
|
+
"./assistant/transport": "./src/assistant/transport.ts",
|
|
22
|
+
"./plan-sync/descriptions": "./src/plan-sync/descriptions.ts",
|
|
23
|
+
"./stores/plans": "./src/stores/plans.ts",
|
|
24
|
+
"./stores/updates": "./src/stores/updates.ts",
|
|
12
25
|
"./adapter": "./src/workspace/adapter.ts",
|
|
13
26
|
"./markdown-demo": "./src/workspace/markdown-demo.ts",
|
|
14
27
|
"./markdown-demo-routes": "./src/workspace/markdown-demo-routes.ts",
|
|
15
28
|
"./platform": "./src/platform/platform.ts",
|
|
16
29
|
"./theme": "./src/appearance/theme.ts",
|
|
30
|
+
"./interface-font": "./src/appearance/interface-font.ts",
|
|
17
31
|
"./i18n": "./src/i18n/i18n.ts",
|
|
18
32
|
"./shortcuts": "./src/shell/shortcuts.ts",
|
|
19
33
|
"./document-print": "./src/documents/document-print.ts",
|
|
@@ -35,7 +49,7 @@
|
|
|
35
49
|
"./components/DesktopWindow.vue": "./src/shell/components/DesktopWindow.vue",
|
|
36
50
|
"./components/LoadingSkeleton.vue": "./src/shell/components/LoadingSkeleton.vue",
|
|
37
51
|
"./components/ModalBackdrop.vue": "./src/shell/components/ModalBackdrop.vue",
|
|
38
|
-
"./components/
|
|
52
|
+
"./components/ObjectDetailModal.vue": "./src/objects/components/ObjectDetailModal.vue",
|
|
39
53
|
"./components/OpenWorkspaceIcon.vue": "./src/shell/components/OpenWorkspaceIcon.vue",
|
|
40
54
|
"./components/PlanDetailPanel.vue": "./src/plans/components/PlanDetailPanel.vue",
|
|
41
55
|
"./components/PluginDetailPage.vue": "./src/plugins/components/PluginDetailPage.vue",
|
|
@@ -59,15 +73,14 @@
|
|
|
59
73
|
"./workspace-objects.ts": "./src/objects/workspace-objects.ts",
|
|
60
74
|
"./workspace-relations.ts": "./src/objects/workspace-relations.ts",
|
|
61
75
|
"./workspace-settings.ts": "./src/workspace/workspace-settings.ts",
|
|
62
|
-
"./workspace-sync.ts": "./src/workspace/workspace-sync.ts",
|
|
63
76
|
"./workspace-welcome.ts": "./src/workspace/workspace-welcome.ts",
|
|
64
77
|
"./*": "./src/*"
|
|
65
78
|
},
|
|
66
79
|
"dependencies": {
|
|
67
80
|
"@fontsource-variable/inter": "^5.3.0",
|
|
68
|
-
"@tano/editor": "npm:@tano.page/editor@0.
|
|
69
|
-
"@tano/markdown": "npm:@tano.page/markdown@0.
|
|
70
|
-
"@tano/protocol": "npm:@tano.page/protocol@0.
|
|
81
|
+
"@tano/editor": "npm:@tano.page/editor@0.15.0",
|
|
82
|
+
"@tano/markdown": "npm:@tano.page/markdown@0.15.0",
|
|
83
|
+
"@tano/protocol": "npm:@tano.page/protocol@0.15.0",
|
|
71
84
|
"@tauri-apps/api": "^2.8.0",
|
|
72
85
|
"@tauri-apps/plugin-dialog": "^2.4.0",
|
|
73
86
|
"@xmldom/xmldom": "0.9.12",
|
|
@@ -111,8 +124,8 @@
|
|
|
111
124
|
"url": "git+https://github.com/Dramwig/Tano.git"
|
|
112
125
|
},
|
|
113
126
|
"tanoCore": {
|
|
114
|
-
"sourceCommit": "
|
|
115
|
-
"version": "0.
|
|
127
|
+
"sourceCommit": "70164f251c3bacf688734a440d682dba28e38eae",
|
|
128
|
+
"version": "0.15.0",
|
|
116
129
|
"importName": "@tano/workbench"
|
|
117
130
|
}
|
|
118
131
|
}
|
package/src/App.vue
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { provide, proxyRefs, ref, shallowReactive, toRefs } from 'vue';
|
|
3
3
|
import {
|
|
4
4
|
ArrowDownToLine,
|
|
5
|
-
Blocks,
|
|
6
5
|
Bot,
|
|
7
6
|
CalendarDays,
|
|
8
7
|
Check,
|
|
@@ -14,8 +13,8 @@ import {
|
|
|
14
13
|
FolderPlus,
|
|
15
14
|
GitFork,
|
|
16
15
|
House,
|
|
16
|
+
Mail,
|
|
17
17
|
PanelLeftOpen,
|
|
18
|
-
RefreshCw,
|
|
19
18
|
Search,
|
|
20
19
|
SquarePen,
|
|
21
20
|
Trash2,
|
|
@@ -33,7 +32,9 @@ import HelpLauncher from './help/components/HelpLauncher.vue';
|
|
|
33
32
|
import OpenWorkspaceIcon from './shell/components/OpenWorkspaceIcon.vue';
|
|
34
33
|
import PluginExplorer from './plugins/components/PluginExplorer.vue';
|
|
35
34
|
import PluginMenu from './plugins/components/PluginMenu.vue';
|
|
35
|
+
import PluginStatusBar from './plugins/components/PluginStatusBar.vue';
|
|
36
36
|
import PluginView from './plugins/components/PluginView.vue';
|
|
37
|
+
import { isOverlaySidebarNavHidden } from './plugins/overlay-mapping';
|
|
37
38
|
import ReferenceGraphPopover from './objects/components/ReferenceGraphPopover.vue';
|
|
38
39
|
import SidebarNavigation from './shell/components/SidebarNavigation.vue';
|
|
39
40
|
import SidebarUpdateButton from './shell/components/SidebarUpdateButton.vue';
|
|
@@ -53,7 +54,9 @@ import WindowScope from './windows/WindowScope.vue';
|
|
|
53
54
|
import {
|
|
54
55
|
CalendarView,
|
|
55
56
|
InlineAssistantInput,
|
|
57
|
+
MailWorkspaceView,
|
|
56
58
|
SidebarAssistant,
|
|
59
|
+
SidebarMail,
|
|
57
60
|
SidebarPlan,
|
|
58
61
|
} from './shell/workbench-async-components';
|
|
59
62
|
import { workbenchContextKey } from './shell/workbench-context';
|
|
@@ -108,6 +111,9 @@ const {
|
|
|
108
111
|
modal,
|
|
109
112
|
settingsPanel,
|
|
110
113
|
SETTINGS_TAB_ID,
|
|
114
|
+
MAIL_TAB_ID,
|
|
115
|
+
mailEnabled,
|
|
116
|
+
openMail,
|
|
111
117
|
repositoryActionItems,
|
|
112
118
|
showModal,
|
|
113
119
|
activeId,
|
|
@@ -131,7 +137,6 @@ const {
|
|
|
131
137
|
fileDragStart,
|
|
132
138
|
finishTreeRename,
|
|
133
139
|
noteCount,
|
|
134
|
-
showObjects,
|
|
135
140
|
sidebarCalendarDate,
|
|
136
141
|
openCalendar,
|
|
137
142
|
showPlanEvent,
|
|
@@ -143,7 +148,6 @@ const {
|
|
|
143
148
|
extensions,
|
|
144
149
|
extensionActions,
|
|
145
150
|
commandPaletteOpened,
|
|
146
|
-
openSystemSync,
|
|
147
151
|
openImport,
|
|
148
152
|
openTemplateLibrary,
|
|
149
153
|
openSettings,
|
|
@@ -195,6 +199,32 @@ const {
|
|
|
195
199
|
// The brand icon opens the self-drawn application menu on desktop; the web build keeps it as a home link.
|
|
196
200
|
const appMenuOpen = ref(false);
|
|
197
201
|
const brandButton = ref<HTMLElement | null>(null);
|
|
202
|
+
function runPluginCommandById(commandId: string) {
|
|
203
|
+
const builtin = workbenchCommands.value.find((item) => item.id === commandId);
|
|
204
|
+
if (builtin) {
|
|
205
|
+
void builtin.run();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const ws = workspace.value;
|
|
209
|
+
if (!ws) return;
|
|
210
|
+
const cmd = store.value.pluginCommands.find(
|
|
211
|
+
(item) => `${item.pluginId}:${item.id}` === commandId || item.id === commandId,
|
|
212
|
+
);
|
|
213
|
+
if (!cmd) return;
|
|
214
|
+
void store.value
|
|
215
|
+
.interactWithPlugin({
|
|
216
|
+
workspaceId: ws.id,
|
|
217
|
+
pluginId: cmd.pluginId,
|
|
218
|
+
instanceId: cmd.instanceId,
|
|
219
|
+
kind: 'command',
|
|
220
|
+
name: cmd.id,
|
|
221
|
+
payload: {
|
|
222
|
+
workspaceId: ws.id,
|
|
223
|
+
...(store.value.active?.id ? { fileId: store.value.active.id } : {}),
|
|
224
|
+
},
|
|
225
|
+
})
|
|
226
|
+
.catch(() => {});
|
|
227
|
+
}
|
|
198
228
|
</script>
|
|
199
229
|
|
|
200
230
|
<template>
|
|
@@ -320,7 +350,7 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
320
350
|
>
|
|
321
351
|
<template v-if="navigationModule === 'workspace'">
|
|
322
352
|
<button
|
|
323
|
-
v-if="isVisible('search')"
|
|
353
|
+
v-if="isVisible('search') && !isOverlaySidebarNavHidden('search', store.overlaySnapshot?.hiddenSidebarItems)"
|
|
324
354
|
type="button"
|
|
325
355
|
class="icon-button"
|
|
326
356
|
:aria-label="t('查找文档')"
|
|
@@ -332,7 +362,7 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
332
362
|
<Search :size="16" :stroke-width="1.6" />
|
|
333
363
|
</button>
|
|
334
364
|
<button
|
|
335
|
-
v-if="store.workspaceSettings.showGraph && isVisible('graph')"
|
|
365
|
+
v-if="store.workspaceSettings.showGraph && isVisible('graph') && !isOverlaySidebarNavHidden('graph', store.overlaySnapshot?.hiddenSidebarItems)"
|
|
336
366
|
type="button"
|
|
337
367
|
class="icon-button"
|
|
338
368
|
:aria-label="t('打开关系图谱')"
|
|
@@ -359,14 +389,18 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
359
389
|
</div>
|
|
360
390
|
<SidebarNavigation
|
|
361
391
|
v-if="navigationContext === 'home'"
|
|
362
|
-
v-slot="{ isVisible }"
|
|
392
|
+
v-slot="{ isVisible, orderStyle }"
|
|
363
393
|
:items="sidebarNavigationItems"
|
|
364
394
|
:active="sidebar"
|
|
395
|
+
:overlay-hidden-ids="store.overlaySnapshot?.hiddenSidebarItems"
|
|
396
|
+
:overlay-order="store.overlaySnapshot?.sidebarOrder"
|
|
365
397
|
@open="closeButtonVisibilityMenus"
|
|
366
398
|
>
|
|
367
399
|
<button
|
|
400
|
+
v-if="isVisible('plan')"
|
|
368
401
|
type="button"
|
|
369
402
|
class="sidebar-navigation-button"
|
|
403
|
+
:style="orderStyle('plan')"
|
|
370
404
|
:aria-label="t('计划')"
|
|
371
405
|
:data-tooltip="t('计划')"
|
|
372
406
|
aria-controls="sidebar-plan-panel"
|
|
@@ -378,6 +412,22 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
378
412
|
><span>{{ t('计划') }}</span></span
|
|
379
413
|
>
|
|
380
414
|
</button>
|
|
415
|
+
<button
|
|
416
|
+
v-if="mailEnabled && isVisible(MAIL_TAB_ID)"
|
|
417
|
+
type="button"
|
|
418
|
+
class="sidebar-navigation-button"
|
|
419
|
+
:style="orderStyle(MAIL_TAB_ID)"
|
|
420
|
+
:aria-label="t('邮箱')"
|
|
421
|
+
:data-tooltip="t('邮箱')"
|
|
422
|
+
:aria-controls="`sidebar-${MAIL_TAB_ID}`"
|
|
423
|
+
:aria-pressed="sidebarView === MAIL_TAB_ID"
|
|
424
|
+
@click="openMail()"
|
|
425
|
+
>
|
|
426
|
+
<Mail :size="18" :stroke-width="1.6" aria-hidden="true" />
|
|
427
|
+
<span :aria-hidden="sidebarView !== MAIL_TAB_ID"
|
|
428
|
+
><span>{{ t('邮箱') }}</span></span
|
|
429
|
+
>
|
|
430
|
+
</button>
|
|
381
431
|
<template v-for="view in extensionViews" :key="view.id">
|
|
382
432
|
<button
|
|
383
433
|
v-if="
|
|
@@ -385,6 +435,7 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
385
435
|
"
|
|
386
436
|
type="button"
|
|
387
437
|
class="sidebar-navigation-button"
|
|
438
|
+
:style="orderStyle(view.id)"
|
|
388
439
|
:aria-label="view.label"
|
|
389
440
|
:data-tooltip="view.label"
|
|
390
441
|
:aria-controls="`sidebar-${view.id}`"
|
|
@@ -528,6 +579,11 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
528
579
|
@select-date="openCalendar"
|
|
529
580
|
@select-event="showPlanEvent"
|
|
530
581
|
/>
|
|
582
|
+
<SidebarMail
|
|
583
|
+
v-if="mailEnabled && sidebarView === MAIL_TAB_ID"
|
|
584
|
+
:id="`sidebar-${MAIL_TAB_ID}`"
|
|
585
|
+
@open-mail="openMail"
|
|
586
|
+
/>
|
|
531
587
|
<template v-for="view in extensionViews" :key="view.id">
|
|
532
588
|
<div
|
|
533
589
|
v-if="view.sidebar"
|
|
@@ -626,13 +682,6 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
626
682
|
"
|
|
627
683
|
:actions="extensionActions"
|
|
628
684
|
/>
|
|
629
|
-
<button
|
|
630
|
-
v-if="workspace && native && !mobile && !store.isWeb"
|
|
631
|
-
role="menuitem"
|
|
632
|
-
@click="openSystemSync()"
|
|
633
|
-
>
|
|
634
|
-
<RefreshCw :size="16" />{{ t('Git 与同步') }}
|
|
635
|
-
</button>
|
|
636
685
|
<button
|
|
637
686
|
v-if="workspace"
|
|
638
687
|
role="menuitem"
|
|
@@ -652,9 +701,6 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
652
701
|
>
|
|
653
702
|
<Files :size="16" />{{ t('文档模板') }}
|
|
654
703
|
</button>
|
|
655
|
-
<button role="menuitem" @click="showObjects()">
|
|
656
|
-
<Blocks :size="16" />{{ t('工作区对象') }}
|
|
657
|
-
</button>
|
|
658
704
|
<button role="menuitem" @click="openSettings('about')">
|
|
659
705
|
<CircleHelp :size="16" />{{ t('关于 Tano / 同页')
|
|
660
706
|
}}{{ updates.state.candidate ? t(' · 有新版本') : '' }}
|
|
@@ -931,6 +977,7 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
931
977
|
</template>
|
|
932
978
|
<template #default="{ pane }">
|
|
933
979
|
<WorkbenchSettings v-if="pane.activeId === SETTINGS_TAB_ID" tabbed />
|
|
980
|
+
<MailWorkspaceView v-else-if="mailEnabled && pane.activeId === MAIL_TAB_ID" />
|
|
934
981
|
<template v-for="view in extensionViews" :key="view.id"
|
|
935
982
|
><component
|
|
936
983
|
v-if="pane.activeId === view.id"
|
|
@@ -953,6 +1000,7 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
953
1000
|
@select-month="showCalendarMonth"
|
|
954
1001
|
@select-event="showPlanEvent"
|
|
955
1002
|
/>
|
|
1003
|
+
<MailWorkspaceView v-else-if="mailEnabled && homeContent === MAIL_TAB_ID" />
|
|
956
1004
|
<component
|
|
957
1005
|
v-else-if="homeExtension"
|
|
958
1006
|
:is="homeExtension.component"
|
|
@@ -960,6 +1008,17 @@ const brandButton = ref<HTMLElement | null>(null);
|
|
|
960
1008
|
/>
|
|
961
1009
|
</template>
|
|
962
1010
|
<div v-else class="editor-empty"><div class="editor-empty-mark" aria-hidden="true" /></div>
|
|
1011
|
+
<PluginStatusBar
|
|
1012
|
+
v-if="workspace && !isAuxiliaryWindow"
|
|
1013
|
+
:items="store.pluginStatusBarItems"
|
|
1014
|
+
:workspace-id="workspace.id"
|
|
1015
|
+
:active-document-id="store.active?.id"
|
|
1016
|
+
:execute="store.interactWithPlugin"
|
|
1017
|
+
:safe-mode="store.overlaySnapshot?.safeMode"
|
|
1018
|
+
:pinned-commands="store.overlaySnapshot?.pinnedCommands"
|
|
1019
|
+
@exit-safe-mode="store.setSafeMode(false)"
|
|
1020
|
+
@run-pinned-command="runPluginCommandById"
|
|
1021
|
+
/>
|
|
963
1022
|
<Teleport :to="activeWindow.overlays"
|
|
964
1023
|
><WindowScope :key="activeWindow.id" :context="activeWindow">
|
|
965
1024
|
<InlineAssistantInput
|
|
@@ -8,13 +8,19 @@ import type { InstalledObjectPlugin } from '../plugins/workspace-plugins';
|
|
|
8
8
|
export const appearanceKinds = ['color', 'icons', 'layout', 'material', 'shape'] as const;
|
|
9
9
|
/** Kinds a theme plugin may set. Materials are drawn by the host, so plugins cannot contribute or reference them. */
|
|
10
10
|
const pluginPresetKinds = ['color', 'icons', 'layout', 'shape'] as const;
|
|
11
|
+
/** Raised card: flat opaque surfaces with sculpted bevels and dimensional edges. */
|
|
12
|
+
export const raisedCardMaterial = 'builtin:raised';
|
|
11
13
|
/** The frosted-glass material turns the sidebar and page sheets of any layout into translucent glass. */
|
|
12
14
|
export const glassMaterial = 'builtin:frost';
|
|
13
15
|
/** Liquid glass: the same layers, but clear glass whose thick edges catch the light. */
|
|
14
16
|
export const liquidGlassMaterial = 'builtin:liquid';
|
|
15
17
|
/** Glass materials share the desk, the background image and the layer structure. */
|
|
16
18
|
export const glassMaterials: readonly string[] = [glassMaterial, liquidGlassMaterial];
|
|
17
|
-
const materialSurface: Record<string, NonNullable<AppearancePreset['material']>> = {
|
|
19
|
+
const materialSurface: Record<string, NonNullable<AppearancePreset['material']>> = {
|
|
20
|
+
[raisedCardMaterial]: 'raised',
|
|
21
|
+
[glassMaterial]: 'frost',
|
|
22
|
+
[liquidGlassMaterial]: 'liquid',
|
|
23
|
+
};
|
|
18
24
|
export type AppearanceKind = typeof appearanceKinds[number];
|
|
19
25
|
export const builtinDefault = 'builtin:tano';
|
|
20
26
|
export const insetLayout = 'builtin:inset';
|
|
@@ -26,7 +32,11 @@ export const builtinAppearance: AppearanceBuiltins = {
|
|
|
26
32
|
{ id: 'builtin:paper', label: '纸感', structure: 'document', surface: 'paper', gap: 24, pageWidth: 800 },
|
|
27
33
|
],
|
|
28
34
|
colors: builtinColors,
|
|
29
|
-
materials: [
|
|
35
|
+
materials: [
|
|
36
|
+
{ id: raisedCardMaterial, label: '立体卡片' },
|
|
37
|
+
{ id: glassMaterial, label: '磨砂玻璃' },
|
|
38
|
+
{ id: liquidGlassMaterial, label: '液态玻璃' },
|
|
39
|
+
],
|
|
30
40
|
shapes: [
|
|
31
41
|
{ id: 'builtin:rounded', label: '圆润宽松', tokens: { 'radius-control': '10px', 'radius-card': '16px', 'radius-dialog': '20px', 'space-panel': '22px', 'space-row-gap': '6px',
|
|
32
42
|
'overlay-shadow': '0px 1px 2px #1b263a14, 0px 8px 24px #1b263a14', 'dialog-shadow': '0px 24px 64px #1b263a33' } },
|
|
@@ -68,8 +78,8 @@ export interface AppearancePreset extends AppearanceChoice {
|
|
|
68
78
|
missing?: { kind: AppearanceKind; id: string }[];
|
|
69
79
|
previews?: AppearancePreview[];
|
|
70
80
|
structure?: LayoutThemeDefinition['structure'];
|
|
71
|
-
/** Set when the preset
|
|
72
|
-
material?: 'frost' | 'liquid';
|
|
81
|
+
/** Set when the preset uses a non-flat material, so the preview can draw it. */
|
|
82
|
+
material?: 'raised' | 'frost' | 'liquid';
|
|
73
83
|
}
|
|
74
84
|
export interface AppearanceSnapshot {
|
|
75
85
|
workspaceId: string;
|
|
@@ -99,8 +99,52 @@ const previews = computed(() => props.preset.previews?.length ? props.preset.pre
|
|
|
99
99
|
[data-preview-structure='document'] .theme-preview-heading { width: 44%; align-self: center; height: 3px; margin-bottom: 2px; }
|
|
100
100
|
[data-preview-structure='document'] .theme-preview-callout { display: none; }
|
|
101
101
|
[data-preview-structure='document'] .theme-preview-paragraph-short { display: flex; }
|
|
102
|
+
/* Raised card: clean flat surfaces with crisp 1px edge bevels and quiet double-bezel tray (see layout-themes.css). */
|
|
103
|
+
.theme-preview[data-preview-surface='raised'] .theme-preview-scene {
|
|
104
|
+
--preview-raised-edge: color-mix(in srgb, var(--preview-text) 5%, var(--preview-line));
|
|
105
|
+
--preview-raised-highlight: #ffffff;
|
|
106
|
+
--preview-raised-underside: color-mix(in srgb, var(--preview-text) 4%, transparent);
|
|
107
|
+
--preview-raised-groove: color-mix(in srgb, var(--preview-sidebar) 92%, var(--preview-paper) 8%);
|
|
108
|
+
--preview-raised-outer: color-mix(in srgb, var(--preview-line) 85%, var(--preview-paper) 15%);
|
|
109
|
+
--preview-raised-shadow:
|
|
110
|
+
inset 0 1px 0 var(--preview-raised-highlight),
|
|
111
|
+
inset 0 -1px 0 var(--preview-raised-underside),
|
|
112
|
+
0 1px 2px 0 color-mix(in srgb, var(--preview-text) 4.5%, transparent),
|
|
113
|
+
0 0 0 2px var(--preview-raised-groove),
|
|
114
|
+
0 0 0 2.5px var(--preview-raised-outer),
|
|
115
|
+
0 3px 6px -2px color-mix(in srgb, var(--preview-text) 5%, transparent);
|
|
116
|
+
background: color-mix(in srgb, var(--preview-sidebar) 97.5%, var(--preview-text) 2.5%);
|
|
117
|
+
}
|
|
118
|
+
.theme-preview[data-preview-surface='raised'] .theme-preview-scene[data-preview-mode='dark'] {
|
|
119
|
+
--preview-raised-edge: color-mix(in srgb, #ffffff 11%, var(--preview-paper));
|
|
120
|
+
--preview-raised-highlight: rgb(255 255 255 / 15%);
|
|
121
|
+
--preview-raised-underside: rgb(0 0 0 / 38%);
|
|
122
|
+
--preview-raised-groove: color-mix(in srgb, var(--preview-sidebar) 56%, #000000);
|
|
123
|
+
--preview-raised-outer: color-mix(in srgb, #ffffff 9%, var(--preview-sidebar));
|
|
124
|
+
--preview-raised-shadow:
|
|
125
|
+
inset 0 1px 0 var(--preview-raised-highlight),
|
|
126
|
+
inset 0 -1px 0 var(--preview-raised-underside),
|
|
127
|
+
0 1px 2px 0 rgb(0 0 0 / 52%),
|
|
128
|
+
0 0 0 2px var(--preview-raised-groove),
|
|
129
|
+
0 0 0 2.5px var(--preview-raised-outer),
|
|
130
|
+
0 4px 8px -2px rgb(0 0 0 / 50%);
|
|
131
|
+
background: color-mix(in srgb, var(--preview-sidebar) 70%, #000000 30%);
|
|
132
|
+
}
|
|
133
|
+
.theme-preview[data-preview-surface='raised'] .theme-preview-window {
|
|
134
|
+
border-color: var(--preview-raised-edge);
|
|
135
|
+
box-shadow: var(--preview-raised-shadow);
|
|
136
|
+
}
|
|
137
|
+
.theme-preview[data-preview-surface='raised'][data-preview-structure='islands']:not([data-preview-flat-sidebar]) .theme-preview-sidebar,
|
|
138
|
+
.theme-preview[data-preview-surface='raised'][data-preview-structure='islands'] .theme-preview-main,
|
|
139
|
+
.theme-preview[data-preview-surface='raised'][data-preview-structure='document'] .theme-preview-document {
|
|
140
|
+
border-color: var(--preview-raised-edge);
|
|
141
|
+
box-shadow: var(--preview-raised-shadow);
|
|
142
|
+
}
|
|
143
|
+
.theme-preview[data-preview-surface='raised'][data-preview-structure='continuous'] .theme-preview-main {
|
|
144
|
+
box-shadow: inset 1px 0 0 var(--preview-raised-edge), inset 0 1px 0 var(--preview-raised-highlight);
|
|
145
|
+
}
|
|
102
146
|
/* Frosted glass: the same two cards, milky and translucent over soft orbs of colour (see layout-themes.css). */
|
|
103
|
-
.theme-preview[data-preview-surface] .theme-preview-scene {
|
|
147
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-scene {
|
|
104
148
|
--preview-syntax-blue: #2d5fb8;
|
|
105
149
|
--preview-syntax-purple: #6a45b8;
|
|
106
150
|
--preview-syntax-teal: #0b7480;
|
|
@@ -114,7 +158,7 @@ const previews = computed(() => props.preset.previews?.length ? props.preset.pre
|
|
|
114
158
|
radial-gradient(36% 40% at 94% 4%, color-mix(in srgb, var(--preview-syntax-teal) 26%, transparent), transparent 70%),
|
|
115
159
|
linear-gradient(170deg, color-mix(in srgb, var(--preview-sidebar) 70%, #ffffff), color-mix(in srgb, var(--preview-sidebar) 40%, #ffffff));
|
|
116
160
|
}
|
|
117
|
-
.theme-preview[data-preview-surface] .theme-preview-scene[data-preview-mode='dark'] {
|
|
161
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-scene[data-preview-mode='dark'] {
|
|
118
162
|
--preview-syntax-blue: #9cbcff;
|
|
119
163
|
--preview-syntax-purple: #cbb5ff;
|
|
120
164
|
--preview-glass: 60%;
|
|
@@ -126,20 +170,20 @@ const previews = computed(() => props.preset.previews?.length ? props.preset.pre
|
|
|
126
170
|
radial-gradient(30% 40% at 82% 40%, color-mix(in srgb, var(--preview-syntax-purple) 16%, transparent), transparent 70%),
|
|
127
171
|
linear-gradient(170deg, var(--preview-sidebar), color-mix(in srgb, var(--preview-sidebar) 86%, var(--preview-text) 14%));
|
|
128
172
|
}
|
|
129
|
-
.theme-preview[data-preview-surface] .theme-preview-window,
|
|
130
|
-
.theme-preview[data-preview-surface] .theme-preview-toolbar,
|
|
131
|
-
.theme-preview[data-preview-surface] .theme-preview-workspace { background: transparent; }
|
|
132
|
-
.theme-preview[data-preview-surface] .theme-preview-window { border-color: transparent; box-shadow: none; }
|
|
173
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-window,
|
|
174
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-toolbar,
|
|
175
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-workspace { background: transparent; }
|
|
176
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-window { border-color: transparent; box-shadow: none; }
|
|
133
177
|
.theme-preview[data-preview-surface='frost']:not([data-preview-flat-sidebar]) .theme-preview-sidebar,
|
|
134
178
|
.theme-preview[data-preview-surface='liquid'][data-preview-structure='islands']:not([data-preview-flat-sidebar]) .theme-preview-sidebar,
|
|
135
|
-
.theme-preview[data-preview-surface] .theme-preview-main {
|
|
179
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-main {
|
|
136
180
|
border-color: var(--preview-rim);
|
|
137
181
|
border-radius: 6px;
|
|
138
182
|
background: linear-gradient(160deg, var(--preview-sheen), transparent 55%), color-mix(in srgb, var(--preview-paper) var(--preview-glass), transparent);
|
|
139
183
|
box-shadow: inset 0 1px 0 var(--preview-rim), 0 6px 12px -8px #1c305a4d;
|
|
140
184
|
-webkit-backdrop-filter: blur(8px) saturate(170%) brightness(1.04); backdrop-filter: blur(8px) saturate(170%) brightness(1.04);
|
|
141
185
|
}
|
|
142
|
-
.theme-preview[data-preview-surface] .theme-preview-main { --preview-glass: 74%; }
|
|
186
|
+
.theme-preview:is([data-preview-surface='frost'], [data-preview-surface='liquid']) .theme-preview-main { --preview-glass: 74%; }
|
|
143
187
|
/* Liquid glass: clearer cards whose edges catch the light (see layout-themes.css). */
|
|
144
188
|
.theme-preview[data-preview-surface='liquid'] .theme-preview-scene { --preview-glass: 10%; --preview-rim: #ffffff80; --preview-edge: #ffffff80; --preview-outline: #1c24301f; }
|
|
145
189
|
.theme-preview[data-preview-surface='liquid'] .theme-preview-scene[data-preview-mode='dark'] { --preview-glass: 16%; --preview-rim: #ffffff42; --preview-edge: #ffffff1a; --preview-outline: #00000073; }
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { sanitizeCustomFontName } from './editor-font';
|
|
2
|
+
|
|
3
|
+
/** Device-local typeface for menus, sidebars, tabs, dialogs and settings.
|
|
4
|
+
* Document prose keeps its own font setting (editor-font.ts). */
|
|
5
|
+
export type InterfaceFontChoice = 'builtin' | 'system' | 'custom';
|
|
6
|
+
export interface InterfaceFontPreference { choice: InterfaceFontChoice; customName: string }
|
|
7
|
+
|
|
8
|
+
export const interfaceFontPreferenceKey = 'tano.preference.interfaceFont';
|
|
9
|
+
export const interfaceFontChanged = 'tano:interface-font-changed';
|
|
10
|
+
|
|
11
|
+
export function defaultInterfaceFont(): InterfaceFontPreference {
|
|
12
|
+
return { choice: 'builtin', customName: '' };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function parseInterfaceFont(value: string | null): InterfaceFontPreference {
|
|
16
|
+
try {
|
|
17
|
+
const saved = JSON.parse(value ?? 'null');
|
|
18
|
+
if (!saved || typeof saved !== 'object') return defaultInterfaceFont();
|
|
19
|
+
const choice: InterfaceFontChoice = saved.choice === 'system' || saved.choice === 'custom' ? saved.choice : 'builtin';
|
|
20
|
+
const customName = typeof saved.customName === 'string' ? sanitizeCustomFontName(saved.customName) : '';
|
|
21
|
+
return { choice, customName };
|
|
22
|
+
} catch {
|
|
23
|
+
return defaultInterfaceFont();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function readInterfaceFont(): InterfaceFontPreference {
|
|
28
|
+
try {
|
|
29
|
+
return parseInterfaceFont(window.localStorage.getItem(interfaceFontPreferenceKey));
|
|
30
|
+
} catch {
|
|
31
|
+
return defaultInterfaceFont();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Same file the stylesheet's 'Tano UI Sans SC' 400 face points at; Vite emits
|
|
36
|
+
* one hashed asset for both references. */
|
|
37
|
+
export const builtinChineseRegularUrl = new URL('../fonts/TanoUISansSC-Regular.woff2', import.meta.url).href;
|
|
38
|
+
|
|
39
|
+
/** The bundled Chinese face is Simplified Chinese; other Han locales keep
|
|
40
|
+
* platform faces (workbench-shell.css :lang rule), so they skip the preload. */
|
|
41
|
+
export function usesBuiltinChinese(preference: InterfaceFontPreference, lang = document.documentElement.lang): boolean {
|
|
42
|
+
return preference.choice === 'builtin' && !/^(zh-(TW|HK|MO|Hant)|ja|ko)\b/i.test(lang);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Start fetching the regular Chinese face before Vue and the stylesheet load,
|
|
46
|
+
* so the first paint does not swap from the platform face. */
|
|
47
|
+
export function preloadBuiltinChinese(preference: InterfaceFontPreference): void {
|
|
48
|
+
if (!usesBuiltinChinese(preference) || document.querySelector('link[data-tano-ui-font]')) return;
|
|
49
|
+
const link = document.createElement('link');
|
|
50
|
+
link.rel = 'preload';
|
|
51
|
+
link.as = 'font';
|
|
52
|
+
link.type = 'font/woff2';
|
|
53
|
+
link.crossOrigin = 'anonymous';
|
|
54
|
+
link.href = builtinChineseRegularUrl;
|
|
55
|
+
link.dataset.tanoUiFont = '';
|
|
56
|
+
document.head.append(link);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** `undefined` keeps the stylesheet default (bundled Inter + bundled Noto Sans SC). */
|
|
60
|
+
export function interfaceFontFamily(preference: InterfaceFontPreference): string | undefined {
|
|
61
|
+
if (preference.choice === 'system') return 'var(--font-ui-system)';
|
|
62
|
+
const name = sanitizeCustomFontName(preference.customName).trim();
|
|
63
|
+
if (preference.choice === 'custom' && name) return `${JSON.stringify(name)}, var(--font-ui-system)`;
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function applyInterfaceFont(preference: InterfaceFontPreference, root: HTMLElement = document.documentElement): void {
|
|
68
|
+
const family = interfaceFontFamily(preference);
|
|
69
|
+
if (family) root.style.setProperty('--font-ui', family);
|
|
70
|
+
else root.style.removeProperty('--font-ui');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let syncInstalled = false;
|
|
74
|
+
/** Run once per window before Vue mounts, so the first paint already uses the
|
|
75
|
+
* chosen face and the separate settings window stays in step with the main one. */
|
|
76
|
+
export function installInterfaceFont(): void {
|
|
77
|
+
const preference = readInterfaceFont();
|
|
78
|
+
applyInterfaceFont(preference);
|
|
79
|
+
preloadBuiltinChinese(preference);
|
|
80
|
+
if (syncInstalled) return;
|
|
81
|
+
syncInstalled = true;
|
|
82
|
+
window.addEventListener('storage', (event) => {
|
|
83
|
+
if (event.key === interfaceFontPreferenceKey || event.key === null) applyInterfaceFont(readInterfaceFont());
|
|
84
|
+
});
|
|
85
|
+
window.addEventListener(interfaceFontChanged, (event) => {
|
|
86
|
+
applyInterfaceFont((event as CustomEvent<InterfaceFontPreference>).detail);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function saveInterfaceFont(preference: InterfaceFontPreference): void {
|
|
91
|
+
const value = { choice: preference.choice, customName: sanitizeCustomFontName(preference.customName) };
|
|
92
|
+
try {
|
|
93
|
+
window.localStorage.setItem(interfaceFontPreferenceKey, JSON.stringify(value));
|
|
94
|
+
} catch {
|
|
95
|
+
// The choice still applies to this window when device storage is unavailable.
|
|
96
|
+
}
|
|
97
|
+
applyInterfaceFont(value);
|
|
98
|
+
window.dispatchEvent(new CustomEvent<InterfaceFontPreference>(interfaceFontChanged, { detail: value }));
|
|
99
|
+
}
|
package/src/appearance/theme.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { appearanceVersion, themeTokenNames, themeColorTokens, themeRadiusTokens
|
|
|
2
2
|
// Legacy v2 shapes may declare fonts. Accept the package, but keep typography
|
|
3
3
|
// under the user's font settings rather than applying it with component shape.
|
|
4
4
|
const componentShapeTokens = [...themeRadiusTokens, ...themeSpaceTokens, ...themeShadowTokens];
|
|
5
|
+
export const THEME_STYLE_ID = 'tano-theme-tokens';
|
|
5
6
|
export type ThemePreference = 'light' | 'dark' | 'system';
|
|
6
7
|
export interface ResolvedTheme {
|
|
7
8
|
version: typeof appearanceVersion;
|
|
@@ -14,12 +15,34 @@ export const themeChangedEvent = 'tano-theme-changed';
|
|
|
14
15
|
let currentPreference: ThemePreference = 'system';
|
|
15
16
|
type ColorAppearance = Pick<ColorThemeDefinition, 'light' | 'dark'> & { id?: string };
|
|
16
17
|
let appearance: ColorAppearance = { light: {}, dark: {} };
|
|
17
|
-
const applied = new Set<string>();
|
|
18
18
|
let layout: LayoutThemeDefinition | undefined;
|
|
19
19
|
let shape: ShapeThemeDefinition | undefined;
|
|
20
20
|
|
|
21
|
+
function writeThemeStyle(resolved: ResolvedTheme['mode'], tokens: Record<string, string>): void {
|
|
22
|
+
if (typeof document === 'undefined' || !document.head) return;
|
|
23
|
+
const declarations = Object.entries(tokens)
|
|
24
|
+
.map(([key, value]) => `--${key}: ${value};`)
|
|
25
|
+
.join(' ');
|
|
26
|
+
let style = document.getElementById(THEME_STYLE_ID) as HTMLStyleElement | null;
|
|
27
|
+
if (!declarations) {
|
|
28
|
+
style?.remove();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const css = `:root[data-theme="${resolved}"] { ${declarations} }`;
|
|
32
|
+
if (!style) {
|
|
33
|
+
style = document.createElement('style');
|
|
34
|
+
style.id = THEME_STYLE_ID;
|
|
35
|
+
style.textContent = css;
|
|
36
|
+
const overlayStyle = document.head.querySelector('style[data-tano-overlay-style], #tano-workbench-overlay-style');
|
|
37
|
+
if (overlayStyle) document.head.insertBefore(style, overlayStyle);
|
|
38
|
+
else document.head.appendChild(style);
|
|
39
|
+
} else if (style.textContent !== css) {
|
|
40
|
+
style.textContent = css;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
21
44
|
/** Only validated contract tokens reach the host. Empty maps restore built-in CSS. */
|
|
22
|
-
/** `material` is a host-drawn card material (e.g. builtin:frost); undefined is the flat default. */
|
|
45
|
+
/** `material` is a host-drawn card material (e.g. builtin:raised, builtin:frost, builtin:liquid); undefined is the flat default. */
|
|
23
46
|
export function applyAppearance(value?: ColorAppearance, layoutValue?: LayoutThemeDefinition, shapeValue?: ShapeThemeDefinition, mode = currentPreference, material?: string): void {
|
|
24
47
|
appearance = value ?? { light: {}, dark: {} };
|
|
25
48
|
layout = layoutValue ? { ...layoutValue } : undefined;
|
|
@@ -48,8 +71,6 @@ export function resolvedTheme(): ResolvedTheme {
|
|
|
48
71
|
tokens: Object.fromEntries(themeTokenNames.map(key => [key, styles.getPropertyValue(`--${key}`).trim()]).filter(([, value]) => value)) };
|
|
49
72
|
}
|
|
50
73
|
|
|
51
|
-
|
|
52
|
-
|
|
53
74
|
export function parseThemePreference(value: unknown): ThemePreference {
|
|
54
75
|
return value === 'light' || value === 'dark' ? value : 'system';
|
|
55
76
|
}
|
|
@@ -79,14 +100,9 @@ export function applyTheme(preference: ThemePreference): void {
|
|
|
79
100
|
const resolved = resolveThemeMode(preference, appearance);
|
|
80
101
|
document.documentElement.dataset.theme = resolved;
|
|
81
102
|
document.documentElement.style.colorScheme = resolved;
|
|
82
|
-
for (const key of applied) document.documentElement.style.removeProperty(`--${key}`);
|
|
83
|
-
applied.clear();
|
|
84
103
|
const colors = appearance[resolved] ?? {};
|
|
85
104
|
const tokens = { ...Object.fromEntries(themeColorTokens.flatMap(key => colors[key] === undefined ? [] : [[key, colors[key]]])),
|
|
86
105
|
...Object.fromEntries(componentShapeTokens.flatMap(key => shape?.tokens[key] === undefined ? [] : [[key, shape.tokens[key]]])) };
|
|
87
|
-
|
|
88
|
-
document.documentElement.style.setProperty(`--${key}`, value);
|
|
89
|
-
applied.add(key);
|
|
90
|
-
}
|
|
106
|
+
writeThemeStyle(resolved, tokens);
|
|
91
107
|
window.dispatchEvent(new Event(themeChangedEvent));
|
|
92
108
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
|
2
|
+
import {
|
|
3
|
+
interfaceFontChanged,
|
|
4
|
+
interfaceFontPreferenceKey,
|
|
5
|
+
readInterfaceFont,
|
|
6
|
+
saveInterfaceFont,
|
|
7
|
+
type InterfaceFontPreference,
|
|
8
|
+
} from './interface-font';
|
|
9
|
+
|
|
10
|
+
/** Settings-page binding; other windows follow through the storage event. */
|
|
11
|
+
export function useInterfaceFont() {
|
|
12
|
+
const preference = ref(readInterfaceFont());
|
|
13
|
+
function update(patch: Partial<InterfaceFontPreference>) {
|
|
14
|
+
preference.value = { ...preference.value, ...patch };
|
|
15
|
+
saveInterfaceFont(preference.value);
|
|
16
|
+
}
|
|
17
|
+
function sync(event: Event) {
|
|
18
|
+
if (event instanceof StorageEvent && event.key !== interfaceFontPreferenceKey && event.key !== null) return;
|
|
19
|
+
preference.value = event instanceof CustomEvent ? event.detail as InterfaceFontPreference : readInterfaceFont();
|
|
20
|
+
}
|
|
21
|
+
onMounted(() => {
|
|
22
|
+
window.addEventListener('storage', sync);
|
|
23
|
+
window.addEventListener(interfaceFontChanged, sync);
|
|
24
|
+
});
|
|
25
|
+
onBeforeUnmount(() => {
|
|
26
|
+
window.removeEventListener('storage', sync);
|
|
27
|
+
window.removeEventListener(interfaceFontChanged, sync);
|
|
28
|
+
});
|
|
29
|
+
return { preference, update };
|
|
30
|
+
}
|