툴바에서 행과 열을 골라 표를 만듭니다. 셀 안에서는 여러 문단 대신 줄바꿈으로 내용을 이어 쓰며, Tab과 Shift+Tab으로 다음·이전 셀로 이동합니다.

행과 열 추가·삭제, 셀 병합, 제목 셀 전환은 선택한 셀을 기준으로 동작합니다. 표를 정렬 가능하게 저장한 뒤 발행 화면에서 열 정렬을 쓰려면 nabi-note/viewerattachViewer()를 연결해야 합니다. 병합된 셀이 있는 표는 열 정렬 대상이 아닙니다.

wing
기본 서체높이
HTML에디터를 불러오는 중…
JSON나비트리에디터를 불러오는 중…
설치
npm install nabi-note
코드
import {
  createNabiWith, mountSurface, mountToolbar, mountContextToolbar,
  mountHints, watchSettle, taskListWing, tableWings, imageWing,
  mountViewTools,
} from 'nabi-note'

const selected = [
  taskListWing,
  ...tableWings,
  imageWing,
]
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('table').build()

CSS 스타일

표는 .nabi-content table, 셀은 .nabi-content :is(th, td)로 꾸밉니다. 셀의 구조와 viewer가 넣는 정렬 버튼은 바꾸지 마세요.

css
.article-body table { inline-size: 100%; border-collapse: collapse; }
.article-body :is(th, td) { padding: .6rem .75rem; border: 1px solid var(--nabi-line); }
.article-body th { background: var(--nabi-soft); font-weight: 700; }
.article-body tr:nth-child(even) td { background: color-mix(in srgb, var(--nabi-soft) 45%, transparent); }

viewer를 연결했다면 .nabi-sort 버튼은 남겨 두세요. 셀에 position이나 오른쪽 padding을 강제로 덮어쓰면 정렬 버튼과 겹칠 수 있습니다.