如何在Meteor JS中集成TinyMCE和CKEditor? [英] how to integrate TinyMCE and CKEditor in Meteor JS?

查看:84
本文介绍了如何在Meteor JS中集成TinyMCE和CKEditor?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中使用CKEditor或TinyMCE编辑器。
所以我把TinyMCE文件夹放在meteor公共文件夹中,同时把

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>


但是收到以下错误。
资源解释为脚本,但使用MIME类型text / html传输:http:// localhost:3000 /%3Cyour%20installation%20path%3E / tinymce / tinymce.min。 JS。 (索引):97
未捕获的SyntaxError:意外的令牌< tinymce.min.js:1
未捕获的ReferenceError:未定义tinymce

如何解决此问题?它与CKEditor相同。
有没有其他丰富的编辑器,我可以在Meteor JS中使用?

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

推荐答案

首先,你需要把来自CKEDITOR构建下载的公共文件夹中的所有内容。 CKEDITOR提供了各种各样的东西,并根据相关目录引用了所有东西。

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.

你的公共文件夹应该有一个名为ckeditor的目录,它应包含以下文件和文件夹:

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

在主布局中文件参考CKEDITOR如下:

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>

在您的模板中:

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

最后,在模板的渲染功能中:

Finally, in the rendered function of your template:

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

通常情况下,你会说这个。$('#content')。 ckeditor()但这不起作用因为CKEDITOR在你的公共文件夹中。因此,您需要对 #content 元素的全局引用。

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.

这篇关于如何在Meteor JS中集成TinyMCE和CKEditor?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆