From 43c762ef1025aab39953f33f3650652f0c5a2fe9 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Wed, 25 May 2016 15:12:26 +0800 Subject: [PATCH] MDL-45427 mod_data: Inserting tags into templates. Allows tags to be inserted into the editor without having to touch Atto at all. --- mod/data/data.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); }