I can't get a basic tinymce call to work in browserify, even though it works perfectly if I just load tinymce from a CDN. Here's a minimal example of what I'm trying to do.
// main.js
var tinymceConverter = require('./modules/tinymce-converter');
document.addEventListener('DOMContentLoaded', function () {
tinymceConverter.init();
}
// tinymce-converter.js
'use strict';
var tinymce = require('tinymce/tinymce');
module.exports = {
init: function () {
tinymce.init({
// some params
});
}
};
However, I get the Uncaught TypeError: tinymce.init is not a function
error from the js console.
I have tried various combinations of other require
calls, some in combination with jQuery, which is used a lot in this project. (Hence a solution with jQuery would be welcome, although my first priority is to get it working at all.) Am I missing something obvious?
I got around it by adding setup attribute, then the console warned that I didn't have some plugins code and image, once I added those it stopped giving console errors and I was able to take out the setup attribute.
tinymce.init({
selector: '#tiny',
plugins: ['paste', 'link', 'code', 'image'],
setup: function(ed) {
ed.on("init", function (ed) {
alert(7);
})
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With