File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments