@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
@@ -1,57 +1,72 @@
1
1
  <script setup lang="ts">
2
+ import './plugin-center.css';
2
3
  import { recordHelpCompleted } from '../../help/help-checklist';
3
4
  import { usePluginActions, matchesPlugin } from '../use-plugin-actions';
4
5
  import LoadingSkeleton from '../../shell/components/LoadingSkeleton.vue';
5
6
  import { retiredSystemPlugin } from '../workspace-plugins';
6
7
  import { t } from '../../i18n/i18n';
7
- import { computed, nextTick, ref, watch } from 'vue';
8
+ import { computed, inject, nextTick, ref, useSlots, watch } from 'vue';
8
9
  import {
9
- ArrowUpRight,
10
10
  Check,
11
11
  ChevronDown,
12
- Download,
13
- LoaderCircle,
12
+ Code2,
14
13
  Package,
14
+ Plus,
15
15
  Search,
16
- ShieldCheck,
17
- Upload,
18
16
  X,
19
17
  } from 'lucide-vue-next';
20
- import { parsePluginPackage, pluginPackageLimit } from '@tano/protocol';
21
- import type { PluginManifest, PluginPackage } from '@tano/protocol';
18
+ import type { PluginManifest, WorkspacePersonalPluginPolicy } from '@tano/protocol';
19
+ import { useWorkbenchRuntime } from '../../runtime';
20
+ import { workbenchPrefsKey } from '../../shell/workbench-context';
22
21
  import PluginRuntimePanel from './PluginRuntimePanel.vue';
23
-
24
- import PluginChangeSummary from './PluginChangeSummary.vue';
25
- import PluginRepositoryStorage from './PluginRepositoryStorage.vue';
26
22
  import PluginCatalogBrowser from './PluginCatalogBrowser.vue';
27
23
  import PluginConnections from './PluginConnections.vue';
28
24
  import PluginAutomations from './PluginAutomations.vue';
29
- import { documentOverviewPlugin } from '../example';
25
+ import PluginImportDialog from './PluginImportDialog.vue';
26
+ import PluginDeveloperArea from './PluginDeveloperArea.vue';
30
27
 
31
28
  import { useWorkspaceStore } from '../../stores/workspace';
32
29
 
33
- import PluginDialog from './PluginDialog.vue';
34
-
35
30
  import PluginListItem from './PluginListItem.vue';
36
31
  import { bundledPluginCatalog, type PluginCatalogEntry } from '../plugin-catalog';
37
32
 
38
- const props = withDefaults(defineProps<{ catalog?: readonly PluginCatalogEntry[] }>(), {
39
- catalog: () => bundledPluginCatalog,
40
- });
33
+ const props = withDefaults(
34
+ defineProps<{
35
+ catalog?: readonly PluginCatalogEntry[];
36
+ developerMode?: boolean;
37
+ }>(),
38
+ {
39
+ catalog: () => bundledPluginCatalog,
40
+ developerMode: undefined,
41
+ },
42
+ );
43
+ const slots = useSlots();
44
+ const workbench = inject(workbenchPrefsKey, null);
45
+ const runtime = useWorkbenchRuntime();
41
46
  const store = useWorkspaceStore();
42
47
  const { error, status, pending, busy, change, installFromCatalog } = usePluginActions(undefined, () => props.catalog);
43
- watch(status, value => { if (value && importing.value) { importing.value = false; preview.value = undefined; manifestText.value = ''; chooseView('installed'); } });
44
- defineExpose({ openImport });
45
- const emit = defineEmits<{ objects: []; feedback: [status: string, error: string] }>();
48
+ const emit = defineEmits<{
49
+ createObject: [type: string];
50
+ feedback: [status: string, error: string];
51
+ enableDeveloperMode: [];
52
+ }>();
53
+
54
+ const localDeveloperMode = ref(false);
55
+ const isDeveloperMode = computed(
56
+ () => props.developerMode ?? (workbench ? Boolean(workbench.developerMode) : localDeveloperMode.value),
57
+ );
58
+ const communityAvailable = computed(() => Boolean(store.pluginCatalogSource));
59
+ const automationsAvailable = computed(() => Boolean(runtime.plugins?.automations));
60
+ const pluginObjectTypes = computed(() =>
61
+ store.objectDefinitions.filter((type) => type.category === 'plugin' && type.storage === 'record'),
62
+ );
46
63
  watch([status, error], ([message, failure]) => emit('feedback', message, failure));
47
- const input = ref<HTMLInputElement>();
64
+
48
65
  const search = ref<HTMLInputElement>();
49
- const manifestText = ref('');
50
- const preview = ref<PluginManifest>();
51
- const previewPackage = ref<PluginPackage>();
52
- type View = 'discover' | 'installed' | 'community' | 'publishing';
66
+ type View = 'discover' | 'installed' | 'community' | 'customize' | 'developer';
53
67
  const view = ref<View>('discover');
54
- const publishingOpened = ref(false);
68
+ const developerOpened = ref(false);
69
+ const developerSection = ref<'tools' | 'forge' | 'publishing'>('tools');
55
70
  const query = ref('');
56
71
  const category = ref('all');
57
72
  const installedFilter = ref('all');
@@ -72,8 +87,6 @@ const installedById = computed(
72
87
  () => new Map(store.installedPlugins.map((item) => [item.manifest.id, item])),
73
88
  );
74
89
  const feedbackError = computed(() => error.value || store.pluginError);
75
- const hasDialog = computed(() => importing.value);
76
- let importSequence = 0;
77
90
 
78
91
  const matches = (plugin: PluginManifest) => matchesPlugin(plugin, query.value);
79
92
  const catalog = computed(() =>
@@ -112,14 +125,46 @@ const resultsTitle = computed(() =>
112
125
  watch([view, query, category, installedFilter, () => props.catalog], () => {
113
126
  visibleLimit.value = pageSize;
114
127
  });
128
+ watch(isDeveloperMode, (enabled) => {
129
+ if (!enabled) {
130
+ developerOpened.value = false;
131
+ if (view.value === 'developer') view.value = 'discover';
132
+ }
133
+ });
134
+ watch(communityAvailable, (available) => {
135
+ if (!available && view.value === 'community') {
136
+ view.value = 'discover';
137
+ }
138
+ });
115
139
 
116
140
  function chooseView(value: View) {
117
- if (value === 'publishing') publishingOpened.value = true;
141
+ if (value === 'community' && !communityAvailable.value) return;
142
+ if (value === 'customize' && !slots.customize) return;
143
+ if (value === 'developer' && !isDeveloperMode.value) return;
144
+ if (value === 'developer') developerOpened.value = true;
118
145
  view.value = value;
119
146
  query.value = '';
120
147
  category.value = 'all';
121
148
  installedFilter.value = 'all';
122
149
  }
150
+ function enableDeveloperArea() {
151
+ if (workbench) {
152
+ workbench.developerMode = true;
153
+ } else {
154
+ localDeveloperMode.value = true;
155
+ }
156
+ emit('enableDeveloperMode');
157
+ nextTick(() => {
158
+ if (isDeveloperMode.value) {
159
+ developerSection.value = 'tools';
160
+ chooseView('developer');
161
+ }
162
+ });
163
+ }
164
+ function updatePersonalPolicy(value: WorkspacePersonalPluginPolicy) {
165
+ if (!store.workspace) return;
166
+ void change({ personalCodePlugins: value });
167
+ }
123
168
  function clearFilters() {
124
169
  query.value = '';
125
170
  category.value = 'all';
@@ -130,295 +175,235 @@ function browse() {
130
175
  chooseView('discover');
131
176
  nextTick(() => search.value?.focus());
132
177
  }
133
- function showDetails(plugin: PluginManifest) { recordHelpCompleted('plugins', 'plugin-details'); void store.openPluginDetail(plugin.id); }
178
+ function showDetails(plugin: PluginManifest) {
179
+ recordHelpCompleted('plugins', 'plugin-details');
180
+ void store.openPluginDetail(plugin.id);
181
+ }
134
182
  function openImport() {
135
183
  error.value = '';
136
184
  status.value = '';
137
185
  importing.value = true;
138
186
  }
139
- function closeDialog() {
140
- if (busy.value) return;
141
- importSequence++;
142
-
143
- importing.value = false;
144
- manifestText.value = '';
145
- preview.value = undefined;
146
- error.value = '';
147
- }
187
+ defineExpose({ openImport });
148
188
  watch(
149
189
  () => store.workspace?.id,
150
190
  () => {
151
- importSequence++;
152
191
  importing.value = false;
153
-
154
- manifestText.value = '';
155
- preview.value = undefined;
192
+ developerOpened.value = false;
156
193
  error.value = '';
157
194
  status.value = '';
158
195
  chooseView('discover');
159
196
  },
160
197
  );
161
- watch(manifestText, () => {
162
- preview.value = undefined;
163
- previewPackage.value = undefined;
164
- });
165
- function inspect() {
166
- error.value = '';
167
- status.value = '';
168
- preview.value = undefined;
169
- try {
170
- previewPackage.value = parsePluginPackage(manifestText.value);
171
- preview.value = previewPackage.value.manifest;
172
- } catch (cause) {
173
- error.value =
174
- cause instanceof SyntaxError
175
- ? t('JSON 格式有误,请检查引号、逗号和括号后重试。')
176
- : String(cause);
177
- }
178
- }
179
- async function importFile(event: Event) {
180
- const file = (event.target as HTMLInputElement).files?.[0];
181
- (event.target as HTMLInputElement).value = '';
182
- if (!file) return;
183
- preview.value = undefined;
184
- error.value = '';
185
- status.value = '';
186
- const workspace = store.workspace?.id;
187
- const sequence = ++importSequence;
188
- try {
189
- if (file.size > pluginPackageLimit) throw new Error(t('插件包不能超过 4 MiB'));
190
- const content = await file.text();
191
- if (store.workspace?.id !== workspace || sequence !== importSequence) return;
192
- manifestText.value = content;
193
- // Watch invalidation must finish before publishing the inspected preview.
194
- await nextTick();
195
- if (store.workspace?.id === workspace && sequence === importSequence) inspect();
196
- } catch (cause) {
197
- if (store.workspace?.id === workspace && sequence === importSequence)
198
- error.value = String(cause);
199
- }
200
- }
201
- async function importCachedPackage() {
202
- try { await store.cachePluginPackage(manifestText.value); status.value = t('插件包已保存到此设备,请在详情中授权运行'); await store.refresh(); }
203
- catch (cause) { error.value = String(cause); }
204
- }
205
198
  </script>
206
199
 
207
200
  <template>
208
201
  <div class="plugin-center">
209
202
  <LoadingSkeleton v-if="store.workspaceLoading?.plugins" :rows="6" />
210
203
  <div v-show="!store.workspaceLoading?.plugins" class="component-loading-content">
211
- <div class="catalog-controls">
212
- <header class="center-heading">
213
- <div class="center-title">
214
- <h1>{{ t('插件') }}</h1>
215
- <p>{{ t('发现、安装和管理你的同页扩展。') }}</p>
216
- </div>
217
- <div class="heading-actions">
218
- <label v-if="view === 'discover' || view === 'installed'" class="plugin-search"
219
- ><Search :size="15" aria-hidden="true" />
220
- <input
221
- ref="search"
222
- v-model="query"
223
- type="search"
224
- :aria-label="t('查找插件')"
225
- :placeholder="view === 'discover' ? t('搜索插件') : t('搜索已安装插件')"
226
- />
204
+ <div class="catalog-controls">
205
+ <header class="center-heading">
206
+ <div class="center-title">
207
+ <h1>{{ t('插件') }}</h1>
208
+ <p>{{ t('发现、安装和管理你的同页扩展。') }}</p>
209
+ </div>
210
+ <div class="heading-actions">
211
+ <label v-if="view === 'discover' || view === 'installed'" class="plugin-search"
212
+ ><Search :size="15" aria-hidden="true" />
213
+ <input
214
+ ref="search"
215
+ v-model="query"
216
+ type="search"
217
+ :aria-label="t('查找插件')"
218
+ :placeholder="view === 'discover' ? t('搜索插件') : t('搜索已安装插件')"
219
+ />
220
+ <button
221
+ v-if="query"
222
+ :aria-label="t('清空搜索')"
223
+ @click="
224
+ query = '';
225
+ search?.focus();
226
+ "
227
+ >
228
+ <X :size="14" />
229
+ </button>
230
+ </label>
231
+ </div>
232
+ </header>
233
+ <div class="catalog-navigation">
234
+ <nav class="center-nav" :aria-label="t('插件中心导航')">
227
235
  <button
228
- v-if="query"
229
- :aria-label="t('清空搜索')"
230
- @click="
231
- query = '';
232
- search?.focus();
233
- "
236
+ :class="{ active: view === 'discover' }"
237
+ :aria-pressed="view === 'discover'"
238
+ @click="chooseView('discover')"
234
239
  >
235
- <X :size="14" />
240
+ {{ t('发现') }}
236
241
  </button>
242
+ <button
243
+ v-if="communityAvailable"
244
+ :class="{ active: view === 'community' }"
245
+ :aria-pressed="view === 'community'"
246
+ @click="chooseView('community')"
247
+ >
248
+ {{ t('社区目录') }}
249
+ </button>
250
+ <button
251
+ :class="{ active: view === 'installed' }"
252
+ :aria-pressed="view === 'installed'"
253
+ @click="chooseView('installed')"
254
+ >
255
+ {{ t('已安装') }} <span class="nav-count">{{ store.installedPlugins.length }}</span>
256
+ </button>
257
+ <button
258
+ v-if="$slots.customize"
259
+ :class="{ active: view === 'customize' }"
260
+ :aria-pressed="view === 'customize'"
261
+ @click="chooseView('customize')"
262
+ >
263
+ {{ t('工作台微调') }}
264
+ </button>
265
+ <button
266
+ v-if="isDeveloperMode"
267
+ :class="{ active: view === 'developer' }"
268
+ :aria-pressed="view === 'developer'"
269
+ @click="chooseView('developer')"
270
+ >
271
+ <Code2 :size="14" aria-hidden="true" />{{ t('开发者') }}
272
+ </button>
273
+ </nav>
274
+ <label v-if="view === 'discover' || view === 'installed'" class="catalog-filter">
275
+ <select v-if="view === 'discover'" v-model="category" :aria-label="t('插件分类')">
276
+ <option value="all">{{ t('全部分类') }}</option>
277
+ <option v-for="group in categories" :key="group.id" :value="group.id">
278
+ {{ group.label }} · {{ group.count }}
279
+ </option>
280
+ </select>
281
+ <select v-else v-model="installedFilter" :aria-label="t('安装状态')">
282
+ <option value="all">{{ t('全部状态') }}</option>
283
+ <option value="enabled">{{ t('已启用') }}</option>
284
+ <option value="disabled">{{ t('已停用') }}</option>
285
+ </select>
286
+ <ChevronDown :size="13" aria-hidden="true" />
237
287
  </label>
238
- <button v-if="view === 'community' && $slots.publishing" class="pc-button pc-primary" @click="chooseView('publishing')">
239
- <Upload :size="15" />{{ t('发布插件') }}
240
- </button>
241
- <button v-if="view !== 'publishing'" class="pc-button pc-add" :aria-label="t('导入插件')" @click="openImport">
242
- <Upload :size="15" />{{ t('导入') }}
243
- </button>
244
288
  </div>
245
- </header>
246
- <div class="catalog-navigation">
247
- <nav class="center-nav" :aria-label="t('插件中心导航')">
248
- <button :class="{ active: view === 'community' }" :aria-pressed="view === 'community'" @click="chooseView('community')">{{ t('社区目录') }}</button>
249
- <button
250
- :class="{ active: view === 'discover' }"
251
- :aria-pressed="view === 'discover'"
252
- @click="chooseView('discover')"
253
- >
254
- {{ t('发现') }}
255
- </button>
256
- <button
257
- :class="{ active: view === 'installed' }"
258
- :aria-pressed="view === 'installed'"
259
- @click="chooseView('installed')"
260
- >
261
- {{ t('已安装') }} <span class="nav-count">{{ store.installedPlugins.length }}</span>
262
- </button>
263
- <button v-if="$slots.publishing" :class="{ active: view === 'publishing' }" :aria-pressed="view === 'publishing'" @click="chooseView('publishing')">{{ t('我的投稿') }}</button>
264
- </nav>
265
- <label v-if="view === 'discover' || view === 'installed'" class="catalog-filter">
266
- <select v-if="view === 'discover'" v-model="category" :aria-label="t('插件分类')">
267
- <option value="all">{{ t('全部分类') }}</option>
268
- <option v-for="group in categories" :key="group.id" :value="group.id">
269
- {{ group.label }} · {{ group.count }}
270
- </option>
271
- </select>
272
- <select v-else v-model="installedFilter" :aria-label="t('安装状态')">
273
- <option value="all">{{ t('全部状态') }}</option>
274
- <option value="enabled">{{ t('已启用') }}</option>
275
- <option value="disabled">{{ t('已停用') }}</option>
276
- </select>
277
- <ChevronDown :size="13" aria-hidden="true" />
278
- </label>
279
289
  </div>
280
- </div>
281
-
282
- <template v-if="!hasDialog && view !== 'publishing'">
283
- <p v-if="feedbackError" class="pc-feedback error" role="alert">{{ feedbackError }}</p>
284
- <p v-if="status" class="pc-feedback success" role="status">
285
- <Check :size="15" />{{ status }}
286
- </p>
287
- </template>
288
290
 
289
- <PluginCatalogBrowser v-if="view === 'community'" />
290
- <section v-else-if="view !== 'publishing'"
291
- class="catalog-results"
292
- :aria-label="view === 'discover' ? t('可安装插件') : t('已安装插件')"
293
- >
294
- <div class="catalog-heading">
295
- <h2>{{ resultsTitle }}</h2>
296
- <span class="result-count" role="status" :aria-label="t('{0} 款插件', [resultCount])">{{
297
- resultCount
298
- }}</span>
299
- </div>
300
- <div v-if="visiblePlugins.length" class="plugin-list">
301
- <PluginListItem
302
- v-for="plugin in visiblePlugins"
303
- :key="plugin.id"
304
- :plugin="plugin"
305
- :installed="installedById.has(plugin.id)"
306
- :enabled="installedById.get(plugin.id)?.enabled"
307
- :show-state="view === 'installed'"
308
- :busy="busy || !store.canManagePlugins"
309
- :pending="pending === plugin.id"
310
- @details="showDetails(plugin)"
311
- @install="installFromCatalog(plugin)"
312
- />
313
- </div>
314
- <div v-else-if="view === 'installed' && !store.installedPlugins.length" class="pc-empty">
315
- <Package :size="28" :stroke-width="1.4" />
316
- <h3>{{ t('还没有安装插件') }}</h3>
317
- <p>{{ t('去发现适合你的插件,或导入自己的插件。') }}</p>
318
- <button class="pc-button pc-secondary" @click="browse">{{ t('浏览插件') }}</button>
319
- </div>
320
- <div v-else class="pc-empty">
321
- <Search :size="28" :stroke-width="1.4" />
322
- <h3>{{ t('没有找到匹配的插件') }}</h3>
323
- <p>{{ t('试试其他关键词,或调整筛选条件。') }}</p>
324
- <button class="pc-button pc-secondary" @click="clearFilters">{{ t('重置筛选') }}</button>
325
- </div>
326
- <div v-if="remaining" class="catalog-more">
327
- <button class="pc-button pc-secondary" @click="visibleLimit += pageSize">
328
- {{ t('显示更多') }} <ChevronDown :size="14" /></button
329
- ><span>{{ t('已显示') }} {{ visiblePlugins.length }} / {{ resultCount }}</span>
330
- </div>
331
- <p v-if="view === 'installed' && visiblePlugins.length" class="installed-note">
332
- {{ t('插件版本与共享设置跟随工作区;个人启用和代码授权保存在此设备。卸载后保留已有内容。') }}
333
- </p>
334
- </section>
291
+ <template v-if="!importing && view !== 'developer'">
292
+ <p v-if="feedbackError" class="pc-feedback error" role="alert">{{ feedbackError }}</p>
293
+ <p v-if="status" class="pc-feedback success" role="status">
294
+ <Check :size="15" />{{ status }}
295
+ </p>
296
+ </template>
335
297
 
336
- <div v-if="publishingOpened && $slots.publishing" v-show="view === 'publishing'">
337
- <slot name="publishing" />
338
- </div>
339
- <template v-if="view !== 'publishing'">
340
- <PluginRuntimePanel />
341
- <PluginConnections />
342
- <PluginAutomations />
343
- <PluginRepositoryStorage />
344
- </template>
345
- <footer v-if="view !== 'publishing'" class="center-footer">
346
- <span>{{ store.pluginCatalogSource ? t('社区目录已接入 · 版本由工作区管理员选择') : t('当前提供内置插件与文件导入 · 社区目录尚未配置') }}</span
347
- ><button @click="emit('objects')">{{ t('管理工作区对象') }} <ArrowUpRight :size="13" /></button>
348
- </footer>
349
- <Teleport to="body"><PluginDialog
350
- v-if="hasDialog"
351
- :title="importing ? t('导入插件') : t('插件详情')"
352
- :busy="busy"
353
- @close="closeDialog"
354
- >
355
- <p v-if="feedbackError" class="pc-feedback error" role="alert">{{ feedbackError }}</p>
356
- <p v-if="status" class="pc-feedback success" role="status">
357
- <Check :size="16" />{{ status }}
358
- </p>
359
- <template v-if="importing">
360
- <p class="dialog-intro">{{ t('导入声明式清单或代码插件包。管理员为工作区安装,成员可补充此设备缺少的插件包。') }}</p>
361
- <button class="pc-button pc-secondary" @click="manifestText = JSON.stringify(documentOverviewPlugin, null, 2)">{{ t('载入文档总览示例') }}</button>
362
- <input
363
- ref="input"
364
- type="file"
365
- accept=".json,application/json"
366
- hidden
367
- @change="importFile"
368
- />
369
- <button class="import-file" :disabled="busy" @click="input?.click()">
370
- <Upload :size="25" /><strong>{{ t('选择 JSON 文件') }}</strong
371
- ><span>{{ t('支持 .json 文件,最大 4 MiB') }}</span>
372
- </button>
373
- <label class="manifest-label" for="plugin-manifest">{{ t('或粘贴插件清单') }}</label>
374
- <textarea
375
- id="plugin-manifest"
376
- v-model="manifestText"
377
- :aria-label="t('插件 JSON 清单')"
378
- :disabled="busy"
379
- spellcheck="false"
380
- :placeholder="t('在此粘贴 JSON 内容…')"
381
- rows="6"
382
- />
383
- <div class="import-check">
384
- <span>{{ t('代码插件需要单独授权;导入和检查不会执行脚本。') }}</span
385
- ><button
386
- class="pc-button pc-secondary"
387
- :disabled="!manifestText.trim() || busy"
388
- @click="inspect"
389
- >
390
- {{ t('检查清单') }}
391
- </button>
298
+ <PluginDeveloperArea
299
+ v-if="developerOpened && isDeveloperMode"
300
+ v-show="view === 'developer'"
301
+ :can-publish="!!$slots.publishing"
302
+ :initial-section="developerSection"
303
+ @open-import="openImport"
304
+ >
305
+ <template v-if="$slots.forge" #forge="slotProps">
306
+ <slot name="forge" v-bind="slotProps" />
307
+ </template>
308
+ <template v-if="$slots.publishing" #publishing="slotProps">
309
+ <slot name="publishing" v-bind="slotProps" />
310
+ </template>
311
+ </PluginDeveloperArea>
312
+ <PluginCatalogBrowser v-if="view === 'community' && communityAvailable" />
313
+ <slot v-else-if="view === 'customize' && $slots.customize" name="customize" :developer-mode="isDeveloperMode" />
314
+ <section
315
+ v-else-if="view === 'discover' || view === 'installed'"
316
+ class="catalog-results"
317
+ :aria-label="view === 'discover' ? t('可安装插件') : t('已安装插件')"
318
+ >
319
+ <div class="catalog-heading">
320
+ <h2>{{ resultsTitle }}</h2>
321
+ <span class="result-count" role="status" :aria-label="t('{0} 款插件', [resultCount])">{{
322
+ resultCount
323
+ }}</span>
392
324
  </div>
393
- <div v-if="preview" class="plugin-preview">
394
- <div>
395
- <Check :size="17" /><strong>{{ preview.name }}</strong
396
- ><span>v{{ preview.version }}</span>
397
- </div>
398
- <p>{{ preview.description }}</p>
399
- <PluginChangeSummary :before="installedById.get(preview.id)?.manifest" :after="preview" :workspace="store.workspace?.name" />
400
- <p>
401
- {{ preview.objectTypes.map((item) => item.label).join('、') || t('无新增对象类型') }} ·
402
- {{ preview.relationTypes.length }} {{ t('种关系') }}
403
- </p>
404
- <button
405
- class="pc-button pc-primary"
406
- :disabled="busy || !store.canManagePlugins"
407
- @click="change({ install: preview, package: previewPackage })"
408
- >
409
- <Download :size="15" />{{
410
- installedById.has(preview.id) ? t('更新并启用插件') : t('安装此插件')
411
- }}
412
- </button>
413
- <button v-if="preview.manifestVersion === 2" class="pc-button pc-secondary" :disabled="busy" @click="importCachedPackage">{{ t('仅保存到此设备') }}</button>
325
+ <div v-if="visiblePlugins.length" class="plugin-list">
326
+ <PluginListItem
327
+ v-for="plugin in visiblePlugins"
328
+ :key="plugin.id"
329
+ :plugin="plugin"
330
+ :installed="installedById.has(plugin.id)"
331
+ :enabled="installedById.get(plugin.id)?.enabled"
332
+ :scope="installedById.get(plugin.id)?.scope"
333
+ :show-state="view === 'installed'"
334
+ :busy="busy || !store.canManagePlugins"
335
+ :pending="pending === plugin.id"
336
+ @details="showDetails(plugin)"
337
+ @install="installFromCatalog(plugin)"
338
+ />
414
339
  </div>
415
- </template>
416
- </PluginDialog></Teleport>
340
+ <div v-else-if="view === 'installed' && !store.installedPlugins.length" class="pc-empty">
341
+ <Package :size="28" :stroke-width="1.4" />
342
+ <h3>{{ t('还没有安装插件') }}</h3>
343
+ <p>{{ t('去发现适合你的插件,扩展你的工作台能力。') }}</p>
344
+ <button class="pc-button pc-secondary" @click="browse">{{ t('浏览插件') }}</button>
345
+ </div>
346
+ <div v-else class="pc-empty">
347
+ <Search :size="28" :stroke-width="1.4" />
348
+ <h3>{{ t('没有找到匹配的插件') }}</h3>
349
+ <p>{{ t('试试其他关键词,或调整筛选条件。') }}</p>
350
+ <button class="pc-button pc-secondary" @click="clearFilters">{{ t('重置筛选') }}</button>
351
+ </div>
352
+ <div v-if="remaining" class="catalog-more">
353
+ <button class="pc-button pc-secondary" @click="visibleLimit += pageSize">
354
+ {{ t('显示更多') }} <ChevronDown :size="14" /></button
355
+ ><span>{{ t('已显示') }} {{ visiblePlugins.length }} / {{ resultCount }}</span>
356
+ </div>
357
+
358
+ <template v-if="view === 'installed'">
359
+ <p v-if="visiblePlugins.length" class="installed-note">
360
+ {{ t('工作区插件与共享设置跟随工作区;全局插件、个人启用和代码授权保存在此设备,跨工作区生效。卸载后保留已有内容。') }}
361
+ </p>
362
+ <div v-if="store.canManagePlugins && store.workspace" class="workspace-plugin-policy">
363
+ <label>
364
+ <span>{{ t('本工作区对个人代码插件的策略') }}</span>
365
+ <select
366
+ :value="store.personalCodePluginPolicy"
367
+ :disabled="busy"
368
+ :aria-label="t('本工作区对个人代码插件的策略')"
369
+ @change="updatePersonalPolicy(($event.target as HTMLSelectElement).value as WorkspacePersonalPluginPolicy)"
370
+ >
371
+ <option value="allow">{{ t('允许运行(遵循个人授权)') }}</option>
372
+ <option value="read-only">{{ t('仅允许只读访问(禁止写入)') }}</option>
373
+ <option value="block">{{ t('禁止个人代码插件访问本工作区') }}</option>
374
+ </select>
375
+ </label>
376
+ </div>
377
+ <PluginRuntimePanel v-if="store.pluginRuntime.length" />
378
+ <PluginConnections v-if="store.pluginConnectionStorageLabel" />
379
+ <PluginAutomations v-if="automationsAvailable" />
380
+ </template>
381
+ </section>
382
+
383
+ <footer v-if="view !== 'developer' && view !== 'customize'" class="center-footer">
384
+ <span v-if="communityAvailable">{{ t('社区目录已接入 · 版本由工作区管理员选择') }}</span>
385
+ <button
386
+ v-if="!isDeveloperMode"
387
+ type="button"
388
+ class="dev-optin-link"
389
+ @click="enableDeveloperArea"
390
+ >
391
+ <Code2 :size="13" aria-hidden="true" />{{ t('开启开发者模式以导入或开发插件') }}
392
+ </button>
393
+ <button
394
+ v-if="pluginObjectTypes.length"
395
+ :disabled="!store.workspace || store.workspace.readOnly || !store.capabilities.features.objectReferences"
396
+ @click="emit('createObject', pluginObjectTypes[0]!.type)"
397
+ >
398
+ <Plus :size="13" />{{ t('新建插件对象') }}
399
+ </button>
400
+ </footer>
401
+ <PluginImportDialog
402
+ v-if="importing"
403
+ @close="importing = false"
404
+ @installed="chooseView('installed')"
405
+ @feedback="(message, failure) => { status = message; error = failure; }"
406
+ />
417
407
  </div>
418
408
  </div>
419
409
  </template>
420
-
421
- <style scoped src="./plugin-center.css"></style>
422
-
423
- <style scoped>
424
- </style>