Closed Thread Icon

Topic awaiting preservation: HTML rich text editor (from archived thread) (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=27597" title="Pages that link to Topic awaiting preservation: HTML rich text editor (from archived thread) (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: HTML rich text editor (from archived thread) <span class="small">(Page 1 of 1)</span>\

 
H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-06-2006 01:27

I was searching around for some info and came acrross this archived bit of discussion.
http://www.ozoneasylum.com/18264?threadOption=noPages

Currently I have a small rich text editor and have been using the method DmS described (with execCommand etc). The limitation of this being IE only, otherwise it works quite well.

What I am curious about is the method below which pugzly used... was just wondering how (if at all) it could handle overlapping tags etc. For example using the execCommand method, if we have a string.

"This is a test String"

if I was to highlight String and bold it ("This is a test String") then the html behind it would have <b>String</b>

If however i then went and highlighted the whole string and applied bold, using execCommand it adjusts the HTML automatically and you would still only have one set of <b> tags - which is fine. <b>This is a test String</b>


With the method below however, from what i can tell, you would end up with <b>This is a test <b>String</b></b> , doubling up on the tags. Am I thinking correctly with this, or am I missing something?

The code pugzly suggested is below:

quote:
All we do is make a textarea with the body of the article in it. Above the textarea are various buttons such as

<input type="button" value="B" onclick="hiliteToBold(body);" style="font-weight: bold" title="Make the highlighted text bold." />

And that calls this simple function:

function hiliteToBold(txtArea){
txtAreaName = txtArea.name;
txtRange = document.all[txtAreaName].createTextRange();
txtContainer = txtRange.parentElement().name;
objRange = document.selection.createRange();
hiliteTxt = objRange.text;
toBoldTxt = "<b>" + hiliteTxt + "</b>";
if(hiliteTxt != ""){ objRange.text = toBoldTxt;
}
}

We have them for various effects like bold, italics, line breaks, font sizes, and smart quotes

It's simple, easy to add to, and doesn't leave the content editors in the dark.



Thanks all

DmS
Maniac (V) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 03-06-2006 11:45

Today I'd go with a complete free crossbrowser webeditor, there are a lot of them, easy to install and they work well. Thing is, they are also very similar from a functionality point of view.

It takes so much time to implement a good one yourself so if it's not for learning purposes I can't see any advantages to rolling your own full fledged web-editor.
/D

{cell 260} {Blog}
-{"Theories without facts are just religions...}-

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-08-2006 01:15

Well i'm already working on one, i have made some before using the MS Components, eventually i will want it to work in other browsers however.

I have figured out how to make a complete RTE without too much trouble, but I'm curious about editors like XStandard. They claim to produce XHTML Strict code from the start, whereas other editors clean up the code afterwards to meet whatever standards.

I'm sure its possible, just trying to figure out how to do it.

« BackwardsOnwards »

Show Forum Drop Down Menu