Link
Seleziona del testo e associa un indirizzo. Se inserisci un indirizzo senza selezionare testo, l’indirizzo stesso viene inserito come testo del link. Anche digitare un indirizzo http:// o https:// e poi premere Space o Enter lo trasforma in link.
I link salvano solo http:, https: e percorsi dello stesso sito che iniziano con . o /. Gli indirizzi la cui origine non può essere identificata chiaramente, come javascript: o //example.com, vengono rifiutati. I link allegato creati dagli upload salvano anche informazioni sul file e non possono essere creati manualmente come link ordinari.
npm install nabi-noteimport {
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: 'it' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'it' }
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()))const selected = wings().use('a').build()Stili CSS
Stilizza i link ordinari con .nabi-content a e i link allegato separatamente con .nabi-content a[data-nabi-file].
.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);
}Le parti ::before e ::after dei link allegato sono usate per mostrare icona ed estensione del file, quindi di solito è meglio non sostituire o rimuovere il loro content.