| 1 |
efrain |
1 |
/**
|
| 1441 |
ariadna |
2 |
* TinyMCE version 7.7.1 (2025-03-05)
|
| 1 |
efrain |
3 |
*/
|
|
|
4 |
|
|
|
5 |
(function () {
|
|
|
6 |
'use strict';
|
|
|
7 |
|
|
|
8 |
const Cell = initial => {
|
|
|
9 |
let value = initial;
|
|
|
10 |
const get = () => {
|
|
|
11 |
return value;
|
|
|
12 |
};
|
|
|
13 |
const set = v => {
|
|
|
14 |
value = v;
|
|
|
15 |
};
|
|
|
16 |
return {
|
|
|
17 |
get,
|
|
|
18 |
set
|
|
|
19 |
};
|
|
|
20 |
};
|
|
|
21 |
|
|
|
22 |
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
23 |
|
|
|
24 |
const get$2 = toggleState => {
|
|
|
25 |
const isEnabled = () => {
|
|
|
26 |
return toggleState.get();
|
|
|
27 |
};
|
|
|
28 |
return { isEnabled };
|
|
|
29 |
};
|
|
|
30 |
|
|
|
31 |
const fireVisualChars = (editor, state) => {
|
|
|
32 |
return editor.dispatch('VisualChars', { state });
|
|
|
33 |
};
|
|
|
34 |
|
|
|
35 |
const hasProto = (v, constructor, predicate) => {
|
|
|
36 |
var _a;
|
|
|
37 |
if (predicate(v, constructor.prototype)) {
|
|
|
38 |
return true;
|
|
|
39 |
} else {
|
|
|
40 |
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
|
41 |
}
|
|
|
42 |
};
|
|
|
43 |
const typeOf = x => {
|
|
|
44 |
const t = typeof x;
|
|
|
45 |
if (x === null) {
|
|
|
46 |
return 'null';
|
|
|
47 |
} else if (t === 'object' && Array.isArray(x)) {
|
|
|
48 |
return 'array';
|
|
|
49 |
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
|
50 |
return 'string';
|
|
|
51 |
} else {
|
|
|
52 |
return t;
|
|
|
53 |
}
|
|
|
54 |
};
|
|
|
55 |
const isType$1 = type => value => typeOf(value) === type;
|
|
|
56 |
const isSimpleType = type => value => typeof value === type;
|
|
|
57 |
const eq = t => a => t === a;
|
|
|
58 |
const isString = isType$1('string');
|
|
|
59 |
const isObject = isType$1('object');
|
|
|
60 |
const isNull = eq(null);
|
|
|
61 |
const isBoolean = isSimpleType('boolean');
|
|
|
62 |
const isNullable = a => a === null || a === undefined;
|
|
|
63 |
const isNonNullable = a => !isNullable(a);
|
|
|
64 |
const isNumber = isSimpleType('number');
|
|
|
65 |
|
|
|
66 |
class Optional {
|
|
|
67 |
constructor(tag, value) {
|
|
|
68 |
this.tag = tag;
|
|
|
69 |
this.value = value;
|
|
|
70 |
}
|
|
|
71 |
static some(value) {
|
|
|
72 |
return new Optional(true, value);
|
|
|
73 |
}
|
|
|
74 |
static none() {
|
|
|
75 |
return Optional.singletonNone;
|
|
|
76 |
}
|
|
|
77 |
fold(onNone, onSome) {
|
|
|
78 |
if (this.tag) {
|
|
|
79 |
return onSome(this.value);
|
|
|
80 |
} else {
|
|
|
81 |
return onNone();
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
isSome() {
|
|
|
85 |
return this.tag;
|
|
|
86 |
}
|
|
|
87 |
isNone() {
|
|
|
88 |
return !this.tag;
|
|
|
89 |
}
|
|
|
90 |
map(mapper) {
|
|
|
91 |
if (this.tag) {
|
|
|
92 |
return Optional.some(mapper(this.value));
|
|
|
93 |
} else {
|
|
|
94 |
return Optional.none();
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
bind(binder) {
|
|
|
98 |
if (this.tag) {
|
|
|
99 |
return binder(this.value);
|
|
|
100 |
} else {
|
|
|
101 |
return Optional.none();
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
exists(predicate) {
|
|
|
105 |
return this.tag && predicate(this.value);
|
|
|
106 |
}
|
|
|
107 |
forall(predicate) {
|
|
|
108 |
return !this.tag || predicate(this.value);
|
|
|
109 |
}
|
|
|
110 |
filter(predicate) {
|
|
|
111 |
if (!this.tag || predicate(this.value)) {
|
|
|
112 |
return this;
|
|
|
113 |
} else {
|
|
|
114 |
return Optional.none();
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
getOr(replacement) {
|
|
|
118 |
return this.tag ? this.value : replacement;
|
|
|
119 |
}
|
|
|
120 |
or(replacement) {
|
|
|
121 |
return this.tag ? this : replacement;
|
|
|
122 |
}
|
|
|
123 |
getOrThunk(thunk) {
|
|
|
124 |
return this.tag ? this.value : thunk();
|
|
|
125 |
}
|
|
|
126 |
orThunk(thunk) {
|
|
|
127 |
return this.tag ? this : thunk();
|
|
|
128 |
}
|
|
|
129 |
getOrDie(message) {
|
|
|
130 |
if (!this.tag) {
|
|
|
131 |
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
|
132 |
} else {
|
|
|
133 |
return this.value;
|
|
|
134 |
}
|
|
|
135 |
}
|
|
|
136 |
static from(value) {
|
|
|
137 |
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
|
138 |
}
|
|
|
139 |
getOrNull() {
|
|
|
140 |
return this.tag ? this.value : null;
|
|
|
141 |
}
|
|
|
142 |
getOrUndefined() {
|
|
|
143 |
return this.value;
|
|
|
144 |
}
|
|
|
145 |
each(worker) {
|
|
|
146 |
if (this.tag) {
|
|
|
147 |
worker(this.value);
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
toArray() {
|
|
|
151 |
return this.tag ? [this.value] : [];
|
|
|
152 |
}
|
|
|
153 |
toString() {
|
|
|
154 |
return this.tag ? `some(${ this.value })` : 'none()';
|
|
|
155 |
}
|
|
|
156 |
}
|
|
|
157 |
Optional.singletonNone = new Optional(false);
|
|
|
158 |
|
|
|
159 |
const map = (xs, f) => {
|
|
|
160 |
const len = xs.length;
|
|
|
161 |
const r = new Array(len);
|
|
|
162 |
for (let i = 0; i < len; i++) {
|
|
|
163 |
const x = xs[i];
|
|
|
164 |
r[i] = f(x, i);
|
|
|
165 |
}
|
|
|
166 |
return r;
|
|
|
167 |
};
|
|
|
168 |
const each$1 = (xs, f) => {
|
|
|
169 |
for (let i = 0, len = xs.length; i < len; i++) {
|
|
|
170 |
const x = xs[i];
|
|
|
171 |
f(x, i);
|
|
|
172 |
}
|
|
|
173 |
};
|
|
|
174 |
const filter = (xs, pred) => {
|
|
|
175 |
const r = [];
|
|
|
176 |
for (let i = 0, len = xs.length; i < len; i++) {
|
|
|
177 |
const x = xs[i];
|
|
|
178 |
if (pred(x, i)) {
|
|
|
179 |
r.push(x);
|
|
|
180 |
}
|
|
|
181 |
}
|
|
|
182 |
return r;
|
|
|
183 |
};
|
|
|
184 |
|
|
|
185 |
const keys = Object.keys;
|
|
|
186 |
const each = (obj, f) => {
|
|
|
187 |
const props = keys(obj);
|
|
|
188 |
for (let k = 0, len = props.length; k < len; k++) {
|
|
|
189 |
const i = props[k];
|
|
|
190 |
const x = obj[i];
|
|
|
191 |
f(x, i);
|
|
|
192 |
}
|
|
|
193 |
};
|
|
|
194 |
|
|
|
195 |
const Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
196 |
|
|
|
197 |
const path = (parts, scope) => {
|
|
|
198 |
let o = scope !== undefined && scope !== null ? scope : Global;
|
|
|
199 |
for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
|
|
|
200 |
o = o[parts[i]];
|
|
|
201 |
}
|
|
|
202 |
return o;
|
|
|
203 |
};
|
|
|
204 |
const resolve = (p, scope) => {
|
|
|
205 |
const parts = p.split('.');
|
|
|
206 |
return path(parts, scope);
|
|
|
207 |
};
|
|
|
208 |
|
|
|
209 |
const unsafe = (name, scope) => {
|
|
|
210 |
return resolve(name, scope);
|
|
|
211 |
};
|
|
|
212 |
const getOrDie = (name, scope) => {
|
|
|
213 |
const actual = unsafe(name, scope);
|
|
|
214 |
if (actual === undefined || actual === null) {
|
|
|
215 |
throw new Error(name + ' not available on this browser');
|
|
|
216 |
}
|
|
|
217 |
return actual;
|
|
|
218 |
};
|
|
|
219 |
|
|
|
220 |
const getPrototypeOf = Object.getPrototypeOf;
|
|
|
221 |
const sandHTMLElement = scope => {
|
|
|
222 |
return getOrDie('HTMLElement', scope);
|
|
|
223 |
};
|
|
|
224 |
const isPrototypeOf = x => {
|
|
|
225 |
const scope = resolve('ownerDocument.defaultView', x);
|
|
|
226 |
return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
|
|
|
227 |
};
|
|
|
228 |
|
|
|
229 |
const ELEMENT = 1;
|
|
|
230 |
const TEXT = 3;
|
|
|
231 |
|
|
|
232 |
const type = element => element.dom.nodeType;
|
|
|
233 |
const value = element => element.dom.nodeValue;
|
|
|
234 |
const isType = t => element => type(element) === t;
|
|
|
235 |
const isHTMLElement = element => isElement(element) && isPrototypeOf(element.dom);
|
|
|
236 |
const isElement = isType(ELEMENT);
|
|
|
237 |
const isText = isType(TEXT);
|
|
|
238 |
|
|
|
239 |
const rawSet = (dom, key, value) => {
|
|
|
240 |
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
|
241 |
dom.setAttribute(key, value + '');
|
|
|
242 |
} else {
|
|
|
243 |
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
|
244 |
throw new Error('Attribute value was not simple');
|
|
|
245 |
}
|
|
|
246 |
};
|
|
|
247 |
const set = (element, key, value) => {
|
|
|
248 |
rawSet(element.dom, key, value);
|
|
|
249 |
};
|
|
|
250 |
const get$1 = (element, key) => {
|
|
|
251 |
const v = element.dom.getAttribute(key);
|
|
|
252 |
return v === null ? undefined : v;
|
|
|
253 |
};
|
|
|
254 |
const remove$3 = (element, key) => {
|
|
|
255 |
element.dom.removeAttribute(key);
|
|
|
256 |
};
|
|
|
257 |
|
|
|
258 |
const read = (element, attr) => {
|
|
|
259 |
const value = get$1(element, attr);
|
|
|
260 |
return value === undefined || value === '' ? [] : value.split(' ');
|
|
|
261 |
};
|
|
|
262 |
const add$2 = (element, attr, id) => {
|
|
|
263 |
const old = read(element, attr);
|
|
|
264 |
const nu = old.concat([id]);
|
|
|
265 |
set(element, attr, nu.join(' '));
|
|
|
266 |
return true;
|
|
|
267 |
};
|
|
|
268 |
const remove$2 = (element, attr, id) => {
|
|
|
269 |
const nu = filter(read(element, attr), v => v !== id);
|
|
|
270 |
if (nu.length > 0) {
|
|
|
271 |
set(element, attr, nu.join(' '));
|
|
|
272 |
} else {
|
|
|
273 |
remove$3(element, attr);
|
|
|
274 |
}
|
|
|
275 |
return false;
|
|
|
276 |
};
|
|
|
277 |
|
|
|
278 |
const supports = element => element.dom.classList !== undefined;
|
|
|
279 |
const get = element => read(element, 'class');
|
|
|
280 |
const add$1 = (element, clazz) => add$2(element, 'class', clazz);
|
|
|
281 |
const remove$1 = (element, clazz) => remove$2(element, 'class', clazz);
|
|
|
282 |
|
|
|
283 |
const add = (element, clazz) => {
|
|
|
284 |
if (supports(element)) {
|
|
|
285 |
element.dom.classList.add(clazz);
|
|
|
286 |
} else {
|
|
|
287 |
add$1(element, clazz);
|
|
|
288 |
}
|
|
|
289 |
};
|
|
|
290 |
const cleanClass = element => {
|
|
|
291 |
const classList = supports(element) ? element.dom.classList : get(element);
|
|
|
292 |
if (classList.length === 0) {
|
|
|
293 |
remove$3(element, 'class');
|
|
|
294 |
}
|
|
|
295 |
};
|
|
|
296 |
const remove = (element, clazz) => {
|
|
|
297 |
if (supports(element)) {
|
|
|
298 |
const classList = element.dom.classList;
|
|
|
299 |
classList.remove(clazz);
|
|
|
300 |
} else {
|
|
|
301 |
remove$1(element, clazz);
|
|
|
302 |
}
|
|
|
303 |
cleanClass(element);
|
|
|
304 |
};
|
|
|
305 |
|
|
|
306 |
const fromHtml = (html, scope) => {
|
|
|
307 |
const doc = scope || document;
|
|
|
308 |
const div = doc.createElement('div');
|
|
|
309 |
div.innerHTML = html;
|
|
|
310 |
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
|
311 |
const message = 'HTML does not have a single root node';
|
|
|
312 |
console.error(message, html);
|
|
|
313 |
throw new Error(message);
|
|
|
314 |
}
|
|
|
315 |
return fromDom(div.childNodes[0]);
|
|
|
316 |
};
|
|
|
317 |
const fromTag = (tag, scope) => {
|
|
|
318 |
const doc = scope || document;
|
|
|
319 |
const node = doc.createElement(tag);
|
|
|
320 |
return fromDom(node);
|
|
|
321 |
};
|
|
|
322 |
const fromText = (text, scope) => {
|
|
|
323 |
const doc = scope || document;
|
|
|
324 |
const node = doc.createTextNode(text);
|
|
|
325 |
return fromDom(node);
|
|
|
326 |
};
|
|
|
327 |
const fromDom = node => {
|
|
|
328 |
if (node === null || node === undefined) {
|
|
|
329 |
throw new Error('Node cannot be null or undefined');
|
|
|
330 |
}
|
|
|
331 |
return { dom: node };
|
|
|
332 |
};
|
|
|
333 |
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
|
334 |
const SugarElement = {
|
|
|
335 |
fromHtml,
|
|
|
336 |
fromTag,
|
|
|
337 |
fromText,
|
|
|
338 |
fromDom,
|
|
|
339 |
fromPoint
|
|
|
340 |
};
|
|
|
341 |
|
|
|
342 |
const charMap = {
|
|
|
343 |
'\xA0': 'nbsp',
|
|
|
344 |
'\xAD': 'shy'
|
|
|
345 |
};
|
|
|
346 |
const charMapToRegExp = (charMap, global) => {
|
|
|
347 |
let regExp = '';
|
|
|
348 |
each(charMap, (_value, key) => {
|
|
|
349 |
regExp += key;
|
|
|
350 |
});
|
|
|
351 |
return new RegExp('[' + regExp + ']', global ? 'g' : '');
|
|
|
352 |
};
|
|
|
353 |
const charMapToSelector = charMap => {
|
|
|
354 |
let selector = '';
|
|
|
355 |
each(charMap, value => {
|
|
|
356 |
if (selector) {
|
|
|
357 |
selector += ',';
|
|
|
358 |
}
|
|
|
359 |
selector += 'span.mce-' + value;
|
|
|
360 |
});
|
|
|
361 |
return selector;
|
|
|
362 |
};
|
|
|
363 |
const regExp = charMapToRegExp(charMap);
|
|
|
364 |
const regExpGlobal = charMapToRegExp(charMap, true);
|
|
|
365 |
const selector = charMapToSelector(charMap);
|
|
|
366 |
const nbspClass = 'mce-nbsp';
|
|
|
367 |
|
|
|
368 |
const getRaw = element => element.dom.contentEditable;
|
|
|
369 |
|
|
|
370 |
const wrapCharWithSpan = value => '<span data-mce-bogus="1" class="mce-' + charMap[value] + '">' + value + '</span>';
|
|
|
371 |
|
|
|
372 |
const isWrappedNbsp = node => node.nodeName.toLowerCase() === 'span' && node.classList.contains('mce-nbsp-wrap');
|
|
|
373 |
const isMatch = n => {
|
|
|
374 |
const value$1 = value(n);
|
|
|
375 |
return isText(n) && isString(value$1) && regExp.test(value$1);
|
|
|
376 |
};
|
|
|
377 |
const isContentEditableFalse = node => isHTMLElement(node) && getRaw(node) === 'false';
|
|
|
378 |
const isChildEditable = (node, currentState) => {
|
|
|
379 |
if (isHTMLElement(node) && !isWrappedNbsp(node.dom)) {
|
|
|
380 |
const value = getRaw(node);
|
|
|
381 |
if (value === 'true') {
|
|
|
382 |
return true;
|
|
|
383 |
} else if (value === 'false') {
|
|
|
384 |
return false;
|
|
|
385 |
}
|
|
|
386 |
}
|
|
|
387 |
return currentState;
|
|
|
388 |
};
|
|
|
389 |
const filterEditableDescendants = (scope, predicate, editable) => {
|
|
|
390 |
let result = [];
|
|
|
391 |
const dom = scope.dom;
|
|
|
392 |
const children = map(dom.childNodes, SugarElement.fromDom);
|
|
|
393 |
const isEditable = node => isWrappedNbsp(node.dom) || !isContentEditableFalse(node);
|
|
|
394 |
each$1(children, x => {
|
|
|
395 |
if (editable && isEditable(x) && predicate(x)) {
|
|
|
396 |
result = result.concat([x]);
|
|
|
397 |
}
|
|
|
398 |
result = result.concat(filterEditableDescendants(x, predicate, isChildEditable(x, editable)));
|
|
|
399 |
});
|
|
|
400 |
return result;
|
|
|
401 |
};
|
|
|
402 |
const findParentElm = (elm, rootElm) => {
|
|
|
403 |
while (elm.parentNode) {
|
|
|
404 |
if (elm.parentNode === rootElm) {
|
|
|
405 |
return rootElm;
|
|
|
406 |
}
|
|
|
407 |
elm = elm.parentNode;
|
|
|
408 |
}
|
|
|
409 |
return undefined;
|
|
|
410 |
};
|
|
|
411 |
const replaceWithSpans = text => text.replace(regExpGlobal, wrapCharWithSpan);
|
|
|
412 |
|
|
|
413 |
const show = (editor, rootElm) => {
|
|
|
414 |
const dom = editor.dom;
|
|
|
415 |
const nodeList = filterEditableDescendants(SugarElement.fromDom(rootElm), isMatch, editor.dom.isEditable(rootElm));
|
|
|
416 |
each$1(nodeList, n => {
|
|
|
417 |
var _a;
|
|
|
418 |
const parent = n.dom.parentNode;
|
|
|
419 |
if (isWrappedNbsp(parent)) {
|
|
|
420 |
add(SugarElement.fromDom(parent), nbspClass);
|
|
|
421 |
} else {
|
|
|
422 |
const withSpans = replaceWithSpans(dom.encode((_a = value(n)) !== null && _a !== void 0 ? _a : ''));
|
|
|
423 |
const div = dom.create('div', {}, withSpans);
|
|
|
424 |
let node;
|
|
|
425 |
while (node = div.lastChild) {
|
|
|
426 |
dom.insertAfter(node, n.dom);
|
|
|
427 |
}
|
|
|
428 |
editor.dom.remove(n.dom);
|
|
|
429 |
}
|
|
|
430 |
});
|
|
|
431 |
};
|
|
|
432 |
const hide = (editor, rootElm) => {
|
|
|
433 |
const nodeList = editor.dom.select(selector, rootElm);
|
|
|
434 |
each$1(nodeList, node => {
|
|
|
435 |
if (isWrappedNbsp(node)) {
|
|
|
436 |
remove(SugarElement.fromDom(node), nbspClass);
|
|
|
437 |
} else {
|
|
|
438 |
editor.dom.remove(node, true);
|
|
|
439 |
}
|
|
|
440 |
});
|
|
|
441 |
};
|
|
|
442 |
const toggle = editor => {
|
|
|
443 |
const body = editor.getBody();
|
|
|
444 |
const bookmark = editor.selection.getBookmark();
|
|
|
445 |
let parentNode = findParentElm(editor.selection.getNode(), body);
|
|
|
446 |
parentNode = parentNode !== undefined ? parentNode : body;
|
|
|
447 |
hide(editor, parentNode);
|
|
|
448 |
show(editor, parentNode);
|
|
|
449 |
editor.selection.moveToBookmark(bookmark);
|
|
|
450 |
};
|
|
|
451 |
|
|
|
452 |
const applyVisualChars = (editor, toggleState) => {
|
|
|
453 |
fireVisualChars(editor, toggleState.get());
|
|
|
454 |
const body = editor.getBody();
|
|
|
455 |
if (toggleState.get() === true) {
|
|
|
456 |
show(editor, body);
|
|
|
457 |
} else {
|
|
|
458 |
hide(editor, body);
|
|
|
459 |
}
|
|
|
460 |
};
|
|
|
461 |
const toggleVisualChars = (editor, toggleState) => {
|
|
|
462 |
toggleState.set(!toggleState.get());
|
|
|
463 |
const bookmark = editor.selection.getBookmark();
|
|
|
464 |
applyVisualChars(editor, toggleState);
|
|
|
465 |
editor.selection.moveToBookmark(bookmark);
|
|
|
466 |
};
|
|
|
467 |
|
|
|
468 |
const register$2 = (editor, toggleState) => {
|
|
|
469 |
editor.addCommand('mceVisualChars', () => {
|
|
|
470 |
toggleVisualChars(editor, toggleState);
|
|
|
471 |
});
|
|
|
472 |
};
|
|
|
473 |
|
|
|
474 |
const option = name => editor => editor.options.get(name);
|
|
|
475 |
const register$1 = editor => {
|
|
|
476 |
const registerOption = editor.options.register;
|
|
|
477 |
registerOption('visualchars_default_state', {
|
|
|
478 |
processor: 'boolean',
|
|
|
479 |
default: false
|
|
|
480 |
});
|
|
|
481 |
};
|
|
|
482 |
const isEnabledByDefault = option('visualchars_default_state');
|
|
|
483 |
|
|
|
484 |
const setup$1 = (editor, toggleState) => {
|
|
|
485 |
editor.on('init', () => {
|
|
|
486 |
applyVisualChars(editor, toggleState);
|
|
|
487 |
});
|
|
|
488 |
};
|
|
|
489 |
|
|
|
490 |
const first = (fn, rate) => {
|
|
|
491 |
let timer = null;
|
|
|
492 |
const cancel = () => {
|
|
|
493 |
if (!isNull(timer)) {
|
|
|
494 |
clearTimeout(timer);
|
|
|
495 |
timer = null;
|
|
|
496 |
}
|
|
|
497 |
};
|
|
|
498 |
const throttle = (...args) => {
|
|
|
499 |
if (isNull(timer)) {
|
|
|
500 |
timer = setTimeout(() => {
|
|
|
501 |
timer = null;
|
|
|
502 |
fn.apply(null, args);
|
|
|
503 |
}, rate);
|
|
|
504 |
}
|
|
|
505 |
};
|
|
|
506 |
return {
|
|
|
507 |
cancel,
|
|
|
508 |
throttle
|
|
|
509 |
};
|
|
|
510 |
};
|
|
|
511 |
|
|
|
512 |
const setup = (editor, toggleState) => {
|
|
|
513 |
const debouncedToggle = first(() => {
|
|
|
514 |
toggle(editor);
|
|
|
515 |
}, 300);
|
|
|
516 |
editor.on('keydown', e => {
|
|
|
517 |
if (toggleState.get() === true) {
|
|
|
518 |
e.keyCode === 13 ? toggle(editor) : debouncedToggle.throttle();
|
|
|
519 |
}
|
|
|
520 |
});
|
|
|
521 |
editor.on('remove', debouncedToggle.cancel);
|
|
|
522 |
};
|
|
|
523 |
|
|
|
524 |
const toggleActiveState = (editor, enabledStated) => api => {
|
|
|
525 |
api.setActive(enabledStated.get());
|
|
|
526 |
const editorEventCallback = e => api.setActive(e.state);
|
|
|
527 |
editor.on('VisualChars', editorEventCallback);
|
|
|
528 |
return () => editor.off('VisualChars', editorEventCallback);
|
|
|
529 |
};
|
|
|
530 |
const register = (editor, toggleState) => {
|
|
|
531 |
const onAction = () => editor.execCommand('mceVisualChars');
|
|
|
532 |
editor.ui.registry.addToggleButton('visualchars', {
|
|
|
533 |
tooltip: 'Show invisible characters',
|
|
|
534 |
icon: 'visualchars',
|
|
|
535 |
onAction,
|
| 1441 |
ariadna |
536 |
onSetup: toggleActiveState(editor, toggleState),
|
|
|
537 |
context: 'any'
|
| 1 |
efrain |
538 |
});
|
|
|
539 |
editor.ui.registry.addToggleMenuItem('visualchars', {
|
|
|
540 |
text: 'Show invisible characters',
|
|
|
541 |
icon: 'visualchars',
|
|
|
542 |
onAction,
|
| 1441 |
ariadna |
543 |
onSetup: toggleActiveState(editor, toggleState),
|
|
|
544 |
context: 'any'
|
| 1 |
efrain |
545 |
});
|
|
|
546 |
};
|
|
|
547 |
|
|
|
548 |
var Plugin = () => {
|
|
|
549 |
global.add('visualchars', editor => {
|
|
|
550 |
register$1(editor);
|
|
|
551 |
const toggleState = Cell(isEnabledByDefault(editor));
|
|
|
552 |
register$2(editor, toggleState);
|
|
|
553 |
register(editor, toggleState);
|
|
|
554 |
setup(editor, toggleState);
|
|
|
555 |
setup$1(editor, toggleState);
|
|
|
556 |
return get$2(toggleState);
|
|
|
557 |
});
|
|
|
558 |
};
|
|
|
559 |
|
|
|
560 |
Plugin();
|
|
|
561 |
|
|
|
562 |
})();
|