Thu gọn
Gộp phần tóm tắt ngắn và nội dung thành một khối. Khi tạo từ thanh công cụ, hãy nhập phần tóm tắt trước rồi viết tiếp nội dung bên dưới.
Trạng thái mở được đặt bằng nút tam giác được lưu trong tài liệu và trở thành trạng thái ban đầu khi xuất bản. Khi chỉnh sửa, bạn cũng có thể nhấn tam giác để mở và đóng khối.
Trong ô bảng hoặc khối khác, chỉ khối thu gọn đó mở hoặc đóng. Nếu con trỏ hay vùng chọn nằm trong phần nội dung đang đóng, chúng được chuyển ra ngoài; vùng chọn ở nơi khác được giữ nguyên.
npm install nabi-noteimport {
createLocale, createNabiWith, mountSurface, mountToolbar,
mountContextToolbar, mountHints, watchSettle, quoteWing, detailsWing,
codeWing, mountViewTools,
} from 'nabi-note'
const selected = [
quoteWing,
detailsWing,
codeWing,
]
const locale = createLocale('vi')
const { nabi, registry } = createNabiWith(selected, { locale })
// Bring your own highlighter (Prism, highlight.js, Shiki, …) — the wing stays as it is
// and only the attach is swapped (`makeCodeAttach` ships from the same door)
// { ...codeWing, attach: makeCodeAttach({ highlight: (source, lang) => [{ text: source }] }) }
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 })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale }
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()))
// Call from your language selector. Content and editing history stay intact.
// locale.setLocale('ko')const selected = wings().use('details').build()Kiểu CSS
Bạn có thể tạo kiểu cho khối thu gọn bằng .nabi-content details, và tiêu đề bằng .nabi-content details > summary.
.article-body details {
padding: .75rem 1rem;
border: 1px solid var(--nabi-line);
border-radius: var(--nabi-radius);
background: var(--nabi-soft);
}
.article-body details > summary { cursor: pointer; font-weight: 700; }
.article-body details[open] > summary { margin-block-end: .75rem; }Thuộc tính open là trạng thái mở ban đầu do tác giả lưu. CSS có thể tạo kiểu cho trạng thái này, nhưng tốt nhất không nên ép thay đổi trạng thái.