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:
[plugin] <P> vs <BR> - put this in your pipe and smoke it...


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.

 


Hipikat
User

Jan 18, 2005, 10:53 PM

Post #1 of 7 (4114 views)
Shortcut
[plugin] <P> vs <BR> - put this in your pipe and smoke it... Can't Post

Well, the topic's been started on this forum at least two dozen times, so this makes two dozen and one. I wrote the original EnterParagraphs plugin and have basically re-written it. It's bigger, bolder, and better than any other solution out there as far for not blowing up markup, while getting pretty Ps, is concerned.

Don't know what I'm talking about? Basically, Mozilla related browsers have always just stuck in a line break instead of fiddling paragrah (P) tags, when you hit enter. Trying to get a nice solution has caused worlds of pain for many innocent web programmers.

Do know what I'm talking about? There's more information and another link to the package, at the example page below. It's a plugin, so just install, load and register.

http://sisyphus.uwa.edu.au/test/paragecko/htmlarea-041129/examples/para.html

Discuss.
Attachments: EnterParagraphs.050119.tgz (4.16 KB)


sleemanj
User

Jan 19, 2005, 1:37 AM

Post #2 of 7 (4096 views)
Shortcut
Re: [Hipikat] [plugin] <P> vs <BR> - put this in your pipe and smoke it... [In reply to] Can't Post

Hi Hipikat,

you might have seen in the thread about my fork some discussion regarding a function that came out of the CVS that seemed to do the same thing as EnterParagraphs. And that it was broken, and that I fixed it.


I just wondered, what EnterParagraphs plugin does that is not (now, after I fixed the broken function) done in my fork without EnterParagraphs turned on.

You can see an example of my fork running here (click) (without EnterParagraphs).

I just want to know if EnterParagraphs is no longer useful within my fork (it's currently still in the package), or wether it adds something more, or does it better.

Thanks for your time.

PS: In my fork, the function that does the paragraph magic is "dom_checkInsertP", you can grab htmlarea.js here (click) if you want to have a look how it works.


James Sleeman
PHP Programmer


Hipikat
User

Jan 19, 2005, 7:03 PM

Post #3 of 7 (4061 views)
Shortcut
Re: [sleemanj] [plugin] <P> vs <BR> - put this in your pipe and smoke it... [In reply to] Can't Post

At first glance...

When selecting between the content of two <div>s before {enter}, both resulting <div>s are selected afterwards, and the caret lands in the <body>, between them instead of inside the start of the second <div>.

Likewise, {enter} from inside a <dt> (or <dd>) results in two <dt>s (or <dd>s), and the caret illegally in the <dl>, between them

Hitting {enter} inside content which is the direct child of a <td> wraps all of that content in a <p> and creates another <p> after it with the caret inside, but doesn't actually split the content where the caret was upon {enter} at all.

Check that, it happens wherever content isn't already wrapped in a <p> or *certain* other block level elements. I would imagine that best practice would be treating all block level containers which may contain <p>s the same way you'd treat the <body> - but your method will, for example, just keep creating more <div>s if you keep hitting {enter} from inside one

Your method illegally duplicates ID attributes if one {enter}s from within a <div> or <p> (and presumably other elements) that has one

With {enter}ing from inside inline elements, it seems to be at least making the mistake of, if code is of the form <p><span>content{caret}content</span></p>, landing after an {enter} like <p><span>content</span></p><p>{caret}<span>content</span></p>, rather than having the caret sink through all the inline elements to rest against the start of the second content

I could go on, if you'd like...
Edge cases are what DOM hacking is all about :)


sleemanj
User

Jan 19, 2005, 11:06 PM

Post #4 of 7 (4055 views)
Shortcut
Re: [Hipikat] [plugin] <P> vs <BR> - put this in your pipe and smoke it... [In reply to] Can't Post

So, to summarise, the EnterParagraphs plugin is much better than my half-hearted attempt ;) That's cool, I only fixed up the code that Mishoo had written in dom_checkInsertP to work a bit better, I only spent a couple of hours on it :)

My question is, how hard do you think it would be to take your plugin and roll it into my fork (or official htmlarea once itools decides on it's future), right in the core, basically replacing dom_checkInsertP. I think it's a worthwhile thing and it's obviously a significant improvement over what either Mishoo or I have done.

Would you be interested in looking at doing that? If not would you be ok with me doing it?


James Sleeman
PHP Programmer


Hipikat
User

Jan 20, 2005, 1:02 AM

Post #5 of 7 (4044 views)
Shortcut
Re: [sleemanj] [plugin] <P> vs <BR> - put this in your pipe and smoke it... [In reply to] Can't Post

Yeah, I tried hacking dom_checkInsertP for a while, too. When I first saw it I thought 'Oh no! much more consice than EnterParagraphs!'. And in hindsight, I really wish I had been trumped, because now I'm convinced that this most simple sounding of problems has no simple solution... At least with the current state of Gecko's DOM.

Before I put anything in the core, I'd argue that it probably belongs as a plugin more. Functionally, it should be in the core, sure, but it is bloated - 12k for optional behaviour, plus the processing involved.

This would be pure pedantry, but I'm in a University environment where some people have very old machines, and I would assume there are all sorts of light weight web apps htmlArea might be nice for, and the internet's an even more diverse environment. On the other hand, htmlarea.js is over 80k itself, so just ignore me :)

Also why not, is that EnterParagraphs is still far from perfect, as I say, so why get rid of good old reliable <br />s, when there could be a lot of weird content out there, which could still explode if the default behaviour became this hack...

Anyway, you can officially do whatever you want with it. I don't really have time to do anything else with it any time in the near future (my tickets, they overflow).


sleemanj
User

Jan 20, 2005, 2:09 AM

Post #6 of 7 (4038 views)
Shortcut
Re: [Hipikat] [plugin] <P> vs <BR> - put this in your pipe and smoke it... [In reply to] Can't Post


In Reply To
At least with the current state of Gecko's DOM.


Just as well IE works in the expected manner. I think it would have been nigh impossible with IE's dom, thier selection and range interfaces just aren't up to speed I think.


In Reply To
but it is bloated - 12k for optional behaviour, plus the processing involved.


Ahh, ok I didn't realise it was so big (should have looked first). Right. I think it does deserve to be the default behaviour, because it is better than Moz's whacked out enter-br behaviour. But not at the expense of 12kb of code.


In Reply To
On the other hand, htmlarea.js is over 80k itself, so just ignore me :)


Yes, htmlarea.js needs some cleaning up (I'm sure there is redundant code, things like searching arrays, commented out blocks...). Probably should generate one of those 'compressed' javascript versions, I'd like to see it drop to ~50k maybe.

What I'll do is leave it as a seperate plugin, but I'll treat it a bit special with a config variable, say

HTMLArea.Config.prototype.moz_para_behaviour

a value of 'default' will be the standard enter-br, a value of 'best' will be your plugin (which gets auto-loaded & registered), and a value of 'quick' will be dom_checkInsertP.

I probably will move it somewhere special other than plugins/EnterParagraphs.


James Sleeman
PHP Programmer


sleemanj
User

Jan 20, 2005, 11:19 AM

Post #7 of 7 (4015 views)
Shortcut
Re: [Hipikat] [plugin] <P> vs <BR> - put this in your pipe and smoke it... [In reply to] Can't Post

Hi hipikat. I've put this latest version into my fork. I have made one miniscule change which you might want to put into your copy, it just scrolls the carat into view when you hit enter. Otherwise when you hit enter at the bottom of the editor the carat drops out of sight until you hit another key.

on line 257,


Code
editor.scrollToElement(holdEnd);


this uses a function in my fork (which is currently gecko only, but good enough for now).


Code
HTMLArea.prototype.scrollToElement = function(e) 
{
if(HTMLArea.is_gecko)
{
var top = 0;
var left = 0;
while(e)
{
top += e.offsetTop;
left += e.offsetLeft;
if(e.offsetParent && e.offsetParent.tagName.toLowerCase() != 'body')
{
e = e.offsetParent;
}
else
{
e = null;
}
}
this._iframe.contentWindow.scrollTo(left, top);
}
}



James Sleeman
PHP Programmer

 
 
 


Search for (options)