From 4ed291d79a7e1430c0d364e956f2083db14dfcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?wifi=E6=AD=AAf?= <1402772884@qq.com> Date: Mon, 17 Feb 2025 12:42:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?docs(mini-markdown-docs):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=BB=84=E4=BB=B6=E9=A2=84=E8=A7=88=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/example/demo.tsx | 9 ++ docs/docs/example/index.mdx | 9 ++ docs/{ => docs}/guide/api.mdx | 0 docs/{ => docs}/guide/ast-parser.mdx | 14 +- docs/{ => docs}/guide/custom-preview.mdx | 0 docs/{ => docs}/guide/grammar.mdx | 0 ...245\345\205\267\346\240\217-component.png" | Bin docs/{ => docs}/guide/index.mdx | 0 docs/{ => docs}/guide/shortcut-keys.mdx | 0 docs/{ => docs}/guide/start.mdx | 4 +- docs/{ => docs}/index.md | 0 docs/{ => docs}/public/gitee.svg | 0 docs/{ => docs}/public/logo.svg | 0 docs/{ => docs}/public/react_light.svg | 0 docs/example/index.tsx | 152 ------------------ docs/rspress.config.ts | 12 +- docs/tsconfig.json | 4 +- 17 files changed, 41 insertions(+), 163 deletions(-) create mode 100644 docs/docs/example/demo.tsx create mode 100644 docs/docs/example/index.mdx rename docs/{ => docs}/guide/api.mdx (100%) rename docs/{ => docs}/guide/ast-parser.mdx (95%) rename docs/{ => docs}/guide/custom-preview.mdx (100%) rename docs/{ => docs}/guide/grammar.mdx (100%) rename "docs/guide/img/\350\207\252\345\256\232\344\271\211\345\267\245\345\205\267\346\240\217-component.png" => "docs/docs/guide/img/\350\207\252\345\256\232\344\271\211\345\267\245\345\205\267\346\240\217-component.png" (100%) rename docs/{ => docs}/guide/index.mdx (100%) rename docs/{ => docs}/guide/shortcut-keys.mdx (100%) rename docs/{ => docs}/guide/start.mdx (78%) rename docs/{ => docs}/index.md (100%) rename docs/{ => docs}/public/gitee.svg (100%) rename docs/{ => docs}/public/logo.svg (100%) rename docs/{ => docs}/public/react_light.svg (100%) delete mode 100644 docs/example/index.tsx diff --git a/docs/docs/example/demo.tsx b/docs/docs/example/demo.tsx new file mode 100644 index 0000000..e1db7d2 --- /dev/null +++ b/docs/docs/example/demo.tsx @@ -0,0 +1,9 @@ +import { Editor } from "@mini-markdown-rc/editor"; + +export default function () { + return ( +
+ +
+ ); +} diff --git a/docs/docs/example/index.mdx b/docs/docs/example/index.mdx new file mode 100644 index 0000000..015d766 --- /dev/null +++ b/docs/docs/example/index.mdx @@ -0,0 +1,9 @@ +# hello + +```tsx title="hello.ts" +console.log('hello') +``` + +## 案例 + + \ No newline at end of file diff --git a/docs/guide/api.mdx b/docs/docs/guide/api.mdx similarity index 100% rename from docs/guide/api.mdx rename to docs/docs/guide/api.mdx diff --git a/docs/guide/ast-parser.mdx b/docs/docs/guide/ast-parser.mdx similarity index 95% rename from docs/guide/ast-parser.mdx rename to docs/docs/guide/ast-parser.mdx index f33ea56..867de55 100644 --- a/docs/guide/ast-parser.mdx +++ b/docs/docs/guide/ast-parser.mdx @@ -1,4 +1,4 @@ -import { PackageManagerTabs } from "@theme"; +import { PackageManagerTabs } from "@rspress/theme-default"; # AST 解析 @@ -141,6 +141,18 @@ import { parseMarkdown, transformHtml } from "@mini-markdown-rc/ast-parser"; const { parseMarkdown, transformHtml } = require("@mini-markdown-rc/ast-parser"); ``` +## 样式 + +该库导出了一个默认样式文件,用于渲染转换后的html样式。 + +> 对于代码块的样式,需要手动引入样式文件。 +> +> `import "highlight.js/styles/atom-one-dark.css";` + +```ts +import '@mini-markdown-rc/ast-parser/style/index.css' +``` + ## 案例 ```js diff --git a/docs/guide/custom-preview.mdx b/docs/docs/guide/custom-preview.mdx similarity index 100% rename from docs/guide/custom-preview.mdx rename to docs/docs/guide/custom-preview.mdx diff --git a/docs/guide/grammar.mdx b/docs/docs/guide/grammar.mdx similarity index 100% rename from docs/guide/grammar.mdx rename to docs/docs/guide/grammar.mdx diff --git "a/docs/guide/img/\350\207\252\345\256\232\344\271\211\345\267\245\345\205\267\346\240\217-component.png" "b/docs/docs/guide/img/\350\207\252\345\256\232\344\271\211\345\267\245\345\205\267\346\240\217-component.png" similarity index 100% rename from "docs/guide/img/\350\207\252\345\256\232\344\271\211\345\267\245\345\205\267\346\240\217-component.png" rename to "docs/docs/guide/img/\350\207\252\345\256\232\344\271\211\345\267\245\345\205\267\346\240\217-component.png" diff --git a/docs/guide/index.mdx b/docs/docs/guide/index.mdx similarity index 100% rename from docs/guide/index.mdx rename to docs/docs/guide/index.mdx diff --git a/docs/guide/shortcut-keys.mdx b/docs/docs/guide/shortcut-keys.mdx similarity index 100% rename from docs/guide/shortcut-keys.mdx rename to docs/docs/guide/shortcut-keys.mdx diff --git a/docs/guide/start.mdx b/docs/docs/guide/start.mdx similarity index 78% rename from docs/guide/start.mdx rename to docs/docs/guide/start.mdx index 8b5edf1..5261d73 100644 --- a/docs/guide/start.mdx +++ b/docs/docs/guide/start.mdx @@ -1,4 +1,4 @@ -import { PackageManagerTabs } from '@theme'; +import { PackageManagerTabs } from '@rspress/theme-default'; # 快速开始 @@ -12,7 +12,7 @@ import { PackageManagerTabs } from '@theme'; ## 使用 -```tsx [src/App.tsx] +```tsx title="App.tsx" import { Editor } from "@mini-markdown-rc/editor"; export default function App() { diff --git a/docs/index.md b/docs/docs/index.md similarity index 100% rename from docs/index.md rename to docs/docs/index.md diff --git a/docs/public/gitee.svg b/docs/docs/public/gitee.svg similarity index 100% rename from docs/public/gitee.svg rename to docs/docs/public/gitee.svg diff --git a/docs/public/logo.svg b/docs/docs/public/logo.svg similarity index 100% rename from docs/public/logo.svg rename to docs/docs/public/logo.svg diff --git a/docs/public/react_light.svg b/docs/docs/public/react_light.svg similarity index 100% rename from docs/public/react_light.svg rename to docs/docs/public/react_light.svg diff --git a/docs/example/index.tsx b/docs/example/index.tsx deleted file mode 100644 index d35fb38..0000000 --- a/docs/example/index.tsx +++ /dev/null @@ -1,152 +0,0 @@ -import React, { FC, useEffect, useRef, useState } from "react"; -import { Editor, insertContent, ToolbarManager } from "@mini-markdown-rc/editor"; -import type { Callback, EditorRef } from "@mini-markdown-rc/editor"; -import { Button, message } from "antd"; -// 可根据需要引入不同的主题 -import "highlight.js/styles/atom-one-dark.css"; -import { ViewUpdate } from "@mini-markdown-rc/editor"; - -export const frontmatter = { - // 声明布局类型 - pageType: "page", -}; - -const App: FC = () => { - // 请求测试 - const handleUpload = async (file: File, callback: Callback) => { - await new Promise((resolve) => { - setTimeout(() => { - console.log("settimeout 上传成功", file); - resolve({}); - }, 1500); - }); - callback({ - url: "https://www.baidu.com/img/flexible/logo/pc/result@2.png", - alt: "alt", - }); - message.success("上传成功"); - }; - - const [theme, setTheme] = useState<"light" | "dark">("light"); - const changeTheme = () => { - setTheme(theme === "light" ? "dark" : "light"); - }; - - const handleChange = (val: string, view: ViewUpdate) => { - console.log(val, view); - }; - - const handlePatseUpload = async (file: File, callback: Callback) => { - await new Promise((resolve) => { - setTimeout(() => { - console.log("settimeout 上传成功", file); - resolve({}); - }, 1500); - }); - callback({ - url: "https://www.baidu.com/img/flexible/logo/pc/result@2.png", - alt: "123", - }); - message.success("上传成功"); - }; - - const editorRef = useRef(null); - - useEffect(() => { - if (editorRef.current) { - console.log(editorRef.current); - } - }, []); - - return ( - <> - - - - - - - - - - -
- -
- - ); -}; - -export default App; diff --git a/docs/rspress.config.ts b/docs/rspress.config.ts index a8c3bb3..3b69b4d 100644 --- a/docs/rspress.config.ts +++ b/docs/rspress.config.ts @@ -1,12 +1,14 @@ import { defineConfig } from "rspress/config"; import { sidebar } from "./sidebar"; -// import { pluginPreview } from "@rspress/plugin-preview"; +import { pluginPreview } from "@rspress/plugin-preview"; export default defineConfig({ - // plugins: [pluginPreview({ - // // defaultRenderMode: 'pure' - // })], - root: "./", + plugins: [ + pluginPreview({ + defaultRenderMode: "pure", + }), + ], + root: "docs", title: "Mini Markdown Editor", description: "一个基于 React 的 Markdown 编辑器", icon: "/logo.svg", diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 81288d7..df9ad96 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -17,9 +17,7 @@ "allowImportingTsExtensions": true, }, "include": [ - "**/*.mdx", - "**/*.ts", - "**/*.tsx", + "docs", "theme", "rspress.config.ts" ], -- Gitee From 920b89d2ed85289a29be8dafb89170511fd82282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?wifi=E6=AD=AAf?= <1402772884@qq.com> Date: Mon, 17 Feb 2025 12:43:48 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ci(mini-markdown-ast-parser):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=A0=B7=E5=BC=8F=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mini-markdown-ast-parser/example/demo.css | 43 +++++- .../mini-markdown-ast-parser/example/demo.md | 138 +++++++++++++++++- ...55\346\263\225\350\247\204\345\210\231.md" | 33 ----- .../mini-markdown-ast-parser/package.json | 3 +- .../src/styles/index.css | 44 +++++- 5 files changed, 217 insertions(+), 44 deletions(-) delete mode 100644 "packages/mini-markdown-ast-parser/example/markdown\347\274\226\350\276\221\345\231\250\350\257\255\346\263\225\350\247\204\345\210\231.md" diff --git a/packages/mini-markdown-ast-parser/example/demo.css b/packages/mini-markdown-ast-parser/example/demo.css index 728d959..92d97dd 100644 --- a/packages/mini-markdown-ast-parser/example/demo.css +++ b/packages/mini-markdown-ast-parser/example/demo.css @@ -9,6 +9,8 @@ padding: 0 10px; word-wrap: break-word; color: #3f4a54; + margin: 0.8em 0; + font-weight: 700; } .mini-md-h1 { @@ -39,7 +41,6 @@ line-height: 22px; padding: 2px 4px; color: #3594f7; - /* #f1f1f1 */ background-color: rgba(59, 170, 250, 0.1); border-radius: 4px; } @@ -77,8 +78,7 @@ margin: 20px 0; overflow: auto; padding: 0 1.2em; - background-color: #ececec; - border-left: 5px solid #35b378; + border-left: 5px solid #d0d7de; color: #3f4a54; } @@ -106,12 +106,37 @@ .mini-md-ul, .mini-md-ol { margin: 0.6em 0; + padding-inline-start: 30px; + list-style: initial; +} + +.mini-md-li { + list-style: initial; } .mini-md-li::marker { color: #1456f0; } +.mini-md-ul > .mini-md-li { + list-style-type: disc; +} +.mini-md-ul .mini-md-ul > .mini-md-li { + list-style-type: circle; +} +.mini-md-ul .mini-md-ul .mini-md-ul > .mini-md-li { + list-style-type: square; +} +.mini-md-ol > .mini-md-li { + list-style-type: decimal; +} +.mini-md-ol .mini-md-ol > .mini-md-li { + list-style-type: lower-alpha; +} +.mini-md-ol .mini-md-ol .mini-md-ol > .mini-md-li { + list-style-type: lower-roman; +} + .mini-md-code-container { font-size: 12px; line-height: 1; @@ -176,9 +201,19 @@ border-top-right-radius: 0; color: #a9b7c6; display: block; - font-family: source-code-pro, Menlo, Monaco, Consolas, Courier New, monospace; + font-family: + source-code-pro, + Menlo, + Monaco, + Consolas, + Courier New, + monospace; font-size: 14px; line-height: 1.6; overflow: auto; padding: 1em; } + +.markdown-editor-preview p { + margin: 0 !important; +} diff --git a/packages/mini-markdown-ast-parser/example/demo.md b/packages/mini-markdown-ast-parser/example/demo.md index 36116c8..d46173e 100644 --- a/packages/mini-markdown-ast-parser/example/demo.md +++ b/packages/mini-markdown-ast-parser/example/demo.md @@ -13,4 +13,140 @@ asd 4. demo4 5. demo5 测试 -6. \ No newline at end of file +6. + +asdss**--~~_asd_~~--**asd_123_ + +**asd** + +asd`code``code`asd--uder--~~bolang~~ + +--uder--[link](./demo.md) + +--- + +# h1 `code` _bolang_ +## h2 `code` --bolang-- + +> blockquote `code` + +> blockquote `code` +> +> blockquote _bolang_ + +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) + +- 1 + - asd + - 啊啥的、2 + - 啊啥的、2 + - 啊啥的、asdsa + - 啊啥的、asdsa + - 啊啥的、asdsa + - 啊啥的、asdsa +- 2 + - 2asd + - 啊啥的、3 + - 啊啥的、asdsa +- 3 + +```html + + + + + + Document + + + ${html} + + + +``` +```js +const a = 1; +``` + +

hellored

+ +```python +def hello(): + print('hello') + return +``` + +`

hello

` + +| 姓名 | 年龄 | 地址 | +| ------ | ------- | ------- | +| 张三 | 18 | `北京` | +| 李四 | 20 | `上海` | + +----- + +asdss**asd**asd_123_ + +**asd** + +asd`code``code`asd--uder--~~bolang~~ + +--uder--[link](./demo.md) + +--- + +# h1 `code` _bolang_ +## h2 `code` --bolang-- + +> blockquote `code` + +> blockquote `code` +> +> blockquote _bolang_ + +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) + +- 1 + - asd + - 啊啥的、2 + - 啊啥的、2 + - 啊啥的、asdsa +- 2 + - 2asd +- 3 + +```html + + + ${html} + + + +``` +```js +const a = 1;asdasdasdsadad +``` + +

hellored

+ +1. aaa + 1. 222 + 2. 333 + 1. 111 +3. bbb + +```python +def hello(): +``` + +`

hello

` + +| 姓名 | 年龄 | 地址 | +| ------ | ------- | ------- | +| 张三 | 18 | 北京 | \ No newline at end of file diff --git "a/packages/mini-markdown-ast-parser/example/markdown\347\274\226\350\276\221\345\231\250\350\257\255\346\263\225\350\247\204\345\210\231.md" "b/packages/mini-markdown-ast-parser/example/markdown\347\274\226\350\276\221\345\231\250\350\257\255\346\263\225\350\247\204\345\210\231.md" deleted file mode 100644 index 1ed30ed..0000000 --- "a/packages/mini-markdown-ast-parser/example/markdown\347\274\226\350\276\221\345\231\250\350\257\255\346\263\225\350\247\204\345\210\231.md" +++ /dev/null @@ -1,33 +0,0 @@ -# heading 标题 - -**加粗** bold 加粗 - -_斜体_ italic 斜体 - ---下划线-- underline 下划线 - -~~删除线~~ delete 删除线 - -> blockquote 引用 - -[link](http://www.xxx.com) link 链接 - -![image](http://www.xxx.com/image.jpg) image 图片 - -`inlineCode` inlineCode 行内高亮 - ---- thematicBreak 分割线 - -```js -``` -code 代码 - - -- list 列表 -1. list 列表 - -| head1 | head2 | head3 | -|-------|-------|-------| -| cell1 | cell2 | cell3 | table 表格 - -
html 标签 diff --git a/packages/mini-markdown-ast-parser/package.json b/packages/mini-markdown-ast-parser/package.json index d3d89bd..8d3d76d 100644 --- a/packages/mini-markdown-ast-parser/package.json +++ b/packages/mini-markdown-ast-parser/package.json @@ -14,7 +14,8 @@ "./style": { "import": "./dist/style/index.css", "require": "./dist/style/index.css" - } + }, + "./*": "./dist/*" }, "publishConfig": { "access": "public", diff --git a/packages/mini-markdown-ast-parser/src/styles/index.css b/packages/mini-markdown-ast-parser/src/styles/index.css index e018226..92d97dd 100644 --- a/packages/mini-markdown-ast-parser/src/styles/index.css +++ b/packages/mini-markdown-ast-parser/src/styles/index.css @@ -9,7 +9,8 @@ padding: 0 10px; word-wrap: break-word; color: #3f4a54; - margin: 0 !important; + margin: 0.8em 0; + font-weight: 700; } .mini-md-h1 { @@ -40,7 +41,6 @@ line-height: 22px; padding: 2px 4px; color: #3594f7; - /* #f1f1f1 */ background-color: rgba(59, 170, 250, 0.1); border-radius: 4px; } @@ -78,8 +78,7 @@ margin: 20px 0; overflow: auto; padding: 0 1.2em; - background-color: #ececec; - border-left: 5px solid #35b378; + border-left: 5px solid #d0d7de; color: #3f4a54; } @@ -107,12 +106,37 @@ .mini-md-ul, .mini-md-ol { margin: 0.6em 0; + padding-inline-start: 30px; + list-style: initial; +} + +.mini-md-li { + list-style: initial; } .mini-md-li::marker { color: #1456f0; } +.mini-md-ul > .mini-md-li { + list-style-type: disc; +} +.mini-md-ul .mini-md-ul > .mini-md-li { + list-style-type: circle; +} +.mini-md-ul .mini-md-ul .mini-md-ul > .mini-md-li { + list-style-type: square; +} +.mini-md-ol > .mini-md-li { + list-style-type: decimal; +} +.mini-md-ol .mini-md-ol > .mini-md-li { + list-style-type: lower-alpha; +} +.mini-md-ol .mini-md-ol .mini-md-ol > .mini-md-li { + list-style-type: lower-roman; +} + .mini-md-code-container { font-size: 12px; line-height: 1; @@ -177,9 +201,19 @@ border-top-right-radius: 0; color: #a9b7c6; display: block; - font-family: source-code-pro, Menlo, Monaco, Consolas, Courier New, monospace; + font-family: + source-code-pro, + Menlo, + Monaco, + Consolas, + Courier New, + monospace; font-size: 14px; line-height: 1.6; overflow: auto; padding: 1em; } + +.markdown-editor-preview p { + margin: 0 !important; +} -- Gitee From 35a996b98f2c329d9ed192473b31f9c3dca9202e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?wifi=E6=AD=AAf?= <1402772884@qq.com> Date: Mon, 17 Feb 2025 12:44:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?test(mini-markdown-play):=20=E6=89=93?= =?UTF-8?q?=E5=8C=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mini-markdown-play/.npmrc | 1 + packages/mini-markdown-play/package.json | 1 + packages/mini-markdown-play/src/App.tsx | 11 +- .../mini-markdown-play/src/pages/ast-demo.md | 135 ++++++++++++++++++ .../mini-markdown-play/src/pages/ast-test.tsx | 18 +++ .../mini-markdown-play/src/pages/ui-test.tsx | 8 +- .../mini-markdown-play/src/router/index.tsx | 81 ++++++----- 7 files changed, 211 insertions(+), 44 deletions(-) create mode 100644 packages/mini-markdown-play/.npmrc create mode 100644 packages/mini-markdown-play/src/pages/ast-demo.md create mode 100644 packages/mini-markdown-play/src/pages/ast-test.tsx diff --git a/packages/mini-markdown-play/.npmrc b/packages/mini-markdown-play/.npmrc new file mode 100644 index 0000000..caa71fe --- /dev/null +++ b/packages/mini-markdown-play/.npmrc @@ -0,0 +1 @@ +shamefully-hoist=false \ No newline at end of file diff --git a/packages/mini-markdown-play/package.json b/packages/mini-markdown-play/package.json index 6bbe332..d58bcba 100644 --- a/packages/mini-markdown-play/package.json +++ b/packages/mini-markdown-play/package.json @@ -10,6 +10,7 @@ "preview": "vite preview" }, "dependencies": { + "@mini-markdown-rc/ast-parser": "workspace:^1.0.1", "@mini-markdown-rc/editor": "workspace:*", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/packages/mini-markdown-play/src/App.tsx b/packages/mini-markdown-play/src/App.tsx index 0ed4f80..81159ab 100644 --- a/packages/mini-markdown-play/src/App.tsx +++ b/packages/mini-markdown-play/src/App.tsx @@ -1,15 +1,16 @@ -import { useRoutes, NavLink } from 'react-router-dom' -import routes from './router' +import { useRoutes, NavLink } from "react-router-dom"; +import routes from "./router"; export default function App() { - const outlet = useRoutes(routes) + const outlet = useRoutes(routes); return ( <> -
+
组件库测试 + AST测试 CSS主题切换方案测试
{outlet} - ) + ); } diff --git a/packages/mini-markdown-play/src/pages/ast-demo.md b/packages/mini-markdown-play/src/pages/ast-demo.md new file mode 100644 index 0000000..65a762b --- /dev/null +++ b/packages/mini-markdown-play/src/pages/ast-demo.md @@ -0,0 +1,135 @@ +asdss**--~~_asd_~~--**asd_123_ + +**asd** + +asd`code``code`asd--uder--~~bolang~~ + +--uder--[link](./demo.md) + +--- + +# h1 `code` _bolang_ +## h2 `code` --bolang-- + +> blockquote `code` + +> blockquote `code` +> +> blockquote _bolang_ + +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) + +- 1 + - asd + - 啊啥的、2 + - 啊啥的、2 + - 啊啥的、asdsa + - 啊啥的、asdsa + - 啊啥的、asdsa + - 啊啥的、asdsa +- 2 + - 2asd + - 啊啥的、3 + - 啊啥的、asdsa +- 3 + +```html + + + + + + Document + + + ${html} + + + +``` +```js +const a = 1; +``` + +

hellored

+ +```python +def hello(): + print('hello') + return +``` + +`

hello

` + +| 姓名 | 年龄 | 地址 | +| ------ | ------- | ------- | +| 张三 | 18 | `北京` | +| 李四 | 20 | `上海` | + +----- + +asdss**asd**asd_123_ + +**asd** + +asd`code``code`asd--uder--~~bolang~~ + +--uder--[link](./demo.md) + +--- + +# h1 `code` _bolang_ +## h2 `code` --bolang-- + +> blockquote `code` + +> blockquote `code` +> +> blockquote _bolang_ + +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) +![image](https://www.baidu.com/img/flexible/logo/pc/result@2.png) + +- 1 + - asd + - 啊啥的、2 + - 啊啥的、2 + - 啊啥的、asdsa +- 2 + - 2asd +- 3 + +```html + + + ${html} + + + +``` +```js +const a = 1;asdasdasdsadad +``` + +

hellored

+ +1. aaa + 1. 222 + 2. 333 + 1. 111 +3. bbb + +```python +def hello(): +``` + +`

hello

` + +| 姓名 | 年龄 | 地址 | +| ------ | ------- | ------- | +| 张三 | 18 | 北京 | \ No newline at end of file diff --git a/packages/mini-markdown-play/src/pages/ast-test.tsx b/packages/mini-markdown-play/src/pages/ast-test.tsx new file mode 100644 index 0000000..1a68151 --- /dev/null +++ b/packages/mini-markdown-play/src/pages/ast-test.tsx @@ -0,0 +1,18 @@ +import { FC, useEffect, useState } from "react"; +// 可根据需要引入不同的主题 +import "highlight.js/styles/atom-one-dark.css"; +import { parseMarkdown, transformHtml } from "@mini-markdown-rc/ast-parser"; +import "@mini-markdown-rc/ast-parser/style/index.css"; +import mdCode from "./ast-demo.md?raw"; + +const App: FC = () => { + const [code, setCode] = useState(""); + useEffect(() => { + const res = parseMarkdown(mdCode); + setCode(transformHtml(res)); + }, []); + + return
; +}; + +export default App; diff --git a/packages/mini-markdown-play/src/pages/ui-test.tsx b/packages/mini-markdown-play/src/pages/ui-test.tsx index c559314..e2f162e 100644 --- a/packages/mini-markdown-play/src/pages/ui-test.tsx +++ b/packages/mini-markdown-play/src/pages/ui-test.tsx @@ -1,4 +1,4 @@ -import { FC, useState } from "react"; +import { FC, useEffect, useState } from "react"; import styled from "styled-components"; import { Editor } from "@mini-markdown-rc/editor"; import type { Callback } from "@mini-markdown-rc/editor"; @@ -6,6 +6,8 @@ import { Button, message } from "antd"; // 可根据需要引入不同的主题 import "highlight.js/styles/atom-one-dark.css"; import { ViewUpdate } from "@mini-markdown-rc/editor"; +import { parseMarkdown } from "@mini-markdown-rc/ast-parser"; +import "@mini-markdown-rc/ast-parser/style/index.css"; const AppWrapper = styled.div` width: 100%; @@ -15,6 +17,10 @@ const AppWrapper = styled.div` `; const App: FC = () => { + useEffect(() => { + const res = parseMarkdown(`# hello world`); + console.log(res); + }); // 请求测试 const handleUpload = async (file: File, callback: Callback) => { await new Promise((resolve) => { diff --git a/packages/mini-markdown-play/src/router/index.tsx b/packages/mini-markdown-play/src/router/index.tsx index 663c271..8d6bbe0 100644 --- a/packages/mini-markdown-play/src/router/index.tsx +++ b/packages/mini-markdown-play/src/router/index.tsx @@ -1,41 +1,46 @@ -import { RouteObject, Navigate } from 'react-router-dom' -import UITest from '@/pages/ui-test' -import CssTest from '@/pages/css-test' -import CssInJs from '@/pages/css-in-js' -import ModuleCSS from '@/pages/module-css' -import Tailwindcss from '@/pages/tailwindcss' +import { RouteObject, Navigate } from "react-router-dom"; +import UITest from "@/pages/ui-test"; +import ASTTest from "@/pages/ast-test"; +import CssTest from "@/pages/css-test"; +import CssInJs from "@/pages/css-in-js"; +import ModuleCSS from "@/pages/module-css"; +import Tailwindcss from "@/pages/tailwindcss"; const routes: RouteObject[] = [ - { - path: '/', - element: - }, - { - path: '/ui-test', - element: - }, - { - path: '/css-test', - element: , - children: [ - { - index: true, - element: - }, - { - path: 'css-in-js', - element: - }, - { - path: 'module-css', - element: - }, - { - path: 'tailwindcss', - element: - } - ] - } -] + { + path: "/", + element: , + }, + { + path: "/ui-test", + element: , + }, + { + path: "/ast-test", + element: , + }, + { + path: "/css-test", + element: , + children: [ + { + index: true, + element: , + }, + { + path: "css-in-js", + element: , + }, + { + path: "module-css", + element: , + }, + { + path: "tailwindcss", + element: , + }, + ], + }, +]; -export default routes \ No newline at end of file +export default routes; -- Gitee