Merge branch 'wip-MDL-45427-master' of git://github.com/abgreeve/moodle
authorDavid Monllao <davidm@moodle.com>
Mon, 30 May 2016 02:19:24 +0000 (10:19 +0800)
committerDavid Monllao <davidm@moodle.com>
Mon, 30 May 2016 02:19:24 +0000 (10:19 +0800)
mod/data/data.js

index a733dbf..871de64 100644 (file)
@@ -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);
     }