Forum Archive

Show Preview

thecontinium

Hi.

I have looked high and low with no luck but this feels like it should be simple. I am trying to programmatically emulate swiping left in the editor to show the preview of a markdown file.

Is there a way to open a file in preview using a url or is there a workflow / python interface to show the file in preview ?

Cheers

omz

There is no built-in “Show Preview” action, and there isn’t really a Python interface for this either. The good news is that Editorial can call native Objective-C code, using the objc_util module, so this hack should work (via a “Run Python Script” action):

from objc_util import UIApplication, on_main_thread

@on_main_thread
def main():
    app=UIApplication.sharedApplication()
    vc=app.keyWindow().rootViewController()
    vc.showAccessoryWithAnimationDuration_(0.3)
    avc = vc.accessoryViewController()
    avc.showPreview()

main()

Caveat: This might break at some point, when I change the internals. It should be possible to adapt it though.

daveterry

Super cool. Can I ask how you’d display the file list (left slider) of the current open document? Thanks in advance.

...dave