feat(core): move Llms runtime components from plugin-llms to core/theme#3026
feat(core): move Llms runtime components from plugin-llms to core/theme#3026
Conversation
## 完成的工作
已成功将 `plugin-llms` 中的 `LlmsViewOptions` 等组件内置到 `@rspress/core` 中。
### 1. 在 `core/src/theme/components/Llms/` 目录下创建了以下文件:
- `useMdUrl.ts` - 获取当前页面 markdown 文件 URL 的 hook
- `IconCopy.tsx` - 复制图标组件
- `LlmsContainer.tsx` + `LlmsContainer.module.scss` - 容器组件
- `LlmsCopyButton.tsx` + `LlmsCopyButton.module.scss` - 复制 Markdown 内容的按钮组件
- `LlmsViewOptions.tsx` + `LlmsViewOptions.module.scss` - 下拉菜单选项组件(支持打开 ChatGPT、Claude 等)
- `index.tsx` - 导出文件
### 2. 在 `core/src/theme/index.ts` 中添加了导出:
```ts
export {
LlmsContainer,
type LlmsContainerProps,
LlmsCopyButton,
type LlmsCopyButtonProps,
LlmsViewOptions,
type LlmsViewOptionsProps,
useMdUrl,
} from './components/Llms/index';
```
### 3. 更新了 `plugin-llms`:
- `src/runtime/index.tsx` 现在从 `@rspress/core/theme` 重新导出这些组件
- 删除了原来的组件文件(LlmsContainer、LlmsCopyButton、LlmsViewOptions、useMdUrl、IconCopy 及其样式文件)
- 更新了 `rslib.config.ts` 移除了 Sass 插件
- 更新了 `package.json` 移除了 `@rsbuild/plugin-sass` 依赖
用户现在可以直接从 `@rspress/core/theme` 导入这些组件:
```ts
import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl } from '@rspress/core/theme';
```
或者继续使用 `@rspress/plugin-llms/runtime`(向后兼容):
```ts
import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl } from '@rspress/plugin-llms/runtime';
```
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 2 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 nodePath:
📦 Download Diff Report: node Bundle Diff 📁 webPath:
📦 Download Diff Report: web Bundle Diff Generated by Rsdoctor GitHub Action |
There was a problem hiding this comment.
Pull request overview
This pull request moves LLMS-related components (LlmsViewOptions, LlmsCopyButton, LlmsContainer, and useMdUrl) from the @rspress/plugin-llms package to the @rspress/core theme package to make them built-in components. This refactoring eliminates the need for SASS and CSS modules in the plugin package.
Changes:
- Moved LLMS components from plugin-llms to core/theme/components/Llms
- Converted from SCSS modules to standard SCSS with BEM-style class names
- Removed @rsbuild/plugin-sass dependency from plugin-llms
- Re-exported components from plugin-llms for backward compatibility
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Removed @rsbuild/plugin-sass dependency from plugin-llms |
| packages/plugin-llms/package.json | Removed @rsbuild/plugin-sass from devDependencies |
| packages/plugin-llms/rslib.config.ts | Removed sass plugin, CSS module config, and BannerPlugin; added @rspress/core/theme to externals |
| packages/plugin-llms/src/runtime/index.tsx | Changed to re-export all components from @rspress/core/theme |
| packages/plugin-llms/src/runtime/useMdUrl.ts | Deleted - moved to core |
| packages/plugin-llms/src/runtime/env.d.ts | Deleted - no longer needed without SCSS modules |
| packages/plugin-llms/src/runtime/LlmsViewOptions.module.scss | Deleted - moved to core as standard SCSS |
| packages/plugin-llms/src/runtime/LlmsCopyButton.module.scss | Deleted - moved to core as standard SCSS |
| packages/plugin-llms/src/runtime/IconCopy.tsx | Deleted - using existing IconCopy from core |
| packages/core/src/theme/index.ts | Added exports for all LLMS components |
| packages/core/src/theme/components/Llms/index.tsx | New export file for LLMS components |
| packages/core/src/theme/components/Llms/index.scss | New shared styles for LLMS button base class |
| packages/core/src/theme/components/Llms/LlmsViewOptions.tsx | Moved from plugin, converted to use BEM classes and core icons |
| packages/core/src/theme/components/Llms/LlmsViewOptions.scss | New styles file with BEM naming |
| packages/core/src/theme/components/Llms/LlmsCopyButton.tsx | Moved from plugin, converted to use BEM classes and core icons |
| packages/core/src/theme/components/Llms/LlmsCopyButton.scss | New styles file with BEM naming |
| packages/core/src/theme/components/Llms/LlmsContainer.tsx | Moved from plugin, simplified to use BEM class |
| packages/core/src/theme/components/Llms/LlmsContainer.scss | Updated class name to BEM format |
| packages/core/src/theme/components/Llms/useMdUrl.ts | Moved from plugin, now uses routePathToMdPath from core/runtime |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (3)
packages/core/src/theme/components/Llms/LlmsViewOptions.tsx:168
- The SVG icon for ChatGPT contains a duplicate path element. Both line 167 and line 168 have identical path data. This is unnecessary duplication and should be removed. Only one path element is needed.
packages/core/src/theme/components/Llms/LlmsViewOptions.tsx:200 - The button element is missing the
type="button"attribute. Without this attribute, the button defaults totype="submit", which could cause unintended form submissions if this component is used within a form context. Addtype="button"to make the behavior explicit.
packages/core/src/theme/components/Llms/LlmsViewOptions.tsx:245 - Using a
divelement with anonClickhandler is not accessible for keyboard navigation. This element should be abuttonwithtype="button"to ensure it's keyboard accessible and properly announced to screen readers. Alternatively, addrole="button",tabIndex={0}, and handle keyboard events (Enter/Space keys).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…3027) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Summary
Related Issue
Checklist
AI Summary
What was changed
This PR moves the LLMS-related runtime components from
@rspress/plugin-llmsto@rspress/core/theme, making them built-in components available to all Rspress users.Components moved to
core/src/theme/components/Llms/:LlmsContainer- A container component for LLMS UI elementsLlmsCopyButton- A button component that copies markdown content to clipboardLlmsViewOptions- A dropdown menu component with options to open content in ChatGPT, Claude, or copy markdown linksuseMdUrl- A hook that returns the current page's markdown file URLChanges to
@rspress/plugin-llms:@rspress/core/themefor backward compatibility@rsbuild/plugin-sassdependency (no longer needed)rslib.config.tsbuild configurationWhy
Moving these components to core provides several benefits:
@rspress/plugin-llms/runtimewill continue to workUsage
Users can now import these components directly from core:
Or continue using the plugin import (backward compatible):
This PR was written using Vibe Kanban