|
| 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, openFile, newFile, append, replace, reloadCustomizations } from 'protocol-launcher/textastic'; |
| 9 | +import { SelectInstallationMethod } from '../../.vitepress/components'; |
| 10 | +import { useAppStore } from '../../.vitepress/stores/app'; |
| 11 | +import { openFileParams, newFileParams, appendParams, replaceParams } from '../../.vitepress/constants/textastic'; |
| 12 | + |
| 13 | +const appStore = useAppStore(); |
| 14 | +const currentMethod = ref('On-Demand'); |
| 15 | +const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/textastic' : 'protocol-launcher'); |
| 16 | +</script> |
| 17 | + |
| 18 | +# Textastic |
| 19 | + |
| 20 | +[Textastic](https://www.textasticapp.com/) is a powerful text editor for iOS, iPadOS, and macOS with syntax highlighting for over 80 programming and markup languages. **Protocol Launcher** allows you to generate deep links to open, create, and edit files in Textastic. |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +There are two ways to use this library: |
| 25 | + |
| 26 | +- On-Demand import from subpaths enables tree-shaking and keeps bundles small. |
| 27 | +- Full Import from the root package is convenient but includes all app modules. |
| 28 | + |
| 29 | +Pick On-Demand for production builds; Full Import is fine for quick scripts or demos. |
| 30 | + |
| 31 | +<SelectInstallationMethod v-model="currentMethod" /> |
| 32 | + |
| 33 | +### Open App |
| 34 | + |
| 35 | +```ts-vue [{{currentMethod}}] |
| 36 | +import { {{ currentMethod === 'On-Demand' ? 'open' : 'textastic' }} } from '{{ importPath }}' |
| 37 | +
|
| 38 | +const url = {{currentMethod === 'On-Demand' ? '' : 'textastic.'}}open() |
| 39 | +``` |
| 40 | + |
| 41 | +<div class="flex justify-center"> |
| 42 | + <VPLink :href="open()" target="_self"> |
| 43 | + Open Textastic |
| 44 | + </VPLink> |
| 45 | +</div> |
| 46 | + |
| 47 | +### Open File |
| 48 | + |
| 49 | +```ts-vue [{{currentMethod}}] |
| 50 | +import { {{ currentMethod === 'On-Demand' ? 'openFile' : 'textastic' }} } from '{{ importPath }}' |
| 51 | +
|
| 52 | +const url = {{currentMethod === 'On-Demand' ? '' : 'textastic.'}}openFile({ |
| 53 | + path: 'example.com', |
| 54 | + name: 'index.html', |
| 55 | +}) |
| 56 | +``` |
| 57 | + |
| 58 | +<div class="flex justify-center"> |
| 59 | + <VPLink :href="openFile(openFileParams)" target="_self"> |
| 60 | + Open File in Textastic |
| 61 | + </VPLink> |
| 62 | +</div> |
| 63 | + |
| 64 | +### New File |
| 65 | + |
| 66 | +```ts-vue [{{currentMethod}}] |
| 67 | +import { {{ currentMethod === 'On-Demand' ? 'newFile' : 'textastic' }} } from '{{ importPath }}' |
| 68 | +
|
| 69 | +const url = {{currentMethod === 'On-Demand' ? '' : 'textastic.'}}newFile({ |
| 70 | + name: 'foo.txt', |
| 71 | + text: 'bar', |
| 72 | +}) |
| 73 | +``` |
| 74 | + |
| 75 | +<div class="flex justify-center"> |
| 76 | + <VPLink :href="newFile(newFileParams)" target="_self"> |
| 77 | + Create New File in Textastic |
| 78 | + </VPLink> |
| 79 | +</div> |
| 80 | + |
| 81 | +### Append Text |
| 82 | + |
| 83 | +```ts-vue [{{currentMethod}}] |
| 84 | +import { {{ currentMethod === 'On-Demand' ? 'append' : 'textastic' }} } from '{{ importPath }}' |
| 85 | +
|
| 86 | +const url = {{currentMethod === 'On-Demand' ? '' : 'textastic.'}}append({ |
| 87 | + location: 'iCloud', |
| 88 | + name: 'clipboard.txt', |
| 89 | +}) |
| 90 | +``` |
| 91 | + |
| 92 | +<div class="flex justify-center"> |
| 93 | + <VPLink :href="append(appendParams)" target="_self"> |
| 94 | + Append Text in Textastic |
| 95 | + </VPLink> |
| 96 | +</div> |
| 97 | + |
| 98 | +### Replace Text |
| 99 | + |
| 100 | +```ts-vue [{{currentMethod}}] |
| 101 | +import { {{ currentMethod === 'On-Demand' ? 'replace' : 'textastic' }} } from '{{ importPath }}' |
| 102 | +
|
| 103 | +const url = {{currentMethod === 'On-Demand' ? '' : 'textastic.'}}replace({ |
| 104 | + location: 'iCloud', |
| 105 | + name: 'scratchpad.txt', |
| 106 | + text: 'foo', |
| 107 | +}) |
| 108 | +``` |
| 109 | + |
| 110 | +<div class="flex justify-center"> |
| 111 | + <VPLink :href="replace(replaceParams)" target="_self"> |
| 112 | + Replace Text in Textastic |
| 113 | + </VPLink> |
| 114 | +</div> |
| 115 | + |
| 116 | +### Reload Customizations |
| 117 | + |
| 118 | +```ts-vue [{{currentMethod}}] |
| 119 | +import { {{ currentMethod === 'On-Demand' ? 'reloadCustomizations' : 'textastic' }} } from '{{ importPath }}' |
| 120 | +
|
| 121 | +const url = {{currentMethod === 'On-Demand' ? '' : 'textastic.'}}reloadCustomizations() |
| 122 | +``` |
| 123 | + |
| 124 | +<div class="flex justify-center"> |
| 125 | + <VPLink :href="reloadCustomizations()" target="_self"> |
| 126 | + Reload Customizations in Textastic |
| 127 | + </VPLink> |
| 128 | +</div> |
0 commit comments