I have switched to TinyMCE from FCK due to the <p> <.p>
issue with FCK. Everything so far is fine with TinyMCE. However, I do not like the way TinyMCE forces paragraphs instead of line breaks on enter. I understand the developers have reasons for wanting paragraphs as default, but it's really confusing from a user perspective when a forum requires shift-enter to line break.
As such, I want to disable this function and get line breaks by default.
I have read the TinyMCE FAQ, forums, and documentation, and their standard answer is:
1) http://wiki.moxiecode.com/index.php/TinyMCE:FAQ#TinyMCE_produce_BR_eleme...
tinyMCE.init({
forced_root_block : false,
force_br_newlines : true,
force_p_newlines : false
});
2) http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/force_br_newlines
tinyMCE.init({
...
force_br_newlines : true,
forced_root_block : '' // Needed for 3.x
});
I would like to try these configurations, but I am having a lot of trouble understanding or figuring out where to put this code - in TinyMCE, the WYSIWYG module, or my site's theme.
Can you help me figure out where it goes or how to enter it?
Thanks for any help you can provide.
Comments
Comment #1
nimi CreditAttribution: nimi commentedI am having the exact same issue. Did you find a solution that works?
Comment #2
uomeds CreditAttribution: uomeds commentedFrom what I have read, I am almost certain the
tinyMCE.init({
solutions I posted above should work. We just have to figure out where and how to insert it.I am hoping the WYSIWYG coder can clarify, since I think it needs to go into the module.
Comment #3
TwoDPersonally, I expect paragraphs when pressing enter and think excessive use of linkebreaks are what makes many websites (and wordprocessor documents!) very hard to style or zoom/scale the text nicely on.
But you can try this, from #313497: Allow configuration of advanced editor settings. I haven't actually tested it but I think it should work.
Just leave out the starting/ending PHP tags and put it in your template.php file. If you have enabled TinyMCE for more than one format you can just add another formatN key to the tinymce array.
Once the issue I mentioned above is fixed, you should not need this workaround anymore.
Comment #5
samchok CreditAttribution: samchok commentedThe above code in template.php seemed to work for me. But now I'm getting a new problem: The TinyMCE editor correctly create a 'br' instead of 'p' tag, but when the Preview (and the newly created page) shows no 'br' or 'p' at all! Allt he text is on the same line...
What could it be?
Comment #6
samchok CreditAttribution: samchok commentedI add that the input type associated to the editor is "Full HTML", so no tags should be filtered by drupal.
Also, the 'br' tags are present in DB: if I edit the page the editor still displays new lines and disabling the editor the 'br' tags are still there.
So it seems that drupal is not showing the 'br' tags in the 'view' tab only.
Comment #7
samchok CreditAttribution: samchok commentedThe problem was with the HTML filter checkbox associated with the "Full HTML" input type. Disabling it everything works fine again.
Comment #8
srobert72 CreditAttribution: srobert72 commented#3 : I tried this solution and it works
See #56 at #313497: Allow configuration of advanced editor settings
Or this link : http://drupal.org/node/313497#comment-2762226
Comment #9
asnair CreditAttribution: asnair commentedYes, this works!
Notes:
template.php file is in the themes folder. And this code is to be inserted outside of any function.
The N in FormatN is to be obtained from admin/settings/filters (in Drupal). In my case the selected Input Format is "Full HTML" which is 2nd in the list. Hence, I replaced N with 2
I pasted the following code above all the functions:-
<?php
//added on 30 Dec 2011 for tinyMCE to use instead of
drupal_add_js( array(
"wysiwyg" => array(
"configs" => array(
"tinymce" => array(
"format2" => array( // Replace N with the id num of the format TinyMCE is enabled for.
'forced_root_block' => FALSE,
'force_br_newlines' => TRUE,
'force_p_newlines' => FALSE
)
)
)
)
),'setting');
// end add
function theme166_menu_local_task($link, $active = FALSE) {
etc
Comment #10
TwoDWe have a better way of doing this now. See wysiwyg.api.php for details.
sites/all/modules/MYMODULE/MYMODULE.info:
sites/all/modules/MYMODULE/MYMODULE.module
Enable the module as usual.
Now it'll work with all themes you've got installed without further modifications, even if updating Wysiwyg or TinyMCE.
Comment #11
mototribe CreditAttribution: mototribe commentedthanks TwoD, exactly what I was looking for - works just fine with D7. This should be a settings option in the module
Comment #12
TwoDOnce I get to finalizing the patch for allowing editors and plugins change the settings GUI, we can add all those settings as separate checkboxes.
Comment #13
ximizu CreditAttribution: ximizu commentedsolution #10 works perfectly for with D7.
Thanks TwoD.
Comment #14
RAWDESK CreditAttribution: RAWDESK commented#10 worked perfectly to prevent
<p>
tags from occurring around youtube embedded media, which rendered faulty with an unwanted blank line in front of it.@TwoD, good idea to provide this in wysiwyg admin UI. Let me know if review/testing is wanted.