@@ -7,6 +7,12 @@ import { Scope } from "parchment";
77import  {  ACTION_DISPATCHER  }  from  "../helpers" ; 
88import  {  SET_FULLSCREEN_ACTION  }  from  "../../store/store" ; 
99
10+ function  returnWithStopPropagation ( context : Context ) : boolean  { 
11+     context . event . stopPropagation ( ) ; 
12+     context . event . preventDefault ( ) ; 
13+     return  true ; 
14+ } 
15+ 
1016/** 
1117 * give custom indent handler to use our custom "indent-left" and "indent-right" formats (formats/indent.ts) 
1218 */ 
@@ -80,13 +86,36 @@ export function shiftEnterKeyKeyboardHandler(this: Keyboard, range: Range, conte
8086} 
8187
8288export  function  movePrevFocus ( this : Keyboard ,  range : Range ,  context : Context ) : any  { 
83-     if  ( context . format . table  ||  context . format . indent  ||  context . format . list  ||  context . format . blockquote )  { 
84-         context . event . stopPropagation ( ) ; 
85-         context . event . preventDefault ( ) ; 
86-         return  true ; 
89+     if  ( context . format . table )  { 
90+         return  returnWithStopPropagation ( context ) ; 
91+     }  else  if  ( context . collapsed )  { 
92+         if  ( context . format . indent  ||  context . format . list  ||  context . format . blockquote )  { 
93+             return  returnWithStopPropagation ( context ) ; 
94+         } 
8795    } 
8896
8997    gotoToolbarKeyboardHandler . call ( this ,  range ,  context ) ; 
98+     return  returnWithStopPropagation ( context ) ; 
99+ } 
100+ 
101+ // Copied from https://github.com/slab/quill/blob/539cbffd0a13b18e9c65eb84dd35e6596e403158/packages/quill/src/modules/keyboard.ts#L372 
102+ // with added stopPropagation and preventDefault 
103+ export  function  moveOutdent ( this : Keyboard ,  _range : Range ,  context : Context ) : any  { 
104+     if  ( context . collapsed  &&  context . offset  !==  0 )  { 
105+         return  returnWithStopPropagation ( context ) ; 
106+     } 
107+     this . quill . format ( "indent" ,  "-1" ,  Quill . sources . USER ) ; 
108+     return  ! returnWithStopPropagation ( context ) ; 
109+ } 
110+ 
111+ // Copied from https://github.com/slab/quill/blob/539cbffd0a13b18e9c65eb84dd35e6596e403158/packages/quill/src/modules/keyboard.ts#L372 
112+ // with added stopPropagation and preventDefault 
113+ export  function  moveIndent ( this : Keyboard ,  _range : Range ,  context : Context ) : any  { 
114+     if  ( context . collapsed  &&  context . offset  !==  0 )  { 
115+         return  returnWithStopPropagation ( context ) ; 
116+     } 
117+     this . quill . format ( "indent" ,  "+1" ,  Quill . sources . USER ) ; 
118+     return  ! returnWithStopPropagation ( context ) ; 
90119} 
91120
92121// focus to first toolbar button 
@@ -99,7 +128,8 @@ export function gotoToolbarKeyboardHandler(this: Keyboard, _range: Range, contex
99128    if  ( toolbar )  { 
100129        ( toolbar ?. querySelector ( ".ql-formats button" )  as  HTMLElement ) ?. focus ( ) ; 
101130    }  else  { 
102-         this . quill . blur ( ) ; 
131+         // "widget-rich-text form-control" 
132+         this . quill . container . parentElement ?. parentElement ?. parentElement ?. focus ( ) ; 
103133    } 
104134} 
105135
@@ -113,7 +143,8 @@ export function gotoStatusBarKeyboardHandler(this: Keyboard, _range: Range, cont
113143    if  ( statusBar )  { 
114144        ( statusBar  as  HTMLElement ) ?. focus ( ) ; 
115145    }  else  { 
116-         this . quill . blur ( ) ; 
146+         // "widget-rich-text form-control" 
147+         this . quill . container . parentElement ?. parentElement ?. parentElement ?. focus ( ) ; 
117148    } 
118149} 
119150
@@ -124,14 +155,16 @@ export function addIndentText(this: Keyboard, range: Range, context: Context): b
124155    if  ( context . format . table )  { 
125156        return  true ; 
126157    } 
127-     this . quill . history . cutoff ( ) ; 
128-     const  delta  =  new  Delta ( ) . retain ( range . index ) . delete ( range . length ) . insert ( "\t" ) ; 
129-     this . quill . updateContents ( delta ,  Quill . sources . USER ) ; 
130-     this . quill . history . cutoff ( ) ; 
131-     this . quill . setSelection ( range . index  +  1 ,  Quill . sources . SILENT ) ; 
132-     context . event . stopPropagation ( ) ; 
133-     context . event . preventDefault ( ) ; 
134-     return  false ; 
158+     if  ( context . collapsed  &&  context . offset  ===  0 )  { 
159+         return  moveIndent . call ( this ,  range ,  context ) ; 
160+     }  else  { 
161+         this . quill . history . cutoff ( ) ; 
162+         const  delta  =  new  Delta ( ) . retain ( range . index ) . delete ( range . length ) . insert ( "\t" ) ; 
163+         this . quill . updateContents ( delta ,  Quill . sources . USER ) ; 
164+         this . quill . history . cutoff ( ) ; 
165+         this . quill . setSelection ( range . index  +  1 ,  Quill . sources . SILENT ) ; 
166+         return  returnWithStopPropagation ( context ) ; 
167+     } 
135168} 
136169
137170/** 
0 commit comments