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 - Add-Ons:
Remove Formatting


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.

 


evanbro
Novice

Jul 8, 2004, 1:20 PM

Post #1 of 8 (23827 views)
Shortcut
Remove Formatting Can't Post

A plugin I wrote that strips formatting, similar to the Midas editor in Mozilla:


Code
function initPage() { 
var editor = new HTMLArea('description', config)
editor.generate();
}
config = new HTMLArea.Config();
config.registerButton({
id: "my-strip_formatting",
tooltip: "Strip all HTML formatting",
image: "http://ebroder.net/uploads/removeformat.gif",
textMode: false,
action: function(editor, id) {
var html = new String();
html = editor.getSelectedHTML();
re = new RegExp("<\/?(abbr|acronym|b|big|cite|code| \
em|font|i|q|s|samp|small|span|strike| \
strong|sub|sup|u|var)[^>]*>", "gi");
html = html.replace(re, "");
editor.insertHTML(html);
}
});

config.toolbar[0].splice(14, 3, ["my-strip_formatting"]);


(The whole regexp is one line and without the slashes)

It matches the same elements that the Remove Formatting button does (uses the same image too). Splicing the button in removes the cut/copy/paste buttons, which are useless to me because I use Mozilla and am too lazy to alter the settings. I think it would be nice to see this included in the final version of 3.0. Works in both IE and Moz


(This post was edited by evanbro on Jul 8, 2004, 1:22 PM)


kozmoz
Novice

Jul 13, 2004, 1:38 PM

Post #2 of 8 (23752 views)
Shortcut
Re: [evanbro] Remove Formatting [In reply to] Can't Post

The strip formatting could use some refinement. When I make my selection somewhat bigger and not exact the paragraph, it splits existing paragraphs in two. The example below make things clear:


Code
<p>word1 word2</p> <p><strong>strong text</strong></p> <p>word3 word4</p>


Now when I make a selection from word2 to word3 inclusive en click the strip selection button, the new html becomes:

Code
<p>word1 </p><p>word2</p> <p>strong text</p> <p>word3</p><p> word4</p>

Rob Juurlink (rob # juurlink. org)

(This post was edited by kozmoz on Jul 28, 2004, 9:18 AM)


kozmoz
Novice

Jul 13, 2004, 2:03 PM

Post #3 of 8 (23747 views)
Shortcut
Re: [kozmoz] Remove Formatting [In reply to] Can't Post

Well, I did some investigation and found out that when the selection otherwise would contain some tags that are not closed, its adds a new tag to the selection to close the tag.

So selection 'word2</p> <p>strong text</p> <p>word3' becomes '<p>word2</p> <p>strong text</p> <p>word3</p>' automatically. I don't know how to solve this problem.

btw, I'm using Firefox 0.8
Rob Juurlink (rob # juurlink. org)

(This post was edited by kozmoz on Jul 28, 2004, 9:18 AM)


evanbro
Novice

Jul 13, 2004, 5:28 PM

Post #4 of 8 (23737 views)
Shortcut
Re: [kozmoz] Remove Formatting [In reply to] Can't Post

Ok. That's not my code, except possibly the last line of it where it replaces the value. That's the Mozilla super-editor "fixing" HTML that it shouldn't be fixing. I don't know what I could to about that.


jameslarking
New User

Jul 28, 2004, 9:03 AM

Post #5 of 8 (23602 views)
Shortcut
Re: [evanbro] Remove Formatting [In reply to] Can't Post

Hi, not sure if I am being dumb here but where does this code go?


kozmoz
Novice

Jul 28, 2004, 9:17 AM

Post #6 of 8 (23598 views)
Shortcut
Re: [jameslarking] Remove Formatting [In reply to] Can't Post


In Reply To
Hi, not sure if I am being dumb here but where does this code go?

Doesn't really matter where exactly. Put it somewhere where the 'config' object is available and before the HTMLArea widget is created. You can add it to htmlarea.js if you like.
Rob Juurlink (rob # juurlink. org)

(This post was edited by kozmoz on Jul 28, 2004, 9:18 AM)


jameslarking
New User

Jul 28, 2004, 9:25 AM

Post #7 of 8 (23592 views)
Shortcut
Re: [kozmoz] Remove Formatting [In reply to] Can't Post

thanks Smile


JCollum
Novice

Nov 19, 2004, 2:45 PM

Post #8 of 8 (22741 views)
Shortcut
Re: [jameslarking] Remove Formatting [In reply to] Can't Post

Can someone put up a complete sample (as an attachment) that shows how to do this? I've tried it and I'm not having much success...

 
 
 


Search for (options)