Skip to content

Commit 5eb994e

Browse files
committed
🎨 Support cross-document undo #4866
Signed-off-by: Daniel <845765@qq.com>
1 parent 03e3f74 commit 5eb994e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

app/src/protyle/undo/globalUndo.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,21 @@ export const requestUndo = async (protyle: IProtyle) => {
165165

166166
if (peekMutatedRootIDs.length > 1) {
167167
const names = await resolveRootNames(peekMutatedRootIDs);
168+
// 确认期间拦截当前编辑器的键盘输入(遮罩只挡鼠标点击,不挡键盘冒泡)
169+
const blockInput = (e: Event) => {
170+
e.stopImmediatePropagation();
171+
e.preventDefault();
172+
};
173+
protyle.wysiwyg.element.addEventListener("keydown", blockInput, true);
174+
protyle.wysiwyg.element.addEventListener("beforeinput", blockInput, true);
168175
const confirmed = await new Promise<boolean>((resolve) => {
169176
confirmDialog(`⚠️ ${window.siyuan.languages.undo}`,
170177
`${window.siyuan.languages.undoCrossDocConfirm}<br>${names.join(" / ")}`,
171178
() => resolve(true),
172179
() => resolve(false));
173180
});
181+
protyle.wysiwyg.element.removeEventListener("keydown", blockInput, true);
182+
protyle.wysiwyg.element.removeEventListener("beforeinput", blockInput, true);
174183
if (!confirmed) {
175184
isUndoing = false; // 拒绝,复位锁,栈与镜像不动
176185
return;

0 commit comments

Comments
 (0)