From 8e8b695cbc43c09380f1d40135583298e334ac8d Mon Sep 17 00:00:00 2001 From: CorreyL Date: Sun, 21 Jan 2024 10:38:12 -0800 Subject: [PATCH] Add a keyboard shortcut for adding a hyperlink Use the conventional Ctrl+K keyboard shortcut for adding a hyperlink --- libs/ui/src/components/rich-input.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/ui/src/components/rich-input.tsx b/libs/ui/src/components/rich-input.tsx index badb74bf..a6873830 100644 --- a/libs/ui/src/components/rich-input.tsx +++ b/libs/ui/src/components/rich-input.tsx @@ -444,7 +444,16 @@ export const RichInput = forwardRef( Image, Underline, Highlight, - Link.configure({ openOnClick: false }), + Link.extend({ + addKeyboardShortcuts() { + return { + "Mod-k": () => { + setLinkGlobal(this.editor as Editor); + return true; + }, + }; + }, + }).configure({ openOnClick: false }), TextAlign.configure({ types: ["heading", "paragraph"] }), ], editorProps: {