var media = (function () {
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
var getScripts = function (editor) {
return editor.getParam('media_scripts');
var getAudioTemplateCallback = function (editor) {
return editor.getParam('audio_template_callback');
var getVideoTemplateCallback = function (editor) {
return editor.getParam('video_template_callback');
var hasLiveEmbeds = function (editor) {
return editor.getParam('media_live_embeds', true);
var shouldFilterHtml = function (editor) {
return editor.getParam('media_filter_html', true);
var getUrlResolver = function (editor) {
return editor.getParam('media_url_resolver');
var hasAltSource = function (editor) {
return editor.getParam('media_alt_source', true);
var hasPoster = function (editor) {
return editor.getParam('media_poster', true);
var hasDimensions = function (editor) {
return editor.getParam('media_dimensions', true);
getAudioTemplateCallback: getAudioTemplateCallback,
getVideoTemplateCallback: getVideoTemplateCallback,
hasLiveEmbeds: hasLiveEmbeds,
shouldFilterHtml: shouldFilterHtml,
getUrlResolver: getUrlResolver,
hasAltSource: hasAltSource,
hasDimensions: hasDimensions
var Cell = function (initial) {
var clone = function () {
var constant = function (value) {
var never = constant(false);
var always = constant(true);
var call = function (thunk) {
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
getOrNull: constant(null),
getOrUndefined: constant(undefined),
toString: constant('none()')
var some = function (a) {
var constant_a = constant(a);
var bind = function (f) {
getOrUndefined: constant_a,
return 'some(' + a + ')';
equals_: function (o, elementEq) {
return o.fold(never, function (b) {
var from = function (value) {
return value === null || value === undefined ? NONE : some(value);
var hasOwnProperty = Object.hasOwnProperty;
var get = function (obj, key) {
return has(obj, key) ? Option.from(obj[key]) : Option.none();
var has = function (obj, key) {
return hasOwnProperty.call(obj, key);
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
var global$4 = tinymce.util.Tools.resolve('tinymce.html.SaxParser');
var getVideoScriptMatch = function (prefixes, src) {
for (var i = 0; i < prefixes.length; i++) {
if (src.indexOf(prefixes[i].filter) !== -1) {
var VideoScript = { getVideoScriptMatch: getVideoScriptMatch };
var trimPx = function (value) {
return value.replace(/px$/, '');
var getEphoxEmbedData = function (attrs) {
var style = attrs.map.style;
var styles = style ? DOM.parseStyle(style) : {};
source1: attrs.map['data-ephox-embed-iri'],
width: get(styles, 'max-width').map(trimPx).getOr(''),
height: get(styles, 'max-height').map(trimPx).getOr('')
var htmlToData = function (prefixes, html) {
var isEphoxEmbed = Cell(false);
allow_conditional_comments: true,
special: 'script,noscript',
start: function (name, attrs) {
if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
data = getEphoxEmbedData(attrs);
if (!data.source1 && name === 'param') {
data.source1 = attrs.map.movie;
if (name === 'iframe' || name === 'object' || name === 'embed' || name === 'video' || name === 'audio') {
data = global$2.extend(attrs.map, data);
var videoScript = VideoScript.getVideoScriptMatch(prefixes, attrs.map.src);
width: videoScript.width,
height: videoScript.height
data.source1 = attrs.map.src;
} else if (!data.source2) {
data.source2 = attrs.map.src;
if (name === 'img' && !data.poster) {
data.poster = attrs.map.src;
data.source1 = data.source1 || data.src || data.data;
data.source2 = data.source2 || '';
data.poster = data.poster || '';
var HtmlToData = { htmlToData: htmlToData };
var global$5 = tinymce.util.Tools.resolve('tinymce.util.Promise');
var guess = function (url) {
swf: 'application/x-shockwave-flash'
var fileEnd = url.toLowerCase().split('.').pop();
var mime = mimes[fileEnd];
var Mime = { guess: guess };
var global$6 = tinymce.util.Tools.resolve('tinymce.html.Schema');
var global$7 = tinymce.util.Tools.resolve('tinymce.html.Writer');
var DOM$1 = global$3.DOM;
var addPx = function (value) {
return /^[0-9.]+$/.test(value) ? value + 'px' : value;
var setAttributes = function (attrs, updatedAttrs) {
for (var name in updatedAttrs) {
var value = '' + updatedAttrs[name];
if (attr.name === name) {
var updateEphoxEmbed = function (data, attrs) {
var style = attrs.map.style;
var styleMap = style ? DOM$1.parseStyle(style) : {};
styleMap['max-width'] = addPx(data.width);
styleMap['max-height'] = addPx(data.height);
setAttributes(attrs, { style: DOM$1.serializeStyle(styleMap) });
var updateHtml = function (html, data, updateAll) {
var isEphoxEmbed = Cell(false);
allow_conditional_comments: true,
special: 'script,noscript',
comment: function (text) {
text: function (text, raw) {
start: function (name, attrs, empty) {
if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
updateEphoxEmbed(data, attrs);
if (data.height !== undefined && data.width !== undefined) {
setAttributes(attrs, { src: '' });
setAttributes(attrs, { src: data.source1 });
src: data['source' + sourceCount],
type: data['source' + sourceCount + 'mime']
if (!data['source' + sourceCount]) {
writer.start(name, attrs, empty);
if (!isEphoxEmbed.get()) {
if (name === 'video' && updateAll) {
for (var index = 1; index <= 2; index++) {
if (data['source' + index]) {
if (sourceCount < index) {
src: data['source' + index],
type: data['source' + index + 'mime']
writer.start('source', attrs, true);
if (data.poster && name === 'object' && updateAll && !hasImage) {
setAttributes(imgAttrs, {
writer.start('img', imgAttrs, true);
}, global$6({})).parse(html);
return writer.getContent();
var UpdateHtml = { updateHtml: updateHtml };
regex: /youtu\.be\/([\w\-_\?&=.]+)/i,
url: '//www.youtube.com/embed/$1',
regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,
url: '//www.youtube.com/embed/$2?$4',
regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,
url: '//www.youtube.com/embed/$1',
regex: /vimeo\.com\/([0-9]+)/,
url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc',
regex: /vimeo\.com\/(.*)\/([0-9]+)/,
url: '//player.vimeo.com/video/$2?title=0&byline=0',
regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,
url: '//maps.google.com/maps/ms?msid=$2&output=embed"',
regex: /dailymotion\.com\/video\/([^_]+)/,
url: '//www.dailymotion.com/embed/video/$1',