@vetta-org/theme-ui 0.1.0 → 0.1.2
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 +735 -7
- package/src/action-approval/AppearanceActionPickerView.tsx +2 -78
- package/src/action-approval/AppearanceApprovalDrawerView.tsx +2 -9
- package/src/action-approval/BatchTasksApprovalFrameView.tsx +4 -1
- package/src/action-approval/GenericActionApprovalView.tsx +2 -9
- package/src/action-approval/ManageActionApprovalFrameView.tsx +4 -1
- package/src/action-approval/NavigationOpenApprovalView.tsx +2 -9
- package/src/action-approval/SchedulerActionApprovalDialogView.tsx +3 -1
- package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +3 -10
- package/src/action-approval/index.ts +0 -1
- package/src/activity/ActivityPanel.tsx +13 -10
- package/src/activity/ActivityPanelFrame.test.tsx +32 -0
- package/src/activity/ActivityPanelFrame.tsx +3 -2
- package/src/activity/BackgroundTasksTabPanelView.tsx +1 -1
- package/src/activity/BrowserPanelView.tsx +48 -49
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.tsx +56 -59
- package/src/activity/PluginTabPickerView.tsx +5 -3
- package/src/activity/PortsTabPanelView.tsx +911 -0
- package/src/activity/ToolCallsSubTabView.tsx +1 -1
- package/src/activity/WorkflowTabPanelView.tsx +1 -1
- package/src/activity/index.ts +9 -0
- package/src/app/AppBackground.tsx +1 -1
- package/src/app/AppBootLoadingView.tsx +4 -2
- package/src/app-shell/DefaultWindowControls.tsx +1 -1
- package/src/app-shell/PageHeaderActionGroup.tsx +1 -1
- package/src/app-shell/PageHeaderContent.tsx +36 -7
- package/src/app-shell/PageHeaderFrame.tsx +15 -3
- package/src/app-shell/PageHeaderSidebarTrigger.tsx +1 -1
- package/src/app-shell/PageHeaderTitle.tsx +1 -1
- package/src/app-shell/WindowControlButton.tsx +1 -1
- package/src/app-shell/header-crowding.test.ts +62 -0
- package/src/app-shell/header-crowding.tsx +137 -0
- package/src/appearance/BackgroundImageFrame.tsx +1 -1
- package/src/appearance/CenterSliceImageFrame.tsx +1 -1
- package/src/appearance/CornerImageFrame.tsx +1 -1
- package/src/appearance/HorizontalSliceImageFrame.tsx +1 -1
- package/src/appearance/NineSliceImageFrame.tsx +1 -1
- package/src/appearance/ThemeSurface.tsx +1 -1
- package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +2 -1
- package/src/batch-tasks/BatchTaskProjectActionsView.test.tsx +97 -0
- package/src/batch-tasks/BatchTaskProjectActionsView.tsx +45 -35
- package/src/batch-tasks/batchTaskUi.tsx +0 -29
- package/src/bottom-panel/BottomPanelView.test.tsx +43 -0
- package/src/bottom-panel/BottomPanelView.tsx +222 -0
- package/src/bottom-panel/index.ts +26 -0
- package/src/chat/AgentAvatarView.tsx +1 -1
- package/src/chat/AnnotationViews.tsx +107 -0
- package/src/chat/AskUserQuestionView.tsx +18 -11
- package/src/chat/AssistantMessageView.tsx +48 -13
- package/src/chat/AtPanelView.test.tsx +61 -0
- package/src/chat/AtPanelView.tsx +63 -38
- package/src/chat/BashTerminalCard.tsx +1 -2
- package/src/chat/ChatHeaderActionsView.tsx +74 -18
- package/src/chat/CompactionStepView.test.tsx +34 -0
- package/src/chat/CompactionStepView.tsx +85 -0
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +731 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +137 -0
- package/src/chat/InlineModelPicker.test.tsx +81 -0
- package/src/chat/InlineModelPicker.tsx +201 -0
- package/src/chat/InlineTokenChip.tsx +2 -68
- package/src/chat/InputBarBackground.tsx +1 -1
- package/src/chat/InputBarPlaceholder.tsx +26 -3
- package/src/chat/LiveThinkingView.tsx +51 -37
- package/src/chat/MessageBoundaryViews.tsx +21 -0
- package/src/chat/MessageFeedContext.tsx +13 -5
- package/src/chat/MessageFeedLayoutView.tsx +28 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +1 -1
- package/src/chat/MessageLayoutView.tsx +1 -1
- package/src/chat/MessageSelectionContextMenuView.tsx +4 -1
- package/src/chat/MessageTimelineView.tsx +1 -1
- package/src/chat/MessageView.tsx +1 -1
- package/src/chat/MessageVisualView.tsx +1 -1
- package/src/chat/ModelConfiguration.tsx +283 -0
- package/src/chat/ModelSelectorTrigger.tsx +63 -0
- package/src/chat/ModelSelectorView.tsx +1037 -223
- package/src/chat/NewSession.ts +1 -37
- package/src/chat/NewSessionPicker.tsx +3 -2
- package/src/chat/ProjectSelectorView.tsx +3 -2
- package/src/chat/ReasoningStepSlider.tsx +61 -0
- package/src/chat/RemoteSessionBadgeView.tsx +24 -0
- package/src/chat/SkillPromptAreaView.tsx +5 -19
- package/src/chat/TeamMemberReplyCardView.test.tsx +33 -0
- package/src/chat/TeamMemberReplyCardView.tsx +133 -0
- package/src/chat/TextBlockView.tsx +7 -770
- package/src/chat/TodoProgress.tsx +25 -53
- package/src/chat/TodoStatusBarView.tsx +14 -5
- package/src/chat/UserMessageView.tsx +113 -33
- package/src/chat/header-action-narrow.test.ts +21 -0
- package/src/chat/header-action-narrow.ts +38 -0
- package/src/chat/index.ts +32 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/send-button.css +4 -22
- package/src/chat/streaming-reveal.test.ts +218 -0
- package/src/chat/streaming-reveal.ts +13 -0
- package/src/file-explorer/ConfirmDeleteDialogView.tsx +2 -1
- package/src/file-explorer/FileContextMenuView.tsx +44 -11
- package/src/file-explorer/FileExplorerSettingsView.tsx +97 -0
- package/src/file-explorer/FileTreeCreateRow.tsx +1 -1
- package/src/file-explorer/FileTreeNodeView.tsx +59 -18
- package/src/file-explorer/FileTreeView.tsx +236 -129
- package/src/file-explorer/file-tree-dom.ts +23 -0
- package/src/file-explorer/file-tree-rows.test.ts +74 -0
- package/src/file-explorer/file-tree-rows.ts +168 -0
- package/src/file-explorer/index.ts +17 -0
- package/src/file-explorer/types.ts +3 -0
- package/src/file-explorer/useFileTreeMarqueeSelection.ts +24 -16
- package/src/file-preview/FilePreviewDialogView.tsx +2 -2
- package/src/file-preview/FilePreviewView.tsx +12 -2
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/index.ts +1 -0
- package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +1 -1
- package/src/layout/AppFrame.tsx +3 -2
- package/src/layout/MainContentFrame.tsx +7 -2
- package/src/layout/ResizeHandle.tsx +68 -17
- package/src/layout/SidebarDock.tsx +75 -19
- package/src/layout/SidebarOverlay.tsx +1 -1
- package/src/layout/index.ts +1 -1
- package/src/layout/resize-handle-axis.test.ts +51 -0
- package/src/live-indicators.test.ts +43 -0
- package/src/markdown/CodeBlock.tsx +123 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +411 -0
- package/src/markdown/MarkdownImage.tsx +51 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +43 -0
- package/src/markdown/RichCodeBlock.tsx +127 -0
- package/src/markdown/SvgPreview.tsx +45 -0
- package/src/markdown/WebsiteIcon.tsx +94 -0
- package/src/markdown/builtin-renderers.tsx +43 -0
- package/src/markdown/definition.tsx +49 -0
- package/src/markdown/host.tsx +18 -0
- package/src/markdown/index.ts +11 -0
- package/src/markdown/inline-tokens.ts +187 -0
- package/src/markdown/markdown-link.ts +279 -0
- package/src/markdown/math-client.ts +116 -0
- package/src/markdown/math-render.ts +23 -0
- package/src/markdown/math-syntax.ts +80 -0
- package/src/markdown/math.worker.ts +16 -0
- package/src/markdown/nodes.ts +15 -0
- package/src/markdown/preview-policy.ts +43 -0
- package/src/markdown/rich-labels.ts +49 -0
- package/src/markdown/rich-syntax.ts +93 -0
- package/src/markdown/stable-blocks.test.ts +90 -0
- package/src/markdown/stable-blocks.ts +124 -0
- package/src/markdown/streaming-reveal.ts +297 -0
- package/src/markdown/streaming.test.ts +57 -0
- package/src/markdown/streaming.ts +211 -0
- package/src/markdown/use-render-snapshot.ts +24 -0
- package/src/markdown/use-rich-visibility.ts +24 -0
- package/src/overlays/CommandMenuRow.tsx +38 -9
- package/src/overlays/CommandMenuView.tsx +77 -117
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/ReleaseNoteMarkdown.tsx +29 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +213 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +139 -54
- package/src/overlays/command-menu-types.ts +2 -0
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +14 -1
- package/src/plugin-ui/index.ts +8 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +4 -4
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +106 -55
- package/src/project/ManageSessionsSplashView.tsx +439 -0
- package/src/project/NewProjectDialogView.tsx +3 -10
- package/src/project/ProjectContextMenuView.tsx +30 -139
- package/src/project/ProjectDetailPageView.test.tsx +140 -0
- package/src/project/ProjectDetailPageView.tsx +372 -165
- package/src/project/ProjectGroupView.tsx +1 -1
- package/src/project/ProjectRowView.tsx +29 -12
- package/src/project/ProjectSessionsView.tsx +25 -47
- package/src/project/QuickScrollOverlay.tsx +1 -1
- package/src/project/SessionContextMenuView.tsx +15 -7
- package/src/project/SessionRowMoreButton.tsx +50 -0
- package/src/project/SessionRowView.tsx +106 -63
- package/src/project/SessionTitleMarquee.tsx +54 -0
- package/src/project/SidebarProjectDisclosure.tsx +60 -0
- package/src/project/SidebarProjectsSectionView.tsx +6 -1
- package/src/project/index.ts +12 -0
- package/src/project/session-row-transition.ts +9 -0
- package/src/project/types.ts +4 -2
- package/src/project/useActiveSessionAutoScroll.ts +10 -4
- package/src/registry.ts +0 -2
- package/src/scheduler/AutomationDetailPaneView.tsx +68 -0
- package/src/scheduler/AutomationPageView.tsx +118 -121
- package/src/scheduler/ExecutionHistoryView.tsx +7 -5
- package/src/scheduler/TaskListView.tsx +52 -201
- package/src/scheduler/index.ts +7 -12
- package/src/settings/AchievementSettingsView.tsx +0 -1
- package/src/settings/AppshotSettingsView.tsx +0 -1
- package/src/settings/BuiltinMcpSectionView.tsx +1 -1
- package/src/settings/EnvironmentGitRowView.tsx +156 -0
- package/src/settings/EnvironmentSettingsView.tsx +25 -3
- package/src/settings/GeneralSettingsView.tsx +17 -20
- package/src/settings/ImChannelGuideDialogView.tsx +2 -2
- package/src/settings/ImFeishuDialogView.tsx +1 -1
- package/src/settings/ImLegacyImportBannerView.tsx +1 -1
- package/src/settings/ImLogDrawerView.tsx +2 -1
- package/src/settings/JsonConfigInputView.tsx +171 -0
- package/src/settings/ModelsFetchedModelsDrawerView.tsx +292 -0
- package/src/settings/ModelsProvidersSectionView.tsx +26 -23
- package/src/settings/MotionSelect.tsx +9 -7
- package/src/settings/NotificationSettingsView.tsx +79 -0
- package/src/settings/PermissionsSettingsView.tsx +3 -7
- package/src/settings/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +205 -182
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -2
- package/src/settings/RemoteMcpSectionView.tsx +1 -1
- package/src/settings/SettingChrome.tsx +2 -2
- package/src/settings/SettingsAiAssistButtonView.tsx +9 -119
- package/src/settings/SettingsFormFields.tsx +4 -7
- package/src/settings/SettingsSidebarView.tsx +64 -3
- package/src/settings/ShortcutRecorderView.test.tsx +108 -0
- package/src/settings/ShortcutRecorderView.tsx +15 -9
- package/src/settings/ShortcutsSettingsView.tsx +1 -1
- package/src/settings/SpaceEditorDialogView.tsx +120 -0
- package/src/settings/SpacesSettingsView.tsx +105 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/index.ts +41 -29
- package/src/shared/ActivityStatusDot.tsx +69 -0
- package/src/shared/AvatarStackView.tsx +13 -13
- package/src/shared/BotAvatar.tsx +11 -9
- package/src/shared/CodeBlockCopyButton.tsx +1 -1
- package/src/shared/ContextMenuView.tsx +4 -11
- package/src/shared/MarkdownTable.tsx +2 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +22 -17
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +81 -0
- package/src/shared/connected-tab-outline.test.ts +2 -2
- package/src/shared/connected-tab-outline.ts +2 -1
- package/src/shared/index.ts +6 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/provider-icon/icons.ts +4 -2
- package/src/shared/provider-icon/index.tsx +1 -1
- package/src/shared/provider-icon/magpie.svg +1 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +25 -15
- package/src/sidebar/DefaultSidebar.tsx +3 -1
- package/src/sidebar/MessageCenterDialogView.tsx +3 -2
- package/src/sidebar/MessageCenterEmptyState.tsx +1 -1
- package/src/sidebar/MessageCenterTabs.tsx +1 -1
- package/src/sidebar/MessageCenterToolbarButton.tsx +1 -1
- package/src/sidebar/MessageCenterTriggerView.tsx +2 -2
- package/src/sidebar/ProjectsPanelEmptyState.tsx +26 -7
- package/src/sidebar/SessionStatusIcon.tsx +16 -1
- package/src/sidebar/SettingsMenuThemeSection.tsx +1 -1
- package/src/sidebar/SettingsMenuTriggerView.test.tsx +42 -0
- package/src/sidebar/SettingsMenuTriggerView.tsx +28 -50
- package/src/sidebar/ShowMoreSessionsButton.tsx +1 -1
- package/src/sidebar/SidebarFilterSelectView.tsx +8 -16
- package/src/sidebar/SidebarNavBadgeView.tsx +1 -1
- package/src/sidebar/SidebarNavIcon.tsx +1 -1
- package/src/sidebar/SidebarNavItemButton.tsx +1 -1
- package/src/sidebar/SidebarNavMorePanel.tsx +19 -7
- package/src/sidebar/SidebarNavigation.tsx +24 -15
- package/src/sidebar/SidebarPanel.tsx +11 -2
- package/src/sidebar/SidebarSectionTriggerLabel.tsx +20 -0
- package/src/sidebar/SidebarTopBar.tsx +10 -7
- package/src/sidebar/WaitingPulseBadge.tsx +19 -0
- package/src/sidebar/index.ts +1 -16
- package/src/skills/index.ts +0 -19
- package/src/skills/skill-icon.tsx +4 -8
- package/src/styles.css +24 -6
- package/src/chat/DefaultSceneCarousel.tsx +0 -113
- package/src/chat/SceneCard.tsx +0 -138
- package/src/scheduler/HistoryDrawerView.tsx +0 -149
- package/src/scheduler/TaskFormDialogView.tsx +0 -60
- package/src/settings/SubscriptionActionsView.tsx +0 -63
- package/src/settings/SubscriptionCardsView.tsx +0 -212
- package/src/settings/TeamDetailView.tsx +0 -148
- package/src/settings/TeamDialogsView.tsx +0 -151
- package/src/settings/TeamListView.tsx +0 -57
- package/src/settings/TeamSettingsView.tsx +0 -51
- package/src/settings/TokenActivityChartView.tsx +0 -286
- package/src/settings/UsageStatsView.tsx +0 -101
- package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +0 -135
- package/src/settings/shouldCloseEmptyApiKeyEditor.ts +0 -40
- package/src/settings/token-activity.test.ts +0 -195
- package/src/settings/token-activity.ts +0 -320
- package/src/sidebar/AddProjectMenuItem.tsx +0 -21
- package/src/sidebar/AddProjectMenuPopoverView.tsx +0 -52
- package/src/sidebar/NotificationMessageListView.tsx +0 -136
- package/src/sidebar/SettingsMenuAccountSection.tsx +0 -32
- package/src/sidebar/SettingsMenuQuotaSection.tsx +0 -45
- package/src/skills/SceneCardView.tsx +0 -194
- package/src/skills/SkillCardView.tsx +0 -186
- package/src/skills/SkillDetailDialogView.tsx +0 -138
- package/src/skills/SkillTagGroupView.tsx +0 -56
- package/src/skills/SkillToggleSwitch.tsx +0 -31
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { chatUrlTransform } from "../markdown/markdown-link";
|
|
2
|
+
import { cn } from "@vetta-org/ui";
|
|
3
|
+
import { MarkdownHostProvider } from "../markdown/host";
|
|
4
|
+
import type { MarkdownHost } from "../markdown/host";
|
|
5
|
+
import { MarkdownImage } from "../markdown/MarkdownImage";
|
|
6
|
+
import { memo, useMemo, type JSX, type MouseEvent } from "react";
|
|
2
7
|
import ReactMarkdown from "react-markdown";
|
|
3
8
|
import type { Components } from "react-markdown";
|
|
4
9
|
import remarkGfm from "remark-gfm";
|
|
5
|
-
import { CodeBlockCopyButtonView } from "../shared/CodeBlockCopyButton";
|
|
6
10
|
import {
|
|
7
11
|
MarkdownTable,
|
|
8
12
|
MarkdownTableBody,
|
|
@@ -11,13 +15,23 @@ import {
|
|
|
11
15
|
MarkdownTableHeaderCell,
|
|
12
16
|
MarkdownTableRow,
|
|
13
17
|
} from "../shared/MarkdownTable";
|
|
14
|
-
import {
|
|
18
|
+
import { useMarkdownDefinition } from "../markdown/definition";
|
|
19
|
+
import { BuiltinCodeBlock, Formula } from "../markdown/builtin-renderers";
|
|
20
|
+
import { richRemarkPlugins } from "../markdown/rich-syntax";
|
|
21
|
+
import { SvgPreview } from "../markdown/SvgPreview";
|
|
22
|
+
import { WebsiteIcon } from "../markdown/WebsiteIcon";
|
|
23
|
+
import { defaultRichContentLabels } from "../markdown/rich-labels";
|
|
24
|
+
import type { MarkdownLabels } from "../markdown/rich-labels";
|
|
25
|
+
import type { HastElement } from "../markdown/nodes";
|
|
15
26
|
|
|
16
27
|
export interface MarkdownPreviewViewProps {
|
|
28
|
+
host?: MarkdownHost;
|
|
17
29
|
content: string;
|
|
18
30
|
theme: "light" | "dark";
|
|
19
31
|
/** Host opens http(s)/mailto/tel links (e.g. via shell.openExternal). */
|
|
20
32
|
onOpenExternal: (href: string) => void;
|
|
33
|
+
labels?: MarkdownLabels;
|
|
34
|
+
className?: string;
|
|
21
35
|
}
|
|
22
36
|
|
|
23
37
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
@@ -59,10 +73,7 @@ function Frontmatter({ entries }: { entries: FrontmatterEntry[] }): JSX.Element
|
|
|
59
73
|
<dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[12px] leading-[1.6]">
|
|
60
74
|
{entries.map((entry, i) => (
|
|
61
75
|
<div key={i} className="contents">
|
|
62
|
-
<dt
|
|
63
|
-
className="font-medium text-muted-foreground"
|
|
64
|
-
style={{ paddingLeft: `${entry.depth * 12}px` }}
|
|
65
|
-
>
|
|
76
|
+
<dt className="font-medium text-muted-foreground" style={{ paddingLeft: `${entry.depth * 12}px` }}>
|
|
66
77
|
{entry.key || "-"}
|
|
67
78
|
</dt>
|
|
68
79
|
<dd className="break-words text-foreground">
|
|
@@ -77,7 +88,8 @@ function Frontmatter({ entries }: { entries: FrontmatterEntry[] }): JSX.Element
|
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
const EXTERNAL_LINK_PROTOCOLS = new Set(["http:", "https:", "mailto:", "tel:"]);
|
|
80
|
-
const MARKDOWN_REMARK_PLUGINS = [remarkGfm];
|
|
91
|
+
const MARKDOWN_REMARK_PLUGINS = [remarkGfm, ...richRemarkPlugins];
|
|
92
|
+
const DEFAULT_LABELS: MarkdownLabels = { copy: "Copy code", copied: "Copied" };
|
|
81
93
|
|
|
82
94
|
function isExternalLink(href: string | undefined): href is string {
|
|
83
95
|
if (!href) return false;
|
|
@@ -88,48 +100,15 @@ function isExternalLink(href: string | undefined): href is string {
|
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
|
|
91
|
-
function MarkdownCodeBlock({
|
|
92
|
-
lang,
|
|
93
|
-
code,
|
|
94
|
-
theme,
|
|
95
|
-
}: {
|
|
96
|
-
lang: string;
|
|
97
|
-
code: string;
|
|
98
|
-
theme: "light" | "dark";
|
|
99
|
-
}): JSX.Element {
|
|
100
|
-
const [copied, setCopied] = useState(false);
|
|
101
|
-
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (!copied) return;
|
|
104
|
-
const id = window.setTimeout(() => setCopied(false), 1500);
|
|
105
|
-
return () => window.clearTimeout(id);
|
|
106
|
-
}, [copied]);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<CodeBlockCopyButtonView
|
|
110
|
-
copied={copied}
|
|
111
|
-
onCopy={() => {
|
|
112
|
-
void navigator.clipboard.writeText(code).then(() => setCopied(true));
|
|
113
|
-
}}
|
|
114
|
-
labels={{ copy: "Copy code", copied: "Copied" }}
|
|
115
|
-
>
|
|
116
|
-
<div className="my-2 overflow-hidden rounded-lg border border-border bg-muted">
|
|
117
|
-
{lang && (
|
|
118
|
-
<div className="border-b border-border px-3 py-1 text-[10px] font-medium text-muted-foreground/50">
|
|
119
|
-
{lang}
|
|
120
|
-
</div>
|
|
121
|
-
)}
|
|
122
|
-
<SyntaxHighlightedCode code={code} lang={lang} theme={theme} />
|
|
123
|
-
</div>
|
|
124
|
-
</CodeBlockCopyButtonView>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
103
|
export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
129
104
|
content,
|
|
130
105
|
theme,
|
|
131
106
|
onOpenExternal,
|
|
107
|
+
labels = DEFAULT_LABELS,
|
|
108
|
+
host,
|
|
109
|
+
className,
|
|
132
110
|
}: MarkdownPreviewViewProps): JSX.Element {
|
|
111
|
+
const definition = useMarkdownDefinition();
|
|
133
112
|
const parsed = parseFrontmatter(content);
|
|
134
113
|
const body = parsed?.body ?? content;
|
|
135
114
|
|
|
@@ -150,9 +129,7 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
150
129
|
h3: ({ children }) => (
|
|
151
130
|
<h3 className="mb-2 mt-3 text-[14px] font-semibold leading-tight text-foreground">{children}</h3>
|
|
152
131
|
),
|
|
153
|
-
h4: ({ children }) =>
|
|
154
|
-
<h4 className="mb-1.5 mt-2.5 text-[13px] font-semibold text-foreground">{children}</h4>
|
|
155
|
-
),
|
|
132
|
+
h4: ({ children }) => <h4 className="mb-1.5 mt-2.5 text-[13px] font-semibold text-foreground">{children}</h4>,
|
|
156
133
|
p: ({ children }) => <p className="my-1.5 text-[13px] leading-[1.6] text-foreground">{children}</p>,
|
|
157
134
|
ul: ({ children }) => (
|
|
158
135
|
<ul className="md-bullet-list my-1.5 text-[13px] leading-[1.6] text-foreground">{children}</ul>
|
|
@@ -163,13 +140,20 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
163
140
|
</ol>
|
|
164
141
|
),
|
|
165
142
|
li: ({ children }) => <li>{children}</li>,
|
|
143
|
+
img: ({ src, alt, title }) => <MarkdownImage src={src} alt={alt} title={title} labels={labels} />,
|
|
166
144
|
code: ({ className, children }) => {
|
|
167
145
|
const raw = String(children);
|
|
146
|
+
if (className?.includes("math-inline") || className?.includes("math-display")) {
|
|
147
|
+
return <Formula source={raw.replace(/\n$/, "")} display={className.includes("math-display")} labels={labels} />;
|
|
148
|
+
}
|
|
168
149
|
const isBlock = (className?.startsWith("language-") ?? false) || raw.includes("\n");
|
|
169
150
|
if (isBlock) {
|
|
170
151
|
const lang = className?.replace("language-", "") ?? "";
|
|
171
152
|
const code = raw.replace(/\n$/, "");
|
|
172
|
-
|
|
153
|
+
const CodeBlock = definition.codeBlock ?? BuiltinCodeBlock;
|
|
154
|
+
return (
|
|
155
|
+
<CodeBlock lang={lang} code={code} theme={theme} labels={labels} />
|
|
156
|
+
);
|
|
173
157
|
}
|
|
174
158
|
return <code className="rounded bg-muted px-1 py-0.5 text-[12px] text-foreground">{children}</code>;
|
|
175
159
|
},
|
|
@@ -179,15 +163,11 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
179
163
|
{children}
|
|
180
164
|
</blockquote>
|
|
181
165
|
),
|
|
182
|
-
table: ({ children }) =>
|
|
183
|
-
<MarkdownTable fontSizeClass="text-[12px]">{children}</MarkdownTable>
|
|
184
|
-
),
|
|
166
|
+
table: ({ children }) => <MarkdownTable fontSizeClass="text-[12px]">{children}</MarkdownTable>,
|
|
185
167
|
thead: ({ children }) => <MarkdownTableHead>{children}</MarkdownTableHead>,
|
|
186
168
|
tbody: ({ children }) => <MarkdownTableBody>{children}</MarkdownTableBody>,
|
|
187
169
|
tr: ({ children }) => <MarkdownTableRow>{children}</MarkdownTableRow>,
|
|
188
|
-
th: ({ children, style }) =>
|
|
189
|
-
<MarkdownTableHeaderCell style={style}>{children}</MarkdownTableHeaderCell>
|
|
190
|
-
),
|
|
170
|
+
th: ({ children, style }) => <MarkdownTableHeaderCell style={style}>{children}</MarkdownTableHeaderCell>,
|
|
191
171
|
td: ({ children, style }) => <MarkdownTableCell style={style}>{children}</MarkdownTableCell>,
|
|
192
172
|
hr: () => <hr className="my-3 border-border" />,
|
|
193
173
|
a: ({ href, children }) => (
|
|
@@ -198,20 +178,37 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
198
178
|
rel={isExternalLink(href) ? "noopener noreferrer" : undefined}
|
|
199
179
|
onClick={(event) => handleLinkClick(event, href)}
|
|
200
180
|
>
|
|
181
|
+
{href && /^https?:\/\//i.test(href) && (
|
|
182
|
+
<>
|
|
183
|
+
<WebsiteIcon href={href} />{" "}
|
|
184
|
+
</>
|
|
185
|
+
)}
|
|
201
186
|
{children}
|
|
202
187
|
</a>
|
|
203
188
|
),
|
|
204
189
|
strong: ({ children }) => <strong className="font-semibold text-foreground">{children}</strong>,
|
|
205
190
|
em: ({ children }) => <em className="italic">{children}</em>,
|
|
191
|
+
"vetta-svg": ({ node }: { node?: HastElement }) => {
|
|
192
|
+
const source = node?.properties?.source;
|
|
193
|
+
const rich = labels.rich ?? defaultRichContentLabels;
|
|
194
|
+
return typeof source === "string" ? <SvgPreview source={source} label={rich.svg} failed={rich.failed} /> : null;
|
|
195
|
+
},
|
|
196
|
+
...definition.components,
|
|
197
|
+
...definition.elements,
|
|
206
198
|
};
|
|
207
|
-
}, [theme, onOpenExternal]);
|
|
199
|
+
}, [theme, onOpenExternal, definition, labels]);
|
|
208
200
|
|
|
209
201
|
return (
|
|
210
|
-
<div className="markdown-body break-words p-4">
|
|
202
|
+
<MarkdownHostProvider host={host}><div className={cn("markdown-body break-words p-4", className)}>
|
|
211
203
|
{parsed && parsed.entries.length > 0 && <Frontmatter entries={parsed.entries} />}
|
|
212
|
-
<ReactMarkdown
|
|
204
|
+
<ReactMarkdown
|
|
205
|
+
urlTransform={chatUrlTransform}
|
|
206
|
+
remarkPlugins={[...MARKDOWN_REMARK_PLUGINS, ...(definition.remarkPlugins ?? [])]}
|
|
207
|
+
rehypePlugins={definition.rehypePlugins}
|
|
208
|
+
components={components}
|
|
209
|
+
>
|
|
213
210
|
{body}
|
|
214
211
|
</ReactMarkdown>
|
|
215
|
-
</div>
|
|
212
|
+
</div></MarkdownHostProvider>
|
|
216
213
|
);
|
|
217
214
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState, type JSX, type ReactNode } from "react";
|
|
2
|
-
import { Popover, PopoverContent, PopoverTrigger
|
|
2
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@vetta-org/ui/popover";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
3
4
|
|
|
4
5
|
export const DEFAULT_PLUGIN_TAB_ICON = "icon-[solar--widget-5-linear]";
|
|
5
6
|
|
|
@@ -75,7 +76,8 @@ export function PluginTabPickerView({
|
|
|
75
76
|
type="button"
|
|
76
77
|
title={labels.menu}
|
|
77
78
|
aria-label={labels.menu}
|
|
78
|
-
|
|
79
|
+
// 右边距让图标中线对齐页头按钮组最右一项的中线(页头右内边距 12 + 组内边距 2 + 半个按钮 20 = 34)。
|
|
80
|
+
className="mb-0.5 mr-5 flex h-7 min-w-7 shrink-0 items-center justify-center gap-0.5 rounded-md px-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
79
81
|
>
|
|
80
82
|
{hasOverflow && (
|
|
81
83
|
<span className="text-[10px] font-semibold tabular-nums leading-none">
|
|
@@ -85,7 +87,7 @@ export function PluginTabPickerView({
|
|
|
85
87
|
<span
|
|
86
88
|
className={
|
|
87
89
|
hasAvailable
|
|
88
|
-
? "icon-[
|
|
90
|
+
? "icon-[mdi--plus] h-4 w-4"
|
|
89
91
|
: "icon-[solar--alt-arrow-down-linear] h-4 w-4"
|
|
90
92
|
}
|
|
91
93
|
/>
|