From: Adrian Greeve Date: Wed, 25 May 2016 07:12:26 +0000 (+0800) Subject: MDL-45427 mod_data: Inserting tags into templates. X-Git-Tag: v3.2.0-beta~1078^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=43c762ef1025aab39953f33f3650652f0c5a2fe9;ds=inline MDL-45427 mod_data: Inserting tags into templates. Allows tags to be inserted into the editor without having to touch Atto at all. --- diff --git a/mod/data/data.js b/mod/data/data.js index a733dbf6656..871de649b83 100644 --- a/mod/data/data.js +++ b/mod/data/data.js @@ -6,9 +6,13 @@ function insert_field_tags(selectlist) { var value = selectlist.options[selectlist.selectedIndex].value; var editorname = 'template'; if (typeof tinyMCE == 'undefined') { - var element = document.getElementsByName(editorname)[0]; - // For inserting when in normal textareas - insertAtCursor(element, value); + if (document.execCommand('insertText')) { + document.execCommand('insertText', false, value); + } else { + var element = document.getElementsByName(editorname)[0]; + // For inserting when in normal textareas + insertAtCursor(element, value); + } } else { tinyMCE.execInstanceCommand(editorname, 'mceInsertContent', false, value); }