App Context Tutorial
Last updated
Last updated
Use the app context to add commands, keybindings, and work with system resources like the clipboard. When creating an extension, the app context is likely where you should start.
.
Entry point app/main.ts
.
Code runs in Bike's native app environment.
Interact with outlines, clipboard, networking, etc.
Some APIs require appropriate manifest.json
permissions.
Import app context API using import { SYMBOL } from 'bike/app'
.
Turitoral assumes that you have run the npm run watch
command. Your extension should automatically build and install when you save changes.
Let's modify the extension that you just created in to add a new "Archive Done" command. The command will move all completed items to an "Archive" row.
In app/main.ts
, add a function to implement the command:
In app/main.ts
, associate that function with a Bike Command:
Save, and your updated extension should build and then install into Bike.
In Bike, open the Command Pallet (Command-Shift-P
). You should see your command listed. Select the command, and you should see "Archive Done!" printed in Bike's Logs Explorer window.
Next, let’s add a keybinding to activate this command.
In app/main.ts
:
Save and then switch back to Bike.
In Bike, enter block selection mode (press Escape
), then type a
. You should again see "Archive Done!" printed in the Logs Explorer window. Keybindings are used when Bike's outline editor has keyboard focus. They are not used when other UI elements have keyboard focus.
To do this:
Find done rows.
Locate (or create) the Archive row.
Move done rows to the Archive row.
In app/main.ts
, add new Row import and updated archiveDoneCommand:
Save, and switch back to Bike.
Mark some rows as done. You can do this with Command-Shift-P, and then select "Bike: Toggle Done". Done rows should show with strikethrough text. Once you have done rows, run the archive command. The done rows should be moved to the Archive row.
Follow the to show a custom UI sheet when rows are archived.