|
| 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 { create, replace, replaceSelection, content, open, append, prepend } from 'protocol-launcher/1writer'; |
| 9 | +import { SelectInstallationMethod } from '../../.vitepress/components'; |
| 10 | +import { |
| 11 | + createParams, |
| 12 | + replaceParams, |
| 13 | + replaceSelectionParams, |
| 14 | + contentParams, |
| 15 | + openParams, |
| 16 | + appendParams, |
| 17 | + prependParams, |
| 18 | +} from '../../.vitepress/constants/1writer'; |
| 19 | + |
| 20 | +const currentMethod = ref('On-Demand'); |
| 21 | +const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/1writer' : 'protocol-launcher'); |
| 22 | +</script> |
| 23 | + |
| 24 | +# 1Writer |
| 25 | + |
| 26 | +[1Writer](https://1writerapp.com/) is a powerful Markdown text editor for iOS with Dropbox, Google Drive, and iCloud support. **Protocol Launcher** allows you to generate deep links to create, edit, and manage documents in 1Writer using the `onewriter://` URL scheme with x-callback-url protocol. |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +There are two ways to use this library: |
| 31 | + |
| 32 | +- On-Demand import from subpaths enables tree-shaking and keeps bundles small. |
| 33 | +- Full Import from the root package is convenient but includes all app modules. |
| 34 | + |
| 35 | +Pick On-Demand for production builds; Full Import is fine for quick scripts or demos. |
| 36 | + |
| 37 | +<SelectInstallationMethod v-model="currentMethod" /> |
| 38 | + |
| 39 | +### Create Document |
| 40 | + |
| 41 | +Creates a new document. |
| 42 | + |
| 43 | +```ts-vue [{{currentMethod}}] |
| 44 | +import { {{ currentMethod === 'On-Demand' ? 'create' : 'oneWriter' }} } from '{{ importPath }}' |
| 45 | +
|
| 46 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}create({ |
| 47 | + path: 'Dropbox/Documents', |
| 48 | + name: 'Notes.txt', |
| 49 | + text: 'Hello world', |
| 50 | +}) |
| 51 | +``` |
| 52 | + |
| 53 | +<div class="flex justify-center"> |
| 54 | + <VPLink :href="create(createParams)" target="_self"> |
| 55 | + Create Document in 1Writer |
| 56 | + </VPLink> |
| 57 | +</div> |
| 58 | + |
| 59 | +### Replace Document |
| 60 | + |
| 61 | +Replaces content of a document. |
| 62 | + |
| 63 | +```ts-vue [{{currentMethod}}] |
| 64 | +import { {{ currentMethod === 'On-Demand' ? 'replace' : 'oneWriter' }} } from '{{ importPath }}' |
| 65 | +
|
| 66 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}replace({ |
| 67 | + path: 'Dropbox/Documents/Notes.txt', |
| 68 | + text: 'Hello world', |
| 69 | +}) |
| 70 | +``` |
| 71 | + |
| 72 | +<div class="flex justify-center"> |
| 73 | + <VPLink :href="replace(replaceParams)" target="_self"> |
| 74 | + Replace Document in 1Writer |
| 75 | + </VPLink> |
| 76 | +</div> |
| 77 | + |
| 78 | +### Replace Selection |
| 79 | + |
| 80 | +Replaces selected text in the current editing document. |
| 81 | + |
| 82 | +```ts-vue [{{currentMethod}}] |
| 83 | +import { {{ currentMethod === 'On-Demand' ? 'replaceSelection' : 'oneWriter' }} } from '{{ importPath }}' |
| 84 | +
|
| 85 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}replaceSelection({ |
| 86 | + text: 'New text', |
| 87 | +}) |
| 88 | +``` |
| 89 | + |
| 90 | +<div class="flex justify-center"> |
| 91 | + <VPLink :href="replaceSelection(replaceSelectionParams)" target="_self"> |
| 92 | + Replace Selection in 1Writer |
| 93 | + </VPLink> |
| 94 | +</div> |
| 95 | + |
| 96 | +### Get Content |
| 97 | + |
| 98 | +Returns content of a document. |
| 99 | + |
| 100 | +```ts-vue [{{currentMethod}}] |
| 101 | +import { {{ currentMethod === 'On-Demand' ? 'content' : 'oneWriter' }} } from '{{ importPath }}' |
| 102 | +
|
| 103 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}content({ |
| 104 | + path: 'Dropbox/Documents/Notes.txt', |
| 105 | +}) |
| 106 | +``` |
| 107 | + |
| 108 | +<div class="flex justify-center"> |
| 109 | + <VPLink :href="content(contentParams)" target="_self"> |
| 110 | + Get Content from 1Writer |
| 111 | + </VPLink> |
| 112 | +</div> |
| 113 | + |
| 114 | +### Open Document |
| 115 | + |
| 116 | +Opens an existing document. |
| 117 | + |
| 118 | +```ts-vue [{{currentMethod}}] |
| 119 | +import { {{ currentMethod === 'On-Demand' ? 'open' : 'oneWriter' }} } from '{{ importPath }}' |
| 120 | +
|
| 121 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}open({ |
| 122 | + path: 'Dropbox/Documents/Notes.txt', |
| 123 | +}) |
| 124 | +``` |
| 125 | + |
| 126 | +<div class="flex justify-center"> |
| 127 | + <VPLink :href="open(openParams)" target="_self"> |
| 128 | + Open Document in 1Writer |
| 129 | + </VPLink> |
| 130 | +</div> |
| 131 | + |
| 132 | +### Append Document |
| 133 | + |
| 134 | +Appends content to an existing document. |
| 135 | + |
| 136 | +```ts-vue [{{currentMethod}}] |
| 137 | +import { {{ currentMethod === 'On-Demand' ? 'append' : 'oneWriter' }} } from '{{ importPath }}' |
| 138 | +
|
| 139 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}append({ |
| 140 | + path: 'Dropbox/Documents/Notes.txt', |
| 141 | + text: 'Hello world', |
| 142 | +}) |
| 143 | +``` |
| 144 | + |
| 145 | +<div class="flex justify-center"> |
| 146 | + <VPLink :href="append(appendParams)" target="_self"> |
| 147 | + Append to Document in 1Writer |
| 148 | + </VPLink> |
| 149 | +</div> |
| 150 | + |
| 151 | +### Prepend Document |
| 152 | + |
| 153 | +Prepends content to an existing document. |
| 154 | + |
| 155 | +```ts-vue [{{currentMethod}}] |
| 156 | +import { {{ currentMethod === 'On-Demand' ? 'prepend' : 'oneWriter' }} } from '{{ importPath }}' |
| 157 | +
|
| 158 | +const url = {{currentMethod === 'On-Demand' ? '' : 'oneWriter.'}}prepend({ |
| 159 | + path: 'Dropbox/Documents/Notes.txt', |
| 160 | + text: 'Hello world', |
| 161 | +}) |
| 162 | +``` |
| 163 | + |
| 164 | +<div class="flex justify-center"> |
| 165 | + <VPLink :href="prepend(prependParams)" target="_self"> |
| 166 | + Prepend to Document in 1Writer |
| 167 | + </VPLink> |
| 168 | +</div> |
0 commit comments