Bảng

Chọn số hàng và cột trên thanh công cụ để tạo bảng. Trong ô, viết tiếp nội dung bằng ngắt dòng thay vì nhiều đoạn; dùng Tab và Shift+Tab để di chuyển đến ô kế tiếp hoặc trước đó.

Thêm, xóa hàng và cột, gộp ô, chuyển ô tiêu đề đều hoạt động theo ô đang chọn. Sau khi lưu bảng có thể sắp xếp, để dùng sắp xếp cột trên trang xuất bản bạn phải kết nối attachViewer() của nabi-note/viewer. Bảng có ô đã gộp không phải đối tượng sắp xếp cột.

Wings
Kiểu chữ cơ sởĐộ lệch
HTMLĐang tải trình soạn thảo…
JSONnabi-treeĐang tải trình soạn thảo…
Cài đặt
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')!

// The locale also sets the direction — Arabic and Urdu run right to left
mountSurface({ nabi, registry, root: content, locale: 'vi' })

const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'vi' }
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('table').build()

Kiểu CSS

Tạo kiểu bảng bằng .nabi-content table, ô bằng .nabi-content :is(th, td). Không thay đổi cấu trúc ô và nút sắp xếp do viewer thêm vào.

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); }

Nếu đã kết nối viewer, hãy giữ nút .nabi-sort. Ép ghi đè position hoặc padding bên phải của ô có thể chồng lên nút sắp xếp.