Tabela
Insira uma tabela e edite linhas, colunas e células. Adicionar e remover linhas ou colunas, mesclar células e alternar células de cabeçalho operam ao redor das células selecionadas. Para usar ordenação de colunas na vista publicada depois de salvar uma tabela como ordenável, conecte attachViewer() de nabi-note/viewer. Tabelas com células mescladas não são ordenadas.
Asas
Tipo de letra padrãoAltura
HTMLCarregando o editor…
JSONnabi-treeCarregando o editor…
Instalação
npm install nabi-noteCódigo
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: 'pt' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'pt' }
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()Estilos CSS
Estilize a tabela com .nabi-content table, e as células com .nabi-content :is(th, td). Não altere a estrutura das células nem o botão de ordenação inserido pelo viewer.
css
.article-body table {
border-collapse: separate;
border-spacing: 0;
width: 100%;
}
.article-body :is(th, td) {
border: 1px solid var(--nabi-line);
padding: .55rem .7rem;
}Se o viewer estiver conectado, mantenha o botão .nabi-sort. Se você sobrescrever à força position ou o padding direito das células, ele pode se sobrepor ao botão de ordenação.