omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Show Preview

    Editorial
    3
    3
    2416
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thecontinium
      thecontinium last edited by

      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

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • daveterry
          daveterry last edited by daveterry

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

          ...dave

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors