HackMD-it
enhance GitHub with
open collaborative editor
Yukai Huang
@TypeScript Switzerland
slide: hackmd.io/p/ts-swiss
We have a collaborative session
please prepare laptop or smartphone to join!
Who am I? 
- Yukai Huang
- Full Stack Developer @HackMD

- VSCode

- I use tabs.

What's HackMD?
Shamelss plug here 
Let's play with it! 
70% of our users are developers. Developers
GitHub.
Extension architecture 
Background script
- Run after the extension start
- Long run action, web request, heavy works, …
- Kinda backend
Content script
- Bind with each page
- Manipulate DOM
- Add event listeners
- Isolated JavaScript environment
Injected script
- Injected with content script
- Accessing global variable
- Call global function
- Acts as JavaScript inserted with HTML script tag
<script>
cross-environment communication
Case: Sync HackMD with GitHub
- We can't send message between two injected scripts
- We need to manage flow by ourself
- Different set of API
content <-> background
content <-> injected
onMessage('event')
: Register event listener
sendMessage('event')
: Trigger event
What if we want the result back?
It's a pain to bridge events manually
- Dead simple API
- Only cares about application logic
import * as Channeru from 'channeru'
const channel = Channeru.create()
const fakeLogin = async () => true
channel.answer('isLogin', async () => {
return await fakeLogin()
})
const isLogin = await channel.callBackground('isLogin')
console.log(isLogin)
Our extension is not open sourced for now 
We
typescript!
- Strongly Typed: Manage different protocol with ease
- IDE Features (I
VSCode)
- an GitHub App
- Integrate GitHub With HackMD
- Remind you when should update documentation
- Commit and push documentation changes right on HackMD
Wrap up
- Cross envornment commnication
- A small library to solve messaging pain
- TypeScript Rocks

Thank you! 
You can find me on
HackMD-it enhance GitHub with open collaborative editor Yukai Huang @TypeScript Switzerland slide: hackmd.io/p/ts-swiss
{"metaMigratedAt":"2023-06-14T19:24:00.815Z","metaMigratedFrom":"YAML","title":"TypeScript Switzerland Winter Meetup","breaks":true,"contributors":"[{\"id\":\"6d3b4625-23c8-4275-a28e-cdc2cb546eda\",\"add\":4378,\"del\":114}]"}