Text Color
Apply a color name to selected text. The stored value is not a CSS color string; it is an allowed name, and the actual color is defined by the --nabi-tc-<name> CSS variable. That lets the same document stay readable in both light and dark themes.
Wings
Base typefaceOffset
HTMLLoading the editor…
JSONnabi-treeLoading the editor…
Install
npm install nabi-noteCode
import {
createNabiWith, mountSurface, mountToolbar, mountContextToolbar,
mountHints, watchSettle, textColorWing, highlightWing, mountViewTools,
} from 'nabi-note'
const selected = [
textColorWing,
highlightWing,
]
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: 'en' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'en' }
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('tc', {
values: ['green', 'coral', 'blue'],
}).build()If values is omitted, the default palette is green, coral, violet, amber, and blue. If you reduce the list, other colors are rejected by commands and when loading documents.
CSS Styles
The document stores only color names. Set the actual editor and published view colors with CSS variables.
css
.nabi-content { --nabi-tc-blue: #2563eb; }Check contrast together with the background color. In a dark theme, the same color name can receive a different value.
css
.dark .article-body {
--nabi-tc-blue: #93c5fd;
--nabi-tc-green: #86efac;
}