plugin.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863
  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.0.7 (2019-06-05)
  8. */
  9. (function () {
  10. var paste = (function (domGlobals) {
  11. 'use strict';
  12. var Cell = function (initial) {
  13. var value = initial;
  14. var get = function () {
  15. return value;
  16. };
  17. var set = function (v) {
  18. value = v;
  19. };
  20. var clone = function () {
  21. return Cell(get());
  22. };
  23. return {
  24. get: get,
  25. set: set,
  26. clone: clone
  27. };
  28. };
  29. var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
  30. var hasProPlugin = function (editor) {
  31. if (/(^|[ ,])powerpaste([, ]|$)/.test(editor.settings.plugins) && global.get('powerpaste')) {
  32. if (typeof domGlobals.window.console !== 'undefined' && domGlobals.window.console.log) {
  33. domGlobals.window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.');
  34. }
  35. return true;
  36. } else {
  37. return false;
  38. }
  39. };
  40. var DetectProPlugin = { hasProPlugin: hasProPlugin };
  41. var get = function (clipboard, quirks) {
  42. return {
  43. clipboard: clipboard,
  44. quirks: quirks
  45. };
  46. };
  47. var Api = { get: get };
  48. var firePastePreProcess = function (editor, html, internal, isWordHtml) {
  49. return editor.fire('PastePreProcess', {
  50. content: html,
  51. internal: internal,
  52. wordContent: isWordHtml
  53. });
  54. };
  55. var firePastePostProcess = function (editor, node, internal, isWordHtml) {
  56. return editor.fire('PastePostProcess', {
  57. node: node,
  58. internal: internal,
  59. wordContent: isWordHtml
  60. });
  61. };
  62. var firePastePlainTextToggle = function (editor, state) {
  63. return editor.fire('PastePlainTextToggle', { state: state });
  64. };
  65. var firePaste = function (editor, ieFake) {
  66. return editor.fire('paste', { ieFake: ieFake });
  67. };
  68. var Events = {
  69. firePastePreProcess: firePastePreProcess,
  70. firePastePostProcess: firePastePostProcess,
  71. firePastePlainTextToggle: firePastePlainTextToggle,
  72. firePaste: firePaste
  73. };
  74. var togglePlainTextPaste = function (editor, clipboard) {
  75. if (clipboard.pasteFormat.get() === 'text') {
  76. clipboard.pasteFormat.set('html');
  77. Events.firePastePlainTextToggle(editor, false);
  78. } else {
  79. clipboard.pasteFormat.set('text');
  80. Events.firePastePlainTextToggle(editor, true);
  81. }
  82. editor.focus();
  83. };
  84. var Actions = { togglePlainTextPaste: togglePlainTextPaste };
  85. var register = function (editor, clipboard) {
  86. editor.addCommand('mceTogglePlainTextPaste', function () {
  87. Actions.togglePlainTextPaste(editor, clipboard);
  88. });
  89. editor.addCommand('mceInsertClipboardContent', function (ui, value) {
  90. if (value.content) {
  91. clipboard.pasteHtml(value.content, value.internal);
  92. }
  93. if (value.text) {
  94. clipboard.pasteText(value.text);
  95. }
  96. });
  97. };
  98. var Commands = { register: register };
  99. var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
  100. var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
  101. var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
  102. var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK');
  103. var internalMimeType = 'x-tinymce/html';
  104. var internalMark = '<!-- ' + internalMimeType + ' -->';
  105. var mark = function (html) {
  106. return internalMark + html;
  107. };
  108. var unmark = function (html) {
  109. return html.replace(internalMark, '');
  110. };
  111. var isMarked = function (html) {
  112. return html.indexOf(internalMark) !== -1;
  113. };
  114. var InternalHtml = {
  115. mark: mark,
  116. unmark: unmark,
  117. isMarked: isMarked,
  118. internalHtmlMime: function () {
  119. return internalMimeType;
  120. }
  121. };
  122. var global$5 = tinymce.util.Tools.resolve('tinymce.html.Entities');
  123. var isPlainText = function (text) {
  124. return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text);
  125. };
  126. var toBRs = function (text) {
  127. return text.replace(/\r?\n/g, '<br>');
  128. };
  129. var openContainer = function (rootTag, rootAttrs) {
  130. var key;
  131. var attrs = [];
  132. var tag = '<' + rootTag;
  133. if (typeof rootAttrs === 'object') {
  134. for (key in rootAttrs) {
  135. if (rootAttrs.hasOwnProperty(key)) {
  136. attrs.push(key + '="' + global$5.encodeAllRaw(rootAttrs[key]) + '"');
  137. }
  138. }
  139. if (attrs.length) {
  140. tag += ' ' + attrs.join(' ');
  141. }
  142. }
  143. return tag + '>';
  144. };
  145. var toBlockElements = function (text, rootTag, rootAttrs) {
  146. var blocks = text.split(/\n\n/);
  147. var tagOpen = openContainer(rootTag, rootAttrs);
  148. var tagClose = '</' + rootTag + '>';
  149. var paragraphs = global$3.map(blocks, function (p) {
  150. return p.split(/\n/).join('<br />');
  151. });
  152. var stitch = function (p) {
  153. return tagOpen + p + tagClose;
  154. };
  155. return paragraphs.length === 1 ? paragraphs[0] : global$3.map(paragraphs, stitch).join('');
  156. };
  157. var convert = function (text, rootTag, rootAttrs) {
  158. return rootTag ? toBlockElements(text, rootTag, rootAttrs) : toBRs(text);
  159. };
  160. var Newlines = {
  161. isPlainText: isPlainText,
  162. convert: convert,
  163. toBRs: toBRs,
  164. toBlockElements: toBlockElements
  165. };
  166. var global$6 = tinymce.util.Tools.resolve('tinymce.html.DomParser');
  167. var global$7 = tinymce.util.Tools.resolve('tinymce.html.Node');
  168. var global$8 = tinymce.util.Tools.resolve('tinymce.html.Schema');
  169. var global$9 = tinymce.util.Tools.resolve('tinymce.html.Serializer');
  170. var shouldBlockDrop = function (editor) {
  171. return editor.getParam('paste_block_drop', false);
  172. };
  173. var shouldPasteDataImages = function (editor) {
  174. return editor.getParam('paste_data_images', false);
  175. };
  176. var shouldFilterDrop = function (editor) {
  177. return editor.getParam('paste_filter_drop', true);
  178. };
  179. var getPreProcess = function (editor) {
  180. return editor.getParam('paste_preprocess');
  181. };
  182. var getPostProcess = function (editor) {
  183. return editor.getParam('paste_postprocess');
  184. };
  185. var getWebkitStyles = function (editor) {
  186. return editor.getParam('paste_webkit_styles');
  187. };
  188. var shouldRemoveWebKitStyles = function (editor) {
  189. return editor.getParam('paste_remove_styles_if_webkit', true);
  190. };
  191. var shouldMergeFormats = function (editor) {
  192. return editor.getParam('paste_merge_formats', true);
  193. };
  194. var isSmartPasteEnabled = function (editor) {
  195. return editor.getParam('smart_paste', true);
  196. };
  197. var isPasteAsTextEnabled = function (editor) {
  198. return editor.getParam('paste_as_text', false);
  199. };
  200. var getRetainStyleProps = function (editor) {
  201. return editor.getParam('paste_retain_style_properties');
  202. };
  203. var getWordValidElements = function (editor) {
  204. var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody';
  205. return editor.getParam('paste_word_valid_elements', defaultValidElements);
  206. };
  207. var shouldConvertWordFakeLists = function (editor) {
  208. return editor.getParam('paste_convert_word_fake_lists', true);
  209. };
  210. var shouldUseDefaultFilters = function (editor) {
  211. return editor.getParam('paste_enable_default_filters', true);
  212. };
  213. var Settings = {
  214. shouldBlockDrop: shouldBlockDrop,
  215. shouldPasteDataImages: shouldPasteDataImages,
  216. shouldFilterDrop: shouldFilterDrop,
  217. getPreProcess: getPreProcess,
  218. getPostProcess: getPostProcess,
  219. getWebkitStyles: getWebkitStyles,
  220. shouldRemoveWebKitStyles: shouldRemoveWebKitStyles,
  221. shouldMergeFormats: shouldMergeFormats,
  222. isSmartPasteEnabled: isSmartPasteEnabled,
  223. isPasteAsTextEnabled: isPasteAsTextEnabled,
  224. getRetainStyleProps: getRetainStyleProps,
  225. getWordValidElements: getWordValidElements,
  226. shouldConvertWordFakeLists: shouldConvertWordFakeLists,
  227. shouldUseDefaultFilters: shouldUseDefaultFilters
  228. };
  229. function filter(content, items) {
  230. global$3.each(items, function (v) {
  231. if (v.constructor === RegExp) {
  232. content = content.replace(v, '');
  233. } else {
  234. content = content.replace(v[0], v[1]);
  235. }
  236. });
  237. return content;
  238. }
  239. function innerText(html) {
  240. var schema = global$8();
  241. var domParser = global$6({}, schema);
  242. var text = '';
  243. var shortEndedElements = schema.getShortEndedElements();
  244. var ignoreElements = global$3.makeMap('script noscript style textarea video audio iframe object', ' ');
  245. var blockElements = schema.getBlockElements();
  246. function walk(node) {
  247. var name = node.name, currentNode = node;
  248. if (name === 'br') {
  249. text += '\n';
  250. return;
  251. }
  252. if (name === 'wbr') {
  253. return;
  254. }
  255. if (shortEndedElements[name]) {
  256. text += ' ';
  257. }
  258. if (ignoreElements[name]) {
  259. text += ' ';
  260. return;
  261. }
  262. if (node.type === 3) {
  263. text += node.value;
  264. }
  265. if (!node.shortEnded) {
  266. if (node = node.firstChild) {
  267. do {
  268. walk(node);
  269. } while (node = node.next);
  270. }
  271. }
  272. if (blockElements[name] && currentNode.next) {
  273. text += '\n';
  274. if (name === 'p') {
  275. text += '\n';
  276. }
  277. }
  278. }
  279. html = filter(html, [/<!\[[^\]]+\]>/g]);
  280. walk(domParser.parse(html));
  281. return text;
  282. }
  283. function trimHtml(html) {
  284. function trimSpaces(all, s1, s2) {
  285. if (!s1 && !s2) {
  286. return ' ';
  287. }
  288. return '\xA0';
  289. }
  290. html = filter(html, [
  291. /^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig,
  292. /<!--StartFragment-->|<!--EndFragment-->/g,
  293. [
  294. /( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,
  295. trimSpaces
  296. ],
  297. /<br class="Apple-interchange-newline">/g,
  298. /<br>$/i
  299. ]);
  300. return html;
  301. }
  302. function createIdGenerator(prefix) {
  303. var count = 0;
  304. return function () {
  305. return prefix + count++;
  306. };
  307. }
  308. var isMsEdge = function () {
  309. return domGlobals.navigator.userAgent.indexOf(' Edge/') !== -1;
  310. };
  311. var Utils = {
  312. filter: filter,
  313. innerText: innerText,
  314. trimHtml: trimHtml,
  315. createIdGenerator: createIdGenerator,
  316. isMsEdge: isMsEdge
  317. };
  318. function isWordContent(content) {
  319. return /<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(content) || /class="OutlineElement/.test(content) || /id="?docs\-internal\-guid\-/.test(content);
  320. }
  321. function isNumericList(text) {
  322. var found, patterns;
  323. patterns = [
  324. /^[IVXLMCD]{1,2}\.[ \u00a0]/,
  325. /^[ivxlmcd]{1,2}\.[ \u00a0]/,
  326. /^[a-z]{1,2}[\.\)][ \u00a0]/,
  327. /^[A-Z]{1,2}[\.\)][ \u00a0]/,
  328. /^[0-9]+\.[ \u00a0]/,
  329. /^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,
  330. /^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/
  331. ];
  332. text = text.replace(/^[\u00a0 ]+/, '');
  333. global$3.each(patterns, function (pattern) {
  334. if (pattern.test(text)) {
  335. found = true;
  336. return false;
  337. }
  338. });
  339. return found;
  340. }
  341. function isBulletList(text) {
  342. return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(text);
  343. }
  344. function convertFakeListsToProperLists(node) {
  345. var currentListNode, prevListNode, lastLevel = 1;
  346. function getText(node) {
  347. var txt = '';
  348. if (node.type === 3) {
  349. return node.value;
  350. }
  351. if (node = node.firstChild) {
  352. do {
  353. txt += getText(node);
  354. } while (node = node.next);
  355. }
  356. return txt;
  357. }
  358. function trimListStart(node, regExp) {
  359. if (node.type === 3) {
  360. if (regExp.test(node.value)) {
  361. node.value = node.value.replace(regExp, '');
  362. return false;
  363. }
  364. }
  365. if (node = node.firstChild) {
  366. do {
  367. if (!trimListStart(node, regExp)) {
  368. return false;
  369. }
  370. } while (node = node.next);
  371. }
  372. return true;
  373. }
  374. function removeIgnoredNodes(node) {
  375. if (node._listIgnore) {
  376. node.remove();
  377. return;
  378. }
  379. if (node = node.firstChild) {
  380. do {
  381. removeIgnoredNodes(node);
  382. } while (node = node.next);
  383. }
  384. }
  385. function convertParagraphToLi(paragraphNode, listName, start) {
  386. var level = paragraphNode._listLevel || lastLevel;
  387. if (level !== lastLevel) {
  388. if (level < lastLevel) {
  389. if (currentListNode) {
  390. currentListNode = currentListNode.parent.parent;
  391. }
  392. } else {
  393. prevListNode = currentListNode;
  394. currentListNode = null;
  395. }
  396. }
  397. if (!currentListNode || currentListNode.name !== listName) {
  398. prevListNode = prevListNode || currentListNode;
  399. currentListNode = new global$7(listName, 1);
  400. if (start > 1) {
  401. currentListNode.attr('start', '' + start);
  402. }
  403. paragraphNode.wrap(currentListNode);
  404. } else {
  405. currentListNode.append(paragraphNode);
  406. }
  407. paragraphNode.name = 'li';
  408. if (level > lastLevel && prevListNode) {
  409. prevListNode.lastChild.append(currentListNode);
  410. }
  411. lastLevel = level;
  412. removeIgnoredNodes(paragraphNode);
  413. trimListStart(paragraphNode, /^\u00a0+/);
  414. trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
  415. trimListStart(paragraphNode, /^\u00a0+/);
  416. }
  417. var elements = [];
  418. var child = node.firstChild;
  419. while (typeof child !== 'undefined' && child !== null) {
  420. elements.push(child);
  421. child = child.walk();
  422. if (child !== null) {
  423. while (typeof child !== 'undefined' && child.parent !== node) {
  424. child = child.walk();
  425. }
  426. }
  427. }
  428. for (var i = 0; i < elements.length; i++) {
  429. node = elements[i];
  430. if (node.name === 'p' && node.firstChild) {
  431. var nodeText = getText(node);
  432. if (isBulletList(nodeText)) {
  433. convertParagraphToLi(node, 'ul');
  434. continue;
  435. }
  436. if (isNumericList(nodeText)) {
  437. var matches = /([0-9]+)\./.exec(nodeText);
  438. var start = 1;
  439. if (matches) {
  440. start = parseInt(matches[1], 10);
  441. }
  442. convertParagraphToLi(node, 'ol', start);
  443. continue;
  444. }
  445. if (node._listLevel) {
  446. convertParagraphToLi(node, 'ul', 1);
  447. continue;
  448. }
  449. currentListNode = null;
  450. } else {
  451. prevListNode = currentListNode;
  452. currentListNode = null;
  453. }
  454. }
  455. }
  456. function filterStyles(editor, validStyles, node, styleValue) {
  457. var outputStyles = {}, matches;
  458. var styles = editor.dom.parseStyle(styleValue);
  459. global$3.each(styles, function (value, name) {
  460. switch (name) {
  461. case 'mso-list':
  462. matches = /\w+ \w+([0-9]+)/i.exec(styleValue);
  463. if (matches) {
  464. node._listLevel = parseInt(matches[1], 10);
  465. }
  466. if (/Ignore/i.test(value) && node.firstChild) {
  467. node._listIgnore = true;
  468. node.firstChild._listIgnore = true;
  469. }
  470. break;
  471. case 'horiz-align':
  472. name = 'text-align';
  473. break;
  474. case 'vert-align':
  475. name = 'vertical-align';
  476. break;
  477. case 'font-color':
  478. case 'mso-foreground':
  479. name = 'color';
  480. break;
  481. case 'mso-background':
  482. case 'mso-highlight':
  483. name = 'background';
  484. break;
  485. case 'font-weight':
  486. case 'font-style':
  487. if (value !== 'normal') {
  488. outputStyles[name] = value;
  489. }
  490. return;
  491. case 'mso-element':
  492. if (/^(comment|comment-list)$/i.test(value)) {
  493. node.remove();
  494. return;
  495. }
  496. break;
  497. }
  498. if (name.indexOf('mso-comment') === 0) {
  499. node.remove();
  500. return;
  501. }
  502. if (name.indexOf('mso-') === 0) {
  503. return;
  504. }
  505. if (Settings.getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) {
  506. outputStyles[name] = value;
  507. }
  508. });
  509. if (/(bold)/i.test(outputStyles['font-weight'])) {
  510. delete outputStyles['font-weight'];
  511. node.wrap(new global$7('b', 1));
  512. }
  513. if (/(italic)/i.test(outputStyles['font-style'])) {
  514. delete outputStyles['font-style'];
  515. node.wrap(new global$7('i', 1));
  516. }
  517. outputStyles = editor.dom.serializeStyle(outputStyles, node.name);
  518. if (outputStyles) {
  519. return outputStyles;
  520. }
  521. return null;
  522. }
  523. var filterWordContent = function (editor, content) {
  524. var retainStyleProperties, validStyles;
  525. retainStyleProperties = Settings.getRetainStyleProps(editor);
  526. if (retainStyleProperties) {
  527. validStyles = global$3.makeMap(retainStyleProperties.split(/[, ]/));
  528. }
  529. content = Utils.filter(content, [
  530. /<br class="?Apple-interchange-newline"?>/gi,
  531. /<b[^>]+id="?docs-internal-[^>]*>/gi,
  532. /<!--[\s\S]+?-->/gi,
  533. /<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
  534. [
  535. /<(\/?)s>/gi,
  536. '<$1strike>'
  537. ],
  538. [
  539. /&nbsp;/gi,
  540. '\xA0'
  541. ],
  542. [
  543. /<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
  544. function (str, spaces) {
  545. return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join('\xA0') : '';
  546. }
  547. ]
  548. ]);
  549. var validElements = Settings.getWordValidElements(editor);
  550. var schema = global$8({
  551. valid_elements: validElements,
  552. valid_children: '-li[p]'
  553. });
  554. global$3.each(schema.elements, function (rule) {
  555. if (!rule.attributes.class) {
  556. rule.attributes.class = {};
  557. rule.attributesOrder.push('class');
  558. }
  559. if (!rule.attributes.style) {
  560. rule.attributes.style = {};
  561. rule.attributesOrder.push('style');
  562. }
  563. });
  564. var domParser = global$6({}, schema);
  565. domParser.addAttributeFilter('style', function (nodes) {
  566. var i = nodes.length, node;
  567. while (i--) {
  568. node = nodes[i];
  569. node.attr('style', filterStyles(editor, validStyles, node, node.attr('style')));
  570. if (node.name === 'span' && node.parent && !node.attributes.length) {
  571. node.unwrap();
  572. }
  573. }
  574. });
  575. domParser.addAttributeFilter('class', function (nodes) {
  576. var i = nodes.length, node, className;
  577. while (i--) {
  578. node = nodes[i];
  579. className = node.attr('class');
  580. if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) {
  581. node.remove();
  582. }
  583. node.attr('class', null);
  584. }
  585. });
  586. domParser.addNodeFilter('del', function (nodes) {
  587. var i = nodes.length;
  588. while (i--) {
  589. nodes[i].remove();
  590. }
  591. });
  592. domParser.addNodeFilter('a', function (nodes) {
  593. var i = nodes.length, node, href, name;
  594. while (i--) {
  595. node = nodes[i];
  596. href = node.attr('href');
  597. name = node.attr('name');
  598. if (href && href.indexOf('#_msocom_') !== -1) {
  599. node.remove();
  600. continue;
  601. }
  602. if (href && href.indexOf('file://') === 0) {
  603. href = href.split('#')[1];
  604. if (href) {
  605. href = '#' + href;
  606. }
  607. }
  608. if (!href && !name) {
  609. node.unwrap();
  610. } else {
  611. if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) {
  612. node.unwrap();
  613. continue;
  614. }
  615. node.attr({
  616. href: href,
  617. name: name
  618. });
  619. }
  620. }
  621. });
  622. var rootNode = domParser.parse(content);
  623. if (Settings.shouldConvertWordFakeLists(editor)) {
  624. convertFakeListsToProperLists(rootNode);
  625. }
  626. content = global$9({ validate: editor.settings.validate }, schema).serialize(rootNode);
  627. return content;
  628. };
  629. var preProcess = function (editor, content) {
  630. return Settings.shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content;
  631. };
  632. var WordFilter = {
  633. preProcess: preProcess,
  634. isWordContent: isWordContent
  635. };
  636. var processResult = function (content, cancelled) {
  637. return {
  638. content: content,
  639. cancelled: cancelled
  640. };
  641. };
  642. var postProcessFilter = function (editor, html, internal, isWordHtml) {
  643. var tempBody = editor.dom.create('div', { style: 'display:none' }, html);
  644. var postProcessArgs = Events.firePastePostProcess(editor, tempBody, internal, isWordHtml);
  645. return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented());
  646. };
  647. var filterContent = function (editor, content, internal, isWordHtml) {
  648. var preProcessArgs = Events.firePastePreProcess(editor, content, internal, isWordHtml);
  649. if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) {
  650. return postProcessFilter(editor, preProcessArgs.content, internal, isWordHtml);
  651. } else {
  652. return processResult(preProcessArgs.content, preProcessArgs.isDefaultPrevented());
  653. }
  654. };
  655. var process = function (editor, html, internal) {
  656. var isWordHtml = WordFilter.isWordContent(html);
  657. var content = isWordHtml ? WordFilter.preProcess(editor, html) : html;
  658. return filterContent(editor, content, internal, isWordHtml);
  659. };
  660. var ProcessFilters = { process: process };
  661. var removeMeta = function (editor, html) {
  662. var body = editor.dom.create('body', {}, html);
  663. global$3.each(body.querySelectorAll('meta'), function (elm) {
  664. return elm.parentNode.removeChild(elm);
  665. });
  666. return body.innerHTML;
  667. };
  668. var pasteHtml = function (editor, html) {
  669. editor.insertContent(removeMeta(editor, html), {
  670. merge: Settings.shouldMergeFormats(editor),
  671. paste: true
  672. });
  673. return true;
  674. };
  675. var isAbsoluteUrl = function (url) {
  676. return /^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(url);
  677. };
  678. var isImageUrl = function (url) {
  679. return isAbsoluteUrl(url) && /.(gif|jpe?g|png)$/.test(url);
  680. };
  681. var createImage = function (editor, url, pasteHtmlFn) {
  682. editor.undoManager.extra(function () {
  683. pasteHtmlFn(editor, url);
  684. }, function () {
  685. editor.insertContent('<img src="' + url + '">');
  686. });
  687. return true;
  688. };
  689. var createLink = function (editor, url, pasteHtmlFn) {
  690. editor.undoManager.extra(function () {
  691. pasteHtmlFn(editor, url);
  692. }, function () {
  693. editor.execCommand('mceInsertLink', false, url);
  694. });
  695. return true;
  696. };
  697. var linkSelection = function (editor, html, pasteHtmlFn) {
  698. return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false;
  699. };
  700. var insertImage = function (editor, html, pasteHtmlFn) {
  701. return isImageUrl(html) ? createImage(editor, html, pasteHtmlFn) : false;
  702. };
  703. var smartInsertContent = function (editor, html) {
  704. global$3.each([
  705. linkSelection,
  706. insertImage,
  707. pasteHtml
  708. ], function (action) {
  709. return action(editor, html, pasteHtml) !== true;
  710. });
  711. };
  712. var insertContent = function (editor, html) {
  713. if (Settings.isSmartPasteEnabled(editor) === false) {
  714. pasteHtml(editor, html);
  715. } else {
  716. smartInsertContent(editor, html);
  717. }
  718. };
  719. var SmartPaste = {
  720. isImageUrl: isImageUrl,
  721. isAbsoluteUrl: isAbsoluteUrl,
  722. insertContent: insertContent
  723. };
  724. var constant = function (value) {
  725. return function () {
  726. return value;
  727. };
  728. };
  729. var never = constant(false);
  730. var always = constant(true);
  731. var never$1 = never;
  732. var always$1 = always;
  733. var none = function () {
  734. return NONE;
  735. };
  736. var NONE = function () {
  737. var eq = function (o) {
  738. return o.isNone();
  739. };
  740. var call = function (thunk) {
  741. return thunk();
  742. };
  743. var id = function (n) {
  744. return n;
  745. };
  746. var noop = function () {
  747. };
  748. var nul = function () {
  749. return null;
  750. };
  751. var undef = function () {
  752. return undefined;
  753. };
  754. var me = {
  755. fold: function (n, s) {
  756. return n();
  757. },
  758. is: never$1,
  759. isSome: never$1,
  760. isNone: always$1,
  761. getOr: id,
  762. getOrThunk: call,
  763. getOrDie: function (msg) {
  764. throw new Error(msg || 'error: getOrDie called on none.');
  765. },
  766. getOrNull: nul,
  767. getOrUndefined: undef,
  768. or: id,
  769. orThunk: call,
  770. map: none,
  771. ap: none,
  772. each: noop,
  773. bind: none,
  774. flatten: none,
  775. exists: never$1,
  776. forall: always$1,
  777. filter: none,
  778. equals: eq,
  779. equals_: eq,
  780. toArray: function () {
  781. return [];
  782. },
  783. toString: constant('none()')
  784. };
  785. if (Object.freeze)
  786. Object.freeze(me);
  787. return me;
  788. }();
  789. var some = function (a) {
  790. var constant_a = function () {
  791. return a;
  792. };
  793. var self = function () {
  794. return me;
  795. };
  796. var map = function (f) {
  797. return some(f(a));
  798. };
  799. var bind = function (f) {
  800. return f(a);
  801. };
  802. var me = {
  803. fold: function (n, s) {
  804. return s(a);
  805. },
  806. is: function (v) {
  807. return a === v;
  808. },
  809. isSome: always$1,
  810. isNone: never$1,
  811. getOr: constant_a,
  812. getOrThunk: constant_a,
  813. getOrDie: constant_a,
  814. getOrNull: constant_a,
  815. getOrUndefined: constant_a,
  816. or: self,
  817. orThunk: self,
  818. map: map,
  819. ap: function (optfab) {
  820. return optfab.fold(none, function (fab) {
  821. return some(fab(a));
  822. });
  823. },
  824. each: function (f) {
  825. f(a);
  826. },
  827. bind: bind,
  828. flatten: constant_a,
  829. exists: bind,
  830. forall: bind,
  831. filter: function (f) {
  832. return f(a) ? me : NONE;
  833. },
  834. equals: function (o) {
  835. return o.is(a);
  836. },
  837. equals_: function (o, elementEq) {
  838. return o.fold(never$1, function (b) {
  839. return elementEq(a, b);
  840. });
  841. },
  842. toArray: function () {
  843. return [a];
  844. },
  845. toString: function () {
  846. return 'some(' + a + ')';
  847. }
  848. };
  849. return me;
  850. };
  851. var from = function (value) {
  852. return value === null || value === undefined ? NONE : some(value);
  853. };
  854. var Option = {
  855. some: some,
  856. none: none,
  857. from: from
  858. };
  859. var typeOf = function (x) {
  860. if (x === null)
  861. return 'null';
  862. var t = typeof x;
  863. if (t === 'object' && Array.prototype.isPrototypeOf(x))
  864. return 'array';
  865. if (t === 'object' && String.prototype.isPrototypeOf(x))
  866. return 'string';
  867. return t;
  868. };
  869. var isType = function (type) {
  870. return function (value) {
  871. return typeOf(value) === type;
  872. };
  873. };
  874. var isFunction = isType('function');
  875. var slice = Array.prototype.slice;
  876. var map = function (xs, f) {
  877. var len = xs.length;
  878. var r = new Array(len);
  879. for (var i = 0; i < len; i++) {
  880. var x = xs[i];
  881. r[i] = f(x, i, xs);
  882. }
  883. return r;
  884. };
  885. var each = function (xs, f) {
  886. for (var i = 0, len = xs.length; i < len; i++) {
  887. var x = xs[i];
  888. f(x, i, xs);
  889. }
  890. };
  891. var filter$1 = function (xs, pred) {
  892. var r = [];
  893. for (var i = 0, len = xs.length; i < len; i++) {
  894. var x = xs[i];
  895. if (pred(x, i, xs)) {
  896. r.push(x);
  897. }
  898. }
  899. return r;
  900. };
  901. var from$1 = isFunction(Array.from) ? Array.from : function (x) {
  902. return slice.call(x);
  903. };
  904. var nu = function (baseFn) {
  905. var data = Option.none();
  906. var callbacks = [];
  907. var map = function (f) {
  908. return nu(function (nCallback) {
  909. get(function (data) {
  910. nCallback(f(data));
  911. });
  912. });
  913. };
  914. var get = function (nCallback) {
  915. if (isReady())
  916. call(nCallback);
  917. else
  918. callbacks.push(nCallback);
  919. };
  920. var set = function (x) {
  921. data = Option.some(x);
  922. run(callbacks);
  923. callbacks = [];
  924. };
  925. var isReady = function () {
  926. return data.isSome();
  927. };
  928. var run = function (cbs) {
  929. each(cbs, call);
  930. };
  931. var call = function (cb) {
  932. data.each(function (x) {
  933. domGlobals.setTimeout(function () {
  934. cb(x);
  935. }, 0);
  936. });
  937. };
  938. baseFn(set);
  939. return {
  940. get: get,
  941. map: map,
  942. isReady: isReady
  943. };
  944. };
  945. var pure = function (a) {
  946. return nu(function (callback) {
  947. callback(a);
  948. });
  949. };
  950. var LazyValue = {
  951. nu: nu,
  952. pure: pure
  953. };
  954. var bounce = function (f) {
  955. return function () {
  956. var args = [];
  957. for (var _i = 0; _i < arguments.length; _i++) {
  958. args[_i] = arguments[_i];
  959. }
  960. var me = this;
  961. domGlobals.setTimeout(function () {
  962. f.apply(me, args);
  963. }, 0);
  964. };
  965. };
  966. var nu$1 = function (baseFn) {
  967. var get = function (callback) {
  968. baseFn(bounce(callback));
  969. };
  970. var map = function (fab) {
  971. return nu$1(function (callback) {
  972. get(function (a) {
  973. var value = fab(a);
  974. callback(value);
  975. });
  976. });
  977. };
  978. var bind = function (aFutureB) {
  979. return nu$1(function (callback) {
  980. get(function (a) {
  981. aFutureB(a).get(callback);
  982. });
  983. });
  984. };
  985. var anonBind = function (futureB) {
  986. return nu$1(function (callback) {
  987. get(function (a) {
  988. futureB.get(callback);
  989. });
  990. });
  991. };
  992. var toLazy = function () {
  993. return LazyValue.nu(get);
  994. };
  995. var toCached = function () {
  996. var cache = null;
  997. return nu$1(function (callback) {
  998. if (cache === null) {
  999. cache = toLazy();
  1000. }
  1001. cache.get(callback);
  1002. });
  1003. };
  1004. return {
  1005. map: map,
  1006. bind: bind,
  1007. anonBind: anonBind,
  1008. toLazy: toLazy,
  1009. toCached: toCached,
  1010. get: get
  1011. };
  1012. };
  1013. var pure$1 = function (a) {
  1014. return nu$1(function (callback) {
  1015. callback(a);
  1016. });
  1017. };
  1018. var Future = {
  1019. nu: nu$1,
  1020. pure: pure$1
  1021. };
  1022. var par = function (asyncValues, nu) {
  1023. return nu(function (callback) {
  1024. var r = [];
  1025. var count = 0;
  1026. var cb = function (i) {
  1027. return function (value) {
  1028. r[i] = value;
  1029. count++;
  1030. if (count >= asyncValues.length) {
  1031. callback(r);
  1032. }
  1033. };
  1034. };
  1035. if (asyncValues.length === 0) {
  1036. callback([]);
  1037. } else {
  1038. each(asyncValues, function (asyncValue, i) {
  1039. asyncValue.get(cb(i));
  1040. });
  1041. }
  1042. });
  1043. };
  1044. var par$1 = function (futures) {
  1045. return par(futures, Future.nu);
  1046. };
  1047. var mapM = function (array, fn) {
  1048. var futures = map(array, fn);
  1049. return par$1(futures);
  1050. };
  1051. var value = function () {
  1052. var subject = Cell(Option.none());
  1053. var clear = function () {
  1054. subject.set(Option.none());
  1055. };
  1056. var set = function (s) {
  1057. subject.set(Option.some(s));
  1058. };
  1059. var on = function (f) {
  1060. subject.get().each(f);
  1061. };
  1062. var isSet = function () {
  1063. return subject.get().isSome();
  1064. };
  1065. return {
  1066. clear: clear,
  1067. set: set,
  1068. isSet: isSet,
  1069. on: on
  1070. };
  1071. };
  1072. var pasteHtml$1 = function (editor, html, internalFlag) {
  1073. var internal = internalFlag ? internalFlag : InternalHtml.isMarked(html);
  1074. var args = ProcessFilters.process(editor, InternalHtml.unmark(html), internal);
  1075. if (args.cancelled === false) {
  1076. SmartPaste.insertContent(editor, args.content);
  1077. }
  1078. };
  1079. var pasteText = function (editor, text) {
  1080. text = editor.dom.encode(text).replace(/\r\n/g, '\n');
  1081. text = Newlines.convert(text, editor.settings.forced_root_block, editor.settings.forced_root_block_attrs);
  1082. pasteHtml$1(editor, text, false);
  1083. };
  1084. var getDataTransferItems = function (dataTransfer) {
  1085. var items = {};
  1086. var mceInternalUrlPrefix = 'data:text/mce-internal,';
  1087. if (dataTransfer) {
  1088. if (dataTransfer.getData) {
  1089. var legacyText = dataTransfer.getData('Text');
  1090. if (legacyText && legacyText.length > 0) {
  1091. if (legacyText.indexOf(mceInternalUrlPrefix) === -1) {
  1092. items['text/plain'] = legacyText;
  1093. }
  1094. }
  1095. }
  1096. if (dataTransfer.types) {
  1097. for (var i = 0; i < dataTransfer.types.length; i++) {
  1098. var contentType = dataTransfer.types[i];
  1099. try {
  1100. items[contentType] = dataTransfer.getData(contentType);
  1101. } catch (ex) {
  1102. items[contentType] = '';
  1103. }
  1104. }
  1105. }
  1106. }
  1107. return items;
  1108. };
  1109. var getClipboardContent = function (editor, clipboardEvent) {
  1110. var content = getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer);
  1111. return Utils.isMsEdge() ? global$3.extend(content, { 'text/html': '' }) : content;
  1112. };
  1113. var hasContentType = function (clipboardContent, mimeType) {
  1114. return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
  1115. };
  1116. var hasHtmlOrText = function (content) {
  1117. return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');
  1118. };
  1119. var getBase64FromUri = function (uri) {
  1120. var idx;
  1121. idx = uri.indexOf(',');
  1122. if (idx !== -1) {
  1123. return uri.substr(idx + 1);
  1124. }
  1125. return null;
  1126. };
  1127. var isValidDataUriImage = function (settings, imgElm) {
  1128. return settings.images_dataimg_filter ? settings.images_dataimg_filter(imgElm) : true;
  1129. };
  1130. var extractFilename = function (editor, str) {
  1131. var m = str.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i);
  1132. return m ? editor.dom.encode(m[1]) : null;
  1133. };
  1134. var uniqueId = Utils.createIdGenerator('mceclip');
  1135. var pasteImage = function (editor, imageItem) {
  1136. var base64 = getBase64FromUri(imageItem.uri);
  1137. var id = uniqueId();
  1138. var name = editor.settings.images_reuse_filename && imageItem.blob.name ? extractFilename(editor, imageItem.blob.name) : id;
  1139. var img = new domGlobals.Image();
  1140. img.src = imageItem.uri;
  1141. if (isValidDataUriImage(editor.settings, img)) {
  1142. var blobCache = editor.editorUpload.blobCache;
  1143. var blobInfo = void 0, existingBlobInfo = void 0;
  1144. existingBlobInfo = blobCache.findFirst(function (cachedBlobInfo) {
  1145. return cachedBlobInfo.base64() === base64;
  1146. });
  1147. if (!existingBlobInfo) {
  1148. blobInfo = blobCache.create(id, imageItem.blob, base64, name);
  1149. blobCache.add(blobInfo);
  1150. } else {
  1151. blobInfo = existingBlobInfo;
  1152. }
  1153. pasteHtml$1(editor, '<img src="' + blobInfo.blobUri() + '">', false);
  1154. } else {
  1155. pasteHtml$1(editor, '<img src="' + imageItem.uri + '">', false);
  1156. }
  1157. };
  1158. var isClipboardEvent = function (event) {
  1159. return event.type === 'paste';
  1160. };
  1161. var readBlobsAsDataUris = function (items) {
  1162. return mapM(items, function (item) {
  1163. return Future.nu(function (resolve) {
  1164. var blob = item.getAsFile ? item.getAsFile() : item;
  1165. var reader = new window.FileReader();
  1166. reader.onload = function () {
  1167. resolve({
  1168. blob: blob,
  1169. uri: reader.result
  1170. });
  1171. };
  1172. reader.readAsDataURL(blob);
  1173. });
  1174. });
  1175. };
  1176. var getImagesFromDataTransfer = function (dataTransfer) {
  1177. var items = dataTransfer.items ? map(from$1(dataTransfer.items), function (item) {
  1178. return item.getAsFile();
  1179. }) : [];
  1180. var files = dataTransfer.files ? from$1(dataTransfer.files) : [];
  1181. var images = filter$1(items.length > 0 ? items : files, function (file) {
  1182. return /^image\/(jpeg|png|gif|bmp)$/.test(file.type);
  1183. });
  1184. return images;
  1185. };
  1186. var pasteImageData = function (editor, e, rng) {
  1187. var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;
  1188. if (editor.settings.paste_data_images && dataTransfer) {
  1189. var images = getImagesFromDataTransfer(dataTransfer);
  1190. if (images.length > 0) {
  1191. e.preventDefault();
  1192. readBlobsAsDataUris(images).get(function (blobResults) {
  1193. if (rng) {
  1194. editor.selection.setRng(rng);
  1195. }
  1196. each(blobResults, function (result) {
  1197. pasteImage(editor, result);
  1198. });
  1199. });
  1200. return true;
  1201. }
  1202. }
  1203. return false;
  1204. };
  1205. var isBrokenAndroidClipboardEvent = function (e) {
  1206. var clipboardData = e.clipboardData;
  1207. return domGlobals.navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
  1208. };
  1209. var isKeyboardPasteEvent = function (e) {
  1210. return global$4.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45;
  1211. };
  1212. var registerEventHandlers = function (editor, pasteBin, pasteFormat) {
  1213. var keyboardPasteEvent = value();
  1214. var keyboardPastePlainTextState;
  1215. editor.on('keydown', function (e) {
  1216. function removePasteBinOnKeyUp(e) {
  1217. if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
  1218. pasteBin.remove();
  1219. }
  1220. }
  1221. if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
  1222. keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;
  1223. if (keyboardPastePlainTextState && global$1.webkit && domGlobals.navigator.userAgent.indexOf('Version/') !== -1) {
  1224. return;
  1225. }
  1226. e.stopImmediatePropagation();
  1227. keyboardPasteEvent.set(e);
  1228. window.setTimeout(function () {
  1229. keyboardPasteEvent.clear();
  1230. }, 100);
  1231. if (global$1.ie && keyboardPastePlainTextState) {
  1232. e.preventDefault();
  1233. Events.firePaste(editor, true);
  1234. return;
  1235. }
  1236. pasteBin.remove();
  1237. pasteBin.create();
  1238. editor.once('keyup', removePasteBinOnKeyUp);
  1239. editor.once('paste', function () {
  1240. editor.off('keyup', removePasteBinOnKeyUp);
  1241. });
  1242. }
  1243. });
  1244. function insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal) {
  1245. var content, isPlainTextHtml;
  1246. if (hasContentType(clipboardContent, 'text/html')) {
  1247. content = clipboardContent['text/html'];
  1248. } else {
  1249. content = pasteBin.getHtml();
  1250. internal = internal ? internal : InternalHtml.isMarked(content);
  1251. if (pasteBin.isDefaultContent(content)) {
  1252. plainTextMode = true;
  1253. }
  1254. }
  1255. content = Utils.trimHtml(content);
  1256. pasteBin.remove();
  1257. isPlainTextHtml = internal === false && Newlines.isPlainText(content);
  1258. if (!content.length || isPlainTextHtml) {
  1259. plainTextMode = true;
  1260. }
  1261. if (plainTextMode) {
  1262. if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) {
  1263. content = clipboardContent['text/plain'];
  1264. } else {
  1265. content = Utils.innerText(content);
  1266. }
  1267. }
  1268. if (pasteBin.isDefaultContent(content)) {
  1269. if (!isKeyBoardPaste) {
  1270. editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
  1271. }
  1272. return;
  1273. }
  1274. if (plainTextMode) {
  1275. pasteText(editor, content);
  1276. } else {
  1277. pasteHtml$1(editor, content, internal);
  1278. }
  1279. }
  1280. var getLastRng = function () {
  1281. return pasteBin.getLastRng() || editor.selection.getRng();
  1282. };
  1283. editor.on('paste', function (e) {
  1284. var isKeyBoardPaste = keyboardPasteEvent.isSet();
  1285. var clipboardContent = getClipboardContent(editor, e);
  1286. var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;
  1287. var internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime());
  1288. keyboardPastePlainTextState = false;
  1289. if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
  1290. pasteBin.remove();
  1291. return;
  1292. }
  1293. if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {
  1294. pasteBin.remove();
  1295. return;
  1296. }
  1297. if (!isKeyBoardPaste) {
  1298. e.preventDefault();
  1299. }
  1300. if (global$1.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) {
  1301. pasteBin.create();
  1302. editor.dom.bind(pasteBin.getEl(), 'paste', function (e) {
  1303. e.stopPropagation();
  1304. });
  1305. editor.getDoc().execCommand('Paste', false, null);
  1306. clipboardContent['text/html'] = pasteBin.getHtml();
  1307. }
  1308. if (hasContentType(clipboardContent, 'text/html')) {
  1309. e.preventDefault();
  1310. if (!internal) {
  1311. internal = InternalHtml.isMarked(clipboardContent['text/html']);
  1312. }
  1313. insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
  1314. } else {
  1315. global$2.setEditorTimeout(editor, function () {
  1316. insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
  1317. }, 0);
  1318. }
  1319. });
  1320. };
  1321. var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) {
  1322. registerEventHandlers(editor, pasteBin, pasteFormat);
  1323. var src;
  1324. editor.parser.addNodeFilter('img', function (nodes, name, args) {
  1325. var isPasteInsert = function (args) {
  1326. return args.data && args.data.paste === true;
  1327. };
  1328. var remove = function (node) {
  1329. if (!node.attr('data-mce-object') && src !== global$1.transparentSrc) {
  1330. node.remove();
  1331. }
  1332. };
  1333. var isWebKitFakeUrl = function (src) {
  1334. return src.indexOf('webkit-fake-url') === 0;
  1335. };
  1336. var isDataUri = function (src) {
  1337. return src.indexOf('data:') === 0;
  1338. };
  1339. if (!editor.settings.paste_data_images && isPasteInsert(args)) {
  1340. var i = nodes.length;
  1341. while (i--) {
  1342. src = nodes[i].attr('src');
  1343. if (!src) {
  1344. continue;
  1345. }
  1346. if (isWebKitFakeUrl(src)) {
  1347. remove(nodes[i]);
  1348. } else if (!editor.settings.allow_html_data_urls && isDataUri(src)) {
  1349. remove(nodes[i]);
  1350. }
  1351. }
  1352. }
  1353. });
  1354. };
  1355. var getPasteBinParent = function (editor) {
  1356. return global$1.ie && editor.inline ? domGlobals.document.body : editor.getBody();
  1357. };
  1358. var isExternalPasteBin = function (editor) {
  1359. return getPasteBinParent(editor) !== editor.getBody();
  1360. };
  1361. var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) {
  1362. if (isExternalPasteBin(editor)) {
  1363. editor.dom.bind(pasteBinElm, 'paste keyup', function (e) {
  1364. if (!isDefault(editor, pasteBinDefaultContent)) {
  1365. editor.fire('paste');
  1366. }
  1367. });
  1368. }
  1369. };
  1370. var create = function (editor, lastRngCell, pasteBinDefaultContent) {
  1371. var dom = editor.dom, body = editor.getBody();
  1372. var pasteBinElm;
  1373. lastRngCell.set(editor.selection.getRng());
  1374. pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', {
  1375. 'id': 'mcepastebin',
  1376. 'class': 'mce-pastebin',
  1377. 'contentEditable': true,
  1378. 'data-mce-bogus': 'all',
  1379. 'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0'
  1380. }, pasteBinDefaultContent);
  1381. if (global$1.ie || global$1.gecko) {
  1382. dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535);
  1383. }
  1384. dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
  1385. e.stopPropagation();
  1386. });
  1387. delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent);
  1388. pasteBinElm.focus();
  1389. editor.selection.select(pasteBinElm, true);
  1390. };
  1391. var remove = function (editor, lastRngCell) {
  1392. if (getEl(editor)) {
  1393. var pasteBinClone = void 0;
  1394. var lastRng = lastRngCell.get();
  1395. while (pasteBinClone = editor.dom.get('mcepastebin')) {
  1396. editor.dom.remove(pasteBinClone);
  1397. editor.dom.unbind(pasteBinClone);
  1398. }
  1399. if (lastRng) {
  1400. editor.selection.setRng(lastRng);
  1401. }
  1402. }
  1403. lastRngCell.set(null);
  1404. };
  1405. var getEl = function (editor) {
  1406. return editor.dom.get('mcepastebin');
  1407. };
  1408. var getHtml = function (editor) {
  1409. var pasteBinElm, pasteBinClones, i, dirtyWrappers, cleanWrapper;
  1410. var copyAndRemove = function (toElm, fromElm) {
  1411. toElm.appendChild(fromElm);
  1412. editor.dom.remove(fromElm, true);
  1413. };
  1414. pasteBinClones = global$3.grep(getPasteBinParent(editor).childNodes, function (elm) {
  1415. return elm.id === 'mcepastebin';
  1416. });
  1417. pasteBinElm = pasteBinClones.shift();
  1418. global$3.each(pasteBinClones, function (pasteBinClone) {
  1419. copyAndRemove(pasteBinElm, pasteBinClone);
  1420. });
  1421. dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm);
  1422. for (i = dirtyWrappers.length - 1; i >= 0; i--) {
  1423. cleanWrapper = editor.dom.create('div');
  1424. pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]);
  1425. copyAndRemove(cleanWrapper, dirtyWrappers[i]);
  1426. }
  1427. return pasteBinElm ? pasteBinElm.innerHTML : '';
  1428. };
  1429. var getLastRng = function (lastRng) {
  1430. return lastRng.get();
  1431. };
  1432. var isDefaultContent = function (pasteBinDefaultContent, content) {
  1433. return content === pasteBinDefaultContent;
  1434. };
  1435. var isPasteBin = function (elm) {
  1436. return elm && elm.id === 'mcepastebin';
  1437. };
  1438. var isDefault = function (editor, pasteBinDefaultContent) {
  1439. var pasteBinElm = getEl(editor);
  1440. return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML);
  1441. };
  1442. var PasteBin = function (editor) {
  1443. var lastRng = Cell(null);
  1444. var pasteBinDefaultContent = '%MCEPASTEBIN%';
  1445. return {
  1446. create: function () {
  1447. return create(editor, lastRng, pasteBinDefaultContent);
  1448. },
  1449. remove: function () {
  1450. return remove(editor, lastRng);
  1451. },
  1452. getEl: function () {
  1453. return getEl(editor);
  1454. },
  1455. getHtml: function () {
  1456. return getHtml(editor);
  1457. },
  1458. getLastRng: function () {
  1459. return getLastRng(lastRng);
  1460. },
  1461. isDefault: function () {
  1462. return isDefault(editor, pasteBinDefaultContent);
  1463. },
  1464. isDefaultContent: function (content) {
  1465. return isDefaultContent(pasteBinDefaultContent, content);
  1466. }
  1467. };
  1468. };
  1469. var Clipboard = function (editor, pasteFormat) {
  1470. var pasteBin = PasteBin(editor);
  1471. editor.on('PreInit', function () {
  1472. return registerEventsAndFilters(editor, pasteBin, pasteFormat);
  1473. });
  1474. return {
  1475. pasteFormat: pasteFormat,
  1476. pasteHtml: function (html, internalFlag) {
  1477. return pasteHtml$1(editor, html, internalFlag);
  1478. },
  1479. pasteText: function (text) {
  1480. return pasteText(editor, text);
  1481. },
  1482. pasteImageData: function (e, rng) {
  1483. return pasteImageData(editor, e, rng);
  1484. },
  1485. getDataTransferItems: getDataTransferItems,
  1486. hasHtmlOrText: hasHtmlOrText,
  1487. hasContentType: hasContentType
  1488. };
  1489. };
  1490. var noop = function () {
  1491. };
  1492. var hasWorkingClipboardApi = function (clipboardData) {
  1493. return global$1.iOS === false && clipboardData !== undefined && typeof clipboardData.setData === 'function' && Utils.isMsEdge() !== true;
  1494. };
  1495. var setHtml5Clipboard = function (clipboardData, html, text) {
  1496. if (hasWorkingClipboardApi(clipboardData)) {
  1497. try {
  1498. clipboardData.clearData();
  1499. clipboardData.setData('text/html', html);
  1500. clipboardData.setData('text/plain', text);
  1501. clipboardData.setData(InternalHtml.internalHtmlMime(), html);
  1502. return true;
  1503. } catch (e) {
  1504. return false;
  1505. }
  1506. } else {
  1507. return false;
  1508. }
  1509. };
  1510. var setClipboardData = function (evt, data, fallback, done) {
  1511. if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {
  1512. evt.preventDefault();
  1513. done();
  1514. } else {
  1515. fallback(data.html, done);
  1516. }
  1517. };
  1518. var fallback = function (editor) {
  1519. return function (html, done) {
  1520. var markedHtml = InternalHtml.mark(html);
  1521. var outer = editor.dom.create('div', {
  1522. 'contenteditable': 'false',
  1523. 'data-mce-bogus': 'all'
  1524. });
  1525. var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml);
  1526. editor.dom.setStyles(outer, {
  1527. position: 'fixed',
  1528. top: '0',
  1529. left: '-3000px',
  1530. width: '1000px',
  1531. overflow: 'hidden'
  1532. });
  1533. outer.appendChild(inner);
  1534. editor.dom.add(editor.getBody(), outer);
  1535. var range = editor.selection.getRng();
  1536. inner.focus();
  1537. var offscreenRange = editor.dom.createRng();
  1538. offscreenRange.selectNodeContents(inner);
  1539. editor.selection.setRng(offscreenRange);
  1540. global$2.setTimeout(function () {
  1541. editor.selection.setRng(range);
  1542. outer.parentNode.removeChild(outer);
  1543. done();
  1544. }, 0);
  1545. };
  1546. };
  1547. var getData = function (editor) {
  1548. return {
  1549. html: editor.selection.getContent({ contextual: true }),
  1550. text: editor.selection.getContent({ format: 'text' })
  1551. };
  1552. };
  1553. var isTableSelection = function (editor) {
  1554. return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
  1555. };
  1556. var hasSelectedContent = function (editor) {
  1557. return !editor.selection.isCollapsed() || isTableSelection(editor);
  1558. };
  1559. var cut = function (editor) {
  1560. return function (evt) {
  1561. if (hasSelectedContent(editor)) {
  1562. setClipboardData(evt, getData(editor), fallback(editor), function () {
  1563. global$2.setTimeout(function () {
  1564. editor.execCommand('Delete');
  1565. }, 0);
  1566. });
  1567. }
  1568. };
  1569. };
  1570. var copy = function (editor) {
  1571. return function (evt) {
  1572. if (hasSelectedContent(editor)) {
  1573. setClipboardData(evt, getData(editor), fallback(editor), noop);
  1574. }
  1575. };
  1576. };
  1577. var register$1 = function (editor) {
  1578. editor.on('cut', cut(editor));
  1579. editor.on('copy', copy(editor));
  1580. };
  1581. var CutCopy = { register: register$1 };
  1582. var global$a = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
  1583. var getCaretRangeFromEvent = function (editor, e) {
  1584. return global$a.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
  1585. };
  1586. var isPlainTextFileUrl = function (content) {
  1587. var plainTextContent = content['text/plain'];
  1588. return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;
  1589. };
  1590. var setFocusedRange = function (editor, rng) {
  1591. editor.focus();
  1592. editor.selection.setRng(rng);
  1593. };
  1594. var setup = function (editor, clipboard, draggingInternallyState) {
  1595. if (Settings.shouldBlockDrop(editor)) {
  1596. editor.on('dragend dragover draggesture dragdrop drop drag', function (e) {
  1597. e.preventDefault();
  1598. e.stopPropagation();
  1599. });
  1600. }
  1601. if (!Settings.shouldPasteDataImages(editor)) {
  1602. editor.on('drop', function (e) {
  1603. var dataTransfer = e.dataTransfer;
  1604. if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
  1605. e.preventDefault();
  1606. }
  1607. });
  1608. }
  1609. editor.on('drop', function (e) {
  1610. var dropContent, rng;
  1611. rng = getCaretRangeFromEvent(editor, e);
  1612. if (e.isDefaultPrevented() || draggingInternallyState.get()) {
  1613. return;
  1614. }
  1615. dropContent = clipboard.getDataTransferItems(e.dataTransfer);
  1616. var internal = clipboard.hasContentType(dropContent, InternalHtml.internalHtmlMime());
  1617. if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) {
  1618. return;
  1619. }
  1620. if (rng && Settings.shouldFilterDrop(editor)) {
  1621. var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
  1622. if (content_1) {
  1623. e.preventDefault();
  1624. global$2.setEditorTimeout(editor, function () {
  1625. editor.undoManager.transact(function () {
  1626. if (dropContent['mce-internal']) {
  1627. editor.execCommand('Delete');
  1628. }
  1629. setFocusedRange(editor, rng);
  1630. content_1 = Utils.trimHtml(content_1);
  1631. if (!dropContent['text/html']) {
  1632. clipboard.pasteText(content_1);
  1633. } else {
  1634. clipboard.pasteHtml(content_1, internal);
  1635. }
  1636. });
  1637. });
  1638. }
  1639. }
  1640. });
  1641. editor.on('dragstart', function (e) {
  1642. draggingInternallyState.set(true);
  1643. });
  1644. editor.on('dragover dragend', function (e) {
  1645. if (Settings.shouldPasteDataImages(editor) && draggingInternallyState.get() === false) {
  1646. e.preventDefault();
  1647. setFocusedRange(editor, getCaretRangeFromEvent(editor, e));
  1648. }
  1649. if (e.type === 'dragend') {
  1650. draggingInternallyState.set(false);
  1651. }
  1652. });
  1653. };
  1654. var DragDrop = { setup: setup };
  1655. var setup$1 = function (editor) {
  1656. var plugin = editor.plugins.paste;
  1657. var preProcess = Settings.getPreProcess(editor);
  1658. if (preProcess) {
  1659. editor.on('PastePreProcess', function (e) {
  1660. preProcess.call(plugin, plugin, e);
  1661. });
  1662. }
  1663. var postProcess = Settings.getPostProcess(editor);
  1664. if (postProcess) {
  1665. editor.on('PastePostProcess', function (e) {
  1666. postProcess.call(plugin, plugin, e);
  1667. });
  1668. }
  1669. };
  1670. var PrePostProcess = { setup: setup$1 };
  1671. function addPreProcessFilter(editor, filterFunc) {
  1672. editor.on('PastePreProcess', function (e) {
  1673. e.content = filterFunc(editor, e.content, e.internal, e.wordContent);
  1674. });
  1675. }
  1676. function addPostProcessFilter(editor, filterFunc) {
  1677. editor.on('PastePostProcess', function (e) {
  1678. filterFunc(editor, e.node);
  1679. });
  1680. }
  1681. function removeExplorerBrElementsAfterBlocks(editor, html) {
  1682. if (!WordFilter.isWordContent(html)) {
  1683. return html;
  1684. }
  1685. var blockElements = [];
  1686. global$3.each(editor.schema.getBlockElements(), function (block, blockName) {
  1687. blockElements.push(blockName);
  1688. });
  1689. var explorerBlocksRegExp = new RegExp('(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*', 'g');
  1690. html = Utils.filter(html, [[
  1691. explorerBlocksRegExp,
  1692. '$1'
  1693. ]]);
  1694. html = Utils.filter(html, [
  1695. [
  1696. /<br><br>/g,
  1697. '<BR><BR>'
  1698. ],
  1699. [
  1700. /<br>/g,
  1701. ' '
  1702. ],
  1703. [
  1704. /<BR><BR>/g,
  1705. '<br>'
  1706. ]
  1707. ]);
  1708. return html;
  1709. }
  1710. function removeWebKitStyles(editor, content, internal, isWordHtml) {
  1711. if (isWordHtml || internal) {
  1712. return content;
  1713. }
  1714. var webKitStylesSetting = Settings.getWebkitStyles(editor);
  1715. var webKitStyles;
  1716. if (Settings.shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') {
  1717. return content;
  1718. }
  1719. if (webKitStylesSetting) {
  1720. webKitStyles = webKitStylesSetting.split(/[, ]/);
  1721. }
  1722. if (webKitStyles) {
  1723. var dom_1 = editor.dom, node_1 = editor.selection.getNode();
  1724. content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) {
  1725. var inputStyles = dom_1.parseStyle(dom_1.decode(value));
  1726. var outputStyles = {};
  1727. if (webKitStyles === 'none') {
  1728. return before + after;
  1729. }
  1730. for (var i = 0; i < webKitStyles.length; i++) {
  1731. var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true);
  1732. if (/color/.test(webKitStyles[i])) {
  1733. inputValue = dom_1.toHex(inputValue);
  1734. currentValue = dom_1.toHex(currentValue);
  1735. }
  1736. if (currentValue !== inputValue) {
  1737. outputStyles[webKitStyles[i]] = inputValue;
  1738. }
  1739. }
  1740. outputStyles = dom_1.serializeStyle(outputStyles, 'span');
  1741. if (outputStyles) {
  1742. return before + ' style="' + outputStyles + '"' + after;
  1743. }
  1744. return before + after;
  1745. });
  1746. } else {
  1747. content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
  1748. }
  1749. content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) {
  1750. return before + ' style="' + value + '"' + after;
  1751. });
  1752. return content;
  1753. }
  1754. function removeUnderlineAndFontInAnchor(editor, root) {
  1755. editor.$('a', root).find('font,u').each(function (i, node) {
  1756. editor.dom.remove(node, true);
  1757. });
  1758. }
  1759. var setup$2 = function (editor) {
  1760. if (global$1.webkit) {
  1761. addPreProcessFilter(editor, removeWebKitStyles);
  1762. }
  1763. if (global$1.ie) {
  1764. addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks);
  1765. addPostProcessFilter(editor, removeUnderlineAndFontInAnchor);
  1766. }
  1767. };
  1768. var Quirks = { setup: setup$2 };
  1769. var makeSetupHandler = function (editor, clipboard) {
  1770. return function (api) {
  1771. api.setActive(clipboard.pasteFormat.get() === 'text');
  1772. var pastePlainTextToggleHandler = function (e) {
  1773. return api.setActive(e.state);
  1774. };
  1775. editor.on('PastePlainTextToggle', pastePlainTextToggleHandler);
  1776. return function () {
  1777. return editor.off('PastePlainTextToggle', pastePlainTextToggleHandler);
  1778. };
  1779. };
  1780. };
  1781. var register$2 = function (editor, clipboard) {
  1782. editor.ui.registry.addToggleButton('pastetext', {
  1783. active: false,
  1784. icon: 'paste-text',
  1785. tooltip: 'Paste as text',
  1786. onAction: function () {
  1787. return editor.execCommand('mceTogglePlainTextPaste');
  1788. },
  1789. onSetup: makeSetupHandler(editor, clipboard)
  1790. });
  1791. editor.ui.registry.addToggleMenuItem('pastetext', {
  1792. text: 'Paste as text',
  1793. onAction: function () {
  1794. return editor.execCommand('mceTogglePlainTextPaste');
  1795. },
  1796. onSetup: makeSetupHandler(editor, clipboard)
  1797. });
  1798. };
  1799. var Buttons = { register: register$2 };
  1800. global.add('paste', function (editor) {
  1801. if (DetectProPlugin.hasProPlugin(editor) === false) {
  1802. var draggingInternallyState = Cell(false);
  1803. var pasteFormat = Cell(Settings.isPasteAsTextEnabled(editor) ? 'text' : 'html');
  1804. var clipboard = Clipboard(editor, pasteFormat);
  1805. var quirks = Quirks.setup(editor);
  1806. Buttons.register(editor, clipboard);
  1807. Commands.register(editor, clipboard);
  1808. PrePostProcess.setup(editor);
  1809. CutCopy.register(editor);
  1810. DragDrop.setup(editor, clipboard, draggingInternallyState);
  1811. return Api.get(clipboard, quirks);
  1812. }
  1813. });
  1814. function Plugin () {
  1815. }
  1816. return Plugin;
  1817. }(window));
  1818. })();