Removing default p tag in editor
Permalink
I have done this a whole bunch of times before without issue, just downloaded 5.6.3.1
Anyone know how to get rid of the default p tag? The way I used to use was to copy the editor_config out to root/blocks/content and add the forced_root_block: false, below the tinyMCE.init({ area and above the mode : "textareas", area.
The new concrete/blocks/content/editor_config file just has the following:
Would I just add $textEditorOptions['forced_root_block'] = 'false', to the top?
Anyone know how to get rid of the default p tag? The way I used to use was to copy the editor_config out to root/blocks/content and add the forced_root_block: false, below the tinyMCE.init({ area and above the mode : "textareas", area.
The new concrete/blocks/content/editor_config file just has the following:
<?php $textEditorOptions = array(); $textEditorOptions['width'] = '100%'; if(isset($theme) && is_object($theme)) { $textEditorOptions['content_css'] = $theme->getThemeEditorCSS(); } $textEditorOptions = Loader::helper('tinymce')->getOptions($textEditorOptions); ?><script language="javascript" type="text/javascript"> tinyMCE.init(<?php echo Loader::helper('json')->encode($textEditorOptions); ?>); </script>
Would I just add $textEditorOptions['forced_root_block'] = 'false', to the top?
Bump
Hello,
Use CSS to remove space from the p tag by targeting the area or the element.
Example
or
Use CSS to remove space from the p tag by targeting the area or the element.
Example
.area p {margin:0}
or
<p class="blablabla"></p> p.blablabla {margin:0}
So does that mean there is not a way to do through the tinymce settings?
I figured out a way to get this done without css,
But not sure how to get so that it doesn't get overridden during updates. Suggestions would be greatly appreciated.
Here is how I got it to remove the default p tag,
1. edit concrete/core/helpers/tinymce.php
modify this:
to this:
then copy out the concrete/blocks/content folder out to root/blocks/content,
then modify root/blocks/content/editor_config.php and change
this
to this
Again, I know this will be overridden when updates occur. Need to find a way so that would not be overridden.
But not sure how to get so that it doesn't get overridden during updates. Suggestions would be greatly appreciated.
Here is how I got it to remove the default p tag,
1. edit concrete/core/helpers/tinymce.php
modify this:
$textEditorOptions = array( 'mode' => 'textareas', 'inlinepopups_skin' => 'concreteMCE', 'theme_concrete_buttons2_add' => 'spellchecker', 'browser_spellcheck' => true, 'gecko_spellcheck' => true, 'relative_urls' => false, 'document_base_url' => BASE_URL . DIR_REL . '/', 'convert_urls' => false, 'entity_encoding' => 'raw', 'editor_selector' => 'ccm-advanced-editor' );
to this:
$textEditorOptions = array( 'forced_root_block' => "p", 'mode' => 'textareas', 'inlinepopups_skin' => 'concreteMCE', 'theme_concrete_buttons2_add' => 'spellchecker', 'browser_spellcheck' => true, 'gecko_spellcheck' => true, 'relative_urls' => false, 'document_base_url' => BASE_URL . DIR_REL . '/', 'convert_urls' => false, 'entity_encoding' => 'raw', 'editor_selector' => 'ccm-advanced-editor' );
then copy out the concrete/blocks/content folder out to root/blocks/content,
then modify root/blocks/content/editor_config.php and change
this
<?php $textEditorOptions = array(); $textEditorOptions['width'] = '100%'; if(isset($theme) && is_object($theme)) { $textEditorOptions['content_css'] = $theme->getThemeEditorCSS(); } $textEditorOptions = Loader::helper('tinymce')->getOptions($textEditorOptions); ?><script language="javascript" type="text/javascript"> tinyMCE.init(<?php echo Loader::helper('json')->encode($textEditorOptions); ?>); </script>
to this
<?php $textEditorOptions = array(); $textEditorOptions['width'] = '100%'; $textEditorOptions['forced_root_block'] = false; if(isset($theme) && is_object($theme)) { $textEditorOptions['content_css'] = $theme->getThemeEditorCSS(); } $textEditorOptions = Loader::helper('tinymce')->getOptions($textEditorOptions); ?><script language="javascript" type="text/javascript"> tinyMCE.init(<?php echo Loader::helper('json')->encode($textEditorOptions); ?>); </script>
Again, I know this will be overridden when updates occur. Need to find a way so that would not be overridden.
Use CSS. It will not get overridden with updates.
This is a much better way.
This is a much better way.
Here is how to do it without change of override as tested on C5631:
1. Copy concrete/core/blocks/content folder to root/blocks/content folder
2. Edit the root/blocks/content/editor_config.php from
to
1. Copy concrete/core/blocks/content folder to root/blocks/content folder
2. Edit the root/blocks/content/editor_config.php from
<?php $textEditorOptions = array(); $textEditorOptions['width'] = '100%'; if(isset($theme) && is_object($theme)) { $textEditorOptions['content_css'] = $theme->getThemeEditorCSS(); } $textEditorOptions = Loader::helper('tinymce')->getOptions($textEditorOptions); ?><script language="javascript" type="text/javascript"> tinyMCE.init(<?php echo Loader::helper('json')->encode($textEditorOptions); ?>); </script>
to
<?php $textEditorOptions = array(); array_push($textEditorOptions,'forced_root_block');//add to array $textEditorOptions['width'] = '100%'; $textEditorOptions['forced_root_block'] = false;//added if(isset($theme) && is_object($theme)) { $textEditorOptions['content_css'] = $theme->getThemeEditorCSS(); } $textEditorOptions = Loader::helper('tinymce')->getOptions($textEditorOptions); ?><script language="javascript" type="text/javascript"> tinyMCE.init(<?php echo Loader::helper('json')->encode($textEditorOptions); ?>); </script>
That was helpful - thanks.
What I found in C5634 was that after adding your code, the Enter and Shift+Enter behaviour had changed to <br> and <p> respectively. In order to restore it, I added two more lines as follows to enable force_p_newlines:
I am not sure why this was necessary since in previous Concrete versions, adding didn't invert the Enter key function?
PS. Of course the two array_push lines could be rolled into one like so:
What I found in C5634 was that after adding your code, the Enter and Shift+Enter behaviour had changed to <br> and <p> respectively. In order to restore it, I added two more lines as follows to enable force_p_newlines:
<?php $textEditorOptions = array(); array_push($textEditorOptions,'forced_root_block');//add to array array_push($textEditorOptions,'force_p_newlines');//add to array $textEditorOptions['width'] = '100%'; $textEditorOptions['forced_root_block'] = false;//added to prevent forced <p> tags being added $textEditorOptions['force_p_newlines'] = true;//added to restore Enter & Shift+Enter behaviour to produce <p> and <br> respectively if(isset($theme) && is_object($theme)) { $textEditorOptions['content_css'] = $theme->getThemeEditorCSS(); } $textEditorOptions = Loader::helper('tinymce')->getOptions($textEditorOptions); ?><script language="javascript" type="text/javascript"> tinyMCE.init(<?php echo Loader::helper('json')->encode($textEditorOptions); ?>); </script>
I am not sure why this was necessary since in previous Concrete versions, adding
'force_root_block' = false
PS. Of course the two array_push lines could be rolled into one like so:
array_push($textEditorOptions,'forced_root_block','force_p_newlines');//add to array