A non-breaking space character, entered with TinyMCE turned off, is somehow automatically replaced with a regular space character the first time when opened with TinyMCE turned on (both in Firefox and in M$IE). It is extremely annoying, as it messes up the display of the content in some table fields on my site. How to make TinyMCE not to touch a   character?

I've seen some posts on TinyMCE site about that, but they seems to be related to Firefox (they say M$IE is OK). For me, it is absolutely the same in both browsers. It would be nice to know where it happens and if there is some more elegant way to disable it as to mess with the TinyMCE code (maybe some theme variable setting or so?).

For the future, it would be nice to have a admin setting for this as a part of the module. Or, simply to make it a default not to be too clever - the user normally puts it there with a certain intention, or?! At the end, it is much more simple to put a normal space where it is enough... ;-)

CommentFileSizeAuthor
#3 tinymce-remove_linebreaks-option.patch2.55 KBmcurry
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

halfer’s picture

I had exactly this problem, and discovered this behaviour may be down to this:

http://tinymce.moxiecode.com/tinymce/docs/option_entity_encoding.html

I switched my encoding to 'named', and the issue seems to have gone away (certainly on Firefox 1.5.x). Hope that helps!

ricmadeira’s picture

Category: support » feature
Priority: Normal » Critical
Status: Active » Reviewed & tested by the community

I encountered this problem long ago, and solved it by adding the following lines to tinymce.module (sorry, don't know how to create a proper patch) so that I could further configure the behavior of the editor.

These lines add two new settings in the admin panel for the module, and you can manipulate them to change the behavior of TinyMCE. If you change the setting "Convert new lines to BRs" from the default "False" to "True", the problem will be solved because the newline characters will be replaced with HTML linebreaks.

I'm updating priority to critical because this issue is a true pain in the neck for sites where the use of the editor is optional.

1st Edit:

  $init['preformatted']       = $settings['preformatted'] ? $settings['preformatted'] : 'false';
  $init['convert_fonts_to_styles'] = $settings['convert_fonts_to_styles'] ? $settings['convert_fonts_to_styles'] : 'false';

// <----------------- !!START OF NEW LINES!! ----------------->

  $init['convert_newlines_to_brs']   = $settings['convert_newlines'] ? $settings['convert_newlines'] : 'false';
  $init['remove_linebreaks']   = $settings['remove_linebreaks'] ? $settings['remove_linebreaks'] : 'true';

// <----------------- !!END OF NEW LINES!! ----------------->

  $tinymce_mod_path = drupal_get_path('module', 'tinymce');

2nd Edit:

  $form['output']['convert_fonts_to_styles'] = array(
    '#type' => 'select', 
    '#title' => t('Convert &lt;font&gt; tags to styles'), 
    '#default_value' => $edit->settings['convert_fonts_to_styles'], 
    '#options' => array('true' => 'true', 'false' => 'false'), 
    '#description' => t('If you set this option to true, font size, font family, font color and font background color will be replaced by inline styles.')
  );

// <----------------- !!START OF NEW LINES!! ----------------->

  $form['output']['remove_linebreaks'] = array(
    '#type' => 'select', 
    '#title' => t('Remove linebreaks'), 
    '#default_value' => $edit->settings['remove_linebreaks'], 
    '#options' => array('true' => 'true', 'false' => 'false'), 
    '#description' => t('This option controls if linebreak characters should be removed from output HTML or not. This option is enabled by default since many backend systems use newline to convertion since they used to be plain old textarea based. With this option enables all HTML content will be placed on one line.')
  );

  $form['output']['convert_newlines'] = array(
    '#type' => 'select', 
    '#title' => t('Convert new lines to BRs'), 
    '#default_value' => $edit->settings['convert_newlines'], 
    '#options' => array('true' => 'true', 'false' => 'false'), 
    '#description' => t('If you set this option to true newline characters codes gets converted in to br elements. This option is set to false by default.')
  );

// <----------------- !!END OF NEW LINES!! ----------------->

  $form['css'] = array(
    '#type' => 'fieldset', 
    '#title' => t('CSS'), 
    '#collapsible' => TRUE, 
    '#collapsed' => TRUE
  );
mcurry’s picture

Component: Miscellaneous » Code
Status: Reviewed & tested by the community » Needs review
FileSize
2.55 KB

Here's a proper patch for review, based on the changes suggested above. Please review and comment.

kreynen’s picture

Status: Needs review » Closed (duplicate)
Yao’s picture

http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/entity_encoding
To make tinymce not to replace entities' names with their codes or whatever we need to have this:
tinyMCE.init({
...
entity_encoding : "raw"
});

So I added
$init['entity_encoding'] = array( "named" );
to tinymce_process_textarea function in tinymce.module (after $init['elements'] = 'edit-'. $textarea_name;)

Yao’s picture

Sorry, correct varsion:

tinyMCE.init({
...
entity_encoding : "named"
});