Realce

Aplique uma cor de realce atrás do texto selecionado. Os dados salvos mantêm apenas nomes de cor permitidos, não valores CSS arbitrários, para que os dados do documento e o estilo visual fiquem separados.

Asas
Tipo de letra padrãoAltura
HTMLCarregando o editor…
JSONnabi-treeCarregando o editor…
Instalação
npm install nabi-note
Código
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: 'pt' })

const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'pt' }
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 for omitido, a paleta padrão é yellow, green, cyan, pink, purple e orange. Se você reduzir a lista, cores não registradas não serão preservadas nem ao carregar um documento existente.

Estilos CSS

O documento guarda apenas nomes de cor. Altere as cores do editor e da vista publicada por variáveis CSS.

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

Alterar várias cores ao mesmo tempo permite manter os nomes de cor do documento e adaptar apenas o clima visual do produto.

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