[kupu-dev] Pasting HTML into Kupu

George Lee georgeleejr at gmail.com
Mon Dec 4 02:31:59 CET 2006


Some more info that might help -- from
http://www.thefutureoftheweb.com/blog/2005/11/onafterpaste

"Internet Explorer has onBeforePaste and onPaste events, but no
onAfterPaste. onPaste fires when the user pastes, but before the HTML
actually goes into the editor. The idea is that the developer has a chance
to look into the clipboard using window.clipboardData.getData().
Unfortunately, you can only retrieve the contents in URL or Text format, not
HTML. Instead, it would be easier to allow the HTML to be pasted, then
process the editor contents afterwards. To accomplish this in Internet
Explorer, we can simply set a timeout in the onPaste event. This works by
allowing the browser time to finish its internal onPaste event before
executing the code in the timeout."

"Just to let you know, Mozilla supports an onInput event which can be used
for pasting. It is conveniently launched AFTER the data is pasted in to a
field."


On 12/3/06, Johnny deBris <johnny at debris.demon.nl> wrote:
>
> George Lee wrote:
> >
> > Technically how do browsers paste -- by typing in character by character
> > what's in the pasted selection? If so it seems like it'd be hard to
> > trigger an HTML cleanup since it couldn't be called after each character
> > ("<" "d" "i" "v") was inserted.
>
> In browsers, paste is a single action. In IE, certain events
> (onbeforepaste and something like onpaste or onafterpaste, or even both)
> are emitted, but not in Mozilla. I think in Mozilla it's not possible to
> automatically trigger cleanups on paste (actually spent some time
> looking at this something like two years ago, perhaps things changed,
> but as far as I know, Mozilla still only supports the 'standard', and
> not IE's extended, events).
>
> > Alternatively, is there a way to
> > override "paste" within browsers with a custom paste function?
>
> There's no hook or anything.
>
> > Or to
> > disable it and create another way like right-click, paste defined
> > through Kupu?
> >
> I'm not sure if you can disable it. I do know you can trigger paste from
> JavaScript (some execCommand call iirc), but in Mozilla it's not allowed
> by default and has to be allowed on a per-domain basis by tweaking some
> config file somewhere (the details are a little fuzzy, it's been a
> while, I just remembered it was cumbersome).
>
> >
> > Where is this code?
> >
> It's in common/kupucontentfilters.js, and if not, it was there at some
> moment so check SVN history...
>
> >
> > How does the filtering and HTML tidying of kupu, work in conjunction
> > with non-kupu users? If someone is entering HTML manually, through epoz,
> > etc., if that uses different tidying standards, then isn't this going to
> > wreak havoc as different users edit the same content with different
> > methods? Or is there a way to enforce tidying across the board -- for
> > instance using a KupuRichWidget which doesn't have to use kupu but will
> > still tidy the HTML according to the same standards whenever it is
> edited?
> >
> I'll leave this one for Duncan to answer, also because it's Plone
> related (partially, I guess the answer in general would be something
> like 'let's just hope they're all flexible enough, and at the same time
> produce clean enough results, so that they can cooperate nicely)...
>
> Cheers,
>
> Guido
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/kupu-dev/attachments/20061203/8b498cbd/attachment-0001.htm 


More information about the kupu-dev mailing list