From 58485855aad2b99a6a14303bcf9ee4645baf3f1c Mon Sep 17 00:00:00 2001 From: castroCrea Date: Wed, 4 Aug 2021 19:11:54 +0200 Subject: [PATCH] Handle inputRules on Enter I'm creating an inputRule for links `const inputRegexExact = /(https?:\/\/[\w\d./?=#]+)[\s\n]$/;` that will create my link at the end of a line when the user hit enter --- src/inputrules.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/inputrules.js b/src/inputrules.js index 299ce0a..4cbd135 100644 --- a/src/inputrules.js +++ b/src/inputrules.js @@ -71,6 +71,12 @@ export function inputRules({rules}) { if ($cursor) run(view, $cursor.pos, $cursor.pos, "", rules, plugin) }) } + }, + handleKeyDown(view, event) { + if (event.key !== "Enter") return false; + let {$cursor} = view.state.selection + if ($cursor) return run(view, $cursor.pos, $cursor.pos, "\n", rules, plugin) + return false; } },