Rich Text Editor

21 views
Skip to first unread message

DAZ

unread,
Jul 26, 2011, 4:16:51 PM7/26/11
to RightJS
Hi Nic,

I've just found the Rich Text Editor today and have to say it is a
brilliant piece of work. The styling and customization options make it
the best I've seen by a long way.

I just have one little issue with it - the number of <br> and <div>
tags it creates as I press enter. Is there any way to stop these?

For example if I want a list, I type it out

one
two
three

Highlight it, then click the list button, but this html gets produced:

<ul>
<li>one<br></li>
<li>two<br></li>
<li>three<br></li>
</ul>

It would be good if these <br> tags got removed as it was made into a
list.

Also it would be nice if the default when typing was to make any block
of text a paragraph once enter is pressed and then ignore the enter
that comes after.

eg.

This is paragraph 1.

This is paragraph 2.

Would automatically be formatted as

<p>This is paragraph 1.</p>
<p>This is paragraph 2.</p>

I know this is asking a lot, but is any of this at all possible?

Thanks again for this great bit of code!

cheers,

DAZ

Nikolay Nemshilov

unread,
Jul 27, 2011, 12:19:21 AM7/27/11
to rig...@googlegroups.com
Hi DAZ,

The html is getting created by a browser and varies from model to model. Plus there is a difference between starting an editor with an empty string or with '<p>something</p>'.

Generally yes, certainly it is fixable. I've already rewritten most of the browsers RTE functionality to our own engine and the controls of BR would be the next logical thing to do. But I'm buried under other projects at the moment. Maybe some day later.

--
Nikolay

> --
> You received this message because you are subscribed to the Google Groups "RightJS" group.
> To post to this group, send email to rig...@googlegroups.com.
> To unsubscribe from this group, send email to rightjs+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rightjs?hl=en.
>

--
Nikolay V. Nemshilov
The Web-Developer

DAZ

unread,
Jul 27, 2011, 3:52:33 AM7/27/11
to RightJS
No worries Nikolay, thanks for keeping it in mind.

I was thinking that these type of editors often leave a lot of
'orphaned' tags like <div></div><br><div></div> - usually at the end
(due to the user pressing enter lots of times)

How about some sort of 'clean up' function that swept these orphans
away?

I think I could do this in Ruby using an after save callback and lots
of gsub calls, but it would be nice to have it baked into the editor.

ps - what does the 'save' button do? I can't figure it out.

Thanks again,

DAZ
> > For more options, visit this group athttp://groups.google.com/group/rightjs?hl=en.

Nikolay Nemshilov

unread,
Jul 27, 2011, 4:04:30 AM7/27/11
to rig...@googlegroups.com
> No worries Nikolay, thanks for keeping it in mind.
>
> I was thinking that these type of editors often leave a lot of
> 'orphaned' tags like <div></div><br><div></div> - usually at the end
> (due to the user pressing enter lots of times)
>
> How about some sort of 'clean up' function that swept these orphans
> away?

Sure. I ended up writing most of the RTE engine from scratch because the browsers are unreliable. At the moment it handles the formatting/styles, images and so on. But I think the next step would be to cleanup the html from empty tags and make it control the new lines properly.


> I think I could do this in Ruby using an after save callback and lots
> of gsub calls, but it would be nice to have it baked into the editor.

I guess a ruby cleaner would be necessary anyways, because people might send crap some other way. Personally me I would parse it with Hpricot and rebuild back in a clean way. It also would be a good idea to nuke all the naughty tags like scripts and objects.

> ps - what does the 'save' button do? I can't figure it out.

It's simple. If the editor is on a form, then it will try to call the Form#send method to submit the form via ajax.

> For more options, visit this group at http://groups.google.com/group/rightjs?hl=en.

Reply all
Reply to author
Forward
0 new messages