Anyone struggle with editing larger chunks of text in Shortcuts? Perhaps this may be of interest?
Over on the Drafts forum there was a tangential question recently about using Drafts as an editor for long text mid-Shortcuts custom shortcut. Unfortunately that didn’t quite fit with the functionality and purpose of the app. There’s certainly possibilities where a kludge could be applied to work around it, but it wasn’t ideal. I wondered if I could come up with an alternative and here’s what I came up with.
The Underling Issue
Shortcuts just doesn’t really lend itself to text editing. You can load some content into the Ask for Input field, but you don’t get a lot of space to work with.
The original poster was trying to work with an XML file. Hardly the best place to be editing something like that.
What I came up with seems to work and was much simpler than I’d expected.
And here’s the custom shortcut to demonstrate it.
Example - Scriptable Basic Editor
A Bit More Detail
When the example shortcut is run it downloads a text file from the Internet. It then displays this in an Ask for Input action for editing. The resulting text is then URL encoded and passed as a parameter called content to the Basic Editor script in Scriptable.
This script grabs the content parameter (implicitly decoded), and places this into an HTML string. Specifically so that it is the default text for a text area named taEditor.
The HTML is then rendered in a Scriptable web view and where you can modify the text in a reasonably large text field. Note that I’ve set this to be a comfortable size in landscape on my 9.7" iPad. If you run this on a different size and/or orientation, you’ll probably want to tweak the height and weight for the text area in the CSS style above. I’m sure this can actually be made more dynamic, but my CSS is rusty and it’s late Friday evening here in the UK; a challenge for another day.
This content is then URL encoded and passed back on the x-success x-callback URL as a parameter called result.
The custom shortcut then picks up the baton once again, extracts the result parameter value, URL decodes it, and then simply displays it in a Quick Look action.
This idea of building a web page to interact with and pass results back to Shortcuts seems pretty useful to me. This is a relatively basic example, but you could build practically any sort of web based user interface you like and pass results back to Shortcuts.
Even if you just make use of this, you can tailor the web page so that the text area uses your preferred font and font size, the colours are appealing, etc.
Hopefully this’ll help a few people out with their text capture for Shortcuts or provide some idea around other Shortcuts : Scriptable integrated automations.