npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@scriba-editor/plugin-code-block

v0.1.1

Published

Code blocks with safe syntax highlighting (lowlight, token decorations) for the Scriba editor.

Readme

@scriba-editor/plugin-code-block

Blocchi di codice per l'editor Scriba, con evidenziazione della sintassi e scelta del linguaggio. Come il plugin "Code sample" di TinyMCE, ma l'evidenziazione produce decorazioni, mai HTML: nessuna stringa dell'evidenziatore arriva alla pagina.

Installazione

pnpm add @scriba-editor/plugin-code-block lowlight

Il pacchetto dipende da lowlight 3.3.0; nell'app crei tu l'istanza con le grammatiche che vuoi (l'esempio sotto usa quelle comuni).

Uso

import {
  codeBlockKeymap,
  codeBlockNodes,
  codeBlockToolbarItems,
  codeHighlight,
  toggleCodeBlock,
} from '@scriba-editor/plugin-code-block'
import { common, createLowlight } from 'lowlight'

const schema = new Schema({
  nodes: { ...basicSchemaSpec.nodes, ...codeBlockNodes },
  marks: basicSchemaSpec.marks,
})

const state = EditorState.create({
  schema,
  plugins: [
    codeHighlight({ lowlight: createLowlight(common) }),
    keymap(codeBlockKeymap(), { priority: 60 }),
    // …
  ],
})

// pulsante del blocco e menu del linguaggio (visibile solo dentro un blocco di codice)
const items = codeBlockToolbarItems(schema)

Cosa esporta

| Export | Descrizione | | ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- | | codeBlockNodes | Nodo code_block: solo testo, niente mark, attributo language (o null). | | codeHighlight(options) | Plugin di evidenziazione come decorazioni; codeHighlightKey ne è la chiave. | | codeBlockKeymap() | Scorciatoie (vedi sotto). | | codeBlockToolbarItems(schema, languages?) | Pulsante code_block e menu code_language (voce "testo semplice" + linguaggi). | | defaultCodeLanguages | JavaScript, TypeScript, HTML/XML, CSS, JSON, Python, PHP, Java, C#, SQL, Bash. | | toggleCodeBlock, setCodeLanguage(lang), exitCodeBlock, exitOnTripleEnter, resetEmptyCodeBlock, isInCodeBlock | Comandi. | | LANGUAGE | Espressione regolare dei nomi di linguaggio ammessi. |

Opzioni di codeHighlight (HighlightOptions):

  • lowlight (obbligatoria): istanza di lowlight con le grammatiche registrate;
  • autoDetect: indovina il linguaggio dei blocchi senza (più lento; default false);
  • maxLength: i blocchi più lunghi non si evidenziano (default 100 000 caratteri).

I linguaggi del menu devono essere registrati nella tua istanza di lowlight; per cambiarli passa un secondo argomento a codeBlockToolbarItems: [{ id: 'python', label: 'Python' }, …].

Scorciatoie

| Tasti | Azione | | ---------------------------- | ----------------------------------------------------------------- | | Maiusc+Mod+Alt+C | Blocco di codice acceso/spento (non Mod+Alt+C, usata da DevTools) | | Mod+Invio | Esce dal blocco, con un nuovo paragrafo sotto | | Invio (dopo due righe vuote) | Esce dal blocco, togliendo le righe vuote (tre Invio di fila) | | Backspace in un blocco vuoto | Lo riporta a paragrafo |

Tab non è catturato: chi usa la tastiera può sempre uscire dall'editor (WCAG).

Note

  • HTML: <pre><code class="language-js">…</code></pre>. In lettura il linguaggio viene da data-language o da una classe language-xxx/lang-xxx su <pre> o su <code>; la class scritta deriva solo dal linguaggio validato, mai dall'input. Vedi sicurezza.
  • L'evidenziatore usa solo i nomi di classe (limitati a [\w-]) e le lunghezze del testo; i risultati sono in cache per blocco, quindi i blocchi invariati non si rielaborano. Gli errori dell'evidenziatore non interrompono mai la scrittura.
  • I colori dei token vengono dal tema (@scriba-editor/themes). Vedi plugin.