jHtmlArea - WYSIWYG HTML editor for jQuery

Author Message

Rocket Man
Posts: 302
Posted on: 2014-03-18 14:37:02.000
Just found this, it's pretty cool:
http://jhtmlarea.codeplex.com/

It lets you turn any <textarea> in your code into a full-fledged WYSIWYG text editor. It translates everything into HTML. You can even do rich copy/paste from Excel, Word, PowerPoint, another web page, or Google Docs.

I've just tested it and it works perfectly in Rockets.

Of course, there are some caveats-- the HTML that you get from copying from Word or Google Docs is basically unreadable by humans, and of course you don't want to let people embed HTML into their posts anyway because of cross-site scripting issues. Rockets (the blog) right now strips out all HTML code for safety.

But if you just input the raw HTML as $POST data and manipulate it afterwards, it could be a very useful way to let people enter rich text into, say, a content management system.

xerxes
Posts: 86
Posted on: 2014-03-27 13:32:11.000
Hi Rocket-man, did you use it for comments (this textarea doesn't have any menus for formatting), or where is it in newLISPonrockets.com?

Most of the posts I've read on the web are from people who are struggling to use it: you have evidently had no problem :) When you say it can import text from Word, is it only HTML that it strips out? I ask this, because I've done a fair amount of programming in Word, but not recently, and I know the new Excel .xlsx (you can see this if you rename it to .zip & unzip it) format is really a zipped file containing a bunch of mainly XML files. So, I am expecting that Word has gone the same way. Looking at the Excel XML files shows the markup, but at the bottom somewhere there is binary formatting happening. So,
1) don't you get non-HTML stuff as well, and
2) if so, does Rockets strip those hairy characters out as well?

cheers

Rocket Man
Posts: 302
Posted on: 2014-03-27 16:27:14.000
Hi Xerxes,

It's not being used on newLISPonrockets.com at the moment. It's just something I'm testing on a project I'm working on (the project runs on Rockets, but it's not visible to the public).

I'll write up a post on how I integrated it into a Rockets page, though... it wasn't that hard. Just needed to load a Javascript library and call it via jQuery.

The neat thing that it does is that when you copy/paste from Word, even though the Word file is saved as .docx (the XML format) or even .doc (the old binary format), it doesn't matter. The very act of copy/pasting translates it instantly into HTML. I know; it was kind of an OMG WHAT moment for me too.

So you don't get non-HTML characters at all. You get the same HTML that you would get if Word had saved it as HTML format, but there's no saving required. Just copy/paste. It's all instant.

Now, the HTML is really ugly. It's full of crap and garbage formatting nonsense, but it's still valid HTML.

And it's really easy to do some (replace) commands with regular expressions to strip that out (which I've also done) leaving only nice, pristine HTML.

I'll do a blog post on it when I get a chance.

xerxes
Posts: 86
Posted on: 2014-04-01 01:08:34.000
"OMG WHAT moment" indeed - I work all the time in Office with VBA (even using it for web-scraping), and this appears to be something I could REALLY use.

Looking forward to the details, thanks


Views: 2169