Skip to content

Commit

Permalink
feat: add markdown gfm extension support (#8)
Browse files Browse the repository at this point in the history
#### What type of PR is this?

/kind feature

#### What this PR does / why we need it:

为 markdown 编辑块增加 GFM 回显支持。

#### How to test it?

使用如下语法:

```
- [x] Write the press release
- [ ] Update the website
- [ ] Contact the media
```

保存之后刷新,查看任务列表是否还存在。

#### Which issue(s) this PR fixes:

Fixes #6 

#### Does this PR introduce a user-facing change?
```release-note
为 markdown 编辑块增加 GFM 回显支持
```
  • Loading branch information
LIlGG authored Jan 2, 2024
1 parent 126ced9 commit be5c26d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@lezer/highlight": "1.1.6",
"marked": "^9.1.2",
"turndown": "^7.1.2",
"turndown-plugin-gfm": "^1.0.2",
"vue": "^3.3.4"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions console/src/editor/markdown-edited.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Fragment } from "@tiptap/pm/model";
import { markdown } from "@codemirror/lang-markdown";
import { marked } from "marked";
import TurndownService from "turndown";
import { gfm } from "turndown-plugin-gfm";
import { ToolboxItem } from "@halo-dev/richtext-editor";
import type { EditorState } from "@tiptap/pm/state";
import MdiPencilOutline from "~icons/mdi/pencil-outline";
Expand All @@ -19,6 +20,7 @@ const turndownService = new TurndownService({
bulletListMarker: "-",
codeBlockStyle: "fenced",
});
turndownService.use(gfm);

declare module "@tiptap/core" {
interface Commands<ReturnType> {
Expand Down

0 comments on commit be5c26d

Please sign in to comment.