Skip to content

Commit

Permalink
chore: add example #269
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 2, 2024
1 parent dc52578 commit aa3b0d1
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 2 deletions.
11 changes: 11 additions & 0 deletions examples/#269/.kktrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { LoaderConfOptions, WebpackConfiguration } from 'kkt';

export default (conf: WebpackConfiguration, env: 'production' | 'development', options: LoaderConfOptions) => {
conf.ignoreWarnings = [{ module: /node_modules[\\/]parse5[\\/]/ }];
// https://github.com/kktjs/kkt/issues/336#issue-1097660932
conf.module!.exprContextCritical = false;
if (env === 'production') {
conf.output = { ...conf.output, publicPath: './' };
}
return conf;
};
34 changes: 34 additions & 0 deletions examples/#269/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@examples/269",
"version": "5.1.1",
"private": true,
"scripts": {
"build": "kkt build",
"start": "kkt start"
},
"dependencies": {
"react": "~18.2.0",
"react-dom": "~18.2.0",
"rehype-sanitize": "^6.0.0"
},
"devDependencies": {
"@kkt/less-modules": "^7.4.7",
"@kkt/scope-plugin-options": "^7.4.7",
"kkt": "^7.4.7"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
17 changes: 17 additions & 0 deletions examples/#269/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React Markdown Preview</title>
<meta name="keywords" content="react,component,markdown,preview" />
<meta name="description" content="React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style." />
</head>

<body>
<div id="root"></div>
</body>

</html>
34 changes: 34 additions & 0 deletions examples/#269/src/example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
import MarkdownPreview from '@uiw/react-markdown-preview';

const source = `
## MarkdownPreview
\`\`\`bash
$ npm install @uiw/react-markdown-preview --save
\`\`\`
`;

export default function Demo() {
return (
<MarkdownPreview
source={source}
rehypePlugins={[
[
rehypeSanitize,
{
...defaultSchema,
attributes: {
...defaultSchema.attributes,
svg: ['className', 'hidden', 'viewBox', 'fill', 'height', 'width'],
path: ['fill-rule', 'd'],
div: ['className', 'class', 'data-code', ...(defaultSchema.attributes?.div || [])],
},
tagNames: [...(defaultSchema.tagNames || []), 'svg', 'path', 'div'],
},
],
]}
style={{ padding: 16 }}
/>
);
}
7 changes: 7 additions & 0 deletions examples/#269/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createRoot } from 'react-dom/client';
import Demo from './example';

const container = document.getElementById('root');
const root = createRoot(container!);

root.render(<Demo />);
1 change: 1 addition & 0 deletions examples/#269/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
7 changes: 7 additions & 0 deletions examples/#269/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"baseUrl": "./"
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "5.1.2",
"packages": ["core", "website"]
"packages": ["core", "examples/**", "website"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"node": ">=16.0.0"
},
"workspaces": [
"examples/**",
"core",
"website"
]
Expand Down
1 change: 0 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"mermaid": "^10.6.1",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-router-dom": "^6.8.1",
"rehype-sanitize": "^6.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit aa3b0d1

Please sign in to comment.