How can I access and modify the content of the editor?

I am porting a plugin to Thunderbird 68 (Highlighter), that modifies the content of the HTML inside the email composer.

Where can I find a reference page to do that, please?

So far, I am trying just some sample code, but nothing happens when the function is called.

  var msg_compose_window = document.getElementById("msgcomposeWindow");
  var msg_type = msg_compose_window.getAttribute("msgtype");

  try {
      var editor_type = GetCurrentEditorType();
      if (! (editor_type == "html" || editor_type == "htmlmail")) return;

      var editor = GetCurrentEditor();
      editor.beginTransaction();

      var body = editor.outputToString('text/html', 2);
      body = body.replace("ipsum", "<b>ipsum</b>");
      editor.rebuildDocumentFromSource(body);

      editor.endTransaction();

  } catch (e) {
      console.log(e);
      return false;
  }

I am trying to find documentation on this page: https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Thunderbird_extensions/Building_a_Thunderbird_extension but no luck so far, a lot of broken links and out of date information.

Thanks,
André

This addon development forum is more active: https://thunderbird.topicbox.com/groups/addons

Thank you. I will try.

Thanks for working to update https://addons.thunderbird.net/en-US/thunderbird/addon/highlighter-222207/

Did you get the information you need? I didn’t find your followup posting at https://thunderbird.topicbox.com/groups/addons

Andre, did you get the information you need?

I set up a webextension experiment with the following code in implementation.js and it worked:
var { ExtensionCommon } = ChromeUtils.import(“resource://gre/modules/ExtensionCommon.jsm”);
var { Services } = ChromeUtils.import(“resource://gre/modules/Services.jsm”);

var myapi = class extends ExtensionCommon.ExtensionAPI {
  getAPI(context) {
    return {
      myapi: {
        async YourFunctionName() {
          let recentWindow = Services.wm.getMostRecentWindow("msgcompose");
          if (recentWindow) {
            try {
                  var editor_type = recentWindow.GetCurrentEditorType();
                  if (! (editor_type == "html" || editor_type == "htmlmail")) return;
                  var editor = recentWindow.GetCurrentEditor();
                  editor.beginTransaction();
                  var OldBody = editor.outputToString('text/html', 2);
                  var NewBody;
                  NewBody = OldBody.replace("ipsum", "<b>ipsum</b>"");
                  editor.rebuildDocumentFromSource(NewBody);
                  editor.endTransaction();
                 }
              catch (e) {
// I don't know why, but console.log(e); did not work, therefore I used recentWindow.alert(e); for testing
                  console.log(e);
                  return false;
              }
          }
        },
      },
    };
  }
};

(And I would also recommend the addon development forum: https://thunderbird.topicbox.com/groups/addons )