YouTube

يستقبل عنوان فيديو YouTube أو معرّفه وينشئ كتلة مضمّنة. لا يُحفظ العنوان الكامل، بل معرّف الفيديو المكوّن من 11 حرفًا والعرض فقط، ويبدأ الفيديو الجديد بمحاذاة وسط وعرض 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: 'ar' })

const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'ar' }
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 المحاذاة للحفاظ على حجم الفيديو، لذلك لا تستبدلها.