on-codemerge
Version:
A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product
26 lines (25 loc) • 1.17 kB
JavaScript
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */
var u = Object.defineProperty;
var d = (o, t, e) => t in o ? u(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
var r = (o, t, e) => d(o, typeof t != "symbol" ? t + "" : t, e);
import { createIframe as c } from "../../../utils/helpers.mjs";
class m {
constructor(t, e) {
r(this, "videoUrl");
r(this, "editor");
this.editor = t, this.videoUrl = e;
}
execute() {
const t = this.extractYouTubeVideoId(this.videoUrl);
if (!t) return;
const e = c("max-w-full rounded-lg p-2");
e.src = `https://www.youtube.com/embed/${t}`, e.width = "800", e.height = "400", e.frameBorder = "0", e.allowFullscreen = !0, this.editor.insertContent(e);
}
extractYouTubeVideoId(t) {
const e = /(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, i = t.match(e);
return i ? i[1] : null;
}
}
export {
m as YouTubeVideoCommand
};