Evidenziazione

Applica un colore di evidenziazione consentito dietro il testo selezionato. I dati salvati conservano solo nomi di colore consentiti, non valori CSS arbitrari, così i dati del documento e lo stile visivo restano separati.

Ali
Carattere di baseAltezza
HTMLCaricamento dell’editor…
JSONnabi-treeCaricamento dell’editor…
Installazione
npm install nabi-note
Codice
import {
  createNabiWith, mountSurface, mountToolbar, mountContextToolbar,
  mountHints, watchSettle, textColorWing, highlightWing, linkWing,
  mountViewTools,
} from 'nabi-note'

const selected = [
  textColorWing,
  highlightWing,
  linkWing,
]
const { nabi, registry } = createNabiWith(selected)

const root = document.querySelector('.nabi')!
const content = document.querySelector('.nabi-content')!

// The locale also sets the direction — Arabic and Urdu run right to left
mountSurface({ nabi, registry, root: content, locale: 'it' })

const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'it' }
const toolbar = mountToolbar({ ...shared, root: document.querySelector('#toolbar')! })
const context = mountContextToolbar({ ...shared, root: document.querySelector('#context')! })
mountHints({ toolbar, context, root, surface: content })
// The preview and fullscreen buttons — they stand their own box at the end of the row
mountViewTools({ ...shared, root, container: document.querySelector('#toolbar')! })

// on every change — hook up your own code here
// nabi.onChange(() => user_callback(nabi.getHtml()))
ts
const selected = wings().use('hl', {
  values: ['yellow', 'green', 'cyan'],
}).build()

Se values viene omesso, la palette predefinita è yellow, green, cyan, pink, purple e orange. Se restringi la lista, i colori non registrati non vengono mantenuti neppure quando si carica un documento esistente.

Stili CSS

Il documento salva solo nomi di colore. Cambia i colori dell’editor e della vista pubblicata tramite variabili CSS.

css
.nabi-content { --nabi-hl-yellow: #fff0a6; }

Modificare più colori insieme permette di mantenere i nomi dei colori nel documento adattando solo il tono del prodotto.

css
.article-body {
  --nabi-hl-yellow: #fff0a6;
  --nabi-hl-green: #c8f0d8;
  --nabi-hl-pink: #ffd6e5;
}