ハイライト
選択した文字の背後にハイライト色を付けます。保存データには任意の CSS 色ではなく、許可された色名だけが残るため、文書データと画面上の見た目を分けて扱えます。
ウィング
既定の書体高さ
HTMLエディタを読み込んでいます…
JSONnabi-treeエディタを読み込んでいます…
インストール
npm install nabi-noteコード
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: 'ja' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'ja' }
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()values を省略すると、yellow、green、cyan、pink、purple、orange を使います。リストを絞ると、登録していない色は読み込んだ文書でも維持されません。
CSS スタイル
文書には色名だけが保存されます。エディターと公開画面の色は CSS 変数で変えます。
css
.nabi-content { --nabi-hl-yellow: #fff0a6; }複数の色をまとめて変えれば、文書内の色名はそのままに、サービスの雰囲気だけを調整できます。
css
.article-body {
--nabi-hl-yellow: #fff0a6;
--nabi-hl-green: #c8f0d8;
--nabi-hl-pink: #ffd6e5;
}