@@ -138,6 +138,8 @@ const Math = {
138
138
const obj = this . collection [ id ]
139
139
if ( obj . isOpen ) return
140
140
141
+ // obj.container.contentEditable = false
142
+
141
143
// Open the element
142
144
// TODO: Refactor this
143
145
if ( obj . isOpen === null ) {
@@ -147,10 +149,6 @@ const Math = {
147
149
obj . container . removeAttribute ( "style" )
148
150
obj . image . removeAttribute ( "style" )
149
151
obj . isOpen = true
150
-
151
- // MathQuill weirdness
152
- obj . dynamicInterface . focus ( )
153
- obj . dynamicInterface . reflow ( )
154
152
} else {
155
153
obj . container . removeAttribute ( "style" )
156
154
obj . image . removeAttribute ( "style" )
@@ -169,22 +167,23 @@ const Math = {
169
167
obj . flags . push ( "ignoreInputDynamic" )
170
168
obj . dynamicInterface . latex ( obj . data )
171
169
obj . latexInterface . latex ( obj . data )
172
-
173
- // MathQuill weirdness
174
- obj . dynamicInterface . focus ( )
175
- obj . dynamicInterface . reflow ( )
176
170
} else {
177
171
throw new Error ( "Cache miss" )
178
172
}
179
173
}
180
174
181
- obj . container . contentEditable = false
182
-
183
175
if ( obj . flags . includes ( "disableInputDynamic" ) ) obj . labels [ 0 ] . click ( ) // Forces the raw latex view to open
184
176
185
- // Todo: This should not live in here. This component is dynamic.
186
- if ( window . setLatexCommandsVisibility ) window . setLatexCommandsVisibility ( true )
187
- this . events . dispatchEvent ( new CustomEvent ( "focus" , { detail : obj } ) )
177
+ // NOTE: Mathquill requires a single frame (at least) to get ready
178
+ requestAnimationFrame ( ( ) => {
179
+ // MathQuill weirdness
180
+ obj . dynamicInterface . focus ( )
181
+ obj . dynamicInterface . reflow ( )
182
+
183
+ // Todo: This should not live in here. This component is dynamic.
184
+ if ( window . setLatexCommandsVisibility ) window . setLatexCommandsVisibility ( true )
185
+ this . events . dispatchEvent ( new CustomEvent ( "focus" , { detail : obj } ) )
186
+ } )
188
187
} ,
189
188
190
189
/**
@@ -333,7 +332,7 @@ const Math = {
333
332
} )
334
333
}
335
334
336
- obj . container . contentEditable = true
335
+ // obj.container.contentEditable = true
337
336
this . events . dispatchEvent ( new CustomEvent ( "blur" , { detail : obj } ) )
338
337
obj . container . setAttribute ( "math" , btoa ( obj . data ) )
339
338
} ,
0 commit comments