Skip to content

Commit aa3b0d1

Browse files
committed
chore: add example #269
1 parent dc52578 commit aa3b0d1

File tree

10 files changed

+113
-2
lines changed

10 files changed

+113
-2
lines changed

examples/#269/.kktrc.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { LoaderConfOptions, WebpackConfiguration } from 'kkt';
2+
3+
export default (conf: WebpackConfiguration, env: 'production' | 'development', options: LoaderConfOptions) => {
4+
conf.ignoreWarnings = [{ module: /node_modules[\\/]parse5[\\/]/ }];
5+
// https://github.com/kktjs/kkt/issues/336#issue-1097660932
6+
conf.module!.exprContextCritical = false;
7+
if (env === 'production') {
8+
conf.output = { ...conf.output, publicPath: './' };
9+
}
10+
return conf;
11+
};

examples/#269/package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@examples/269",
3+
"version": "5.1.1",
4+
"private": true,
5+
"scripts": {
6+
"build": "kkt build",
7+
"start": "kkt start"
8+
},
9+
"dependencies": {
10+
"react": "~18.2.0",
11+
"react-dom": "~18.2.0",
12+
"rehype-sanitize": "^6.0.0"
13+
},
14+
"devDependencies": {
15+
"@kkt/less-modules": "^7.4.7",
16+
"@kkt/scope-plugin-options": "^7.4.7",
17+
"kkt": "^7.4.7"
18+
},
19+
"eslintConfig": {
20+
"extends": "react-app"
21+
},
22+
"browserslist": {
23+
"production": [
24+
">0.2%",
25+
"not dead",
26+
"not op_mini all"
27+
],
28+
"development": [
29+
"last 1 chrome version",
30+
"last 1 firefox version",
31+
"last 1 safari version"
32+
]
33+
}
34+
}

examples/#269/public/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>React Markdown Preview</title>
9+
<meta name="keywords" content="react,component,markdown,preview" />
10+
<meta name="description" content="React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style." />
11+
</head>
12+
13+
<body>
14+
<div id="root"></div>
15+
</body>
16+
17+
</html>

examples/#269/src/example.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
2+
import MarkdownPreview from '@uiw/react-markdown-preview';
3+
4+
const source = `
5+
## MarkdownPreview
6+
7+
\`\`\`bash
8+
$ npm install @uiw/react-markdown-preview --save
9+
\`\`\`
10+
`;
11+
12+
export default function Demo() {
13+
return (
14+
<MarkdownPreview
15+
source={source}
16+
rehypePlugins={[
17+
[
18+
rehypeSanitize,
19+
{
20+
...defaultSchema,
21+
attributes: {
22+
...defaultSchema.attributes,
23+
svg: ['className', 'hidden', 'viewBox', 'fill', 'height', 'width'],
24+
path: ['fill-rule', 'd'],
25+
div: ['className', 'class', 'data-code', ...(defaultSchema.attributes?.div || [])],
26+
},
27+
tagNames: [...(defaultSchema.tagNames || []), 'svg', 'path', 'div'],
28+
},
29+
],
30+
]}
31+
style={{ padding: 16 }}
32+
/>
33+
);
34+
}

examples/#269/src/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createRoot } from 'react-dom/client';
2+
import Demo from './example';
3+
4+
const container = document.getElementById('root');
5+
const root = createRoot(container!);
6+
7+
root.render(<Demo />);

examples/#269/src/react-app-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

examples/#269/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig",
3+
"compilerOptions": {
4+
"baseUrl": "./"
5+
},
6+
"include": ["src"]
7+
}

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"version": "5.1.2",
3-
"packages": ["core", "website"]
3+
"packages": ["core", "examples/**", "website"]
44
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"node": ">=16.0.0"
5151
},
5252
"workspaces": [
53+
"examples/**",
5354
"core",
5455
"website"
5556
]

website/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"mermaid": "^10.6.1",
1515
"react": "~18.2.0",
1616
"react-dom": "~18.2.0",
17-
"react-router-dom": "^6.8.1",
1817
"rehype-sanitize": "^6.0.0"
1918
},
2019
"devDependencies": {

0 commit comments

Comments
 (0)