YouTube

รับที่อยู่วิดีโอ YouTube หรือ ID วิดีโอ แล้วสร้างเป็นบล็อกฝัง ในเอกสารจะเก็บไม่ใช่ที่อยู่เต็ม แต่เป็น ID วิดีโอ 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: 'th' })

const settle = watchSettle(document, { surface: content })
const shared = { nabi, registry, surface: content, settle, locale: 'th' }
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 สำหรับการจัดแนวเพื่อรักษาขนาดวิดีโอ จึงไม่ควรเขียนทับ