angular-ui / ui-tinymce

AngularUI wrapper for TinyMCE
MIT License
488 stars 371 forks source link

using ui-tinymce with lazy loaded tynyMCE npm module #359

Open SiriusED opened 6 years ago

SiriusED commented 6 years ago

Hi, Im trying to use ui-tinymce with lazy loaded the tynyMCE npm module via webpack like:

// Main module
require('angular-ui-tinymce');

angular.module('pages', [
    'ui.tinymce'
]);

// And then in my directive for text edit I load the tinymce
constructor () {
    // Import TinyMCE
    require.ensure([], function(require) {
        require('tinymce/tinymce.min.js');

        // List of plugins you want to use in TinyMCE
        require('tinymce/plugins/advlist');
        require('tinymce/plugins/anchor');

        // TinyMCE theme
        require('tinymce/themes/modern');
    }, 'tinymce_bundle');
}

Html template of my directive:

<textarea ui-tinymce
          ng-model="editor.model"
          ng-change="editor.onTextChanged()"></textarea>

And it doesn't work, textarea always if just simply textarea.

How can I use ui-tinymce with lazy loaded tinyCME core lib?

williamscs commented 5 years ago

The very first thing the link function does in this directive is to check that tinymce exists on the window.

You could have your lazy loader add tinymce to the window. Otherwise, this library's link function would need to check that tinymce's module is available.

sbschorer commented 4 years ago

Have you found a solution, @SiriusED? I'm stuck on that problem as well.