htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
A possible solution to Double line breaks


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


jaypee
Novice

Jan 3, 2005, 7:41 AM

Post #1 of 6 (4102 views)
Shortcut
A possible solution to Double line breaks Can't Post

I've been browsing this forum on the problem about hitting enter causes double line break because of inserting a <p></p> tag (as it should). I read that some people argued that the users of the editor had to learn to use shift+ enter instead when single line breaks was needed. The only problem is that the average user will never learn.
Inserting <br> when hitting enter would also cause problems i.e. with lists, so that solution isn't that good either.


I have configured the stylesheet for <p> tags like suggested by other users:

editor.config.pageStyle = "address,pre,p,li,table {margin: 0 cm; margin-bottom: 0.001 pt;}"

That works allright except when you switch to HTML mode and back again (or save to the server), then all extra linebreaks are gone because of the p tag formatting. This I changed by replacing all <p /> tags by <br>. That works in IE 6.0 at least so far .
Apart from the above mentioned stylesheet change I made the following change in the getHTML function (used CVS 1.95):

// retrieve the HTML
HTMLArea.prototype.getHTML = function() {
switch (this._editMode) {
case "wysiwyg" :
if (!this.config.fullPage) {

a= HTMLArea.getHTML(this._doc.body, false, this);
a=a.replace(/<p \/>/g,"<br>");
return a;
} else
a=this.doctype + "\n" + HTMLArea.getHTML(this._doc.documentElement, true, this);
a=a.replace(/<p \/>/g,"<br>");
return a;
case "textmode" :
a= this._textArea.value;
a=a.replace(/<p \/>/g,"<br>");
return a;
default : alert("Mode <" + mode + "> not defined!");
}
return false;
};

Comments on this will be much appreciated....


yermo
Novice

Jan 15, 2005, 12:43 PM

Post #2 of 6 (3908 views)
Shortcut
Re: [jaypee] A possible solution to Double line breaks [In reply to] Can't Post

I'm finding that using wrapping <p> tags causes other very serious problems in selections. (the <strong><p>this is a test</p></strong> problem under FireFox.)

Being new to the forum, why is inserting <p> tags the correct behavior for on ENTER?

How does using <br> tags on ENTER break lists?


WoRmS
New User

Jan 31, 2005, 5:46 PM

Post #3 of 6 (3711 views)
Shortcut
Re: [jaypee] A possible solution to Double line breaks [In reply to] Can't Post

I cant get et to work in IE 6,0 Frown
Mozilla Firefox NOOO problem Smile

Any input ?


jaypee
Novice

Feb 1, 2005, 12:45 AM

Post #4 of 6 (3687 views)
Shortcut
Re: [WoRmS] A possible solution to Double line breaks [In reply to] Can't Post

What isn't working in IE 6.0? Do you get an error message? Did you apply the style configuration; it doesn't work without that?

It works perfectly in IE 6.0 for me, and copy pasting Word documents also is no problem regarding line breaks...


WoRmS
New User

Feb 1, 2005, 10:33 AM

Post #5 of 6 (3636 views)
Shortcut
Re: [jaypee] A possible solution to Double line breaks [In reply to] Can't Post

Yes i copy the code from the forum and put it ind
(htmlarea.js) line 1759
And i get no
error message ind IE or MZ.

OLD********************************************************************************

// retrieve the HTML
// HTMLArea.prototype.getHTML = function() {
// switch (this._editMode) {
// case "wysiwyg" :
// if (!this.config.fullPage) {
// return HTMLArea.getHTML(this._doc.body, false, this);
// } else
// return this.doctype + "\n" + HTMLArea.getHTML(this._doc.documentElement, true, this);
// case "textmode" : return this._textArea.value;
// default : alert("Mode <" + mode + "> not defined!");
// }
// return false;
// };

NEW*****************************************************************************

// retrieve the HTML
HTMLArea.prototype.getHTML = function() {
switch (this._editMode) {
case "wysiwyg" :
if (!this.config.fullPage) {

a= HTMLArea.getHTML(this._doc.body, false, this);
a=a.replace(/<p \/>/g,"<br>");
return a;
} else
a=this.doctype + "\n" + HTMLArea.getHTML(this._doc.documentElement, true, this);
a=a.replace(/<p \/>/g,"<br>");
return a;
case "textmode" :
a= this._textArea.value;
a=a.replace(/<p \/>/g,"<br>");
return a;
default : alert("Mode <" + mode + "> not defined!");
}
return false;
};

***********************************************************************************

Crazy www.4me2.dk


(This post was edited by WoRmS on Feb 1, 2005, 10:53 AM)


jaypee
Novice

Feb 2, 2005, 2:08 AM

Post #6 of 6 (3619 views)
Shortcut
Re: [WoRmS] A possible solution to Double line breaks [In reply to] Can't Post

Remember the stylesheet. In the file that calls the htmlarea (in this case fullpage plugin) you have to add the style like this:

function initDocument() {
var editor = new HTMLArea("ta");
editor.generate();
editor.config.pageStyle = "address,pre,p,li,table {margin: 0 cm; margin-bottom: 0.001 pt;}"

}

Did you do that?

an alternative could be:
in HTMLArea:
this.pageStyle = "address,pre,p,li,table {margin: 0 cm; margin-bottom: 0.001 pt;}";

instead of:
this.pageStyle = "";

 
 
 


Search for (options)