TinyMCE MS MVC looking for non-minified file

1.2k views Asked by At

I have an MS MVC deployment that is looking for a subscript for TinyMCE "theme.js" and not finding it because the file is theme.min.js. How do I get MVC to look for the minified file?

The tinymce file is tinyMCE.min.js, so it is finding that one. Is this a problem with setting TinyMCE or MS MVC?

Long explanation : We are in the process of implementing TinyMCE on a Microsoft MVC page. It was working locally but would not run when deployed to the server. It was failing with a 404, file not found for the file : PROJECT_ROOT/bundles/themes/modern/theme.js

This was not the location of the theme file it was looking for and after a little research I found out that you needed to set the tinymce.baseURL property. When I did this it helped a little by changing the location in the error to the actual location of the file : PROJECT_ROOT/Scripts/libs/tinymce/themes/modern/theme.js

The problem is that for some reason it was looking for the un-minified file theme.js and not theme.min.js. If I change the name to theme.js it works.

I thought that MVC and/or TinyMCE would do some magic to get the right name. Is there a setting I need to change?

3

There are 3 answers

0
Michael Fromin On

TinyMCE should work out to load minified (or non-minified) files based on which TinyMCE file you load (tinymce.js or tinymce.min.js).

Not sure what's happening in your case but that logic appears to be failing.

If you grab the DEV package from https://www.tiny.cloud/get-tiny/self-hosted/ it would come with both the minified and non-minified versions of each file so the editor would find what it needs at runtime.

Note: The code in the minified and non-minified files functions just the same so from a functionality perspective it does not really matter if theme.min.js or theme.js code is loaded. It only add ~200K to the file size so even that is immaterial.

1
Terry H On

I think I found the solution for this. There is a property you can set in the tinymce object called "suffix" that resolved this for me.

So, for the first part I set a rootURL property in the page calling TinyMCE, and then added the line tinymce.baseURL = rootURL + 'Scripts/libs/tinymce' just before the tinymce.init.

Then, to get it to find the theme.min.js set tinymce.suffix = '.min'

This seems to have resolved the issue. Not sure if this is a hack solution but it is working. If anyone has a better way to do it please let me know.

0
krchun On

You need to set tinymce.suffix = '.min'; before you init TinyMCE

tinymce.suffix = '.min';
tinymce.baseURL = '/js/tinymce';
tinymce.init({
    selector: '#editor',
    menubar: false,
    plugins: 'code' 
});