0

I use ui-tinymce module in angular project. In one controller are called tinymce.execCommand('mceRemoveControl', true, 'ntContent'); and this works fine. But after grunt build command I get the following error: ReferenceError: tinymce is not defined. Can anyone help with this ?

2
  • It sounds like the tinymce javascript dependency isn't included. It can't fine the 'tinymce' variable declared anywhere. Check to make sure the tinymce javascript file is being loaded before all your angular code is run. Commented Feb 17, 2015 at 16:22
  • try including directly with cdn <script src="//cdn.tinymce.com/4/tinymce.min.js"></script> in your page head Commented Dec 25, 2016 at 8:01

1 Answer 1

2

I had the same problem with angular-ui-tinymce module, I fixed this by making sure that the file is included.

<script src="bower_components/tinymce-dist/tinymce.min.js"></script>
<script src="bower_components/angular-ui-tinymce/src/tinymce.js"></script>

This scripts are inserted in the index.html file bower install angular-ui-tinymce and also the source code is downloaded and placed at the appropriate location.

Also when you run grunt build on the copy task it will not copy the files needed from the /tinymce-distfolder and a solution is to manually add to the copy task to copy the folders you need. I had to copy the /skins /themes /plugins folders directly into the dist/scripts folder by inserting the following code into the grunt.js file at the copy task:

// Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          ...
        }, {
          ...
        }, {
          expand: true,
          cwd: 'bower_components/tinymce-dist/themes/modern/',
          src: ['**'],
          dest: '<%= yeoman.dist %>/scripts/themes/modern/'
        }, {
          expand: true,
          cwd: 'bower_components/tinymce-dist/skins/',
          src: ['**'],
          dest: '<%= yeoman.dist %>/scripts/skins/'
        }, {
          expand: true,
          cwd: 'bower_components/tinymce-dist/plugins/link/',
          src: ['**'],
          dest: '<%= yeoman.dist %>/scripts/plugins/link/'
        }]
      },
      styles: {
        ...
      }
    }

This is not the best solution ever but it worked for me, hope it helps somebody.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.