mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Change nodeIsInline logic to be more typesafe
This commit is contained in:
parent
feddf96f2a
commit
9b5d915983
1 changed files with 2 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue