File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
src/packages/frontend/editors/slate Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ OS doesn't take. On MacOS that includes option+space for now.
19
19
TODO: instead, anytime autoformat happens, there could be an indicator about it in the
20
20
toolbar, with a button to undo it (leaving the space). This would be general for
21
21
return as well.
22
+
23
+ IMPORTANT: we also explicitly do this same insertText action in
24
+ frontend/editors/slate/slate-react/components/editable.tsx
25
+ to handle virtual keyboards. See https://github.com/sagemathinc/cocalc/issues/8536
22
26
*/
23
27
24
28
import { toggleCheckbox } from "../elements/checkbox/editable" ;
Original file line number Diff line number Diff line change @@ -273,6 +273,9 @@ export const Editable: React.FC<EditableProps> = (props: EditableProps) => {
273
273
getTargetRanges ( ) : DOMStaticRange [ ] ;
274
274
inputType : string ;
275
275
isComposing : boolean ;
276
+ ctrlKey ?: boolean ;
277
+ altKey ?: boolean ;
278
+ metaKey ?: boolean ;
276
279
} ,
277
280
) => {
278
281
if (
@@ -295,6 +298,16 @@ export const Editable: React.FC<EditableProps> = (props: EditableProps) => {
295
298
296
299
event . preventDefault ( ) ;
297
300
301
+ if (
302
+ type == "insertText" &&
303
+ ! event . isComposing &&
304
+ event . data == " " &&
305
+ ! ( event . ctrlKey || event . altKey || event . metaKey )
306
+ ) {
307
+ editor . insertText ( " " , { } ) ;
308
+ return ;
309
+ }
310
+
298
311
// COMPAT: For the deleting forward/backward input types we don't want
299
312
// to change the selection because it is the range that will be deleted,
300
313
// and those commands determine that for themselves.
@@ -694,6 +707,7 @@ export const Editable: React.FC<EditableProps> = (props: EditableProps) => {
694
707
}
695
708
}
696
709
}
710
+ 1 ;
697
711
}
698
712
} ,
699
713
[ readOnly , attributes . onCut ] ,
You can’t perform that action at this time.
0 commit comments