BeaT's Blog

TinyMce extra br and p near new lines bug

Stardate 101.2010 Captain's Log

I encountered a known problem while installing tiny mce on expression engine, transforming new lines to br or p tags.

Supplemental

When i speak of newline I mean \n\r or chr(13)+chr(10). I saw that the "bug" appeared on different platforms like blogspot, joomla anywhere where tinymce exists.

It's a known problem, but i didn`t found an actual solution on google. People that use br and not paragraphs resolved it with

  • force_br_newlines : true,
  • forced_root_block : '',

but i wanted paragraphs not line breaks.

First i thought the problem was the expression engine so i disabled the formatting option at the "custom weblog field" to "none"(instead of xhtml or auto <br /> (from cpanel and from all previous entries).

No change, then i tried to modify tinymce's settings, still nothing.

Then i pinned down the problem : when i edit an entry, tiny mce automatically transforms the ascii "newline" to <br /> or <p>&nbsp;</p>. I checked the database, the field text was good (only <p>'s and normal newlines). I tried with Opera and Firefox ... the problem persisted. When you hit "Edit entry" you can see double spaces between paragraphs, and when i hit "html" source from the tiny mce bars ("code" button) there they were : lots of line breaks over all newlines.

What is happening :

//you enter 
<p>Lorem ipsum dolor sit amet consectetuer a ut ut hendrerit Sed. Maecenas justo.</p>
<p>In sit justo ipsum Vestibulum a semper orci Pellentesque nibh pulvinar. Pretium In et elit tincidunt mauris nisl dui sed Sed est. Duis sed.</p>
//and becomes <p>Lorem ipsum dolor sit amet consectetuer a ut ut hendrerit Sed. Maecenas justo.</p>
<br /><p>In sit justo ipsum Vestibulum a semper orci Pellentesque nibh pulvinar. Pretium In et elit tincidunt mauris nisl dui sed Sed est. Duis sed.</p> //or <p>Lorem ipsum dolor sit amet consectetuer a ut ut hendrerit Sed. Maecenas justo.</p>
<p>&nbsp;</p><p>In sit justo ipsum Vestibulum a semper orci Pellentesque nibh pulvinar. Pretium In et elit tincidunt mauris nisl dui sed Sed est. Duis sed.</p> 

 

I read and set all the tiny mce related settings, but still nothing :

  • convert_newlines_to_brs: "false",
  • force_p_newlines: "true",
  • force_br_newlines : "false",
  • remove_redundant_brs : "true",
  • remove_linebreaks : "true",
  • forced_root_block : "",

 

I found a  workaround with a custom cleanup, that before the submit removes all the line breaks from the input, is kinda cruel but if you are desperate it works (i think, i didn't tested it).

function CustomCleanup(type, content) {
  switch (type) {
   // gets passed when user submits the form
   case "get_from_editor":
    content = content.replace(/<br \/>/gi, "\n"); // would be nice if this replace only replaces the brs in a pre block. bur for the moment it is ok.
    break;
   // gets passed when new content is inserted into the editor
   case "insert_to_editor":
    break;
  }
return content;
}

tinyMCE.init({
    ...
    cleanup_callback : "myCustomCleanup"
});

 

Finally the solution

After some swearing time and play around with this settings it came to me what i did wrong, the settings were boolean type, and i gived them string values.

Ok let me explain it, convert_newlines_to_brs: false is good, convert_newlines_to_brs: "false" is actual convert_newlines_to_brs: true or convert_newlines_to_brs: "anything-here"

So, actual is not a bug, just a bad setting and the solution is : convert_newlines_to_brs: false , without the double quotes.

Morale : when you are in a hurry to fix something, return to it after a break grin.

Tags : tinymce, error, bug, trick, editor, blog

Entry Info

By .(JavaScript must be enabled to view this email address) • Tagged  #Software  #Web  • Written April 12 2010 • So far it has 22904 views and 256 Comments • Permalink

Comments
Comments page 1 of 6  1 2 3 >  Last »
1.

Hello,
Thank you for your post
I am using tinymce 3.3.8 (latest) I have the same problem problem with copy paste from word/outlook. I’ve tried the setting you posted , but is this setting enough to? can you post also the whole config object ?

Posted by Ovidiu 08/11 03:45 PM

2.

You are the only one that has this (deceptively simple) fix for this issue.  I have been running around the web looking for this answer… and you’re right…  Just needed to take a break.  smile

Thanks!

Posted by Shifty McCool 06/10 04:35 PM

3.

Thanks guys
Is no need to post the config, that is the only setting that is needed for this feature to work.

Posted by B3aT 06/21 08:26 PM

4.

The <a >cheapest propecia</a> better quality variations, known as http://www.propeciabuy.sitew.com cheapest propecia as approvingly as propecia online prescription, can be found in the marketplace. The http://www.propeciabuy.sitew.com finasteride propecia is at one’s disposal in the remedy type and requires to turn eaten aside mouth.

Posted by propecia purchase 05/05 07:51 PM

6.

Angry Birds       
Angry Birds Space Free       
Demo Angry Birds Space

Posted by Emiptthufftaf 05/05 08:40 PM

7.

The <a >propecia on line</a> cork quality variations, known as http://flavors.me/propeciafinasteride propecia side effects as well as buy propecia online, can be establish in the marketplace. The http://www.propeciabuy.sitew.com purchase propecia is at one’s disposal in the pill paradigm and requires to turn eaten on mouth.

Posted by purchase propecia 05/05 10:24 PM

8.

Самые взрослые мастера столицы быстро в течении 29 минут после звонка приедут и отремонтируют холодильники и морозильники любых марок.Выезд бесплатный.Цены на ремонт самые низкие в Москве.Наш сайт: http://www.xolodremont.ru
<a href=“http://www.gorodservis.ru” title=”ремонт холодильников самсунг”>ремонт холодильников самсунг</a>
<a href=“http://www.xolodremont.ru/remont_holodilnikov_metro_frunzenskaya.html”>Ремонт холодильников вокруг станции метро Фрунзенская</a>


——————————
вскрыть дверь
ремонт холодильников

Posted by Mrtfnhjyt 05/05 10:29 PM

9.

hdpxhc bbtoeo louboutin schuhe  nbftvi boutique lancel à paris  guyimh http://sac-lancelpascher.info/  gjscjx sac-lancelpascher.info  wogffz

Posted by szgnwsrc 05/05 11:12 PM

10.

Never to capitalize on <a >viagra cheap</a> pro any other purpose or as a recreational cheap viagra uk because it may examine http://www.cheapviagrapurchase.com buy cheap viagra noxious to your health. Put to use it exclusively recompense the <a >generic levitra buy</a> helplessness treatment. Women, children, and teenagers are strictly prohibited from using the http://www.vardenafilpurchase.com vardenafil cheap.

Posted by viagra cheapest 05/05 11:36 PM

11.

[url=http://liquid.rv.ua]табурины знак бесконечность земфира
[/url]

Posted by Miniseict 05/05 11:43 PM

12.

thank you comfortable and thanks for tut! pleas send to me massage i need help me to understand photoshop That really is funny! I including what We have read thus far. I are already contemplating managing for political office for the past few years. I plan to be one whom brings a new experience that all can take advantage of and not force feasted. Did
volcano vaporizers
Eating free types of something you’ve got no intention involving. I love this one! <br />Pets, such legitimate friends, and certainly they pee on your own carpet, but it’s not possible to get crazy, because that they always take a look at you so innocently… Oliver Stone called them a conspiracy theory, but he’s at the particular far end on the metric regarding measuring identity disorders. 
<a >volcano vaporizer</a >

Posted by flienikew 05/05 11:57 PM

13.

Высокий уровень развития юристов нашей фирмы, обучение в величайшем учебном заведении мира и разнообразное приобретение развития дают право говорить о профессионализме наших сотрудников и адвокатов и фирмы в целом. На любой вопрос клиента каждый раз будет найден ответ, всякий спор разобран, а обращение в суд выиграно. Перечень дел, предлагаемых нашими сотрудниками разнообразен: включая регистрации юридических лиц и заканчивая разрешением жилищьных проблем. На все работы имеются разрешения и необходимые договора. 
Юридическая фирма НУР : Споры о детях

Posted by NuRTrom 05/06 12:54 AM

14.

[url=http://lively.rv.ua]лексику создать сообщение
[/url]

Posted by baxNearlibe 05/06 07:03 AM

15.

Diablo III for free

Posted by PINIAFLANNA 05/06 08:02 AM

16.

[url=http://solve.if.ua]СУН-
[/url]

Posted by awainfota 05/06 10:52 AM

17.

In no way to deplete <a >cheap viagra no prescription</a> for any other resolution or as a recreational cheapest viagra online because it may make good http://www.cheapviagrapurchase.com viagra cheapest bad to your health. Use it exclusively for the <a >generic levitra buy</a> sterility treatment. Women, children, and teenagers are strictly prohibited from using the http://levitravardenafilreviews.com buying levitra.

Posted by cheap viagra to buy 05/06 11:23 AM

18.

[url=http://loader.rv.ua]провоз калясок аэрофлотом
[/url]

Posted by fonnodsirrisk 05/06 02:50 PM

19.

100 acceptance payday loans free payday loan payday advance payday loans without debit card payday loans no bank account same day payday fast payday cash

Posted by Fughurign 05/06 03:28 PM

20.

Call me:  00-299588001

Posted by boimbenia 05/06 05:13 PM

21.

Never to capitalize on <a >cheap viagra sildenafil</a> pro any other resolution or as a recreational cheapest viagra because it may prove http://www.cheapviagrapurchase.com cheap viagra noxious to your health. Buy it purely recompense the <a >vardenafil no prescription</a> sterility treatment. Women, children, and teenagers are strictly prohibited from using the http://levitravardenafilreviews.com buy generic levitra.

Posted by cheap viagra 05/06 10:31 PM

22.

[url=http://local.rv.ua]ИГРЫ
[/url]

Posted by weptElaltyMat 05/06 10:33 PM

24.

[url=http://somewhat.if.ua]Manic Street Preachers - Umbrella скачать бесплатно
[/url]

Posted by gawninvange 05/07 01:16 AM

25.

Diablo 3 download

Posted by intessutt 05/07 01:24 AM

26.

[url=http://locate.rv.ua]Jeep Wrangler II (TJ) . i V ( Hp)
[/url]

Posted by AlowsAninimot 05/07 06:17 AM

27.

http://xydei.pp.ua/

Posted by CristiMore 05/07 07:59 AM

28.

wcvrhxs windows 7 ultimate gyxktii windows 7 ultimate product key wqibnfd windows 7 keygen ozageop <a href=“http://www.windows7ultimateonline.com/”>cheap windows 7</a> ctppxiu <a href=“http://www.windows7ultimateonline.com/”>cheap windows 7</a> qbiynil <a href=“http://www.windows7ultimateonline.com/”>windows 7</a>

Posted by egvmebjf 05/07 12:56 PM

29.

[url=http://spare.if.ua]молодёжь социальная группа
[/url]

Posted by Natacarry 05/07 03:04 PM

30.

c v N e f http:///www.digiforia.com  A X n h
http://www.3ziiz.com  A Y s J
http://www.mulberryeffiebags.com

Posted by liaftishatoldk 05/07 04:28 PM

31.

Storing <a >amoxicillin antibiotics</a> fittingly is definitely respected and cannot be neglected. If not bewitched pains of, amoxicillin dose will not last instead of long time. Every http://amoxilamoxicillin.webs.com amoxicillin requires so-called storage for longevity. Temperature is the before all step in storing http://amoxilamoxicillin.webs.com dosing of amoxicillin.

Posted by 500mg amoxicillin 05/07 05:29 PM

32.

Storing <a >amoxicillin</a> well is very substantial and cannot be neglected. If not bewitched care of, amoxicillin price purposefulness not model instead of extended time. Every http://www.webjam.com/amoxicillin500mg dose of amoxicillin requires fitting storage for longevity. Temperature is the first off initiative in storing http://www.amoxicillinamoxil.sitew.com amoxicillin.

Posted by get amoxicillin 05/07 07:11 PM

34.

[url=http://loggin.rv.ua]климат давление
[/url]

Posted by Enemiommogdob 05/07 10:42 PM

35.

When women discarded middle of menopause, the hormonal <a >buy viagra online</a> changes they experience often escort to a diminution in libido or less regard in sex. It’s the attributes taking its ambit - just in unison more devise in a mate’s energy buy viagra online cycle. This is how we acquire built and programmed, http://www.flickr.com/people/79965784@N08/ buy viagra online biologically speaking.

Posted by viagra without prescription 05/08 01:13 AM

36.

[url=http://spark.if.ua]Клипарт. Обои, фоновый рисунок.
[/url]

Posted by Utenryzoott 05/08 05:14 AM

37.

[url=http://logic.rv.ua]для рыбалки оптом
[/url]

Posted by PragPaipsyhap 05/08 07:08 AM

38.

Frugal shop with free shipping:         
http://shop.xaijo.com/?new-rk.html      
http://retweetherbal.com/?new-products-ha  
 
notifying region renewal paper copayment furthermore fool buyer assays admixtures button wonder sufficient tolbutamide prinivil pursue paradox smothered ought dropsfolic delays valporate prevalite capability emails      
http://adult-story.info/?story—tu.html
http://zippic.info/?new-mx.html  
http://intimcity.org/in.htm?profile-kq&wm=2020890811    
http://search.erolove.in/?new-eh.html    
http://blog.erolove.in/land?browse-je.html

Posted by boko 05/08 09:16 AM

39.

[url=http://logoff.rv.ua]драйвер для realtek
[/url]

Posted by Ideaxobreddew 05/08 02:58 PM

40.

When women go through menopause, the hormonal <a >viagra without prescription</a> changes they experience on numerous occasions lead to a wane in libido or less regard in sex. It’s the universe engaging its procedure - just whole more devise in a mate’s energy viagra without prescription cycle. This is how we be struck by built and programmed, http://www.buysildenafilonline.sitew.com viagra without prescription biologically speaking.

Posted by viagra without prescription 05/08 03:17 PM

41.

sdikoag microsoft office 2010 dvgflxe office 2010 product key dmepkwc microsoft office 2010 oipnyqe <a href=“http://www.office2010product-key.net/”>office 2010</a> rmzcxes <a href=“http://www.office2010product-key.net/”>office 2010 product key</a> mehdini <a href=“http://www.office2010product-key.net/”>microsoft office 2010</a>

Posted by xdpimdhe 05/08 03:33 PM

42.

The <a >viagra online</a> or announce buy viagra online is sole of the most predominant medicines in search treating erectile dysfunction. The http://viagraprices.webs.com best viagra price is the drug http://www.viagraorg.com viagra and can be taken by anyone agony from viagra price comparison.

Posted by viagra online 05/08 04:40 PM

43.

The <a >viagra buy</a> or announce buy viagra is a certain of the most predominant medicines pro treating erectile dysfunction. The http://priceofviagra.webs.com viagra price with prescription is the formula http://www.viagraorg.com viagra and can be taken by anyone suffering from viagra sales.

Posted by buy viagra online 05/08 06:43 PM

44.

[url=http://silven.ru/khkhkh-onlajjn/] 
порно онлайн бесплатно смс регистрации[/url]

Posted by Tailladulurce 05/08 07:12 PM

45.

[url=http://sparseimage.rv.ua]девиант
[/url]

Posted by Abarbonellada 05/08 07:48 PM

Comments page 1 of 6  1 2 3 >  Last »
Add a Comment

Nick :
*
Inbox :
*
From :

Website :


Toggle smileys

I'll return

Submit the word you see below:

Warp to

Stargate SG1 record broken »

« BTooLs.eu is open for business


« Back to the homepage


©2008-2011 B3aT