From dbe3d6c8f1dd67072ad47312181954759480c6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9B?= <1501034130@qq.com> Date: Tue, 22 Oct 2024 22:19:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E4=B8=8B=E5=88=92?= =?UTF-8?q?=E7=BA=BF=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/editor/keymap.ts | 1 + src/components/editor/schema.ts | 6 ++++++ src/styles/Icons.css | 4 ++++ src/views/NoteView.vue | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/src/components/editor/keymap.ts b/src/components/editor/keymap.ts index 74da91e..7c696e0 100644 --- a/src/components/editor/keymap.ts +++ b/src/components/editor/keymap.ts @@ -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 }), diff --git a/src/components/editor/schema.ts b/src/components/editor/schema.ts index 65feece..7d13d45 100644 --- a/src/components/editor/schema.ts +++ b/src/components/editor/schema.ts @@ -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() { diff --git a/src/styles/Icons.css b/src/styles/Icons.css index e80c877..7a06cf5 100644 --- a/src/styles/Icons.css +++ b/src/styles/Icons.css @@ -46,6 +46,10 @@ content: "\e23f"; } +.i-underline::before { + content: "\e249"; +} + .i-strikethrough::before { content: "\e257"; } diff --git a/src/views/NoteView.vue b/src/views/NoteView.vue index 78e1f10..5964e66 100644 --- a/src/views/NoteView.vue +++ b/src/views/NoteView.vue @@ -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"),