|
| 1 | +--- |
| 2 | +layout: doc |
| 3 | +--- |
| 4 | + |
| 5 | +<script setup lang="ts"> |
| 6 | +import { ref, computed } from 'vue'; |
| 7 | +import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue'; |
| 8 | +import { open, newFile, quickSearch } from 'protocol-launcher/ia-writer'; |
| 9 | +import { SelectInstallationMethod } from '../../.vitepress/components'; |
| 10 | +import { openParams, newFileParams, quickSearchParams } from '../../.vitepress/constants/ia-writer'; |
| 11 | + |
| 12 | +const currentMethod = ref('On-Demand'); |
| 13 | +const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/ia-writer' : 'protocol-launcher'); |
| 14 | +</script> |
| 15 | + |
| 16 | +# iA Writer |
| 17 | + |
| 18 | +[iA Writer](https://ia.net/writer) is a focused writing app for macOS, iPadOS, and iOS. **Protocol Launcher** allows you to generate iA Writer URL Commands with the `ia-writer://` scheme and x-callback-url support. |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +There are two ways to use this library: |
| 23 | + |
| 24 | +- On-Demand import from subpaths enables tree-shaking and keeps bundles small. |
| 25 | +- Full Import from the root package is convenient but includes all app modules. |
| 26 | + |
| 27 | +Pick On-Demand for production builds; Full Import is fine for quick scripts or demos. |
| 28 | + |
| 29 | +<SelectInstallationMethod v-model="currentMethod" /> |
| 30 | + |
| 31 | +### Open Document |
| 32 | + |
| 33 | +Opens Editor with an existing document if found, or a new empty document. |
| 34 | + |
| 35 | +```ts-vue [{{currentMethod}}] |
| 36 | +import { {{ currentMethod === 'On-Demand' ? 'open' : 'iaWriter' }} } from '{{ importPath }}' |
| 37 | +
|
| 38 | +const url = {{currentMethod === 'On-Demand' ? '' : 'iaWriter.'}}open({ |
| 39 | + path: '/Drafts/Notes.txt', |
| 40 | +}) |
| 41 | +``` |
| 42 | + |
| 43 | +<div class="flex justify-center"> |
| 44 | + <VPLink :href="open(openParams)" target="_self"> |
| 45 | + Open Document in iA Writer |
| 46 | + </VPLink> |
| 47 | +</div> |
| 48 | + |
| 49 | +### New File |
| 50 | + |
| 51 | +Opens Editor with a new document. |
| 52 | + |
| 53 | +```ts-vue [{{currentMethod}}] |
| 54 | +import { {{ currentMethod === 'On-Demand' ? 'newFile' : 'iaWriter' }} } from '{{ importPath }}' |
| 55 | +
|
| 56 | +const url = {{currentMethod === 'On-Demand' ? '' : 'iaWriter.'}}newFile({ |
| 57 | + path: '/Drafts/Meeting Notes.txt', |
| 58 | + text: '# Meeting Notes\n\n', |
| 59 | + author: 'AI', |
| 60 | +}) |
| 61 | +``` |
| 62 | + |
| 63 | +<div class="flex justify-center"> |
| 64 | + <VPLink :href="newFile(newFileParams)" target="_self"> |
| 65 | + Create New File in iA Writer |
| 66 | + </VPLink> |
| 67 | +</div> |
| 68 | + |
| 69 | +### Quick Search |
| 70 | + |
| 71 | +Opens Quick Search with a given query. |
| 72 | + |
| 73 | +```ts-vue [{{currentMethod}}] |
| 74 | +import { {{ currentMethod === 'On-Demand' ? 'quickSearch' : 'iaWriter' }} } from '{{ importPath }}' |
| 75 | +
|
| 76 | +const url = {{currentMethod === 'On-Demand' ? '' : 'iaWriter.'}}quickSearch({ |
| 77 | + query: 'meeting notes', |
| 78 | +}) |
| 79 | +``` |
| 80 | + |
| 81 | +<div class="flex justify-center"> |
| 82 | + <VPLink :href="quickSearch(quickSearchParams)" target="_self"> |
| 83 | + Search in iA Writer |
| 84 | + </VPLink> |
| 85 | +</div> |
| 86 | + |
| 87 | +### Read File |
| 88 | + |
| 89 | +Reads and returns file contents. iA Writer requires an `auth-token` for data commands and returns `path` and `text` parameters on `x-success`. |
| 90 | + |
| 91 | +```ts-vue [{{currentMethod}}] |
| 92 | +import { {{ currentMethod === 'On-Demand' ? 'read' : 'iaWriter' }} } from '{{ importPath }}' |
| 93 | +
|
| 94 | +const url = {{currentMethod === 'On-Demand' ? '' : 'iaWriter.'}}read({ |
| 95 | + authToken: 'REPLACE_WITH_YOUR_TOKEN', |
| 96 | + path: '/Drafts/Notes.txt', |
| 97 | + xSuccess: 'myapp://callback', |
| 98 | +}) |
| 99 | +``` |
| 100 | + |
| 101 | +### Write File |
| 102 | + |
| 103 | +Creates or modifies an existing file and returns file contents. iA Writer requires an `auth-token` for data commands and returns `path` and `text` parameters on `x-success`. |
| 104 | + |
| 105 | +```ts-vue [{{currentMethod}}] |
| 106 | +import { {{ currentMethod === 'On-Demand' ? 'write' : 'iaWriter' }} } from '{{ importPath }}' |
| 107 | +
|
| 108 | +const url = {{currentMethod === 'On-Demand' ? '' : 'iaWriter.'}}write({ |
| 109 | + authToken: 'REPLACE_WITH_YOUR_TOKEN', |
| 110 | + path: '/Drafts/Notes.txt', |
| 111 | + text: 'Hello world', |
| 112 | + mode: 'add', |
| 113 | + addLocation: 'end', |
| 114 | + addPadding: 'paragraph', |
| 115 | + author: 'AI', |
| 116 | + xSuccess: 'myapp://callback', |
| 117 | +}) |
| 118 | +``` |
| 119 | + |
| 120 | +### Version |
| 121 | + |
| 122 | +Returns iA Writer app version and URL scheme version. iA Writer returns `scheme-version` and `app-version` parameters on `x-success`. |
| 123 | + |
| 124 | +```ts-vue [{{currentMethod}}] |
| 125 | +import { {{ currentMethod === 'On-Demand' ? 'version' : 'iaWriter' }} } from '{{ importPath }}' |
| 126 | +
|
| 127 | +const url = {{currentMethod === 'On-Demand' ? '' : 'iaWriter.'}}version({ |
| 128 | + xSuccess: 'myapp://callback', |
| 129 | +}) |
| 130 | +``` |
| 131 | + |
| 132 | +## Official Documentation |
| 133 | + |
| 134 | +- [iA Writer URL Commands](https://ia.net/writer/support/help/url-commands) |
0 commit comments