Skip to content

feat(plugin-playground)!: change defaultRenderMode to 'pure' and support combined usage with plugin-preview#3059

Merged
SoonIter merged 11 commits intomainfrom
syt-vibe-kanban/2d92-plugin-playgroun
Jan 26, 2026
Merged

feat(plugin-playground)!: change defaultRenderMode to 'pure' and support combined usage with plugin-preview#3059
SoonIter merged 11 commits intomainfrom
syt-vibe-kanban/2d92-plugin-playgroun

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Jan 26, 2026

Summary

change defaultRenderMode to 'pure' and support combined usage with plugin-preview

// rspress.config.ts
plugins: [
  pluginPreview(),
  pluginPlayground()
]

Related Issue

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Changes

1. Changed defaultRenderMode default value to 'pure' in plugin-playground

  • Modified packages/plugin-playground/src/cli/index.ts - changed the default value from 'playground' to 'pure'
  • Updated the JSDoc comment @default annotation accordingly

2. Enabled combined usage of plugin-playground and plugin-preview

  • Removed removePlugin('@rspress/plugin-preview') from plugin-playground
  • Both plugins now default to pure mode, allowing users to explicitly specify playground or preview via code block meta
  • This enables using both plugins together in the same project

3. Added e2e test for combined plugin usage

  • Created new e2e fixture e2e/fixtures/plugin-playground-preview/
  • Tests verify that:
    • Code blocks without meta render as pure code blocks (default)
    • Code blocks with playground meta render as Playground components
    • Code blocks with preview meta render as Preview components

4. Rewrote plugin-playground documentation (EN & ZH)

  • Reorganized documentation structure following plugin-preview's style
  • Added interactive Playground demos directly in the documentation
  • Added examples for external file references (_playgroundDemo.jsx)
  • Added layout direction section with horizontal/vertical examples
  • Added warning about not modifying defaultRenderMode to avoid affecting combined usage

5. Registered plugin-playground in website

  • Added @rspress/plugin-playground to website dependencies
  • Registered pluginPlayground() in rspress.config.ts
  • Created external demo files for documentation examples

This PR was written using Vibe Kanban


Copilot AI review requested due to automatic review settings January 26, 2026 09:20
@SoonIter SoonIter changed the title plugin-playground 中 defaultRenderMode 默认值调为 pure (vibe-kanban) feat(plugin-playground): change defaultRenderMode to 'pure' and support combined usage with plugin-preview Jan 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the default render mode for @rspress/plugin-playground to pure, aligns documentation for both plugin-playground and plugin-preview around this behavior, and adds an E2E fixture to validate combined usage of the two plugins.

Changes:

  • Set plugin-playground’s defaultRenderMode default to 'pure' and remove its automatic removal of @rspress/plugin-preview, enabling them to co-exist.
  • Update Chinese and English documentation for plugin-playground and plugin-preview to document the new defaultRenderMode = 'pure' default and warn about changing it when using both plugins together.
  • Add a new E2E fixture and Playwright test (plugin-playground-preview) that runs plugin-preview and plugin-playground together, verifying that plain, playground, and preview code blocks all render correctly under the new defaults.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
website/rspress.config.ts Registers pluginPlayground() alongside pluginPreview() for the docs site, exercising the new “both plugins, default pure mode” behavior in real usage.
website/package.json Adds @rspress/plugin-playground as a workspace dependency for the website docs so the new plugin usage in rspress.config.ts is valid.
website/docs/zh/plugin/official-plugins/preview.mdx Documents that defaultRenderMode for plugin-preview is 'pure' and adds a warning that changing it can affect combined use with @rspress/plugin-playground.
website/docs/zh/plugin/official-plugins/playground.mdx Reworks usage docs (step-wise sections, internal/external demos, direction layout), introduces defaultRenderMode (default 'pure') and warns against changing it when used with plugin-preview.
website/docs/zh/plugin/official-plugins/_playgroundDemo.jsx Adds a simple external JSX demo component for the Chinese playground docs’ “external file” example.
website/docs/en/plugin/official-plugins/preview.mdx Mirrors the Chinese preview docs updates in English, including the 'pure' default and warning about combined usage with @rspress/plugin-playground.
website/docs/en/plugin/official-plugins/playground.mdx Mirrors the Chinese playground docs updates in English, including clearer usage examples, external file demos, and defaultRenderMode = 'pure' documentation.
website/docs/en/plugin/official-plugins/_playgroundDemo.jsx Adds the English version of the external JSX demo component for the playground docs.
pnpm-lock.yaml Adds a new importer block for the e2e/fixtures/plugin-playground-preview project, wiring its dependencies (@rspress/core, @rspress/plugin-playground, @rspress/plugin-preview, React 19, etc.) into the lockfile.
packages/plugin-playground/src/cli/index.ts Updates PlaygroundOptions’s defaultRenderMode JSDoc to @default 'pure', changes the destructuring default from 'playground' to 'pure', and simplifies the config hook by removing the removePlugin('@rspress/plugin-preview') call so both plugins can run together.
e2e/fixtures/plugin-playground/rspress.config.ts Explicitly sets defaultRenderMode: 'playground' for the existing playground E2E fixture, preserving its previous behavior and expectations after the global default changes to 'pure'.
e2e/fixtures/plugin-playground-preview/tsconfig.json Minimal TS config enabling esModuleInterop and jsx: "react-jsx" for the new combined fixture project.
e2e/fixtures/plugin-playground-preview/rspress.config.ts Defines a new fixture site that enables both pluginPreview() and pluginPlayground() together on the same docs root.
e2e/fixtures/plugin-playground-preview/package.json Declares the combined fixture package, including workspace dependencies on @rspress/core, @rspress/plugin-playground, @rspress/plugin-preview, and React 19.
e2e/fixtures/plugin-playground-preview/index.test.ts New Playwright E2E test that starts the combined fixture, verifies a pure code block stays a normal code block, and ensures exactly one .rspress-playground and one .rspress-preview render with the expected text.
e2e/fixtures/plugin-playground-preview/doc/index.mdx MDX content used by the combined fixture: includes one plain JSX code block, one playground block, and one preview block to exercise and assert the new default 'pure' semantics across both plugins.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

**1. Changed `defaultRenderMode` default value to `'pure'` in plugin-playground**
- Modified `packages/plugin-playground/src/cli/index.ts:52` - changed the default value from `'playground'` to `'pure'`
- Updated the JSDoc comment `@default` from `'playground'` to `'pure'`
- Updated the existing e2e test `e2e/fixtures/plugin-playground/rspress.config.ts` to explicitly set `defaultRenderMode: 'playground'` to maintain test compatibility

**2. Created a new e2e case for plugin-playground and plugin-preview combined usage**
- Created new fixture directory: `e2e/fixtures/plugin-playground-preview/`
- Created files:
  - `package.json` - dependencies for both plugins
  - `tsconfig.json` - TypeScript config
  - `rspress.config.ts` - configures both `pluginPreview()` and `pluginPlayground()`
  - `doc/index.mdx` - test document with code blocks
  - `doc/component.jsx` - external component file
  - `index.test.ts` - test that verifies plugin-playground takes precedence when both plugins are configured (plugin-playground removes plugin-preview via `removePlugin`)
**1. `packages/plugin-playground/src/cli/index.ts`**
- 将 `defaultRenderMode` 默认值从 `'playground'` 改为 `'pure'`
- 更新 JSDoc 注释中的 `@default`
- 移除 `removePlugin('@rspress/plugin-preview')` 调用,允许两个插件同时使用

**2. `e2e/fixtures/plugin-playground/rspress.config.ts`**
- 添加 `defaultRenderMode: 'playground'` 保持原有测试行为

**3. 新建 `e2e/fixtures/plugin-playground-preview/`**
- `package.json` - 同时依赖两个插件
- `tsconfig.json`
- `rspress.config.ts` - 配置两个插件(都使用默认 `pure` 模式)
- `doc/index.mdx` - 测试三种场景:
  - 无 meta:渲染为普通代码块
  - `playground` meta:使用 plugin-playground
  - `preview` meta:使用 plugin-preview
- `index.test.ts` - 验证两个插件可以同时工作
**plugin-preview 文档** (英文/中文):
- 添加了 `:::warning` 提示不建议修改默认值,否则影响与 plugin-playground 的连用

**plugin-playground 文档** (英文/中文):
- 将 `defaultRenderMode` 默认值从 `'playground'` 更新为 `'pure'`
- 统一了文档格式(添加了 Type 和 Default 字段)
- 添加了 `:::warning` 提示不建议修改默认值,否则影响与 plugin-preview 的连用
**1. 重写了 plugin-playground 文档(中英文)**

参考 plugin-preview 的文档风格,重新组织了文档结构:
- 添加了完整的交互示例(计数器 demo)
- 使用 ` ```jsx playground ` 语法展示可编辑的 Playground
- 添加了外部文件引用的示例 (`_playgroundDemo.jsx`)
- 添加了布局方向(direction)章节,展示 horizontal/vertical 模式
- 重新组织了配置选项,统一了格式(Type/Default)
- 保留了 `defaultRenderMode` 的 warning 提示

**2. 在 website 中注册了 plugin-playground**

- `website/package.json`: 添加了 `@rspress/plugin-playground` 依赖
- `website/rspress.config.ts`:
  - 导入 `pluginPlayground`
  - 在 plugins 数组中注册 `pluginPlayground()`
- 创建了外部 demo 文件:
  - `website/docs/zh/plugin/official-plugins/_playgroundDemo.jsx`
  - `website/docs/en/plugin/official-plugins/_playgroundDemo.jsx`

现在 plugin-playground 文档页面会包含可交互的 Playground 示例,用户可以直接在文档中编辑代码并看到实时效果。
1. 该插件可与 plugin-preview 一起使用
2. plugin-playground 的代码编译发生在浏览器中
3. 因此用法限制比 plugin-preview 更多(例如不支持从本地文件导入模块)
4. 建议将 plugin-playground 作为 plugin-preview 的补充,用于需要实时编辑代码的场景
@SoonIter SoonIter force-pushed the syt-vibe-kanban/2d92-plugin-playgroun branch from 511d68e to 295ea2f Compare January 26, 2026 09:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 26, 2026

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 3 projects with changes.

📊 Quick Summary
Project Total Size Change
node 10.9 MB +62.9 KB (0.6%)
node_md 1.4 MB +8.1 KB (0.6%)
web 15.5 MB +54.7 KB (0.3%)
📋 Detailed Reports (Click to expand)

📁 node

Path: website/doc_build/diff-rsdoctor/node/rsdoctor-data.json

📌 Baseline Commit: 6847733204 | PR: #3057

Metric Current Baseline Change
📊 Total Size 10.9 MB 10.8 MB +62.9 KB (0.6%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 10.9 MB 10.8 MB +62.9 KB (0.6%)
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: node Bundle Diff

📁 node_md

Path: website/doc_build/diff-rsdoctor/node_md/rsdoctor-data.json

📌 Baseline Commit: 6847733204 | PR: #3057

Metric Current Baseline Change
📊 Total Size 1.4 MB 1.4 MB +8.1 KB (0.6%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 1.4 MB 1.4 MB +8.1 KB (0.6%)

📦 Download Diff Report: node_md Bundle Diff

📁 web

Path: website/doc_build/diff-rsdoctor/web/rsdoctor-data.json

📌 Baseline Commit: 6847733204 | PR: #3057

Metric Current Baseline Change
📊 Total Size 15.5 MB 15.5 MB +54.7 KB (0.3%)
📄 JavaScript 15.3 MB 15.2 MB +52.0 KB (0.3%)
🎨 CSS 118.6 KB 117.6 KB +1.0 KB (0.9%)
🌐 HTML 0 B 0 B 0
📁 Other Assets 153.8 KB 152.0 KB +1.7 KB (+1.1%)

📦 Download Diff Report: web Bundle Diff

Generated by Rsdoctor GitHub Action

@SoonIter SoonIter changed the title feat(plugin-playground): change defaultRenderMode to 'pure' and support combined usage with plugin-preview feat(plugin-playground)!: change defaultRenderMode to 'pure' and support combined usage with plugin-preview Jan 26, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 26, 2026

Deploying rspress-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: ff4726a
Status: ✅  Deploy successful!
Preview URL: https://cceba3d3.rspress-v2.pages.dev
Branch Preview URL: https://syt-vibe-kanban-2d92-plugin.rspress-v2.pages.dev

View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread e2e/fixtures/plugin-playground-preview/index.test.ts Outdated
@SoonIter SoonIter requested a review from Timeless0911 January 26, 2026 10:53
@SoonIter SoonIter merged commit 84f4f81 into main Jan 26, 2026
5 checks passed
@SoonIter SoonIter deleted the syt-vibe-kanban/2d92-plugin-playgroun branch January 26, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants