@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.
Files changed (248) hide show
  1. package/package.json +50 -16
  2. package/src/App.vue +82 -752
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/agent-identities.ts +1 -97
  17. package/src/assistant/agent-task-context.ts +1 -54
  18. package/src/assistant/attachments.ts +1 -1
  19. package/src/assistant/completion.ts +1 -61
  20. package/src/assistant/components/AssistantChangeList.vue +98 -21
  21. package/src/assistant/components/AssistantPanel.vue +425 -8
  22. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  23. package/src/assistant/connection-actions.ts +237 -0
  24. package/src/assistant/document-mentions.ts +1 -33
  25. package/src/assistant/engine.ts +1 -532
  26. package/src/assistant/execution.ts +6 -33
  27. package/src/assistant/files.ts +5 -13
  28. package/src/assistant/hash.ts +1 -4
  29. package/src/assistant/inbox.ts +1 -148
  30. package/src/assistant/language.ts +10 -37
  31. package/src/assistant/mention-autocomplete.ts +69 -0
  32. package/src/assistant/plugin-bridge-builder.ts +146 -0
  33. package/src/assistant/prompts.ts +1 -58
  34. package/src/assistant/proposal-actions.ts +336 -0
  35. package/src/assistant/results.ts +20 -86
  36. package/src/assistant/store.ts +167 -327
  37. package/src/assistant/structures.ts +1 -155
  38. package/src/assistant/tasks.ts +8 -96
  39. package/src/assistant/tool-rules.ts +1 -7
  40. package/src/assistant/workspace-bridge.ts +1 -1
  41. package/src/composables/use-document-actions.ts +38 -20
  42. package/src/composables/use-file-tree-controller.ts +7 -12
  43. package/src/composables/use-workbench-help.ts +177 -0
  44. package/src/composables/use-workbench-history.ts +2 -4
  45. package/src/composables/use-workbench-lifecycle.ts +249 -0
  46. package/src/composables/use-workbench-modals.ts +6 -1
  47. package/src/composables/use-workbench-outline.ts +0 -5
  48. package/src/composables/use-workbench-settings.ts +185 -0
  49. package/src/composables/use-workbench-shortcuts.ts +40 -1021
  50. package/src/composables/use-workbench-views.ts +325 -0
  51. package/src/data-tables/data-tables.ts +1 -2
  52. package/src/documents/components/DocumentActionMenu.vue +279 -0
  53. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  54. package/src/documents/components/DocumentInspector.vue +168 -0
  55. package/src/documents/components/DocumentPane.vue +482 -0
  56. package/src/documents/description-merge.ts +1 -9
  57. package/src/features.ts +1 -0
  58. package/src/files/components/FileMetadataPanel.vue +49 -15
  59. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  60. package/src/fonts/Inter-Latin.woff2 +0 -0
  61. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  62. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  63. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  64. package/src/help/help-milestones.ts +3 -5
  65. package/src/i18n/locale-catalogs.ts +7 -6
  66. package/src/i18n/locale-registry.ts +8 -6
  67. package/src/i18n/locales/de-DE.json +371 -3
  68. package/src/i18n/locales/en-US.json +371 -2
  69. package/src/i18n/locales/es-ES.json +371 -3
  70. package/src/i18n/locales/ja-JP.json +370 -2
  71. package/src/i18n/locales/zh-TW.json +370 -2
  72. package/src/mail/components/MailAccountDialog.vue +450 -0
  73. package/src/mail/components/MailComposerDialog.vue +326 -0
  74. package/src/mail/components/MailProviderIcon.vue +30 -0
  75. package/src/mail/components/MailWorkspaceView.vue +821 -0
  76. package/src/mail/components/SidebarMail.vue +134 -0
  77. package/src/mail/mail-avatar.ts +17 -0
  78. package/src/mail/mail-bridge.ts +68 -0
  79. package/src/mail/mail-calendar.ts +208 -0
  80. package/src/mail/mail-markdown.ts +195 -0
  81. package/src/mail/types.ts +226 -0
  82. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  83. package/src/objects/content-references.ts +6 -56
  84. package/src/objects/wiki-links.ts +1 -48
  85. package/src/objects/workspace-objects.ts +3 -4
  86. package/src/plan-sync/types.ts +6 -3
  87. package/src/plans/calendar-interaction.ts +194 -0
  88. package/src/plans/calendar.ts +65 -9
  89. package/src/plans/components/CalendarAgendaView.vue +165 -0
  90. package/src/plans/components/CalendarDayPopover.vue +172 -39
  91. package/src/plans/components/CalendarFilterBar.vue +128 -0
  92. package/src/plans/components/CalendarMonthView.vue +224 -0
  93. package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
  94. package/src/plans/components/CalendarTimelineView.vue +517 -0
  95. package/src/plans/components/CalendarTopbarControls.vue +101 -0
  96. package/src/plans/components/CalendarView.vue +264 -748
  97. package/src/plans/components/CalendarYearView.vue +138 -0
  98. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  99. package/src/plans/components/PlanConnectionsDialog.vue +1 -1
  100. package/src/plans/components/PlanDateField.vue +6 -4
  101. package/src/plans/components/PlanDetailPanel.vue +227 -32
  102. package/src/plans/components/PlanEventList.vue +16 -4
  103. package/src/plans/components/SidebarPlan.vue +22 -15
  104. package/src/plans/components/TaskRepeatControls.vue +169 -30
  105. package/src/plans/components/calendar-shared.css +192 -0
  106. package/src/plans/composables/use-calendar-interactions.ts +396 -0
  107. package/src/plans/composables/use-calendar-scroll.ts +420 -0
  108. package/src/plans/local-reminders.ts +149 -0
  109. package/src/plans/personal-plans.ts +10 -1
  110. package/src/plans/plan-date.ts +8 -1
  111. package/src/plans/plan-migration.ts +95 -0
  112. package/src/plans/recurrence.ts +95 -0
  113. package/src/plans/task-repeat.ts +8 -8
  114. package/src/plans/timeline-layout.ts +92 -0
  115. package/src/plugins/assistant-bridge.ts +520 -0
  116. package/src/plugins/attachment-reader.ts +3 -1
  117. package/src/plugins/cache-storage.ts +42 -2
  118. package/src/plugins/components/PluginAutomations.vue +3 -3
  119. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  120. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  121. package/src/plugins/components/PluginConnections.vue +1 -1
  122. package/src/plugins/components/PluginCustomView.vue +2 -2
  123. package/src/plugins/components/PluginDetailPage.vue +136 -57
  124. package/src/plugins/components/PluginDeveloperArea.vue +192 -0
  125. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  126. package/src/plugins/components/PluginExplorer.vue +21 -25
  127. package/src/plugins/components/PluginImportDialog.vue +410 -0
  128. package/src/plugins/components/PluginInstaller.vue +273 -288
  129. package/src/plugins/components/PluginListItem.vue +3 -0
  130. package/src/plugins/components/PluginMaintenance.vue +37 -34
  131. package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
  132. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  133. package/src/plugins/components/PluginSettingsForm.vue +112 -0
  134. package/src/plugins/components/PluginStatusBar.vue +161 -0
  135. package/src/plugins/components/PluginSurface.vue +18 -6
  136. package/src/plugins/components/PluginUiDialog.vue +452 -0
  137. package/src/plugins/components/PluginsTabPage.vue +61 -0
  138. package/src/plugins/components/plugin-center.css +5 -0
  139. package/src/plugins/data.ts +9 -86
  140. package/src/plugins/editor-plugin-adapters.ts +169 -0
  141. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  142. package/src/plugins/excalidraw/manifest.json +12 -1
  143. package/src/plugins/host.ts +662 -43
  144. package/src/plugins/native.ts +2 -10
  145. package/src/plugins/overlay-mapping.ts +125 -0
  146. package/src/plugins/packages.ts +73 -1
  147. package/src/plugins/plugin-data.ts +2 -3
  148. package/src/plugins/plugin-permissions.ts +57 -0
  149. package/src/plugins/plugin-rpc-router.ts +558 -0
  150. package/src/plugins/plugin-sdk.ts +1 -94
  151. package/src/plugins/plugin-ui-dialogs.ts +167 -0
  152. package/src/plugins/policy.ts +53 -3
  153. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  154. package/src/plugins/presentation-preview/manifest.json +2 -1
  155. package/src/plugins/queries.ts +1 -73
  156. package/src/plugins/sandbox.ts +15 -1
  157. package/src/plugins/use-plugin-actions.ts +67 -20
  158. package/src/plugins/user-plugins.ts +254 -0
  159. package/src/plugins/view-header.ts +2 -7
  160. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  161. package/src/plugins/word-preview/manifest.json +13 -1
  162. package/src/plugins/workbench.ts +175 -2
  163. package/src/plugins/worker.js +105 -8
  164. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  165. package/src/plugins/workspace-plugins.ts +212 -21
  166. package/src/runtime.ts +103 -4
  167. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  168. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  169. package/src/settings/components/SettingsPanel.vue +8 -3
  170. package/src/settings/components/WorkbenchSettings.vue +20 -7
  171. package/src/settings/components/settings-context.ts +1 -1
  172. package/src/settings/components/settings-search.ts +2 -3
  173. package/src/settings/settings-tab.ts +1 -0
  174. package/src/shell/command-palette.ts +3 -3
  175. package/src/shell/components/EditorToolbar.vue +8 -9
  176. package/src/shell/components/EditorTools.vue +1 -5
  177. package/src/shell/components/PaneTopbar.vue +393 -0
  178. package/src/shell/components/SelectionToolbar.vue +0 -2
  179. package/src/shell/components/SidebarNavigation.vue +22 -2
  180. package/src/shell/components/WorkbenchContextMenus.vue +58 -34
  181. package/src/shell/components/WorkbenchModals.vue +47 -62
  182. package/src/shell/components/WorkbenchPanes.vue +371 -1342
  183. package/src/shell/components/WorkbenchSidebar.vue +486 -0
  184. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  185. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  186. package/src/shell/pane-registry.ts +69 -0
  187. package/src/shell/use-surface-dismissal.ts +219 -0
  188. package/src/shell/use-workbench-commands.ts +599 -0
  189. package/src/shell/use-workbench-keybindings.ts +337 -0
  190. package/src/shell/use-workbench.ts +531 -1153
  191. package/src/shell/workbench-async-components.ts +14 -5
  192. package/src/shell/workbench-context.ts +30 -3
  193. package/src/stores/mail.ts +414 -0
  194. package/src/stores/plan-sync.ts +2 -1
  195. package/src/stores/plans.ts +2 -9
  196. package/src/stores/workspace-document-io.ts +807 -0
  197. package/src/stores/workspace-file-ops.ts +1 -1
  198. package/src/stores/workspace-knowledge.ts +2 -114
  199. package/src/stores/workspace-lifecycle.ts +459 -0
  200. package/src/stores/workspace-plugins-state.ts +254 -259
  201. package/src/stores/workspace-session.ts +287 -0
  202. package/src/stores/workspace-tabs-layout.ts +6 -44
  203. package/src/stores/workspace-types.ts +50 -0
  204. package/src/stores/workspace.ts +184 -1363
  205. package/src/styles/agent-diff-modals.css +0 -7
  206. package/src/styles/dark-theme.css +3 -3
  207. package/src/styles/inspector.css +0 -59
  208. package/src/styles/layout-themes.css +346 -0
  209. package/src/styles/mail.css +1568 -0
  210. package/src/styles/mobile.css +2 -2
  211. package/src/styles/recent-and-media.css +0 -17
  212. package/src/styles/theme-contract.css +3 -3
  213. package/src/styles/workbench-shell.css +110 -17
  214. package/src/styles/workspace-states.css +9 -33
  215. package/src/styles.css +0 -1
  216. package/src/tabs/components/DesktopTabs.vue +19 -14
  217. package/src/tabs/components/NewTabPicker.vue +10 -4
  218. package/src/tabs/tab-label.ts +0 -1
  219. package/src/windows/AuxiliaryWindows.vue +2 -2
  220. package/src/windows/use-window-event-bridge.ts +152 -0
  221. package/src/workspace/components/TemplateLibrary.vue +1 -1
  222. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  223. package/src/workspace/components/WorkspaceIconPicker.vue +30 -7
  224. package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
  225. package/src/workspace/workspace-comments.ts +11 -151
  226. package/src/workspace/workspace-welcome.ts +1 -1
  227. package/src/assistant/locales/de-DE.json +0 -126
  228. package/src/assistant/locales/en-US.json +0 -126
  229. package/src/assistant/locales/es-ES.json +0 -126
  230. package/src/assistant/locales/ja-JP.json +0 -126
  231. package/src/assistant/locales/zh-CN.json +0 -126
  232. package/src/assistant/locales/zh-TW.json +0 -126
  233. package/src/assistant/task-prompts.json +0 -39
  234. package/src/documents/components/FormulaMenu.vue +0 -50
  235. package/src/files/components/FileDatabasePage.vue +0 -152
  236. package/src/files/components/FolderHomeIcon.vue +0 -12
  237. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  238. package/src/objects/components/ObjectPanel.vue +0 -554
  239. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  240. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  241. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  242. package/src/styles/object-panel.css +0 -163
  243. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  244. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  245. package/src/workspace/welcome-slogans.ts +0 -11
  246. package/src/workspace/workspace-git.ts +0 -35
  247. package/src/workspace/workspace-sync.ts +0 -46
  248. package/src/workspace/workspace-views.ts +0 -48
@@ -10,6 +10,13 @@ import { Search, Upload } from 'lucide-vue-next';
10
10
  import WorkspaceIcon from './WorkspaceIcon.vue';
11
11
  import { filterWorkspaceIconGroups, workspaceBuiltinIconGroups, workspaceEmojiGroups } from '../workspace-icons';
12
12
 
13
+ export interface WorkspaceIconPickerExtraTab {
14
+ id: string;
15
+ label: string;
16
+ matches?: (icon: string) => boolean;
17
+ defaultOpen?: boolean;
18
+ }
19
+
13
20
  const props = withDefaults(defineProps<{
14
21
  icon: string;
15
22
  mode: 'demo' | 'web' | 'local';
@@ -17,8 +24,10 @@ const props = withDefaults(defineProps<{
17
24
  label?: string;
18
25
  triggerClass?: string;
19
26
  align?: 'start' | 'end';
27
+ allowIcons?: boolean;
20
28
  allowUpload?: boolean;
21
- }>(), { align: 'end', allowUpload: true });
29
+ extraTab?: WorkspaceIconPickerExtraTab;
30
+ }>(), { align: 'end', allowIcons: true, allowUpload: true });
22
31
  const label = computed(() => props.label ?? t('工作区图标'));
23
32
  const emit = defineEmits<{ select: [value: string]; upload: []; pasteImage: [file: File]; 'update:open': [value: boolean] }>();
24
33
  const pickerId = useId();
@@ -31,13 +40,16 @@ const open = ref(false);
31
40
  // movement of the document underneath the teleported picker.
32
41
  let anchorRect: DOMRect | undefined;
33
42
  watch(open, value => emit('update:open', value), { flush: 'sync' });
34
- const tabs = [
43
+ const baseTabs = [
35
44
  { id: 'emoji', get label() { return t('表情符号'); } },
36
45
  { id: 'icons', get label() { return t('图标'); } },
37
46
  { id: 'upload', get label() { return t('上传'); } },
38
47
  ] as const;
39
- const visibleTabs = computed(() => tabs.filter(item => props.allowUpload || item.id !== 'upload'));
40
- type Tab = typeof tabs[number]['id'];
48
+ const visibleTabs = computed(() => [
49
+ ...(props.extraTab ? [{ id: props.extraTab.id, label: props.extraTab.label }] : []),
50
+ ...baseTabs.filter(item => (props.allowIcons || item.id !== 'icons') && (props.allowUpload || item.id !== 'upload')),
51
+ ]);
52
+ type Tab = string;
41
53
  const tab = ref<Tab>('emoji');
42
54
  const query = ref('');
43
55
  const currentCategory = ref('');
@@ -106,7 +118,10 @@ function place() {
106
118
  async function toggle() {
107
119
  if (props.disabled) return;
108
120
  if (open.value) { close(); return; }
109
- tab.value = props.icon.startsWith('icon:') ? 'icons' : 'emoji';
121
+ if (props.extraTab?.matches?.(props.icon)) 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;
124
+ else tab.value = 'emoji';
110
125
  query.value = ''; focusedIcon.value = '';
111
126
  anchorRect = trigger.value?.getBoundingClientRect();
112
127
  place();
@@ -114,7 +129,11 @@ async function toggle() {
114
129
  await nextTick();
115
130
  place();
116
131
  resetScroll();
117
- searchInput.value?.focus({ preventScroll: true });
132
+ if (tab.value === 'emoji' || tab.value === 'icons') {
133
+ searchInput.value?.focus({ preventScroll: true });
134
+ } else {
135
+ panel.value?.querySelector<HTMLElement>('[data-icon-choice][aria-pressed="true"], [data-icon-choice], [role="tab"][aria-selected="true"]')?.focus({ preventScroll: true });
136
+ }
118
137
  }
119
138
  function close(restoreFocus = false) {
120
139
  open.value = false;
@@ -238,7 +257,10 @@ onBeforeUnmount(() => {
238
257
  <button type="button" class="workspace-icon-picker-remove" :disabled="disabled || !icon" @click="select('')">{{ t('移除') }}</button>
239
258
  </header>
240
259
  <div :id="`${pickerId}-content`" class="workspace-icon-picker-content" role="tabpanel" :aria-labelledby="`${pickerId}-${tab}-tab`">
241
- <template v-if="tab !== 'upload'">
260
+ <template v-if="extraTab && tab === extraTab.id">
261
+ <slot name="extra-tab" :select="select" :close="close" :disabled="disabled" :icon="icon" />
262
+ </template>
263
+ <template v-else-if="tab !== 'upload'">
242
264
  <label class="workspace-icon-picker-search"><Search :size="15" aria-hidden="true" /><input ref="searchInput" v-model="query" :aria-label="t('筛选图标')" :placeholder="t('筛选…')" /></label>
243
265
  <div ref="scrollArea" class="workspace-icon-picker-scroll" @scroll="syncCategory">
244
266
  <section v-for="group in filteredGroups" :id="`${pickerId}-${group.id}`" :key="group.id" class="workspace-icon-picker-group" :data-category="group.id" :aria-label="group.label">
@@ -267,6 +289,7 @@ onBeforeUnmount(() => {
267
289
  <p class="workspace-icon-picker-upload-title">{{ t('上传{0}', [label]) }}</p>
268
290
  <div class="workspace-icon-picker-upload-actions">
269
291
  <button type="button" class="settings-button" :disabled="disabled" @click="upload">{{ t('选择图片') }}</button>
292
+ <slot name="upload-actions" :close="close" />
270
293
  <p class="workspace-icon-picker-upload-paste">{{ t('或按') }} <kbd>Ctrl+V</kbd> {{ t('粘贴图片') }}</p>
271
294
  </div>
272
295
  </div>
@@ -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>
@@ -1,151 +1,11 @@
1
- import {
2
- commentDataPath,
3
- emptyCommentFile,
4
- parseCommentFile,
5
- rebaseCommentMentions,
6
- } from '@tano/protocol';
7
- import type {
8
- CommentAnchor,
9
- CommentFile,
10
- CommentKind,
11
- CommentMessage,
12
- CommentMention,
13
- CommentThread,
14
- WorkspaceAdapter,
15
- Workspace,
16
- } from '@tano/protocol';
17
-
18
- export interface CommentAuthor { id: string; name: string }
19
- export type CommentStorage = Pick<WorkspaceAdapter, 'refresh' | 'read' | 'write' | 'create'>;
20
- export interface CommentMessageEdit { messageId: string; expectedBody: string; body: string; mentions?: CommentMention[] }
21
- export interface CommentMessageRemoval {
22
- messageId: string;
23
- expectedBody: string;
24
- expectedMessages?: { id: string; body: string }[];
25
- }
26
- const pendingWrites = new WeakMap<CommentStorage, Map<string, Promise<unknown>>>();
27
- export type CommentChange =
28
- | { type: 'start'; id: string; body: string; author: CommentAuthor; anchor?: CommentAnchor; mentions?: CommentMention[]; agentTaskId?: string }
29
- | { type: 'reply'; threadId: string; id: string; body: string; author: CommentAuthor; replyTo?: string; mentions?: CommentMention[]; agentTaskId?: string }
30
- | { type: 'resolve'; threadId: string; resolved: boolean }
31
- | ({ type: 'edit'; threadId: string; authorId: string } & CommentMessageEdit)
32
- | ({ type: 'delete'; threadId: string; authorId: string } & CommentMessageRemoval)
33
- | { type: 'reanchor'; threadId: string; expectedBaseHash: string; anchor: CommentAnchor | null };
34
-
35
- function message(id: string, body: string, author: CommentAuthor, mentions?: CommentMention[], replyTo?: string): CommentMessage {
36
- return { id, body: body.trim(), authorId: author.id, authorName: author.name, createdAt: Date.now(),
37
- ...(mentions?.length ? { mentions: rebaseCommentMentions(mentions, body, body.trim()) } : {}), ...(replyTo ? { replyTo } : {}) };
38
- }
39
-
40
- /** Each edit is reapplied to the newest file, so independent replies survive a CAS conflict. */
41
- export function applyCommentChange(file: CommentFile, change: CommentChange): CommentFile {
42
- const next = structuredClone(file);
43
- if (change.type === 'start') {
44
- if (next.threads.some(thread => thread.id === change.id)) return next;
45
- if (!change.body.trim()) throw new Error('请输入评论内容');
46
- if (next.kind === 'annotation' && !change.anchor) throw new Error('请先选择要批注的内容');
47
- if (next.kind === 'discussion' && change.anchor) throw new Error('整篇讨论不需要局部锚点');
48
- const createdAt = Date.now();
49
- next.threads.push({ id: change.id, ...(change.anchor ? { anchor: change.anchor } : {}),
50
- messages: [{ ...message(change.id, change.body, change.author, change.mentions),
51
- ...(change.agentTaskId ? { agentTaskId: change.agentTaskId } : {}) }], resolved: false,
52
- detached: false, createdAt });
53
- } else {
54
- const thread = next.threads.find(item => item.id === change.threadId);
55
- if (!thread && change.type === 'delete') return next;
56
- if (!thread) throw new Error('评论已被移除,请刷新后重试');
57
- if (change.type === 'reply') {
58
- if (thread.messages.some(item => item.id === change.id)) return next;
59
- if (!change.body.trim()) throw new Error('请输入回复内容');
60
- thread.messages.push({ ...message(change.id, change.body, change.author, change.mentions, change.replyTo),
61
- ...(change.agentTaskId ? { agentTaskId: change.agentTaskId } : {}) });
62
- } else if (change.type === 'resolve') thread.resolved = change.resolved;
63
- else if (change.type === 'edit' || change.type === 'delete') {
64
- const index = thread.messages.findIndex(item => item.id === change.messageId);
65
- const current = thread.messages[index];
66
- if (!current && change.type === 'delete') return next;
67
- if (!current) throw new Error('评论已被移除,请刷新后重试');
68
- if (current.authorId !== change.authorId) throw new Error('只能编辑或删除自己发表的评论');
69
- if (current.body !== change.expectedBody) throw new Error('评论已由其他编辑更新,请刷新后重试;输入内容仍保留');
70
- if (change.type === 'edit') {
71
- if (!change.body.trim()) throw new Error('请输入评论内容');
72
- current.mentions = change.mentions === undefined
73
- ? rebaseCommentMentions(current.mentions ?? [], current.body, change.body.trim())
74
- : rebaseCommentMentions(change.mentions, change.body, change.body.trim());
75
- current.body = change.body.trim();
76
- current.updatedAt = Date.now();
77
- } else if (index === 0) {
78
- if (!change.expectedMessages || change.expectedMessages.length !== thread.messages.length ||
79
- thread.messages.some((item, i) => item.id !== change.expectedMessages![i]?.id ||
80
- item.body !== change.expectedMessages![i]?.body))
81
- throw new Error('评论或回复已变化,请刷新后重新确认删除');
82
- next.threads = next.threads.filter(item => item.id !== thread.id);
83
- } else {
84
- thread.messages.splice(index, 1);
85
- for (const item of thread.messages) if (item.replyTo === change.messageId) delete item.replyTo;
86
- }
87
- }
88
- else {
89
- if (!thread.anchor || thread.anchor.baseHash !== change.expectedBaseHash)
90
- throw new Error('批注锚点已由其他编辑更新,请刷新后重试');
91
- if (change.anchor) thread.anchor = change.anchor;
92
- thread.detached = !change.anchor;
93
- }
94
- }
95
- return parseCommentFile(JSON.stringify(next), next.kind, next.fileId);
96
- }
97
-
98
- export async function loadCommentFile(adapter: CommentStorage, kind: CommentKind, fileId: string, workspaceSnapshot?: Workspace) {
99
- const path = commentDataPath(kind, fileId);
100
- const workspace = workspaceSnapshot ?? await adapter.refresh();
101
- if (!workspace.files.some(file => file.kind === 'file' && file.path === path))
102
- return { file: emptyCommentFile(kind, fileId), hash: null as string | null };
103
- const snapshot = await adapter.read(path);
104
- return { file: parseCommentFile(snapshot.content, kind, fileId), hash: snapshot.hash };
105
- }
106
-
107
- export async function saveCommentChange(
108
- adapter: CommentStorage,
109
- kind: CommentKind,
110
- fileId: string,
111
- change: CommentChange,
112
- ) {
113
- const path = commentDataPath(kind, fileId);
114
- let queued = pendingWrites.get(adapter);
115
- if (!queued) { queued = new Map(); pendingWrites.set(adapter, queued); }
116
- const previous = queued.get(path);
117
- const save = async () => {
118
- await previous?.catch(() => {});
119
- return writeCommentChange(adapter, kind, fileId, path, change);
120
- };
121
- const result = save();
122
- queued.set(path, result);
123
- try { return await result; }
124
- finally { if (queued.get(path) === result) queued.delete(path); }
125
- }
126
-
127
- async function writeCommentChange(
128
- adapter: CommentStorage, kind: CommentKind, fileId: string, path: string, change: CommentChange,
129
- ) {
130
- for (let attempt = 0; attempt < 5; attempt++) {
131
- const current = await loadCommentFile(adapter, kind, fileId);
132
- const updated = applyCommentChange(current.file, change);
133
- const content = `${JSON.stringify(updated, null, 2)}\n`;
134
- if (current.hash) {
135
- const result = await adapter.write(path, content, current.hash);
136
- if (result.status === 'saved') return updated;
137
- if (result.status === 'missing') continue;
138
- } else {
139
- try { await adapter.create(path, content); return updated; }
140
- catch (error) {
141
- const refreshed = await adapter.refresh();
142
- if (!refreshed.files.some(file => file.path === path)) throw error;
143
- }
144
- }
145
- }
146
- throw new Error('评论同时被修改,请稍后重试;输入内容仍保留');
147
- }
148
-
149
- export function visibleThreads(file: CommentFile): CommentThread[] {
150
- return file.threads.filter(thread => !thread.detached);
151
- }
1
+ export {
2
+ applyCommentChange,
3
+ loadCommentFile,
4
+ saveCommentChange,
5
+ visibleThreads,
6
+ type CommentAuthor,
7
+ type CommentChange,
8
+ type CommentMessageEdit,
9
+ type CommentMessageRemoval,
10
+ type CommentStorage,
11
+ } from '@tano/protocol/workspace-comments';
@@ -24,7 +24,7 @@ ${storage}
24
24
  - [ ] 点击左侧工作区名称旁的「新建文档」按钮,创建你的第一篇笔记。
25
25
  - [ ] 点击侧栏的搜索按钮,查找刚刚写下的内容。
26
26
  - [ ] 勾选一个方框,记录你已经完成的步骤。
27
- - [ ] 在工作区对象面板中查看文件资源,确认文档和附件仍是普通文件。
27
+ - [ ] 在文档中输入 \`@\` 引用人物、任务、文档或附件,确认文档和附件仍是普通文件。
28
28
  - [ ] 打开关系图,沿着稳定身份从文件回到对象,再回到原始文件。
29
29
 
30
30
  ## 让想法自然成形