From 2c2dce16fd0ca111913d68d6c12d47fb566bde17 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 23 Jun 2022 11:22:36 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/5270 --- app/src/protyle/toolbar/index.ts | 5 ++--- app/src/protyle/wysiwyg/input.ts | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 0d0f8fec2..6efce2cd1 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -891,9 +891,8 @@ export class Toolbar { focusSideBlock(renderElement); } } else if (event.key === "Tab") { - const start = textElement.selectionStart; - textElement.value = textElement.value.substring(0, start) + "\t" + textElement.value.substring(textElement.selectionEnd); - textElement.selectionStart = textElement.selectionEnd = start + 1; + // https://github.com/siyuan-note/siyuan/issues/5270 + document.execCommand("insertText", false, "\t"); event.preventDefault(); } }); diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts index 7819b6e83..7b8c11201 100644 --- a/app/src/protyle/wysiwyg/input.ts +++ b/app/src/protyle/wysiwyg/input.ts @@ -181,6 +181,8 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: protyle.hint.render(protyle); } hideElements(["gutter"], protyle); + // 在数学公式输入框中撤销到最后一步,再继续撤销会撤销编辑器正文内容,从而出发 input 事件 + protyle.toolbar.subElement.classList.add("fn__none"); updateInput(html, protyle, id, type, todoOldHTML); };