plugin.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. /**
  2. * Copyright (c) Tiny Technologies, Inc. All rights reserved.
  3. * Licensed under the LGPL or a commercial license.
  4. * For LGPL see License.txt in the project root for license information.
  5. * For commercial licenses see https://www.tiny.cloud/
  6. *
  7. * Version: 5.10.2 (2021-11-17)
  8. */
  9. (function () {
  10. 'use strict';
  11. var global$9 = tinymce.util.Tools.resolve('tinymce.PluginManager');
  12. var __assign = function () {
  13. __assign = Object.assign || function __assign(t) {
  14. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15. s = arguments[i];
  16. for (var p in s)
  17. if (Object.prototype.hasOwnProperty.call(s, p))
  18. t[p] = s[p];
  19. }
  20. return t;
  21. };
  22. return __assign.apply(this, arguments);
  23. };
  24. var typeOf = function (x) {
  25. var t = typeof x;
  26. if (x === null) {
  27. return 'null';
  28. } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
  29. return 'array';
  30. } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
  31. return 'string';
  32. } else {
  33. return t;
  34. }
  35. };
  36. var isType = function (type) {
  37. return function (value) {
  38. return typeOf(value) === type;
  39. };
  40. };
  41. var isString = isType('string');
  42. var isObject = isType('object');
  43. var isArray = isType('array');
  44. var isNullable = function (a) {
  45. return a === null || a === undefined;
  46. };
  47. var isNonNullable = function (a) {
  48. return !isNullable(a);
  49. };
  50. var noop = function () {
  51. };
  52. var constant = function (value) {
  53. return function () {
  54. return value;
  55. };
  56. };
  57. var identity = function (x) {
  58. return x;
  59. };
  60. var never = constant(false);
  61. var always = constant(true);
  62. var none = function () {
  63. return NONE;
  64. };
  65. var NONE = function () {
  66. var call = function (thunk) {
  67. return thunk();
  68. };
  69. var id = identity;
  70. var me = {
  71. fold: function (n, _s) {
  72. return n();
  73. },
  74. isSome: never,
  75. isNone: always,
  76. getOr: id,
  77. getOrThunk: call,
  78. getOrDie: function (msg) {
  79. throw new Error(msg || 'error: getOrDie called on none.');
  80. },
  81. getOrNull: constant(null),
  82. getOrUndefined: constant(undefined),
  83. or: id,
  84. orThunk: call,
  85. map: none,
  86. each: noop,
  87. bind: none,
  88. exists: never,
  89. forall: always,
  90. filter: function () {
  91. return none();
  92. },
  93. toArray: function () {
  94. return [];
  95. },
  96. toString: constant('none()')
  97. };
  98. return me;
  99. }();
  100. var some = function (a) {
  101. var constant_a = constant(a);
  102. var self = function () {
  103. return me;
  104. };
  105. var bind = function (f) {
  106. return f(a);
  107. };
  108. var me = {
  109. fold: function (n, s) {
  110. return s(a);
  111. },
  112. isSome: always,
  113. isNone: never,
  114. getOr: constant_a,
  115. getOrThunk: constant_a,
  116. getOrDie: constant_a,
  117. getOrNull: constant_a,
  118. getOrUndefined: constant_a,
  119. or: self,
  120. orThunk: self,
  121. map: function (f) {
  122. return some(f(a));
  123. },
  124. each: function (f) {
  125. f(a);
  126. },
  127. bind: bind,
  128. exists: bind,
  129. forall: bind,
  130. filter: function (f) {
  131. return f(a) ? me : NONE;
  132. },
  133. toArray: function () {
  134. return [a];
  135. },
  136. toString: function () {
  137. return 'some(' + a + ')';
  138. }
  139. };
  140. return me;
  141. };
  142. var from = function (value) {
  143. return value === null || value === undefined ? NONE : some(value);
  144. };
  145. var Optional = {
  146. some: some,
  147. none: none,
  148. from: from
  149. };
  150. var nativePush = Array.prototype.push;
  151. var each$1 = function (xs, f) {
  152. for (var i = 0, len = xs.length; i < len; i++) {
  153. var x = xs[i];
  154. f(x, i);
  155. }
  156. };
  157. var flatten = function (xs) {
  158. var r = [];
  159. for (var i = 0, len = xs.length; i < len; ++i) {
  160. if (!isArray(xs[i])) {
  161. throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
  162. }
  163. nativePush.apply(r, xs[i]);
  164. }
  165. return r;
  166. };
  167. var Cell = function (initial) {
  168. var value = initial;
  169. var get = function () {
  170. return value;
  171. };
  172. var set = function (v) {
  173. value = v;
  174. };
  175. return {
  176. get: get,
  177. set: set
  178. };
  179. };
  180. var keys = Object.keys;
  181. var hasOwnProperty = Object.hasOwnProperty;
  182. var each = function (obj, f) {
  183. var props = keys(obj);
  184. for (var k = 0, len = props.length; k < len; k++) {
  185. var i = props[k];
  186. var x = obj[i];
  187. f(x, i);
  188. }
  189. };
  190. var get$1 = function (obj, key) {
  191. return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
  192. };
  193. var has = function (obj, key) {
  194. return hasOwnProperty.call(obj, key);
  195. };
  196. var getScripts = function (editor) {
  197. return editor.getParam('media_scripts');
  198. };
  199. var getAudioTemplateCallback = function (editor) {
  200. return editor.getParam('audio_template_callback');
  201. };
  202. var getVideoTemplateCallback = function (editor) {
  203. return editor.getParam('video_template_callback');
  204. };
  205. var hasLiveEmbeds = function (editor) {
  206. return editor.getParam('media_live_embeds', true);
  207. };
  208. var shouldFilterHtml = function (editor) {
  209. return editor.getParam('media_filter_html', true);
  210. };
  211. var getUrlResolver = function (editor) {
  212. return editor.getParam('media_url_resolver');
  213. };
  214. var hasAltSource = function (editor) {
  215. return editor.getParam('media_alt_source', true);
  216. };
  217. var hasPoster = function (editor) {
  218. return editor.getParam('media_poster', true);
  219. };
  220. var hasDimensions = function (editor) {
  221. return editor.getParam('media_dimensions', true);
  222. };
  223. var global$8 = tinymce.util.Tools.resolve('tinymce.util.Tools');
  224. var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
  225. var global$6 = tinymce.util.Tools.resolve('tinymce.html.SaxParser');
  226. var getVideoScriptMatch = function (prefixes, src) {
  227. if (prefixes) {
  228. for (var i = 0; i < prefixes.length; i++) {
  229. if (src.indexOf(prefixes[i].filter) !== -1) {
  230. return prefixes[i];
  231. }
  232. }
  233. }
  234. };
  235. var DOM$1 = global$7.DOM;
  236. var trimPx = function (value) {
  237. return value.replace(/px$/, '');
  238. };
  239. var getEphoxEmbedData = function (attrs) {
  240. var style = attrs.map.style;
  241. var styles = style ? DOM$1.parseStyle(style) : {};
  242. return {
  243. type: 'ephox-embed-iri',
  244. source: attrs.map['data-ephox-embed-iri'],
  245. altsource: '',
  246. poster: '',
  247. width: get$1(styles, 'max-width').map(trimPx).getOr(''),
  248. height: get$1(styles, 'max-height').map(trimPx).getOr('')
  249. };
  250. };
  251. var htmlToData = function (prefixes, html) {
  252. var isEphoxEmbed = Cell(false);
  253. var data = {};
  254. global$6({
  255. validate: false,
  256. allow_conditional_comments: true,
  257. start: function (name, attrs) {
  258. if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
  259. isEphoxEmbed.set(true);
  260. data = getEphoxEmbedData(attrs);
  261. } else {
  262. if (!data.source && name === 'param') {
  263. data.source = attrs.map.movie;
  264. }
  265. if (name === 'iframe' || name === 'object' || name === 'embed' || name === 'video' || name === 'audio') {
  266. if (!data.type) {
  267. data.type = name;
  268. }
  269. data = global$8.extend(attrs.map, data);
  270. }
  271. if (name === 'script') {
  272. var videoScript = getVideoScriptMatch(prefixes, attrs.map.src);
  273. if (!videoScript) {
  274. return;
  275. }
  276. data = {
  277. type: 'script',
  278. source: attrs.map.src,
  279. width: String(videoScript.width),
  280. height: String(videoScript.height)
  281. };
  282. }
  283. if (name === 'source') {
  284. if (!data.source) {
  285. data.source = attrs.map.src;
  286. } else if (!data.altsource) {
  287. data.altsource = attrs.map.src;
  288. }
  289. }
  290. if (name === 'img' && !data.poster) {
  291. data.poster = attrs.map.src;
  292. }
  293. }
  294. }
  295. }).parse(html);
  296. data.source = data.source || data.src || data.data;
  297. data.altsource = data.altsource || '';
  298. data.poster = data.poster || '';
  299. return data;
  300. };
  301. var guess = function (url) {
  302. var mimes = {
  303. mp3: 'audio/mpeg',
  304. m4a: 'audio/x-m4a',
  305. wav: 'audio/wav',
  306. mp4: 'video/mp4',
  307. webm: 'video/webm',
  308. ogg: 'video/ogg',
  309. swf: 'application/x-shockwave-flash'
  310. };
  311. var fileEnd = url.toLowerCase().split('.').pop();
  312. var mime = mimes[fileEnd];
  313. return mime ? mime : '';
  314. };
  315. var global$5 = tinymce.util.Tools.resolve('tinymce.html.Schema');
  316. var global$4 = tinymce.util.Tools.resolve('tinymce.html.Writer');
  317. var DOM = global$7.DOM;
  318. var addPx = function (value) {
  319. return /^[0-9.]+$/.test(value) ? value + 'px' : value;
  320. };
  321. var setAttributes = function (attrs, updatedAttrs) {
  322. each(updatedAttrs, function (val, name) {
  323. var value = '' + val;
  324. if (attrs.map[name]) {
  325. var i = attrs.length;
  326. while (i--) {
  327. var attr = attrs[i];
  328. if (attr.name === name) {
  329. if (value) {
  330. attrs.map[name] = value;
  331. attr.value = value;
  332. } else {
  333. delete attrs.map[name];
  334. attrs.splice(i, 1);
  335. }
  336. }
  337. }
  338. } else if (value) {
  339. attrs.push({
  340. name: name,
  341. value: value
  342. });
  343. attrs.map[name] = value;
  344. }
  345. });
  346. };
  347. var updateEphoxEmbed = function (data, attrs) {
  348. var style = attrs.map.style;
  349. var styleMap = style ? DOM.parseStyle(style) : {};
  350. styleMap['max-width'] = addPx(data.width);
  351. styleMap['max-height'] = addPx(data.height);
  352. setAttributes(attrs, { style: DOM.serializeStyle(styleMap) });
  353. };
  354. var sources = [
  355. 'source',
  356. 'altsource'
  357. ];
  358. var updateHtml = function (html, data, updateAll) {
  359. var writer = global$4();
  360. var isEphoxEmbed = Cell(false);
  361. var sourceCount = 0;
  362. var hasImage;
  363. global$6({
  364. validate: false,
  365. allow_conditional_comments: true,
  366. comment: function (text) {
  367. writer.comment(text);
  368. },
  369. cdata: function (text) {
  370. writer.cdata(text);
  371. },
  372. text: function (text, raw) {
  373. writer.text(text, raw);
  374. },
  375. start: function (name, attrs, empty) {
  376. if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
  377. isEphoxEmbed.set(true);
  378. updateEphoxEmbed(data, attrs);
  379. } else {
  380. switch (name) {
  381. case 'video':
  382. case 'object':
  383. case 'embed':
  384. case 'img':
  385. case 'iframe':
  386. if (data.height !== undefined && data.width !== undefined) {
  387. setAttributes(attrs, {
  388. width: data.width,
  389. height: data.height
  390. });
  391. }
  392. break;
  393. }
  394. if (updateAll) {
  395. switch (name) {
  396. case 'video':
  397. setAttributes(attrs, {
  398. poster: data.poster,
  399. src: ''
  400. });
  401. if (data.altsource) {
  402. setAttributes(attrs, { src: '' });
  403. }
  404. break;
  405. case 'iframe':
  406. setAttributes(attrs, { src: data.source });
  407. break;
  408. case 'source':
  409. if (sourceCount < 2) {
  410. setAttributes(attrs, {
  411. src: data[sources[sourceCount]],
  412. type: data[sources[sourceCount] + 'mime']
  413. });
  414. if (!data[sources[sourceCount]]) {
  415. return;
  416. }
  417. }
  418. sourceCount++;
  419. break;
  420. case 'img':
  421. if (!data.poster) {
  422. return;
  423. }
  424. hasImage = true;
  425. break;
  426. }
  427. }
  428. }
  429. writer.start(name, attrs, empty);
  430. },
  431. end: function (name) {
  432. if (!isEphoxEmbed.get()) {
  433. if (name === 'video' && updateAll) {
  434. for (var index = 0; index < 2; index++) {
  435. if (data[sources[index]]) {
  436. var attrs = [];
  437. attrs.map = {};
  438. if (sourceCount <= index) {
  439. setAttributes(attrs, {
  440. src: data[sources[index]],
  441. type: data[sources[index] + 'mime']
  442. });
  443. writer.start('source', attrs, true);
  444. }
  445. }
  446. }
  447. }
  448. if (data.poster && name === 'object' && updateAll && !hasImage) {
  449. var imgAttrs = [];
  450. imgAttrs.map = {};
  451. setAttributes(imgAttrs, {
  452. src: data.poster,
  453. width: data.width,
  454. height: data.height
  455. });
  456. writer.start('img', imgAttrs, true);
  457. }
  458. }
  459. writer.end(name);
  460. }
  461. }, global$5({})).parse(html);
  462. return writer.getContent();
  463. };
  464. var urlPatterns = [
  465. {
  466. regex: /youtu\.be\/([\w\-_\?&=.]+)/i,
  467. type: 'iframe',
  468. w: 560,
  469. h: 314,
  470. url: 'www.youtube.com/embed/$1',
  471. allowFullscreen: true
  472. },
  473. {
  474. regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,
  475. type: 'iframe',
  476. w: 560,
  477. h: 314,
  478. url: 'www.youtube.com/embed/$2?$4',
  479. allowFullscreen: true
  480. },
  481. {
  482. regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,
  483. type: 'iframe',
  484. w: 560,
  485. h: 314,
  486. url: 'www.youtube.com/embed/$1',
  487. allowFullscreen: true
  488. },
  489. {
  490. regex: /vimeo\.com\/([0-9]+)/,
  491. type: 'iframe',
  492. w: 425,
  493. h: 350,
  494. url: 'player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc',
  495. allowFullscreen: true
  496. },
  497. {
  498. regex: /vimeo\.com\/(.*)\/([0-9]+)/,
  499. type: 'iframe',
  500. w: 425,
  501. h: 350,
  502. url: 'player.vimeo.com/video/$2?title=0&amp;byline=0',
  503. allowFullscreen: true
  504. },
  505. {
  506. regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,
  507. type: 'iframe',
  508. w: 425,
  509. h: 350,
  510. url: 'maps.google.com/maps/ms?msid=$2&output=embed"',
  511. allowFullscreen: false
  512. },
  513. {
  514. regex: /dailymotion\.com\/video\/([^_]+)/,
  515. type: 'iframe',
  516. w: 480,
  517. h: 270,
  518. url: 'www.dailymotion.com/embed/video/$1',
  519. allowFullscreen: true
  520. },
  521. {
  522. regex: /dai\.ly\/([^_]+)/,
  523. type: 'iframe',
  524. w: 480,
  525. h: 270,
  526. url: 'www.dailymotion.com/embed/video/$1',
  527. allowFullscreen: true
  528. }
  529. ];
  530. var getProtocol = function (url) {
  531. var protocolMatches = url.match(/^(https?:\/\/|www\.)(.+)$/i);
  532. if (protocolMatches && protocolMatches.length > 1) {
  533. return protocolMatches[1] === 'www.' ? 'https://' : protocolMatches[1];
  534. } else {
  535. return 'https://';
  536. }
  537. };
  538. var getUrl = function (pattern, url) {
  539. var protocol = getProtocol(url);
  540. var match = pattern.regex.exec(url);
  541. var newUrl = protocol + pattern.url;
  542. var _loop_1 = function (i) {
  543. newUrl = newUrl.replace('$' + i, function () {
  544. return match[i] ? match[i] : '';
  545. });
  546. };
  547. for (var i = 0; i < match.length; i++) {
  548. _loop_1(i);
  549. }
  550. return newUrl.replace(/\?$/, '');
  551. };
  552. var matchPattern = function (url) {
  553. var patterns = urlPatterns.filter(function (pattern) {
  554. return pattern.regex.test(url);
  555. });
  556. if (patterns.length > 0) {
  557. return global$8.extend({}, patterns[0], { url: getUrl(patterns[0], url) });
  558. } else {
  559. return null;
  560. }
  561. };
  562. var getIframeHtml = function (data) {
  563. var allowFullscreen = data.allowfullscreen ? ' allowFullscreen="1"' : '';
  564. return '<iframe src="' + data.source + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
  565. };
  566. var getFlashHtml = function (data) {
  567. var html = '<object data="' + data.source + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
  568. if (data.poster) {
  569. html += '<img src="' + data.poster + '" width="' + data.width + '" height="' + data.height + '" />';
  570. }
  571. html += '</object>';
  572. return html;
  573. };
  574. var getAudioHtml = function (data, audioTemplateCallback) {
  575. if (audioTemplateCallback) {
  576. return audioTemplateCallback(data);
  577. } else {
  578. return '<audio controls="controls" src="' + data.source + '">' + (data.altsource ? '\n<source src="' + data.altsource + '"' + (data.altsourcemime ? ' type="' + data.altsourcemime + '"' : '') + ' />\n' : '') + '</audio>';
  579. }
  580. };
  581. var getVideoHtml = function (data, videoTemplateCallback) {
  582. if (videoTemplateCallback) {
  583. return videoTemplateCallback(data);
  584. } else {
  585. return '<video width="' + data.width + '" height="' + data.height + '"' + (data.poster ? ' poster="' + data.poster + '"' : '') + ' controls="controls">\n' + '<source src="' + data.source + '"' + (data.sourcemime ? ' type="' + data.sourcemime + '"' : '') + ' />\n' + (data.altsource ? '<source src="' + data.altsource + '"' + (data.altsourcemime ? ' type="' + data.altsourcemime + '"' : '') + ' />\n' : '') + '</video>';
  586. }
  587. };
  588. var getScriptHtml = function (data) {
  589. return '<script src="' + data.source + '"></script>';
  590. };
  591. var dataToHtml = function (editor, dataIn) {
  592. var data = global$8.extend({}, dataIn);
  593. if (!data.source) {
  594. global$8.extend(data, htmlToData(getScripts(editor), data.embed));
  595. if (!data.source) {
  596. return '';
  597. }
  598. }
  599. if (!data.altsource) {
  600. data.altsource = '';
  601. }
  602. if (!data.poster) {
  603. data.poster = '';
  604. }
  605. data.source = editor.convertURL(data.source, 'source');
  606. data.altsource = editor.convertURL(data.altsource, 'source');
  607. data.sourcemime = guess(data.source);
  608. data.altsourcemime = guess(data.altsource);
  609. data.poster = editor.convertURL(data.poster, 'poster');
  610. var pattern = matchPattern(data.source);
  611. if (pattern) {
  612. data.source = pattern.url;
  613. data.type = pattern.type;
  614. data.allowfullscreen = pattern.allowFullscreen;
  615. data.width = data.width || String(pattern.w);
  616. data.height = data.height || String(pattern.h);
  617. }
  618. if (data.embed) {
  619. return updateHtml(data.embed, data, true);
  620. } else {
  621. var videoScript = getVideoScriptMatch(getScripts(editor), data.source);
  622. if (videoScript) {
  623. data.type = 'script';
  624. data.width = String(videoScript.width);
  625. data.height = String(videoScript.height);
  626. }
  627. var audioTemplateCallback = getAudioTemplateCallback(editor);
  628. var videoTemplateCallback = getVideoTemplateCallback(editor);
  629. data.width = data.width || '300';
  630. data.height = data.height || '150';
  631. global$8.each(data, function (value, key) {
  632. data[key] = editor.dom.encode('' + value);
  633. });
  634. if (data.type === 'iframe') {
  635. return getIframeHtml(data);
  636. } else if (data.sourcemime === 'application/x-shockwave-flash') {
  637. return getFlashHtml(data);
  638. } else if (data.sourcemime.indexOf('audio') !== -1) {
  639. return getAudioHtml(data, audioTemplateCallback);
  640. } else if (data.type === 'script') {
  641. return getScriptHtml(data);
  642. } else {
  643. return getVideoHtml(data, videoTemplateCallback);
  644. }
  645. }
  646. };
  647. var isMediaElement = function (element) {
  648. return element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri');
  649. };
  650. var setup$2 = function (editor) {
  651. editor.on('click keyup touchend', function () {
  652. var selectedNode = editor.selection.getNode();
  653. if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) {
  654. if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) {
  655. selectedNode.setAttribute('data-mce-selected', '2');
  656. }
  657. }
  658. });
  659. editor.on('ObjectSelected', function (e) {
  660. var objectType = e.target.getAttribute('data-mce-object');
  661. if (objectType === 'script') {
  662. e.preventDefault();
  663. }
  664. });
  665. editor.on('ObjectResized', function (e) {
  666. var target = e.target;
  667. if (target.getAttribute('data-mce-object')) {
  668. var html = target.getAttribute('data-mce-html');
  669. if (html) {
  670. html = unescape(html);
  671. target.setAttribute('data-mce-html', escape(updateHtml(html, {
  672. width: String(e.width),
  673. height: String(e.height)
  674. })));
  675. }
  676. }
  677. });
  678. };
  679. var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise');
  680. var cache = {};
  681. var embedPromise = function (data, dataToHtml, handler) {
  682. return new global$3(function (res, rej) {
  683. var wrappedResolve = function (response) {
  684. if (response.html) {
  685. cache[data.source] = response;
  686. }
  687. return res({
  688. url: data.source,
  689. html: response.html ? response.html : dataToHtml(data)
  690. });
  691. };
  692. if (cache[data.source]) {
  693. wrappedResolve(cache[data.source]);
  694. } else {
  695. handler({ url: data.source }, wrappedResolve, rej);
  696. }
  697. });
  698. };
  699. var defaultPromise = function (data, dataToHtml) {
  700. return global$3.resolve({
  701. html: dataToHtml(data),
  702. url: data.source
  703. });
  704. };
  705. var loadedData = function (editor) {
  706. return function (data) {
  707. return dataToHtml(editor, data);
  708. };
  709. };
  710. var getEmbedHtml = function (editor, data) {
  711. var embedHandler = getUrlResolver(editor);
  712. return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor));
  713. };
  714. var isCached = function (url) {
  715. return has(cache, url);
  716. };
  717. var extractMeta = function (sourceInput, data) {
  718. return get$1(data, sourceInput).bind(function (mainData) {
  719. return get$1(mainData, 'meta');
  720. });
  721. };
  722. var getValue = function (data, metaData, sourceInput) {
  723. return function (prop) {
  724. var _a;
  725. var getFromData = function () {
  726. return get$1(data, prop);
  727. };
  728. var getFromMetaData = function () {
  729. return get$1(metaData, prop);
  730. };
  731. var getNonEmptyValue = function (c) {
  732. return get$1(c, 'value').bind(function (v) {
  733. return v.length > 0 ? Optional.some(v) : Optional.none();
  734. });
  735. };
  736. var getFromValueFirst = function () {
  737. return getFromData().bind(function (child) {
  738. return isObject(child) ? getNonEmptyValue(child).orThunk(getFromMetaData) : getFromMetaData().orThunk(function () {
  739. return Optional.from(child);
  740. });
  741. });
  742. };
  743. var getFromMetaFirst = function () {
  744. return getFromMetaData().orThunk(function () {
  745. return getFromData().bind(function (child) {
  746. return isObject(child) ? getNonEmptyValue(child) : Optional.from(child);
  747. });
  748. });
  749. };
  750. return _a = {}, _a[prop] = (prop === sourceInput ? getFromValueFirst() : getFromMetaFirst()).getOr(''), _a;
  751. };
  752. };
  753. var getDimensions = function (data, metaData) {
  754. var dimensions = {};
  755. get$1(data, 'dimensions').each(function (dims) {
  756. each$1([
  757. 'width',
  758. 'height'
  759. ], function (prop) {
  760. get$1(metaData, prop).orThunk(function () {
  761. return get$1(dims, prop);
  762. }).each(function (value) {
  763. return dimensions[prop] = value;
  764. });
  765. });
  766. });
  767. return dimensions;
  768. };
  769. var unwrap = function (data, sourceInput) {
  770. var metaData = sourceInput ? extractMeta(sourceInput, data).getOr({}) : {};
  771. var get = getValue(data, metaData, sourceInput);
  772. return __assign(__assign(__assign(__assign(__assign({}, get('source')), get('altsource')), get('poster')), get('embed')), getDimensions(data, metaData));
  773. };
  774. var wrap = function (data) {
  775. var wrapped = __assign(__assign({}, data), {
  776. source: { value: get$1(data, 'source').getOr('') },
  777. altsource: { value: get$1(data, 'altsource').getOr('') },
  778. poster: { value: get$1(data, 'poster').getOr('') }
  779. });
  780. each$1([
  781. 'width',
  782. 'height'
  783. ], function (prop) {
  784. get$1(data, prop).each(function (value) {
  785. var dimensions = wrapped.dimensions || {};
  786. dimensions[prop] = value;
  787. wrapped.dimensions = dimensions;
  788. });
  789. });
  790. return wrapped;
  791. };
  792. var handleError = function (editor) {
  793. return function (error) {
  794. var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.';
  795. editor.notificationManager.open({
  796. type: 'error',
  797. text: errorMessage
  798. });
  799. };
  800. };
  801. var snippetToData = function (editor, embedSnippet) {
  802. return htmlToData(getScripts(editor), embedSnippet);
  803. };
  804. var getEditorData = function (editor) {
  805. var element = editor.selection.getNode();
  806. var snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : '';
  807. return __assign({ embed: snippet }, htmlToData(getScripts(editor), snippet));
  808. };
  809. var addEmbedHtml = function (api, editor) {
  810. return function (response) {
  811. if (isString(response.url) && response.url.trim().length > 0) {
  812. var html = response.html;
  813. var snippetData = snippetToData(editor, html);
  814. var nuData = __assign(__assign({}, snippetData), {
  815. source: response.url,
  816. embed: html
  817. });
  818. api.setData(wrap(nuData));
  819. }
  820. };
  821. };
  822. var selectPlaceholder = function (editor, beforeObjects) {
  823. var afterObjects = editor.dom.select('*[data-mce-object]');
  824. for (var i = 0; i < beforeObjects.length; i++) {
  825. for (var y = afterObjects.length - 1; y >= 0; y--) {
  826. if (beforeObjects[i] === afterObjects[y]) {
  827. afterObjects.splice(y, 1);
  828. }
  829. }
  830. }
  831. editor.selection.select(afterObjects[0]);
  832. };
  833. var handleInsert = function (editor, html) {
  834. var beforeObjects = editor.dom.select('*[data-mce-object]');
  835. editor.insertContent(html);
  836. selectPlaceholder(editor, beforeObjects);
  837. editor.nodeChanged();
  838. };
  839. var submitForm = function (prevData, newData, editor) {
  840. newData.embed = updateHtml(newData.embed, newData);
  841. if (newData.embed && (prevData.source === newData.source || isCached(newData.source))) {
  842. handleInsert(editor, newData.embed);
  843. } else {
  844. getEmbedHtml(editor, newData).then(function (response) {
  845. handleInsert(editor, response.html);
  846. }).catch(handleError(editor));
  847. }
  848. };
  849. var showDialog = function (editor) {
  850. var editorData = getEditorData(editor);
  851. var currentData = Cell(editorData);
  852. var initialData = wrap(editorData);
  853. var handleSource = function (prevData, api) {
  854. var serviceData = unwrap(api.getData(), 'source');
  855. if (prevData.source !== serviceData.source) {
  856. addEmbedHtml(win, editor)({
  857. url: serviceData.source,
  858. html: ''
  859. });
  860. getEmbedHtml(editor, serviceData).then(addEmbedHtml(win, editor)).catch(handleError(editor));
  861. }
  862. };
  863. var handleEmbed = function (api) {
  864. var data = unwrap(api.getData());
  865. var dataFromEmbed = snippetToData(editor, data.embed);
  866. api.setData(wrap(dataFromEmbed));
  867. };
  868. var handleUpdate = function (api, sourceInput) {
  869. var data = unwrap(api.getData(), sourceInput);
  870. var embed = dataToHtml(editor, data);
  871. api.setData(wrap(__assign(__assign({}, data), { embed: embed })));
  872. };
  873. var mediaInput = [{
  874. name: 'source',
  875. type: 'urlinput',
  876. filetype: 'media',
  877. label: 'Source'
  878. }];
  879. var sizeInput = !hasDimensions(editor) ? [] : [{
  880. type: 'sizeinput',
  881. name: 'dimensions',
  882. label: 'Constrain proportions',
  883. constrain: true
  884. }];
  885. var generalTab = {
  886. title: 'General',
  887. name: 'general',
  888. items: flatten([
  889. mediaInput,
  890. sizeInput
  891. ])
  892. };
  893. var embedTextarea = {
  894. type: 'textarea',
  895. name: 'embed',
  896. label: 'Paste your embed code below:'
  897. };
  898. var embedTab = {
  899. title: 'Embed',
  900. items: [embedTextarea]
  901. };
  902. var advancedFormItems = [];
  903. if (hasAltSource(editor)) {
  904. advancedFormItems.push({
  905. name: 'altsource',
  906. type: 'urlinput',
  907. filetype: 'media',
  908. label: 'Alternative source URL'
  909. });
  910. }
  911. if (hasPoster(editor)) {
  912. advancedFormItems.push({
  913. name: 'poster',
  914. type: 'urlinput',
  915. filetype: 'image',
  916. label: 'Media poster (Image URL)'
  917. });
  918. }
  919. var advancedTab = {
  920. title: 'Advanced',
  921. name: 'advanced',
  922. items: advancedFormItems
  923. };
  924. var tabs = [
  925. generalTab,
  926. embedTab
  927. ];
  928. if (advancedFormItems.length > 0) {
  929. tabs.push(advancedTab);
  930. }
  931. var body = {
  932. type: 'tabpanel',
  933. tabs: tabs
  934. };
  935. var win = editor.windowManager.open({
  936. title: 'Insert/Edit Media',
  937. size: 'normal',
  938. body: body,
  939. buttons: [
  940. {
  941. type: 'cancel',
  942. name: 'cancel',
  943. text: 'Cancel'
  944. },
  945. {
  946. type: 'submit',
  947. name: 'save',
  948. text: 'Save',
  949. primary: true
  950. }
  951. ],
  952. onSubmit: function (api) {
  953. var serviceData = unwrap(api.getData());
  954. submitForm(currentData.get(), serviceData, editor);
  955. api.close();
  956. },
  957. onChange: function (api, detail) {
  958. switch (detail.name) {
  959. case 'source':
  960. handleSource(currentData.get(), api);
  961. break;
  962. case 'embed':
  963. handleEmbed(api);
  964. break;
  965. case 'dimensions':
  966. case 'altsource':
  967. case 'poster':
  968. handleUpdate(api, detail.name);
  969. break;
  970. }
  971. currentData.set(unwrap(api.getData()));
  972. },
  973. initialData: initialData
  974. });
  975. };
  976. var get = function (editor) {
  977. var showDialog$1 = function () {
  978. showDialog(editor);
  979. };
  980. return { showDialog: showDialog$1 };
  981. };
  982. var register$1 = function (editor) {
  983. var showDialog$1 = function () {
  984. showDialog(editor);
  985. };
  986. editor.addCommand('mceMedia', showDialog$1);
  987. };
  988. var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node');
  989. var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
  990. var global = tinymce.util.Tools.resolve('tinymce.html.DomParser');
  991. var sanitize = function (editor, html) {
  992. if (shouldFilterHtml(editor) === false) {
  993. return html;
  994. }
  995. var writer = global$4();
  996. var blocked;
  997. global$6({
  998. validate: false,
  999. allow_conditional_comments: false,
  1000. comment: function (text) {
  1001. if (!blocked) {
  1002. writer.comment(text);
  1003. }
  1004. },
  1005. cdata: function (text) {
  1006. if (!blocked) {
  1007. writer.cdata(text);
  1008. }
  1009. },
  1010. text: function (text, raw) {
  1011. if (!blocked) {
  1012. writer.text(text, raw);
  1013. }
  1014. },
  1015. start: function (name, attrs, empty) {
  1016. blocked = true;
  1017. if (name === 'script' || name === 'noscript' || name === 'svg') {
  1018. return;
  1019. }
  1020. for (var i = attrs.length - 1; i >= 0; i--) {
  1021. var attrName = attrs[i].name;
  1022. if (attrName.indexOf('on') === 0) {
  1023. delete attrs.map[attrName];
  1024. attrs.splice(i, 1);
  1025. }
  1026. if (attrName === 'style') {
  1027. attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
  1028. }
  1029. }
  1030. writer.start(name, attrs, empty);
  1031. blocked = false;
  1032. },
  1033. end: function (name) {
  1034. if (blocked) {
  1035. return;
  1036. }
  1037. writer.end(name);
  1038. }
  1039. }, global$5({})).parse(html);
  1040. return writer.getContent();
  1041. };
  1042. var isLiveEmbedNode = function (node) {
  1043. var name = node.name;
  1044. return name === 'iframe' || name === 'video' || name === 'audio';
  1045. };
  1046. var getDimension = function (node, styles, dimension, defaultValue) {
  1047. if (defaultValue === void 0) {
  1048. defaultValue = null;
  1049. }
  1050. var value = node.attr(dimension);
  1051. if (isNonNullable(value)) {
  1052. return value;
  1053. } else if (!has(styles, dimension)) {
  1054. return defaultValue;
  1055. } else {
  1056. return null;
  1057. }
  1058. };
  1059. var setDimensions = function (node, previewNode, styles) {
  1060. var useDefaults = previewNode.name === 'img' || node.name === 'video';
  1061. var defaultWidth = useDefaults ? '300' : null;
  1062. var fallbackHeight = node.name === 'audio' ? '30' : '150';
  1063. var defaultHeight = useDefaults ? fallbackHeight : null;
  1064. previewNode.attr({
  1065. width: getDimension(node, styles, 'width', defaultWidth),
  1066. height: getDimension(node, styles, 'height', defaultHeight)
  1067. });
  1068. };
  1069. var appendNodeContent = function (editor, nodeName, previewNode, html) {
  1070. var newNode = global({
  1071. forced_root_block: false,
  1072. validate: false
  1073. }, editor.schema).parse(html, { context: nodeName });
  1074. while (newNode.firstChild) {
  1075. previewNode.append(newNode.firstChild);
  1076. }
  1077. };
  1078. var createPlaceholderNode = function (editor, node) {
  1079. var name = node.name;
  1080. var placeHolder = new global$2('img', 1);
  1081. placeHolder.shortEnded = true;
  1082. retainAttributesAndInnerHtml(editor, node, placeHolder);
  1083. setDimensions(node, placeHolder, {});
  1084. placeHolder.attr({
  1085. 'style': node.attr('style'),
  1086. 'src': global$1.transparentSrc,
  1087. 'data-mce-object': name,
  1088. 'class': 'mce-object mce-object-' + name
  1089. });
  1090. return placeHolder;
  1091. };
  1092. var createPreviewNode = function (editor, node) {
  1093. var name = node.name;
  1094. var previewWrapper = new global$2('span', 1);
  1095. previewWrapper.attr({
  1096. 'contentEditable': 'false',
  1097. 'style': node.attr('style'),
  1098. 'data-mce-object': name,
  1099. 'class': 'mce-preview-object mce-object-' + name
  1100. });
  1101. retainAttributesAndInnerHtml(editor, node, previewWrapper);
  1102. var styles = editor.dom.parseStyle(node.attr('style'));
  1103. var previewNode = new global$2(name, 1);
  1104. setDimensions(node, previewNode, styles);
  1105. previewNode.attr({
  1106. src: node.attr('src'),
  1107. style: node.attr('style'),
  1108. class: node.attr('class')
  1109. });
  1110. if (name === 'iframe') {
  1111. previewNode.attr({
  1112. allowfullscreen: node.attr('allowfullscreen'),
  1113. frameborder: '0'
  1114. });
  1115. } else {
  1116. var attrs = [
  1117. 'controls',
  1118. 'crossorigin',
  1119. 'currentTime',
  1120. 'loop',
  1121. 'muted',
  1122. 'poster',
  1123. 'preload'
  1124. ];
  1125. each$1(attrs, function (attrName) {
  1126. previewNode.attr(attrName, node.attr(attrName));
  1127. });
  1128. var sanitizedHtml = previewWrapper.attr('data-mce-html');
  1129. if (isNonNullable(sanitizedHtml)) {
  1130. appendNodeContent(editor, name, previewNode, unescape(sanitizedHtml));
  1131. }
  1132. }
  1133. var shimNode = new global$2('span', 1);
  1134. shimNode.attr('class', 'mce-shim');
  1135. previewWrapper.append(previewNode);
  1136. previewWrapper.append(shimNode);
  1137. return previewWrapper;
  1138. };
  1139. var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) {
  1140. var attribs = sourceNode.attributes;
  1141. var ai = attribs.length;
  1142. while (ai--) {
  1143. var attrName = attribs[ai].name;
  1144. var attrValue = attribs[ai].value;
  1145. if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') {
  1146. if (attrName === 'data' || attrName === 'src') {
  1147. attrValue = editor.convertURL(attrValue, attrName);
  1148. }
  1149. targetNode.attr('data-mce-p-' + attrName, attrValue);
  1150. }
  1151. }
  1152. var innerHtml = sourceNode.firstChild && sourceNode.firstChild.value;
  1153. if (innerHtml) {
  1154. targetNode.attr('data-mce-html', escape(sanitize(editor, innerHtml)));
  1155. targetNode.firstChild = null;
  1156. }
  1157. };
  1158. var isPageEmbedWrapper = function (node) {
  1159. var nodeClass = node.attr('class');
  1160. return nodeClass && /\btiny-pageembed\b/.test(nodeClass);
  1161. };
  1162. var isWithinEmbedWrapper = function (node) {
  1163. while (node = node.parent) {
  1164. if (node.attr('data-ephox-embed-iri') || isPageEmbedWrapper(node)) {
  1165. return true;
  1166. }
  1167. }
  1168. return false;
  1169. };
  1170. var placeHolderConverter = function (editor) {
  1171. return function (nodes) {
  1172. var i = nodes.length;
  1173. var node;
  1174. var videoScript;
  1175. while (i--) {
  1176. node = nodes[i];
  1177. if (!node.parent) {
  1178. continue;
  1179. }
  1180. if (node.parent.attr('data-mce-object')) {
  1181. continue;
  1182. }
  1183. if (node.name === 'script') {
  1184. videoScript = getVideoScriptMatch(getScripts(editor), node.attr('src'));
  1185. if (!videoScript) {
  1186. continue;
  1187. }
  1188. }
  1189. if (videoScript) {
  1190. if (videoScript.width) {
  1191. node.attr('width', videoScript.width.toString());
  1192. }
  1193. if (videoScript.height) {
  1194. node.attr('height', videoScript.height.toString());
  1195. }
  1196. }
  1197. if (isLiveEmbedNode(node) && hasLiveEmbeds(editor) && global$1.ceFalse) {
  1198. if (!isWithinEmbedWrapper(node)) {
  1199. node.replace(createPreviewNode(editor, node));
  1200. }
  1201. } else {
  1202. if (!isWithinEmbedWrapper(node)) {
  1203. node.replace(createPlaceholderNode(editor, node));
  1204. }
  1205. }
  1206. }
  1207. };
  1208. };
  1209. var setup$1 = function (editor) {
  1210. editor.on('preInit', function () {
  1211. var specialElements = editor.schema.getSpecialElements();
  1212. global$8.each('video audio iframe object'.split(' '), function (name) {
  1213. specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi');
  1214. });
  1215. var boolAttrs = editor.schema.getBoolAttrs();
  1216. global$8.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) {
  1217. boolAttrs[name] = {};
  1218. });
  1219. editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', placeHolderConverter(editor));
  1220. editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) {
  1221. var i = nodes.length;
  1222. var node;
  1223. var realElm;
  1224. var ai;
  1225. var attribs;
  1226. var innerHtml;
  1227. var innerNode;
  1228. var realElmName;
  1229. var className;
  1230. while (i--) {
  1231. node = nodes[i];
  1232. if (!node.parent) {
  1233. continue;
  1234. }
  1235. realElmName = node.attr(name);
  1236. realElm = new global$2(realElmName, 1);
  1237. if (realElmName !== 'audio' && realElmName !== 'script') {
  1238. className = node.attr('class');
  1239. if (className && className.indexOf('mce-preview-object') !== -1) {
  1240. realElm.attr({
  1241. width: node.firstChild.attr('width'),
  1242. height: node.firstChild.attr('height')
  1243. });
  1244. } else {
  1245. realElm.attr({
  1246. width: node.attr('width'),
  1247. height: node.attr('height')
  1248. });
  1249. }
  1250. }
  1251. realElm.attr({ style: node.attr('style') });
  1252. attribs = node.attributes;
  1253. ai = attribs.length;
  1254. while (ai--) {
  1255. var attrName = attribs[ai].name;
  1256. if (attrName.indexOf('data-mce-p-') === 0) {
  1257. realElm.attr(attrName.substr(11), attribs[ai].value);
  1258. }
  1259. }
  1260. if (realElmName === 'script') {
  1261. realElm.attr('type', 'text/javascript');
  1262. }
  1263. innerHtml = node.attr('data-mce-html');
  1264. if (innerHtml) {
  1265. innerNode = new global$2('#text', 3);
  1266. innerNode.raw = true;
  1267. innerNode.value = sanitize(editor, unescape(innerHtml));
  1268. realElm.append(innerNode);
  1269. }
  1270. node.replace(realElm);
  1271. }
  1272. });
  1273. });
  1274. editor.on('SetContent', function () {
  1275. editor.$('span.mce-preview-object').each(function (index, elm) {
  1276. var $elm = editor.$(elm);
  1277. if ($elm.find('span.mce-shim').length === 0) {
  1278. $elm.append('<span class="mce-shim"></span>');
  1279. }
  1280. });
  1281. });
  1282. };
  1283. var setup = function (editor) {
  1284. editor.on('ResolveName', function (e) {
  1285. var name;
  1286. if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) {
  1287. e.name = name;
  1288. }
  1289. });
  1290. };
  1291. var register = function (editor) {
  1292. var onAction = function () {
  1293. return editor.execCommand('mceMedia');
  1294. };
  1295. editor.ui.registry.addToggleButton('media', {
  1296. tooltip: 'Insert/edit media',
  1297. icon: 'embed',
  1298. onAction: onAction,
  1299. onSetup: function (buttonApi) {
  1300. var selection = editor.selection;
  1301. buttonApi.setActive(isMediaElement(selection.getNode()));
  1302. return selection.selectorChangedWithUnbind('img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]', buttonApi.setActive).unbind;
  1303. }
  1304. });
  1305. editor.ui.registry.addMenuItem('media', {
  1306. icon: 'embed',
  1307. text: 'Media...',
  1308. onAction: onAction
  1309. });
  1310. };
  1311. function Plugin () {
  1312. global$9.add('media', function (editor) {
  1313. register$1(editor);
  1314. register(editor);
  1315. setup(editor);
  1316. setup$1(editor);
  1317. setup$2(editor);
  1318. return get(editor);
  1319. });
  1320. }
  1321. Plugin();
  1322. }());