I using CKEditor, and if I click the Source button and paste HTML code like below :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" />
</head>
<body>
<p>test</p>
</body>
</html>
and click to Source again and then submit the form, the html
, head
and , body
tags are removed and just stays <p>test</p>
!
CKEditor configuration:
CKEDITOR.replace('content', {
extraPlugins: 'font,panelbutton,colorbutton,colordialog,justify,indentblock,aparat,buyLink',
autoGrow_onStartup: true,
enterMode: CKEDITOR.ENTER_BR,
FullPage : false,
allowedContent : true,
ProtectedTags : 'html|head|body'
});
Can you help me?
If you want to edit an entire HTML page, with <html>
, <head>
and <body>
elements, you need to set the config.fullPage
option to true
:
CKEDITOR.replace( 'content', {
fullPage: true,
extraPlugins: 'font,panelbutton,colorbutton,colordialog,justify,indentblock,aparat,buyLink',
// You may want to disable content filtering because if you use full page mode, you probably
// want to freely enter any HTML content in source mode without any limitations.
allowedContent: true,
autoGrow_onStartup: true,
enterMode: CKEDITOR.ENTER_BR
} );
Pay attention to using proper case (fullPage
is not FullPage
) in your configuration. See also the following resources for more information:
If you want to use the config.autoGrow_onStartup
option, you need to include the Auto Grow plugin in your setup.
Last but not least, changing the Enter Mode setting to BR
or DIV
is not recommended. The default CKEDITOR.ENTER_P
mode is fully supported by all editor features and plugins and is also the most correct one in terms of best practices for creating web content.
If you do it to control paragraph spacing, you should use stylesheets instead. Edit the contents.css
file and set up a suitable margin value for <p>
elements, for example:
p { margin: 0; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With