diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index f62c47ef785..fc4c056f296 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -555,12 +555,17 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { // https://github.com/siyuan-note/siyuan/issues/5185 if (range.startOffset === 0 && range.startContainer.nodeType === 3) { const previousSibling = hasPreviousSibling(range.startContainer) as HTMLElement; - if (previousSibling && previousSibling.nodeType !== 3 && previousSibling.getAttribute("data-type").indexOf("inline-math") > -1) { + if (previousSibling && + previousSibling.nodeType !== 3 && + previousSibling.getAttribute("data-type")?.indexOf("inline-math") > -1 + ) { protyle.toolbar.showRender(protyle, previousSibling); return; } else if (!previousSibling && - range.startContainer.parentElement.previousSibling && range.startContainer.parentElement.previousSibling.isSameNode(range.startContainer.parentElement.previousElementSibling) && - range.startContainer.parentElement.previousElementSibling.getAttribute("data-type").indexOf("inline-math") > -1) { + range.startContainer.parentElement.previousSibling && + range.startContainer.parentElement.previousSibling.isSameNode(range.startContainer.parentElement.previousElementSibling) && + range.startContainer.parentElement.previousElementSibling.getAttribute("data-type")?.indexOf("inline-math") > -1 + ) { protyle.toolbar.showRender(protyle, range.startContainer.parentElement.previousElementSibling); return; }