code: function replaceTriggerText (ctx, targetElement, path, offset, triggerCharSet, 
                  text, requireLeadingSpace, hasTrailingSpace) {
              resetSelection(ctx, targetElement, path, offset);
  
              var mentionInfo = getTriggerInfo(ctx, triggerCharSet, requireLeadingSpace, true, hasTrailingSpace);
  
              if (mentionInfo !== undefined) {
                  if (selectedElementIsTextAreaOrInput()) {
                      var myField = getDocument(ctx).activeElement;
                      text = text + ' ';
                      var startPos = mentionInfo.mentionPosition;
                      var endPos = mentionInfo.mentionPosition + mentionInfo.mentionText.length + 1;
                      myField.value = myField.value.substring(0, startPos) + text +
                          myField.value.substring(endPos, myField.value.length);
                      myField.selectionStart = startPos + text.length;
                      myField.selectionEnd = startPos + text.length;
                  } else {
                      // add a space to the end of the pasted text
                      text = text + '\xA0';
                      pasteHtml(ctx, text, mentionInfo.mentionPosition,
                              mentionInfo.mentionPosition + mentionInfo.mentionText.length + 1);
                  }
              }
          }
docs: public