u
This commit is contained in:
commit
c570ec514c
550 files changed
+152597
No files matched your search
@@ -0,0 +1,7 @@
|
||||
// Exports the "visualchars" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('hugerte/plugins/visualchars')
|
||||
// ES2015:
|
||||
// import 'hugerte/plugins/visualchars'
|
||||
require('./plugin.js');
|
||||
@@ -0,0 +1,563 @@
|
||||
/**
|
||||
* HugeRTE version 1.0.9 (2025-03-15)
|
||||
* Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
|
||||
* Copyright (c) 2024 HugeRTE contributors
|
||||
* Licensed under the MIT license (https://github.com/hugerte/hugerte/blob/main/LICENSE.TXT)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const Cell = initial => {
|
||||
let value = initial;
|
||||
const get = () => {
|
||||
return value;
|
||||
};
|
||||
const set = v => {
|
||||
value = v;
|
||||
};
|
||||
return {
|
||||
get,
|
||||
set
|
||||
};
|
||||
};
|
||||
|
||||
var global = hugerte.util.Tools.resolve('hugerte.PluginManager');
|
||||
|
||||
const get$2 = toggleState => {
|
||||
const isEnabled = () => {
|
||||
return toggleState.get();
|
||||
};
|
||||
return { isEnabled };
|
||||
};
|
||||
|
||||
const fireVisualChars = (editor, state) => {
|
||||
return editor.dispatch('VisualChars', { state });
|
||||
};
|
||||
|
||||
const hasProto = (v, constructor, predicate) => {
|
||||
var _a;
|
||||
if (predicate(v, constructor.prototype)) {
|
||||
return true;
|
||||
} else {
|
||||
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
||||
}
|
||||
};
|
||||
const typeOf = x => {
|
||||
const t = typeof x;
|
||||
if (x === null) {
|
||||
return 'null';
|
||||
} else if (t === 'object' && Array.isArray(x)) {
|
||||
return 'array';
|
||||
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
||||
return 'string';
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
};
|
||||
const isType$1 = type => value => typeOf(value) === type;
|
||||
const isSimpleType = type => value => typeof value === type;
|
||||
const eq = t => a => t === a;
|
||||
const isString = isType$1('string');
|
||||
const isObject = isType$1('object');
|
||||
const isNull = eq(null);
|
||||
const isBoolean = isSimpleType('boolean');
|
||||
const isNullable = a => a === null || a === undefined;
|
||||
const isNonNullable = a => !isNullable(a);
|
||||
const isNumber = isSimpleType('number');
|
||||
|
||||
class Optional {
|
||||
constructor(tag, value) {
|
||||
this.tag = tag;
|
||||
this.value = value;
|
||||
}
|
||||
static some(value) {
|
||||
return new Optional(true, value);
|
||||
}
|
||||
static none() {
|
||||
return Optional.singletonNone;
|
||||
}
|
||||
fold(onNone, onSome) {
|
||||
if (this.tag) {
|
||||
return onSome(this.value);
|
||||
} else {
|
||||
return onNone();
|
||||
}
|
||||
}
|
||||
isSome() {
|
||||
return this.tag;
|
||||
}
|
||||
isNone() {
|
||||
return !this.tag;
|
||||
}
|
||||
map(mapper) {
|
||||
if (this.tag) {
|
||||
return Optional.some(mapper(this.value));
|
||||
} else {
|
||||
return Optional.none();
|
||||
}
|
||||
}
|
||||
bind(binder) {
|
||||
if (this.tag) {
|
||||
return binder(this.value);
|
||||
} else {
|
||||
return Optional.none();
|
||||
}
|
||||
}
|
||||
exists(predicate) {
|
||||
return this.tag && predicate(this.value);
|
||||
}
|
||||
forall(predicate) {
|
||||
return !this.tag || predicate(this.value);
|
||||
}
|
||||
filter(predicate) {
|
||||
if (!this.tag || predicate(this.value)) {
|
||||
return this;
|
||||
} else {
|
||||
return Optional.none();
|
||||
}
|
||||
}
|
||||
getOr(replacement) {
|
||||
return this.tag ? this.value : replacement;
|
||||
}
|
||||
or(replacement) {
|
||||
return this.tag ? this : replacement;
|
||||
}
|
||||
getOrThunk(thunk) {
|
||||
return this.tag ? this.value : thunk();
|
||||
}
|
||||
orThunk(thunk) {
|
||||
return this.tag ? this : thunk();
|
||||
}
|
||||
getOrDie(message) {
|
||||
if (!this.tag) {
|
||||
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
||||
} else {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
static from(value) {
|
||||
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
||||
}
|
||||
getOrNull() {
|
||||
return this.tag ? this.value : null;
|
||||
}
|
||||
getOrUndefined() {
|
||||
return this.value;
|
||||
}
|
||||
each(worker) {
|
||||
if (this.tag) {
|
||||
worker(this.value);
|
||||
}
|
||||
}
|
||||
toArray() {
|
||||
return this.tag ? [this.value] : [];
|
||||
}
|
||||
toString() {
|
||||
return this.tag ? `some(${ this.value })` : 'none()';
|
||||
}
|
||||
}
|
||||
Optional.singletonNone = new Optional(false);
|
||||
|
||||
const map = (xs, f) => {
|
||||
const len = xs.length;
|
||||
const r = new Array(len);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const x = xs[i];
|
||||
r[i] = f(x, i);
|
||||
}
|
||||
return r;
|
||||
};
|
||||
const each$1 = (xs, f) => {
|
||||
for (let i = 0, len = xs.length; i < len; i++) {
|
||||
const x = xs[i];
|
||||
f(x, i);
|
||||
}
|
||||
};
|
||||
const filter = (xs, pred) => {
|
||||
const r = [];
|
||||
for (let i = 0, len = xs.length; i < len; i++) {
|
||||
const x = xs[i];
|
||||
if (pred(x, i)) {
|
||||
r.push(x);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
};
|
||||
|
||||
const keys = Object.keys;
|
||||
const each = (obj, f) => {
|
||||
const props = keys(obj);
|
||||
for (let k = 0, len = props.length; k < len; k++) {
|
||||
const i = props[k];
|
||||
const x = obj[i];
|
||||
f(x, i);
|
||||
}
|
||||
};
|
||||
|
||||
const Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
||||
|
||||
const path = (parts, scope) => {
|
||||
let o = scope !== undefined && scope !== null ? scope : Global;
|
||||
for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
|
||||
o = o[parts[i]];
|
||||
}
|
||||
return o;
|
||||
};
|
||||
const resolve = (p, scope) => {
|
||||
const parts = p.split('.');
|
||||
return path(parts, scope);
|
||||
};
|
||||
|
||||
const unsafe = (name, scope) => {
|
||||
return resolve(name, scope);
|
||||
};
|
||||
const getOrDie = (name, scope) => {
|
||||
const actual = unsafe(name, scope);
|
||||
if (actual === undefined || actual === null) {
|
||||
throw new Error(name + ' not available on this browser');
|
||||
}
|
||||
return actual;
|
||||
};
|
||||
|
||||
const getPrototypeOf = Object.getPrototypeOf;
|
||||
const sandHTMLElement = scope => {
|
||||
return getOrDie('HTMLElement', scope);
|
||||
};
|
||||
const isPrototypeOf = x => {
|
||||
const scope = resolve('ownerDocument.defaultView', x);
|
||||
return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
|
||||
};
|
||||
|
||||
const ELEMENT = 1;
|
||||
const TEXT = 3;
|
||||
|
||||
const type = element => element.dom.nodeType;
|
||||
const value = element => element.dom.nodeValue;
|
||||
const isType = t => element => type(element) === t;
|
||||
const isHTMLElement = element => isElement(element) && isPrototypeOf(element.dom);
|
||||
const isElement = isType(ELEMENT);
|
||||
const isText = isType(TEXT);
|
||||
|
||||
const rawSet = (dom, key, value) => {
|
||||
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
||||
dom.setAttribute(key, value + '');
|
||||
} else {
|
||||
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
||||
throw new Error('Attribute value was not simple');
|
||||
}
|
||||
};
|
||||
const set = (element, key, value) => {
|
||||
rawSet(element.dom, key, value);
|
||||
};
|
||||
const get$1 = (element, key) => {
|
||||
const v = element.dom.getAttribute(key);
|
||||
return v === null ? undefined : v;
|
||||
};
|
||||
const remove$3 = (element, key) => {
|
||||
element.dom.removeAttribute(key);
|
||||
};
|
||||
|
||||
const read = (element, attr) => {
|
||||
const value = get$1(element, attr);
|
||||
return value === undefined || value === '' ? [] : value.split(' ');
|
||||
};
|
||||
const add$2 = (element, attr, id) => {
|
||||
const old = read(element, attr);
|
||||
const nu = old.concat([id]);
|
||||
set(element, attr, nu.join(' '));
|
||||
return true;
|
||||
};
|
||||
const remove$2 = (element, attr, id) => {
|
||||
const nu = filter(read(element, attr), v => v !== id);
|
||||
if (nu.length > 0) {
|
||||
set(element, attr, nu.join(' '));
|
||||
} else {
|
||||
remove$3(element, attr);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const supports = element => element.dom.classList !== undefined;
|
||||
const get = element => read(element, 'class');
|
||||
const add$1 = (element, clazz) => add$2(element, 'class', clazz);
|
||||
const remove$1 = (element, clazz) => remove$2(element, 'class', clazz);
|
||||
|
||||
const add = (element, clazz) => {
|
||||
if (supports(element)) {
|
||||
element.dom.classList.add(clazz);
|
||||
} else {
|
||||
add$1(element, clazz);
|
||||
}
|
||||
};
|
||||
const cleanClass = element => {
|
||||
const classList = supports(element) ? element.dom.classList : get(element);
|
||||
if (classList.length === 0) {
|
||||
remove$3(element, 'class');
|
||||
}
|
||||
};
|
||||
const remove = (element, clazz) => {
|
||||
if (supports(element)) {
|
||||
const classList = element.dom.classList;
|
||||
classList.remove(clazz);
|
||||
} else {
|
||||
remove$1(element, clazz);
|
||||
}
|
||||
cleanClass(element);
|
||||
};
|
||||
|
||||
const fromHtml = (html, scope) => {
|
||||
const doc = scope || document;
|
||||
const div = doc.createElement('div');
|
||||
div.innerHTML = html;
|
||||
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
||||
const message = 'HTML does not have a single root node';
|
||||
console.error(message, html);
|
||||
throw new Error(message);
|
||||
}
|
||||
return fromDom(div.childNodes[0]);
|
||||
};
|
||||
const fromTag = (tag, scope) => {
|
||||
const doc = scope || document;
|
||||
const node = doc.createElement(tag);
|
||||
return fromDom(node);
|
||||
};
|
||||
const fromText = (text, scope) => {
|
||||
const doc = scope || document;
|
||||
const node = doc.createTextNode(text);
|
||||
return fromDom(node);
|
||||
};
|
||||
const fromDom = node => {
|
||||
if (node === null || node === undefined) {
|
||||
throw new Error('Node cannot be null or undefined');
|
||||
}
|
||||
return { dom: node };
|
||||
};
|
||||
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
||||
const SugarElement = {
|
||||
fromHtml,
|
||||
fromTag,
|
||||
fromText,
|
||||
fromDom,
|
||||
fromPoint
|
||||
};
|
||||
|
||||
const charMap = {
|
||||
'\xA0': 'nbsp',
|
||||
'\xAD': 'shy'
|
||||
};
|
||||
const charMapToRegExp = (charMap, global) => {
|
||||
let regExp = '';
|
||||
each(charMap, (_value, key) => {
|
||||
regExp += key;
|
||||
});
|
||||
return new RegExp('[' + regExp + ']', global ? 'g' : '');
|
||||
};
|
||||
const charMapToSelector = charMap => {
|
||||
let selector = '';
|
||||
each(charMap, value => {
|
||||
if (selector) {
|
||||
selector += ',';
|
||||
}
|
||||
selector += 'span.mce-' + value;
|
||||
});
|
||||
return selector;
|
||||
};
|
||||
const regExp = charMapToRegExp(charMap);
|
||||
const regExpGlobal = charMapToRegExp(charMap, true);
|
||||
const selector = charMapToSelector(charMap);
|
||||
const nbspClass = 'mce-nbsp';
|
||||
|
||||
const getRaw = element => element.dom.contentEditable;
|
||||
|
||||
const wrapCharWithSpan = value => '<span data-mce-bogus="1" class="mce-' + charMap[value] + '">' + value + '</span>';
|
||||
|
||||
const isWrappedNbsp = node => node.nodeName.toLowerCase() === 'span' && node.classList.contains('mce-nbsp-wrap');
|
||||
const isMatch = n => {
|
||||
const value$1 = value(n);
|
||||
return isText(n) && isString(value$1) && regExp.test(value$1);
|
||||
};
|
||||
const isContentEditableFalse = node => isHTMLElement(node) && getRaw(node) === 'false';
|
||||
const isChildEditable = (node, currentState) => {
|
||||
if (isHTMLElement(node) && !isWrappedNbsp(node.dom)) {
|
||||
const value = getRaw(node);
|
||||
if (value === 'true') {
|
||||
return true;
|
||||
} else if (value === 'false') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return currentState;
|
||||
};
|
||||
const filterEditableDescendants = (scope, predicate, editable) => {
|
||||
let result = [];
|
||||
const dom = scope.dom;
|
||||
const children = map(dom.childNodes, SugarElement.fromDom);
|
||||
const isEditable = node => isWrappedNbsp(node.dom) || !isContentEditableFalse(node);
|
||||
each$1(children, x => {
|
||||
if (editable && isEditable(x) && predicate(x)) {
|
||||
result = result.concat([x]);
|
||||
}
|
||||
result = result.concat(filterEditableDescendants(x, predicate, isChildEditable(x, editable)));
|
||||
});
|
||||
return result;
|
||||
};
|
||||
const findParentElm = (elm, rootElm) => {
|
||||
while (elm.parentNode) {
|
||||
if (elm.parentNode === rootElm) {
|
||||
return rootElm;
|
||||
}
|
||||
elm = elm.parentNode;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
const replaceWithSpans = text => text.replace(regExpGlobal, wrapCharWithSpan);
|
||||
|
||||
const show = (editor, rootElm) => {
|
||||
const dom = editor.dom;
|
||||
const nodeList = filterEditableDescendants(SugarElement.fromDom(rootElm), isMatch, editor.dom.isEditable(rootElm));
|
||||
each$1(nodeList, n => {
|
||||
var _a;
|
||||
const parent = n.dom.parentNode;
|
||||
if (isWrappedNbsp(parent)) {
|
||||
add(SugarElement.fromDom(parent), nbspClass);
|
||||
} else {
|
||||
const withSpans = replaceWithSpans(dom.encode((_a = value(n)) !== null && _a !== void 0 ? _a : ''));
|
||||
const div = dom.create('div', {}, withSpans);
|
||||
let node;
|
||||
while (node = div.lastChild) {
|
||||
dom.insertAfter(node, n.dom);
|
||||
}
|
||||
editor.dom.remove(n.dom);
|
||||
}
|
||||
});
|
||||
};
|
||||
const hide = (editor, rootElm) => {
|
||||
const nodeList = editor.dom.select(selector, rootElm);
|
||||
each$1(nodeList, node => {
|
||||
if (isWrappedNbsp(node)) {
|
||||
remove(SugarElement.fromDom(node), nbspClass);
|
||||
} else {
|
||||
editor.dom.remove(node, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
const toggle = editor => {
|
||||
const body = editor.getBody();
|
||||
const bookmark = editor.selection.getBookmark();
|
||||
let parentNode = findParentElm(editor.selection.getNode(), body);
|
||||
parentNode = parentNode !== undefined ? parentNode : body;
|
||||
hide(editor, parentNode);
|
||||
show(editor, parentNode);
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
};
|
||||
|
||||
const applyVisualChars = (editor, toggleState) => {
|
||||
fireVisualChars(editor, toggleState.get());
|
||||
const body = editor.getBody();
|
||||
if (toggleState.get() === true) {
|
||||
show(editor, body);
|
||||
} else {
|
||||
hide(editor, body);
|
||||
}
|
||||
};
|
||||
const toggleVisualChars = (editor, toggleState) => {
|
||||
toggleState.set(!toggleState.get());
|
||||
const bookmark = editor.selection.getBookmark();
|
||||
applyVisualChars(editor, toggleState);
|
||||
editor.selection.moveToBookmark(bookmark);
|
||||
};
|
||||
|
||||
const register$2 = (editor, toggleState) => {
|
||||
editor.addCommand('mceVisualChars', () => {
|
||||
toggleVisualChars(editor, toggleState);
|
||||
});
|
||||
};
|
||||
|
||||
const option = name => editor => editor.options.get(name);
|
||||
const register$1 = editor => {
|
||||
const registerOption = editor.options.register;
|
||||
registerOption('visualchars_default_state', {
|
||||
processor: 'boolean',
|
||||
default: false
|
||||
});
|
||||
};
|
||||
const isEnabledByDefault = option('visualchars_default_state');
|
||||
|
||||
const setup$1 = (editor, toggleState) => {
|
||||
editor.on('init', () => {
|
||||
applyVisualChars(editor, toggleState);
|
||||
});
|
||||
};
|
||||
|
||||
const first = (fn, rate) => {
|
||||
let timer = null;
|
||||
const cancel = () => {
|
||||
if (!isNull(timer)) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
};
|
||||
const throttle = (...args) => {
|
||||
if (isNull(timer)) {
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
fn.apply(null, args);
|
||||
}, rate);
|
||||
}
|
||||
};
|
||||
return {
|
||||
cancel,
|
||||
throttle
|
||||
};
|
||||
};
|
||||
|
||||
const setup = (editor, toggleState) => {
|
||||
const debouncedToggle = first(() => {
|
||||
toggle(editor);
|
||||
}, 300);
|
||||
editor.on('keydown', e => {
|
||||
if (toggleState.get() === true) {
|
||||
e.keyCode === 13 ? toggle(editor) : debouncedToggle.throttle();
|
||||
}
|
||||
});
|
||||
editor.on('remove', debouncedToggle.cancel);
|
||||
};
|
||||
|
||||
const toggleActiveState = (editor, enabledStated) => api => {
|
||||
api.setActive(enabledStated.get());
|
||||
const editorEventCallback = e => api.setActive(e.state);
|
||||
editor.on('VisualChars', editorEventCallback);
|
||||
return () => editor.off('VisualChars', editorEventCallback);
|
||||
};
|
||||
const register = (editor, toggleState) => {
|
||||
const onAction = () => editor.execCommand('mceVisualChars');
|
||||
editor.ui.registry.addToggleButton('visualchars', {
|
||||
tooltip: 'Show invisible characters',
|
||||
icon: 'visualchars',
|
||||
onAction,
|
||||
onSetup: toggleActiveState(editor, toggleState)
|
||||
});
|
||||
editor.ui.registry.addToggleMenuItem('visualchars', {
|
||||
text: 'Show invisible characters',
|
||||
icon: 'visualchars',
|
||||
onAction,
|
||||
onSetup: toggleActiveState(editor, toggleState)
|
||||
});
|
||||
};
|
||||
|
||||
var Plugin = () => {
|
||||
global.add('visualchars', editor => {
|
||||
register$1(editor);
|
||||
const toggleState = Cell(isEnabledByDefault(editor));
|
||||
register$2(editor, toggleState);
|
||||
register(editor, toggleState);
|
||||
setup(editor, toggleState);
|
||||
setup$1(editor, toggleState);
|
||||
return get$2(toggleState);
|
||||
});
|
||||
};
|
||||
|
||||
Plugin();
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* HugeRTE version 1.0.9 (2025-03-15)
|
||||
* Copyright (c) 2022 Ephox Corporation DBA Tiny Technologies, Inc.
|
||||
* Copyright (c) 2024 HugeRTE contributors
|
||||
* Licensed under the MIT license (https://github.com/hugerte/hugerte/blob/main/LICENSE.TXT)
|
||||
*/
|
||||
!function(){"use strict";var t=hugerte.util.Tools.resolve("hugerte.PluginManager");const e=t=>e=>(t=>{const e=typeof t;return null===t?"null":"object"===e&&Array.isArray(t)?"array":"object"===e&&(n=o=t,(r=String).prototype.isPrototypeOf(n)||(null===(s=o.constructor)||void 0===s?void 0:s.name)===r.name)?"string":e;var n,o,r,s})(e)===t,n=t=>e=>typeof e===t,o=e("string"),r=e("object"),s=(null,t=>null===t);const a=n("boolean"),l=n("number");class i{constructor(t,e){this.tag=t,this.value=e}static some(t){return new i(!0,t)}static none(){return i.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?i.some(t(this.value)):i.none()}bind(t){return this.tag?t(this.value):i.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:i.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(null!=t?t:"Called getOrDie on None")}static from(t){return null==t?i.none():i.some(t)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}i.singletonNone=new i(!1);const u=(t,e)=>{for(let n=0,o=t.length;n<o;n++)e(t[n],n)},c=Object.keys,d=(t,e)=>{const n=c(t);for(let o=0,r=n.length;o<r;o++){const r=n[o];e(t[r],r)}},h="undefined"!=typeof window?window:Function("return this;")(),g=(t,e)=>((t,e)=>{let n=null!=e?e:h;for(let e=0;e<t.length&&null!=n;++e)n=n[t[e]];return n})(t.split("."),e),m=Object.getPrototypeOf,v=t=>{const e=g("ownerDocument.defaultView",t);return r(t)&&((t=>((t,e)=>{const n=((t,e)=>g(t,e))(t,e);if(null==n)throw new Error(t+" not available on this browser");return n})("HTMLElement",t))(e).prototype.isPrototypeOf(t)||/^HTML\w*Element$/.test(m(t).constructor.name))},f=t=>t.dom.nodeValue,p=t=>e=>(t=>t.dom.nodeType)(e)===t,b=t=>w(t)&&v(t.dom),w=p(1),y=p(3),A=(t,e,n)=>{((t,e,n)=>{if(!(o(n)||a(n)||l(n)))throw console.error("Invalid call to Attribute.set. Key ",e,":: Value ",n,":: Element ",t),new Error("Attribute value was not simple");t.setAttribute(e,n+"")})(t.dom,e,n)},k=(t,e)=>{t.dom.removeAttribute(e)},N=(t,e)=>{const n=((t,e)=>{const n=t.dom.getAttribute(e);return null===n?void 0:n})(t,e);return void 0===n||""===n?[]:n.split(" ")},T=t=>void 0!==t.dom.classList,C=t=>{if(null==t)throw new Error("Node cannot be null or undefined");return{dom:t}},E=C,O={"\xa0":"nbsp","\xad":"shy"},L=(t,e)=>{let n="";return d(t,((t,e)=>{n+=e})),new RegExp("["+n+"]",e?"g":"")},V=L(O),j=L(O,!0),B=(t=>{let e="";return d(t,(t=>{e&&(e+=","),e+="span.mce-"+t})),e})(O),S="mce-nbsp",_=t=>t.dom.contentEditable,x=t=>'<span data-mce-bogus="1" class="mce-'+O[t]+'">'+t+"</span>",M=t=>"span"===t.nodeName.toLowerCase()&&t.classList.contains("mce-nbsp-wrap"),P=t=>{const e=f(t);return y(t)&&o(e)&&V.test(e)},D=(t,e,n)=>{let o=[];const r=((t,e)=>{const n=t.length,o=new Array(n);for(let r=0;r<n;r++){const n=t[r];o[r]=e(n,r)}return o})(t.dom.childNodes,E);return u(r,(t=>{var r;n&&(M((r=t).dom)||!(t=>b(t)&&"false"===_(t))(r))&&e(t)&&(o=o.concat([t])),o=o.concat(D(t,e,((t,e)=>{if(b(t)&&!M(t.dom)){const e=_(t);if("true"===e)return!0;if("false"===e)return!1}return e})(t,n)))})),o},H=(t,e)=>{const n=t.dom,o=D(E(e),P,t.dom.isEditable(e));u(o,(e=>{var o;const r=e.dom.parentNode;if(M(r))s=E(r),a=S,T(s)?s.dom.classList.add(a):((t,e)=>{((t,e,n)=>{const o=N(t,e).concat([n]);A(t,e,o.join(" "))})(t,"class",e)})(s,a);else{const r=n.encode(null!==(o=f(e))&&void 0!==o?o:"").replace(j,x),s=n.create("div",{},r);let a;for(;a=s.lastChild;)n.insertAfter(a,e.dom);t.dom.remove(e.dom)}var s,a}))},I=(t,e)=>{const n=t.dom.select(B,e);u(n,(e=>{var n,o;M(e)?(n=E(e),o=S,T(n)?n.dom.classList.remove(o):((t,e)=>{((t,e,n)=>{const o=((t,e)=>{const o=[];for(let e=0,r=t.length;e<r;e++){const r=t[e];r!==n&&o.push(r)}return o})(N(t,e));o.length>0?A(t,e,o.join(" ")):k(t,e)})(t,"class",e)})(n,o),(t=>{const e=T(t)?t.dom.classList:(t=>N(t,"class"))(t);0===e.length&&k(t,"class")})(n)):t.dom.remove(e,!0)}))},$=t=>{const e=t.getBody(),n=t.selection.getBookmark();let o=((t,e)=>{for(;t.parentNode;){if(t.parentNode===e)return e;t=t.parentNode}})(t.selection.getNode(),e);o=void 0!==o?o:e,I(t,o),H(t,o),t.selection.moveToBookmark(n)},F=(t,e)=>{((t,e)=>{t.dispatch("VisualChars",{state:e})})(t,e.get());const n=t.getBody();!0===e.get()?H(t,n):I(t,n)},K=("visualchars_default_state",t=>t.options.get("visualchars_default_state"));const R=(t,e)=>{const n=((t,e)=>{let n=null;return{cancel:()=>{s(n)||(clearTimeout(n),n=null)},throttle:(...e)=>{s(n)&&(n=setTimeout((()=>{n=null,t.apply(null,e)}),300))}}})((()=>{$(t)}));t.on("keydown",(o=>{!0===e.get()&&(13===o.keyCode?$(t):n.throttle())})),t.on("remove",n.cancel)},U=(t,e)=>n=>{n.setActive(e.get());const o=t=>n.seLine truncated
|
||||
Reference in new issue
Block a user