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

v0.1.1

Published

Read-only blocks for the Scriba editor: block ids and a canEdit rule, checked in the editor and on the server.

Readme

@scriba-editor/plugin-permissions

Permessi per blocco: alcuni blocchi (paragrafi, titoli, tabelle, ...) possono essere resi non modificabili per l'utente corrente. TinyMCE ha solo contenteditable="false" a mano, senza regole né controllo lato server.

pnpm add @scriba-editor/plugin-permissions

Uso

import { blockPermissions, withBlockIds } from '@scriba-editor/plugin-permissions'

// 1. gli id dei blocchi nello schema (data-block-id in HTML)
const schema = new Schema({
  nodes: withBlockIds({ ...basicSchemaSpec.nodes, ...tableNodes }),
  marks,
})

// 2. il plugin: canEdit decide per id (qui: gli id che iniziano con "lock")
const plugins = [...blockPermissions({ canEdit: (id) => !id.startsWith('lock'), t })]

Gli id li assegni tu nell'HTML che carichi (<p data-block-id="lock-intro">): un blocco senza id è sempre modificabile. Se i permessi cambiano, chiama view.updateState(view.state) per aggiornare i blocchi segnati.

Esportazioni

| Nome | Cosa fa | | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | withBlockIds(nodes, names?) | Aggiunge l'attributo blockId ai tipi indicati (predefiniti: DEFAULT_BLOCK_TYPES) | | DEFAULT_BLOCK_TYPES | paragraph, heading, blockquote, bullet_list, ordered_list, list_item, code_block, table | | blockPermissions(options) | Plugin: rifiuta le modifiche ai blocchi protetti e le annuncia | | checkBlockEdits(before, after, rules) | Controllo lato server: restituisce gli id modificati, cancellati o aggiunti (vuoto = permesso) | | transactionAllowed(tr, rules) | Dice se una transazione lascia intatti i blocchi protetti | | BLOCK_ID, blockIdOf(node), isBlockId(v) | Nome dell'attributo, lettura e validazione dell'id (1-100 caratteri: lettere, cifre, _ - . :) | | LOCKED_CLASS | Classe scriba-locked messa sul DOM dei blocchi protetti | | deleteKeepingLocked, deleteSelectionKeepingLocked, typeKeepingLocked, pasteKeepingLocked, marksAroundLocked | Elementi di base usati dal plugin: in una selezione mista cancellano, scrivono, incollano e formattano solo ciò che è modificabile | | BlockRules, CanEdit, BlockPermissionOptions | Tipi |

Opzioni (BlockPermissionOptions)

  • canEdit(id): se l'utente può modificare il blocco.
  • t: funzione di traduzione.
  • allowMarks: mark ammessi anche sul testo protetto (predefinito ['comment'], così si può ancora commentare).
  • trusted(tr): modifiche applicate comunque (predefinito: modifiche remote di @scriba-editor/plugin-collab, che il server di collaborazione verifica con la stessa regola).
  • onRefused(tr): chiamata quando una modifica è rifiutata.

Comportamento e accessibilità

Il blocco protetto è segnato con la classe scriba-locked; il cursore può entrarci (leggere, selezionare, copiare, commentare), ma ogni modifica viene rifiutata. Il rifiuto è annunciato in una regione role="status": "Questo blocco è protetto: non puoi modificarlo". Con Backspace/Canc su una selezione mista si cancella solo il testo modificabile. Gli id incollati non vengono portati con sé, e se un blocco con id si divide o si copia l'id resta alla copia con più testo.

Sicurezza

I permessi nel client sono una comodità per utenti onesti: chiunque può inviare al backend un documento modificato saltando l'editor. Il server deve applicare la stessa regola, ad esempio:

const changed = checkBlockEdits(docPrima, docDopo, { canEdit })
if (changed.length) throw new Error(`Blocchi protetti modificati: ${changed.join(', ')}`)

Vedi sicurezza (5.1 e 5.8) e plugin.