tinymce_plugins_lists.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242
  1. import {
  2. __commonJS
  3. } from "./chunk-2LSFTFF7.js";
  4. // node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/lists/plugin.js
  5. var require_plugin = __commonJS({
  6. "node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/lists/plugin.js"() {
  7. (function() {
  8. "use strict";
  9. var global$7 = tinymce.util.Tools.resolve("tinymce.PluginManager");
  10. var typeOf = function(x) {
  11. var t = typeof x;
  12. if (x === null) {
  13. return "null";
  14. } else if (t === "object" && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === "Array")) {
  15. return "array";
  16. } else if (t === "object" && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === "String")) {
  17. return "string";
  18. } else {
  19. return t;
  20. }
  21. };
  22. var isType$1 = function(type2) {
  23. return function(value) {
  24. return typeOf(value) === type2;
  25. };
  26. };
  27. var isSimpleType = function(type2) {
  28. return function(value) {
  29. return typeof value === type2;
  30. };
  31. };
  32. var isString = isType$1("string");
  33. var isObject = isType$1("object");
  34. var isArray = isType$1("array");
  35. var isBoolean = isSimpleType("boolean");
  36. var isFunction = isSimpleType("function");
  37. var isNumber = isSimpleType("number");
  38. var noop = function() {
  39. };
  40. var constant = function(value) {
  41. return function() {
  42. return value;
  43. };
  44. };
  45. var identity = function(x) {
  46. return x;
  47. };
  48. var tripleEquals = function(a, b) {
  49. return a === b;
  50. };
  51. var not = function(f) {
  52. return function(t) {
  53. return !f(t);
  54. };
  55. };
  56. var never = constant(false);
  57. var always = constant(true);
  58. var none = function() {
  59. return NONE;
  60. };
  61. var NONE = function() {
  62. var call = function(thunk) {
  63. return thunk();
  64. };
  65. var id = identity;
  66. var me = {
  67. fold: function(n, _s) {
  68. return n();
  69. },
  70. isSome: never,
  71. isNone: always,
  72. getOr: id,
  73. getOrThunk: call,
  74. getOrDie: function(msg) {
  75. throw new Error(msg || "error: getOrDie called on none.");
  76. },
  77. getOrNull: constant(null),
  78. getOrUndefined: constant(void 0),
  79. or: id,
  80. orThunk: call,
  81. map: none,
  82. each: noop,
  83. bind: none,
  84. exists: never,
  85. forall: always,
  86. filter: function() {
  87. return none();
  88. },
  89. toArray: function() {
  90. return [];
  91. },
  92. toString: constant("none()")
  93. };
  94. return me;
  95. }();
  96. var some = function(a) {
  97. var constant_a = constant(a);
  98. var self = function() {
  99. return me;
  100. };
  101. var bind2 = function(f) {
  102. return f(a);
  103. };
  104. var me = {
  105. fold: function(n, s) {
  106. return s(a);
  107. },
  108. isSome: always,
  109. isNone: never,
  110. getOr: constant_a,
  111. getOrThunk: constant_a,
  112. getOrDie: constant_a,
  113. getOrNull: constant_a,
  114. getOrUndefined: constant_a,
  115. or: self,
  116. orThunk: self,
  117. map: function(f) {
  118. return some(f(a));
  119. },
  120. each: function(f) {
  121. f(a);
  122. },
  123. bind: bind2,
  124. exists: bind2,
  125. forall: bind2,
  126. filter: function(f) {
  127. return f(a) ? me : NONE;
  128. },
  129. toArray: function() {
  130. return [a];
  131. },
  132. toString: function() {
  133. return "some(" + a + ")";
  134. }
  135. };
  136. return me;
  137. };
  138. var from = function(value) {
  139. return value === null || value === void 0 ? NONE : some(value);
  140. };
  141. var Optional = {
  142. some,
  143. none,
  144. from
  145. };
  146. var nativeSlice = Array.prototype.slice;
  147. var nativePush = Array.prototype.push;
  148. var map = function(xs, f) {
  149. var len = xs.length;
  150. var r = new Array(len);
  151. for (var i = 0; i < len; i++) {
  152. var x = xs[i];
  153. r[i] = f(x, i);
  154. }
  155. return r;
  156. };
  157. var each$1 = function(xs, f) {
  158. for (var i = 0, len = xs.length; i < len; i++) {
  159. var x = xs[i];
  160. f(x, i);
  161. }
  162. };
  163. var filter$1 = function(xs, pred) {
  164. var r = [];
  165. for (var i = 0, len = xs.length; i < len; i++) {
  166. var x = xs[i];
  167. if (pred(x, i)) {
  168. r.push(x);
  169. }
  170. }
  171. return r;
  172. };
  173. var groupBy = function(xs, f) {
  174. if (xs.length === 0) {
  175. return [];
  176. } else {
  177. var wasType = f(xs[0]);
  178. var r = [];
  179. var group = [];
  180. for (var i = 0, len = xs.length; i < len; i++) {
  181. var x = xs[i];
  182. var type2 = f(x);
  183. if (type2 !== wasType) {
  184. r.push(group);
  185. group = [];
  186. }
  187. wasType = type2;
  188. group.push(x);
  189. }
  190. if (group.length !== 0) {
  191. r.push(group);
  192. }
  193. return r;
  194. }
  195. };
  196. var foldl = function(xs, f, acc) {
  197. each$1(xs, function(x, i) {
  198. acc = f(acc, x, i);
  199. });
  200. return acc;
  201. };
  202. var findUntil = function(xs, pred, until) {
  203. for (var i = 0, len = xs.length; i < len; i++) {
  204. var x = xs[i];
  205. if (pred(x, i)) {
  206. return Optional.some(x);
  207. } else if (until(x, i)) {
  208. break;
  209. }
  210. }
  211. return Optional.none();
  212. };
  213. var find$1 = function(xs, pred) {
  214. return findUntil(xs, pred, never);
  215. };
  216. var flatten = function(xs) {
  217. var r = [];
  218. for (var i = 0, len = xs.length; i < len; ++i) {
  219. if (!isArray(xs[i])) {
  220. throw new Error("Arr.flatten item " + i + " was not an array, input: " + xs);
  221. }
  222. nativePush.apply(r, xs[i]);
  223. }
  224. return r;
  225. };
  226. var bind = function(xs, f) {
  227. return flatten(map(xs, f));
  228. };
  229. var reverse = function(xs) {
  230. var r = nativeSlice.call(xs, 0);
  231. r.reverse();
  232. return r;
  233. };
  234. var get$1 = function(xs, i) {
  235. return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
  236. };
  237. var head = function(xs) {
  238. return get$1(xs, 0);
  239. };
  240. var last = function(xs) {
  241. return get$1(xs, xs.length - 1);
  242. };
  243. var findMap = function(arr, f) {
  244. for (var i = 0; i < arr.length; i++) {
  245. var r = f(arr[i], i);
  246. if (r.isSome()) {
  247. return r;
  248. }
  249. }
  250. return Optional.none();
  251. };
  252. var __assign = function() {
  253. __assign = Object.assign || function __assign2(t) {
  254. for (var s, i = 1, n = arguments.length; i < n; i++) {
  255. s = arguments[i];
  256. for (var p in s)
  257. if (Object.prototype.hasOwnProperty.call(s, p))
  258. t[p] = s[p];
  259. }
  260. return t;
  261. };
  262. return __assign.apply(this, arguments);
  263. };
  264. function __spreadArray(to, from2, pack) {
  265. if (pack || arguments.length === 2)
  266. for (var i = 0, l = from2.length, ar; i < l; i++) {
  267. if (ar || !(i in from2)) {
  268. if (!ar)
  269. ar = Array.prototype.slice.call(from2, 0, i);
  270. ar[i] = from2[i];
  271. }
  272. }
  273. return to.concat(ar || Array.prototype.slice.call(from2));
  274. }
  275. var cached = function(f) {
  276. var called = false;
  277. var r;
  278. return function() {
  279. var args = [];
  280. for (var _i = 0; _i < arguments.length; _i++) {
  281. args[_i] = arguments[_i];
  282. }
  283. if (!called) {
  284. called = true;
  285. r = f.apply(null, args);
  286. }
  287. return r;
  288. };
  289. };
  290. var DeviceType = function(os, browser, userAgent, mediaMatch2) {
  291. var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
  292. var isiPhone = os.isiOS() && !isiPad;
  293. var isMobile = os.isiOS() || os.isAndroid();
  294. var isTouch = isMobile || mediaMatch2("(pointer:coarse)");
  295. var isTablet = isiPad || !isiPhone && isMobile && mediaMatch2("(min-device-width:768px)");
  296. var isPhone = isiPhone || isMobile && !isTablet;
  297. var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
  298. var isDesktop = !isPhone && !isTablet && !iOSwebview;
  299. return {
  300. isiPad: constant(isiPad),
  301. isiPhone: constant(isiPhone),
  302. isTablet: constant(isTablet),
  303. isPhone: constant(isPhone),
  304. isTouch: constant(isTouch),
  305. isAndroid: os.isAndroid,
  306. isiOS: os.isiOS,
  307. isWebView: constant(iOSwebview),
  308. isDesktop: constant(isDesktop)
  309. };
  310. };
  311. var firstMatch = function(regexes, s) {
  312. for (var i = 0; i < regexes.length; i++) {
  313. var x = regexes[i];
  314. if (x.test(s)) {
  315. return x;
  316. }
  317. }
  318. return void 0;
  319. };
  320. var find = function(regexes, agent) {
  321. var r = firstMatch(regexes, agent);
  322. if (!r) {
  323. return {
  324. major: 0,
  325. minor: 0
  326. };
  327. }
  328. var group = function(i) {
  329. return Number(agent.replace(r, "$" + i));
  330. };
  331. return nu$2(group(1), group(2));
  332. };
  333. var detect$3 = function(versionRegexes, agent) {
  334. var cleanedAgent = String(agent).toLowerCase();
  335. if (versionRegexes.length === 0) {
  336. return unknown$2();
  337. }
  338. return find(versionRegexes, cleanedAgent);
  339. };
  340. var unknown$2 = function() {
  341. return nu$2(0, 0);
  342. };
  343. var nu$2 = function(major, minor) {
  344. return {
  345. major,
  346. minor
  347. };
  348. };
  349. var Version = {
  350. nu: nu$2,
  351. detect: detect$3,
  352. unknown: unknown$2
  353. };
  354. var detectBrowser$1 = function(browsers2, userAgentData) {
  355. return findMap(userAgentData.brands, function(uaBrand) {
  356. var lcBrand = uaBrand.brand.toLowerCase();
  357. return find$1(browsers2, function(browser) {
  358. var _a;
  359. return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
  360. }).map(function(info) {
  361. return {
  362. current: info.name,
  363. version: Version.nu(parseInt(uaBrand.version, 10), 0)
  364. };
  365. });
  366. });
  367. };
  368. var detect$2 = function(candidates, userAgent) {
  369. var agent = String(userAgent).toLowerCase();
  370. return find$1(candidates, function(candidate) {
  371. return candidate.search(agent);
  372. });
  373. };
  374. var detectBrowser = function(browsers2, userAgent) {
  375. return detect$2(browsers2, userAgent).map(function(browser) {
  376. var version = Version.detect(browser.versionRegexes, userAgent);
  377. return {
  378. current: browser.name,
  379. version
  380. };
  381. });
  382. };
  383. var detectOs = function(oses2, userAgent) {
  384. return detect$2(oses2, userAgent).map(function(os) {
  385. var version = Version.detect(os.versionRegexes, userAgent);
  386. return {
  387. current: os.name,
  388. version
  389. };
  390. });
  391. };
  392. var contains$1 = function(str, substr) {
  393. return str.indexOf(substr) !== -1;
  394. };
  395. var blank = function(r) {
  396. return function(s) {
  397. return s.replace(r, "");
  398. };
  399. };
  400. var trim = blank(/^\s+|\s+$/g);
  401. var isNotEmpty = function(s) {
  402. return s.length > 0;
  403. };
  404. var isEmpty$1 = function(s) {
  405. return !isNotEmpty(s);
  406. };
  407. var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
  408. var checkContains = function(target) {
  409. return function(uastring) {
  410. return contains$1(uastring, target);
  411. };
  412. };
  413. var browsers = [
  414. {
  415. name: "Edge",
  416. versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
  417. search: function(uastring) {
  418. return contains$1(uastring, "edge/") && contains$1(uastring, "chrome") && contains$1(uastring, "safari") && contains$1(uastring, "applewebkit");
  419. }
  420. },
  421. {
  422. name: "Chrome",
  423. brand: "Chromium",
  424. versionRegexes: [
  425. /.*?chrome\/([0-9]+)\.([0-9]+).*/,
  426. normalVersionRegex
  427. ],
  428. search: function(uastring) {
  429. return contains$1(uastring, "chrome") && !contains$1(uastring, "chromeframe");
  430. }
  431. },
  432. {
  433. name: "IE",
  434. versionRegexes: [
  435. /.*?msie\ ?([0-9]+)\.([0-9]+).*/,
  436. /.*?rv:([0-9]+)\.([0-9]+).*/
  437. ],
  438. search: function(uastring) {
  439. return contains$1(uastring, "msie") || contains$1(uastring, "trident");
  440. }
  441. },
  442. {
  443. name: "Opera",
  444. versionRegexes: [
  445. normalVersionRegex,
  446. /.*?opera\/([0-9]+)\.([0-9]+).*/
  447. ],
  448. search: checkContains("opera")
  449. },
  450. {
  451. name: "Firefox",
  452. versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
  453. search: checkContains("firefox")
  454. },
  455. {
  456. name: "Safari",
  457. versionRegexes: [
  458. normalVersionRegex,
  459. /.*?cpu os ([0-9]+)_([0-9]+).*/
  460. ],
  461. search: function(uastring) {
  462. return (contains$1(uastring, "safari") || contains$1(uastring, "mobile/")) && contains$1(uastring, "applewebkit");
  463. }
  464. }
  465. ];
  466. var oses = [
  467. {
  468. name: "Windows",
  469. search: checkContains("win"),
  470. versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
  471. },
  472. {
  473. name: "iOS",
  474. search: function(uastring) {
  475. return contains$1(uastring, "iphone") || contains$1(uastring, "ipad");
  476. },
  477. versionRegexes: [
  478. /.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
  479. /.*cpu os ([0-9]+)_([0-9]+).*/,
  480. /.*cpu iphone os ([0-9]+)_([0-9]+).*/
  481. ]
  482. },
  483. {
  484. name: "Android",
  485. search: checkContains("android"),
  486. versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
  487. },
  488. {
  489. name: "OSX",
  490. search: checkContains("mac os x"),
  491. versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
  492. },
  493. {
  494. name: "Linux",
  495. search: checkContains("linux"),
  496. versionRegexes: []
  497. },
  498. {
  499. name: "Solaris",
  500. search: checkContains("sunos"),
  501. versionRegexes: []
  502. },
  503. {
  504. name: "FreeBSD",
  505. search: checkContains("freebsd"),
  506. versionRegexes: []
  507. },
  508. {
  509. name: "ChromeOS",
  510. search: checkContains("cros"),
  511. versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
  512. }
  513. ];
  514. var PlatformInfo = {
  515. browsers: constant(browsers),
  516. oses: constant(oses)
  517. };
  518. var edge = "Edge";
  519. var chrome = "Chrome";
  520. var ie = "IE";
  521. var opera = "Opera";
  522. var firefox = "Firefox";
  523. var safari = "Safari";
  524. var unknown$1 = function() {
  525. return nu$1({
  526. current: void 0,
  527. version: Version.unknown()
  528. });
  529. };
  530. var nu$1 = function(info) {
  531. var current = info.current;
  532. var version = info.version;
  533. var isBrowser = function(name2) {
  534. return function() {
  535. return current === name2;
  536. };
  537. };
  538. return {
  539. current,
  540. version,
  541. isEdge: isBrowser(edge),
  542. isChrome: isBrowser(chrome),
  543. isIE: isBrowser(ie),
  544. isOpera: isBrowser(opera),
  545. isFirefox: isBrowser(firefox),
  546. isSafari: isBrowser(safari)
  547. };
  548. };
  549. var Browser = {
  550. unknown: unknown$1,
  551. nu: nu$1,
  552. edge: constant(edge),
  553. chrome: constant(chrome),
  554. ie: constant(ie),
  555. opera: constant(opera),
  556. firefox: constant(firefox),
  557. safari: constant(safari)
  558. };
  559. var windows = "Windows";
  560. var ios = "iOS";
  561. var android = "Android";
  562. var linux = "Linux";
  563. var osx = "OSX";
  564. var solaris = "Solaris";
  565. var freebsd = "FreeBSD";
  566. var chromeos = "ChromeOS";
  567. var unknown = function() {
  568. return nu({
  569. current: void 0,
  570. version: Version.unknown()
  571. });
  572. };
  573. var nu = function(info) {
  574. var current = info.current;
  575. var version = info.version;
  576. var isOS = function(name2) {
  577. return function() {
  578. return current === name2;
  579. };
  580. };
  581. return {
  582. current,
  583. version,
  584. isWindows: isOS(windows),
  585. isiOS: isOS(ios),
  586. isAndroid: isOS(android),
  587. isOSX: isOS(osx),
  588. isLinux: isOS(linux),
  589. isSolaris: isOS(solaris),
  590. isFreeBSD: isOS(freebsd),
  591. isChromeOS: isOS(chromeos)
  592. };
  593. };
  594. var OperatingSystem = {
  595. unknown,
  596. nu,
  597. windows: constant(windows),
  598. ios: constant(ios),
  599. android: constant(android),
  600. linux: constant(linux),
  601. osx: constant(osx),
  602. solaris: constant(solaris),
  603. freebsd: constant(freebsd),
  604. chromeos: constant(chromeos)
  605. };
  606. var detect$1 = function(userAgent, userAgentDataOpt, mediaMatch2) {
  607. var browsers2 = PlatformInfo.browsers();
  608. var oses2 = PlatformInfo.oses();
  609. var browser = userAgentDataOpt.bind(function(userAgentData) {
  610. return detectBrowser$1(browsers2, userAgentData);
  611. }).orThunk(function() {
  612. return detectBrowser(browsers2, userAgent);
  613. }).fold(Browser.unknown, Browser.nu);
  614. var os = detectOs(oses2, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
  615. var deviceType = DeviceType(os, browser, userAgent, mediaMatch2);
  616. return {
  617. browser,
  618. os,
  619. deviceType
  620. };
  621. };
  622. var PlatformDetection = { detect: detect$1 };
  623. var mediaMatch = function(query) {
  624. return window.matchMedia(query).matches;
  625. };
  626. var platform = cached(function() {
  627. return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
  628. });
  629. var detect = function() {
  630. return platform();
  631. };
  632. var compareDocumentPosition = function(a, b, match) {
  633. return (a.compareDocumentPosition(b) & match) !== 0;
  634. };
  635. var documentPositionContainedBy = function(a, b) {
  636. return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);
  637. };
  638. var ELEMENT = 1;
  639. var fromHtml = function(html, scope) {
  640. var doc = scope || document;
  641. var div = doc.createElement("div");
  642. div.innerHTML = html;
  643. if (!div.hasChildNodes() || div.childNodes.length > 1) {
  644. console.error("HTML does not have a single root node", html);
  645. throw new Error("HTML must have a single root node");
  646. }
  647. return fromDom(div.childNodes[0]);
  648. };
  649. var fromTag = function(tag, scope) {
  650. var doc = scope || document;
  651. var node = doc.createElement(tag);
  652. return fromDom(node);
  653. };
  654. var fromText = function(text, scope) {
  655. var doc = scope || document;
  656. var node = doc.createTextNode(text);
  657. return fromDom(node);
  658. };
  659. var fromDom = function(node) {
  660. if (node === null || node === void 0) {
  661. throw new Error("Node cannot be null or undefined");
  662. }
  663. return { dom: node };
  664. };
  665. var fromPoint = function(docElm, x, y) {
  666. return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
  667. };
  668. var SugarElement = {
  669. fromHtml,
  670. fromTag,
  671. fromText,
  672. fromDom,
  673. fromPoint
  674. };
  675. var is$2 = function(element, selector) {
  676. var dom = element.dom;
  677. if (dom.nodeType !== ELEMENT) {
  678. return false;
  679. } else {
  680. var elem = dom;
  681. if (elem.matches !== void 0) {
  682. return elem.matches(selector);
  683. } else if (elem.msMatchesSelector !== void 0) {
  684. return elem.msMatchesSelector(selector);
  685. } else if (elem.webkitMatchesSelector !== void 0) {
  686. return elem.webkitMatchesSelector(selector);
  687. } else if (elem.mozMatchesSelector !== void 0) {
  688. return elem.mozMatchesSelector(selector);
  689. } else {
  690. throw new Error("Browser lacks native selectors");
  691. }
  692. }
  693. };
  694. var eq = function(e1, e2) {
  695. return e1.dom === e2.dom;
  696. };
  697. var regularContains = function(e1, e2) {
  698. var d1 = e1.dom;
  699. var d2 = e2.dom;
  700. return d1 === d2 ? false : d1.contains(d2);
  701. };
  702. var ieContains = function(e1, e2) {
  703. return documentPositionContainedBy(e1.dom, e2.dom);
  704. };
  705. var contains = function(e1, e2) {
  706. return detect().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
  707. };
  708. var is$1 = is$2;
  709. var global$6 = tinymce.util.Tools.resolve("tinymce.dom.RangeUtils");
  710. var global$5 = tinymce.util.Tools.resolve("tinymce.dom.TreeWalker");
  711. var global$4 = tinymce.util.Tools.resolve("tinymce.util.VK");
  712. var keys = Object.keys;
  713. var each = function(obj, f) {
  714. var props = keys(obj);
  715. for (var k = 0, len = props.length; k < len; k++) {
  716. var i = props[k];
  717. var x = obj[i];
  718. f(x, i);
  719. }
  720. };
  721. var objAcc = function(r) {
  722. return function(x, i) {
  723. r[i] = x;
  724. };
  725. };
  726. var internalFilter = function(obj, pred, onTrue, onFalse) {
  727. var r = {};
  728. each(obj, function(x, i) {
  729. (pred(x, i) ? onTrue : onFalse)(x, i);
  730. });
  731. return r;
  732. };
  733. var filter = function(obj, pred) {
  734. var t = {};
  735. internalFilter(obj, pred, objAcc(t), noop);
  736. return t;
  737. };
  738. typeof window !== "undefined" ? window : Function("return this;")();
  739. var name = function(element) {
  740. var r = element.dom.nodeName;
  741. return r.toLowerCase();
  742. };
  743. var type = function(element) {
  744. return element.dom.nodeType;
  745. };
  746. var isType = function(t) {
  747. return function(element) {
  748. return type(element) === t;
  749. };
  750. };
  751. var isElement = isType(ELEMENT);
  752. var isTag = function(tag) {
  753. return function(e) {
  754. return isElement(e) && name(e) === tag;
  755. };
  756. };
  757. var rawSet = function(dom, key, value) {
  758. if (isString(value) || isBoolean(value) || isNumber(value)) {
  759. dom.setAttribute(key, value + "");
  760. } else {
  761. console.error("Invalid call to Attribute.set. Key ", key, ":: Value ", value, ":: Element ", dom);
  762. throw new Error("Attribute value was not simple");
  763. }
  764. };
  765. var setAll = function(element, attrs) {
  766. var dom = element.dom;
  767. each(attrs, function(v, k) {
  768. rawSet(dom, k, v);
  769. });
  770. };
  771. var clone$1 = function(element) {
  772. return foldl(element.dom.attributes, function(acc, attr) {
  773. acc[attr.name] = attr.value;
  774. return acc;
  775. }, {});
  776. };
  777. var parent = function(element) {
  778. return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
  779. };
  780. var children = function(element) {
  781. return map(element.dom.childNodes, SugarElement.fromDom);
  782. };
  783. var child = function(element, index) {
  784. var cs = element.dom.childNodes;
  785. return Optional.from(cs[index]).map(SugarElement.fromDom);
  786. };
  787. var firstChild = function(element) {
  788. return child(element, 0);
  789. };
  790. var lastChild = function(element) {
  791. return child(element, element.dom.childNodes.length - 1);
  792. };
  793. var before$1 = function(marker, element) {
  794. var parent$1 = parent(marker);
  795. parent$1.each(function(v) {
  796. v.dom.insertBefore(element.dom, marker.dom);
  797. });
  798. };
  799. var append$1 = function(parent2, element) {
  800. parent2.dom.appendChild(element.dom);
  801. };
  802. var before = function(marker, elements) {
  803. each$1(elements, function(x) {
  804. before$1(marker, x);
  805. });
  806. };
  807. var append = function(parent2, elements) {
  808. each$1(elements, function(x) {
  809. append$1(parent2, x);
  810. });
  811. };
  812. var remove = function(element) {
  813. var dom = element.dom;
  814. if (dom.parentNode !== null) {
  815. dom.parentNode.removeChild(dom);
  816. }
  817. };
  818. var clone = function(original, isDeep) {
  819. return SugarElement.fromDom(original.dom.cloneNode(isDeep));
  820. };
  821. var deep = function(original) {
  822. return clone(original, true);
  823. };
  824. var shallowAs = function(original, tag) {
  825. var nu2 = SugarElement.fromTag(tag);
  826. var attributes = clone$1(original);
  827. setAll(nu2, attributes);
  828. return nu2;
  829. };
  830. var mutate = function(original, tag) {
  831. var nu2 = shallowAs(original, tag);
  832. before$1(original, nu2);
  833. var children$1 = children(original);
  834. append(nu2, children$1);
  835. remove(original);
  836. return nu2;
  837. };
  838. var global$3 = tinymce.util.Tools.resolve("tinymce.dom.DOMUtils");
  839. var global$2 = tinymce.util.Tools.resolve("tinymce.util.Tools");
  840. var matchNodeName = function(name2) {
  841. return function(node) {
  842. return node && node.nodeName.toLowerCase() === name2;
  843. };
  844. };
  845. var matchNodeNames = function(regex) {
  846. return function(node) {
  847. return node && regex.test(node.nodeName);
  848. };
  849. };
  850. var isTextNode = function(node) {
  851. return node && node.nodeType === 3;
  852. };
  853. var isListNode = matchNodeNames(/^(OL|UL|DL)$/);
  854. var isOlUlNode = matchNodeNames(/^(OL|UL)$/);
  855. var isOlNode = matchNodeName("ol");
  856. var isListItemNode = matchNodeNames(/^(LI|DT|DD)$/);
  857. var isDlItemNode = matchNodeNames(/^(DT|DD)$/);
  858. var isTableCellNode = matchNodeNames(/^(TH|TD)$/);
  859. var isBr = matchNodeName("br");
  860. var isFirstChild = function(node) {
  861. return node.parentNode.firstChild === node;
  862. };
  863. var isTextBlock = function(editor, node) {
  864. return node && !!editor.schema.getTextBlockElements()[node.nodeName];
  865. };
  866. var isBlock = function(node, blockElements) {
  867. return node && node.nodeName in blockElements;
  868. };
  869. var isBogusBr = function(dom, node) {
  870. if (!isBr(node)) {
  871. return false;
  872. }
  873. return dom.isBlock(node.nextSibling) && !isBr(node.previousSibling);
  874. };
  875. var isEmpty = function(dom, elm, keepBookmarks) {
  876. var empty = dom.isEmpty(elm);
  877. if (keepBookmarks && dom.select("span[data-mce-type=bookmark]", elm).length > 0) {
  878. return false;
  879. }
  880. return empty;
  881. };
  882. var isChildOfBody = function(dom, elm) {
  883. return dom.isChildOf(elm, dom.getRoot());
  884. };
  885. var shouldIndentOnTab = function(editor) {
  886. return editor.getParam("lists_indent_on_tab", true);
  887. };
  888. var getForcedRootBlock = function(editor) {
  889. var block = editor.getParam("forced_root_block", "p");
  890. if (block === false) {
  891. return "";
  892. } else if (block === true) {
  893. return "p";
  894. } else {
  895. return block;
  896. }
  897. };
  898. var getForcedRootBlockAttrs = function(editor) {
  899. return editor.getParam("forced_root_block_attrs", {});
  900. };
  901. var createTextBlock = function(editor, contentNode) {
  902. var dom = editor.dom;
  903. var blockElements = editor.schema.getBlockElements();
  904. var fragment = dom.createFragment();
  905. var blockName = getForcedRootBlock(editor);
  906. var node, textBlock, hasContentNode;
  907. if (blockName) {
  908. textBlock = dom.create(blockName);
  909. if (textBlock.tagName === blockName.toUpperCase()) {
  910. dom.setAttribs(textBlock, getForcedRootBlockAttrs(editor));
  911. }
  912. if (!isBlock(contentNode.firstChild, blockElements)) {
  913. fragment.appendChild(textBlock);
  914. }
  915. }
  916. if (contentNode) {
  917. while (node = contentNode.firstChild) {
  918. var nodeName = node.nodeName;
  919. if (!hasContentNode && (nodeName !== "SPAN" || node.getAttribute("data-mce-type") !== "bookmark")) {
  920. hasContentNode = true;
  921. }
  922. if (isBlock(node, blockElements)) {
  923. fragment.appendChild(node);
  924. textBlock = null;
  925. } else {
  926. if (blockName) {
  927. if (!textBlock) {
  928. textBlock = dom.create(blockName);
  929. fragment.appendChild(textBlock);
  930. }
  931. textBlock.appendChild(node);
  932. } else {
  933. fragment.appendChild(node);
  934. }
  935. }
  936. }
  937. }
  938. if (!blockName) {
  939. fragment.appendChild(dom.create("br"));
  940. } else {
  941. if (!hasContentNode) {
  942. textBlock.appendChild(dom.create("br", { "data-mce-bogus": "1" }));
  943. }
  944. }
  945. return fragment;
  946. };
  947. var DOM$2 = global$3.DOM;
  948. var splitList = function(editor, list, li) {
  949. var removeAndKeepBookmarks = function(targetNode) {
  950. global$2.each(bookmarks, function(node2) {
  951. targetNode.parentNode.insertBefore(node2, li.parentNode);
  952. });
  953. DOM$2.remove(targetNode);
  954. };
  955. var bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', list);
  956. var newBlock = createTextBlock(editor, li);
  957. var tmpRng = DOM$2.createRng();
  958. tmpRng.setStartAfter(li);
  959. tmpRng.setEndAfter(list);
  960. var fragment = tmpRng.extractContents();
  961. for (var node = fragment.firstChild; node; node = node.firstChild) {
  962. if (node.nodeName === "LI" && editor.dom.isEmpty(node)) {
  963. DOM$2.remove(node);
  964. break;
  965. }
  966. }
  967. if (!editor.dom.isEmpty(fragment)) {
  968. DOM$2.insertAfter(fragment, list);
  969. }
  970. DOM$2.insertAfter(newBlock, list);
  971. if (isEmpty(editor.dom, li.parentNode)) {
  972. removeAndKeepBookmarks(li.parentNode);
  973. }
  974. DOM$2.remove(li);
  975. if (isEmpty(editor.dom, list)) {
  976. DOM$2.remove(list);
  977. }
  978. };
  979. var isDescriptionDetail = isTag("dd");
  980. var isDescriptionTerm = isTag("dt");
  981. var outdentDlItem = function(editor, item) {
  982. if (isDescriptionDetail(item)) {
  983. mutate(item, "dt");
  984. } else if (isDescriptionTerm(item)) {
  985. parent(item).each(function(dl) {
  986. return splitList(editor, dl.dom, item.dom);
  987. });
  988. }
  989. };
  990. var indentDlItem = function(item) {
  991. if (isDescriptionTerm(item)) {
  992. mutate(item, "dd");
  993. }
  994. };
  995. var dlIndentation = function(editor, indentation, dlItems) {
  996. if (indentation === "Indent") {
  997. each$1(dlItems, indentDlItem);
  998. } else {
  999. each$1(dlItems, function(item) {
  1000. return outdentDlItem(editor, item);
  1001. });
  1002. }
  1003. };
  1004. var getNormalizedPoint = function(container, offset) {
  1005. if (isTextNode(container)) {
  1006. return {
  1007. container,
  1008. offset
  1009. };
  1010. }
  1011. var node = global$6.getNode(container, offset);
  1012. if (isTextNode(node)) {
  1013. return {
  1014. container: node,
  1015. offset: offset >= container.childNodes.length ? node.data.length : 0
  1016. };
  1017. } else if (node.previousSibling && isTextNode(node.previousSibling)) {
  1018. return {
  1019. container: node.previousSibling,
  1020. offset: node.previousSibling.data.length
  1021. };
  1022. } else if (node.nextSibling && isTextNode(node.nextSibling)) {
  1023. return {
  1024. container: node.nextSibling,
  1025. offset: 0
  1026. };
  1027. }
  1028. return {
  1029. container,
  1030. offset
  1031. };
  1032. };
  1033. var normalizeRange = function(rng) {
  1034. var outRng = rng.cloneRange();
  1035. var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
  1036. outRng.setStart(rangeStart.container, rangeStart.offset);
  1037. var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
  1038. outRng.setEnd(rangeEnd.container, rangeEnd.offset);
  1039. return outRng;
  1040. };
  1041. var global$1 = tinymce.util.Tools.resolve("tinymce.dom.DomQuery");
  1042. var getParentList = function(editor, node) {
  1043. var selectionStart = node || editor.selection.getStart(true);
  1044. return editor.dom.getParent(selectionStart, "OL,UL,DL", getClosestListRootElm(editor, selectionStart));
  1045. };
  1046. var isParentListSelected = function(parentList, selectedBlocks) {
  1047. return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
  1048. };
  1049. var findSubLists = function(parentList) {
  1050. return filter$1(parentList.querySelectorAll("ol,ul,dl"), isListNode);
  1051. };
  1052. var getSelectedSubLists = function(editor) {
  1053. var parentList = getParentList(editor);
  1054. var selectedBlocks = editor.selection.getSelectedBlocks();
  1055. if (isParentListSelected(parentList, selectedBlocks)) {
  1056. return findSubLists(parentList);
  1057. } else {
  1058. return filter$1(selectedBlocks, function(elm) {
  1059. return isListNode(elm) && parentList !== elm;
  1060. });
  1061. }
  1062. };
  1063. var findParentListItemsNodes = function(editor, elms) {
  1064. var listItemsElms = global$2.map(elms, function(elm) {
  1065. var parentLi = editor.dom.getParent(elm, "li,dd,dt", getClosestListRootElm(editor, elm));
  1066. return parentLi ? parentLi : elm;
  1067. });
  1068. return global$1.unique(listItemsElms);
  1069. };
  1070. var getSelectedListItems = function(editor) {
  1071. var selectedBlocks = editor.selection.getSelectedBlocks();
  1072. return filter$1(findParentListItemsNodes(editor, selectedBlocks), isListItemNode);
  1073. };
  1074. var getSelectedDlItems = function(editor) {
  1075. return filter$1(getSelectedListItems(editor), isDlItemNode);
  1076. };
  1077. var getClosestListRootElm = function(editor, elm) {
  1078. var parentTableCell = editor.dom.getParents(elm, "TD,TH");
  1079. return parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
  1080. };
  1081. var findLastParentListNode = function(editor, elm) {
  1082. var parentLists = editor.dom.getParents(elm, "ol,ul", getClosestListRootElm(editor, elm));
  1083. return last(parentLists);
  1084. };
  1085. var getSelectedLists = function(editor) {
  1086. var firstList = findLastParentListNode(editor, editor.selection.getStart());
  1087. var subsequentLists = filter$1(editor.selection.getSelectedBlocks(), isOlUlNode);
  1088. return firstList.toArray().concat(subsequentLists);
  1089. };
  1090. var getSelectedListRoots = function(editor) {
  1091. var selectedLists = getSelectedLists(editor);
  1092. return getUniqueListRoots(editor, selectedLists);
  1093. };
  1094. var getUniqueListRoots = function(editor, lists) {
  1095. var listRoots = map(lists, function(list) {
  1096. return findLastParentListNode(editor, list).getOr(list);
  1097. });
  1098. return global$1.unique(listRoots);
  1099. };
  1100. var is = function(lhs, rhs, comparator) {
  1101. if (comparator === void 0) {
  1102. comparator = tripleEquals;
  1103. }
  1104. return lhs.exists(function(left) {
  1105. return comparator(left, rhs);
  1106. });
  1107. };
  1108. var lift2 = function(oa, ob, f) {
  1109. return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
  1110. };
  1111. var fromElements = function(elements, scope) {
  1112. var doc = scope || document;
  1113. var fragment = doc.createDocumentFragment();
  1114. each$1(elements, function(element) {
  1115. fragment.appendChild(element.dom);
  1116. });
  1117. return SugarElement.fromDom(fragment);
  1118. };
  1119. var fireListEvent = function(editor, action, element) {
  1120. return editor.fire("ListMutation", {
  1121. action,
  1122. element
  1123. });
  1124. };
  1125. var isSupported = function(dom) {
  1126. return dom.style !== void 0 && isFunction(dom.style.getPropertyValue);
  1127. };
  1128. var internalSet = function(dom, property, value) {
  1129. if (!isString(value)) {
  1130. console.error("Invalid call to CSS.set. Property ", property, ":: Value ", value, ":: Element ", dom);
  1131. throw new Error("CSS value must be a string: " + value);
  1132. }
  1133. if (isSupported(dom)) {
  1134. dom.style.setProperty(property, value);
  1135. }
  1136. };
  1137. var set = function(element, property, value) {
  1138. var dom = element.dom;
  1139. internalSet(dom, property, value);
  1140. };
  1141. var joinSegment = function(parent2, child2) {
  1142. append$1(parent2.item, child2.list);
  1143. };
  1144. var joinSegments = function(segments) {
  1145. for (var i = 1; i < segments.length; i++) {
  1146. joinSegment(segments[i - 1], segments[i]);
  1147. }
  1148. };
  1149. var appendSegments = function(head$1, tail) {
  1150. lift2(last(head$1), head(tail), joinSegment);
  1151. };
  1152. var createSegment = function(scope, listType) {
  1153. var segment = {
  1154. list: SugarElement.fromTag(listType, scope),
  1155. item: SugarElement.fromTag("li", scope)
  1156. };
  1157. append$1(segment.list, segment.item);
  1158. return segment;
  1159. };
  1160. var createSegments = function(scope, entry, size) {
  1161. var segments = [];
  1162. for (var i = 0; i < size; i++) {
  1163. segments.push(createSegment(scope, entry.listType));
  1164. }
  1165. return segments;
  1166. };
  1167. var populateSegments = function(segments, entry) {
  1168. for (var i = 0; i < segments.length - 1; i++) {
  1169. set(segments[i].item, "list-style-type", "none");
  1170. }
  1171. last(segments).each(function(segment) {
  1172. setAll(segment.list, entry.listAttributes);
  1173. setAll(segment.item, entry.itemAttributes);
  1174. append(segment.item, entry.content);
  1175. });
  1176. };
  1177. var normalizeSegment = function(segment, entry) {
  1178. if (name(segment.list) !== entry.listType) {
  1179. segment.list = mutate(segment.list, entry.listType);
  1180. }
  1181. setAll(segment.list, entry.listAttributes);
  1182. };
  1183. var createItem = function(scope, attr, content) {
  1184. var item = SugarElement.fromTag("li", scope);
  1185. setAll(item, attr);
  1186. append(item, content);
  1187. return item;
  1188. };
  1189. var appendItem = function(segment, item) {
  1190. append$1(segment.list, item);
  1191. segment.item = item;
  1192. };
  1193. var writeShallow = function(scope, cast, entry) {
  1194. var newCast = cast.slice(0, entry.depth);
  1195. last(newCast).each(function(segment) {
  1196. var item = createItem(scope, entry.itemAttributes, entry.content);
  1197. appendItem(segment, item);
  1198. normalizeSegment(segment, entry);
  1199. });
  1200. return newCast;
  1201. };
  1202. var writeDeep = function(scope, cast, entry) {
  1203. var segments = createSegments(scope, entry, entry.depth - cast.length);
  1204. joinSegments(segments);
  1205. populateSegments(segments, entry);
  1206. appendSegments(cast, segments);
  1207. return cast.concat(segments);
  1208. };
  1209. var composeList = function(scope, entries) {
  1210. var cast = foldl(entries, function(cast2, entry) {
  1211. return entry.depth > cast2.length ? writeDeep(scope, cast2, entry) : writeShallow(scope, cast2, entry);
  1212. }, []);
  1213. return head(cast).map(function(segment) {
  1214. return segment.list;
  1215. });
  1216. };
  1217. var isList = function(el) {
  1218. return is$1(el, "OL,UL");
  1219. };
  1220. var hasFirstChildList = function(el) {
  1221. return firstChild(el).exists(isList);
  1222. };
  1223. var hasLastChildList = function(el) {
  1224. return lastChild(el).exists(isList);
  1225. };
  1226. var isIndented = function(entry) {
  1227. return entry.depth > 0;
  1228. };
  1229. var isSelected = function(entry) {
  1230. return entry.isSelected;
  1231. };
  1232. var cloneItemContent = function(li) {
  1233. var children$1 = children(li);
  1234. var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
  1235. return map(content, deep);
  1236. };
  1237. var createEntry = function(li, depth, isSelected2) {
  1238. return parent(li).filter(isElement).map(function(list) {
  1239. return {
  1240. depth,
  1241. dirty: false,
  1242. isSelected: isSelected2,
  1243. content: cloneItemContent(li),
  1244. itemAttributes: clone$1(li),
  1245. listAttributes: clone$1(list),
  1246. listType: name(list)
  1247. };
  1248. });
  1249. };
  1250. var indentEntry = function(indentation, entry) {
  1251. switch (indentation) {
  1252. case "Indent":
  1253. entry.depth++;
  1254. break;
  1255. case "Outdent":
  1256. entry.depth--;
  1257. break;
  1258. case "Flatten":
  1259. entry.depth = 0;
  1260. }
  1261. entry.dirty = true;
  1262. };
  1263. var cloneListProperties = function(target, source) {
  1264. target.listType = source.listType;
  1265. target.listAttributes = __assign({}, source.listAttributes);
  1266. };
  1267. var cleanListProperties = function(entry) {
  1268. entry.listAttributes = filter(entry.listAttributes, function(_value, key) {
  1269. return key !== "start";
  1270. });
  1271. };
  1272. var closestSiblingEntry = function(entries, start) {
  1273. var depth = entries[start].depth;
  1274. var matches = function(entry) {
  1275. return entry.depth === depth && !entry.dirty;
  1276. };
  1277. var until = function(entry) {
  1278. return entry.depth < depth;
  1279. };
  1280. return findUntil(reverse(entries.slice(0, start)), matches, until).orThunk(function() {
  1281. return findUntil(entries.slice(start + 1), matches, until);
  1282. });
  1283. };
  1284. var normalizeEntries = function(entries) {
  1285. each$1(entries, function(entry, i) {
  1286. closestSiblingEntry(entries, i).fold(function() {
  1287. if (entry.dirty) {
  1288. cleanListProperties(entry);
  1289. }
  1290. }, function(matchingEntry) {
  1291. return cloneListProperties(entry, matchingEntry);
  1292. });
  1293. });
  1294. return entries;
  1295. };
  1296. var Cell = function(initial) {
  1297. var value = initial;
  1298. var get2 = function() {
  1299. return value;
  1300. };
  1301. var set2 = function(v) {
  1302. value = v;
  1303. };
  1304. return {
  1305. get: get2,
  1306. set: set2
  1307. };
  1308. };
  1309. var parseItem = function(depth, itemSelection, selectionState, item) {
  1310. return firstChild(item).filter(isList).fold(function() {
  1311. itemSelection.each(function(selection) {
  1312. if (eq(selection.start, item)) {
  1313. selectionState.set(true);
  1314. }
  1315. });
  1316. var currentItemEntry = createEntry(item, depth, selectionState.get());
  1317. itemSelection.each(function(selection) {
  1318. if (eq(selection.end, item)) {
  1319. selectionState.set(false);
  1320. }
  1321. });
  1322. var childListEntries = lastChild(item).filter(isList).map(function(list) {
  1323. return parseList(depth, itemSelection, selectionState, list);
  1324. }).getOr([]);
  1325. return currentItemEntry.toArray().concat(childListEntries);
  1326. }, function(list) {
  1327. return parseList(depth, itemSelection, selectionState, list);
  1328. });
  1329. };
  1330. var parseList = function(depth, itemSelection, selectionState, list) {
  1331. return bind(children(list), function(element) {
  1332. var parser = isList(element) ? parseList : parseItem;
  1333. var newDepth = depth + 1;
  1334. return parser(newDepth, itemSelection, selectionState, element);
  1335. });
  1336. };
  1337. var parseLists = function(lists, itemSelection) {
  1338. var selectionState = Cell(false);
  1339. var initialDepth = 0;
  1340. return map(lists, function(list) {
  1341. return {
  1342. sourceList: list,
  1343. entries: parseList(initialDepth, itemSelection, selectionState, list)
  1344. };
  1345. });
  1346. };
  1347. var outdentedComposer = function(editor, entries) {
  1348. var normalizedEntries = normalizeEntries(entries);
  1349. return map(normalizedEntries, function(entry) {
  1350. var content = fromElements(entry.content);
  1351. return SugarElement.fromDom(createTextBlock(editor, content.dom));
  1352. });
  1353. };
  1354. var indentedComposer = function(editor, entries) {
  1355. var normalizedEntries = normalizeEntries(entries);
  1356. return composeList(editor.contentDocument, normalizedEntries).toArray();
  1357. };
  1358. var composeEntries = function(editor, entries) {
  1359. return bind(groupBy(entries, isIndented), function(entries2) {
  1360. var groupIsIndented = head(entries2).exists(isIndented);
  1361. return groupIsIndented ? indentedComposer(editor, entries2) : outdentedComposer(editor, entries2);
  1362. });
  1363. };
  1364. var indentSelectedEntries = function(entries, indentation) {
  1365. each$1(filter$1(entries, isSelected), function(entry) {
  1366. return indentEntry(indentation, entry);
  1367. });
  1368. };
  1369. var getItemSelection = function(editor) {
  1370. var selectedListItems = map(getSelectedListItems(editor), SugarElement.fromDom);
  1371. return lift2(find$1(selectedListItems, not(hasFirstChildList)), find$1(reverse(selectedListItems), not(hasFirstChildList)), function(start, end) {
  1372. return {
  1373. start,
  1374. end
  1375. };
  1376. });
  1377. };
  1378. var listIndentation = function(editor, lists, indentation) {
  1379. var entrySets = parseLists(lists, getItemSelection(editor));
  1380. each$1(entrySets, function(entrySet) {
  1381. indentSelectedEntries(entrySet.entries, indentation);
  1382. var composedLists = composeEntries(editor, entrySet.entries);
  1383. each$1(composedLists, function(composedList) {
  1384. fireListEvent(editor, indentation === "Indent" ? "IndentList" : "OutdentList", composedList.dom);
  1385. });
  1386. before(entrySet.sourceList, composedLists);
  1387. remove(entrySet.sourceList);
  1388. });
  1389. };
  1390. var selectionIndentation = function(editor, indentation) {
  1391. var lists = map(getSelectedListRoots(editor), SugarElement.fromDom);
  1392. var dlItems = map(getSelectedDlItems(editor), SugarElement.fromDom);
  1393. var isHandled = false;
  1394. if (lists.length || dlItems.length) {
  1395. var bookmark = editor.selection.getBookmark();
  1396. listIndentation(editor, lists, indentation);
  1397. dlIndentation(editor, indentation, dlItems);
  1398. editor.selection.moveToBookmark(bookmark);
  1399. editor.selection.setRng(normalizeRange(editor.selection.getRng()));
  1400. editor.nodeChanged();
  1401. isHandled = true;
  1402. }
  1403. return isHandled;
  1404. };
  1405. var indentListSelection = function(editor) {
  1406. return selectionIndentation(editor, "Indent");
  1407. };
  1408. var outdentListSelection = function(editor) {
  1409. return selectionIndentation(editor, "Outdent");
  1410. };
  1411. var flattenListSelection = function(editor) {
  1412. return selectionIndentation(editor, "Flatten");
  1413. };
  1414. var global = tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager");
  1415. var DOM$1 = global$3.DOM;
  1416. var createBookmark = function(rng) {
  1417. var bookmark = {};
  1418. var setupEndPoint = function(start) {
  1419. var container = rng[start ? "startContainer" : "endContainer"];
  1420. var offset = rng[start ? "startOffset" : "endOffset"];
  1421. if (container.nodeType === 1) {
  1422. var offsetNode = DOM$1.create("span", { "data-mce-type": "bookmark" });
  1423. if (container.hasChildNodes()) {
  1424. offset = Math.min(offset, container.childNodes.length - 1);
  1425. if (start) {
  1426. container.insertBefore(offsetNode, container.childNodes[offset]);
  1427. } else {
  1428. DOM$1.insertAfter(offsetNode, container.childNodes[offset]);
  1429. }
  1430. } else {
  1431. container.appendChild(offsetNode);
  1432. }
  1433. container = offsetNode;
  1434. offset = 0;
  1435. }
  1436. bookmark[start ? "startContainer" : "endContainer"] = container;
  1437. bookmark[start ? "startOffset" : "endOffset"] = offset;
  1438. };
  1439. setupEndPoint(true);
  1440. if (!rng.collapsed) {
  1441. setupEndPoint();
  1442. }
  1443. return bookmark;
  1444. };
  1445. var resolveBookmark = function(bookmark) {
  1446. var restoreEndPoint = function(start) {
  1447. var node;
  1448. var nodeIndex = function(container2) {
  1449. var node2 = container2.parentNode.firstChild, idx = 0;
  1450. while (node2) {
  1451. if (node2 === container2) {
  1452. return idx;
  1453. }
  1454. if (node2.nodeType !== 1 || node2.getAttribute("data-mce-type") !== "bookmark") {
  1455. idx++;
  1456. }
  1457. node2 = node2.nextSibling;
  1458. }
  1459. return -1;
  1460. };
  1461. var container = node = bookmark[start ? "startContainer" : "endContainer"];
  1462. var offset = bookmark[start ? "startOffset" : "endOffset"];
  1463. if (!container) {
  1464. return;
  1465. }
  1466. if (container.nodeType === 1) {
  1467. offset = nodeIndex(container);
  1468. container = container.parentNode;
  1469. DOM$1.remove(node);
  1470. if (!container.hasChildNodes() && DOM$1.isBlock(container)) {
  1471. container.appendChild(DOM$1.create("br"));
  1472. }
  1473. }
  1474. bookmark[start ? "startContainer" : "endContainer"] = container;
  1475. bookmark[start ? "startOffset" : "endOffset"] = offset;
  1476. };
  1477. restoreEndPoint(true);
  1478. restoreEndPoint();
  1479. var rng = DOM$1.createRng();
  1480. rng.setStart(bookmark.startContainer, bookmark.startOffset);
  1481. if (bookmark.endContainer) {
  1482. rng.setEnd(bookmark.endContainer, bookmark.endOffset);
  1483. }
  1484. return normalizeRange(rng);
  1485. };
  1486. var listToggleActionFromListName = function(listName) {
  1487. switch (listName) {
  1488. case "UL":
  1489. return "ToggleUlList";
  1490. case "OL":
  1491. return "ToggleOlList";
  1492. case "DL":
  1493. return "ToggleDLList";
  1494. }
  1495. };
  1496. var isCustomList = function(list) {
  1497. return /\btox\-/.test(list.className);
  1498. };
  1499. var listState = function(editor, listName, activate) {
  1500. var nodeChangeHandler = function(e) {
  1501. var inList = findUntil(e.parents, isListNode, isTableCellNode).filter(function(list) {
  1502. return list.nodeName === listName && !isCustomList(list);
  1503. }).isSome();
  1504. activate(inList);
  1505. };
  1506. var parents = editor.dom.getParents(editor.selection.getNode());
  1507. nodeChangeHandler({ parents });
  1508. editor.on("NodeChange", nodeChangeHandler);
  1509. return function() {
  1510. return editor.off("NodeChange", nodeChangeHandler);
  1511. };
  1512. };
  1513. var updateListStyle = function(dom, el, detail) {
  1514. var type2 = detail["list-style-type"] ? detail["list-style-type"] : null;
  1515. dom.setStyle(el, "list-style-type", type2);
  1516. };
  1517. var setAttribs = function(elm, attrs) {
  1518. global$2.each(attrs, function(value, key) {
  1519. elm.setAttribute(key, value);
  1520. });
  1521. };
  1522. var updateListAttrs = function(dom, el, detail) {
  1523. setAttribs(el, detail["list-attributes"]);
  1524. global$2.each(dom.select("li", el), function(li) {
  1525. setAttribs(li, detail["list-item-attributes"]);
  1526. });
  1527. };
  1528. var updateListWithDetails = function(dom, el, detail) {
  1529. updateListStyle(dom, el, detail);
  1530. updateListAttrs(dom, el, detail);
  1531. };
  1532. var removeStyles = function(dom, element, styles) {
  1533. global$2.each(styles, function(style) {
  1534. var _a;
  1535. return dom.setStyle(element, (_a = {}, _a[style] = "", _a));
  1536. });
  1537. };
  1538. var getEndPointNode = function(editor, rng, start, root) {
  1539. var container = rng[start ? "startContainer" : "endContainer"];
  1540. var offset = rng[start ? "startOffset" : "endOffset"];
  1541. if (container.nodeType === 1) {
  1542. container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
  1543. }
  1544. if (!start && isBr(container.nextSibling)) {
  1545. container = container.nextSibling;
  1546. }
  1547. while (container.parentNode !== root) {
  1548. if (isTextBlock(editor, container)) {
  1549. return container;
  1550. }
  1551. if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
  1552. return container;
  1553. }
  1554. container = container.parentNode;
  1555. }
  1556. return container;
  1557. };
  1558. var getSelectedTextBlocks = function(editor, rng, root) {
  1559. var textBlocks = [];
  1560. var dom = editor.dom;
  1561. var startNode = getEndPointNode(editor, rng, true, root);
  1562. var endNode = getEndPointNode(editor, rng, false, root);
  1563. var block;
  1564. var siblings = [];
  1565. for (var node = startNode; node; node = node.nextSibling) {
  1566. siblings.push(node);
  1567. if (node === endNode) {
  1568. break;
  1569. }
  1570. }
  1571. global$2.each(siblings, function(node2) {
  1572. if (isTextBlock(editor, node2)) {
  1573. textBlocks.push(node2);
  1574. block = null;
  1575. return;
  1576. }
  1577. if (dom.isBlock(node2) || isBr(node2)) {
  1578. if (isBr(node2)) {
  1579. dom.remove(node2);
  1580. }
  1581. block = null;
  1582. return;
  1583. }
  1584. var nextSibling = node2.nextSibling;
  1585. if (global.isBookmarkNode(node2)) {
  1586. if (isListNode(nextSibling) || isTextBlock(editor, nextSibling) || !nextSibling && node2.parentNode === root) {
  1587. block = null;
  1588. return;
  1589. }
  1590. }
  1591. if (!block) {
  1592. block = dom.create("p");
  1593. node2.parentNode.insertBefore(block, node2);
  1594. textBlocks.push(block);
  1595. }
  1596. block.appendChild(node2);
  1597. });
  1598. return textBlocks;
  1599. };
  1600. var hasCompatibleStyle = function(dom, sib, detail) {
  1601. var sibStyle = dom.getStyle(sib, "list-style-type");
  1602. var detailStyle = detail ? detail["list-style-type"] : "";
  1603. detailStyle = detailStyle === null ? "" : detailStyle;
  1604. return sibStyle === detailStyle;
  1605. };
  1606. var applyList = function(editor, listName, detail) {
  1607. var rng = editor.selection.getRng();
  1608. var listItemName = "LI";
  1609. var root = getClosestListRootElm(editor, editor.selection.getStart(true));
  1610. var dom = editor.dom;
  1611. if (dom.getContentEditable(editor.selection.getNode()) === "false") {
  1612. return;
  1613. }
  1614. listName = listName.toUpperCase();
  1615. if (listName === "DL") {
  1616. listItemName = "DT";
  1617. }
  1618. var bookmark = createBookmark(rng);
  1619. var selectedTextBlocks = getSelectedTextBlocks(editor, rng, root);
  1620. global$2.each(selectedTextBlocks, function(block) {
  1621. var listBlock;
  1622. var sibling = block.previousSibling;
  1623. var parent2 = block.parentNode;
  1624. if (!isListItemNode(parent2)) {
  1625. if (sibling && isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
  1626. listBlock = sibling;
  1627. block = dom.rename(block, listItemName);
  1628. sibling.appendChild(block);
  1629. } else {
  1630. listBlock = dom.create(listName);
  1631. block.parentNode.insertBefore(listBlock, block);
  1632. listBlock.appendChild(block);
  1633. block = dom.rename(block, listItemName);
  1634. }
  1635. removeStyles(dom, block, [
  1636. "margin",
  1637. "margin-right",
  1638. "margin-bottom",
  1639. "margin-left",
  1640. "margin-top",
  1641. "padding",
  1642. "padding-right",
  1643. "padding-bottom",
  1644. "padding-left",
  1645. "padding-top"
  1646. ]);
  1647. updateListWithDetails(dom, listBlock, detail);
  1648. mergeWithAdjacentLists(editor.dom, listBlock);
  1649. }
  1650. });
  1651. editor.selection.setRng(resolveBookmark(bookmark));
  1652. };
  1653. var isValidLists = function(list1, list2) {
  1654. return list1 && list2 && isListNode(list1) && list1.nodeName === list2.nodeName;
  1655. };
  1656. var hasSameListStyle = function(dom, list1, list2) {
  1657. var targetStyle = dom.getStyle(list1, "list-style-type", true);
  1658. var style = dom.getStyle(list2, "list-style-type", true);
  1659. return targetStyle === style;
  1660. };
  1661. var hasSameClasses = function(elm1, elm2) {
  1662. return elm1.className === elm2.className;
  1663. };
  1664. var shouldMerge = function(dom, list1, list2) {
  1665. return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
  1666. };
  1667. var mergeWithAdjacentLists = function(dom, listBlock) {
  1668. var sibling, node;
  1669. sibling = listBlock.nextSibling;
  1670. if (shouldMerge(dom, listBlock, sibling)) {
  1671. while (node = sibling.firstChild) {
  1672. listBlock.appendChild(node);
  1673. }
  1674. dom.remove(sibling);
  1675. }
  1676. sibling = listBlock.previousSibling;
  1677. if (shouldMerge(dom, listBlock, sibling)) {
  1678. while (node = sibling.lastChild) {
  1679. listBlock.insertBefore(node, listBlock.firstChild);
  1680. }
  1681. dom.remove(sibling);
  1682. }
  1683. };
  1684. var updateList$1 = function(editor, list, listName, detail) {
  1685. if (list.nodeName !== listName) {
  1686. var newList = editor.dom.rename(list, listName);
  1687. updateListWithDetails(editor.dom, newList, detail);
  1688. fireListEvent(editor, listToggleActionFromListName(listName), newList);
  1689. } else {
  1690. updateListWithDetails(editor.dom, list, detail);
  1691. fireListEvent(editor, listToggleActionFromListName(listName), list);
  1692. }
  1693. };
  1694. var toggleMultipleLists = function(editor, parentList, lists, listName, detail) {
  1695. var parentIsList = isListNode(parentList);
  1696. if (parentIsList && parentList.nodeName === listName && !hasListStyleDetail(detail)) {
  1697. flattenListSelection(editor);
  1698. } else {
  1699. applyList(editor, listName, detail);
  1700. var bookmark = createBookmark(editor.selection.getRng());
  1701. var allLists = parentIsList ? __spreadArray([parentList], lists, true) : lists;
  1702. global$2.each(allLists, function(elm) {
  1703. updateList$1(editor, elm, listName, detail);
  1704. });
  1705. editor.selection.setRng(resolveBookmark(bookmark));
  1706. }
  1707. };
  1708. var hasListStyleDetail = function(detail) {
  1709. return "list-style-type" in detail;
  1710. };
  1711. var toggleSingleList = function(editor, parentList, listName, detail) {
  1712. if (parentList === editor.getBody()) {
  1713. return;
  1714. }
  1715. if (parentList) {
  1716. if (parentList.nodeName === listName && !hasListStyleDetail(detail) && !isCustomList(parentList)) {
  1717. flattenListSelection(editor);
  1718. } else {
  1719. var bookmark = createBookmark(editor.selection.getRng());
  1720. updateListWithDetails(editor.dom, parentList, detail);
  1721. var newList = editor.dom.rename(parentList, listName);
  1722. mergeWithAdjacentLists(editor.dom, newList);
  1723. editor.selection.setRng(resolveBookmark(bookmark));
  1724. applyList(editor, listName, detail);
  1725. fireListEvent(editor, listToggleActionFromListName(listName), newList);
  1726. }
  1727. } else {
  1728. applyList(editor, listName, detail);
  1729. fireListEvent(editor, listToggleActionFromListName(listName), parentList);
  1730. }
  1731. };
  1732. var toggleList = function(editor, listName, _detail) {
  1733. var parentList = getParentList(editor);
  1734. var selectedSubLists = getSelectedSubLists(editor);
  1735. var detail = isObject(_detail) ? _detail : {};
  1736. if (selectedSubLists.length > 0) {
  1737. toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
  1738. } else {
  1739. toggleSingleList(editor, parentList, listName, detail);
  1740. }
  1741. };
  1742. var DOM = global$3.DOM;
  1743. var normalizeList = function(dom, list) {
  1744. var parentNode = list.parentNode;
  1745. if (parentNode.nodeName === "LI" && parentNode.firstChild === list) {
  1746. var sibling = parentNode.previousSibling;
  1747. if (sibling && sibling.nodeName === "LI") {
  1748. sibling.appendChild(list);
  1749. if (isEmpty(dom, parentNode)) {
  1750. DOM.remove(parentNode);
  1751. }
  1752. } else {
  1753. DOM.setStyle(parentNode, "listStyleType", "none");
  1754. }
  1755. }
  1756. if (isListNode(parentNode)) {
  1757. var sibling = parentNode.previousSibling;
  1758. if (sibling && sibling.nodeName === "LI") {
  1759. sibling.appendChild(list);
  1760. }
  1761. }
  1762. };
  1763. var normalizeLists = function(dom, element) {
  1764. var lists = global$2.grep(dom.select("ol,ul", element));
  1765. global$2.each(lists, function(list) {
  1766. normalizeList(dom, list);
  1767. });
  1768. };
  1769. var findNextCaretContainer = function(editor, rng, isForward, root) {
  1770. var node = rng.startContainer;
  1771. var offset = rng.startOffset;
  1772. if (isTextNode(node) && (isForward ? offset < node.data.length : offset > 0)) {
  1773. return node;
  1774. }
  1775. var nonEmptyBlocks = editor.schema.getNonEmptyElements();
  1776. if (node.nodeType === 1) {
  1777. node = global$6.getNode(node, offset);
  1778. }
  1779. var walker = new global$5(node, root);
  1780. if (isForward) {
  1781. if (isBogusBr(editor.dom, node)) {
  1782. walker.next();
  1783. }
  1784. }
  1785. while (node = walker[isForward ? "next" : "prev2"]()) {
  1786. if (node.nodeName === "LI" && !node.hasChildNodes()) {
  1787. return node;
  1788. }
  1789. if (nonEmptyBlocks[node.nodeName]) {
  1790. return node;
  1791. }
  1792. if (isTextNode(node) && node.data.length > 0) {
  1793. return node;
  1794. }
  1795. }
  1796. };
  1797. var hasOnlyOneBlockChild = function(dom, elm) {
  1798. var childNodes = elm.childNodes;
  1799. return childNodes.length === 1 && !isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
  1800. };
  1801. var unwrapSingleBlockChild = function(dom, elm) {
  1802. if (hasOnlyOneBlockChild(dom, elm)) {
  1803. dom.remove(elm.firstChild, true);
  1804. }
  1805. };
  1806. var moveChildren = function(dom, fromElm, toElm) {
  1807. var node;
  1808. var targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
  1809. unwrapSingleBlockChild(dom, fromElm);
  1810. if (!isEmpty(dom, fromElm, true)) {
  1811. while (node = fromElm.firstChild) {
  1812. targetElm.appendChild(node);
  1813. }
  1814. }
  1815. };
  1816. var mergeLiElements = function(dom, fromElm, toElm) {
  1817. var listNode;
  1818. var ul = fromElm.parentNode;
  1819. if (!isChildOfBody(dom, fromElm) || !isChildOfBody(dom, toElm)) {
  1820. return;
  1821. }
  1822. if (isListNode(toElm.lastChild)) {
  1823. listNode = toElm.lastChild;
  1824. }
  1825. if (ul === toElm.lastChild) {
  1826. if (isBr(ul.previousSibling)) {
  1827. dom.remove(ul.previousSibling);
  1828. }
  1829. }
  1830. var node = toElm.lastChild;
  1831. if (node && isBr(node) && fromElm.hasChildNodes()) {
  1832. dom.remove(node);
  1833. }
  1834. if (isEmpty(dom, toElm, true)) {
  1835. dom.$(toElm).empty();
  1836. }
  1837. moveChildren(dom, fromElm, toElm);
  1838. if (listNode) {
  1839. toElm.appendChild(listNode);
  1840. }
  1841. var contains$12 = contains(SugarElement.fromDom(toElm), SugarElement.fromDom(fromElm));
  1842. var nestedLists = contains$12 ? dom.getParents(fromElm, isListNode, toElm) : [];
  1843. dom.remove(fromElm);
  1844. each$1(nestedLists, function(list) {
  1845. if (isEmpty(dom, list) && list !== dom.getRoot()) {
  1846. dom.remove(list);
  1847. }
  1848. });
  1849. };
  1850. var mergeIntoEmptyLi = function(editor, fromLi, toLi) {
  1851. editor.dom.$(toLi).empty();
  1852. mergeLiElements(editor.dom, fromLi, toLi);
  1853. editor.selection.setCursorLocation(toLi, 0);
  1854. };
  1855. var mergeForward = function(editor, rng, fromLi, toLi) {
  1856. var dom = editor.dom;
  1857. if (dom.isEmpty(toLi)) {
  1858. mergeIntoEmptyLi(editor, fromLi, toLi);
  1859. } else {
  1860. var bookmark = createBookmark(rng);
  1861. mergeLiElements(dom, fromLi, toLi);
  1862. editor.selection.setRng(resolveBookmark(bookmark));
  1863. }
  1864. };
  1865. var mergeBackward = function(editor, rng, fromLi, toLi) {
  1866. var bookmark = createBookmark(rng);
  1867. mergeLiElements(editor.dom, fromLi, toLi);
  1868. var resolvedBookmark = resolveBookmark(bookmark);
  1869. editor.selection.setRng(resolvedBookmark);
  1870. };
  1871. var backspaceDeleteFromListToListCaret = function(editor, isForward) {
  1872. var dom = editor.dom, selection = editor.selection;
  1873. var selectionStartElm = selection.getStart();
  1874. var root = getClosestListRootElm(editor, selectionStartElm);
  1875. var li = dom.getParent(selection.getStart(), "LI", root);
  1876. if (li) {
  1877. var ul = li.parentNode;
  1878. if (ul === editor.getBody() && isEmpty(dom, ul)) {
  1879. return true;
  1880. }
  1881. var rng_1 = normalizeRange(selection.getRng());
  1882. var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng_1, isForward, root), "LI", root);
  1883. if (otherLi_1 && otherLi_1 !== li) {
  1884. editor.undoManager.transact(function() {
  1885. if (isForward) {
  1886. mergeForward(editor, rng_1, otherLi_1, li);
  1887. } else {
  1888. if (isFirstChild(li)) {
  1889. outdentListSelection(editor);
  1890. } else {
  1891. mergeBackward(editor, rng_1, li, otherLi_1);
  1892. }
  1893. }
  1894. });
  1895. return true;
  1896. } else if (!otherLi_1) {
  1897. if (!isForward && rng_1.startOffset === 0 && rng_1.endOffset === 0) {
  1898. editor.undoManager.transact(function() {
  1899. flattenListSelection(editor);
  1900. });
  1901. return true;
  1902. }
  1903. }
  1904. }
  1905. return false;
  1906. };
  1907. var removeBlock = function(dom, block, root) {
  1908. var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
  1909. dom.remove(block);
  1910. if (parentBlock && dom.isEmpty(parentBlock)) {
  1911. dom.remove(parentBlock);
  1912. }
  1913. };
  1914. var backspaceDeleteIntoListCaret = function(editor, isForward) {
  1915. var dom = editor.dom;
  1916. var selectionStartElm = editor.selection.getStart();
  1917. var root = getClosestListRootElm(editor, selectionStartElm);
  1918. var block = dom.getParent(selectionStartElm, dom.isBlock, root);
  1919. if (block && dom.isEmpty(block)) {
  1920. var rng = normalizeRange(editor.selection.getRng());
  1921. var otherLi_2 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), "LI", root);
  1922. if (otherLi_2) {
  1923. editor.undoManager.transact(function() {
  1924. removeBlock(dom, block, root);
  1925. mergeWithAdjacentLists(dom, otherLi_2.parentNode);
  1926. editor.selection.select(otherLi_2, true);
  1927. editor.selection.collapse(isForward);
  1928. });
  1929. return true;
  1930. }
  1931. }
  1932. return false;
  1933. };
  1934. var backspaceDeleteCaret = function(editor, isForward) {
  1935. return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
  1936. };
  1937. var backspaceDeleteRange = function(editor) {
  1938. var selectionStartElm = editor.selection.getStart();
  1939. var root = getClosestListRootElm(editor, selectionStartElm);
  1940. var startListParent = editor.dom.getParent(selectionStartElm, "LI,DT,DD", root);
  1941. if (startListParent || getSelectedListItems(editor).length > 0) {
  1942. editor.undoManager.transact(function() {
  1943. editor.execCommand("Delete");
  1944. normalizeLists(editor.dom, editor.getBody());
  1945. });
  1946. return true;
  1947. }
  1948. return false;
  1949. };
  1950. var backspaceDelete = function(editor, isForward) {
  1951. return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
  1952. };
  1953. var setup$1 = function(editor) {
  1954. editor.on("keydown", function(e) {
  1955. if (e.keyCode === global$4.BACKSPACE) {
  1956. if (backspaceDelete(editor, false)) {
  1957. e.preventDefault();
  1958. }
  1959. } else if (e.keyCode === global$4.DELETE) {
  1960. if (backspaceDelete(editor, true)) {
  1961. e.preventDefault();
  1962. }
  1963. }
  1964. });
  1965. };
  1966. var get = function(editor) {
  1967. return {
  1968. backspaceDelete: function(isForward) {
  1969. backspaceDelete(editor, isForward);
  1970. }
  1971. };
  1972. };
  1973. var updateList = function(editor, update) {
  1974. var parentList = getParentList(editor);
  1975. editor.undoManager.transact(function() {
  1976. if (isObject(update.styles)) {
  1977. editor.dom.setStyles(parentList, update.styles);
  1978. }
  1979. if (isObject(update.attrs)) {
  1980. each(update.attrs, function(v, k) {
  1981. return editor.dom.setAttrib(parentList, k, v);
  1982. });
  1983. }
  1984. });
  1985. };
  1986. var parseAlphabeticBase26 = function(str) {
  1987. var chars = reverse(trim(str).split(""));
  1988. var values = map(chars, function(char, i) {
  1989. var charValue = char.toUpperCase().charCodeAt(0) - "A".charCodeAt(0) + 1;
  1990. return Math.pow(26, i) * charValue;
  1991. });
  1992. return foldl(values, function(sum, v) {
  1993. return sum + v;
  1994. }, 0);
  1995. };
  1996. var composeAlphabeticBase26 = function(value) {
  1997. value--;
  1998. if (value < 0) {
  1999. return "";
  2000. } else {
  2001. var remainder = value % 26;
  2002. var quotient = Math.floor(value / 26);
  2003. var rest = composeAlphabeticBase26(quotient);
  2004. var char = String.fromCharCode("A".charCodeAt(0) + remainder);
  2005. return rest + char;
  2006. }
  2007. };
  2008. var isUppercase = function(str) {
  2009. return /^[A-Z]+$/.test(str);
  2010. };
  2011. var isLowercase = function(str) {
  2012. return /^[a-z]+$/.test(str);
  2013. };
  2014. var isNumeric = function(str) {
  2015. return /^[0-9]+$/.test(str);
  2016. };
  2017. var deduceListType = function(start) {
  2018. if (isNumeric(start)) {
  2019. return 2;
  2020. } else if (isUppercase(start)) {
  2021. return 0;
  2022. } else if (isLowercase(start)) {
  2023. return 1;
  2024. } else if (isEmpty$1(start)) {
  2025. return 3;
  2026. } else {
  2027. return 4;
  2028. }
  2029. };
  2030. var parseStartValue = function(start) {
  2031. switch (deduceListType(start)) {
  2032. case 2:
  2033. return Optional.some({
  2034. listStyleType: Optional.none(),
  2035. start
  2036. });
  2037. case 0:
  2038. return Optional.some({
  2039. listStyleType: Optional.some("upper-alpha"),
  2040. start: parseAlphabeticBase26(start).toString()
  2041. });
  2042. case 1:
  2043. return Optional.some({
  2044. listStyleType: Optional.some("lower-alpha"),
  2045. start: parseAlphabeticBase26(start).toString()
  2046. });
  2047. case 3:
  2048. return Optional.some({
  2049. listStyleType: Optional.none(),
  2050. start: ""
  2051. });
  2052. case 4:
  2053. return Optional.none();
  2054. }
  2055. };
  2056. var parseDetail = function(detail) {
  2057. var start = parseInt(detail.start, 10);
  2058. if (is(detail.listStyleType, "upper-alpha")) {
  2059. return composeAlphabeticBase26(start);
  2060. } else if (is(detail.listStyleType, "lower-alpha")) {
  2061. return composeAlphabeticBase26(start).toLowerCase();
  2062. } else {
  2063. return detail.start;
  2064. }
  2065. };
  2066. var open = function(editor) {
  2067. var currentList = getParentList(editor);
  2068. if (!isOlNode(currentList)) {
  2069. return;
  2070. }
  2071. editor.windowManager.open({
  2072. title: "List Properties",
  2073. body: {
  2074. type: "panel",
  2075. items: [{
  2076. type: "input",
  2077. name: "start",
  2078. label: "Start list at number",
  2079. inputMode: "numeric"
  2080. }]
  2081. },
  2082. initialData: {
  2083. start: parseDetail({
  2084. start: editor.dom.getAttrib(currentList, "start", "1"),
  2085. listStyleType: Optional.some(editor.dom.getStyle(currentList, "list-style-type"))
  2086. })
  2087. },
  2088. buttons: [
  2089. {
  2090. type: "cancel",
  2091. name: "cancel",
  2092. text: "Cancel"
  2093. },
  2094. {
  2095. type: "submit",
  2096. name: "save",
  2097. text: "Save",
  2098. primary: true
  2099. }
  2100. ],
  2101. onSubmit: function(api) {
  2102. var data = api.getData();
  2103. parseStartValue(data.start).each(function(detail) {
  2104. editor.execCommand("mceListUpdate", false, {
  2105. attrs: { start: detail.start === "1" ? "" : detail.start },
  2106. styles: { "list-style-type": detail.listStyleType.getOr("") }
  2107. });
  2108. });
  2109. api.close();
  2110. }
  2111. });
  2112. };
  2113. var queryListCommandState = function(editor, listName) {
  2114. return function() {
  2115. var parentList = getParentList(editor);
  2116. return parentList && parentList.nodeName === listName;
  2117. };
  2118. };
  2119. var registerDialog = function(editor) {
  2120. editor.addCommand("mceListProps", function() {
  2121. open(editor);
  2122. });
  2123. };
  2124. var register$2 = function(editor) {
  2125. editor.on("BeforeExecCommand", function(e) {
  2126. var cmd = e.command.toLowerCase();
  2127. if (cmd === "indent") {
  2128. indentListSelection(editor);
  2129. } else if (cmd === "outdent") {
  2130. outdentListSelection(editor);
  2131. }
  2132. });
  2133. editor.addCommand("InsertUnorderedList", function(ui, detail) {
  2134. toggleList(editor, "UL", detail);
  2135. });
  2136. editor.addCommand("InsertOrderedList", function(ui, detail) {
  2137. toggleList(editor, "OL", detail);
  2138. });
  2139. editor.addCommand("InsertDefinitionList", function(ui, detail) {
  2140. toggleList(editor, "DL", detail);
  2141. });
  2142. editor.addCommand("RemoveList", function() {
  2143. flattenListSelection(editor);
  2144. });
  2145. registerDialog(editor);
  2146. editor.addCommand("mceListUpdate", function(ui, detail) {
  2147. if (isObject(detail)) {
  2148. updateList(editor, detail);
  2149. }
  2150. });
  2151. editor.addQueryStateHandler("InsertUnorderedList", queryListCommandState(editor, "UL"));
  2152. editor.addQueryStateHandler("InsertOrderedList", queryListCommandState(editor, "OL"));
  2153. editor.addQueryStateHandler("InsertDefinitionList", queryListCommandState(editor, "DL"));
  2154. };
  2155. var setupTabKey = function(editor) {
  2156. editor.on("keydown", function(e) {
  2157. if (e.keyCode !== global$4.TAB || global$4.metaKeyPressed(e)) {
  2158. return;
  2159. }
  2160. editor.undoManager.transact(function() {
  2161. if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
  2162. e.preventDefault();
  2163. }
  2164. });
  2165. });
  2166. };
  2167. var setup = function(editor) {
  2168. if (shouldIndentOnTab(editor)) {
  2169. setupTabKey(editor);
  2170. }
  2171. setup$1(editor);
  2172. };
  2173. var register$1 = function(editor) {
  2174. var exec = function(command) {
  2175. return function() {
  2176. return editor.execCommand(command);
  2177. };
  2178. };
  2179. if (!editor.hasPlugin("advlist")) {
  2180. editor.ui.registry.addToggleButton("numlist", {
  2181. icon: "ordered-list",
  2182. active: false,
  2183. tooltip: "Numbered list",
  2184. onAction: exec("InsertOrderedList"),
  2185. onSetup: function(api) {
  2186. return listState(editor, "OL", api.setActive);
  2187. }
  2188. });
  2189. editor.ui.registry.addToggleButton("bullist", {
  2190. icon: "unordered-list",
  2191. active: false,
  2192. tooltip: "Bullet list",
  2193. onAction: exec("InsertUnorderedList"),
  2194. onSetup: function(api) {
  2195. return listState(editor, "UL", api.setActive);
  2196. }
  2197. });
  2198. }
  2199. };
  2200. var register = function(editor) {
  2201. var listProperties = {
  2202. text: "List properties...",
  2203. icon: "ordered-list",
  2204. onAction: function() {
  2205. return editor.execCommand("mceListProps");
  2206. },
  2207. onSetup: function(api) {
  2208. return listState(editor, "OL", function(active) {
  2209. return api.setDisabled(!active);
  2210. });
  2211. }
  2212. };
  2213. editor.ui.registry.addMenuItem("listprops", listProperties);
  2214. editor.ui.registry.addContextMenu("lists", {
  2215. update: function(node) {
  2216. var parentList = getParentList(editor, node);
  2217. return isOlNode(parentList) ? ["listprops"] : [];
  2218. }
  2219. });
  2220. };
  2221. function Plugin() {
  2222. global$7.add("lists", function(editor) {
  2223. if (editor.hasPlugin("rtc", true) === false) {
  2224. setup(editor);
  2225. register$2(editor);
  2226. } else {
  2227. registerDialog(editor);
  2228. }
  2229. register$1(editor);
  2230. register(editor);
  2231. return get(editor);
  2232. });
  2233. }
  2234. Plugin();
  2235. })();
  2236. }
  2237. });
  2238. // node_modules/.pnpm/tinymce@5.10.7/node_modules/tinymce/plugins/lists/index.js
  2239. require_plugin();
  2240. //# sourceMappingURL=tinymce_plugins_lists.js.map