php 如何使用 CKEditor 作为表单输入?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18599605/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use CKEditor as form input?
提问by pastx
I am trying to make simple web editor using CKEditorbut i cant find out how to make it work.
我正在尝试使用CKEditor制作简单的网页编辑器,但我不知道如何使它工作。
First i checked their samples site. Only thing they do to make CKEditor work is include .js file and add ckeditor class to form textarea element.
首先,我检查了他们的样品站点。他们唯一让 CKEditor 工作的事情就是包含 .js 文件并添加 ckeditor 类以形成 textarea 元素。
<script src="../ckeditor.js"></script>
.
.
.
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
So i copy .js file and try it in my own folder and when i run php script whole textarea element is hidden and doesnt create CKEditor panel as it should like in this sample page.There might be some javascript configuration but i havent found any in source code of sample page.
所以我复制 .js 文件并在我自己的文件夹中尝试它,当我运行 php 脚本时,整个 textarea 元素被隐藏并且不会像在这个示例页面中那样创建 CKEditor 面板。可能有一些 javascript 配置,但我在示例页面的源代码中没有找到任何配置。
回答by meshkati
call CKEDITOR.replace( 'editor1' );
in your js files or simply in your html file like this:
调用CKEDITOR.replace( 'editor1' );
您的 js 文件或简单地调用您的 html 文件,如下所示:
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10">
<script>
CKEDITOR.replace( 'editor1' );
</script>
回答by Majid
- Copy all of your
ckeditor
folder to server. Add it to html page ;like this:
<script src="../script/ckeditor/ckeditor.js" type="text/javascript"></script>
Assign CSS class of
ckeditor
totextarea
; likeclass="ckeditor"
.
- 将所有
ckeditor
文件夹复制到服务器。 将其添加到 html 页面;像这样:
<script src="../script/ckeditor/ckeditor.js" type="text/javascript"></script>
分配 CSS 类
ckeditor
totextarea
; 喜欢class="ckeditor"
。
回答by Black Mamba
<script src="../ckeditor.js"></script>
<form name="ckeditor">
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
As given in the main website.
如主网站所示。