Question

I am trying to create an addon that turns all textareas on certain pages into WYSIWYG HTML editors. I tried using PageMod by calling the NicEdit library and then running a content script with the code to turn all textareas into NicEdit editors. Here is the code I am trying to use:

main.js:

// Import the APIs
var pageMod = require("page-mod");
var self = require("self");

// Create a page mod
// It will run a script whenever a URL is loaded
pageMod.PageMod({
  include: "*",
  contentScriptFile: [self.data.url("nicEdit-latest.js"),
                      self.data.url("pagedit.js")]
});

pagedit.js

bkLib.onDomLoaded(nicEditors.allTextAreas);

And then NicEdit-latest.js is just the NicEdit lirbrary.

I saved and installed the addon and tried to load W3Schools' demo on textareas, but the textarea still looked like a normal textarea.

Was it helpful?

Solution

OK, I figured it out. The content scripts were firing at the wrong time. I fixed it by adding

     contentScriptWhen: 'start',

between the include and the ContentScriptFile.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top