CKEditor 允许 <html>、<head>、<body> 而不使用 fullPage:true

CKEdtior allow <html>, <head>, <body> without using fullPage: true

CKEdtior 使用默认配置设置 fullPage = false 删除 <html>, <head> and <body>。当您将 HTML 粘贴到 'source' 视图,然后关闭并重新打开源视图时,这一点最为明显。

但是,如果您制作 fullPage = true,那么编辑器会自动将这些标签添加到每个文本区域。

我如何编辑配置以允许(不删除)这些标签,但默认情况下不添加到每个编辑器?

这是不可能的(没有黑客攻击)。如果你想能够使用这些标签,那么全页模式必须是true。原因是 CKEditor 将您加载到其中的内容放在 <body> 元素(或不同的元素,具体取决于编辑器类型)中。

我想到的黑客正在使用 source protection to find content before <body> and after it and secure it. See a demo: http://jsfiddle.net/hkx8g8b8/1/

CKEDITOR.replace( 'editor', {
    protectedSource: [
        /^[\s\S]*<body>\s*/i,
        /\s*<\/body>[\s\S]*$/i
   ]
} );

如果您想允许在 <body> 标签中使用某些属性,您当然需要扩展此正则表达式。