Replace selections in 1Writer

1Writer is definitely the most versatile text editor for long form available for iPhone and I'm proud to be one of the first to spot this gem wandering the App Store. Last year I explained how to integrate 1Writer with TextTool, another outstanding app released last year to replace the selected text after transformation on the latter. Today we're going to dive deeper into 1Writer and its improved workflow to replace text using other apps.

Using retParam

This is our action from last year to apply the entify method to our selected text using the clipboard:

texttool://x-callback-url/transform?text=[text]&method=entify&x-success={onewriter://x-callback-url/replace?name=[name]&path=Documents&type=local}

In this action, you must manually insert the path and type of your file, making it unreliable in a more complex organization. Now, if you grasp at the actions built-in 1Writer, you'll find te:Replace, an action you may recognize from other apps, such as Drafts, as a method to pick a different word in Terminology and replace the current selected word in the caller app.

onewriter://x-callback-url/import-action?name=Send%20to%20Drafts&url=drafts%3A%2F%2Fx-callback-url%2Fcreate%3Ftext%3D%5Btext%5D

te:Replace

terminology://x-callback-url/replace?text=[text]&retParam=text&x-source=1Writer&x-success={onewriter://x-callback-url/replace-selection}&x-cancel={onewriter://}

Terminology uses the retParam to set the word that returns to the caller, 1Writer in our case. You may find the use for this parameter on Phraseology as well, but aside from Agile Tortoise great apps, you can use this trick to tidy up your links with Clean Links.

Clean Links

clean-links://x-callback-url/clean?url=[text]&retParam=text&x-source=1Writer&x-success={onewriter://x-callback-url/replace-selection}&x-cancel={onewriter://}

Without retParam

Now the fun begins, remember the action from last year I posted a couple paragraphs behind? Well, you had to hardcode the path to the file you were working on and that’s a versatility killer until 1Writer added the replace-selection support we just saw. It fails without retParam unless you add the text parameter elsewhere — as we do here:

texttool://x-callback-url/transform?text=[text]&method=educate&x-success={onewriter://x-callback-url/replace-selection?text=[[output]]}&x-cancel={onewriter://}

This one uses the educate method to change quotes to smart quotes and dashes to hyphens. Notice how we tell TextTool to send the [[output]] as text, since it doesn’t support retParam.

Using Safari for research

Writing online leads to a lot of research, since 1Writer lacks a built-in browser, we can use the flexibility of this new workflow method to link 1Writer with Safari using an action for the previous and a bookmarklet for the latter due to its lack of x-callback-url support1.

The idea is quite simple, we’re going to send our selected text in 1Writer as a web search in Safari using the url scheme introduced by Viticci, on MacStories.

Search Safari

x-web-search://?[text]

On Safari, you can navigate until you find what you’re looking for. We’re going to use a bookmarklet to send the site we found back to 1Writer:

javascript:window.location='onewriter://x-callback-url/replace-selection?text='+encodeURIComponent('%5B%5D('+location.href+'%20%5C''+document.title+'%5C')')

This one will create an almost perfect Markdown link using the url and title of the page you send to 1Writer. Would be awesome if we could use the query again, so we could built a complete Markdown link, it could be the [text] parameter again or something like |text|, but it would be awesome to speed up our writing workflows using 1Writer.

So remember, if you enjoy using 1Writer as much as I do, this is your new best friend:

onewriter://x-callback-url/replace-selection

It works just like that with any app using the retParam parameter, for others, don't forget to attach what's the output you want:

onewriter://x-callback-url/replace-selection?text=[[output]]

Unfortunately, not so many apps support an output parameter, some even documented it (like Calca), but haven't implemented yet. I bet we'll soon have more apps to explore inter-app communication with more and more layers. It feels like yesterday when the x-callback-url library had no more than 30 apps. Now you find almost 90. Times are changing fast.


  1. You may recall Google Chrome has x-callback-url support, yet it doesn’t allow to send parameters back to the caller app, hence derailing the workflow. You can still use this into any browser with bookmarklet support.