plugin.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /**
  2. * TinyMCE version 6.8.6 (TBD)
  3. */
  4. (function () {
  5. 'use strict';
  6. const Cell = initial => {
  7. let value = initial;
  8. const get = () => {
  9. return value;
  10. };
  11. const set = v => {
  12. value = v;
  13. };
  14. return {
  15. get,
  16. set
  17. };
  18. };
  19. var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
  20. let unique = 0;
  21. const generate = prefix => {
  22. const date = new Date();
  23. const time = date.getTime();
  24. const random = Math.floor(Math.random() * 1000000000);
  25. unique++;
  26. return prefix + '_' + random + unique + String(time);
  27. };
  28. const get$1 = customTabs => {
  29. const addTab = spec => {
  30. var _a;
  31. const name = (_a = spec.name) !== null && _a !== void 0 ? _a : generate('tab-name');
  32. const currentCustomTabs = customTabs.get();
  33. currentCustomTabs[name] = spec;
  34. customTabs.set(currentCustomTabs);
  35. };
  36. return { addTab };
  37. };
  38. const register$2 = (editor, dialogOpener) => {
  39. editor.addCommand('mceHelp', dialogOpener);
  40. };
  41. const option = name => editor => editor.options.get(name);
  42. const register$1 = editor => {
  43. const registerOption = editor.options.register;
  44. registerOption('help_tabs', { processor: 'array' });
  45. };
  46. const getHelpTabs = option('help_tabs');
  47. const getForcedPlugins = option('forced_plugins');
  48. const register = (editor, dialogOpener) => {
  49. editor.ui.registry.addButton('help', {
  50. icon: 'help',
  51. tooltip: 'Help',
  52. onAction: dialogOpener
  53. });
  54. editor.ui.registry.addMenuItem('help', {
  55. text: 'Help',
  56. icon: 'help',
  57. shortcut: 'Alt+0',
  58. onAction: dialogOpener
  59. });
  60. };
  61. const hasProto = (v, constructor, predicate) => {
  62. var _a;
  63. if (predicate(v, constructor.prototype)) {
  64. return true;
  65. } else {
  66. return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
  67. }
  68. };
  69. const typeOf = x => {
  70. const t = typeof x;
  71. if (x === null) {
  72. return 'null';
  73. } else if (t === 'object' && Array.isArray(x)) {
  74. return 'array';
  75. } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
  76. return 'string';
  77. } else {
  78. return t;
  79. }
  80. };
  81. const isType = type => value => typeOf(value) === type;
  82. const isSimpleType = type => value => typeof value === type;
  83. const eq = t => a => t === a;
  84. const isString = isType('string');
  85. const isUndefined = eq(undefined);
  86. const isNullable = a => a === null || a === undefined;
  87. const isNonNullable = a => !isNullable(a);
  88. const isFunction = isSimpleType('function');
  89. const constant = value => {
  90. return () => {
  91. return value;
  92. };
  93. };
  94. const never = constant(false);
  95. class Optional {
  96. constructor(tag, value) {
  97. this.tag = tag;
  98. this.value = value;
  99. }
  100. static some(value) {
  101. return new Optional(true, value);
  102. }
  103. static none() {
  104. return Optional.singletonNone;
  105. }
  106. fold(onNone, onSome) {
  107. if (this.tag) {
  108. return onSome(this.value);
  109. } else {
  110. return onNone();
  111. }
  112. }
  113. isSome() {
  114. return this.tag;
  115. }
  116. isNone() {
  117. return !this.tag;
  118. }
  119. map(mapper) {
  120. if (this.tag) {
  121. return Optional.some(mapper(this.value));
  122. } else {
  123. return Optional.none();
  124. }
  125. }
  126. bind(binder) {
  127. if (this.tag) {
  128. return binder(this.value);
  129. } else {
  130. return Optional.none();
  131. }
  132. }
  133. exists(predicate) {
  134. return this.tag && predicate(this.value);
  135. }
  136. forall(predicate) {
  137. return !this.tag || predicate(this.value);
  138. }
  139. filter(predicate) {
  140. if (!this.tag || predicate(this.value)) {
  141. return this;
  142. } else {
  143. return Optional.none();
  144. }
  145. }
  146. getOr(replacement) {
  147. return this.tag ? this.value : replacement;
  148. }
  149. or(replacement) {
  150. return this.tag ? this : replacement;
  151. }
  152. getOrThunk(thunk) {
  153. return this.tag ? this.value : thunk();
  154. }
  155. orThunk(thunk) {
  156. return this.tag ? this : thunk();
  157. }
  158. getOrDie(message) {
  159. if (!this.tag) {
  160. throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
  161. } else {
  162. return this.value;
  163. }
  164. }
  165. static from(value) {
  166. return isNonNullable(value) ? Optional.some(value) : Optional.none();
  167. }
  168. getOrNull() {
  169. return this.tag ? this.value : null;
  170. }
  171. getOrUndefined() {
  172. return this.value;
  173. }
  174. each(worker) {
  175. if (this.tag) {
  176. worker(this.value);
  177. }
  178. }
  179. toArray() {
  180. return this.tag ? [this.value] : [];
  181. }
  182. toString() {
  183. return this.tag ? `some(${ this.value })` : 'none()';
  184. }
  185. }
  186. Optional.singletonNone = new Optional(false);
  187. const nativeSlice = Array.prototype.slice;
  188. const nativeIndexOf = Array.prototype.indexOf;
  189. const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
  190. const contains = (xs, x) => rawIndexOf(xs, x) > -1;
  191. const map = (xs, f) => {
  192. const len = xs.length;
  193. const r = new Array(len);
  194. for (let i = 0; i < len; i++) {
  195. const x = xs[i];
  196. r[i] = f(x, i);
  197. }
  198. return r;
  199. };
  200. const filter = (xs, pred) => {
  201. const r = [];
  202. for (let i = 0, len = xs.length; i < len; i++) {
  203. const x = xs[i];
  204. if (pred(x, i)) {
  205. r.push(x);
  206. }
  207. }
  208. return r;
  209. };
  210. const findUntil = (xs, pred, until) => {
  211. for (let i = 0, len = xs.length; i < len; i++) {
  212. const x = xs[i];
  213. if (pred(x, i)) {
  214. return Optional.some(x);
  215. } else if (until(x, i)) {
  216. break;
  217. }
  218. }
  219. return Optional.none();
  220. };
  221. const find = (xs, pred) => {
  222. return findUntil(xs, pred, never);
  223. };
  224. const sort = (xs, comparator) => {
  225. const copy = nativeSlice.call(xs, 0);
  226. copy.sort(comparator);
  227. return copy;
  228. };
  229. const keys = Object.keys;
  230. const hasOwnProperty = Object.hasOwnProperty;
  231. const get = (obj, key) => {
  232. return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
  233. };
  234. const has = (obj, key) => hasOwnProperty.call(obj, key);
  235. const cat = arr => {
  236. const r = [];
  237. const push = x => {
  238. r.push(x);
  239. };
  240. for (let i = 0; i < arr.length; i++) {
  241. arr[i].each(push);
  242. }
  243. return r;
  244. };
  245. var global$3 = tinymce.util.Tools.resolve('tinymce.Resource');
  246. var global$2 = tinymce.util.Tools.resolve('tinymce.util.I18n');
  247. const pLoadHtmlByLangCode = (baseUrl, langCode) => global$3.load(`tinymce.html-i18n.help-keynav.${ langCode }`, `${ baseUrl }/js/i18n/keynav/${ langCode }.js`);
  248. const pLoadI18nHtml = baseUrl => pLoadHtmlByLangCode(baseUrl, global$2.getCode()).catch(() => pLoadHtmlByLangCode(baseUrl, 'en'));
  249. const initI18nLoad = (editor, baseUrl) => {
  250. editor.on('init', () => {
  251. pLoadI18nHtml(baseUrl);
  252. });
  253. };
  254. const pTab = async pluginUrl => {
  255. const body = {
  256. type: 'htmlpanel',
  257. presets: 'document',
  258. html: await pLoadI18nHtml(pluginUrl)
  259. };
  260. return {
  261. name: 'keyboardnav',
  262. title: 'Keyboard Navigation',
  263. items: [body]
  264. };
  265. };
  266. var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
  267. const convertText = source => {
  268. const isMac = global$1.os.isMacOS() || global$1.os.isiOS();
  269. const mac = {
  270. alt: '&#x2325;',
  271. ctrl: '&#x2303;',
  272. shift: '&#x21E7;',
  273. meta: '&#x2318;',
  274. access: '&#x2303;&#x2325;'
  275. };
  276. const other = {
  277. meta: 'Ctrl ',
  278. access: 'Shift + Alt '
  279. };
  280. const replace = isMac ? mac : other;
  281. const shortcut = source.split('+');
  282. const updated = map(shortcut, segment => {
  283. const search = segment.toLowerCase().trim();
  284. return has(replace, search) ? replace[search] : segment;
  285. });
  286. return isMac ? updated.join('').replace(/\s/, '') : updated.join('+');
  287. };
  288. const shortcuts = [
  289. {
  290. shortcuts: ['Meta + B'],
  291. action: 'Bold'
  292. },
  293. {
  294. shortcuts: ['Meta + I'],
  295. action: 'Italic'
  296. },
  297. {
  298. shortcuts: ['Meta + U'],
  299. action: 'Underline'
  300. },
  301. {
  302. shortcuts: ['Meta + A'],
  303. action: 'Select all'
  304. },
  305. {
  306. shortcuts: [
  307. 'Meta + Y',
  308. 'Meta + Shift + Z'
  309. ],
  310. action: 'Redo'
  311. },
  312. {
  313. shortcuts: ['Meta + Z'],
  314. action: 'Undo'
  315. },
  316. {
  317. shortcuts: ['Access + 1'],
  318. action: 'Heading 1'
  319. },
  320. {
  321. shortcuts: ['Access + 2'],
  322. action: 'Heading 2'
  323. },
  324. {
  325. shortcuts: ['Access + 3'],
  326. action: 'Heading 3'
  327. },
  328. {
  329. shortcuts: ['Access + 4'],
  330. action: 'Heading 4'
  331. },
  332. {
  333. shortcuts: ['Access + 5'],
  334. action: 'Heading 5'
  335. },
  336. {
  337. shortcuts: ['Access + 6'],
  338. action: 'Heading 6'
  339. },
  340. {
  341. shortcuts: ['Access + 7'],
  342. action: 'Paragraph'
  343. },
  344. {
  345. shortcuts: ['Access + 8'],
  346. action: 'Div'
  347. },
  348. {
  349. shortcuts: ['Access + 9'],
  350. action: 'Address'
  351. },
  352. {
  353. shortcuts: ['Alt + 0'],
  354. action: 'Open help dialog'
  355. },
  356. {
  357. shortcuts: ['Alt + F9'],
  358. action: 'Focus to menubar'
  359. },
  360. {
  361. shortcuts: ['Alt + F10'],
  362. action: 'Focus to toolbar'
  363. },
  364. {
  365. shortcuts: ['Alt + F11'],
  366. action: 'Focus to element path'
  367. },
  368. {
  369. shortcuts: ['Ctrl + F9'],
  370. action: 'Focus to contextual toolbar'
  371. },
  372. {
  373. shortcuts: ['Shift + Enter'],
  374. action: 'Open popup menu for split buttons'
  375. },
  376. {
  377. shortcuts: ['Meta + K'],
  378. action: 'Insert link (if link plugin activated)'
  379. },
  380. {
  381. shortcuts: ['Meta + S'],
  382. action: 'Save (if save plugin activated)'
  383. },
  384. {
  385. shortcuts: ['Meta + F'],
  386. action: 'Find (if searchreplace plugin activated)'
  387. },
  388. {
  389. shortcuts: ['Meta + Shift + F'],
  390. action: 'Switch to or from fullscreen mode'
  391. }
  392. ];
  393. const tab$2 = () => {
  394. const shortcutList = map(shortcuts, shortcut => {
  395. const shortcutText = map(shortcut.shortcuts, convertText).join(' or ');
  396. return [
  397. shortcut.action,
  398. shortcutText
  399. ];
  400. });
  401. const tablePanel = {
  402. type: 'table',
  403. header: [
  404. 'Action',
  405. 'Shortcut'
  406. ],
  407. cells: shortcutList
  408. };
  409. return {
  410. name: 'shortcuts',
  411. title: 'Handy Shortcuts',
  412. items: [tablePanel]
  413. };
  414. };
  415. const urls = map([
  416. {
  417. key: 'accordion',
  418. name: 'Accordion'
  419. },
  420. {
  421. key: 'advlist',
  422. name: 'Advanced List'
  423. },
  424. {
  425. key: 'anchor',
  426. name: 'Anchor'
  427. },
  428. {
  429. key: 'autolink',
  430. name: 'Autolink'
  431. },
  432. {
  433. key: 'autoresize',
  434. name: 'Autoresize'
  435. },
  436. {
  437. key: 'autosave',
  438. name: 'Autosave'
  439. },
  440. {
  441. key: 'charmap',
  442. name: 'Character Map'
  443. },
  444. {
  445. key: 'code',
  446. name: 'Code'
  447. },
  448. {
  449. key: 'codesample',
  450. name: 'Code Sample'
  451. },
  452. {
  453. key: 'colorpicker',
  454. name: 'Color Picker'
  455. },
  456. {
  457. key: 'directionality',
  458. name: 'Directionality'
  459. },
  460. {
  461. key: 'emoticons',
  462. name: 'Emoticons'
  463. },
  464. {
  465. key: 'fullscreen',
  466. name: 'Full Screen'
  467. },
  468. {
  469. key: 'help',
  470. name: 'Help'
  471. },
  472. {
  473. key: 'image',
  474. name: 'Image'
  475. },
  476. {
  477. key: 'importcss',
  478. name: 'Import CSS'
  479. },
  480. {
  481. key: 'insertdatetime',
  482. name: 'Insert Date/Time'
  483. },
  484. {
  485. key: 'link',
  486. name: 'Link'
  487. },
  488. {
  489. key: 'lists',
  490. name: 'Lists'
  491. },
  492. {
  493. key: 'media',
  494. name: 'Media'
  495. },
  496. {
  497. key: 'nonbreaking',
  498. name: 'Nonbreaking'
  499. },
  500. {
  501. key: 'pagebreak',
  502. name: 'Page Break'
  503. },
  504. {
  505. key: 'preview',
  506. name: 'Preview'
  507. },
  508. {
  509. key: 'quickbars',
  510. name: 'Quick Toolbars'
  511. },
  512. {
  513. key: 'save',
  514. name: 'Save'
  515. },
  516. {
  517. key: 'searchreplace',
  518. name: 'Search and Replace'
  519. },
  520. {
  521. key: 'table',
  522. name: 'Table'
  523. },
  524. {
  525. key: 'template',
  526. name: 'Template'
  527. },
  528. {
  529. key: 'textcolor',
  530. name: 'Text Color'
  531. },
  532. {
  533. key: 'visualblocks',
  534. name: 'Visual Blocks'
  535. },
  536. {
  537. key: 'visualchars',
  538. name: 'Visual Characters'
  539. },
  540. {
  541. key: 'wordcount',
  542. name: 'Word Count'
  543. },
  544. {
  545. key: 'a11ychecker',
  546. name: 'Accessibility Checker',
  547. type: 'premium'
  548. },
  549. {
  550. key: 'advcode',
  551. name: 'Advanced Code Editor',
  552. type: 'premium'
  553. },
  554. {
  555. key: 'advtable',
  556. name: 'Advanced Tables',
  557. type: 'premium'
  558. },
  559. {
  560. key: 'advtemplate',
  561. name: 'Advanced Templates',
  562. type: 'premium',
  563. slug: 'advanced-templates'
  564. },
  565. {
  566. key: 'ai',
  567. name: 'AI Assistant',
  568. type: 'premium'
  569. },
  570. {
  571. key: 'casechange',
  572. name: 'Case Change',
  573. type: 'premium'
  574. },
  575. {
  576. key: 'checklist',
  577. name: 'Checklist',
  578. type: 'premium'
  579. },
  580. {
  581. key: 'editimage',
  582. name: 'Enhanced Image Editing',
  583. type: 'premium'
  584. },
  585. {
  586. key: 'footnotes',
  587. name: 'Footnotes',
  588. type: 'premium'
  589. },
  590. {
  591. key: 'typography',
  592. name: 'Advanced Typography',
  593. type: 'premium',
  594. slug: 'advanced-typography'
  595. },
  596. {
  597. key: 'mediaembed',
  598. name: 'Enhanced Media Embed',
  599. type: 'premium',
  600. slug: 'introduction-to-mediaembed'
  601. },
  602. {
  603. key: 'export',
  604. name: 'Export',
  605. type: 'premium'
  606. },
  607. {
  608. key: 'formatpainter',
  609. name: 'Format Painter',
  610. type: 'premium'
  611. },
  612. {
  613. key: 'inlinecss',
  614. name: 'Inline CSS',
  615. type: 'premium',
  616. slug: 'inline-css'
  617. },
  618. {
  619. key: 'linkchecker',
  620. name: 'Link Checker',
  621. type: 'premium'
  622. },
  623. {
  624. key: 'mentions',
  625. name: 'Mentions',
  626. type: 'premium'
  627. },
  628. {
  629. key: 'mergetags',
  630. name: 'Merge Tags',
  631. type: 'premium'
  632. },
  633. {
  634. key: 'pageembed',
  635. name: 'Page Embed',
  636. type: 'premium'
  637. },
  638. {
  639. key: 'permanentpen',
  640. name: 'Permanent Pen',
  641. type: 'premium'
  642. },
  643. {
  644. key: 'powerpaste',
  645. name: 'PowerPaste',
  646. type: 'premium',
  647. slug: 'introduction-to-powerpaste'
  648. },
  649. {
  650. key: 'rtc',
  651. name: 'Real-Time Collaboration',
  652. type: 'premium',
  653. slug: 'rtc-introduction'
  654. },
  655. {
  656. key: 'tinymcespellchecker',
  657. name: 'Spell Checker Pro',
  658. type: 'premium',
  659. slug: 'introduction-to-tiny-spellchecker'
  660. },
  661. {
  662. key: 'autocorrect',
  663. name: 'Spelling Autocorrect',
  664. type: 'premium'
  665. },
  666. {
  667. key: 'tableofcontents',
  668. name: 'Table of Contents',
  669. type: 'premium'
  670. },
  671. {
  672. key: 'tinycomments',
  673. name: 'Tiny Comments',
  674. type: 'premium',
  675. slug: 'introduction-to-tiny-comments'
  676. },
  677. {
  678. key: 'tinydrive',
  679. name: 'Tiny Drive',
  680. type: 'premium',
  681. slug: 'tinydrive-introduction'
  682. }
  683. ], item => ({
  684. ...item,
  685. type: item.type || 'opensource',
  686. slug: item.slug || item.key
  687. }));
  688. const tab$1 = editor => {
  689. const availablePlugins = () => {
  690. const premiumPlugins = filter(urls, ({type}) => {
  691. return type === 'premium';
  692. });
  693. const sortedPremiumPlugins = sort(map(premiumPlugins, p => p.name), (s1, s2) => s1.localeCompare(s2));
  694. const premiumPluginList = map(sortedPremiumPlugins, pluginName => `<li>${ pluginName }</li>`).join('');
  695. return '<div>' + '<p><b>' + global$2.translate('Premium plugins:') + '</b></p>' + '<ul>' + premiumPluginList + '<li class="tox-help__more-link" ">' + '<a href="https://www.tiny.cloud/pricing/?utm_campaign=help_dialog_plugin_tab&utm_source=tiny&utm_medium=referral&utm_term=read_more&utm_content=premium_plugin_heading" rel="noopener" target="_blank"' + ' data-alloy-tabstop="true" tabindex="-1">' + global$2.translate('Learn more...') + '</a></li>' + '</ul>' + '</div>';
  696. };
  697. const makeLink = p => `<a data-alloy-tabstop="true" tabindex="-1" href="${ p.url }" target="_blank" rel="noopener">${ p.name }</a>`;
  698. const identifyUnknownPlugin = (editor, key) => {
  699. const getMetadata = editor.plugins[key].getMetadata;
  700. if (isFunction(getMetadata)) {
  701. const metadata = getMetadata();
  702. return {
  703. name: metadata.name,
  704. html: makeLink(metadata)
  705. };
  706. } else {
  707. return {
  708. name: key,
  709. html: key
  710. };
  711. }
  712. };
  713. const getPluginData = (editor, key) => find(urls, x => {
  714. return x.key === key;
  715. }).fold(() => {
  716. return identifyUnknownPlugin(editor, key);
  717. }, x => {
  718. const name = x.type === 'premium' ? `${ x.name }*` : x.name;
  719. const html = makeLink({
  720. name,
  721. url: `https://www.tiny.cloud/docs/tinymce/6/${ x.slug }/`
  722. });
  723. return {
  724. name,
  725. html
  726. };
  727. });
  728. const getPluginKeys = editor => {
  729. const keys$1 = keys(editor.plugins);
  730. const forcedPlugins = getForcedPlugins(editor);
  731. return isUndefined(forcedPlugins) ? keys$1 : filter(keys$1, k => !contains(forcedPlugins, k));
  732. };
  733. const pluginLister = editor => {
  734. const pluginKeys = getPluginKeys(editor);
  735. const sortedPluginData = sort(map(pluginKeys, k => getPluginData(editor, k)), (pd1, pd2) => pd1.name.localeCompare(pd2.name));
  736. const pluginLis = map(sortedPluginData, key => {
  737. return '<li>' + key.html + '</li>';
  738. });
  739. const count = pluginLis.length;
  740. const pluginsString = pluginLis.join('');
  741. const html = '<p><b>' + global$2.translate([
  742. 'Plugins installed ({0}):',
  743. count
  744. ]) + '</b></p>' + '<ul>' + pluginsString + '</ul>';
  745. return html;
  746. };
  747. const installedPlugins = editor => {
  748. if (editor == null) {
  749. return '';
  750. }
  751. return '<div>' + pluginLister(editor) + '</div>';
  752. };
  753. const htmlPanel = {
  754. type: 'htmlpanel',
  755. presets: 'document',
  756. html: [
  757. installedPlugins(editor),
  758. availablePlugins()
  759. ].join('')
  760. };
  761. return {
  762. name: 'plugins',
  763. title: 'Plugins',
  764. items: [htmlPanel]
  765. };
  766. };
  767. var global = tinymce.util.Tools.resolve('tinymce.EditorManager');
  768. const tab = () => {
  769. const getVersion = (major, minor) => major.indexOf('@') === 0 ? 'X.X.X' : major + '.' + minor;
  770. const version = getVersion(global.majorVersion, global.minorVersion);
  771. const changeLogLink = '<a data-alloy-tabstop="true" tabindex="-1" href="https://www.tiny.cloud/docs/tinymce/6/changelog/?utm_campaign=help_dialog_version_tab&utm_source=tiny&utm_medium=referral" rel="noopener" target="_blank">TinyMCE ' + version + '</a>';
  772. const htmlPanel = {
  773. type: 'htmlpanel',
  774. html: '<p>' + global$2.translate([
  775. 'You are using {0}',
  776. changeLogLink
  777. ]) + '</p>',
  778. presets: 'document'
  779. };
  780. return {
  781. name: 'versions',
  782. title: 'Version',
  783. items: [htmlPanel]
  784. };
  785. };
  786. const parseHelpTabsSetting = (tabsFromSettings, tabs) => {
  787. const newTabs = {};
  788. const names = map(tabsFromSettings, t => {
  789. var _a;
  790. if (isString(t)) {
  791. if (has(tabs, t)) {
  792. newTabs[t] = tabs[t];
  793. }
  794. return t;
  795. } else {
  796. const name = (_a = t.name) !== null && _a !== void 0 ? _a : generate('tab-name');
  797. newTabs[name] = t;
  798. return name;
  799. }
  800. });
  801. return {
  802. tabs: newTabs,
  803. names
  804. };
  805. };
  806. const getNamesFromTabs = tabs => {
  807. const names = keys(tabs);
  808. const idx = names.indexOf('versions');
  809. if (idx !== -1) {
  810. names.splice(idx, 1);
  811. names.push('versions');
  812. }
  813. return {
  814. tabs,
  815. names
  816. };
  817. };
  818. const pParseCustomTabs = async (editor, customTabs, pluginUrl) => {
  819. const shortcuts = tab$2();
  820. const nav = await pTab(pluginUrl);
  821. const plugins = tab$1(editor);
  822. const versions = tab();
  823. const tabs = {
  824. [shortcuts.name]: shortcuts,
  825. [nav.name]: nav,
  826. [plugins.name]: plugins,
  827. [versions.name]: versions,
  828. ...customTabs.get()
  829. };
  830. return Optional.from(getHelpTabs(editor)).fold(() => getNamesFromTabs(tabs), tabsFromSettings => parseHelpTabsSetting(tabsFromSettings, tabs));
  831. };
  832. const init = (editor, customTabs, pluginUrl) => () => {
  833. pParseCustomTabs(editor, customTabs, pluginUrl).then(({tabs, names}) => {
  834. const foundTabs = map(names, name => get(tabs, name));
  835. const dialogTabs = cat(foundTabs);
  836. const body = {
  837. type: 'tabpanel',
  838. tabs: dialogTabs
  839. };
  840. editor.windowManager.open({
  841. title: 'Help',
  842. size: 'medium',
  843. body,
  844. buttons: [{
  845. type: 'cancel',
  846. name: 'close',
  847. text: 'Close',
  848. primary: true
  849. }],
  850. initialData: {}
  851. });
  852. });
  853. };
  854. var Plugin = () => {
  855. global$4.add('help', (editor, pluginUrl) => {
  856. const customTabs = Cell({});
  857. const api = get$1(customTabs);
  858. register$1(editor);
  859. const dialogOpener = init(editor, customTabs, pluginUrl);
  860. register(editor, dialogOpener);
  861. register$2(editor, dialogOpener);
  862. editor.shortcuts.add('Alt+0', 'Open help dialog', 'mceHelp');
  863. initI18nLoad(editor, pluginUrl);
  864. return api;
  865. });
  866. };
  867. Plugin();
  868. })();