File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export default function Document({
104
104
instance : window . internal . ui . activeFilesystemInstance ,
105
105
id : window . internal . ui . activeLocation ,
106
106
write : {
107
- name : event . target . innerText ,
107
+ name : event . target . innerText . trim ( ) ,
108
108
type : 0
109
109
}
110
110
}
Original file line number Diff line number Diff line change @@ -251,7 +251,22 @@ class Editor {
251
251
event . preventDefault ( )
252
252
if ( this . activeMathElement !== null ) return // No math inside math
253
253
const mathElement = Math . create ( )
254
- Utils . insertNodeAt ( Utils . getCaretPosition ( ) , mathElement . container )
254
+
255
+ // If we are inside a math element, insert the new math after it
256
+ const selection = document . getSelection ( )
257
+ if ( selection . anchorNode . nodeName . toLowerCase ( ) === "math" ) {
258
+ // Should only occur when math is only element in line
259
+ // So this is OK
260
+ this . activeLine . appendChild ( mathElement . container )
261
+
262
+ // Check for BR elements inside activeLine and remove them
263
+ // They appear between elements and we don't want them
264
+ for ( const element of this . activeLine . childNodes ) {
265
+ if ( element . nodeName . toLowerCase ( ) === "br" ) element . remove ( )
266
+ }
267
+ } else {
268
+ Utils . insertNodeAt ( Utils . getCaretPosition ( ) , mathElement . container )
269
+ }
255
270
Math . open ( mathElement . id )
256
271
return
257
272
}
You can’t perform that action at this time.
0 commit comments