Forum closed. New forum available at http://community.wymeditor.org/

Preserve Line Spacing

Support forum for WYMeditor.

Preserve Line Spacing

Postby Grim... on Wed Feb 10, 2010 3:36 pm

Hello there. I've had a search for this but I've found nothing - however, sorry if I'm missing something.

I basically want to preserve empty paragraphs. At the moment if I enter
Code: Select all
1
2

3


4
into my WYMeditor box it changes it to
Code: Select all
<p>1</p><p>2</p><p>3</p><p>4</p>
when I want
Code: Select all
<p>1</p><p>2</p><p></p><p>3</p><p></p><p></p><p>4</p>


How do I stop it removing the extra paragraphs / line breaks? I am happy to have a paragraph with a &nbsp; character in it, but I can't find the line in the wymeditor.js that removes them.

Cheers!
Grim...
 
Posts: 4
Joined: Wed Feb 10, 2010 3:33 pm

Re: Preserve Line Spacing

Postby Grim... on Wed Feb 10, 2010 3:43 pm

Just making a reply so I can subscribe to the thread ;)
Grim...
 
Posts: 4
Joined: Wed Feb 10, 2010 3:33 pm

Re: Preserve Line Spacing

Postby Grim... on Wed Feb 10, 2010 4:47 pm

Aha.

Changing the following
Code: Select all
WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags = function(xhtml)
{
  return xhtml.replace(new RegExp('<('+this.block_tags.join("|").replace(/\|td/,'').replace(/\|th/, '')+')>(<br \/>|&#160;|&nbsp;|\\s)*<\/\\1>' ,'g'),'');
};
to
Code: Select all
WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags = function(xhtml)
{
  return xhtml.replace(new RegExp('<('+this.block_tags.join("|").replace(/\|td/,'').replace(/\|p/,'').replace(/\|th/, '')+')>(<br \/>|&#160;|&nbsp;|\\s)*<\/\\1>' ,'g'),'');
};
solves the problem.

Hopefully someone else will find this useful.
Grim...
 
Posts: 4
Joined: Wed Feb 10, 2010 3:33 pm

Re: Preserve Line Spacing

Postby mr_lundis on Wed Feb 10, 2010 6:17 pm

Hi there!
I'm interested in why you want to keep the empty paragraphs? They add no value to your document what so ever - the removal of empty paragraphs is highly intentional. If you want to increase the margins between paragraphs, you should do so using css, and if you just want to increase space before/after a paragraph (like the third paragraph) then you can always apply a class to that element.

Or do you have some other (non presentational) reason to include empty paragraphs?

Cheers! ;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden

Re: Preserve Line Spacing

Postby Grim... on Thu Feb 11, 2010 1:47 pm

I'm afraid it's a case of client asked, I do.

I don't actually know what he wants the line breaks for, but sometimes he wants one and sometimes he wants three.

Bloody clients ;)
Grim...
 
Posts: 4
Joined: Wed Feb 10, 2010 3:33 pm

Re: Preserve Line Spacing

Postby adbox on Mon May 03, 2010 2:02 am

I am including the jquery.wymeditor.pack.js to save bandwidth so I have not tried the above, but...

When my text area has internal code content like this:

Code: Select all
Matt Khourie, who only last year joined CB Richard Ellis Investors as president, added a second role to his day-to-day duties. Khourie will also serve as chief executive officer, where his new responsibilities include managing the strategic direction and operation of the firm. He took over for Vance Maddocks, who after more than three years dividing his time between two roles, will focus on overseeing the Strategic Partners U.S. series of funds program.

Khourie has more than 30 years in the industry, most recently at CBRE Group's independent development entity, Trammell Crow Co., where he last served as president, development and investment, southeast United States. During his 29 years at TCC, Khourie worked in various positions including leadership roles that focused on investment strategy, portfolio management, development and institutional investor relations.


it looks like this
Code: Select all
Matt Khourie, who only last year joined CB Richard Ellis Investors as president, added a second role to his day-to-day duties. Khourie will also serve as chief executive officer, where his new responsibilities include managing the strategic direction and operation of the firm. He took over for Vance Maddocks, who after more than three years dividing his time between two roles, will focus on overseeing the Strategic Partners U.S. series of funds program. Khourie has more than 30 years in the industry, most recently at CBRE Group's independent development entity, Trammell Crow Co., where he last served as president, development and investment, southeast United States. During his 29 years at TCC, Khourie worked in various positions including leadership roles that focused on investment strategy, portfolio management, development and institutional investor relations.


How can I get it to display right in the editor without replacing linebreaks with <br> tags?
adbox
 
Posts: 1
Joined: Mon May 03, 2010 1:54 am

Re: Preserve Line Spacing

Postby mr_lundis on Sun May 16, 2010 12:18 pm

You could try what Grim posted above by checking out the WYMeditor source code, apply the changes locally, and then build it. See the download page for further instructions.

http://www.wymeditor.org/download/

Cheers! ;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron