Skip to content

Commit

Permalink
编辑器下划线格式
Browse files Browse the repository at this point in the history
  • Loading branch information
fgt1t5y committed Oct 22, 2024
1 parent a2ba359 commit dbe3d6c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/editor/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const extraKeymap = {
"Mod-y": redo,
"Mod-b": toggleMark(schema.marks.bold),
"Mod-i": toggleMark(schema.marks.italic),
"Mod-u": toggleMark(schema.marks.underline),
"Mod-`": toggleMark(schema.marks.code),
"Mod-1": setBlockType(schema.nodes.heading, { level: 1 }),
"Mod-2": setBlockType(schema.nodes.heading, { level: 2 }),
Expand Down
6 changes: 6 additions & 0 deletions src/components/editor/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ export const schema = new Schema({
return ["i", 0];
},
},
underline: {
parseDOM: [{ tag: "u" }],
toDOM() {
return ["u", 0];
},
},
del: {
parseDOM: [{ tag: "del" }],
toDOM() {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/Icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
content: "\e23f";
}

.i-underline::before {
content: "\e249";
}

.i-strikethrough::before {
content: "\e257";
}
Expand Down
6 changes: 6 additions & 0 deletions src/views/NoteView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ const editorTools = [
active: () => editor.value!.isMarkActive("italic"),
enable: () => true,
},
{
icon: "i i-m i-underline",
command: () => editor.value!.toggleMark("underline"),
active: () => editor.value!.isMarkActive("underline"),
enable: () => true,
},
{
icon: "i i-m i-strikethrough",
command: () => editor.value!.toggleMark("del"),
Expand Down

0 comments on commit dbe3d6c

Please sign in to comment.