plugin.js 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820
  1. /**
  2. * TinyMCE version 6.1.0 (2022-06-29)
  3. */
  4. (function () {
  5. 'use strict';
  6. var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
  7. const hasProto = (v, constructor, predicate) => {
  8. var _a;
  9. if (predicate(v, constructor.prototype)) {
  10. return true;
  11. } else {
  12. return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
  13. }
  14. };
  15. const typeOf = x => {
  16. const t = typeof x;
  17. if (x === null) {
  18. return 'null';
  19. } else if (t === 'object' && Array.isArray(x)) {
  20. return 'array';
  21. } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
  22. return 'string';
  23. } else {
  24. return t;
  25. }
  26. };
  27. const isType$1 = type => value => typeOf(value) === type;
  28. const isSimpleType = type => value => typeof value === type;
  29. const isString = isType$1('string');
  30. const isObject = isType$1('object');
  31. const isArray = isType$1('array');
  32. const isBoolean = isSimpleType('boolean');
  33. const isNullable = a => a === null || a === undefined;
  34. const isNonNullable = a => !isNullable(a);
  35. const isFunction = isSimpleType('function');
  36. const isNumber = isSimpleType('number');
  37. const noop = () => {
  38. };
  39. const constant = value => {
  40. return () => {
  41. return value;
  42. };
  43. };
  44. const tripleEquals = (a, b) => {
  45. return a === b;
  46. };
  47. const not = f => t => !f(t);
  48. const never = constant(false);
  49. class Optional {
  50. constructor(tag, value) {
  51. this.tag = tag;
  52. this.value = value;
  53. }
  54. static some(value) {
  55. return new Optional(true, value);
  56. }
  57. static none() {
  58. return Optional.singletonNone;
  59. }
  60. fold(onNone, onSome) {
  61. if (this.tag) {
  62. return onSome(this.value);
  63. } else {
  64. return onNone();
  65. }
  66. }
  67. isSome() {
  68. return this.tag;
  69. }
  70. isNone() {
  71. return !this.tag;
  72. }
  73. map(mapper) {
  74. if (this.tag) {
  75. return Optional.some(mapper(this.value));
  76. } else {
  77. return Optional.none();
  78. }
  79. }
  80. bind(binder) {
  81. if (this.tag) {
  82. return binder(this.value);
  83. } else {
  84. return Optional.none();
  85. }
  86. }
  87. exists(predicate) {
  88. return this.tag && predicate(this.value);
  89. }
  90. forall(predicate) {
  91. return !this.tag || predicate(this.value);
  92. }
  93. filter(predicate) {
  94. if (!this.tag || predicate(this.value)) {
  95. return this;
  96. } else {
  97. return Optional.none();
  98. }
  99. }
  100. getOr(replacement) {
  101. return this.tag ? this.value : replacement;
  102. }
  103. or(replacement) {
  104. return this.tag ? this : replacement;
  105. }
  106. getOrThunk(thunk) {
  107. return this.tag ? this.value : thunk();
  108. }
  109. orThunk(thunk) {
  110. return this.tag ? this : thunk();
  111. }
  112. getOrDie(message) {
  113. if (!this.tag) {
  114. throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
  115. } else {
  116. return this.value;
  117. }
  118. }
  119. static from(value) {
  120. return isNonNullable(value) ? Optional.some(value) : Optional.none();
  121. }
  122. getOrNull() {
  123. return this.tag ? this.value : null;
  124. }
  125. getOrUndefined() {
  126. return this.value;
  127. }
  128. each(worker) {
  129. if (this.tag) {
  130. worker(this.value);
  131. }
  132. }
  133. toArray() {
  134. return this.tag ? [this.value] : [];
  135. }
  136. toString() {
  137. return this.tag ? `some(${ this.value })` : 'none()';
  138. }
  139. }
  140. Optional.singletonNone = new Optional(false);
  141. const nativeSlice = Array.prototype.slice;
  142. const nativeIndexOf = Array.prototype.indexOf;
  143. const nativePush = Array.prototype.push;
  144. const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
  145. const contains$1 = (xs, x) => rawIndexOf(xs, x) > -1;
  146. const exists = (xs, pred) => {
  147. for (let i = 0, len = xs.length; i < len; i++) {
  148. const x = xs[i];
  149. if (pred(x, i)) {
  150. return true;
  151. }
  152. }
  153. return false;
  154. };
  155. const map = (xs, f) => {
  156. const len = xs.length;
  157. const r = new Array(len);
  158. for (let i = 0; i < len; i++) {
  159. const x = xs[i];
  160. r[i] = f(x, i);
  161. }
  162. return r;
  163. };
  164. const each$1 = (xs, f) => {
  165. for (let i = 0, len = xs.length; i < len; i++) {
  166. const x = xs[i];
  167. f(x, i);
  168. }
  169. };
  170. const filter$1 = (xs, pred) => {
  171. const r = [];
  172. for (let i = 0, len = xs.length; i < len; i++) {
  173. const x = xs[i];
  174. if (pred(x, i)) {
  175. r.push(x);
  176. }
  177. }
  178. return r;
  179. };
  180. const groupBy = (xs, f) => {
  181. if (xs.length === 0) {
  182. return [];
  183. } else {
  184. let wasType = f(xs[0]);
  185. const r = [];
  186. let group = [];
  187. for (let i = 0, len = xs.length; i < len; i++) {
  188. const x = xs[i];
  189. const type = f(x);
  190. if (type !== wasType) {
  191. r.push(group);
  192. group = [];
  193. }
  194. wasType = type;
  195. group.push(x);
  196. }
  197. if (group.length !== 0) {
  198. r.push(group);
  199. }
  200. return r;
  201. }
  202. };
  203. const foldl = (xs, f, acc) => {
  204. each$1(xs, (x, i) => {
  205. acc = f(acc, x, i);
  206. });
  207. return acc;
  208. };
  209. const findUntil = (xs, pred, until) => {
  210. for (let i = 0, len = xs.length; i < len; i++) {
  211. const x = xs[i];
  212. if (pred(x, i)) {
  213. return Optional.some(x);
  214. } else if (until(x, i)) {
  215. break;
  216. }
  217. }
  218. return Optional.none();
  219. };
  220. const find = (xs, pred) => {
  221. return findUntil(xs, pred, never);
  222. };
  223. const flatten = xs => {
  224. const r = [];
  225. for (let i = 0, len = xs.length; i < len; ++i) {
  226. if (!isArray(xs[i])) {
  227. throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
  228. }
  229. nativePush.apply(r, xs[i]);
  230. }
  231. return r;
  232. };
  233. const bind = (xs, f) => flatten(map(xs, f));
  234. const reverse = xs => {
  235. const r = nativeSlice.call(xs, 0);
  236. r.reverse();
  237. return r;
  238. };
  239. const get$1 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
  240. const head = xs => get$1(xs, 0);
  241. const last = xs => get$1(xs, xs.length - 1);
  242. const unique = (xs, comparator) => {
  243. const r = [];
  244. const isDuplicated = isFunction(comparator) ? x => exists(r, i => comparator(i, x)) : x => contains$1(r, x);
  245. for (let i = 0, len = xs.length; i < len; i++) {
  246. const x = xs[i];
  247. if (!isDuplicated(x)) {
  248. r.push(x);
  249. }
  250. }
  251. return r;
  252. };
  253. const is$2 = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));
  254. const equals = (lhs, rhs, comparator = tripleEquals) => lift2(lhs, rhs, comparator).getOr(lhs.isNone() && rhs.isNone());
  255. const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
  256. const ELEMENT = 1;
  257. const fromHtml = (html, scope) => {
  258. const doc = scope || document;
  259. const div = doc.createElement('div');
  260. div.innerHTML = html;
  261. if (!div.hasChildNodes() || div.childNodes.length > 1) {
  262. const message = 'HTML does not have a single root node';
  263. console.error(message, html);
  264. throw new Error(message);
  265. }
  266. return fromDom(div.childNodes[0]);
  267. };
  268. const fromTag = (tag, scope) => {
  269. const doc = scope || document;
  270. const node = doc.createElement(tag);
  271. return fromDom(node);
  272. };
  273. const fromText = (text, scope) => {
  274. const doc = scope || document;
  275. const node = doc.createTextNode(text);
  276. return fromDom(node);
  277. };
  278. const fromDom = node => {
  279. if (node === null || node === undefined) {
  280. throw new Error('Node cannot be null or undefined');
  281. }
  282. return { dom: node };
  283. };
  284. const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
  285. const SugarElement = {
  286. fromHtml,
  287. fromTag,
  288. fromText,
  289. fromDom,
  290. fromPoint
  291. };
  292. const is$1 = (element, selector) => {
  293. const dom = element.dom;
  294. if (dom.nodeType !== ELEMENT) {
  295. return false;
  296. } else {
  297. const elem = dom;
  298. if (elem.matches !== undefined) {
  299. return elem.matches(selector);
  300. } else if (elem.msMatchesSelector !== undefined) {
  301. return elem.msMatchesSelector(selector);
  302. } else if (elem.webkitMatchesSelector !== undefined) {
  303. return elem.webkitMatchesSelector(selector);
  304. } else if (elem.mozMatchesSelector !== undefined) {
  305. return elem.mozMatchesSelector(selector);
  306. } else {
  307. throw new Error('Browser lacks native selectors');
  308. }
  309. }
  310. };
  311. const eq = (e1, e2) => e1.dom === e2.dom;
  312. const contains = (e1, e2) => {
  313. const d1 = e1.dom;
  314. const d2 = e2.dom;
  315. return d1 === d2 ? false : d1.contains(d2);
  316. };
  317. const is = is$1;
  318. var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
  319. if (is(scope, a)) {
  320. return Optional.some(scope);
  321. } else if (isFunction(isRoot) && isRoot(scope)) {
  322. return Optional.none();
  323. } else {
  324. return ancestor(scope, a, isRoot);
  325. }
  326. };
  327. typeof window !== 'undefined' ? window : Function('return this;')();
  328. const name = element => {
  329. const r = element.dom.nodeName;
  330. return r.toLowerCase();
  331. };
  332. const type = element => element.dom.nodeType;
  333. const isType = t => element => type(element) === t;
  334. const isElement = isType(ELEMENT);
  335. const isTag = tag => e => isElement(e) && name(e) === tag;
  336. const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
  337. const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
  338. const children = element => map(element.dom.childNodes, SugarElement.fromDom);
  339. const child = (element, index) => {
  340. const cs = element.dom.childNodes;
  341. return Optional.from(cs[index]).map(SugarElement.fromDom);
  342. };
  343. const firstChild = element => child(element, 0);
  344. const lastChild = element => child(element, element.dom.childNodes.length - 1);
  345. const ancestor = (scope, predicate, isRoot) => {
  346. let element = scope.dom;
  347. const stop = isFunction(isRoot) ? isRoot : never;
  348. while (element.parentNode) {
  349. element = element.parentNode;
  350. const el = SugarElement.fromDom(element);
  351. if (predicate(el)) {
  352. return Optional.some(el);
  353. } else if (stop(el)) {
  354. break;
  355. }
  356. }
  357. return Optional.none();
  358. };
  359. const closest = (scope, predicate, isRoot) => {
  360. const is = (s, test) => test(s);
  361. return ClosestOrAncestor(is, ancestor, scope, predicate, isRoot);
  362. };
  363. const before$1 = (marker, element) => {
  364. const parent$1 = parent(marker);
  365. parent$1.each(v => {
  366. v.dom.insertBefore(element.dom, marker.dom);
  367. });
  368. };
  369. const after = (marker, element) => {
  370. const sibling = nextSibling(marker);
  371. sibling.fold(() => {
  372. const parent$1 = parent(marker);
  373. parent$1.each(v => {
  374. append$1(v, element);
  375. });
  376. }, v => {
  377. before$1(v, element);
  378. });
  379. };
  380. const append$1 = (parent, element) => {
  381. parent.dom.appendChild(element.dom);
  382. };
  383. const before = (marker, elements) => {
  384. each$1(elements, x => {
  385. before$1(marker, x);
  386. });
  387. };
  388. const append = (parent, elements) => {
  389. each$1(elements, x => {
  390. append$1(parent, x);
  391. });
  392. };
  393. const empty = element => {
  394. element.dom.textContent = '';
  395. each$1(children(element), rogue => {
  396. remove(rogue);
  397. });
  398. };
  399. const remove = element => {
  400. const dom = element.dom;
  401. if (dom.parentNode !== null) {
  402. dom.parentNode.removeChild(dom);
  403. }
  404. };
  405. var global$5 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
  406. var global$4 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
  407. var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK');
  408. const keys = Object.keys;
  409. const each = (obj, f) => {
  410. const props = keys(obj);
  411. for (let k = 0, len = props.length; k < len; k++) {
  412. const i = props[k];
  413. const x = obj[i];
  414. f(x, i);
  415. }
  416. };
  417. const objAcc = r => (x, i) => {
  418. r[i] = x;
  419. };
  420. const internalFilter = (obj, pred, onTrue, onFalse) => {
  421. const r = {};
  422. each(obj, (x, i) => {
  423. (pred(x, i) ? onTrue : onFalse)(x, i);
  424. });
  425. return r;
  426. };
  427. const filter = (obj, pred) => {
  428. const t = {};
  429. internalFilter(obj, pred, objAcc(t), noop);
  430. return t;
  431. };
  432. const rawSet = (dom, key, value) => {
  433. if (isString(value) || isBoolean(value) || isNumber(value)) {
  434. dom.setAttribute(key, value + '');
  435. } else {
  436. console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
  437. throw new Error('Attribute value was not simple');
  438. }
  439. };
  440. const setAll = (element, attrs) => {
  441. const dom = element.dom;
  442. each(attrs, (v, k) => {
  443. rawSet(dom, k, v);
  444. });
  445. };
  446. const clone$1 = element => foldl(element.dom.attributes, (acc, attr) => {
  447. acc[attr.name] = attr.value;
  448. return acc;
  449. }, {});
  450. const clone = (original, isDeep) => SugarElement.fromDom(original.dom.cloneNode(isDeep));
  451. const deep = original => clone(original, true);
  452. const shallowAs = (original, tag) => {
  453. const nu = SugarElement.fromTag(tag);
  454. const attributes = clone$1(original);
  455. setAll(nu, attributes);
  456. return nu;
  457. };
  458. const mutate = (original, tag) => {
  459. const nu = shallowAs(original, tag);
  460. after(original, nu);
  461. const children$1 = children(original);
  462. append(nu, children$1);
  463. remove(original);
  464. return nu;
  465. };
  466. var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
  467. var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
  468. const matchNodeName = name => node => node && node.nodeName.toLowerCase() === name;
  469. const matchNodeNames = regex => node => node && regex.test(node.nodeName);
  470. const isTextNode = node => node && node.nodeType === 3;
  471. const isListNode = matchNodeNames(/^(OL|UL|DL)$/);
  472. const isOlUlNode = matchNodeNames(/^(OL|UL)$/);
  473. const isOlNode = matchNodeName('ol');
  474. const isListItemNode = matchNodeNames(/^(LI|DT|DD)$/);
  475. const isDlItemNode = matchNodeNames(/^(DT|DD)$/);
  476. const isTableCellNode = matchNodeNames(/^(TH|TD)$/);
  477. const isBr = matchNodeName('br');
  478. const isFirstChild = node => node.parentNode.firstChild === node;
  479. const isTextBlock = (editor, node) => node && !!editor.schema.getTextBlockElements()[node.nodeName];
  480. const isBlock = (node, blockElements) => node && node.nodeName in blockElements;
  481. const isBogusBr = (dom, node) => {
  482. if (!isBr(node)) {
  483. return false;
  484. }
  485. return dom.isBlock(node.nextSibling) && !isBr(node.previousSibling);
  486. };
  487. const isEmpty$1 = (dom, elm, keepBookmarks) => {
  488. const empty = dom.isEmpty(elm);
  489. if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) {
  490. return false;
  491. }
  492. return empty;
  493. };
  494. const isChildOfBody = (dom, elm) => dom.isChildOf(elm, dom.getRoot());
  495. const option = name => editor => editor.options.get(name);
  496. const register$3 = editor => {
  497. const registerOption = editor.options.register;
  498. registerOption('lists_indent_on_tab', {
  499. processor: 'boolean',
  500. default: true
  501. });
  502. };
  503. const shouldIndentOnTab = option('lists_indent_on_tab');
  504. const getForcedRootBlock = option('forced_root_block');
  505. const getForcedRootBlockAttrs = option('forced_root_block_attrs');
  506. const createTextBlock = (editor, contentNode) => {
  507. const dom = editor.dom;
  508. const blockElements = editor.schema.getBlockElements();
  509. const fragment = dom.createFragment();
  510. const blockName = getForcedRootBlock(editor);
  511. const blockAttrs = getForcedRootBlockAttrs(editor);
  512. let node, textBlock, hasContentNode;
  513. textBlock = dom.create(blockName, blockAttrs);
  514. if (!isBlock(contentNode.firstChild, blockElements)) {
  515. fragment.appendChild(textBlock);
  516. }
  517. while (node = contentNode.firstChild) {
  518. const nodeName = node.nodeName;
  519. if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
  520. hasContentNode = true;
  521. }
  522. if (isBlock(node, blockElements)) {
  523. fragment.appendChild(node);
  524. textBlock = null;
  525. } else {
  526. if (!textBlock) {
  527. textBlock = dom.create(blockName, blockAttrs);
  528. fragment.appendChild(textBlock);
  529. }
  530. textBlock.appendChild(node);
  531. }
  532. }
  533. if (!hasContentNode) {
  534. textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
  535. }
  536. return fragment;
  537. };
  538. const DOM$2 = global$2.DOM;
  539. const splitList = (editor, list, li) => {
  540. const removeAndKeepBookmarks = targetNode => {
  541. global$1.each(bookmarks, node => {
  542. targetNode.parentNode.insertBefore(node, li.parentNode);
  543. });
  544. DOM$2.remove(targetNode);
  545. };
  546. const bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', list);
  547. const newBlock = createTextBlock(editor, li);
  548. const tmpRng = DOM$2.createRng();
  549. tmpRng.setStartAfter(li);
  550. tmpRng.setEndAfter(list);
  551. const fragment = tmpRng.extractContents();
  552. for (let node = fragment.firstChild; node; node = node.firstChild) {
  553. if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
  554. DOM$2.remove(node);
  555. break;
  556. }
  557. }
  558. if (!editor.dom.isEmpty(fragment)) {
  559. DOM$2.insertAfter(fragment, list);
  560. }
  561. DOM$2.insertAfter(newBlock, list);
  562. if (isEmpty$1(editor.dom, li.parentNode)) {
  563. removeAndKeepBookmarks(li.parentNode);
  564. }
  565. DOM$2.remove(li);
  566. if (isEmpty$1(editor.dom, list)) {
  567. DOM$2.remove(list);
  568. }
  569. };
  570. const isDescriptionDetail = isTag('dd');
  571. const isDescriptionTerm = isTag('dt');
  572. const outdentDlItem = (editor, item) => {
  573. if (isDescriptionDetail(item)) {
  574. mutate(item, 'dt');
  575. } else if (isDescriptionTerm(item)) {
  576. parent(item).each(dl => splitList(editor, dl.dom, item.dom));
  577. }
  578. };
  579. const indentDlItem = item => {
  580. if (isDescriptionTerm(item)) {
  581. mutate(item, 'dd');
  582. }
  583. };
  584. const dlIndentation = (editor, indentation, dlItems) => {
  585. if (indentation === 'Indent') {
  586. each$1(dlItems, indentDlItem);
  587. } else {
  588. each$1(dlItems, item => outdentDlItem(editor, item));
  589. }
  590. };
  591. const getNormalizedPoint = (container, offset) => {
  592. if (isTextNode(container)) {
  593. return {
  594. container,
  595. offset
  596. };
  597. }
  598. const node = global$5.getNode(container, offset);
  599. if (isTextNode(node)) {
  600. return {
  601. container: node,
  602. offset: offset >= container.childNodes.length ? node.data.length : 0
  603. };
  604. } else if (node.previousSibling && isTextNode(node.previousSibling)) {
  605. return {
  606. container: node.previousSibling,
  607. offset: node.previousSibling.data.length
  608. };
  609. } else if (node.nextSibling && isTextNode(node.nextSibling)) {
  610. return {
  611. container: node.nextSibling,
  612. offset: 0
  613. };
  614. }
  615. return {
  616. container,
  617. offset
  618. };
  619. };
  620. const normalizeRange = rng => {
  621. const outRng = rng.cloneRange();
  622. const rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
  623. outRng.setStart(rangeStart.container, rangeStart.offset);
  624. const rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
  625. outRng.setEnd(rangeEnd.container, rangeEnd.offset);
  626. return outRng;
  627. };
  628. const listNames = [
  629. 'OL',
  630. 'UL',
  631. 'DL'
  632. ];
  633. const listSelector = listNames.join(',');
  634. const getParentList = (editor, node) => {
  635. const selectionStart = node || editor.selection.getStart(true);
  636. return editor.dom.getParent(selectionStart, listSelector, getClosestListHost(editor, selectionStart));
  637. };
  638. const isParentListSelected = (parentList, selectedBlocks) => parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
  639. const findSubLists = parentList => filter$1(parentList.querySelectorAll(listSelector), isListNode);
  640. const getSelectedSubLists = editor => {
  641. const parentList = getParentList(editor);
  642. const selectedBlocks = editor.selection.getSelectedBlocks();
  643. if (isParentListSelected(parentList, selectedBlocks)) {
  644. return findSubLists(parentList);
  645. } else {
  646. return filter$1(selectedBlocks, elm => {
  647. return isListNode(elm) && parentList !== elm;
  648. });
  649. }
  650. };
  651. const findParentListItemsNodes = (editor, elms) => {
  652. const listItemsElms = global$1.map(elms, elm => {
  653. const parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListHost(editor, elm));
  654. return parentLi ? parentLi : elm;
  655. });
  656. return unique(listItemsElms);
  657. };
  658. const getSelectedListItems = editor => {
  659. const selectedBlocks = editor.selection.getSelectedBlocks();
  660. return filter$1(findParentListItemsNodes(editor, selectedBlocks), isListItemNode);
  661. };
  662. const getSelectedDlItems = editor => filter$1(getSelectedListItems(editor), isDlItemNode);
  663. const getClosestEditingHost = (editor, elm) => {
  664. const parentTableCell = editor.dom.getParents(elm, 'TD,TH');
  665. return parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
  666. };
  667. const isListHost = (schema, node) => !isListNode(node) && !isListItemNode(node) && exists(listNames, listName => schema.isValidChild(node.nodeName, listName));
  668. const getClosestListHost = (editor, elm) => {
  669. const parentBlocks = editor.dom.getParents(elm, editor.dom.isBlock);
  670. const parentBlock = find(parentBlocks, elm => isListHost(editor.schema, elm));
  671. return parentBlock.getOr(editor.getBody());
  672. };
  673. const findLastParentListNode = (editor, elm) => {
  674. const parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListHost(editor, elm));
  675. return last(parentLists);
  676. };
  677. const getSelectedLists = editor => {
  678. const firstList = findLastParentListNode(editor, editor.selection.getStart());
  679. const subsequentLists = filter$1(editor.selection.getSelectedBlocks(), isOlUlNode);
  680. return firstList.toArray().concat(subsequentLists);
  681. };
  682. const getSelectedListRoots = editor => {
  683. const selectedLists = getSelectedLists(editor);
  684. return getUniqueListRoots(editor, selectedLists);
  685. };
  686. const getUniqueListRoots = (editor, lists) => {
  687. const listRoots = map(lists, list => findLastParentListNode(editor, list).getOr(list));
  688. return unique(listRoots);
  689. };
  690. const fromElements = (elements, scope) => {
  691. const doc = scope || document;
  692. const fragment = doc.createDocumentFragment();
  693. each$1(elements, element => {
  694. fragment.appendChild(element.dom);
  695. });
  696. return SugarElement.fromDom(fragment);
  697. };
  698. const fireListEvent = (editor, action, element) => editor.dispatch('ListMutation', {
  699. action,
  700. element
  701. });
  702. const blank = r => s => s.replace(r, '');
  703. const trim = blank(/^\s+|\s+$/g);
  704. const isNotEmpty = s => s.length > 0;
  705. const isEmpty = s => !isNotEmpty(s);
  706. const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
  707. const internalSet = (dom, property, value) => {
  708. if (!isString(value)) {
  709. console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
  710. throw new Error('CSS value must be a string: ' + value);
  711. }
  712. if (isSupported(dom)) {
  713. dom.style.setProperty(property, value);
  714. }
  715. };
  716. const set = (element, property, value) => {
  717. const dom = element.dom;
  718. internalSet(dom, property, value);
  719. };
  720. const joinSegment = (parent, child) => {
  721. append$1(parent.item, child.list);
  722. };
  723. const joinSegments = segments => {
  724. for (let i = 1; i < segments.length; i++) {
  725. joinSegment(segments[i - 1], segments[i]);
  726. }
  727. };
  728. const appendSegments = (head$1, tail) => {
  729. lift2(last(head$1), head(tail), joinSegment);
  730. };
  731. const createSegment = (scope, listType) => {
  732. const segment = {
  733. list: SugarElement.fromTag(listType, scope),
  734. item: SugarElement.fromTag('li', scope)
  735. };
  736. append$1(segment.list, segment.item);
  737. return segment;
  738. };
  739. const createSegments = (scope, entry, size) => {
  740. const segments = [];
  741. for (let i = 0; i < size; i++) {
  742. segments.push(createSegment(scope, entry.listType));
  743. }
  744. return segments;
  745. };
  746. const populateSegments = (segments, entry) => {
  747. for (let i = 0; i < segments.length - 1; i++) {
  748. set(segments[i].item, 'list-style-type', 'none');
  749. }
  750. last(segments).each(segment => {
  751. setAll(segment.list, entry.listAttributes);
  752. setAll(segment.item, entry.itemAttributes);
  753. append(segment.item, entry.content);
  754. });
  755. };
  756. const normalizeSegment = (segment, entry) => {
  757. if (name(segment.list) !== entry.listType) {
  758. segment.list = mutate(segment.list, entry.listType);
  759. }
  760. setAll(segment.list, entry.listAttributes);
  761. };
  762. const createItem = (scope, attr, content) => {
  763. const item = SugarElement.fromTag('li', scope);
  764. setAll(item, attr);
  765. append(item, content);
  766. return item;
  767. };
  768. const appendItem = (segment, item) => {
  769. append$1(segment.list, item);
  770. segment.item = item;
  771. };
  772. const writeShallow = (scope, cast, entry) => {
  773. const newCast = cast.slice(0, entry.depth);
  774. last(newCast).each(segment => {
  775. const item = createItem(scope, entry.itemAttributes, entry.content);
  776. appendItem(segment, item);
  777. normalizeSegment(segment, entry);
  778. });
  779. return newCast;
  780. };
  781. const writeDeep = (scope, cast, entry) => {
  782. const segments = createSegments(scope, entry, entry.depth - cast.length);
  783. joinSegments(segments);
  784. populateSegments(segments, entry);
  785. appendSegments(cast, segments);
  786. return cast.concat(segments);
  787. };
  788. const composeList = (scope, entries) => {
  789. const cast = foldl(entries, (cast, entry) => {
  790. return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
  791. }, []);
  792. return head(cast).map(segment => segment.list);
  793. };
  794. const isList = el => is(el, 'OL,UL');
  795. const hasFirstChildList = el => firstChild(el).exists(isList);
  796. const hasLastChildList = el => lastChild(el).exists(isList);
  797. const isIndented = entry => entry.depth > 0;
  798. const isSelected = entry => entry.isSelected;
  799. const cloneItemContent = li => {
  800. const children$1 = children(li);
  801. const content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
  802. return map(content, deep);
  803. };
  804. const createEntry = (li, depth, isSelected) => parent(li).filter(isElement).map(list => ({
  805. depth,
  806. dirty: false,
  807. isSelected,
  808. content: cloneItemContent(li),
  809. itemAttributes: clone$1(li),
  810. listAttributes: clone$1(list),
  811. listType: name(list)
  812. }));
  813. const indentEntry = (indentation, entry) => {
  814. switch (indentation) {
  815. case 'Indent':
  816. entry.depth++;
  817. break;
  818. case 'Outdent':
  819. entry.depth--;
  820. break;
  821. case 'Flatten':
  822. entry.depth = 0;
  823. }
  824. entry.dirty = true;
  825. };
  826. const cloneListProperties = (target, source) => {
  827. target.listType = source.listType;
  828. target.listAttributes = { ...source.listAttributes };
  829. };
  830. const cleanListProperties = entry => {
  831. entry.listAttributes = filter(entry.listAttributes, (_value, key) => key !== 'start');
  832. };
  833. const closestSiblingEntry = (entries, start) => {
  834. const depth = entries[start].depth;
  835. const matches = entry => entry.depth === depth && !entry.dirty;
  836. const until = entry => entry.depth < depth;
  837. return findUntil(reverse(entries.slice(0, start)), matches, until).orThunk(() => findUntil(entries.slice(start + 1), matches, until));
  838. };
  839. const normalizeEntries = entries => {
  840. each$1(entries, (entry, i) => {
  841. closestSiblingEntry(entries, i).fold(() => {
  842. if (entry.dirty) {
  843. cleanListProperties(entry);
  844. }
  845. }, matchingEntry => cloneListProperties(entry, matchingEntry));
  846. });
  847. return entries;
  848. };
  849. const Cell = initial => {
  850. let value = initial;
  851. const get = () => {
  852. return value;
  853. };
  854. const set = v => {
  855. value = v;
  856. };
  857. return {
  858. get,
  859. set
  860. };
  861. };
  862. const parseItem = (depth, itemSelection, selectionState, item) => firstChild(item).filter(isList).fold(() => {
  863. itemSelection.each(selection => {
  864. if (eq(selection.start, item)) {
  865. selectionState.set(true);
  866. }
  867. });
  868. const currentItemEntry = createEntry(item, depth, selectionState.get());
  869. itemSelection.each(selection => {
  870. if (eq(selection.end, item)) {
  871. selectionState.set(false);
  872. }
  873. });
  874. const childListEntries = lastChild(item).filter(isList).map(list => parseList(depth, itemSelection, selectionState, list)).getOr([]);
  875. return currentItemEntry.toArray().concat(childListEntries);
  876. }, list => parseList(depth, itemSelection, selectionState, list));
  877. const parseList = (depth, itemSelection, selectionState, list) => bind(children(list), element => {
  878. const parser = isList(element) ? parseList : parseItem;
  879. const newDepth = depth + 1;
  880. return parser(newDepth, itemSelection, selectionState, element);
  881. });
  882. const parseLists = (lists, itemSelection) => {
  883. const selectionState = Cell(false);
  884. const initialDepth = 0;
  885. return map(lists, list => ({
  886. sourceList: list,
  887. entries: parseList(initialDepth, itemSelection, selectionState, list)
  888. }));
  889. };
  890. const outdentedComposer = (editor, entries) => {
  891. const normalizedEntries = normalizeEntries(entries);
  892. return map(normalizedEntries, entry => {
  893. const content = fromElements(entry.content);
  894. return SugarElement.fromDom(createTextBlock(editor, content.dom));
  895. });
  896. };
  897. const indentedComposer = (editor, entries) => {
  898. const normalizedEntries = normalizeEntries(entries);
  899. return composeList(editor.contentDocument, normalizedEntries).toArray();
  900. };
  901. const composeEntries = (editor, entries) => bind(groupBy(entries, isIndented), entries => {
  902. const groupIsIndented = head(entries).exists(isIndented);
  903. return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
  904. });
  905. const indentSelectedEntries = (entries, indentation) => {
  906. each$1(filter$1(entries, isSelected), entry => indentEntry(indentation, entry));
  907. };
  908. const getItemSelection = editor => {
  909. const selectedListItems = map(getSelectedListItems(editor), SugarElement.fromDom);
  910. return lift2(find(selectedListItems, not(hasFirstChildList)), find(reverse(selectedListItems), not(hasFirstChildList)), (start, end) => ({
  911. start,
  912. end
  913. }));
  914. };
  915. const listIndentation = (editor, lists, indentation) => {
  916. const entrySets = parseLists(lists, getItemSelection(editor));
  917. each$1(entrySets, entrySet => {
  918. indentSelectedEntries(entrySet.entries, indentation);
  919. const composedLists = composeEntries(editor, entrySet.entries);
  920. each$1(composedLists, composedList => {
  921. fireListEvent(editor, indentation === 'Indent' ? 'IndentList' : 'OutdentList', composedList.dom);
  922. });
  923. before(entrySet.sourceList, composedLists);
  924. remove(entrySet.sourceList);
  925. });
  926. };
  927. const selectionIndentation = (editor, indentation) => {
  928. const lists = map(getSelectedListRoots(editor), SugarElement.fromDom);
  929. const dlItems = map(getSelectedDlItems(editor), SugarElement.fromDom);
  930. let isHandled = false;
  931. if (lists.length || dlItems.length) {
  932. const bookmark = editor.selection.getBookmark();
  933. listIndentation(editor, lists, indentation);
  934. dlIndentation(editor, indentation, dlItems);
  935. editor.selection.moveToBookmark(bookmark);
  936. editor.selection.setRng(normalizeRange(editor.selection.getRng()));
  937. editor.nodeChanged();
  938. isHandled = true;
  939. }
  940. return isHandled;
  941. };
  942. const indentListSelection = editor => selectionIndentation(editor, 'Indent');
  943. const outdentListSelection = editor => selectionIndentation(editor, 'Outdent');
  944. const flattenListSelection = editor => selectionIndentation(editor, 'Flatten');
  945. var global = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager');
  946. const DOM$1 = global$2.DOM;
  947. const createBookmark = rng => {
  948. const bookmark = {};
  949. const setupEndPoint = start => {
  950. let container = rng[start ? 'startContainer' : 'endContainer'];
  951. let offset = rng[start ? 'startOffset' : 'endOffset'];
  952. if (container.nodeType === 1) {
  953. const offsetNode = DOM$1.create('span', { 'data-mce-type': 'bookmark' });
  954. if (container.hasChildNodes()) {
  955. offset = Math.min(offset, container.childNodes.length - 1);
  956. if (start) {
  957. container.insertBefore(offsetNode, container.childNodes[offset]);
  958. } else {
  959. DOM$1.insertAfter(offsetNode, container.childNodes[offset]);
  960. }
  961. } else {
  962. container.appendChild(offsetNode);
  963. }
  964. container = offsetNode;
  965. offset = 0;
  966. }
  967. bookmark[start ? 'startContainer' : 'endContainer'] = container;
  968. bookmark[start ? 'startOffset' : 'endOffset'] = offset;
  969. };
  970. setupEndPoint(true);
  971. if (!rng.collapsed) {
  972. setupEndPoint();
  973. }
  974. return bookmark;
  975. };
  976. const resolveBookmark = bookmark => {
  977. const restoreEndPoint = start => {
  978. let node;
  979. const nodeIndex = container => {
  980. let node = container.parentNode.firstChild, idx = 0;
  981. while (node) {
  982. if (node === container) {
  983. return idx;
  984. }
  985. if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
  986. idx++;
  987. }
  988. node = node.nextSibling;
  989. }
  990. return -1;
  991. };
  992. let container = node = bookmark[start ? 'startContainer' : 'endContainer'];
  993. let offset = bookmark[start ? 'startOffset' : 'endOffset'];
  994. if (!container) {
  995. return;
  996. }
  997. if (container.nodeType === 1) {
  998. offset = nodeIndex(container);
  999. container = container.parentNode;
  1000. DOM$1.remove(node);
  1001. if (!container.hasChildNodes() && DOM$1.isBlock(container)) {
  1002. container.appendChild(DOM$1.create('br'));
  1003. }
  1004. }
  1005. bookmark[start ? 'startContainer' : 'endContainer'] = container;
  1006. bookmark[start ? 'startOffset' : 'endOffset'] = offset;
  1007. };
  1008. restoreEndPoint(true);
  1009. restoreEndPoint();
  1010. const rng = DOM$1.createRng();
  1011. rng.setStart(bookmark.startContainer, bookmark.startOffset);
  1012. if (bookmark.endContainer) {
  1013. rng.setEnd(bookmark.endContainer, bookmark.endOffset);
  1014. }
  1015. return normalizeRange(rng);
  1016. };
  1017. const listToggleActionFromListName = listName => {
  1018. switch (listName) {
  1019. case 'UL':
  1020. return 'ToggleUlList';
  1021. case 'OL':
  1022. return 'ToggleOlList';
  1023. case 'DL':
  1024. return 'ToggleDLList';
  1025. }
  1026. };
  1027. const isCustomList = list => /\btox\-/.test(list.className);
  1028. const listState = (editor, listName, activate) => {
  1029. const nodeChangeHandler = e => {
  1030. const inList = findUntil(e.parents, isListNode, isTableCellNode).filter(list => list.nodeName === listName && !isCustomList(list)).isSome();
  1031. activate(inList);
  1032. };
  1033. const parents = editor.dom.getParents(editor.selection.getNode());
  1034. nodeChangeHandler({ parents });
  1035. editor.on('NodeChange', nodeChangeHandler);
  1036. return () => editor.off('NodeChange', nodeChangeHandler);
  1037. };
  1038. const updateListStyle = (dom, el, detail) => {
  1039. const type = detail['list-style-type'] ? detail['list-style-type'] : null;
  1040. dom.setStyle(el, 'list-style-type', type);
  1041. };
  1042. const setAttribs = (elm, attrs) => {
  1043. global$1.each(attrs, (value, key) => {
  1044. elm.setAttribute(key, value);
  1045. });
  1046. };
  1047. const updateListAttrs = (dom, el, detail) => {
  1048. setAttribs(el, detail['list-attributes']);
  1049. global$1.each(dom.select('li', el), li => {
  1050. setAttribs(li, detail['list-item-attributes']);
  1051. });
  1052. };
  1053. const updateListWithDetails = (dom, el, detail) => {
  1054. updateListStyle(dom, el, detail);
  1055. updateListAttrs(dom, el, detail);
  1056. };
  1057. const removeStyles = (dom, element, styles) => {
  1058. global$1.each(styles, style => dom.setStyle(element, style, ''));
  1059. };
  1060. const getEndPointNode = (editor, rng, start, root) => {
  1061. let container = rng[start ? 'startContainer' : 'endContainer'];
  1062. const offset = rng[start ? 'startOffset' : 'endOffset'];
  1063. if (container.nodeType === 1) {
  1064. container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
  1065. }
  1066. if (!start && isBr(container.nextSibling)) {
  1067. container = container.nextSibling;
  1068. }
  1069. while (container.parentNode !== root) {
  1070. if (isTextBlock(editor, container)) {
  1071. return container;
  1072. }
  1073. if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
  1074. return container;
  1075. }
  1076. container = container.parentNode;
  1077. }
  1078. return container;
  1079. };
  1080. const getSelectedTextBlocks = (editor, rng, root) => {
  1081. const textBlocks = [];
  1082. const dom = editor.dom;
  1083. const startNode = getEndPointNode(editor, rng, true, root);
  1084. const endNode = getEndPointNode(editor, rng, false, root);
  1085. let block;
  1086. const siblings = [];
  1087. for (let node = startNode; node; node = node.nextSibling) {
  1088. siblings.push(node);
  1089. if (node === endNode) {
  1090. break;
  1091. }
  1092. }
  1093. global$1.each(siblings, node => {
  1094. if (isTextBlock(editor, node)) {
  1095. textBlocks.push(node);
  1096. block = null;
  1097. return;
  1098. }
  1099. if (dom.isBlock(node) || isBr(node)) {
  1100. if (isBr(node)) {
  1101. dom.remove(node);
  1102. }
  1103. block = null;
  1104. return;
  1105. }
  1106. const nextSibling = node.nextSibling;
  1107. if (global.isBookmarkNode(node)) {
  1108. if (isListNode(nextSibling) || isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) {
  1109. block = null;
  1110. return;
  1111. }
  1112. }
  1113. if (!block) {
  1114. block = dom.create('p');
  1115. node.parentNode.insertBefore(block, node);
  1116. textBlocks.push(block);
  1117. }
  1118. block.appendChild(node);
  1119. });
  1120. return textBlocks;
  1121. };
  1122. const hasCompatibleStyle = (dom, sib, detail) => {
  1123. const sibStyle = dom.getStyle(sib, 'list-style-type');
  1124. let detailStyle = detail ? detail['list-style-type'] : '';
  1125. detailStyle = detailStyle === null ? '' : detailStyle;
  1126. return sibStyle === detailStyle;
  1127. };
  1128. const applyList = (editor, listName, detail) => {
  1129. const rng = editor.selection.getRng();
  1130. let listItemName = 'LI';
  1131. const root = getClosestListHost(editor, editor.selection.getStart(true));
  1132. const dom = editor.dom;
  1133. if (dom.getContentEditable(editor.selection.getNode()) === 'false') {
  1134. return;
  1135. }
  1136. listName = listName.toUpperCase();
  1137. if (listName === 'DL') {
  1138. listItemName = 'DT';
  1139. }
  1140. const bookmark = createBookmark(rng);
  1141. const selectedTextBlocks = getSelectedTextBlocks(editor, rng, root);
  1142. global$1.each(selectedTextBlocks, block => {
  1143. let listBlock;
  1144. const sibling = block.previousSibling;
  1145. const parent = block.parentNode;
  1146. if (!isListItemNode(parent)) {
  1147. if (sibling && isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
  1148. listBlock = sibling;
  1149. block = dom.rename(block, listItemName);
  1150. sibling.appendChild(block);
  1151. } else {
  1152. listBlock = dom.create(listName);
  1153. block.parentNode.insertBefore(listBlock, block);
  1154. listBlock.appendChild(block);
  1155. block = dom.rename(block, listItemName);
  1156. }
  1157. removeStyles(dom, block, [
  1158. 'margin',
  1159. 'margin-right',
  1160. 'margin-bottom',
  1161. 'margin-left',
  1162. 'margin-top',
  1163. 'padding',
  1164. 'padding-right',
  1165. 'padding-bottom',
  1166. 'padding-left',
  1167. 'padding-top'
  1168. ]);
  1169. updateListWithDetails(dom, listBlock, detail);
  1170. mergeWithAdjacentLists(editor.dom, listBlock);
  1171. }
  1172. });
  1173. editor.selection.setRng(resolveBookmark(bookmark));
  1174. };
  1175. const isValidLists = (list1, list2) => {
  1176. return list1 && list2 && isListNode(list1) && list1.nodeName === list2.nodeName;
  1177. };
  1178. const hasSameListStyle = (dom, list1, list2) => {
  1179. const targetStyle = dom.getStyle(list1, 'list-style-type', true);
  1180. const style = dom.getStyle(list2, 'list-style-type', true);
  1181. return targetStyle === style;
  1182. };
  1183. const hasSameClasses = (elm1, elm2) => {
  1184. return elm1.className === elm2.className;
  1185. };
  1186. const shouldMerge = (dom, list1, list2) => {
  1187. return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
  1188. };
  1189. const mergeWithAdjacentLists = (dom, listBlock) => {
  1190. let sibling, node;
  1191. sibling = listBlock.nextSibling;
  1192. if (shouldMerge(dom, listBlock, sibling)) {
  1193. while (node = sibling.firstChild) {
  1194. listBlock.appendChild(node);
  1195. }
  1196. dom.remove(sibling);
  1197. }
  1198. sibling = listBlock.previousSibling;
  1199. if (shouldMerge(dom, listBlock, sibling)) {
  1200. while (node = sibling.lastChild) {
  1201. listBlock.insertBefore(node, listBlock.firstChild);
  1202. }
  1203. dom.remove(sibling);
  1204. }
  1205. };
  1206. const updateList$1 = (editor, list, listName, detail) => {
  1207. if (list.nodeName !== listName) {
  1208. const newList = editor.dom.rename(list, listName);
  1209. updateListWithDetails(editor.dom, newList, detail);
  1210. fireListEvent(editor, listToggleActionFromListName(listName), newList);
  1211. } else {
  1212. updateListWithDetails(editor.dom, list, detail);
  1213. fireListEvent(editor, listToggleActionFromListName(listName), list);
  1214. }
  1215. };
  1216. const toggleMultipleLists = (editor, parentList, lists, listName, detail) => {
  1217. const parentIsList = isListNode(parentList);
  1218. if (parentIsList && parentList.nodeName === listName && !hasListStyleDetail(detail)) {
  1219. flattenListSelection(editor);
  1220. } else {
  1221. applyList(editor, listName, detail);
  1222. const bookmark = createBookmark(editor.selection.getRng());
  1223. const allLists = parentIsList ? [
  1224. parentList,
  1225. ...lists
  1226. ] : lists;
  1227. global$1.each(allLists, elm => {
  1228. updateList$1(editor, elm, listName, detail);
  1229. });
  1230. editor.selection.setRng(resolveBookmark(bookmark));
  1231. }
  1232. };
  1233. const hasListStyleDetail = detail => {
  1234. return 'list-style-type' in detail;
  1235. };
  1236. const toggleSingleList = (editor, parentList, listName, detail) => {
  1237. if (parentList === editor.getBody()) {
  1238. return;
  1239. }
  1240. if (parentList) {
  1241. if (parentList.nodeName === listName && !hasListStyleDetail(detail) && !isCustomList(parentList)) {
  1242. flattenListSelection(editor);
  1243. } else {
  1244. const bookmark = createBookmark(editor.selection.getRng());
  1245. updateListWithDetails(editor.dom, parentList, detail);
  1246. const newList = editor.dom.rename(parentList, listName);
  1247. mergeWithAdjacentLists(editor.dom, newList);
  1248. editor.selection.setRng(resolveBookmark(bookmark));
  1249. applyList(editor, listName, detail);
  1250. fireListEvent(editor, listToggleActionFromListName(listName), newList);
  1251. }
  1252. } else {
  1253. applyList(editor, listName, detail);
  1254. fireListEvent(editor, listToggleActionFromListName(listName), parentList);
  1255. }
  1256. };
  1257. const toggleList = (editor, listName, _detail) => {
  1258. const parentList = getParentList(editor);
  1259. const selectedSubLists = getSelectedSubLists(editor);
  1260. const detail = isObject(_detail) ? _detail : {};
  1261. if (selectedSubLists.length > 0) {
  1262. toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
  1263. } else {
  1264. toggleSingleList(editor, parentList, listName, detail);
  1265. }
  1266. };
  1267. const DOM = global$2.DOM;
  1268. const normalizeList = (dom, list) => {
  1269. const parentNode = list.parentNode;
  1270. if (parentNode.nodeName === 'LI' && parentNode.firstChild === list) {
  1271. const sibling = parentNode.previousSibling;
  1272. if (sibling && sibling.nodeName === 'LI') {
  1273. sibling.appendChild(list);
  1274. if (isEmpty$1(dom, parentNode)) {
  1275. DOM.remove(parentNode);
  1276. }
  1277. } else {
  1278. DOM.setStyle(parentNode, 'listStyleType', 'none');
  1279. }
  1280. }
  1281. if (isListNode(parentNode)) {
  1282. const sibling = parentNode.previousSibling;
  1283. if (sibling && sibling.nodeName === 'LI') {
  1284. sibling.appendChild(list);
  1285. }
  1286. }
  1287. };
  1288. const normalizeLists = (dom, element) => {
  1289. const lists = global$1.grep(dom.select('ol,ul', element));
  1290. global$1.each(lists, list => {
  1291. normalizeList(dom, list);
  1292. });
  1293. };
  1294. const findNextCaretContainer = (editor, rng, isForward, root) => {
  1295. let node = rng.startContainer;
  1296. const offset = rng.startOffset;
  1297. if (isTextNode(node) && (isForward ? offset < node.data.length : offset > 0)) {
  1298. return node;
  1299. }
  1300. const nonEmptyBlocks = editor.schema.getNonEmptyElements();
  1301. if (node.nodeType === 1) {
  1302. node = global$5.getNode(node, offset);
  1303. }
  1304. const walker = new global$4(node, root);
  1305. if (isForward) {
  1306. if (isBogusBr(editor.dom, node)) {
  1307. walker.next();
  1308. }
  1309. }
  1310. const walkFn = isForward ? walker.next.bind(walker) : walker.prev2.bind(walker);
  1311. while (node = walkFn()) {
  1312. if (node.nodeName === 'LI' && !node.hasChildNodes()) {
  1313. return node;
  1314. }
  1315. if (nonEmptyBlocks[node.nodeName]) {
  1316. return node;
  1317. }
  1318. if (isTextNode(node) && node.data.length > 0) {
  1319. return node;
  1320. }
  1321. }
  1322. };
  1323. const hasOnlyOneBlockChild = (dom, elm) => {
  1324. const childNodes = elm.childNodes;
  1325. return childNodes.length === 1 && !isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
  1326. };
  1327. const unwrapSingleBlockChild = (dom, elm) => {
  1328. if (hasOnlyOneBlockChild(dom, elm)) {
  1329. dom.remove(elm.firstChild, true);
  1330. }
  1331. };
  1332. const moveChildren = (dom, fromElm, toElm) => {
  1333. let node;
  1334. const targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
  1335. unwrapSingleBlockChild(dom, fromElm);
  1336. if (!isEmpty$1(dom, fromElm, true)) {
  1337. while (node = fromElm.firstChild) {
  1338. targetElm.appendChild(node);
  1339. }
  1340. }
  1341. };
  1342. const mergeLiElements = (dom, fromElm, toElm) => {
  1343. let listNode;
  1344. const ul = fromElm.parentNode;
  1345. if (!isChildOfBody(dom, fromElm) || !isChildOfBody(dom, toElm)) {
  1346. return;
  1347. }
  1348. if (isListNode(toElm.lastChild)) {
  1349. listNode = toElm.lastChild;
  1350. }
  1351. if (ul === toElm.lastChild) {
  1352. if (isBr(ul.previousSibling)) {
  1353. dom.remove(ul.previousSibling);
  1354. }
  1355. }
  1356. const node = toElm.lastChild;
  1357. if (node && isBr(node) && fromElm.hasChildNodes()) {
  1358. dom.remove(node);
  1359. }
  1360. if (isEmpty$1(dom, toElm, true)) {
  1361. empty(SugarElement.fromDom(toElm));
  1362. }
  1363. moveChildren(dom, fromElm, toElm);
  1364. if (listNode) {
  1365. toElm.appendChild(listNode);
  1366. }
  1367. const contains$1 = contains(SugarElement.fromDom(toElm), SugarElement.fromDom(fromElm));
  1368. const nestedLists = contains$1 ? dom.getParents(fromElm, isListNode, toElm) : [];
  1369. dom.remove(fromElm);
  1370. each$1(nestedLists, list => {
  1371. if (isEmpty$1(dom, list) && list !== dom.getRoot()) {
  1372. dom.remove(list);
  1373. }
  1374. });
  1375. };
  1376. const mergeIntoEmptyLi = (editor, fromLi, toLi) => {
  1377. empty(SugarElement.fromDom(toLi));
  1378. mergeLiElements(editor.dom, fromLi, toLi);
  1379. editor.selection.setCursorLocation(toLi, 0);
  1380. };
  1381. const mergeForward = (editor, rng, fromLi, toLi) => {
  1382. const dom = editor.dom;
  1383. if (dom.isEmpty(toLi)) {
  1384. mergeIntoEmptyLi(editor, fromLi, toLi);
  1385. } else {
  1386. const bookmark = createBookmark(rng);
  1387. mergeLiElements(dom, fromLi, toLi);
  1388. editor.selection.setRng(resolveBookmark(bookmark));
  1389. }
  1390. };
  1391. const mergeBackward = (editor, rng, fromLi, toLi) => {
  1392. const bookmark = createBookmark(rng);
  1393. mergeLiElements(editor.dom, fromLi, toLi);
  1394. const resolvedBookmark = resolveBookmark(bookmark);
  1395. editor.selection.setRng(resolvedBookmark);
  1396. };
  1397. const backspaceDeleteFromListToListCaret = (editor, isForward) => {
  1398. const dom = editor.dom, selection = editor.selection;
  1399. const selectionStartElm = selection.getStart();
  1400. const root = getClosestEditingHost(editor, selectionStartElm);
  1401. const li = dom.getParent(selection.getStart(), 'LI', root);
  1402. if (li) {
  1403. const ul = li.parentNode;
  1404. if (ul === editor.getBody() && isEmpty$1(dom, ul)) {
  1405. return true;
  1406. }
  1407. const rng = normalizeRange(selection.getRng());
  1408. const otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
  1409. if (otherLi && otherLi !== li) {
  1410. editor.undoManager.transact(() => {
  1411. if (isForward) {
  1412. mergeForward(editor, rng, otherLi, li);
  1413. } else {
  1414. if (isFirstChild(li)) {
  1415. outdentListSelection(editor);
  1416. } else {
  1417. mergeBackward(editor, rng, li, otherLi);
  1418. }
  1419. }
  1420. });
  1421. return true;
  1422. } else if (!otherLi) {
  1423. if (!isForward && rng.startOffset === 0 && rng.endOffset === 0) {
  1424. editor.undoManager.transact(() => {
  1425. flattenListSelection(editor);
  1426. });
  1427. return true;
  1428. }
  1429. }
  1430. }
  1431. return false;
  1432. };
  1433. const removeBlock = (dom, block, root) => {
  1434. const parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
  1435. dom.remove(block);
  1436. if (parentBlock && dom.isEmpty(parentBlock)) {
  1437. dom.remove(parentBlock);
  1438. }
  1439. };
  1440. const backspaceDeleteIntoListCaret = (editor, isForward) => {
  1441. const dom = editor.dom;
  1442. const selectionStartElm = editor.selection.getStart();
  1443. const root = getClosestEditingHost(editor, selectionStartElm);
  1444. const block = dom.getParent(selectionStartElm, dom.isBlock, root);
  1445. if (block && dom.isEmpty(block)) {
  1446. const rng = normalizeRange(editor.selection.getRng());
  1447. const otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
  1448. if (otherLi) {
  1449. const findValidElement = element => contains$1([
  1450. 'td',
  1451. 'th',
  1452. 'caption'
  1453. ], name(element));
  1454. const findRoot = node => node.dom === root;
  1455. const otherLiCell = closest(SugarElement.fromDom(otherLi), findValidElement, findRoot);
  1456. const caretCell = closest(SugarElement.fromDom(rng.startContainer), findValidElement, findRoot);
  1457. if (!equals(otherLiCell, caretCell, eq)) {
  1458. return false;
  1459. }
  1460. editor.undoManager.transact(() => {
  1461. removeBlock(dom, block, root);
  1462. mergeWithAdjacentLists(dom, otherLi.parentNode);
  1463. editor.selection.select(otherLi, true);
  1464. editor.selection.collapse(isForward);
  1465. });
  1466. return true;
  1467. }
  1468. }
  1469. return false;
  1470. };
  1471. const backspaceDeleteCaret = (editor, isForward) => {
  1472. return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
  1473. };
  1474. const hasListSelection = editor => {
  1475. const selectionStartElm = editor.selection.getStart();
  1476. const root = getClosestEditingHost(editor, selectionStartElm);
  1477. const startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
  1478. return startListParent || getSelectedListItems(editor).length > 0;
  1479. };
  1480. const backspaceDeleteRange = editor => {
  1481. if (hasListSelection(editor)) {
  1482. editor.undoManager.transact(() => {
  1483. editor.execCommand('Delete');
  1484. normalizeLists(editor.dom, editor.getBody());
  1485. });
  1486. return true;
  1487. }
  1488. return false;
  1489. };
  1490. const backspaceDelete = (editor, isForward) => {
  1491. return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
  1492. };
  1493. const setup$1 = editor => {
  1494. editor.on('ExecCommand', e => {
  1495. const cmd = e.command.toLowerCase();
  1496. if ((cmd === 'delete' || cmd === 'forwarddelete') && hasListSelection(editor)) {
  1497. normalizeLists(editor.dom, editor.getBody());
  1498. }
  1499. });
  1500. editor.on('keydown', e => {
  1501. if (e.keyCode === global$3.BACKSPACE) {
  1502. if (backspaceDelete(editor, false)) {
  1503. e.preventDefault();
  1504. }
  1505. } else if (e.keyCode === global$3.DELETE) {
  1506. if (backspaceDelete(editor, true)) {
  1507. e.preventDefault();
  1508. }
  1509. }
  1510. });
  1511. };
  1512. const get = editor => ({
  1513. backspaceDelete: isForward => {
  1514. backspaceDelete(editor, isForward);
  1515. }
  1516. });
  1517. const updateList = (editor, update) => {
  1518. const parentList = getParentList(editor);
  1519. editor.undoManager.transact(() => {
  1520. if (isObject(update.styles)) {
  1521. editor.dom.setStyles(parentList, update.styles);
  1522. }
  1523. if (isObject(update.attrs)) {
  1524. each(update.attrs, (v, k) => editor.dom.setAttrib(parentList, k, v));
  1525. }
  1526. });
  1527. };
  1528. const parseAlphabeticBase26 = str => {
  1529. const chars = reverse(trim(str).split(''));
  1530. const values = map(chars, (char, i) => {
  1531. const charValue = char.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
  1532. return Math.pow(26, i) * charValue;
  1533. });
  1534. return foldl(values, (sum, v) => sum + v, 0);
  1535. };
  1536. const composeAlphabeticBase26 = value => {
  1537. value--;
  1538. if (value < 0) {
  1539. return '';
  1540. } else {
  1541. const remainder = value % 26;
  1542. const quotient = Math.floor(value / 26);
  1543. const rest = composeAlphabeticBase26(quotient);
  1544. const char = String.fromCharCode('A'.charCodeAt(0) + remainder);
  1545. return rest + char;
  1546. }
  1547. };
  1548. const isUppercase = str => /^[A-Z]+$/.test(str);
  1549. const isLowercase = str => /^[a-z]+$/.test(str);
  1550. const isNumeric = str => /^[0-9]+$/.test(str);
  1551. const deduceListType = start => {
  1552. if (isNumeric(start)) {
  1553. return 2;
  1554. } else if (isUppercase(start)) {
  1555. return 0;
  1556. } else if (isLowercase(start)) {
  1557. return 1;
  1558. } else if (isEmpty(start)) {
  1559. return 3;
  1560. } else {
  1561. return 4;
  1562. }
  1563. };
  1564. const parseStartValue = start => {
  1565. switch (deduceListType(start)) {
  1566. case 2:
  1567. return Optional.some({
  1568. listStyleType: Optional.none(),
  1569. start
  1570. });
  1571. case 0:
  1572. return Optional.some({
  1573. listStyleType: Optional.some('upper-alpha'),
  1574. start: parseAlphabeticBase26(start).toString()
  1575. });
  1576. case 1:
  1577. return Optional.some({
  1578. listStyleType: Optional.some('lower-alpha'),
  1579. start: parseAlphabeticBase26(start).toString()
  1580. });
  1581. case 3:
  1582. return Optional.some({
  1583. listStyleType: Optional.none(),
  1584. start: ''
  1585. });
  1586. case 4:
  1587. return Optional.none();
  1588. }
  1589. };
  1590. const parseDetail = detail => {
  1591. const start = parseInt(detail.start, 10);
  1592. if (is$2(detail.listStyleType, 'upper-alpha')) {
  1593. return composeAlphabeticBase26(start);
  1594. } else if (is$2(detail.listStyleType, 'lower-alpha')) {
  1595. return composeAlphabeticBase26(start).toLowerCase();
  1596. } else {
  1597. return detail.start;
  1598. }
  1599. };
  1600. const open = editor => {
  1601. const currentList = getParentList(editor);
  1602. if (!isOlNode(currentList)) {
  1603. return;
  1604. }
  1605. editor.windowManager.open({
  1606. title: 'List Properties',
  1607. body: {
  1608. type: 'panel',
  1609. items: [{
  1610. type: 'input',
  1611. name: 'start',
  1612. label: 'Start list at number',
  1613. inputMode: 'numeric'
  1614. }]
  1615. },
  1616. initialData: {
  1617. start: parseDetail({
  1618. start: editor.dom.getAttrib(currentList, 'start', '1'),
  1619. listStyleType: Optional.some(editor.dom.getStyle(currentList, 'list-style-type'))
  1620. })
  1621. },
  1622. buttons: [
  1623. {
  1624. type: 'cancel',
  1625. name: 'cancel',
  1626. text: 'Cancel'
  1627. },
  1628. {
  1629. type: 'submit',
  1630. name: 'save',
  1631. text: 'Save',
  1632. primary: true
  1633. }
  1634. ],
  1635. onSubmit: api => {
  1636. const data = api.getData();
  1637. parseStartValue(data.start).each(detail => {
  1638. editor.execCommand('mceListUpdate', false, {
  1639. attrs: { start: detail.start === '1' ? '' : detail.start },
  1640. styles: { 'list-style-type': detail.listStyleType.getOr('') }
  1641. });
  1642. });
  1643. api.close();
  1644. }
  1645. });
  1646. };
  1647. const queryListCommandState = (editor, listName) => () => {
  1648. const parentList = getParentList(editor);
  1649. return parentList && parentList.nodeName === listName;
  1650. };
  1651. const registerDialog = editor => {
  1652. editor.addCommand('mceListProps', () => {
  1653. open(editor);
  1654. });
  1655. };
  1656. const register$2 = editor => {
  1657. editor.on('BeforeExecCommand', e => {
  1658. const cmd = e.command.toLowerCase();
  1659. if (cmd === 'indent') {
  1660. indentListSelection(editor);
  1661. } else if (cmd === 'outdent') {
  1662. outdentListSelection(editor);
  1663. }
  1664. });
  1665. editor.addCommand('InsertUnorderedList', (ui, detail) => {
  1666. toggleList(editor, 'UL', detail);
  1667. });
  1668. editor.addCommand('InsertOrderedList', (ui, detail) => {
  1669. toggleList(editor, 'OL', detail);
  1670. });
  1671. editor.addCommand('InsertDefinitionList', (ui, detail) => {
  1672. toggleList(editor, 'DL', detail);
  1673. });
  1674. editor.addCommand('RemoveList', () => {
  1675. flattenListSelection(editor);
  1676. });
  1677. registerDialog(editor);
  1678. editor.addCommand('mceListUpdate', (ui, detail) => {
  1679. if (isObject(detail)) {
  1680. updateList(editor, detail);
  1681. }
  1682. });
  1683. editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL'));
  1684. editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL'));
  1685. editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
  1686. };
  1687. const setupTabKey = editor => {
  1688. editor.on('keydown', e => {
  1689. if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) {
  1690. return;
  1691. }
  1692. editor.undoManager.transact(() => {
  1693. if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
  1694. e.preventDefault();
  1695. }
  1696. });
  1697. });
  1698. };
  1699. const setup = editor => {
  1700. if (shouldIndentOnTab(editor)) {
  1701. setupTabKey(editor);
  1702. }
  1703. setup$1(editor);
  1704. };
  1705. const register$1 = editor => {
  1706. const exec = command => () => editor.execCommand(command);
  1707. if (!editor.hasPlugin('advlist')) {
  1708. editor.ui.registry.addToggleButton('numlist', {
  1709. icon: 'ordered-list',
  1710. active: false,
  1711. tooltip: 'Numbered list',
  1712. onAction: exec('InsertOrderedList'),
  1713. onSetup: api => listState(editor, 'OL', api.setActive)
  1714. });
  1715. editor.ui.registry.addToggleButton('bullist', {
  1716. icon: 'unordered-list',
  1717. active: false,
  1718. tooltip: 'Bullet list',
  1719. onAction: exec('InsertUnorderedList'),
  1720. onSetup: api => listState(editor, 'UL', api.setActive)
  1721. });
  1722. }
  1723. };
  1724. const register = editor => {
  1725. const listProperties = {
  1726. text: 'List properties...',
  1727. icon: 'ordered-list',
  1728. onAction: () => editor.execCommand('mceListProps'),
  1729. onSetup: api => listState(editor, 'OL', api.setEnabled)
  1730. };
  1731. editor.ui.registry.addMenuItem('listprops', listProperties);
  1732. editor.ui.registry.addContextMenu('lists', {
  1733. update: node => {
  1734. const parentList = getParentList(editor, node);
  1735. return isOlNode(parentList) ? ['listprops'] : [];
  1736. }
  1737. });
  1738. };
  1739. var Plugin = () => {
  1740. global$6.add('lists', editor => {
  1741. register$3(editor);
  1742. if (editor.hasPlugin('rtc', true) === false) {
  1743. setup(editor);
  1744. register$2(editor);
  1745. } else {
  1746. registerDialog(editor);
  1747. }
  1748. register$1(editor);
  1749. register(editor);
  1750. return get(editor);
  1751. });
  1752. };
  1753. Plugin();
  1754. })();