code: function (txt) {
          var me = this;
  
          var wwg_mode = false;
  
          var ed = tinymce.get(me.getInputId());
  
          if (me.wysiwygIntialized) {
              if (ed && !ed.isHidden()) {
                  wwg_mode = true;
              }
          }
  
          var ctrl = document.getElementById(me.getInputId());
  
          if (wwg_mode) {
              ed.focus();
              ed.execCommand('mceInsertContent', 0, txt);
          }
          else if (ctrl) {
              ctrl.focus();
  
              var start = ctrl.selectionStart + txt.length;
  
              ctrl.value = ctrl.value.slice(0, ctrl.selectionStart) + txt + ctrl.value.slice(ctrl.selectionEnd);
  
              ctrl.setSelectionRange(start, start);
          }
      }
docs: restoreCurrentSelection -----------------------------------------------------------------