@rspress/plugin-playground 2.0.0-rc.7 → 2.0.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/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -87,7 +87,7 @@ const pkgRootPath = node_path.join(cli_dirname, '../../');
|
|
|
87
87
|
const staticPath = node_path.join(pkgRootPath, 'static');
|
|
88
88
|
let cli_routeMeta;
|
|
89
89
|
function pluginPlayground(options) {
|
|
90
|
-
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = '
|
|
90
|
+
const { render = '', include, defaultDirection = 'horizontal', editorPosition = 'left', babelUrl = DEFAULT_BABEL_URL, monacoLoader = {}, monacoOptions = {}, defaultRenderMode = 'pure' } = options || {};
|
|
91
91
|
const playgroundVirtualModule = new RspackVirtualModulePlugin({});
|
|
92
92
|
const getRouteMeta = ()=>cli_routeMeta;
|
|
93
93
|
if (render && !/Playground\.(jsx?|tsx?)$/.test(render)) throw new Error('[Playground]: render should ends with Playground.(jsx?|tsx?)');
|
|
@@ -97,9 +97,8 @@ function pluginPlayground(options) {
|
|
|
97
97
|
preloads.push(`${monacoPrefix}/editor/editor.main.js`);
|
|
98
98
|
return {
|
|
99
99
|
name: '@rspress/plugin-playground',
|
|
100
|
-
config (config
|
|
100
|
+
config (config) {
|
|
101
101
|
config.markdown = config.markdown || {};
|
|
102
|
-
removePlugin('@rspress/plugin-preview');
|
|
103
102
|
return config;
|
|
104
103
|
},
|
|
105
104
|
async routeGenerated (routes) {
|
package/dist/web/index.js
CHANGED
|
@@ -33,7 +33,7 @@ function Editor(props) {
|
|
|
33
33
|
dark
|
|
34
34
|
]);
|
|
35
35
|
return /*#__PURE__*/ jsx("div", {
|
|
36
|
-
className: `
|
|
36
|
+
className: `rp-playground-editor ${className}`,
|
|
37
37
|
children: /*#__PURE__*/ jsx(react, {
|
|
38
38
|
...rest,
|
|
39
39
|
theme: theme,
|
|
@@ -255,12 +255,12 @@ class Runner extends Component {
|
|
|
255
255
|
const { className = '', code: _code, language: _language, getImport: _getImport, ...rest } = this.props;
|
|
256
256
|
const { error, comp } = this.state;
|
|
257
257
|
return /*#__PURE__*/ jsxs("div", {
|
|
258
|
-
className: `
|
|
258
|
+
className: `rp-playground-runner ${className}`,
|
|
259
259
|
...rest,
|
|
260
260
|
children: [
|
|
261
261
|
comp,
|
|
262
262
|
error && /*#__PURE__*/ jsx("pre", {
|
|
263
|
-
className: "
|
|
263
|
+
className: "rp-playground-error",
|
|
264
264
|
children: error.message
|
|
265
265
|
})
|
|
266
266
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/plugin-playground",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A plugin for rspress to preview the code block in markdown/mdx file.",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -37,25 +37,25 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@babel/types": "^7.28.6",
|
|
39
39
|
"@rsbuild/plugin-react": "~1.4.3",
|
|
40
|
-
"@rslib/core": "0.19.
|
|
40
|
+
"@rslib/core": "0.19.3",
|
|
41
41
|
"@types/babel__core": "^7.20.5",
|
|
42
42
|
"@types/babel__standalone": "^7.1.9",
|
|
43
43
|
"@types/babel__traverse": "^7.28.0",
|
|
44
44
|
"@types/mdast": "^4.0.4",
|
|
45
45
|
"@types/node": "^22.8.1",
|
|
46
|
-
"@types/react": "^19.2.
|
|
46
|
+
"@types/react": "^19.2.10",
|
|
47
47
|
"@types/react-dom": "^19.2.3",
|
|
48
48
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
49
|
-
"react": "^19.2.
|
|
50
|
-
"react-dom": "^19.2.
|
|
49
|
+
"react": "^19.2.4",
|
|
50
|
+
"react-dom": "^19.2.4",
|
|
51
51
|
"react-router-dom": "^7.12.0",
|
|
52
|
-
"rsbuild-plugin-publint": "^0.3.
|
|
52
|
+
"rsbuild-plugin-publint": "^0.3.4",
|
|
53
53
|
"typescript": "^5.8.2",
|
|
54
54
|
"unified": "^11.0.5",
|
|
55
|
-
"@rspress/plugin-playground": "2.0.0
|
|
55
|
+
"@rspress/plugin-playground": "2.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@rspress/core": "^2.0.0
|
|
58
|
+
"@rspress/core": "^2.0.0",
|
|
59
59
|
"react": ">=18.0.0",
|
|
60
60
|
"react-router-dom": "^6.8.1"
|
|
61
61
|
},
|
|
@@ -79,9 +79,9 @@ export default function Playground(props: PlaygroundProps) {
|
|
|
79
79
|
language === 'tsx' || language === 'ts' ? 'typescript' : 'javascript';
|
|
80
80
|
|
|
81
81
|
const classNames = [
|
|
82
|
-
'
|
|
83
|
-
`
|
|
84
|
-
`
|
|
82
|
+
'rp-playground',
|
|
83
|
+
`rp-playground-${direction}`,
|
|
84
|
+
`rp-playground-reverse-${useReverseLayout ? 'y' : 'n'}`,
|
|
85
85
|
'rp-not-doc',
|
|
86
86
|
className,
|
|
87
87
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.rp-playground {
|
|
2
2
|
display: flex;
|
|
3
3
|
border: 1px solid var(--rp-c-divider-light);
|
|
4
4
|
border-radius: 3px;
|
|
@@ -6,52 +6,50 @@
|
|
|
6
6
|
margin-bottom: 20px;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.
|
|
9
|
+
.rp-playground-horizontal {
|
|
10
10
|
flex-direction: row;
|
|
11
11
|
height: 400px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.
|
|
14
|
+
.rp-playground-horizontal.rp-playground-reverse-y {
|
|
15
15
|
flex-direction: row-reverse;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
.
|
|
18
|
+
.rp-playground-vertical {
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.
|
|
22
|
+
.rp-playground-runner {
|
|
23
23
|
position: relative;
|
|
24
24
|
padding: 20px;
|
|
25
25
|
overflow: auto;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.
|
|
28
|
+
.rp-playground-horizontal > .rp-playground-runner {
|
|
29
29
|
width: 40%;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.
|
|
32
|
+
.rp-playground-horizontal > .rp-playground-editor {
|
|
33
33
|
width: 60%;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.
|
|
37
|
-
> .rspress-playground-editor {
|
|
36
|
+
.rp-playground-horizontal.rp-playground-reverse-y > .rp-playground-editor {
|
|
38
37
|
border-right: 1px solid var(--rp-c-divider-light);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
.
|
|
42
|
-
> .rspress-playground-editor {
|
|
40
|
+
.rp-playground-horizontal.rp-playground-reverse-n > .rp-playground-editor {
|
|
43
41
|
border-left: 1px solid var(--rp-c-divider-light);
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
.
|
|
44
|
+
.rp-playground-vertical > .rp-playground-editor {
|
|
47
45
|
height: 300px;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
.
|
|
48
|
+
.rp-playground-vertical > .rp-playground-editor {
|
|
51
49
|
border-top: 1px solid var(--rp-c-divider-light);
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
.
|
|
52
|
+
.rp-playground-error {
|
|
55
53
|
width: 100%;
|
|
56
54
|
height: 100%;
|
|
57
55
|
position: absolute;
|