How to extend a atto plugin with onpaste event?

How to extend a atto plugin with onpaste event?

by Peter Mayer -
Number of replies: 1

I'm trying to attach an on paste event in an atto plugin. For this I would like to use the yui gallery library:

YUI({
    //Last Gallery Build of this module
    gallery: 'gallery-2010.08.11-20-39'
}).use('gallery-event-pasted', function(Y) {
    var onPasted = function(evt) {
        alert('pasted!\n\nwas: "' + evt.prevVal + '"\n\nnow: "' + evt.newVal + '"');
    };
 
    // fire when any text is pasted into textfield
    Y.one('#mytextarea').on('pasted', onPasted);
 
    // fire only if pasted text changed field's value
    Y.one('#mytextarea2').on('pasted', onPasted, null, true);
});

https://yuilibrary.com/gallery-archive/gallery/show/event-pasted.html
Unfortunately, I can not get this to work.
I want to use the onpaste event similar to:

this.get('host').on('pasted', function (e) {
console.log("pasted!");
}, this);

in the initializer function of the plugin.
Can you please show me a way how to integrate the gallery method correctly!


Average of ratings: -
In reply to Peter Mayer

Re: How to extend a atto plugin with onpaste event?

by Stefan H -

Unfortunately I don't know the yuilibrary but I know some Javascript.

What exactly is the problem you are working on?
  • do you want to know where to put the code so that it gets executed?
  • do you really need the gallery method or just an on paste event listener?
  • can you provide more information about the error you are facing or where you got stuck?
You could just load the following js snippet on the page where you need it ...

let itextInputField = document.querySelector("textarea");
   itextInputField.onpaste = function(e){
     console.log("pasted");
   };