我正在尝试设置CKEditor,以便我可以编辑文本(删除/添加),并且所有现有的html标记将保留在源代码中,例如如果我在编辑模式中删除整个文本,我想保留所有html标签。
例如: 我在文本模式下有这个文本:
One two three
它在源模式下看起来如下:
<span data-x="1.1">One </span><span data-x="8.9">two </span><span data-x="8.9">three </span><br />
删除整个文本后,我想保留下面的空html元素:
<span data-x="1.1"></span><span data-x="8.9"></span><span data-x="8.9"></span><br />
我的初始CKEditor配置在这里:
CKEDITOR.config.height = 800;
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.basicEntities = false;
CKEDITOR.config.entities_greek = false;
CKEDITOR.config.entities_latin = false;
CKEDITOR.config.entities_additional = '';
CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
CKEDITOR.dtd.$removeEmpty.span = 0;
CKEDITOR.config.autoParagraph = false;
CKEDITOR.dtd.$removeEmpty['span'] = false;
CKEDITOR.config.extraAllowedContent = 'span(*)';
CKEDITOR.config.fillEmptyBlocks = false;
var editor = CKEDITOR.replace('editor1');
有人知道这是否适合吗?