3 Replies Latest reply on Nov 28, 2016 2:47 AM by Loic.Aigon

    Getting page item information from Drag and Drop

    rollwhistler

      Hi,

       

      I'm creating an html5 extension where you can drag page items, like rectangles or frames you placed in the document and do things with them.

       

      Right now I managed to have a drag area on my plugin that captures the drop element, but once there I don't know how to get the items data...

       

      I get this:

       

      DataTransferItem {type: "", kind: "file", getAsString: function, getAsFile: function, webkitGetAsEntry: function}

      DataTransferItem {type: "com.adobe.cep.dnd.pasteboardtype", kind: "string", getAsString: function, getAsFile: function, webkitGetAsEntry: function}

       

      Two elements instead of just one, and If I try to getAsString the pasteboard one, I just get a few data:

      "{"assetList":[{"type":"image","data":[""]}],"source":"com.adobe.indesign","version":"12.0 "}"

       

      Looking at that it seems is dragging the elements (In this case both rectangles and frames do the same) as images?

       

      Which is not what I would expect. I would expect some item data, like its ID or whatever.

       

      Which should be my approach here? what am I doing wrong?

       

      Thank you for your help and time.

        • 1. Re: Getting page item information from Drag and Drop
          Trevorׅ Adobe Community Professional

          Why don't you on receiving an item from InDesign just check what the selection of InDesign is (app.selection) loop through the selections app.selection[0] - app.selection[ app.selection.length -1 ] and get the info from InDesign?

          1 person found this helpful
          • 2. Re: Getting page item information from Drag and Drop
            rollwhistler Level 1

            Basically because I did not think about that option, thank you!.

             

            But it would be great if the dragged object would contain the element type and id or something, makes much more sense to me.

            • 3. Re: Getting page item information from Drag and Drop
              Loic.Aigon Adobe Community Professional

              I think Trevor's approach is the cleverest I can think of but just for the completeness, you can actually have some info thanks to the dataTransfer payload of the drop event.

              On mac, dropping an item onto the panel will generate a snippet into a temporary location. The url can be found using

               

              ev.dataTransfer.getData("text/uri-list") //file://some/temporary/location/snippet.idms

               

              Then you can edit that file. I use this to read at the BASE64 thumbnail of the snippet and display the representation of the selection inside the panel.

               

              However things are slightly different on Windows as it doesn't return this info for whatever reason, so not only Trevor solution is smart but it will avoid dealing with os specific issues

               

              FWIW

               

              Loic

              2 people found this helpful