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-template

v0.1.1

Published

Document templates for the Scriba editor: pick a ready-made content, preview it and insert it.

Readme

@scriba-editor/plugin-template

Modelli di documento come il plugin template di TinyMCE e advtemplate: un dialogo con l'elenco dei modelli, descrizione, anteprima di sola lettura e "Inserisci". I modelli possono arrivare dal tuo server.

pnpm add @scriba-editor/plugin-template

Uso

import { templateToolbarItem, type TemplateOptions } from '@scriba-editor/plugin-template'

const templateOptions: TemplateOptions = {
  locale: 'it-IT',
  values: { azienda: 'Ditta Esempio' }, // per i segnaposto {{azienda}}
  templates: [
    {
      title: 'Verbale di riunione',
      description: 'Titolo, data, partecipanti e decisioni.',
      content:
        '<h2>Verbale di riunione</h2><p><strong>Data:</strong> {{date}}</p><h3>Decisioni</h3><ol><li><p></p></li></ol>',
    },
    {
      title: 'Lettera',
      // caricato solo alla prima anteprima, ad esempio dal server
      content: () => fetch('/api/modelli/lettera').then((r) => r.text()),
    },
  ],
  // oppure templates: () => fetch('/api/modelli').then((r) => r.json())
}

// menu Inserisci o toolbar:
templateToolbarItem(t, templateOptions)

Esportazioni

| Nome | Cosa fa | | -------------------------------------- | ------------------------------------------------------------------------------------------- | | templateToolbarItem(t, options) | Voce "Modello..." (id: 'template'); disattivata in sola lettura | | openTemplateDialog(view, t, options) | Apre il dialogo da codice | | TemplateOptions | templates (elenco o funzione asincrona), values?, locale? | | Template | { title, description?, content }; content è HTML o una funzione asincrona che lo carica | | TemplateValue | Testo, oppure funzione chiamata a ogni uso | | insertTemplate(fragment) | Comando: inserisce il contenuto nella selezione (un solo passo di undo) | | parseTemplate(schema, html, values?) | HTML del modello trasformato in documento dello schema | | fillPlaceholders(text, values) | Sostituisce i {{nome}} conosciuti; gli altri restano com'erano | | defaultTemplateValues(locale?) | I segnaposto predefiniti {{date}} e {{time}} | | MAX_TEMPLATE_LENGTH | 1 000 000 caratteri: oltre, il modello è rifiutato, non tagliato |

Comportamento

I blocchi del modello mantengono il tipo (un titolo resta titolo): il paragrafo al cursore viene diviso, oppure sostituito se vuoto. In un documento vuoto, o con tutto selezionato, il modello diventa l'intero documento. Dove i blocchi non entrano (cella di tabella, codice) il contenuto è adattato come un incolla. I segnaposto {{nome}} (lettere, cifre, _, ., -) sono riempiti solo nei nodi di testo; date e time sono predefiniti, i tuoi values si aggiungono.

Accessibilità

Il dialogo ha focus trap e restituisce il focus all'editor. I modelli sono un gruppo di radio (frecce) con la descrizione collegata (aria-describedby); l'anteprima è una regione con etichetta; caricamenti ed errori sono annunciati (role="status" e role="alert").

Sicurezza

  • Il contenuto dei modelli può arrivare dal server: è input non fidato. L'HTML è letto in un documento inerte e passa dal parser dello schema (come un incolla); oltre MAX_TEMPLATE_LENGTH è rifiutato.
  • I valori dei segnaposto sono inseriti solo come testo, mai come markup, anche se contengono < o >.
  • Titolo e descrizione sono mostrati come testo. Una risposta lenta per un modello non più selezionato è ignorata, un caricamento fallito mostra un errore.
  • Il server che salva i documenti deve comunque ripassarli da @scriba-editor/sanitize-server.

Vedi sicurezza, accessibilità e plugin.