Prevent users pasting images / links into Edit Live

Hi,

We would like to prevent users pasting images and hyperlinks directly from the clipboard into EditLive. We have separate content types for images and external links and would like the users to use these instead.

Has anyone done this or have any ideas how we could do it?

Cheers,

Tim

Tim,

Well, if you want total control of what users paste, you can always write your own TransferHandler (by extending javax.swing.TransferHandler). But this is not for the faint of heart.

In the Ephox configuration, you have to register a new Event Listener, which listens for the LOADING_COMPLETE event. When you receive this event, find the HTML Pane ( with bean.getHTMLPane() ) and replace the Transfer Handler ( with pane.setTransferHandler() ). Your new Transfer Handler will have to look for Link and Image tags in the pasted text, and strip out anything that you don’t want pasted.

You can, of course, just remove the buttons (so that the users cannot paste links and images), but this won’t prevent them from using the shortcut keys.

Dave

Thanks Dave,

I was hoping there was a simple solution for the problem! Never mind.

I have also followed this up with Ephox and have found a solution similar to what you mention. They have an Advanced API option which allows you to write your own “Paste Filter” in Java and load the JAR into the editor. I found that by writing one of these I was able to modify what was pasted into Ephox. I have sucessfully removed hyperlinks and image tags from pasted HTML. However, the current build of Ephox only runs the paste filter if you are pasting text, not images. So it is still possible for a user to copy an image into EditLive.

I have created a thread on the Ephox forum, and they have kindly created a new build of EditLive which will run the paste filter after they capture an image and turn it into an <img> tag. More details can be found here: -
http://www.ephox.com/forums/viewtopic.php?p=1691

Hopefully this build will make it into the production build and then get into Rhythmyx at a later date. In the meantime, would I be able to substitute a Rhythmyx version of EditLive with the latest Ephox build, or do you guys have to do some magic to integrate EditLive in to Rhythmyx?

Cheers,

Tim

Tim,

It’s good to hear that Ephox is addressing this. The Paste Filter is a new feature in Ephox 6 (I believe), it wasn’t there when I last looked into this.

You can, of course, still use the lower level (TransferHandler) interface: it gives you access to everything, as it’s part of Swing, not Ephox. The downside is that you have to handle the different DataFlavor objects yourself.

I don’t know the answer to your question about updating Ephox, but I’ll go find out.

Dave

According to the developers (who are too shy to post here, I guess), once you’ve upgraded to the new EditLive 6.2, which we started shipping in 6.5.1, you can just replace EditLive with a new version.

If you are running an older release, (5.7.1, or 6.1) there is an “upgrade kit” which allows you to run the new EditLive. Once you have this kit, you can replace EditLive with a new build from Ephox.

Dave