From 8d2e62184dd67b2caf71e7ad50a515f9d86b3ae2 Mon Sep 17 00:00:00 2001 From: Sean Chamberlain Date: Tue, 23 Nov 2021 17:06:58 +1030 Subject: [PATCH] Detect key events in code tag in domObserver --- src/domchange.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domchange.js b/src/domchange.js index fac9414e..b175dcc7 100644 --- a/src/domchange.js +++ b/src/domchange.js @@ -119,7 +119,7 @@ export function readDOMChange(view, from, to, typeOver, addedNodes) { !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) { change = {start: sel.from, endA: sel.to, endB: sel.to} } else if ((browser.ios && view.lastIOSEnter > Date.now() - 225 || browser.android) && - addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P") && + addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P" || n.nodeName == "CODE") && view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) { view.lastIOSEnter = 0 return @@ -164,7 +164,7 @@ export function readDOMChange(view, from, to, typeOver, addedNodes) { // If this looks like the effect of pressing Enter (or was recorded // as being an iOS enter press), just dispatch an Enter key instead. if (((browser.ios && view.lastIOSEnter > Date.now() - 225 && - (!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) || + (!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P" || n.nodeName == "CODE"))) || (!inlineChange && $from.pos < parse.doc.content.size && (nextSel = Selection.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) && nextSel.head == $to.pos)) &&