Dimensione del carattere
Imposta il testo selezionato su un passaggio di dimensione. Se è selezionato un intervallo, il passaggio si applica a quell'intervallo; se è presente solo il cursore, cambia la dimensione del testo del paragrafo corrente. I dati salvati mantengono solo i passaggi consentiti, non valori arbitrari come px.
npm install nabi-noteimport {
createNabiWith, mountSurface, mountToolbar, mountContextToolbar,
mountHints, watchSettle, boldWing, italicWing, underlineWing,
strikeWing, typefaceWing, fontSizeWing, clearFormatWing,
mountViewTools,
} from 'nabi-note'
const selected = [
boldWing,
italicWing,
underlineWing,
strikeWing,
typefaceWing,
fontSizeWing,
clearFormatWing,
]
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()))const selected = wings().use('fs', {
values: ['sm', 'lg', 'xl'],
}).build()Se values viene omesso, vengono usati i passaggi xs, sm, lg e xl. Se restringi l'elenco, gli altri passaggi già presenti nei documenti precedenti vengono rimossi al caricamento.
Stili CSS
Puoi modificare le dimensioni tramite selettori dei passaggi salvati, come .nabi-content [data-nabi-size="xs"]. Non inventare passaggi arbitrari che non sono nel documento; regola il CSS solo entro le values registrate.
.article-body [data-nabi-size="xs"] { font-size: .78em; }
.article-body [data-nabi-size="sm"] { font-size: .9em; }
.article-body [data-nabi-size="lg"] { font-size: 1.3em; }
.article-body [data-nabi-size="xl"] { font-size: 1.65em; }Mantenere coerente la differenza di dimensione fra i passaggi conserva, nella pubblicazione, il significato scelto dall'autore nell'editor.