From 122e67b8de395799d11bdbd809cef8b592d1c2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?wifi=E6=AD=AAf?= <1402772884@qq.com> Date: Fri, 7 Feb 2025 04:20:45 +0800 Subject: [PATCH] =?UTF-8?q?docs(mini-editor-docs):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config.mts | 72 ----- docs/.vitepress/theme/index.ts | 4 - docs/demo/demo.tsx | 10 - docs/example/index.md | 8 - docs/example/index.mdx | 1 + docs/guide/api.md | 1 - docs/guide/api.mdx | 240 ++++++++++++++++ docs/guide/ast-parser.mdx | 9 + docs/guide/custom-preview.mdx | 261 ++++++++++++++++++ docs/guide/grammar.mdx | 158 +++++++++++ docs/guide/index.md | 90 ------ docs/guide/index.mdx | 1 + docs/guide/shortcut-keys.mdx | 0 docs/guide/{start.md => start.mdx} | 26 +- docs/index.md | 25 +- docs/package.json | 16 +- docs/postcss.config.js | 5 + docs/public/gitee.svg | 1 + docs/public/react_dark.svg | 12 - docs/rspress.config.ts | 45 +++ docs/{.vitepress => }/sidebar.ts | 12 +- docs/styles/index.css | 3 + docs/tailwind.config.js | 7 + docs/tsconfig.json | 27 ++ .../src/components/Editor/index.tsx | 2 +- .../src/types/global-config.ts | 2 +- 26 files changed, 781 insertions(+), 257 deletions(-) delete mode 100644 docs/.vitepress/config.mts delete mode 100644 docs/.vitepress/theme/index.ts delete mode 100644 docs/demo/demo.tsx delete mode 100644 docs/example/index.md create mode 100644 docs/example/index.mdx delete mode 100644 docs/guide/api.md create mode 100644 docs/guide/api.mdx create mode 100644 docs/guide/ast-parser.mdx create mode 100644 docs/guide/custom-preview.mdx create mode 100644 docs/guide/grammar.mdx delete mode 100644 docs/guide/index.md create mode 100644 docs/guide/index.mdx create mode 100644 docs/guide/shortcut-keys.mdx rename docs/guide/{start.md => start.mdx} (31%) create mode 100644 docs/postcss.config.js create mode 100644 docs/public/gitee.svg delete mode 100644 docs/public/react_dark.svg create mode 100644 docs/rspress.config.ts rename docs/{.vitepress => }/sidebar.ts (54%) create mode 100644 docs/styles/index.css create mode 100644 docs/tailwind.config.js create mode 100644 docs/tsconfig.json diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts deleted file mode 100644 index c62ff20..0000000 --- a/docs/.vitepress/config.mts +++ /dev/null @@ -1,72 +0,0 @@ -import { defineConfig } from 'vitepress' -import { sidebar } from './sidebar' -import { vitepressDemoPlugin } from 'vitepress-demo-plugin' -import { groupIconMdPlugin, groupIconVitePlugin } from 'vitepress-plugin-group-icons' - -export default defineConfig({ - title: "Mini Markdown Editor", - description: "字节青训营项目: mini markdown editor", - markdown: { - lineNumbers: true, - config(md) { - md.use(vitepressDemoPlugin); - md.use(groupIconMdPlugin); - }, - }, - vite: { - plugins: [ - groupIconVitePlugin() - ], - }, - head: [ - ['link', { rel: 'icon', href: '/logo.svg' }] - ], - themeConfig: { - logo: '/logo.svg', - search: { - provider: 'local', - options: { - locales: { - root: { - translations: { - button: { - buttonText: '搜索文档', - buttonAriaLabel: '搜索文档' - }, - modal: { - noResultsText: '无法找到相关结果', - resetButtonTitle: '清除查询条件', - footer: { - selectText: '选择', - navigateText: '切换', - } - } - } - } - } - } - }, - docFooter: { - prev: '上一页', - next: '下一页' - }, - outline: { - label: '本页目录' - }, - nav: [ - { text: '指南', link: '/guide', activeMatch: '/guide' }, - { text: '文档', link: '/docs', activeMatch: '/docs' }, - { text: '示例', link: '/example', activeMatch: '/example' }, - { text: '关于我们', link: '/team', activeMatch: '/team' }, - ], - sidebar, - sidebarMenuLabel: '菜单', - socialLinks: [ - { icon: 'github', link: 'https://github.com/xiaotianna/mini-markdown-editor' }, - { icon: 'gitee', link: 'https://gitee.com/lin-yaozhen/mini-markdown-editor' } - ], - footer: { - message: '2025 字节青训营「前端」', - } - } -}) diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts deleted file mode 100644 index 2a9a5d1..0000000 --- a/docs/.vitepress/theme/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import Theme from "vitepress/theme"; -import "virtual:group-icons.css"; - -export default Theme; diff --git a/docs/demo/demo.tsx b/docs/demo/demo.tsx deleted file mode 100644 index ec6a747..0000000 --- a/docs/demo/demo.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from "react"; -import { Editor } from "@mini-markdown/editor"; - -export default function Demo() { - return ( -
- -
- ); -} diff --git a/docs/example/index.md b/docs/example/index.md deleted file mode 100644 index 3b35ac5..0000000 --- a/docs/example/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -aside: false -layout: page ---- - -# 在线尝试 - - \ No newline at end of file diff --git a/docs/example/index.mdx b/docs/example/index.mdx new file mode 100644 index 0000000..c6fba08 --- /dev/null +++ b/docs/example/index.mdx @@ -0,0 +1 @@ +# example \ No newline at end of file diff --git a/docs/guide/api.md b/docs/guide/api.md deleted file mode 100644 index c3684bb..0000000 --- a/docs/guide/api.md +++ /dev/null @@ -1 +0,0 @@ -# API \ No newline at end of file diff --git a/docs/guide/api.mdx b/docs/guide/api.mdx new file mode 100644 index 0000000..a2ad6d9 --- /dev/null +++ b/docs/guide/api.mdx @@ -0,0 +1,240 @@ +# API + +## 属性 + +### toolbar + +- 类型:`ToolbarType[] | Record` +- 默认值:`undefined` + +需要渲染的 toolbar,默认全部渲染。你可以随意排序工具栏,通过 `'-'` 分割两个工具栏。 + +```tsx +// 配置方法1 + + +// 配置方法2 + +``` + +### status + +- 类型:`boolean` +- 默认值:`true` + +底部状态栏是否显示,默认显示。 + +```tsx + +``` + +### theme + +- 类型:`"light" | "dark"` +- 默认值:`"light"` + +编辑器主题。 + +```tsx +const App = () => { + const [theme, setTheme] = useState<"light" | "dark">("light"); + const handleChange = () => { + setTheme(theme === "light" ? "dark" : "light"); + }; + return ( + <> + + + + ); +}; +``` + +### local + +- 类型:`boolean` +- 默认值:`true` + +是否开启本地存储,默认开启。 + +> `localStorage` 存储的 key 为 `markdown-editor-content` + +```tsx + +``` + +### lineNumbers + +- 类型:`boolean` +- 默认值:`false` + +编辑区是否显示行号,默认不显示。 + +```tsx + +``` + +## 事件 + +### onChange + +- 类型:`(value: string, editorView: ViewUpdate) => void` + - value:编辑器内容 + - editorView:编辑器实例 + +编辑器内容变化时触发。 + +```tsx + { + console.log(value, editorView); + }} +/> +``` + +### onSave + +- 类型:`(value: string, editorView: ViewUpdate) => void` + +保存事件,当点击 `保存按钮` / `按下快捷键` 时触发。 + +```tsx + { + // 上传服务器 + console.log(value, editorView); + }} +/> +``` + +### onUpload + +- 类型:`(file: File, callback: Callback) => void` + - file:`File` 对象 + - callback:`Callback` + +```ts +type Callback = (param: { url: string; alt?: string }) => void; +``` + +上传图片事件,等待上传结果,务必将上传后的 url 作为 callback 入参回传。 + +```tsx {5,12-15,19} +import { message } from "antd"; + +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("上传成功"); + }; + + return ; +}; +``` + +### onDragUpload + +- 类型:`(files: File, callback: Callback) => void` + +拖拽上传图片事件(同上)。 + +## 类型 + +### EditorView、ViewUpdate + +编辑区使用的是 `CodeMirror`,对外暴露了 `EditorView` 和 `ViewUpdate` 两个类型,可供使用。 + +```ts +import type { EditorView, ViewUpdate } from "mini-markdown-editor"; +``` + +### ToolbarType + +工具栏类型,用于配置 `toolbar`。 + +```ts +type ToolbarType = + | "heading" + | "heading-1" + | "heading-2" + | "heading-3" + | "heading-4" + | "heading-5" + | "heading-6" + | "bold" + | "italic" + | "underline" + | "delete" + | "line" + | "blockquote" + | "ul" + | "ol" + | "inlinecode" + | "code" + | "link" + | "image" + | "image-link" + | "image-upload" + | "table" + | "undo" + | "redo" + | "fullscreen" + | "write" + | "preview" + | "contents" + | "help" + | "output" + | "emoji"; +``` + +**使用:** + +```ts +import type { ToolbarType } from "mini-markdown-editor"; +``` + +### GlobalConfig + +全局配置类型。 + +```ts +interface GlobalConfig { + toolbar?: ToolbarType[] | Record; + status?: boolean; + theme?: "light" | "dark"; + local?: boolean; // 是否开启本地存储 + lineNumbers?: boolean; + onChange?: (value: string, editorView: ViewUpdate) => void; + onUpload?: (file: File, callback: Callback) => void; + onDragUpload?: (file: File, callback: Callback) => void; + onSave?: (value: string, editorView: ViewUpdate) => void; +} + +type Callback = (param: { url: string; alt?: string }) => void; +``` diff --git a/docs/guide/ast-parser.mdx b/docs/guide/ast-parser.mdx new file mode 100644 index 0000000..11a2268 --- /dev/null +++ b/docs/guide/ast-parser.mdx @@ -0,0 +1,9 @@ +import { PackageManagerTabs } from '@theme'; + +# AST 解析 + +完成ast解析,有增量构建 + +## 安装 + + diff --git a/docs/guide/custom-preview.mdx b/docs/guide/custom-preview.mdx new file mode 100644 index 0000000..7c84302 --- /dev/null +++ b/docs/guide/custom-preview.mdx @@ -0,0 +1,261 @@ +# 渲染区样式 + +## 自定义渲染区样式 + +通过 `className` 可以自定义渲染区样式,进行样式重写。 + +> 外层容器类名 `.markdown-editor-preview`。 + +```css +p { + line-height: 20px; +} + +strong { + font-weight: 700; +} + +.mini-md-h1, +.mini-md-h2, +.mini-md-h3, +.mini-md-h4, +.mini-md-h5, +.mini-md-h6 { + width: 100%; + display: block; + padding: 0 10px; + word-wrap: break-word; + /* color: #3f4a54; */ + color: var(--md-preview-special-color); + margin: 0.8em 0; + font-weight: 700; +} + +.mini-md-h1 { + font-size: 2em; +} + +.mini-md-h2 { + font-size: 1.5em; +} + +.mini-md-h3 { + font-size: 1.25em; +} + +.mini-md-h4 { + font-size: 1em; +} + +.mini-md-h5 { + font-size: 0.875em; +} + +.mini-md-h6 { + font-size: 0.85em; +} + +.mini-md-inline-code { + line-height: 22px; + padding: 2px 4px; + /* color: #3594f7; */ + color: var(--md-preview-inlincode-color); + /* #f1f1f1 */ + /* background-color: rgba(59, 170, 250, 0.1); */ + background-color: var(--md-preview-inlincode-bg-color); + border-radius: 4px; +} + +.mini-md-link { + color: #2d8cf0; + text-decoration: none; + transition: color 0.3s; + cursor: pointer; +} + +.mini-md-link:hover { + color: #73d13d; +} + +.mini-md-image { + width: 100%; + /* border: 1px solid #e6e6e6; */ + border: 1px solid var(--md-preview-border-color); + border-radius: 3px; + box-sizing: border-box; + margin: 0 auto; + padding: 5px; +} + +.mini-md-hr { + border: none; + border-top: 1px solid var(--md-preview-border-color); + height: 1px; + margin: 10px 0; +} + +.mini-md-blockquote { + display: block; + line-height: 2em; + margin: 20px 0; + overflow: auto; + padding: 0 1.2em; + /* border-left: 5px solid #d0d7de; */ + border-left: 5px solid var(--md-preview-blockquote-border-color); + color: var(--md-preview-blockquote-color); +} + +.mini-md-table { + width: 50%; + border-collapse: collapse; + margin: 20px 0; +} + +.mini-md-th, +.mini-md-td { + /* border: 1px solid #ddd; */ + border: 1px solid var(--md-preview-table-border-color); + padding: 8px; + text-align: left; +} + +.mini-md-th { + /* background-color: #f2f2f2; */ + background-color: var(--md-preview-th-bg-color); +} + +.mini-md-tr:hover { + /* background-color: #f5f5f5; */ + background-color: var(--md-preview-table-hover-bg-color); +} + +.mini-md-ul, +.mini-md-ol { + margin: 0.6em 0; + padding-inline-start: 30px; + list-style: initial; + .mini-md-li { + list-style: initial; + &::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; + margin: 20px 0; + position: relative; +} + +.mini-md-code-container .mini-md-code-header { + background-color: #282c34; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + display: flex; + font-size: 12px; + font-weight: 600; + height: 32px; + justify-content: space-between; + margin-bottom: 0; + width: 100%; +} + +.mini-md-code-header .mini-md-code-icon { + display: flex; + gap: 5px; + margin-left: 12px; +} + +.mini-md-code-header .mini-md-code-icon span { + border-radius: 50%; + display: inline-block; + height: 10px; + margin-top: 10px; + width: 10px; +} + +.mini-md-code-icon span:nth-of-type(1) { + background-color: #ec6a5e; +} + +.mini-md-code-icon span:nth-of-type(2) { + background-color: #f4bf4f; +} + +.mini-md-code-icon span:nth-of-type(3) { + background-color: #61c554; +} + +.mini-md-code-right { + display: flex; + align-items: center; + margin-right: 10px; + color: #a9b7c6; + + .copy-code-button-wrapper { + margin-left: 5px; + display: inline-flex; + align-items: center; + } +} + +.mini-md-code-container pre { + margin: 0; +} + +.mini-md-code-container pre code { + background-color: #282c34; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + border-top-left-radius: 0; + border-top-right-radius: 0; + color: #a9b7c6; + display: block; + 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; +} +``` + +## Code 代码块样式 + +代码块主题,使用的 `highlight.js`。可以自行导入样式使用,例如: + +```js +// 可根据需要引入不同的主题 +import "highlight.js/styles/atom-one-dark.css"; +``` + diff --git a/docs/guide/grammar.mdx b/docs/guide/grammar.mdx new file mode 100644 index 0000000..7535eb6 --- /dev/null +++ b/docs/guide/grammar.mdx @@ -0,0 +1,158 @@ +# Markdown 语法 + +## 标题 + +```md +# 一级标题 + +## 二级标题 + +### 三级标题 + +#### 四级标题 + +##### 五级标题 + +###### 六级标题 +``` + +## 加粗、斜体、下划线、删除线 + +输入: + +```md +**加粗** + +_斜体_ + +--下划线-- + +~~删除线~~ +``` + +输出: + +**加粗**、_斜体_、下划线、~~删除线~~ + +## 引用 + +输入: + +```md +> 引用一段内容 +``` + +输出: + +> 引用一段内容 + +## 分割线 + +输入: + +```md +--- +``` + +输出: + +--- + +## 列表 + +输入: + +```md + +- 列表1 +- 列表2 +- 列表3 + + +1. 列表1 +2. 列表2 +3. 列表3 +``` + +输出: + +无序列表: + +- 列表1 +- 列表2 +- 列表3 + +有序列表: + +1. 列表1 +2. 列表2 +3. 列表3 + +## 内联代码 + +```md +`内联代码` +``` + +输出: + +`内联代码` + +## 代码块 + +输入: + +
+\`\`\`js
+console.log('代码块')
+\`\`\` +
+ +输出: + +```js +console.log('代码块') +``` + +## 链接 + +输入: + +```md +[链接文字](链接地址) +[链接文字](https://www.example.com) +``` + +输出: + +[链接文字](https://www.example.com) + +## 图片 + +输入: + +```md +![图片描述](图片地址) + +![图片描述](https://www.example.com/image.jpg) +``` + +输出: + + + +## 表格 + +输入: + +```md +| 表头1 | 表头2 | 表头3 | +| ------ | ------ | ------ | +| 内容1 | 内容2 | 内容3 | +``` + +输出: + +| 表头1 | 表头2 | 表头3 | +| ------ | ------ | ------ | +| 内容1 | 内容2 | 内容3 | diff --git a/docs/guide/index.md b/docs/guide/index.md deleted file mode 100644 index fd01991..0000000 --- a/docs/guide/index.md +++ /dev/null @@ -1,90 +0,0 @@ -项目采用 `monorepo` 架构,项目包含3个子项目 - -- `mini-markdown-ast-parser`:Markdown AST 解析器 -- `mini-markdown-editor`:Markdown 编辑器 -- `mini-markdown-material`:物料组件库 - -```bash [安装] -# markdown解析器 -pnpm add mini-markdown-ast-parser -# react markdown 编辑器 -pnpm add mini-markdown-editor -``` - - - -::: code-group - -```bash [安装] -# markdown解析器 -pnpm add mini-markdown-ast-parser -# react markdown 编辑器 -pnpm add mini-markdown-editor -``` - -```js [markdown解析器] -// esm -import { parseMarkdown, transformHtml } from '@mini-markdown/ast-parser' -// commonjs -const { parseMarkdown, transformHtml } = require('@mini-markdown/ast-parser') -// 样式导入 -import '@mini-markdown/ast-parser/style' - -// 解析 markdown 内容为 ast 对象 -const ast = parseMarkdown(code) -// 转换 ast 为 html 字符串 -const html = transformHtml(ast) -``` - -```tsx [markdown编辑器] -import { useState } from 'react' -import { Editor, Preview } from 'mini-markdown-editor' -import 'mini-markdown-editor/dist/style.css' - -export default function MarkdownEditor() { - const [markdown, setMarkdown] = useState('# Hello Mini Markdown\n\n这是一个简单的示例') - - return ( -
- {/* 编辑器区域 */} -
- -
- - {/* 预览区域 */} -
- -
-
- ) -} -``` - -::: - - \ No newline at end of file diff --git a/docs/guide/index.mdx b/docs/guide/index.mdx new file mode 100644 index 0000000..8d3f495 --- /dev/null +++ b/docs/guide/index.mdx @@ -0,0 +1 @@ +# 介绍 \ No newline at end of file diff --git a/docs/guide/shortcut-keys.mdx b/docs/guide/shortcut-keys.mdx new file mode 100644 index 0000000..e69de29 diff --git a/docs/guide/start.md b/docs/guide/start.mdx similarity index 31% rename from docs/guide/start.md rename to docs/guide/start.mdx index 2facb8c..395e0e2 100644 --- a/docs/guide/start.md +++ b/docs/guide/start.mdx @@ -1,26 +1,14 @@ +import { PackageManagerTabs } from '@theme'; + # 快速开始 ## 在线尝试 -可以直接在 [示例](../example) 上进行在线尝试。 +可以直接在 [在线尝试](../example) 上进行在线尝试。 ## 安装 -::: code-group - -```sh [npm] -npm install -D mini-markdown-editor -``` - -```sh [yarn] -yarn add -D mini-markdown-editor -``` - -```sh [pnpm] -pnpm add -D mini-markdown-editor -``` - -::: + ## 使用 @@ -30,10 +18,4 @@ import { Editor, Preview } from "mini-markdown-editor"; export default function App() { return ; } - -// 仅预览 -function PreviewPage() { - const [markdown, setMarkdown] = useState("# Hello Mini Markdown\n\n这是一个简单的示例"); - return ; -} ``` diff --git a/docs/index.md b/docs/index.md index 4f56025..b072229 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,5 @@ --- -layout: home +pageType: home hero: name: Mini Markdown Editor @@ -18,9 +18,7 @@ hero: features: - title: 支持React - icon: - dark: /react_dark.svg - light: /react_light.svg + icon: 🌍 details: React版的markdown编辑器 - title: 轻量级、高性能 icon: 🚀 @@ -29,22 +27,3 @@ features: icon: 📝 details: 快速上手,API简单易用 --- - - \ No newline at end of file diff --git a/docs/package.json b/docs/package.json index 2c204a2..ea83568 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,24 +1,18 @@ { "name": "docs", "version": "1.0.0", - "description": "", - "main": "index.js", "scripts": { - "dev": "vitepress dev", - "build": "vitepress build", - "preview": "vitepress preview" + "dev": "rspress dev", + "build": "rspress build", + "preview": "rspress preview" }, - "keywords": [], - "author": "", "license": "ISC", "devDependencies": { "react": "^18.3.1", "react-dom": "^18.3.1", - "vitepress": "^1.6.1", - "vitepress-demo-plugin": "^1.2.3" + "rspress": "^1.41.0" }, "dependencies": { - "@mini-markdown/editor": "workspace:^0.0.0", - "vitepress-plugin-group-icons": "^1.3.5" + "@mini-markdown/editor": "workspace:^0.0.0" } } \ No newline at end of file diff --git a/docs/postcss.config.js b/docs/postcss.config.js new file mode 100644 index 0000000..ee5f90b --- /dev/null +++ b/docs/postcss.config.js @@ -0,0 +1,5 @@ +module.exports = { + plugins: { + tailwindcss: {}, + }, +}; diff --git a/docs/public/gitee.svg b/docs/public/gitee.svg new file mode 100644 index 0000000..9ba12fd --- /dev/null +++ b/docs/public/gitee.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/react_dark.svg b/docs/public/react_dark.svg deleted file mode 100644 index 265777f..0000000 --- a/docs/public/react_dark.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - React-Logo-Filled (1) - - - - - - - - - \ No newline at end of file diff --git a/docs/rspress.config.ts b/docs/rspress.config.ts new file mode 100644 index 0000000..81a60ef --- /dev/null +++ b/docs/rspress.config.ts @@ -0,0 +1,45 @@ +import { defineConfig } from "rspress/config"; +import { sidebar } from "./sidebar"; + +export default defineConfig({ + root: "./", + title: "Mini Markdown Editor", + description: "一个基于 React 的 Markdown 编辑器", + icon: "/logo.svg", + logo: "/logo.svg", + logoText: "Mini Markdown Editor", + outDir: "dist", + themeConfig: { + nav: [ + { text: "指南", link: "/guide/", activeMatch: "/guide" }, + { text: "文档", link: "/docs/", activeMatch: "/docs" }, + { text: "在线尝试", link: "/example/", activeMatch: "/example" }, + { text: "关于我们", link: "/team/", activeMatch: "/team" }, + ], + sidebar, + socialLinks: [ + { + icon: "github", + mode: "link", + content: "https://github.com/xiaotianna/mini-markdown-editor", + }, + { + icon: { + svg: '', + }, + mode: "link", + content: "https://gitee.com/lin-yaozhen/mini-markdown-editor", + }, + ], + outlineTitle: "本页目录", + prevPageText: "上一页", + nextPageText: "下一页", + searchPlaceholderText: "搜索文档", + searchNoResultsText: "无法找到相关结果", + searchSuggestedQueryText: "请重新搜索", + enableScrollToTop: true, + footer: { + message: "2025 字节青训营「前端」", + }, + }, +}); diff --git a/docs/.vitepress/sidebar.ts b/docs/sidebar.ts similarity index 54% rename from docs/.vitepress/sidebar.ts rename to docs/sidebar.ts index f3578e2..c77f465 100644 --- a/docs/.vitepress/sidebar.ts +++ b/docs/sidebar.ts @@ -1,16 +1,24 @@ export const sidebar = { "/guide/": [ { - text: "简介", + text: "开始", items: [ { text: "介绍", link: "/guide/" }, { text: "快速开始", link: "/guide/start" }, + ], + }, + { + text: "编辑器", + items: [ { text: "API", link: "/guide/api" }, + { text: "自定义预览区", link: "/guide/custom-preview" }, + { text: "Makrdown语法", link: "/guide/grammar" }, + { text: "快捷键", link: "/guide/shortcut-keys" }, ], }, { text: "AST解析", - items: [], + items: [{ text: "使用", link: "/guide/ast-parser" }], }, ], "/docs/": [ diff --git a/docs/styles/index.css b/docs/styles/index.css new file mode 100644 index 0000000..5be59b4 --- /dev/null +++ b/docs/styles/index.css @@ -0,0 +1,3 @@ +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; \ No newline at end of file diff --git a/docs/tailwind.config.js b/docs/tailwind.config.js new file mode 100644 index 0000000..c255572 --- /dev/null +++ b/docs/tailwind.config.js @@ -0,0 +1,7 @@ +module.exports = { + content: ["*.{mdx,tsx}"], + theme: { + extend: {}, + }, + plugins: [], +}; diff --git a/docs/tsconfig.json b/docs/tsconfig.json new file mode 100644 index 0000000..df9ad96 --- /dev/null +++ b/docs/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "ES2020", + "lib": [ + "DOM", + "ES2020" + ], + "module": "ESNext", + "jsx": "react-jsx", + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "isolatedModules": true, + "resolveJsonModule": true, + "moduleResolution": "bundler", + "useDefineForClassFields": true, + "allowImportingTsExtensions": true, + }, + "include": [ + "docs", + "theme", + "rspress.config.ts" + ], + "mdx": { + "checkMdx": true + } +} \ No newline at end of file diff --git a/packages/mini-markdown-editor/src/components/Editor/index.tsx b/packages/mini-markdown-editor/src/components/Editor/index.tsx index 18aef9c..3e4a41e 100644 --- a/packages/mini-markdown-editor/src/components/Editor/index.tsx +++ b/packages/mini-markdown-editor/src/components/Editor/index.tsx @@ -14,7 +14,7 @@ const ScrollWrapper = styled.div<{ width: 100%; height: 100%; overflow: auto; - padding: 5px ${({ $lineNumbers }) => ($lineNumbers ? "0px" : "10px")}; + padding: ${({ $lineNumbers }) => ($lineNumbers ? "0px" : "5px 10px")}; display: flex; flex-direction: column; diff --git a/packages/mini-markdown-editor/src/types/global-config.ts b/packages/mini-markdown-editor/src/types/global-config.ts index 3341a22..d6ede95 100644 --- a/packages/mini-markdown-editor/src/types/global-config.ts +++ b/packages/mini-markdown-editor/src/types/global-config.ts @@ -44,7 +44,7 @@ export interface GlobalConfig { */ onDragUpload?: (file: File, callback: Callback) => void; /** - * 快捷键保存触发 + * 保存触发 * @type {(value: string, editorView: ViewUpdate) => void} */ onSave?: (value: string, editorView: ViewUpdate) => void; -- Gitee