plugin.js 42 KB

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