链接
选中文字后为它附加地址。如果没有选择文字就输入地址,地址本身会作为链接文字插入。输入 http:// 或 https:// 地址后按 Space 或 Enter,也会自动变成链接。
链接只保存 http:、https:,以及以 . 或 / 开头的同站路径。像 javascript: 或 //example.com 这样无法明确识别 origin 的地址会被拒绝。上传生成的附件链接还会保存文件信息,不能像普通链接一样手动创建。
翅膀
默认字体高度
HTML正在加载编辑器…
JSONnabi-tree正在加载编辑器…
安装
npm install nabi-note代码
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: 'zh' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'zh' }
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()CSS 样式
普通链接用 .nabi-content a 设置样式,附件链接用 .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);
}附件链接的 ::before 和 ::after 用来显示文件图标和扩展名,所以通常不要替换或移除它们的 content。