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:
On push enter, breake line?


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.

 


rebell
New User

Oct 15, 2003, 11:44 AM

Post #1 of 9 (4435 views)
Shortcut
On push enter, breake line? Can't Post

Something like this should work, but how do I include this?



el.frameWindow.document.onkeydown = function () {
if (el.frameWindow.event.keyCode == 13) { // ENTER
var sel = el.frameWindow.document.selection;
if (sel.type == "Control")
return;

var r = sel.createRange();
r.pasteHTML("<BR>");
el.frameWindow.event.cancelBubble = true;
el.frameWindow.event.returnValue = false;

r.select();
r.moveEnd("character", 1);
r.moveStart("character", 1);
r.collapse(false);

return false;
}
};
el.frameWindow.document.onkeypress =
el.frameWindow.document.onkeyup = function () {
if (el.frameWindow.event.keyCode == 13) { // ENTER
el.frameWindow.event.cancelBubble = true;
el.frameWindow.event.returnValue = false;
return false;
}
};
}


ap49
Novice

Oct 15, 2003, 1:28 PM

Post #2 of 9 (4418 views)
Shortcut
Re: [rebell] On push enter, breake line? [In reply to] Can't Post

Hi,

Many people have tried br's instead of p's, me being one of them as i would also find it far better. I have battled for hours in many different ways, and have in some cases made it work with code that looks very similar to yours along with lots of other approaches. I have to say though that i think it is fighting a losing battle. When you do get it to insert br's it just breaks (excuse the pun) a lot of the other functions like bulleted lists as its not what the Micro$oft API is looking for i guess so their functions just dont handle it, leaving u in a bit of a mess as instead they are looking for p's. Thats just my view, but feel free to try.

Cheers


Andy


esthera
User

Sep 6, 2004, 9:45 AM

Post #3 of 9 (4100 views)
Shortcut
Re: [ap49] On push enter, breake line? & bullet feature working [In reply to] Can't Post

Did anyone find a way to use <br> and not <p> with teh bulleted feature still working?


mikan
New User

Sep 13, 2004, 8:24 AM

Post #4 of 9 (4048 views)
Shortcut
Re: [esthera] On push enter, breake line? & bullet feature working [In reply to] Can't Post

well, with a kind of different approach it seems to work:

i changed the css of the htmlarea so that p tags don't have a top or bottom margin, which turns a p tag visually into the same as an enter, but with the added p functionalities like bullet lists etc.

so, in your htmlarea.css, but in the line:

p{ margin-top: 0px; margin-bottom: 0px; }

maybe this is an old solution, but i couldn't find a mention to it anywhere on this forum...


kimastergeorge
Novice

Sep 13, 2004, 6:36 PM

Post #5 of 9 (4032 views)
Shortcut
Re: [ap49] On push enter, breake line? [In reply to] Can't Post

Well... You know that SHIFT + ENTER in Internet Explorer = line break, right? If you could somehow emulate the shift key being pressed whenever enter is pressed in IE, and the shift key not being pressed whenever enter and shift are pressed, this would probably work. Also, if it's in an ol, li, or ul tag it keeps with whatever was used.


mikan
New User

Sep 14, 2004, 3:03 AM

Post #6 of 9 (4026 views)
Shortcut
Re: [kimastergeorge] On push enter, breake line? [In reply to] Can't Post

well, actually in text editors (for instance word) there also is the same difference between <enter> and <shift + enter>. so maybe it's even desired behaviour of the editor. IE just renders the code differently from word. by changing the margins of the <p> tag through css i tried to make the editor html render the same as word.

the problem now is that if you insert a blank <enter>, it results in adding a <p /> into your html. with the top and bottom margin set to 0, this tag renders nothing. adding a display: inline-block; to the css of the <p> tag does fix this, but then the editor screws up thinking all paragraphs are blocks instead of inlines. somehow replacing the <p /> tags with <p>&nbsp;</p> when entering the editor and changing it back to <p /> after submitting might solve this though, but i haven't tried it yet.


giodex
New User

Nov 22, 2004, 8:21 AM

Post #7 of 9 (3703 views)
Shortcut
Re: [rebell] On push enter, breake line? [In reply to] Can't Post

Hi everyone

This is my solution:

I've added an icon on a toolbar to save content, like this:

this.toolbar = [
["save", ...

after I've added this line

this.btnList = {
save: [ "Save", "ed_save.gif", false,
function mySubmit() {
document.edit.onsubmit();
document.edit.submit();
}],

This is instead of submit button.

In br tag function, that in my code is like this:

else if (keyEvent) {
// other keys here
switch (ev.keyCode) {
case 13: // KEY enter
if (HTMLArea.is_ie) {
this.insertHTML("<br><!--§-->");
HTMLArea._stopEvent(ev);
}
break;
}
}

i've added a control tag:

<!--§-->

this is a comment that help tag br to insert a break line (please search an old post in this forum to more info)

in the end I've modified my save function like this:

function mySubmit() {
document.edit.onsubmit();
var GG = document.getElementById('editor').value; //this get textarea content
GG = GG.replace(/<!--§-->/ig, ""); //this replace my control tag with nothing
document.getElementById('editor').value = GG; //now the textarea content is clean
document.edit.submit();

I hope that this solution can be useful ....

bye

giodex
Attachments: ed_save.gif (0.49 KB)


scott_sauyet
Novice

Jan 14, 2005, 8:54 AM

Post #8 of 9 (3334 views)
Shortcut
Re: [mikan] On push enter, breake line? & bullet feature working [In reply to] Can't Post


In Reply To
so, in your htmlarea.css, but in the line:

p{ margin-top: 0px; margin-bottom: 0px; }


This doesn't make any difference for me. Has anyone else gotten this to work?

-- Scott


scott_sauyet
Novice

Jan 14, 2005, 12:37 PM

Post #9 of 9 (3325 views)
Shortcut
Re: [scott_sauyet] On push enter, breake line? & bullet feature working [In reply to] Can't Post

I wrote:

In Reply To

In Reply To
so, in your htmlarea.css, but in the line:

p{ margin-top: 0px; margin-bottom: 0px; }


This doesn't make any difference for me. Has anyone else gotten this to work?


I don't know why I didn't see the solution before, but you can change this, by adjusting the config.pageStyle, e.g.

Code
    config.pageStyle="[.. whatever ...] p {margin:0;}"


It really is easy, and I know I've messed with this before, so I have no excuse for not remembering, except that htmlarea.css is such a tempting target.

-- Scott

 
 
 


Search for (options)