Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ckeditor在数据库中添加html标记_Javascript_Html_Ckeditor_Wysiwyg - Fatal编程技术网

Javascript ckeditor在数据库中添加html标记

Javascript ckeditor在数据库中添加html标记,javascript,html,ckeditor,wysiwyg,Javascript,Html,Ckeditor,Wysiwyg,我将ckeditor添加到我的web管理面板 <textarea name="stateinformation" 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

我将ckeditor添加到我的web管理面板

<textarea name="stateinformation" 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' );
    CKEDITOR.replace( 'editor1', {
        on: {
            instanceReady: function( ev ) {
                // Output paragraphs as <p>Text</p>.
                this.dataProcessor.writer.setRules( 'p', {
                    indent: false,
                    breakBeforeOpen: true,
                    breakAfterOpen: false,
                    breakBeforeClose: false,
                    breakAfterClose: true
                });
            }
}
});
</script>

这是要用CKEditor替换的我的文本区域。
//用一个编辑器替换
//实例,使用默认配置。
//CKEDITOR.replace('editor1');
CKEDITOR.replace('editor1'{
关于:{
InstanceRady:功能(ev){
//将段落输出为文本

。 this.dataProcessor.writer.setRules('p'{ 缩进:假, 在打开之前先打开:是的, breakAfterOpen:false, breakBeforeClose:false, breakAfterClose:对 }); } } });
我试着列出一些段落和项目清单。但添加到数据库中的数据如下所示

<p>text...</p><p>&nbsp;</p><p>&nbsp;</p><p>text...</p><ul><li>text...</li><li>text...</li><li>text...</li></ul>
文本…

文本…

  • 文本…
  • 文本…
  • 文本…
  • 文本…

我尝试使用str_replace和stripslashes,但它也消除了para和bullet list的效果。有人能告诉我们如何在不删除这些特殊字符的情况下删除它们的效果吗?

在Ckeditor配置文件中放入您希望允许的标记:例如

config.allowedContent =
    'h1 h2 h3 p blockquote strong em;' +
    'a[!href];' +
    'img(left,right)[!src,alt,width,height];';

有关更多帮助和示例,请参阅
CKEDITOR.instances.editor1.document.getBody().getText()
@Tushar您提供的链接不起作用。我应该将代码放在哪里进行测试?这是否意味着您试图在编辑器中提供html标记数据?