글자색

선택한 글자에 색 이름을 적용합니다. 저장되는 값은 CSS 색상 문자열이 아니라 허용한 이름이며, 실제 색은 --nabi-tc-<name> CSS 변수로 정합니다. 그래서 같은 문서도 라이트·다크 테마에서 읽기 좋게 조정할 수 있습니다.

wing
기본 서체높이
HTML에디터를 불러오는 중…
JSON나비트리에디터를 불러오는 중…
설치
npm install nabi-note
코드
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')!

// locale 이 글의 방향도 정한다 — 아랍어·우르두면 오른쪽에서 왼쪽으로 선다
mountSurface({ nabi, registry, root: content, locale: 'ko' })

const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'ko' }
const toolbar = mountToolbar({ ...shared, root: document.querySelector('#toolbar')! })
const context = mountContextToolbar({ ...shared, root: document.querySelector('#context')! })
mountHints({ toolbar, context, root, surface: content })
// 미리보기·전체화면 두 단추 — 툴바 줄의 끝에 제 상자를 세워 앉는다
mountViewTools({ ...shared, root, container: document.querySelector('#toolbar')! })

// 값이 바뀔 때마다 — 여기에 당신의 코드를 건다
// nabi.onChange(() => user_callback(nabi.getHtml()))
ts
const selected = wings().use('tc', {
  values: ['green', 'coral', 'blue'],
}).build()

values를 생략하면 기본 팔레트(green, coral, violet, amber, blue)를 사용합니다. 목록을 줄이면 그 밖의 색은 명령과 불러오기에서도 받아들이지 않습니다.

CSS 스타일

문서에는 색 이름만 저장됩니다. 편집기와 게시 화면의 실제 색은 CSS 변수로 정합니다.

css
.nabi-content { --nabi-tc-blue: #2563eb; }

글자색은 배경색과 함께 조정해 대비를 확인하세요. 다크 테마에서는 같은 색 이름에 다른 값을 줄 수 있습니다.

css
.dark .article-body {
  --nabi-tc-blue: #93c5fd;
  --nabi-tc-green: #86efac;
}