htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
07/21 LUIS or EVERYONE: This is a challenge for you experts!


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.

 


markulius99
Novice

Jul 21, 2004, 3:27 PM

Post #1 of 3 (7546 views)
Shortcut
07/21 LUIS or EVERYONE: This is a challenge for you experts! Can't Post

Hi LUIS and EVERYONE:
I have an issue that I would like to implement that might not be too hard for you experts:

-On WYSIWYG mode I have something like this:

Apple
Orange
Banana

*Note that I used shift+enter to create break lines <br>

The htmlcode will look like:
<br>Apple
<br>Orange
<br>Banana

-The function that I want to implement will (still on WYSIWYG) allow the user to hightlight that area and click on a button in order to replace every instance of <br> to <p> (Tags that I'm using are just a reference)

QUESTION: Is there a way to do that? I mean highlight ONLY a specific area and modify
the internal html code?

After highlighting and clicking that button my result on HTMLmode will be like:
<p>Apple
<p>Orange
<p>Banana

REFERENCES: My research tells me that I have to use something like the getSelection function and editdoc.body.createTextRange(). Then I have to assign it to variable (like 'contents' on editor.js)
and use 'contents.replace'
I have the idea but I don't know how to put everything together neither I'm sure if that's the way to manipulate the internal HTML code

THANKS IN ADVANCE

MARKULIUS


Luis
Veteran

Jul 22, 2004, 8:31 PM

Post #2 of 3 (7509 views)
Shortcut
Re: [markulius99] 07/21 LUIS or EVERYONE: This is a challenge for you experts! [In reply to] Can't Post

Hi markulius99:

Sure it's possible. I'll send you an example hopefully this weekend.

greetings


Don't give up!!
http://webstationone.com/test/htmlarea


Luis
Veteran

Jul 24, 2004, 3:37 PM

Post #3 of 3 (7456 views)
Shortcut
Re: [markulius99] 07/21 LUIS or EVERYONE: This is a challenge for you experts! [In reply to] Can't Post

Hi Markulius99:

This is pretty simple.

Create a button to call the following function (I assume you already know how) and add it to editor.js:

else if (cmdID.toLowerCase() == 'changetag') {
var Txt = editdoc.selection.createRange().htmlText;
Txt='<P>'+Txt; //Add a <P>tag at the beginning of the string.
Txt = Txt.replace(/<BR>/gi, '<P>');//Change selected <BR>'s to <P>'s
Txt = Txt.replace(/<P><P>/gi, '<P>');// if first thing in string already was a <P> tag, remove duplicate.
if (Txt) { editor_insertHTML(objname, unescape(Txt) ); }
}


Greetings


Don't give up!!
http://webstationone.com/test/htmlarea

 
 
 


Search for (options)