YouTube
YouTube の動画 URL または動画 ID を受け取り、埋め込みブロックにします。文書には完全な URL ではなく 11 文字の動画 ID と幅だけが保存され、新しい動画は中央揃え、幅 70% から始まります。
幅は決められた段階から選び、配置は動画を包む段落に保存されます。エディターでは最初のクリックで動画を選択し、選択後にもう一度クリックすると再生できます。アドレスを変えるのではなく、動画を削除して新しく挿入します。
ウィング
既定の書体高さ
HTMLエディタを読み込んでいます…
JSONnabi-treeエディタを読み込んでいます…
インストール
npm install nabi-noteコード
import {
createNabiWith, mountSurface, mountToolbar, mountContextToolbar,
mountHints, watchSettle, codeWing, imageWing, youtubeWing,
mountViewTools,
} from 'nabi-note'
const selected = [
codeWing,
imageWing,
youtubeWing,
]
const { nabi, registry } = createNabiWith(selected)
// 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: 'ja' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'ja' }
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('youtube').build()CSS スタイル
動画は .nabi-content iframe で枠線や角丸を変更できます。保存された幅と配置は変更しないでください。
css
.article-body iframe {
border-radius: 14px;
box-shadow: 0 10px 28px rgb(0 0 0 / 16%);
}aspect-ratio、幅、配置用の margin は、パッケージが動画サイズを保つために使います。上書きしないでください。