Skip to content

Commit 3bcb2c6

Browse files
zhensherlockcodex
andcommitted
feat(slack): add Slack URL scheme support
Co-Authored-By: Codex <267193182+codex@users.noreply.github.com>
1 parent 09fdb98 commit 3bcb2c6

24 files changed

Lines changed: 843 additions & 0 deletions

File tree

.changeset/quick-toys-rush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'protocol-launcher': minor
3+
---
4+
5+
feat(slack): add Slack URL scheme support

apps/docs/.vitepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export default defineConfig({
114114
'en/apps/shortcuts.md': 'apps/shortcuts.md',
115115
'en/apps/simple-scan.md': 'apps/simple-scan.md',
116116
'en/apps/sketch.md': 'apps/sketch.md',
117+
'en/apps/slack.md': 'apps/slack.md',
117118
'en/apps/soulver.md': 'apps/soulver.md',
118119
'en/apps/sourcetree.md': 'apps/sourcetree.md',
119120
'en/apps/steam.md': 'apps/steam.md',
@@ -284,6 +285,7 @@ export default defineConfig({
284285
{ text: 'Shortcuts', link: '/apps/shortcuts' },
285286
{ text: 'Simple Scan', link: '/apps/simple-scan' },
286287
{ text: 'Sketch', link: '/apps/sketch' },
288+
{ text: 'Slack', link: '/apps/slack' },
287289
{ text: 'Soulver', link: '/apps/soulver' },
288290
{ text: 'SourceTree', link: '/apps/sourcetree' },
289291
{ text: 'Steam', link: '/apps/steam' },
@@ -460,6 +462,7 @@ export default defineConfig({
460462
{ text: 'Shortcuts', link: '/apps/shortcuts' },
461463
{ text: 'Simple Scan', link: '/apps/simple-scan' },
462464
{ text: 'Sketch', link: '/apps/sketch' },
465+
{ text: 'Slack', link: '/apps/slack' },
463466
{ text: 'Soulver', link: '/apps/soulver' },
464467
{ text: 'SourceTree', link: '/apps/sourcetree' },
465468
{ text: 'Steam', link: '/apps/steam' },
@@ -601,6 +604,7 @@ export default defineConfig({
601604
{ text: 'Shortcuts', link: '/zh/apps/shortcuts' },
602605
{ text: 'Simple Scan', link: '/zh/apps/simple-scan' },
603606
{ text: 'Sketch', link: '/zh/apps/sketch' },
607+
{ text: 'Slack', link: '/zh/apps/slack' },
604608
{ text: 'Soulver', link: '/zh/apps/soulver' },
605609
{ text: 'SourceTree', link: '/zh/apps/sourcetree' },
606610
{ text: 'Steam', link: '/zh/apps/steam' },

apps/docs/.vitepress/constants/app-logos.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const appLogoFiles = {
9494
shortcuts: 'shortcuts.png',
9595
'simple-scan': 'simple-scan.webp',
9696
sketch: 'sketch.png',
97+
slack: 'slack.webp',
9798
soulver: 'soulver.png',
9899
sourcetree: 'sourcetree.png',
99100
steam: 'steam.webp',
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export const openParams = {
2+
team: 'T12345',
3+
}
4+
5+
export const openAppParams = {
6+
team: 'T12345',
7+
id: 'A123ABC456',
8+
tab: 'home' as const,
9+
}
10+
11+
export const openChannelParams = {
12+
team: 'T12345',
13+
id: 'C123ABC456',
14+
}
15+
16+
export const openUserParams = {
17+
team: 'T12345',
18+
id: 'U123ABC456',
19+
}
20+
21+
export const openFileParams = {
22+
team: 'T12345',
23+
id: 'F123ABC456',
24+
}
25+
26+
export const shareFileParams = {
27+
team: 'T12345',
28+
id: 'F123ABC456',
29+
}
30+
31+
export const appRedirectParams = {
32+
app: 'A123ABC456',
33+
team: 'T12345',
34+
}
35+
36+
export const channelRedirectParams = {
37+
channel: 'release-notes',
38+
team: 'T12345',
39+
}

apps/docs/en/apps/slack.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
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 {
9+
appRedirect,
10+
channelRedirect,
11+
open,
12+
openApp,
13+
openChannel,
14+
openFile,
15+
openUser,
16+
shareFile,
17+
} from 'protocol-launcher/slack';
18+
import { SelectInstallationMethod } from '../../.vitepress/components';
19+
import {
20+
appRedirectParams,
21+
channelRedirectParams,
22+
openAppParams,
23+
openChannelParams,
24+
openFileParams,
25+
openParams,
26+
openUserParams,
27+
shareFileParams,
28+
} from '../../.vitepress/constants/slack';
29+
30+
const currentMethod = ref('On-Demand');
31+
const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/slack' : 'protocol-launcher');
32+
</script>
33+
34+
# Slack
35+
36+
[Slack](https://slack.com/) is a collaboration platform for team communication, channels, messages, files, and apps. **Protocol Launcher** allows you to generate deep links to open Slack workspaces, channels, users, apps, and files.
37+
38+
## Usage
39+
40+
There are two ways to use this library:
41+
42+
- On-Demand import from subpaths enables tree-shaking and keeps bundles small.
43+
- Full Import from the root package is convenient but includes all app modules.
44+
45+
Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.
46+
47+
<SelectInstallationMethod v-model="currentMethod" />
48+
49+
## Notes
50+
51+
Slack's `slack://` URI templates use Slack IDs for workspaces, channels, users, apps, and files. They do not support workspace subdomains, channel names, user names, or filenames. Use Slack's `app_redirect` URL when you need the official channel-name redirect form.
52+
53+
### Open Slack
54+
55+
Open the native Slack client. Passing `team` switches to a specific workspace.
56+
57+
```ts-vue [{{currentMethod}}]
58+
import { {{ currentMethod === 'On-Demand' ? 'open' : 'slack' }} } from '{{ importPath }}'
59+
60+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}open({
61+
team: '{{ openParams.team }}',
62+
})
63+
```
64+
65+
<div class="flex justify-center">
66+
<VPLink :href="open(openParams)" target="_self">
67+
Open Slack
68+
</VPLink>
69+
</div>
70+
71+
### App Redirect
72+
73+
Create a Slack `app_redirect` URL that opens a direct message with an app or bot.
74+
75+
```ts-vue [{{currentMethod}}]
76+
import { {{ currentMethod === 'On-Demand' ? 'appRedirect' : 'slack' }} } from '{{ importPath }}'
77+
78+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}appRedirect({
79+
app: '{{ appRedirectParams.app }}',
80+
team: '{{ appRedirectParams.team }}',
81+
})
82+
```
83+
84+
<div class="flex justify-center">
85+
<VPLink :href="appRedirect(appRedirectParams)" target="_self">
86+
Open Slack App Redirect
87+
</VPLink>
88+
</div>
89+
90+
### Channel Redirect
91+
92+
Create a Slack `app_redirect` URL that opens a channel by ID or by name.
93+
94+
```ts-vue [{{currentMethod}}]
95+
import { {{ currentMethod === 'On-Demand' ? 'channelRedirect' : 'slack' }} } from '{{ importPath }}'
96+
97+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}channelRedirect({
98+
channel: '{{ channelRedirectParams.channel }}',
99+
team: '{{ channelRedirectParams.team }}',
100+
})
101+
```
102+
103+
<div class="flex justify-center">
104+
<VPLink :href="channelRedirect(channelRedirectParams)" target="_self">
105+
Open Slack Channel Redirect
106+
</VPLink>
107+
</div>
108+
109+
### Open App Home
110+
111+
Open a Slack App Home by workspace ID and app ID. The optional `tab` value can be `home`, `about`, or `messages`.
112+
113+
```ts-vue [{{currentMethod}}]
114+
import { {{ currentMethod === 'On-Demand' ? 'openApp' : 'slack' }} } from '{{ importPath }}'
115+
116+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}openApp({
117+
team: '{{ openAppParams.team }}',
118+
id: '{{ openAppParams.id }}',
119+
tab: '{{ openAppParams.tab }}',
120+
})
121+
```
122+
123+
<div class="flex justify-center">
124+
<VPLink :href="openApp(openAppParams)" target="_self">
125+
Open Slack App Home
126+
</VPLink>
127+
</div>
128+
129+
### Open Channel
130+
131+
Open a Slack channel by workspace ID and channel ID.
132+
133+
```ts-vue [{{currentMethod}}]
134+
import { {{ currentMethod === 'On-Demand' ? 'openChannel' : 'slack' }} } from '{{ importPath }}'
135+
136+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}openChannel({
137+
team: '{{ openChannelParams.team }}',
138+
id: '{{ openChannelParams.id }}',
139+
})
140+
```
141+
142+
<div class="flex justify-center">
143+
<VPLink :href="openChannel(openChannelParams)" target="_self">
144+
Open Slack Channel
145+
</VPLink>
146+
</div>
147+
148+
### Open Direct Message
149+
150+
Open a direct message with a Slack user by workspace ID and user ID.
151+
152+
```ts-vue [{{currentMethod}}]
153+
import { {{ currentMethod === 'On-Demand' ? 'openUser' : 'slack' }} } from '{{ importPath }}'
154+
155+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}openUser({
156+
team: '{{ openUserParams.team }}',
157+
id: '{{ openUserParams.id }}',
158+
})
159+
```
160+
161+
<div class="flex justify-center">
162+
<VPLink :href="openUser(openUserParams)" target="_self">
163+
Open Slack Direct Message
164+
</VPLink>
165+
</div>
166+
167+
### Open File
168+
169+
Open a Slack file by workspace ID and file ID.
170+
171+
```ts-vue [{{currentMethod}}]
172+
import { {{ currentMethod === 'On-Demand' ? 'openFile' : 'slack' }} } from '{{ importPath }}'
173+
174+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}openFile({
175+
team: '{{ openFileParams.team }}',
176+
id: '{{ openFileParams.id }}',
177+
})
178+
```
179+
180+
<div class="flex justify-center">
181+
<VPLink :href="openFile(openFileParams)" target="_self">
182+
Open Slack File
183+
</VPLink>
184+
</div>
185+
186+
### Share File
187+
188+
Open Slack's file sharing dialog by workspace ID and file ID.
189+
190+
```ts-vue [{{currentMethod}}]
191+
import { {{ currentMethod === 'On-Demand' ? 'shareFile' : 'slack' }} } from '{{ importPath }}'
192+
193+
const url = {{currentMethod === 'On-Demand' ? '' : 'slack.'}}shareFile({
194+
team: '{{ shareFileParams.team }}',
195+
id: '{{ shareFileParams.id }}',
196+
})
197+
```
198+
199+
<div class="flex justify-center">
200+
<VPLink :href="shareFile(shareFileParams)" target="_self">
201+
Share Slack File
202+
</VPLink>
203+
</div>
204+
205+
## Official Documentation
206+
207+
- [Slack Deep Linking](https://docs.slack.dev/interactivity/deep-linking/)

apps/docs/en/guide/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ For detailed usage instructions for each application, please refer to their resp
213213
- [Shortcuts](../apps/shortcuts.md)
214214
- [Simple Scan](../apps/simple-scan.md)
215215
- [Sketch](../apps/sketch.md)
216+
- [Slack](../apps/slack.md)
216217
- [Soulver](../apps/soulver.md)
217218
- [SourceTree](../apps/sourcetree.md)
218219
- [Steam](../apps/steam.md)

apps/docs/en/guide/what-is-it.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Currently, we support the following applications:
122122
- [Shortcuts](../apps/shortcuts.md)
123123
- [Simple Scan](../apps/simple-scan.md)
124124
- [Sketch](../apps/sketch.md)
125+
- [Slack](../apps/slack.md)
125126
- [Soulver](../apps/soulver.md)
126127
- [SourceTree](../apps/sourcetree.md)
127128
- [Steam](../apps/steam.md)
21.6 KB
Loading

0 commit comments

Comments
 (0)