code: function replaceMacroText (ctx, targetElement, path, offset, macros, text) {
              resetSelection(ctx, targetElement, path, offset);
  
              var macroMatchInfo = getMacroMatch(ctx, macros);
  
              if (macroMatchInfo.macroHasTrailingSpace) {
                  macroMatchInfo.macroText = macroMatchInfo.macroText + '\xA0';
                  text = text + '\xA0';
              }
  
              if (macroMatchInfo !== undefined) {
                  var element = getDocument(ctx).activeElement;
                  if (selectedElementIsTextAreaOrInput(ctx)) {
                      var startPos = macroMatchInfo.macroPosition;
                      var endPos = macroMatchInfo.macroPosition + macroMatchInfo.macroText.length;
                      element.value = element.value.substring(0, startPos) + text +
                          element.value.substring(endPos, element.value.length);
                      element.selectionStart = startPos + text.length;
                      element.selectionEnd = startPos + text.length;
                  } else {
                      pasteHtml(ctx, text, macroMatchInfo.macroPosition,
                              macroMatchInfo.macroPosition + macroMatchInfo.macroText.length);
                  }
              }
          }
docs: public