tools/app/static/js/registry.js
neil dc2b12a3c6 Syntax Highlighting tool, Markdown guide, unread share badge, Open in menu
- Syntax Highlighting (/syntax): highlight.js tokens rendered with VS Code
  (Dark/Light Modern, One Dark Pro, Monokai, Dracula, GitHub) and Android
  Studio (Darcula, Dark, IntelliJ Light) colors; copy as rich text (VS Code
  clipboard HTML), download RTF, share. Format via Prettier/sql-formatter
  (lazy-loaded), the JSON printer, or built-in whitespace-only formatters
  for brace languages, Python and XML.
- Markdown: Guide dialog, source next to rendered output, with Insert.
- Pastes created by Share count as unread on the Pastebin nav badge.
- Paste view: Open in menu built from registry opensPaste tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 00:30:13 -08:00

57 lines
1.9 KiB
JavaScript

// The list of tools. The sidebar, the home page and the router are all built from it.
//
// To add a tool: create js/tools/<id>.js exporting mount(el, ctx) (see app.js for ctx),
// then add an entry here. A tool owns every path under its `path`, so /paste/abc123
// goes to the paste tool with ctx.rest = "abc123".
//
// Optional fields:
// opensPaste: true the tool loads <path>?paste=<id>; it then appears in a paste's "Open in" menu
// badge: () => number a count shown on the tool's nav item (0 hides it); call
// window.dispatchEvent(new Event('tools:badges')) when it changes
import { unreadCount } from './tools/paste-state.js';
export const TOOLS = [
{
id: 'markdown',
name: 'Markdown',
path: '/markdown',
category: 'Text',
icon: 'M↓',
description: 'Write Markdown with a live preview: side by side, editor only or full-page preview.',
opensPaste: true,
load: () => import('./tools/markdown.js'),
},
{
id: 'syntax',
name: 'Syntax Highlighting',
path: '/syntax',
category: 'Code',
icon: '</>',
description: 'Highlight and format source code with VS Code and Android Studio themes, then copy it as rich text or RTF.',
opensPaste: true,
load: () => import('./tools/syntax.js'),
},
{
id: 'json',
name: 'JSON editor',
path: '/json',
category: 'Data',
icon: '{ }',
description: 'Validate, prettify and compact JSON, with a live tree view you can edit.',
opensPaste: true,
load: () => import('./tools/json.js'),
},
{
id: 'paste',
name: 'Pastebin',
path: '/paste',
category: 'Sharing',
icon: '⎘',
description: 'Share text with a short link. Pastes are deleted after 24 hours.',
badge: unreadCount,
load: () => import('./tools/paste.js'),
},
];
// Sidebar groups appear in this order; unknown categories go last, alphabetically.
export const CATEGORY_ORDER = ['Text', 'Code', 'Data', 'Sharing'];