chockenberry / Provisioning

A Quick Look plug-in for .mobileprovision files
1.55k stars 67 forks source link

There is no way to copy the raw plist data to the clipboard. #1

Closed chockenberry closed 11 years ago

chockenberry commented 11 years ago

I'd like to have way to copy the raw plist data in the .mobileprovision file to the clipboard. Unfortunately, I can't find a way to do this with the HTML presented in com.apple.quicklook.satellite process (the thing that the Quick Look daemon uses to display the HTML for the preview.)

Things I've tried:

The only thing I can think of is copying the data to NSPasteboard at the time the preview is generated. Since there would be no user action prior to this happening, using the plug-in would effectively destroy any current clipboard contents. Not good.

If anyone has any other suggestions, I'd love to hear them.

jxpx777 commented 11 years ago

Maybe I’m not understanding 100% but I think text selection in Quick Look is off by default.

command-tab commented 11 years ago

Just spitballing here: Could the process that generates the HTML also inject JavaScript that, when executed within the HTML, trigger an event back in the parent to copy the plist data to NSPasteboard? I don't know offhand if you can trigger native calls from JavaScript like that, but perhaps.

jxpx777 commented 11 years ago

Definitely possible to wire up a Javascript object in the code runner to point back into the Obj-C code. 1Password's new import scripts are written in Javascript and wired to Cocoa like this.

jxpx777 commented 11 years ago

The JavascriptCore Headstart doc has info about wiring some of this stuff up. Not sure if click event handlers are propagated by default, but if so, you could create a link or button element, wire up its click event to a function that calls some hook back into the Obj-C class that set the whole thing in motion.

atirip commented 11 years ago

You said twice - in Quick Look web view and textarea - that text can't be selected. Please be more specific.

chockenberry commented 11 years ago

@atirip As @jxpx777 said, the default setting in the Quick Look web view is to disallow text selection: http://www.macworld.com/article/1164668/select_and_copy_text_within_quick_look_previews.html

chockenberry commented 11 years ago

@commandtab By the time the HTML is rendered in the web view, there's no link back to the Cocoa code that could do anything with NSPasteboard.

chockenberry commented 11 years ago

@jxpx777 Yes, events in JavaScript can be propagated back to Objective-C code. But in this case, the code that generates the HTML is long gone (the webview is actually displayed in a separate com.apple.quicklook.satellite process. ) The Cocoa code that generates the preview is run from the quicklookd process.

Also, thanks for the link about text selection being off by default. Unfortunately, since this code is running in the sandbox, I can't read that setting and change the layout dynamically (see issue #2 for details.)

atirip commented 11 years ago

What I meant was that one can always select text/DOM with Javascript.

chockenberry commented 11 years ago

@atirip Sure, you can select the text. But then what?

You can't right click on it and select "Copy". And there doesn't appear to be a way to modify the clipboard once the text is selected (the clipboardData object can only be queried after the copy event caused by user interaction.)

atirip commented 11 years ago

I have no idea on how it is done there. On a webpage this means somebody has canceled mouse events on right click. Maybe the selection preventing is also done that way - the best is to cancel mousedown. One can try to add mousedown listener to document (topmost element) with capture set to true and then call stopPropagation in hope that those cancelling handlers get never called. But this would be a hack, not solid solution.

chockenberry commented 11 years ago

I'm going to close this issue. I added a link to the article that @jxpx777 provided in both the preview and the setup instructions.