tinymce_plugins_lists.js 77 KB

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