From 9b5d91598365ed4702b33f6fbc9a40b4e2a5a207 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Tue, 26 Jan 2021 23:49:48 +0100 Subject: [PATCH] Change nodeIsInline logic to be more typesafe --- qt/aqt/data/web/js/editor.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/qt/aqt/data/web/js/editor.ts b/qt/aqt/data/web/js/editor.ts index e906bc4f6..0fdc20aea 100644 --- a/qt/aqt/data/web/js/editor.ts +++ b/qt/aqt/data/web/js/editor.ts @@ -176,19 +176,14 @@ const INLINE_TAGS = [ ]; function nodeIsInline(node: Node): boolean { - return ( - nodeIsText(node) || - INLINE_TAGS.includes((node as Element).tagName) - ); + return !nodeIsElement(node) || INLINE_TAGS.includes(node.tagName); } function inListItem(): boolean { const anchor = window.getSelection().anchorNode; - let n = nodeIsElement(anchor) ? anchor : anchor.parentElement; - let inList = false; - + let n = nodeIsElement(anchor) ? anchor : anchor.parentElement; while (n) { inList = inList || window.getComputedStyle(n).display == "list-item"; n = n.parentElement;