← All changes
|
assets/src/js/frontend/course-builder/builder-lesson/builder-edit-lesson.js
+33
-9
4.3.7
→
4.4.10
View file →
| @@ -284,8 +284,40 @@ | ||
| 284 | 284 | `.cb-section__lesson-edit ${ BuilderEditLesson.selectors.elPermalinkRoot }` |
| 285 | 285 | ); |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | + isDescriptionEditorInCodeMode() { | |
| 289 | + const editorId = BuilderEditLesson.selectors.idDescEditor; | |
| 290 | + const wrapper = | |
| 291 | + document.getElementById( `wp-${ editorId }-wrap` ) || | |
| 292 | + document.getElementById( `${ editorId }-wrap` ); | |
| 293 | + if ( wrapper?.classList.contains( 'html-active' ) ) { | |
| 294 | + return true; | |
| 295 | + } | |
| 296 | + | |
| 297 | + const editor = typeof tinymce !== 'undefined' ? tinymce.get( editorId ) : null; | |
| 298 | + | |
| 299 | + return !! ( editor?.isHidden && editor.isHidden() ); | |
| 300 | + } | |
| 301 | + | |
| 302 | + getDescriptionContentForUpdate() { | |
| 303 | + const editorId = BuilderEditLesson.selectors.idDescEditor; | |
| 304 | + const descEditor = document.getElementById( editorId ); | |
| 305 | + | |
| 306 | + if ( this.isDescriptionEditorInCodeMode() ) { | |
| 307 | + return descEditor ? descEditor.value : ''; | |
| 308 | + } | |
| 309 | + | |
| 310 | + if ( typeof tinymce !== 'undefined' ) { | |
| 311 | + const editor = tinymce.get( editorId ); | |
| 312 | + if ( editor ) { | |
| 313 | + return editor.getContent(); | |
| 314 | + } | |
| 315 | + } | |
| 316 | + | |
| 317 | + return descEditor ? descEditor.value : ''; | |
| 318 | + } | |
| 319 | + | |
| 288 | 320 | showPermalinkUnavailable( permalinkRoot, message = '' ) { |
| 289 | 321 | if ( ! permalinkRoot ) { |
| 290 | 322 | return; |
| 291 | 323 | } |
| @@ -331,17 +363,9 @@ | ||
| 331 | 363 | |
| 332 | 364 | const titleInput = document.getElementById( BuilderEditLesson.selectors.idTitle ); |
| 333 | 365 | data.lesson_title = titleInput ? titleInput.value : ''; |
| 334 | 366 | |
| 335 | - const descEditor = document.getElementById( BuilderEditLesson.selectors.idDescEditor ); | |
| 336 | - data.lesson_description = descEditor ? descEditor.value : ''; | |
| 337 | - | |
| 338 | - if ( typeof tinymce !== 'undefined' ) { | |
| 339 | - const editor = tinymce.get( BuilderEditLesson.selectors.idDescEditor ); | |
| 340 | - if ( editor ) { | |
| 341 | - data.lesson_description = editor.getContent(); | |
| 342 | - } | |
| 343 | - } | |
| 367 | + data.lesson_description = this.getDescriptionContentForUpdate(); | |
| 344 | 368 | |
| 345 | 369 | const permalinkInput = document.querySelector( |
| 346 | 370 | `input[name="lesson_permalink"], #lesson_permalink, ${ BuilderEditLesson.selectors.elPermalinkSlugInput }` |
| 347 | 371 | ); |