@vetta-org/theme-ui 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +740 -20
- 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/CodePreview.tsx +15 -1
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +135 -62
- 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/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +806 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +128 -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 +29 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +6 -2
- 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 +33 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- 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/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- 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/FileLinkBadge.tsx +77 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +418 -0
- package/src/markdown/MarkdownImage.tsx +41 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +82 -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/image-actions.ts +29 -0
- package/src/markdown/index.ts +12 -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.test.ts +31 -0
- package/src/markdown/preview-policy.ts +76 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +55 -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 +77 -17
- package/src/overlays/CommandMenuView.tsx +163 -118
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +55 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +217 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +203 -53
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +26 -1
- package/src/plugin-ui/index.ts +10 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +15 -24
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +114 -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/AppshotSettingsView.tsx +0 -1
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -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 +18 -24
- 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/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +273 -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/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +147 -185
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- 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 -5
- package/src/settings/SpaceEditorDialogView.tsx +158 -0
- package/src/settings/SpacesSettingsView.tsx +150 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +59 -68
- 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/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +10 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +23 -18
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +100 -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 +7 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/platform.ts +9 -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 +33 -24
- 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 +29 -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/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- 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 +26 -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/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -44
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -66
- 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/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
- 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 { Fragment, memo, useEffect, useMemo, useState, type JSX, type MouseEvent } from "react";
|
|
2
7
|
import ReactMarkdown from "react-markdown";
|
|
3
|
-
import type { Components } from "react-markdown";
|
|
8
|
+
import type { Components, Options as ReactMarkdownOptions } 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,24 @@ 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 { splitMarkdownForProgressiveRender } from "../markdown/progressive-chunks";
|
|
21
|
+
import { richRemarkPlugins } from "../markdown/rich-syntax";
|
|
22
|
+
import { SvgPreview } from "../markdown/SvgPreview";
|
|
23
|
+
import { WebsiteIcon } from "../markdown/WebsiteIcon";
|
|
24
|
+
import { defaultRichContentLabels } from "../markdown/rich-labels";
|
|
25
|
+
import type { MarkdownLabels } from "../markdown/rich-labels";
|
|
26
|
+
import type { HastElement } from "../markdown/nodes";
|
|
15
27
|
|
|
16
28
|
export interface MarkdownPreviewViewProps {
|
|
29
|
+
host?: MarkdownHost;
|
|
17
30
|
content: string;
|
|
18
31
|
theme: "light" | "dark";
|
|
19
32
|
/** Host opens http(s)/mailto/tel links (e.g. via shell.openExternal). */
|
|
20
33
|
onOpenExternal: (href: string) => void;
|
|
34
|
+
labels?: MarkdownLabels;
|
|
35
|
+
className?: string;
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
@@ -59,10 +74,7 @@ function Frontmatter({ entries }: { entries: FrontmatterEntry[] }): JSX.Element
|
|
|
59
74
|
<dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-[12px] leading-[1.6]">
|
|
60
75
|
{entries.map((entry, i) => (
|
|
61
76
|
<div key={i} className="contents">
|
|
62
|
-
<dt
|
|
63
|
-
className="font-medium text-muted-foreground"
|
|
64
|
-
style={{ paddingLeft: `${entry.depth * 12}px` }}
|
|
65
|
-
>
|
|
77
|
+
<dt className="font-medium text-muted-foreground" style={{ paddingLeft: `${entry.depth * 12}px` }}>
|
|
66
78
|
{entry.key || "-"}
|
|
67
79
|
</dt>
|
|
68
80
|
<dd className="break-words text-foreground">
|
|
@@ -77,7 +89,8 @@ function Frontmatter({ entries }: { entries: FrontmatterEntry[] }): JSX.Element
|
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
const EXTERNAL_LINK_PROTOCOLS = new Set(["http:", "https:", "mailto:", "tel:"]);
|
|
80
|
-
const MARKDOWN_REMARK_PLUGINS = [remarkGfm];
|
|
92
|
+
const MARKDOWN_REMARK_PLUGINS = [remarkGfm, ...richRemarkPlugins];
|
|
93
|
+
const DEFAULT_LABELS: MarkdownLabels = { copy: "Copy code", copied: "Copied" };
|
|
81
94
|
|
|
82
95
|
function isExternalLink(href: string | undefined): href is string {
|
|
83
96
|
if (!href) return false;
|
|
@@ -88,48 +101,15 @@ function isExternalLink(href: string | undefined): href is string {
|
|
|
88
101
|
}
|
|
89
102
|
}
|
|
90
103
|
|
|
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
104
|
export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
129
105
|
content,
|
|
130
106
|
theme,
|
|
131
107
|
onOpenExternal,
|
|
108
|
+
labels = DEFAULT_LABELS,
|
|
109
|
+
host,
|
|
110
|
+
className,
|
|
132
111
|
}: MarkdownPreviewViewProps): JSX.Element {
|
|
112
|
+
const definition = useMarkdownDefinition();
|
|
133
113
|
const parsed = parseFrontmatter(content);
|
|
134
114
|
const body = parsed?.body ?? content;
|
|
135
115
|
|
|
@@ -150,9 +130,7 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
150
130
|
h3: ({ children }) => (
|
|
151
131
|
<h3 className="mb-2 mt-3 text-[14px] font-semibold leading-tight text-foreground">{children}</h3>
|
|
152
132
|
),
|
|
153
|
-
h4: ({ children }) =>
|
|
154
|
-
<h4 className="mb-1.5 mt-2.5 text-[13px] font-semibold text-foreground">{children}</h4>
|
|
155
|
-
),
|
|
133
|
+
h4: ({ children }) => <h4 className="mb-1.5 mt-2.5 text-[13px] font-semibold text-foreground">{children}</h4>,
|
|
156
134
|
p: ({ children }) => <p className="my-1.5 text-[13px] leading-[1.6] text-foreground">{children}</p>,
|
|
157
135
|
ul: ({ children }) => (
|
|
158
136
|
<ul className="md-bullet-list my-1.5 text-[13px] leading-[1.6] text-foreground">{children}</ul>
|
|
@@ -163,13 +141,20 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
163
141
|
</ol>
|
|
164
142
|
),
|
|
165
143
|
li: ({ children }) => <li>{children}</li>,
|
|
144
|
+
img: ({ src, alt, title }) => <MarkdownImage src={src} alt={alt} title={title} labels={labels} />,
|
|
166
145
|
code: ({ className, children }) => {
|
|
167
146
|
const raw = String(children);
|
|
147
|
+
if (className?.includes("math-inline") || className?.includes("math-display")) {
|
|
148
|
+
return <Formula source={raw.replace(/\n$/, "")} display={className.includes("math-display")} labels={labels} />;
|
|
149
|
+
}
|
|
168
150
|
const isBlock = (className?.startsWith("language-") ?? false) || raw.includes("\n");
|
|
169
151
|
if (isBlock) {
|
|
170
152
|
const lang = className?.replace("language-", "") ?? "";
|
|
171
153
|
const code = raw.replace(/\n$/, "");
|
|
172
|
-
|
|
154
|
+
const CodeBlock = definition.codeBlock ?? BuiltinCodeBlock;
|
|
155
|
+
return (
|
|
156
|
+
<CodeBlock lang={lang} code={code} theme={theme} labels={labels} />
|
|
157
|
+
);
|
|
173
158
|
}
|
|
174
159
|
return <code className="rounded bg-muted px-1 py-0.5 text-[12px] text-foreground">{children}</code>;
|
|
175
160
|
},
|
|
@@ -179,15 +164,11 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
179
164
|
{children}
|
|
180
165
|
</blockquote>
|
|
181
166
|
),
|
|
182
|
-
table: ({ children }) =>
|
|
183
|
-
<MarkdownTable fontSizeClass="text-[12px]">{children}</MarkdownTable>
|
|
184
|
-
),
|
|
167
|
+
table: ({ children }) => <MarkdownTable fontSizeClass="text-[12px]">{children}</MarkdownTable>,
|
|
185
168
|
thead: ({ children }) => <MarkdownTableHead>{children}</MarkdownTableHead>,
|
|
186
169
|
tbody: ({ children }) => <MarkdownTableBody>{children}</MarkdownTableBody>,
|
|
187
170
|
tr: ({ children }) => <MarkdownTableRow>{children}</MarkdownTableRow>,
|
|
188
|
-
th: ({ children, style }) =>
|
|
189
|
-
<MarkdownTableHeaderCell style={style}>{children}</MarkdownTableHeaderCell>
|
|
190
|
-
),
|
|
171
|
+
th: ({ children, style }) => <MarkdownTableHeaderCell style={style}>{children}</MarkdownTableHeaderCell>,
|
|
191
172
|
td: ({ children, style }) => <MarkdownTableCell style={style}>{children}</MarkdownTableCell>,
|
|
192
173
|
hr: () => <hr className="my-3 border-border" />,
|
|
193
174
|
a: ({ href, children }) => (
|
|
@@ -198,20 +179,112 @@ export const MarkdownPreviewView = memo(function MarkdownPreviewView({
|
|
|
198
179
|
rel={isExternalLink(href) ? "noopener noreferrer" : undefined}
|
|
199
180
|
onClick={(event) => handleLinkClick(event, href)}
|
|
200
181
|
>
|
|
182
|
+
{href && /^https?:\/\//i.test(href) && (
|
|
183
|
+
<>
|
|
184
|
+
<WebsiteIcon href={href} />{" "}
|
|
185
|
+
</>
|
|
186
|
+
)}
|
|
201
187
|
{children}
|
|
202
188
|
</a>
|
|
203
189
|
),
|
|
204
190
|
strong: ({ children }) => <strong className="font-semibold text-foreground">{children}</strong>,
|
|
205
191
|
em: ({ children }) => <em className="italic">{children}</em>,
|
|
192
|
+
"vetta-svg": ({ node }: { node?: HastElement }) => {
|
|
193
|
+
const source = node?.properties?.source;
|
|
194
|
+
const rich = labels.rich ?? defaultRichContentLabels;
|
|
195
|
+
return typeof source === "string" ? <SvgPreview source={source} label={rich.svg} failed={rich.failed} /> : null;
|
|
196
|
+
},
|
|
197
|
+
...definition.components,
|
|
198
|
+
...definition.elements,
|
|
206
199
|
};
|
|
207
|
-
}, [theme, onOpenExternal]);
|
|
200
|
+
}, [theme, onOpenExternal, definition, labels]);
|
|
201
|
+
|
|
202
|
+
const remarkPlugins = useMemo(
|
|
203
|
+
() => [...MARKDOWN_REMARK_PLUGINS, ...(definition.remarkPlugins ?? [])],
|
|
204
|
+
[definition.remarkPlugins],
|
|
205
|
+
);
|
|
206
|
+
const chunks = useMemo(() => splitMarkdownForProgressiveRender(body), [body]);
|
|
207
|
+
const mountedChunks = useProgressiveChunkCount(chunks.length);
|
|
208
|
+
const progressive = chunks.length > 1;
|
|
208
209
|
|
|
209
210
|
return (
|
|
210
|
-
<div className="markdown-body break-words p-4">
|
|
211
|
+
<MarkdownHostProvider host={host}><div className={cn("markdown-body break-words p-4", className)}>
|
|
211
212
|
{parsed && parsed.entries.length > 0 && <Frontmatter entries={parsed.entries} />}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
{chunks.slice(0, mountedChunks).map((chunk, index) => {
|
|
214
|
+
const rendered = (
|
|
215
|
+
<MarkdownChunk
|
|
216
|
+
markdown={chunk}
|
|
217
|
+
remarkPlugins={remarkPlugins}
|
|
218
|
+
rehypePlugins={definition.rehypePlugins}
|
|
219
|
+
components={components}
|
|
220
|
+
/>
|
|
221
|
+
);
|
|
222
|
+
return progressive ? (
|
|
223
|
+
// Off-screen sections skip layout and paint; "auto" remembers each measured height.
|
|
224
|
+
<div key={index} style={PROGRESSIVE_CHUNK_STYLE}>
|
|
225
|
+
{rendered}
|
|
226
|
+
</div>
|
|
227
|
+
) : (
|
|
228
|
+
<Fragment key={index}>{rendered}</Fragment>
|
|
229
|
+
);
|
|
230
|
+
})}
|
|
231
|
+
</div></MarkdownHostProvider>
|
|
232
|
+
);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const PROGRESSIVE_CHUNK_STYLE = { contentVisibility: "auto", containIntrinsicSize: "auto 800px" } as const;
|
|
236
|
+
/** Sections rendered in the first frame; enough to fill the pane. */
|
|
237
|
+
const INITIAL_CHUNKS = 2;
|
|
238
|
+
|
|
239
|
+
const MarkdownChunk = memo(function MarkdownChunk({
|
|
240
|
+
markdown,
|
|
241
|
+
remarkPlugins,
|
|
242
|
+
rehypePlugins,
|
|
243
|
+
components,
|
|
244
|
+
}: {
|
|
245
|
+
markdown: string;
|
|
246
|
+
remarkPlugins: ReactMarkdownOptions["remarkPlugins"];
|
|
247
|
+
rehypePlugins: ReactMarkdownOptions["rehypePlugins"];
|
|
248
|
+
components: Components;
|
|
249
|
+
}): JSX.Element {
|
|
250
|
+
return (
|
|
251
|
+
<ReactMarkdown
|
|
252
|
+
urlTransform={chatUrlTransform}
|
|
253
|
+
remarkPlugins={remarkPlugins}
|
|
254
|
+
rehypePlugins={rehypePlugins}
|
|
255
|
+
components={components}
|
|
256
|
+
>
|
|
257
|
+
{markdown}
|
|
258
|
+
</ReactMarkdown>
|
|
216
259
|
);
|
|
217
260
|
});
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Parsing and rendering a large document in one task blocks the window for seconds. The
|
|
264
|
+
* first sections render at once and the rest are added one per idle period, so the preview
|
|
265
|
+
* appears immediately and input stays responsive while it fills in.
|
|
266
|
+
*/
|
|
267
|
+
function useProgressiveChunkCount(total: number): number {
|
|
268
|
+
const [count, setCount] = useState(() => Math.min(total, INITIAL_CHUNKS));
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
if (count >= total) return;
|
|
271
|
+
const handle = scheduleIdle(() => setCount((current) => Math.min(total, current + 1)));
|
|
272
|
+
return () => cancelIdle(handle);
|
|
273
|
+
}, [count, total]);
|
|
274
|
+
return Math.min(count, total);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function scheduleIdle(callback: () => void): number {
|
|
278
|
+
if (typeof window !== "undefined" && typeof window.requestIdleCallback === "function") {
|
|
279
|
+
return window.requestIdleCallback(callback, { timeout: 200 });
|
|
280
|
+
}
|
|
281
|
+
return setTimeout(callback, 16) as unknown as number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function cancelIdle(handle: number): void {
|
|
285
|
+
if (typeof window !== "undefined" && typeof window.cancelIdleCallback === "function") {
|
|
286
|
+
window.cancelIdleCallback(handle);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
clearTimeout(handle);
|
|
290
|
+
}
|
|
@@ -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
|
/>
|