YouTube
Pega una dirección de YouTube o usa el botón de YouTube para insertar un vídeo. El documento guarda solo el ID de 11 caracteres del vídeo y la anchura, no la URL completa, y un vídeo nuevo empieza centrado al 70% de anchura.
La anchura se elige en pasos fijos, y la alineación se guarda en el párrafo que envuelve el vídeo. En el editor, el primer clic selecciona el vídeo; una vez seleccionado, otro clic puede reproducirlo. Para cambiar la dirección, borra el vídeo e inserta uno nuevo.
Alas
Tipografía baseAltura
HTMLCargando el editor…
JSONnabi-treeCargando el editor…
Instalación
npm install nabi-noteCódigo
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: 'es' })
const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'es' }
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()Estilos CSS
Usa .nabi-content iframe para cambiar el borde o las esquinas del vídeo. No cambies la anchura ni la alineación guardadas.
css
.article-body iframe {
border-radius: 14px;
box-shadow: 0 10px 28px rgb(0 0 0 / 16%);
}El paquete usa aspect-ratio, anchura y márgenes de alineación para mantener el vídeo con el tamaño correcto, así que no los sobrescribas.