Tamanho do texto
Altere o texto selecionado para um passo de tamanho. Se houver um intervalo selecionado, o passo é aplicado a esse intervalo; se houver apenas o cursor, ele altera o tamanho do texto do parágrafo atual. Os dados salvos mantêm apenas passos permitidos, não valores arbitrários como px.
npm install nabi-noteimport {
createLocale, 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 locale = createLocale('pt')
const { nabi, registry } = createNabiWith(selected, { locale })
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 })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale }
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()))
// Call from your language selector. Content and editing history stay intact.
// locale.setLocale('ko')const selected = wings().use('fs', {
values: ['sm', 'lg', 'xl'],
}).build()Se values for omitido, os passos xs, sm, lg e xl são usados. Se você reduzir a lista, outros passos já presentes em documentos antigos são removidos ao carregar.
Estilos CSS
Você pode alterar tamanhos por seletores de passos salvos, como .nabi-content [data-nabi-size="xs"]. Não invente passos arbitrários que não estão no documento; ajuste o CSS apenas dentro dos values registrados.
.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; }Manter consistente a diferença entre os passos preserva o significado escolhido pelo autor no editor quando o documento é publicado.