ckeditor4学习
镜像下载速度快
git clone https://gitclone.com/github.com/ckeditor/ckeditor4.git
<script type="text/javascript" src="/ckeditor4/ckeditor.js"></script>
<div id="editor"></div>
var editor = CKEDITOR.replace('editor');
editor.setData("");
editor.document.getBody().getHtml(); //获取数据
editor.getData("");
var content=CKEDITOR.instances.editorId.getData();//editorId为元素的ID
CKEDITOR.instances.editorId.innerHtml('');
因为我的程序中editorId不确定,并且editor不止一个,所以用一个map将所有editor存起来,按照一定规律的命名方式获取
var editorMap = new Map();
var editorId = "editor" + contentId;
var editor = CKEDITOR.replace(editorId);
editor.setData(content.detail);
editorMap.set(editorId, editor);
var editor = editorMap.get("editor" + contentId);
var data = editor.getData();