how to integrate TinyMCE and CKEditor in Meteor JS?

橙三吉。 提交于 2020-01-01 11:46:09

问题


I am trying to use CKEditor or TinyMCE editor in my project. So I put TinyMCE folder in meteor public folder, also put

<head>
<script type="text/javascript" src="<your installation path>/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
    tinymce.init({
        selector: "textarea"
    });
</script>

in template head tag. However receiving following error. Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/%3Cyour%20installation%20path%3E/tinymce/tinymce.min.js". (index):97 Uncaught SyntaxError: Unexpected token < tinymce.min.js:1 Uncaught ReferenceError: tinymce is not defined

How do I fix this problem? It is same to CKEditor. Is there any other rich editor ,which I can use in Meteor JS?


回答1:


First, you need to put everything from the CKEDITOR build download in the public folder. CKEDITOR comes with all sorts of stuff and references everything based on relative directories.

Your public folder should have a directory named ckeditor it should contain contain the following files and folders:

 adapters
 lang
 plugins
 skins
 ckeditor.js
 config.js
 contents.css
 styles.js

In your primary layout file reference CKEDITOR like so:

 <head>
   <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
   <script type="text/javascript" src="/ckeditor/adapters/jquery.js"></script>
 </head>

In your template:

 <template name="yourTemplate">
   <textarea id="content" name="content"></textarea>
 </template>

Finally, in the rendered function of your template:

 Template.yourTemplate.rendered = function() {
   $('#content').ckeditor();
 };

Normally, you would say this.$('#content').ckeditor() but that doesn't work because CKEDITOR is in your public folder. As a result, you need to the global reference to the #content element.




回答2:


Instead of /public folder, put your files in /client/compatibility. Then initialize it in the template you want to use it.

Template.editor.rendered = function() {
  tinymce.init({
    selector: 'textarea'
  });
};



回答3:


This was the only result searching for wysiwyg:

https://github.com/mcrider/meteor-bootstrap-wysiwyg

meteor add mcrider:bootstrap-wysiwyg

Looks a bit simpler than CKEditor or TinyMCE but maybe that's ok for your project.



来源:https://stackoverflow.com/questions/26010749/how-to-integrate-tinymce-and-ckeditor-in-meteor-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!