| @@ -221,37 +221,13 @@ | ||
| 221 | 221 | } ); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | reInitTinymce( id ) { |
| 225 | - if ( ! window.tinymce || ! id ) { | |
| 226 | - return; | |
| 227 | - } | |
| 228 | - | |
| 229 | - const elTextarea = document.getElementById( id ); | |
| 230 | - if ( ! elTextarea ) { | |
| 231 | - return; | |
| 232 | - } | |
| 233 | - | |
| 234 | - this.reInitQuicktags( id ); | |
| 235 | - const editor = window.tinymce.get( id ); | |
| 236 | - const editorContainer = editor?.getContainer?.(); | |
| 237 | - const isEditorAttached = editor && ( | |
| 238 | - editor.targetElm === elTextarea || | |
| 239 | - editor.getElement?.() === elTextarea || | |
| 240 | - editorContainer?.contains( elTextarea ) | |
| 241 | - ); | |
| 242 | - | |
| 243 | - if ( isEditorAttached ) { | |
| 244 | - this.setDefaultEditorTab( id ); | |
| 245 | - return; | |
| 246 | - } | |
| 247 | - | |
| 248 | 225 | window.tinymce.execCommand( 'mceRemoveEditor', true, id ); |
| 249 | 226 | window.tinymce.execCommand( 'mceAddEditor', true, id ); |
| 250 | - this.setDefaultEditorTab( id ); | |
| 251 | 227 | } |
| 252 | 228 | |
| 253 | - reInitQuicktags( id ) { | |
| 229 | + reInitQuickTags( id ) { | |
| 254 | 230 | const toolbar = document.getElementById( `qt_${ id }_toolbar` ); |
| 255 | 231 | if ( ! toolbar || toolbar.children.length || ! window.quicktags ) { |
| 256 | 232 | return; |
| 257 | 233 | } |
| @@ -271,8 +247,13 @@ | ||
| 271 | 247 | } |
| 272 | 248 | |
| 273 | 249 | if ( wrapEditor.classList.contains( 'html-active' ) && window.switchEditors?.go ) { |
| 274 | 250 | window.switchEditors.go( id, 'tmce' ); |
| 251 | + | |
| 252 | + const elTextarea = document.getElementById( id ); | |
| 253 | + if ( elTextarea ) { | |
| 254 | + elTextarea.style.visibility = ''; | |
| 255 | + } | |
| 275 | 256 | } |
| 276 | 257 | |
| 277 | 258 | wrapEditor.classList.add( 'tmce-active' ); |
| 278 | 259 | wrapEditor.classList.remove( 'html-active' ); |
| @@ -295,12 +276,9 @@ | ||
| 295 | 276 | if ( id === 'content' ) { |
| 296 | 277 | return; |
| 297 | 278 | } |
| 298 | 279 | |
| 299 | - this.setDefaultEditorTab( id ); | |
| 300 | - | |
| 301 | 280 | const elTextarea = document.getElementById( id ); |
| 302 | - | |
| 303 | 281 | if ( ! elTextarea ) { |
| 304 | 282 | return; |
| 305 | 283 | } |
| 306 | 284 | |
| @@ -324,8 +302,11 @@ | ||
| 324 | 302 | editor.settings.convert_urls = true; |
| 325 | 303 | editor.settings.document_base_url = lpData.site_url; |
| 326 | 304 | // End config use absolute url |
| 327 | 305 | |
| 306 | + // Add quick tags | |
| 307 | + this.reInitQuickTags( id ); | |
| 308 | + | |
| 328 | 309 | // Events focus in TinyMCE editor |
| 329 | 310 | editor.on( 'change keyup', ( e ) => { |
| 330 | 311 | // Auto save if it has class lp-auto-save |
| 331 | 312 | elTextarea.value = editor.getContent(); |
| @@ -348,9 +329,12 @@ | ||
| 348 | 329 | .${ EditQuestion.selectors.elQuestionFibInput } { |
| 349 | 330 | border: 1px dashed rebeccapurple; |
| 350 | 331 | padding: 5px; |
| 351 | 332 | } |
| 352 | - ` ); | |
| 333 | + ` ); | |
| 334 | + | |
| 335 | + // Set default tab visual | |
| 336 | + this.setDefaultEditorTab( id ); | |
| 353 | 337 | } ); |
| 354 | 338 | editor.on( 'setcontent', ( e ) => { |
| 355 | 339 | const uniquid = this.randomString(); |
| 356 | 340 | const elementg = editor.dom.select( |
| @@ -371,10 +355,10 @@ | ||
| 371 | 355 | if ( |
| 372 | 356 | fibSelection |
| 373 | 357 | .getNode() |
| 374 | 358 | .classList.contains( |
| 375 | - `${ EditQuestion.selectors.elQuestionFibInput }` | |
| 376 | - ) | |
| 359 | + `${ EditQuestion.selectors.elQuestionFibInput }` | |
| 360 | + ) | |
| 377 | 361 | ) { |
| 378 | 362 | const blankId = fibSelection.getNode().dataset.id; |
| 379 | 363 | const textBlank = fibSelection.getNode().textContent.trim(); |
| 380 | 364 | if ( textBlank.length === 0 ) { |
| @@ -997,9 +981,9 @@ | ||
| 997 | 981 | elAnswersConfig.dataset.answers = JSON.stringify( dataAnswers ); |
| 998 | 982 | } |
| 999 | 983 | |
| 1000 | 984 | /***** Fill in the blank question type *****/ |
| 1001 | - // For FIB question type | |
| 985 | + // For FIB question type | |
| 1002 | 986 | fibInsertBlank = ( args ) => { |
| 1003 | 987 | const { e, target } = args; |
| 1004 | 988 | const elBtnFibInsertBlank = target.closest( |
| 1005 | 989 | EditQuestion.selectors.elBtnFibInsertBlank |