Media Embed
Paste a bare YouTube or Vimeo URL onto a line of its own and it becomes a responsive 16:9 embed — the behaviour people expect from Notion or Medium. A URL pasted inside a sentence is left alone, because there it means a link, not a video.
Embeds in the saved content: 0
Loading…
Adding your own providers
The src of the generated iframe is never the pasted string. Each provider is matched with a strict regex, the video ID is captured and constrained to [A-Za-z0-9_-], and the embed URL is built from a template — so a crafted URL cannot smuggle anything into the frame. Keep that shape in your own resolver: capture an ID, build the URL, and return null for anything you do not recognise.
<script src="/richtexteditor/plugins/all_plugins.js"></script>
<script>
// On by default. Turn it off per editor:
var editor = new RichTextEditor("#div_editor1", { autoEmbedEnabled: false });
// Add providers. Return an https:// embed URL, or null to decline.
// Build the URL from a captured ID — never from the pasted string.
RTE_DefaultConfig.autoEmbedResolver = function (url) {
var m = /^https:\/\/media\.example\.com\/v\/([A-Za-z0-9_-]{6,20})$/.exec(url);
return m ? "https://media.example.com/embed/" + m[1] : null;
};
</script>For a chosen-from-a-dialog video rather than a pasted one, see Insert Video.