File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
src/packages/frontend/editors/slate/keyboard Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -39,11 +39,22 @@ const keyHandlers: { [x: string]: KeyHandler } = {};
39
39
40
40
export function register (
41
41
key : Partial < Key > | Partial < Key > [ ] ,
42
- handler : KeyHandler
42
+ handler : KeyHandler ,
43
43
) : void {
44
+ const handlerNoThrow = ( opts ) => {
45
+ try {
46
+ return handler ( opts ) ;
47
+ } catch ( err ) {
48
+ // making this a warning -- there's a number of situations where the
49
+ // it's best to just not do anything special, rather than crash cocalc.
50
+ console . log ( "slate key handler throw " , key , err ) ;
51
+ return false ;
52
+ }
53
+ } ;
54
+
44
55
if ( key [ 0 ] != null ) {
45
56
for ( const k of key as Partial < Key > [ ] ) {
46
- register ( k , handler ) ;
57
+ register ( k , handlerNoThrow ) ;
47
58
}
48
59
return ;
49
60
}
@@ -53,7 +64,7 @@ export function register(
53
64
// making this a warning to support hot module reloading.
54
65
console . warn ( `WARNING: there is already a handler registered for ${ s } ` ) ;
55
66
}
56
- keyHandlers [ s ] = handler ;
67
+ keyHandlers [ s ] = handlerNoThrow ;
57
68
}
58
69
59
70
export function getHandler ( event ) : KeyHandler | undefined {
You can’t perform that action at this time.
0 commit comments