Loading ...
Sorry, an error occurred while loading the content.

YUI SimpleEditor: Where is the Paste Event?

Expand Messages
  • jsmith200046
    I m using the SimpleEditor and wanted to do a transformation when the user pastes text in. In other words (for instance), if the user pasted the text ABC , I
    Message 1 of 6 , Jan 2, 2009
    • 0 Attachment
      I'm using the SimpleEditor and wanted to do a transformation when the
      user pastes text in. In other words (for instance), if the user pasted
      the text "ABC", I want to be able to have the editor receive the text
      "XYZ".

      I assume there must be an event in the editor I can listen for like
      onbeforepaste. I haven't found it, though. Can anyone give me a quick
      sample of how to do this?

      Thanks in advance,
      Jay
    • Dav Glass
      Jay -- There is no paste event: Opera fails to give an event. Firefox doesn t allow access to the pasted content. Safari does weird things ;) So it s not
      Message 2 of 6 , Jan 2, 2009
      • 0 Attachment
        Jay --

        There is no paste event:
            Opera fails to give an event.
            Firefox doesn't allow access to the pasted content.
            Safari does weird things ;)

        So it's not possible from JavaScript to get a standard paste event.

        Dav

        --
        Dav Glass
        davglass@...
        blog.davglass.com


        + Windows: n. - The most successful computer virus, ever. +
        + A computer without a Microsoft operating system is like a dog
           without bricks tied to its head +
        + A Microsoft Certified Systems Engineer is to computing what a
          McDonalds Certified Food Specialist is to fine cuisine  +


        On Fri, Jan 2, 2009 at 2:27 PM, jsmith200046 <jsmith200046@...> wrote:

        I'm using the SimpleEditor and wanted to do a transformation when the
        user pastes text in. In other words (for instance), if the user pasted
        the text "ABC", I want to be able to have the editor receive the text
        "XYZ".

        I assume there must be an event in the editor I can listen for like
        onbeforepaste. I haven't found it, though. Can anyone give me a quick
        sample of how to do this?

        Thanks in advance,
        Jay


      • cjavajim
        ... How about using a plain TEXTAREA? With that, all the user has to do is just select some text (not even copy it to the clipboard!) and drag it to the
        Message 3 of 6 , Jan 3, 2009
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, "jsmith200046"
          <jsmith200046@...> wrote:
          >
          > I'm using the SimpleEditor and wanted to do a transformation when the
          > user pastes text in. In other words (for instance), if the user pasted
          > the text "ABC", I want to be able to have the editor receive the text
          > "XYZ".
          >
          > I assume there must be an event in the editor I can listen for like
          > onbeforepaste. I haven't found it, though. Can anyone give me a quick
          > sample of how to do this?
          >
          > Thanks in advance,
          > Jay
          >

          How about using a plain TEXTAREA? With that, all the user has to do is
          just select some text (not even copy it to the clipboard!) and drag it
          to the TEXTAREA. Then use the standard DOM events to change the text.
        • jsmith200046
          Thanks for the speedy reply, Dav. Is there a practical workaround? For instance, the two approaches I can think of are to either capture each time anything
          Message 4 of 6 , Jan 5, 2009
          • 0 Attachment
            Thanks for the speedy reply, Dav.

            Is there a practical workaround? For instance, the two approaches I
            can think of are to either capture each time anything changes in the
            editor (although that is probably impossible given the answer below),
            and running a timer once a second to see if the prohibited text was
            entered.

            The second approach seems like it has the potential to drop the user's
            input if they are typing when the timer goes off. Also, that is a bit
            of processing penalty for a border case.

            --- In ydn-javascript@yahoogroups.com, "Dav Glass" <davglass@...>
            wrote:
            >
            > Jay --
            >
            > There is no paste event:
            > Opera fails to give an event.
            > Firefox doesn't allow access to the pasted content.
            > Safari does weird things ;)
            >
            > So it's not possible from JavaScript to get a standard paste event.
            >
            > Dav
          • Dav Glass
            Jay -- The best way is to add a button to the toolbar for paste and have it open a textarea to allow access to the content that was pasted.. Does that make
            Message 5 of 6 , Jan 5, 2009
            • 0 Attachment
              Jay --

              The best way is to add a button to the toolbar for paste and have it open a textarea to allow access to the content that was pasted..

              Does that make sense?
              Dav

              --
              Dav Glass
              davglass@...
              blog.davglass.com


              + Windows: n. - The most successful computer virus, ever. +
              + A computer without a Microsoft operating system is like a dog
                 without bricks tied to its head +
              + A Microsoft Certified Systems Engineer is to computing what a
                McDonalds Certified Food Specialist is to fine cuisine  +


              On Mon, Jan 5, 2009 at 7:24 AM, jsmith200046 <jsmith200046@...> wrote:

              Thanks for the speedy reply, Dav.

              Is there a practical workaround? For instance, the two approaches I
              can think of are to either capture each time anything changes in the
              editor (although that is probably impossible given the answer below),
              and running a timer once a second to see if the prohibited text was
              entered.

              The second approach seems like it has the potential to drop the user's
              input if they are typing when the timer goes off. Also, that is a bit
              of processing penalty for a border case.

              --- In ydn-javascript@yahoogroups.com, "Dav Glass" <davglass@...>
              wrote:


              >
              > Jay --
              >
              > There is no paste event:
              > Opera fails to give an event.
              > Firefox doesn't allow access to the pasted content.
              > Safari does weird things ;)
              >
              > So it's not possible from JavaScript to get a standard paste event.
              >
              > Dav


            • jsmith200046
              ... open a ... That does, but it won t quite work for me. The user can still drag and drop text into the control and also right click then Paste. I do have a
              Message 6 of 6 , Jan 6, 2009
              • 0 Attachment
                --- In ydn-javascript@yahoogroups.com, "Dav Glass" <davglass@...>
                wrote:
                >
                > Jay --
                >
                > The best way is to add a button to the toolbar for paste and have it
                open a
                > textarea to allow access to the content that was pasted..
                >
                > Does that make sense?
                > Dav
                >

                That does, but it won't quite work for me. The user can still drag and
                drop text into the control and also right click then Paste.

                I do have a work around for my case, though. My task is to transform
                links into something else. I can simulate what I'm trying to do with
                CSS in the editor, then I can post-process the user's input.

                Thanks for the great editor! I just switched from tinyMCE.
              Your message has been successfully submitted and would be delivered to recipients shortly.