Skip to content

glyph-md/plugin-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glyph Plugin Template

A starter for building a Glyph plugin. Click Use this template to make your own repo.

A plugin is a single ES module (main.js) that default-exports { activate(ctx) }, plus a manifest.json. Write your source across as many files as you like under src/; the build bundles them into one main.js.

Develop

npm install
npm run build      # bundles src/ into main.js
npm run typecheck  # optional: tsc against the bundled glyph types

Try it in Glyph: command palette → Manage Plugins…Install from folder… → pick this folder (after npm run build).

The API

src/main.ts shows the v1 surface (typed via types/glyph.d.ts):

  • ctx.commands.register({ id, title, run }) — add a command to the palette.
  • ctx.ui.addStatusBarItem({ id, mount }) — add a status bar item; mount(el, registerCleanup) is framework-agnostic.
  • ctx.notify(message) — show a toast.
  • ctx.registerTranslations(locale, namespace, resources) — ship and read your own i18n strings.
  • ctx.apiVersion — the host's plugin API version.

Don't bundle React or Glyph internals; the host provides what you need through ctx.

Need network access or no UI mounts? Set "sandbox": true in manifest.json to run in an isolated worker: fetch is limited to your declared network:<host> permissions, and the ctx subset is commands, ui.addStyles, exporters, workspace, assets, settings, notify, and translations. See the API reference.

Publish

  1. Set your id, name, version, and description in manifest.json, and list every shipped file (entry + assets) in files.
  2. npm run build, zip manifest.json plus the declared files (zip -r plugin.zip manifest.json main.js assets or Compress-Archive on Windows), and attach the zip to a tagged release.
  3. Open a PR adding your entry to the marketplace index: packageUrl points at the release zip and sha256 is its digest. See its CONTRIBUTING guide.

Bump version + packageUrl + sha256 per release; Glyph then offers users an in-app update.

About

Starter template for building a Glyph plugin

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors