Vaadin 6 : RichTextArea and remove formatting

220 Views Asked by At

It's been a while that I've been reported about a problem on the software I'm on charge. I will try to explain it as much detailed as possible (Sorry if my english seems bad to you by the way ^^').

Context : The software has been developed as a Web Application (Java EE) + the framework Vaadin 6 (not 7). Since this project exists for about 4 or 5 years, the technology used isn't the newest but it's currently ok. This software is used by our internal clients so about a 70 users are using it per day. I'm on charge of this project for 9 months now.

Problem : Often, users copy some info (words, tables and so on) from others sources like a Word Document, or a PowerPoint. Then paste it into a RichTextArea. then they export all those info into an Excel (XLS) file. But sometimes, those pasted info aren't reported, or generate some HTML Tags (not understandable for most users).

What I had suggested : The RichTextArea has some tools, displayed with buttons, one of them is "Remove Formatting", if they press it, everything would be ok. But I had to agree with them, it isn't intuitive and "friendly" to use. Since they are my clients, I want to help them as much as possible.

What I want : I want that if they copy paste into the RichTextArea:

  • They should be invited to remove the format (with a notification on paste) by pressing the Remove Formatting Button, so I should valorize it.
  • Or automatically apply the remove formatting on paste.

But I couldn't achieve those solutions because I don't know how to detect the action of pasting, moreover, for the second solution, I couldn't retrieve on the code the remove formatting action.

Can you help me in order to achieve this please? Any tips that doesn't involve an other technology would be appreciated :)

Aynath

1

There are 1 best solutions below

0
On

If this is still relevant:

Not sure about the first approach. But the first thing that comes to my mind is to use usual change event. When user will paste the new text, you will be notified that values were changed. Then use any tool to clean HTML and get the simple text (I suggest to use something like jsoup because it is the easiest thing). Or, if you need something specific implement your own parser/cleaner. The last thing is to simply set a new text to the current area value.

Otherwise, you can use Vaadin add-ons which may provide such information. Just look for add-ons repository for CKEditor or TinyMCE Editor