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>
This commit is contained in:
parent
f4232ef9b5
commit
dc2b12a3c6
37 changed files with 3704 additions and 27 deletions
|
|
@ -65,13 +65,36 @@ function renderNav() {
|
|||
...grouped(TOOLS.filter((t) => matches(t, q))).map(([cat, tools]) =>
|
||||
el('div.nav-group', {},
|
||||
el('div.nav-heading', {}, cat),
|
||||
tools.map((t) => el('a.nav-item', { href: t.path, dataset: { path: t.path } }, el('span.nav-icon', {}, t.icon), t.name)),
|
||||
tools.map((t) => el('a.nav-item', { href: t.path, dataset: { path: t.path, tool: t.id } },
|
||||
el('span.nav-icon', {}, t.icon), el('span.nav-label', {}, t.name), t.badge ? el('span.badge', { hidden: true }) : null)),
|
||||
),
|
||||
),
|
||||
);
|
||||
markActive();
|
||||
updateBadges();
|
||||
}
|
||||
|
||||
// Counts on nav items (e.g. unread shared pastes), plus a dot on the mobile menu button.
|
||||
function updateBadges() {
|
||||
let total = 0;
|
||||
for (const t of TOOLS) {
|
||||
if (!t.badge) continue;
|
||||
let n = 0;
|
||||
try { n = t.badge() || 0; } catch {}
|
||||
total += n;
|
||||
const b = navList.querySelector(`.nav-item[data-tool="${t.id}"] .badge`);
|
||||
if (b) {
|
||||
b.hidden = !n;
|
||||
b.textContent = n > 99 ? '99+' : String(n);
|
||||
b.title = `${n} new`;
|
||||
}
|
||||
}
|
||||
menuBtn.classList.toggle('has-badge', total > 0);
|
||||
}
|
||||
window.addEventListener('tools:badges', updateBadges);
|
||||
window.addEventListener('storage', (e) => { if (!e.key || e.key.startsWith('tools:')) updateBadges(); }); // other tabs
|
||||
setInterval(updateBadges, 60000); // expiry
|
||||
|
||||
function markActive() {
|
||||
const tool = findTool(location.pathname);
|
||||
for (const a of navList.querySelectorAll('.nav-item')) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue