MDL-77140 mod_lti: fix content item return for new TinyMCE versions

This commit is contained in:
Jake Dallimore 2023-02-10 09:47:29 +08:00
parent 0780e87f06
commit 7e6f706717
3 changed files with 9 additions and 3 deletions

View File

@ -6,6 +6,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define("mod_lti/form-field",["jquery"],(function($){var FormField=function(name,type,resetIfUndefined,defaultValue){this.name=name,this.id="id_"+this.name,this.selector="#"+this.id,this.type=type,this.resetIfUndefined=resetIfUndefined,this.defaultValue=defaultValue};return FormField.TYPES={TEXT:1,SELECT:2,CHECKBOX:3,EDITOR:4},FormField.prototype.setFieldValue=function(value){if(null===value){if(!this.resetIfUndefined)return;value=this.defaultValue}switch(this.type){case FormField.TYPES.CHECKBOX:value?$(this.selector).prop("checked",!0):$(this.selector).prop("checked",!1);break;case FormField.TYPES.EDITOR:if(void 0!==value.text){var attoEditor=$(this.selector+"editable");attoEditor.length?attoEditor.html(value.text):"undefined"!=typeof tinyMCE&&tinyMCE.execInstanceCommand(this.id,"mceInsertContent",!1,value.text),$(this.selector).val(value.text)}break;default:$(this.selector).val(value)}},FormField}));
define("mod_lti/form-field",["jquery"],(function($){var FormField=function(name,type,resetIfUndefined,defaultValue){this.name=name,this.id="id_"+this.name,this.selector="#"+this.id,this.type=type,this.resetIfUndefined=resetIfUndefined,this.defaultValue=defaultValue};return FormField.TYPES={TEXT:1,SELECT:2,CHECKBOX:3,EDITOR:4},FormField.prototype.setFieldValue=function(value){if(null===value){if(!this.resetIfUndefined)return;value=this.defaultValue}switch(this.type){case FormField.TYPES.CHECKBOX:value?$(this.selector).prop("checked",!0):$(this.selector).prop("checked",!1);break;case FormField.TYPES.EDITOR:if(void 0!==value.text){var attoEditor=$(this.selector+"editable");attoEditor.length?attoEditor.html(value.text):"undefined"!=typeof tinyMCE&&("3"==tinyMCE.majorVersion?tinyMCE.execInstanceCommand(this.id,"mceInsertContent",!1,value.text):tinyMCE.get(this.id).setContent(value.text)),$(this.selector).val(value.text)}break;default:$(this.selector).val(value)}},FormField}));
//# sourceMappingURL=form-field.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -87,7 +87,13 @@ define(['jquery'],
attoEditor.html(value.text);
} else if (typeof tinyMCE !== 'undefined') {
// If the editor is not Atto, try to fallback to TinyMCE.
tinyMCE.execInstanceCommand(this.id, 'mceInsertContent', false, value.text);
if (tinyMCE.majorVersion == "3") {
// Tiny 3.
tinyMCE.execInstanceCommand(this.id, 'mceInsertContent', false, value.text);
} else {
// Tiny 4+.
tinyMCE.get(this.id).setContent(value.text);
}
}
// Set text to actual editor text area.