TinyMCE 404/undefined

2020-05-01 09:23发布

I am using TinyMCE with Twitter Bootstrap v3.1 in a Q/A application.

For some reason I am getting multiple 404 errors from TinyMCE in console:

GET http://localhost/assets/lib/TinyMCE/themes/modern/themeundefined.js 404 (Not Found) tinymce.min.js:3
Failed to load: /assets/lib/TinyMCE//themes/modern/themeundefined.js 

As far as I can see the path is correct. I have typed the path directly into the browser bar (without undefinedtheme.js) and it pops up.

Full path to TinyMCE is: http://localhost/application/assets/lib/TinyMCE/

  1. I have mod-rewrite enabled, I have tried disabling but didn't help.
  2. I have tried setting:
    • tinyMCE.baseURL = "/assets/lib/TinyMCE";
    • tinyMCE.baseURL = "/application/assets/lib/TinyMCE";
    • tinyMCE.baseURL = "localhost/application/assets/lib/TinyMCE";

I have searched the TinyMCE FAQ for the issue which pointed me to mod_rewrite.

Basically what has caused the undefinedtheme.js thing?

My TinyMCE Initiator:

//TinyMCE Initiator

//set scope
$(document).ready(function() {

    tinyMCE.baseURL = "/assets/lib/TinyMCE";

    tinymce.init({
        selector: "textarea#tinymce",
        theme: "modern",
        /*width: 400,*/
        height: 300,
        plugins: [
             "advlist autolink link lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime nonbreaking",
             "save contextmenu directionality emoticons template paste textcolor"
       ],
       content_css: "../assets/css/bootstrap.css",
       toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify bullist numlist forecolor | outdent indent | l      ink | ", 
       style_formats: [
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ]
    }); 

});

1条回答
【Aperson】
2楼-- · 2020-05-01 10:14

TinyMCE should be included before the textarea tag, not after

<doctype html>
    <head>
        <script src="/assets/lib/TinyMCE/tinymce.min.js"></script>
    </head>

    <body>
        <div class="container" role="main">
            <textarea id="tinymce"></textarea>
        </div>
    </body>

<script>

$(document).ready(function() {

    tinymce.init({
        selector: "textarea#tinymce",
        theme: "modern",
        //width: 400,
        height: 300,
        plugins: [
             "advlist autolink link lists charmap print preview hr anchor pagebreak spellchecker",
             "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime nonbreaking",
             "save contextmenu directionality emoticons template paste textcolor"
       ],
       content_css: "../assets/css/bootstrap.css",
       toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify bullist numlist forecolor | outdent indent | l      ink | ", 
       style_formats: [
            {title: 'Bold text', inline: 'b'},
            {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
            {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
            {title: 'Example 1', inline: 'span', classes: 'example1'},
            {title: 'Example 2', inline: 'span', classes: 'example2'},
            {title: 'Table styles'},
            {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
        ]
    });
});

</script>

</html>
查看更多
登录 后发表回答