Link

Selecione texto e associe um endereço a ele. Se você inserir um endereço sem selecionar texto, o próprio endereço é inserido como texto do link. Digitar um endereço http:// ou https:// e depois pressionar Espaço ou Enter também o transforma em link.

Links guardam apenas http:, https: e caminhos do mesmo site que começam com . ou /. Endereços cuja origem não possa ser identificada claramente, como javascript: ou //example.com, são rejeitados. Links de anexos criados por uploads também guardam informações de arquivo e não podem ser criados manualmente como links comuns.

Asas
Tipo de letra padrãoAltura
HTMLCarregando o editor…
JSONnabi-treeCarregando o editor…
Instalação
npm install nabi-note
Código
import {
  createNabiWith, mountSurface, mountToolbar, mountContextToolbar,
  mountHints, watchSettle, subscriptWing, highlightWing, linkWing,
  mountViewTools,
} from 'nabi-note'

const selected = [
  subscriptWing,
  highlightWing,
  linkWing,
]
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('a').build()

Estilos CSS

Estilize links comuns com .nabi-content a, e links de anexo separadamente com .nabi-content a[data-nabi-file].

css
.article-body a:not([data-nabi-file]) {
  color: var(--nabi-accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .16em;
}

.article-body a[data-nabi-file] {
  display: inline-flex;
  gap: .35em;
  padding: .25em .55em;
  background: var(--nabi-soft);
}

As partes ::before e ::after de links de anexo são usadas para mostrar o ícone do arquivo e a extensão, então normalmente é melhor não substituir nem remover seu content.