| Línea 1... |
Línea 1... |
| 1 |
/**
|
1 |
/**
|
| 2 |
* TinyMCE version 6.8.3 (2024-02-08)
|
2 |
* TinyMCE version 7.7.1 (2025-03-05)
|
| 3 |
*/
|
3 |
*/
|
| Línea 4... |
Línea 4... |
| 4 |
|
4 |
|
| 5 |
(function () {
|
5 |
(function () {
|
| Línea 422... |
Línea 422... |
| 422 |
copy.sort(comparator);
|
422 |
copy.sort(comparator);
|
| 423 |
return copy;
|
423 |
return copy;
|
| 424 |
};
|
424 |
};
|
| 425 |
const get$b = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
425 |
const get$b = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
| 426 |
const head = xs => get$b(xs, 0);
|
426 |
const head = xs => get$b(xs, 0);
|
| 427 |
const last$3 = xs => get$b(xs, xs.length - 1);
|
427 |
const last$2 = xs => get$b(xs, xs.length - 1);
|
| 428 |
const from = isFunction(Array.from) ? Array.from : x => nativeSlice.call(x);
|
428 |
const from = isFunction(Array.from) ? Array.from : x => nativeSlice.call(x);
|
| 429 |
const findMap = (arr, f) => {
|
429 |
const findMap = (arr, f) => {
|
| 430 |
for (let i = 0; i < arr.length; i++) {
|
430 |
for (let i = 0; i < arr.length; i++) {
|
| 431 |
const r = f(arr[i], i);
|
431 |
const r = f(arr[i], i);
|
| 432 |
if (r.isSome()) {
|
432 |
if (r.isSome()) {
|
| Línea 592... |
Línea 592... |
| 592 |
return i;
|
592 |
return i;
|
| 593 |
}
|
593 |
}
|
| 594 |
}
|
594 |
}
|
| 595 |
return -1;
|
595 |
return -1;
|
| 596 |
};
|
596 |
};
|
| 597 |
const last$2 = collection => collection[collection.length - 1];
|
597 |
const last$1 = collection => collection[collection.length - 1];
|
| Línea 598... |
Línea 598... |
| 598 |
|
598 |
|
| 599 |
const cached = f => {
|
599 |
const cached = f => {
|
| 600 |
let called = false;
|
600 |
let called = false;
|
| 601 |
let r;
|
601 |
let r;
|
| Línea 650... |
Línea 650... |
| 650 |
const group = i => {
|
650 |
const group = i => {
|
| 651 |
return Number(agent.replace(r, '$' + i));
|
651 |
return Number(agent.replace(r, '$' + i));
|
| 652 |
};
|
652 |
};
|
| 653 |
return nu$3(group(1), group(2));
|
653 |
return nu$3(group(1), group(2));
|
| 654 |
};
|
654 |
};
|
| 655 |
const detect$5 = (versionRegexes, agent) => {
|
655 |
const detect$4 = (versionRegexes, agent) => {
|
| 656 |
const cleanedAgent = String(agent).toLowerCase();
|
656 |
const cleanedAgent = String(agent).toLowerCase();
|
| 657 |
if (versionRegexes.length === 0) {
|
657 |
if (versionRegexes.length === 0) {
|
| 658 |
return unknown$2();
|
658 |
return unknown$2();
|
| 659 |
}
|
659 |
}
|
| 660 |
return find$1(versionRegexes, cleanedAgent);
|
660 |
return find$1(versionRegexes, cleanedAgent);
|
| Línea 668... |
Línea 668... |
| 668 |
minor
|
668 |
minor
|
| 669 |
};
|
669 |
};
|
| 670 |
};
|
670 |
};
|
| 671 |
const Version = {
|
671 |
const Version = {
|
| 672 |
nu: nu$3,
|
672 |
nu: nu$3,
|
| 673 |
detect: detect$5,
|
673 |
detect: detect$4,
|
| 674 |
unknown: unknown$2
|
674 |
unknown: unknown$2
|
| 675 |
};
|
675 |
};
|
| Línea 676... |
Línea 676... |
| 676 |
|
676 |
|
| 677 |
const detectBrowser$1 = (browsers, userAgentData) => {
|
677 |
const detectBrowser$1 = (browsers, userAgentData) => {
|
| Línea 685... |
Línea 685... |
| 685 |
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
685 |
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
| 686 |
}));
|
686 |
}));
|
| 687 |
});
|
687 |
});
|
| 688 |
};
|
688 |
};
|
| Línea 689... |
Línea 689... |
| 689 |
|
689 |
|
| 690 |
const detect$4 = (candidates, userAgent) => {
|
690 |
const detect$3 = (candidates, userAgent) => {
|
| 691 |
const agent = String(userAgent).toLowerCase();
|
691 |
const agent = String(userAgent).toLowerCase();
|
| 692 |
return find$2(candidates, candidate => {
|
692 |
return find$2(candidates, candidate => {
|
| 693 |
return candidate.search(agent);
|
693 |
return candidate.search(agent);
|
| 694 |
});
|
694 |
});
|
| 695 |
};
|
695 |
};
|
| 696 |
const detectBrowser = (browsers, userAgent) => {
|
696 |
const detectBrowser = (browsers, userAgent) => {
|
| 697 |
return detect$4(browsers, userAgent).map(browser => {
|
697 |
return detect$3(browsers, userAgent).map(browser => {
|
| 698 |
const version = Version.detect(browser.versionRegexes, userAgent);
|
698 |
const version = Version.detect(browser.versionRegexes, userAgent);
|
| 699 |
return {
|
699 |
return {
|
| 700 |
current: browser.name,
|
700 |
current: browser.name,
|
| 701 |
version
|
701 |
version
|
| 702 |
};
|
702 |
};
|
| 703 |
});
|
703 |
});
|
| 704 |
};
|
704 |
};
|
| 705 |
const detectOs = (oses, userAgent) => {
|
705 |
const detectOs = (oses, userAgent) => {
|
| 706 |
return detect$4(oses, userAgent).map(os => {
|
706 |
return detect$3(oses, userAgent).map(os => {
|
| 707 |
const version = Version.detect(os.versionRegexes, userAgent);
|
707 |
const version = Version.detect(os.versionRegexes, userAgent);
|
| 708 |
return {
|
708 |
return {
|
| 709 |
current: os.name,
|
709 |
current: os.name,
|
| 710 |
version
|
710 |
version
|
| Línea 938... |
Línea 938... |
| 938 |
solaris: constant(solaris),
|
938 |
solaris: constant(solaris),
|
| 939 |
freebsd: constant(freebsd),
|
939 |
freebsd: constant(freebsd),
|
| 940 |
chromeos: constant(chromeos)
|
940 |
chromeos: constant(chromeos)
|
| 941 |
};
|
941 |
};
|
| Línea 942... |
Línea 942... |
| 942 |
|
942 |
|
| 943 |
const detect$3 = (userAgent, userAgentDataOpt, mediaMatch) => {
|
943 |
const detect$2 = (userAgent, userAgentDataOpt, mediaMatch) => {
|
| 944 |
const browsers = PlatformInfo.browsers();
|
944 |
const browsers = PlatformInfo.browsers();
|
| 945 |
const oses = PlatformInfo.oses();
|
945 |
const oses = PlatformInfo.oses();
|
| 946 |
const browser = userAgentDataOpt.bind(userAgentData => detectBrowser$1(browsers, userAgentData)).orThunk(() => detectBrowser(browsers, userAgent)).fold(Browser.unknown, Browser.nu);
|
946 |
const browser = userAgentDataOpt.bind(userAgentData => detectBrowser$1(browsers, userAgentData)).orThunk(() => detectBrowser(browsers, userAgent)).fold(Browser.unknown, Browser.nu);
|
| 947 |
const os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
947 |
const os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
| Línea 950... |
Línea 950... |
| 950 |
browser,
|
950 |
browser,
|
| 951 |
os,
|
951 |
os,
|
| 952 |
deviceType
|
952 |
deviceType
|
| 953 |
};
|
953 |
};
|
| 954 |
};
|
954 |
};
|
| 955 |
const PlatformDetection = { detect: detect$3 };
|
955 |
const PlatformDetection = { detect: detect$2 };
|
| Línea 956... |
Línea 956... |
| 956 |
|
956 |
|
| 957 |
const mediaMatch = query => window.matchMedia(query).matches;
|
957 |
const mediaMatch = query => window.matchMedia(query).matches;
|
| 958 |
let platform$4 = cached(() => PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch));
|
958 |
let platform$4 = cached(() => PlatformDetection.detect(window.navigator.userAgent, Optional.from(window.navigator.userAgentData), mediaMatch));
|
| Línea 959... |
Línea 959... |
| 959 |
const detect$2 = () => platform$4();
|
959 |
const detect$1 = () => platform$4();
|
| 960 |
|
960 |
|
| 961 |
const userAgent = navigator.userAgent;
|
961 |
const userAgent = window.navigator.userAgent;
|
| 962 |
const platform$3 = detect$2();
|
962 |
const platform$3 = detect$1();
|
| 963 |
const browser$3 = platform$3.browser;
|
963 |
const browser$3 = platform$3.browser;
|
| 964 |
const os$1 = platform$3.os;
|
964 |
const os$1 = platform$3.os;
|
| 965 |
const deviceType = platform$3.deviceType;
|
965 |
const deviceType = platform$3.deviceType;
|
| Línea 1163... |
Línea 1163... |
| 1163 |
const type$1 = element => element.dom.nodeType;
|
1163 |
const type$1 = element => element.dom.nodeType;
|
| 1164 |
const isType = t => element => type$1(element) === t;
|
1164 |
const isType = t => element => type$1(element) === t;
|
| 1165 |
const isComment$1 = element => type$1(element) === COMMENT || name(element) === '#comment';
|
1165 |
const isComment$1 = element => type$1(element) === COMMENT || name(element) === '#comment';
|
| 1166 |
const isHTMLElement$1 = element => isElement$7(element) && isPrototypeOf(element.dom);
|
1166 |
const isHTMLElement$1 = element => isElement$7(element) && isPrototypeOf(element.dom);
|
| 1167 |
const isElement$7 = isType(ELEMENT);
|
1167 |
const isElement$7 = isType(ELEMENT);
|
| 1168 |
const isText$b = isType(TEXT);
|
1168 |
const isText$c = isType(TEXT);
|
| 1169 |
const isDocument$2 = isType(DOCUMENT);
|
1169 |
const isDocument$2 = isType(DOCUMENT);
|
| 1170 |
const isDocumentFragment$1 = isType(DOCUMENT_FRAGMENT);
|
1170 |
const isDocumentFragment$1 = isType(DOCUMENT_FRAGMENT);
|
| 1171 |
const isTag = tag => e => isElement$7(e) && name(e) === tag;
|
1171 |
const isTag = tag => e => isElement$7(e) && name(e) === tag;
|
| Línea 1172... |
Línea 1172... |
| 1172 |
|
1172 |
|
| Línea 1176... |
Línea 1176... |
| 1176 |
} else {
|
1176 |
} else {
|
| 1177 |
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
1177 |
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
| 1178 |
throw new Error('Attribute value was not simple');
|
1178 |
throw new Error('Attribute value was not simple');
|
| 1179 |
}
|
1179 |
}
|
| 1180 |
};
|
1180 |
};
|
| 1181 |
const set$3 = (element, key, value) => {
|
1181 |
const set$4 = (element, key, value) => {
|
| 1182 |
rawSet(element.dom, key, value);
|
1182 |
rawSet(element.dom, key, value);
|
| 1183 |
};
|
1183 |
};
|
| 1184 |
const setAll$1 = (element, attrs) => {
|
1184 |
const setAll$1 = (element, attrs) => {
|
| 1185 |
const dom = element.dom;
|
1185 |
const dom = element.dom;
|
| 1186 |
each$d(attrs, (v, k) => {
|
1186 |
each$d(attrs, (v, k) => {
|
| Línea 1194... |
Línea 1194... |
| 1194 |
const getOpt = (element, key) => Optional.from(get$9(element, key));
|
1194 |
const getOpt = (element, key) => Optional.from(get$9(element, key));
|
| 1195 |
const has$1 = (element, key) => {
|
1195 |
const has$1 = (element, key) => {
|
| 1196 |
const dom = element.dom;
|
1196 |
const dom = element.dom;
|
| 1197 |
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
|
1197 |
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
|
| 1198 |
};
|
1198 |
};
|
| 1199 |
const remove$a = (element, key) => {
|
1199 |
const remove$9 = (element, key) => {
|
| 1200 |
element.dom.removeAttribute(key);
|
1200 |
element.dom.removeAttribute(key);
|
| 1201 |
};
|
1201 |
};
|
| 1202 |
const hasNone = element => {
|
1202 |
const hasNone = element => {
|
| 1203 |
const attrs = element.dom.attributes;
|
1203 |
const attrs = element.dom.attributes;
|
| 1204 |
return attrs === undefined || attrs === null || attrs.length === 0;
|
1204 |
return attrs === undefined || attrs === null || attrs.length === 0;
|
| Línea 1213... |
Línea 1213... |
| 1213 |
return value === undefined || value === '' ? [] : value.split(' ');
|
1213 |
return value === undefined || value === '' ? [] : value.split(' ');
|
| 1214 |
};
|
1214 |
};
|
| 1215 |
const add$4 = (element, attr, id) => {
|
1215 |
const add$4 = (element, attr, id) => {
|
| 1216 |
const old = read$4(element, attr);
|
1216 |
const old = read$4(element, attr);
|
| 1217 |
const nu = old.concat([id]);
|
1217 |
const nu = old.concat([id]);
|
| 1218 |
set$3(element, attr, nu.join(' '));
|
1218 |
set$4(element, attr, nu.join(' '));
|
| 1219 |
return true;
|
1219 |
return true;
|
| 1220 |
};
|
1220 |
};
|
| 1221 |
const remove$9 = (element, attr, id) => {
|
1221 |
const remove$8 = (element, attr, id) => {
|
| 1222 |
const nu = filter$5(read$4(element, attr), v => v !== id);
|
1222 |
const nu = filter$5(read$4(element, attr), v => v !== id);
|
| 1223 |
if (nu.length > 0) {
|
1223 |
if (nu.length > 0) {
|
| 1224 |
set$3(element, attr, nu.join(' '));
|
1224 |
set$4(element, attr, nu.join(' '));
|
| 1225 |
} else {
|
1225 |
} else {
|
| 1226 |
remove$a(element, attr);
|
1226 |
remove$9(element, attr);
|
| 1227 |
}
|
1227 |
}
|
| 1228 |
return false;
|
1228 |
return false;
|
| 1229 |
};
|
1229 |
};
|
| Línea 1230... |
Línea 1230... |
| 1230 |
|
1230 |
|
| 1231 |
const supports = element => element.dom.classList !== undefined;
|
1231 |
const supports = element => element.dom.classList !== undefined;
|
| 1232 |
const get$8 = element => read$4(element, 'class');
|
1232 |
const get$8 = element => read$4(element, 'class');
|
| 1233 |
const add$3 = (element, clazz) => add$4(element, 'class', clazz);
|
1233 |
const add$3 = (element, clazz) => add$4(element, 'class', clazz);
|
| 1234 |
const remove$8 = (element, clazz) => remove$9(element, 'class', clazz);
|
1234 |
const remove$7 = (element, clazz) => remove$8(element, 'class', clazz);
|
| 1235 |
const toggle$2 = (element, clazz) => {
|
1235 |
const toggle$2 = (element, clazz) => {
|
| 1236 |
if (contains$2(get$8(element), clazz)) {
|
1236 |
if (contains$2(get$8(element), clazz)) {
|
| 1237 |
return remove$8(element, clazz);
|
1237 |
return remove$7(element, clazz);
|
| 1238 |
} else {
|
1238 |
} else {
|
| 1239 |
return add$3(element, clazz);
|
1239 |
return add$3(element, clazz);
|
| 1240 |
}
|
1240 |
}
|
| Línea 1248... |
Línea 1248... |
| 1248 |
}
|
1248 |
}
|
| 1249 |
};
|
1249 |
};
|
| 1250 |
const cleanClass = element => {
|
1250 |
const cleanClass = element => {
|
| 1251 |
const classList = supports(element) ? element.dom.classList : get$8(element);
|
1251 |
const classList = supports(element) ? element.dom.classList : get$8(element);
|
| 1252 |
if (classList.length === 0) {
|
1252 |
if (classList.length === 0) {
|
| 1253 |
remove$a(element, 'class');
|
1253 |
remove$9(element, 'class');
|
| 1254 |
}
|
1254 |
}
|
| 1255 |
};
|
1255 |
};
|
| 1256 |
const remove$7 = (element, clazz) => {
|
1256 |
const remove$6 = (element, clazz) => {
|
| 1257 |
if (supports(element)) {
|
1257 |
if (supports(element)) {
|
| 1258 |
const classList = element.dom.classList;
|
1258 |
const classList = element.dom.classList;
|
| 1259 |
classList.remove(clazz);
|
1259 |
classList.remove(clazz);
|
| 1260 |
} else {
|
1260 |
} else {
|
| 1261 |
remove$8(element, clazz);
|
1261 |
remove$7(element, clazz);
|
| 1262 |
}
|
1262 |
}
|
| 1263 |
cleanClass(element);
|
1263 |
cleanClass(element);
|
| 1264 |
};
|
1264 |
};
|
| 1265 |
const toggle$1 = (element, clazz) => {
|
1265 |
const toggle$1 = (element, clazz) => {
|
| 1266 |
const result = supports(element) ? element.dom.classList.toggle(clazz) : toggle$2(element, clazz);
|
1266 |
const result = supports(element) ? element.dom.classList.toggle(clazz) : toggle$2(element, clazz);
|
| Línea 1390... |
Línea 1390... |
| 1390 |
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
1390 |
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
| 1391 |
};
|
1391 |
};
|
| 1392 |
const firstChild = element => child$1(element, 0);
|
1392 |
const firstChild = element => child$1(element, 0);
|
| 1393 |
const lastChild = element => child$1(element, element.dom.childNodes.length - 1);
|
1393 |
const lastChild = element => child$1(element, element.dom.childNodes.length - 1);
|
| 1394 |
const childNodesCount = element => element.dom.childNodes.length;
|
1394 |
const childNodesCount = element => element.dom.childNodes.length;
|
| 1395 |
const hasChildNodes = element => element.dom.hasChildNodes();
|
- |
|
| Línea 1396... |
Línea 1395... |
| 1396 |
|
1395 |
|
| 1397 |
const getHead = doc => {
|
1396 |
const getHead = doc => {
|
| 1398 |
const b = doc.dom.head;
|
1397 |
const b = doc.dom.head;
|
| 1399 |
if (b === null || b === undefined) {
|
1398 |
if (b === null || b === undefined) {
|
| 1400 |
throw new Error('Head is not available yet');
|
1399 |
throw new Error('Head is not available yet');
|
| 1401 |
}
|
1400 |
}
|
| 1402 |
return SugarElement.fromDom(b);
|
1401 |
return SugarElement.fromDom(b);
|
| Línea 1403... |
Línea 1402... |
| 1403 |
};
|
1402 |
};
|
| 1404 |
|
- |
|
| 1405 |
const isShadowRoot = dos => isDocumentFragment$1(dos) && isNonNullable(dos.dom.host);
|
- |
|
| 1406 |
const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
1403 |
|
| 1407 |
const isSupported$1 = constant(supported);
|
1404 |
const isShadowRoot = dos => isDocumentFragment$1(dos) && isNonNullable(dos.dom.host);
|
| 1408 |
const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;
|
1405 |
const getRootNode = e => SugarElement.fromDom(e.dom.getRootNode());
|
| 1409 |
const getStyleContainer = dos => isShadowRoot(dos) ? dos : getHead(documentOrOwner(dos));
|
1406 |
const getStyleContainer = dos => isShadowRoot(dos) ? dos : getHead(documentOrOwner(dos));
|
| 1410 |
const getContentContainer = dos => isShadowRoot(dos) ? dos : SugarElement.fromDom(documentOrOwner(dos).dom.body);
|
1407 |
const getContentContainer = dos => isShadowRoot(dos) ? dos : SugarElement.fromDom(documentOrOwner(dos).dom.body);
|
| 1411 |
const getShadowRoot = e => {
|
1408 |
const getShadowRoot = e => {
|
| 1412 |
const r = getRootNode(e);
|
1409 |
const r = getRootNode(e);
|
| 1413 |
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
1410 |
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
| 1414 |
};
|
1411 |
};
|
| 1415 |
const getShadowHost = e => SugarElement.fromDom(e.dom.host);
|
1412 |
const getShadowHost = e => SugarElement.fromDom(e.dom.host);
|
| 1416 |
const getOriginalEventTarget = event => {
|
1413 |
const getOriginalEventTarget = event => {
|
| 1417 |
if (isSupported$1() && isNonNullable(event.target)) {
|
1414 |
if (isNonNullable(event.target)) {
|
| 1418 |
const el = SugarElement.fromDom(event.target);
|
1415 |
const el = SugarElement.fromDom(event.target);
|
| 1419 |
if (isElement$7(el) && isOpenShadowHost(el)) {
|
1416 |
if (isElement$7(el) && isOpenShadowHost(el)) {
|
| 1420 |
if (event.composed && event.composedPath) {
|
1417 |
if (event.composed && event.composedPath) {
|
| Línea 1428... |
Línea 1425... |
| 1428 |
return Optional.from(event.target);
|
1425 |
return Optional.from(event.target);
|
| 1429 |
};
|
1426 |
};
|
| 1430 |
const isOpenShadowHost = element => isNonNullable(element.dom.shadowRoot);
|
1427 |
const isOpenShadowHost = element => isNonNullable(element.dom.shadowRoot);
|
| Línea 1431... |
Línea 1428... |
| 1431 |
|
1428 |
|
| 1432 |
const inBody = element => {
|
1429 |
const inBody = element => {
|
| 1433 |
const dom = isText$b(element) ? element.dom.parentNode : element.dom;
|
1430 |
const dom = isText$c(element) ? element.dom.parentNode : element.dom;
|
| 1434 |
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
1431 |
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
| 1435 |
return false;
|
1432 |
return false;
|
| 1436 |
}
|
1433 |
}
|
| 1437 |
const doc = dom.ownerDocument;
|
1434 |
const doc = dom.ownerDocument;
|
| Línea 1509... |
Línea 1506... |
| 1509 |
} else {
|
1506 |
} else {
|
| 1510 |
return closest$2(element).fold(constant(assumeEditable), editable => getRaw$1(editable) === 'true');
|
1507 |
return closest$2(element).fold(constant(assumeEditable), editable => getRaw$1(editable) === 'true');
|
| 1511 |
}
|
1508 |
}
|
| 1512 |
};
|
1509 |
};
|
| 1513 |
const getRaw$1 = element => element.dom.contentEditable;
|
1510 |
const getRaw$1 = element => element.dom.contentEditable;
|
| - |
|
1511 |
const set$3 = (element, editable) => {
|
| - |
|
1512 |
element.dom.contentEditable = editable ? 'true' : 'false';
|
| - |
|
1513 |
};
|
| Línea 1514... |
Línea 1514... |
| 1514 |
|
1514 |
|
| Línea 1515... |
Línea 1515... |
| 1515 |
const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
1515 |
const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
| 1516 |
|
1516 |
|
| Línea 1559... |
Línea 1559... |
| 1559 |
css[ruleName] = dom.style[ruleName];
|
1559 |
css[ruleName] = dom.style[ruleName];
|
| 1560 |
}
|
1560 |
}
|
| 1561 |
}
|
1561 |
}
|
| 1562 |
return css;
|
1562 |
return css;
|
| 1563 |
};
|
1563 |
};
|
| 1564 |
const remove$6 = (element, property) => {
|
1564 |
const remove$5 = (element, property) => {
|
| 1565 |
const dom = element.dom;
|
1565 |
const dom = element.dom;
|
| 1566 |
internalRemove(dom, property);
|
1566 |
internalRemove(dom, property);
|
| 1567 |
if (is$2(getOpt(element, 'style').map(trim$4), '')) {
|
1567 |
if (is$2(getOpt(element, 'style').map(trim$4), '')) {
|
| 1568 |
remove$a(element, 'style');
|
1568 |
remove$9(element, 'style');
|
| 1569 |
}
|
1569 |
}
|
| 1570 |
};
|
1570 |
};
|
| 1571 |
const reflow = e => e.dom.offsetWidth;
|
1571 |
const reflow = e => e.dom.offsetWidth;
|
| Línea 1572... |
Línea 1572... |
| 1572 |
|
1572 |
|
| Línea 1616... |
Línea 1616... |
| 1616 |
};
|
1616 |
};
|
| Línea 1617... |
Línea 1617... |
| 1617 |
|
1617 |
|
| 1618 |
const empty = element => {
|
1618 |
const empty = element => {
|
| 1619 |
element.dom.textContent = '';
|
1619 |
element.dom.textContent = '';
|
| 1620 |
each$e(children$1(element), rogue => {
|
1620 |
each$e(children$1(element), rogue => {
|
| 1621 |
remove$5(rogue);
|
1621 |
remove$4(rogue);
|
| 1622 |
});
|
1622 |
});
|
| 1623 |
};
|
1623 |
};
|
| 1624 |
const remove$5 = element => {
|
1624 |
const remove$4 = element => {
|
| 1625 |
const dom = element.dom;
|
1625 |
const dom = element.dom;
|
| 1626 |
if (dom.parentNode !== null) {
|
1626 |
if (dom.parentNode !== null) {
|
| 1627 |
dom.parentNode.removeChild(dom);
|
1627 |
dom.parentNode.removeChild(dom);
|
| 1628 |
}
|
1628 |
}
|
| 1629 |
};
|
1629 |
};
|
| 1630 |
const unwrap = wrapper => {
|
1630 |
const unwrap = wrapper => {
|
| 1631 |
const children = children$1(wrapper);
|
1631 |
const children = children$1(wrapper);
|
| 1632 |
if (children.length > 0) {
|
1632 |
if (children.length > 0) {
|
| 1633 |
after$3(wrapper, children);
|
1633 |
after$3(wrapper, children);
|
| 1634 |
}
|
1634 |
}
|
| 1635 |
remove$5(wrapper);
|
1635 |
remove$4(wrapper);
|
| Línea 1636... |
Línea 1636... |
| 1636 |
};
|
1636 |
};
|
| 1637 |
|
1637 |
|
| 1638 |
const fromHtml = (html, scope) => {
|
1638 |
const fromHtml = (html, scope) => {
|
| Línea 1751... |
Línea 1751... |
| 1751 |
if (win) {
|
1751 |
if (win) {
|
| 1752 |
win.scrollTo(x, y);
|
1752 |
win.scrollTo(x, y);
|
| 1753 |
}
|
1753 |
}
|
| 1754 |
};
|
1754 |
};
|
| 1755 |
const intoView = (element, alignToTop) => {
|
1755 |
const intoView = (element, alignToTop) => {
|
| 1756 |
const isSafari = detect$2().browser.isSafari();
|
1756 |
const isSafari = detect$1().browser.isSafari();
|
| 1757 |
if (isSafari && isFunction(element.dom.scrollIntoViewIfNeeded)) {
|
1757 |
if (isSafari && isFunction(element.dom.scrollIntoViewIfNeeded)) {
|
| 1758 |
element.dom.scrollIntoViewIfNeeded(false);
|
1758 |
element.dom.scrollIntoViewIfNeeded(false);
|
| 1759 |
} else {
|
1759 |
} else {
|
| 1760 |
element.dom.scrollIntoView(alignToTop);
|
1760 |
element.dom.scrollIntoView(alignToTop);
|
| 1761 |
}
|
1761 |
}
|
| 1762 |
};
|
1762 |
};
|
| Línea 1763... |
Línea 1763... |
| 1763 |
|
1763 |
|
| 1764 |
const get$4 = _win => {
|
1764 |
const get$4 = _win => {
|
| 1765 |
const win = _win === undefined ? window : _win;
|
1765 |
const win = _win === undefined ? window : _win;
|
| 1766 |
if (detect$2().browser.isFirefox()) {
|
1766 |
if (detect$1().browser.isFirefox()) {
|
| 1767 |
return Optional.none();
|
1767 |
return Optional.none();
|
| 1768 |
} else {
|
1768 |
} else {
|
| 1769 |
return Optional.from(win.visualViewport);
|
1769 |
return Optional.from(win.visualViewport);
|
| 1770 |
}
|
1770 |
}
|
| Línea 1801... |
Línea 1801... |
| 1801 |
return result;
|
1801 |
return result;
|
| 1802 |
};
|
1802 |
};
|
| Línea 1803... |
Línea 1803... |
| 1803 |
|
1803 |
|
| Línea 1804... |
Línea 1804... |
| 1804 |
const descendants = (scope, selector) => all(selector, scope);
|
1804 |
const descendants = (scope, selector) => all(selector, scope);
|
| - |
|
1805 |
|
| - |
|
1806 |
const ancestor$2 = (scope, predicate, isRoot) => ancestor$4(scope, predicate, isRoot).isSome();
|
| Línea 1805... |
Línea 1807... |
| 1805 |
|
1807 |
const sibling = (scope, predicate) => sibling$1(scope, predicate).isSome();
|
| 1806 |
const ancestor$2 = (scope, selector, isRoot) => ancestor$3(scope, selector, isRoot).isSome();
|
1808 |
const descendant = (scope, predicate) => descendant$2(scope, predicate).isSome();
|
| 1807 |
|
1809 |
|
| 1808 |
class DomTreeWalker {
|
1810 |
class DomTreeWalker {
|
| Línea 1872... |
Línea 1874... |
| 1872 |
}
|
1874 |
}
|
| 1873 |
return undefined;
|
1875 |
return undefined;
|
| 1874 |
}
|
1876 |
}
|
| 1875 |
}
|
1877 |
}
|
| Línea -... |
Línea 1878... |
| - |
|
1878 |
|
| - |
|
1879 |
const zeroWidth = '\uFEFF';
|
| - |
|
1880 |
const nbsp = '\xA0';
|
| - |
|
1881 |
const isZwsp$2 = char => char === zeroWidth;
|
| - |
|
1882 |
const removeZwsp = s => s.replace(/\uFEFF/g, '');
|
| - |
|
1883 |
|
| - |
|
1884 |
const whiteSpaceRegExp = /^[ \t\r\n]*$/;
|
| - |
|
1885 |
const isWhitespaceText = text => whiteSpaceRegExp.test(text);
|
| - |
|
1886 |
const isZwsp$1 = text => {
|
| - |
|
1887 |
for (const c of text) {
|
| - |
|
1888 |
if (!isZwsp$2(c)) {
|
| - |
|
1889 |
return false;
|
| - |
|
1890 |
}
|
| - |
|
1891 |
}
|
| - |
|
1892 |
return true;
|
| - |
|
1893 |
};
|
| - |
|
1894 |
const isCollapsibleWhitespace$1 = c => ' \f\t\x0B'.indexOf(c) !== -1;
|
| - |
|
1895 |
const isNewLineChar = c => c === '\n' || c === '\r';
|
| - |
|
1896 |
const isNewline = (text, idx) => idx < text.length && idx >= 0 ? isNewLineChar(text[idx]) : false;
|
| - |
|
1897 |
const normalize$4 = (text, tabSpaces = 4, isStartOfContent = true, isEndOfContent = true) => {
|
| - |
|
1898 |
const tabSpace = repeat(' ', tabSpaces);
|
| - |
|
1899 |
const normalizedText = text.replace(/\t/g, tabSpace);
|
| - |
|
1900 |
const result = foldl(normalizedText, (acc, c) => {
|
| - |
|
1901 |
if (isCollapsibleWhitespace$1(c) || c === nbsp) {
|
| - |
|
1902 |
if (acc.pcIsSpace || acc.str === '' && isStartOfContent || acc.str.length === normalizedText.length - 1 && isEndOfContent || isNewline(normalizedText, acc.str.length + 1)) {
|
| - |
|
1903 |
return {
|
| - |
|
1904 |
pcIsSpace: false,
|
| - |
|
1905 |
str: acc.str + nbsp
|
| - |
|
1906 |
};
|
| - |
|
1907 |
} else {
|
| - |
|
1908 |
return {
|
| - |
|
1909 |
pcIsSpace: true,
|
| - |
|
1910 |
str: acc.str + ' '
|
| - |
|
1911 |
};
|
| - |
|
1912 |
}
|
| - |
|
1913 |
} else {
|
| - |
|
1914 |
return {
|
| - |
|
1915 |
pcIsSpace: isNewLineChar(c),
|
| - |
|
1916 |
str: acc.str + c
|
| - |
|
1917 |
};
|
| - |
|
1918 |
}
|
| - |
|
1919 |
}, {
|
| - |
|
1920 |
pcIsSpace: false,
|
| - |
|
1921 |
str: ''
|
| - |
|
1922 |
});
|
| - |
|
1923 |
return result.str;
|
| - |
|
1924 |
};
|
| 1876 |
|
1925 |
|
| 1877 |
const isNodeType = type => {
|
1926 |
const isNodeType = type => {
|
| 1878 |
return node => {
|
1927 |
return node => {
|
| 1879 |
return !!node && node.nodeType === type;
|
1928 |
return !!node && node.nodeType === type;
|
| 1880 |
};
|
1929 |
};
|
| Línea 1918... |
Línea 1967... |
| 1918 |
const hasAttribute = attrName => {
|
1967 |
const hasAttribute = attrName => {
|
| 1919 |
return node => {
|
1968 |
return node => {
|
| 1920 |
return isElement$6(node) && node.hasAttribute(attrName);
|
1969 |
return isElement$6(node) && node.hasAttribute(attrName);
|
| 1921 |
};
|
1970 |
};
|
| 1922 |
};
|
1971 |
};
|
| 1923 |
const hasAttributeValue = (attrName, attrValue) => {
|
- |
|
| 1924 |
return node => {
|
- |
|
| 1925 |
return isElement$6(node) && node.getAttribute(attrName) === attrValue;
|
- |
|
| 1926 |
};
|
- |
|
| 1927 |
};
|
- |
|
| 1928 |
const isBogus$2 = node => isElement$6(node) && node.hasAttribute('data-mce-bogus');
|
1972 |
const isBogus$1 = node => isElement$6(node) && node.hasAttribute('data-mce-bogus');
|
| 1929 |
const isBogusAll$1 = node => isElement$6(node) && node.getAttribute('data-mce-bogus') === 'all';
|
1973 |
const isBogusAll = node => isElement$6(node) && node.getAttribute('data-mce-bogus') === 'all';
|
| 1930 |
const isTable$2 = node => isElement$6(node) && node.tagName === 'TABLE';
|
1974 |
const isTable$2 = node => isElement$6(node) && node.tagName === 'TABLE';
|
| 1931 |
const hasContentEditableState = value => {
|
1975 |
const hasContentEditableState = value => {
|
| 1932 |
return node => {
|
1976 |
return node => {
|
| 1933 |
if (isHTMLElement(node)) {
|
1977 |
if (isHTMLElement(node)) {
|
| 1934 |
if (node.contentEditable === value) {
|
1978 |
if (node.contentEditable === value) {
|
| Línea 1943... |
Línea 1987... |
| 1943 |
};
|
1987 |
};
|
| 1944 |
const isTextareaOrInput = matchNodeNames([
|
1988 |
const isTextareaOrInput = matchNodeNames([
|
| 1945 |
'textarea',
|
1989 |
'textarea',
|
| 1946 |
'input'
|
1990 |
'input'
|
| 1947 |
]);
|
1991 |
]);
|
| 1948 |
const isText$a = isNodeType(3);
|
1992 |
const isText$b = isNodeType(3);
|
| 1949 |
const isCData = isNodeType(4);
|
1993 |
const isCData = isNodeType(4);
|
| 1950 |
const isPi = isNodeType(7);
|
1994 |
const isPi = isNodeType(7);
|
| 1951 |
const isComment = isNodeType(8);
|
1995 |
const isComment = isNodeType(8);
|
| 1952 |
const isDocument$1 = isNodeType(9);
|
1996 |
const isDocument$1 = isNodeType(9);
|
| 1953 |
const isDocumentFragment = isNodeType(11);
|
1997 |
const isDocumentFragment = isNodeType(11);
|
| 1954 |
const isBr$6 = matchNodeName('br');
|
1998 |
const isBr$6 = matchNodeName('br');
|
| 1955 |
const isImg = matchNodeName('img');
|
1999 |
const isImg = matchNodeName('img');
|
| 1956 |
const isContentEditableTrue$3 = hasContentEditableState('true');
|
2000 |
const isContentEditableTrue$3 = hasContentEditableState('true');
|
| 1957 |
const isContentEditableFalse$b = hasContentEditableState('false');
|
2001 |
const isContentEditableFalse$b = hasContentEditableState('false');
|
| - |
|
2002 |
const isEditingHost = node => isHTMLElement(node) && node.isContentEditable && isNonNullable(node.parentElement) && !node.parentElement.isContentEditable;
|
| 1958 |
const isTableCell$3 = matchNodeNames([
|
2003 |
const isTableCell$3 = matchNodeNames([
|
| 1959 |
'td',
|
2004 |
'td',
|
| 1960 |
'th'
|
2005 |
'th'
|
| 1961 |
]);
|
2006 |
]);
|
| 1962 |
const isTableCellOrCaption = matchNodeNames([
|
2007 |
const isTableCellOrCaption = matchNodeNames([
|
| Línea 1972... |
Línea 2017... |
| 1972 |
]);
|
2017 |
]);
|
| 1973 |
const isListItem$2 = matchNodeName('li');
|
2018 |
const isListItem$2 = matchNodeName('li');
|
| 1974 |
const isDetails = matchNodeName('details');
|
2019 |
const isDetails = matchNodeName('details');
|
| 1975 |
const isSummary$1 = matchNodeName('summary');
|
2020 |
const isSummary$1 = matchNodeName('summary');
|
| Línea 1976... |
Línea -... |
| 1976 |
|
- |
|
| 1977 |
const zeroWidth = '\uFEFF';
|
- |
|
| 1978 |
const nbsp = '\xA0';
|
- |
|
| 1979 |
const isZwsp$2 = char => char === zeroWidth;
|
- |
|
| 1980 |
const removeZwsp = s => s.replace(/\uFEFF/g, '');
|
- |
|
| 1981 |
|
2021 |
|
| 1982 |
const NodeValue = (is, name) => {
|
- |
|
| 1983 |
const get = element => {
|
2022 |
const defaultOptionValues = {
|
| 1984 |
if (!is(element)) {
|
- |
|
| 1985 |
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
- |
|
| 1986 |
}
|
- |
|
| 1987 |
return getOption(element).getOr('');
|
- |
|
| 1988 |
};
|
- |
|
| 1989 |
const getOption = element => is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
- |
|
| 1990 |
const set = (element, value) => {
|
2023 |
skipBogus: true,
|
| 1991 |
if (!is(element)) {
|
- |
|
| 1992 |
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
- |
|
| 1993 |
}
|
2024 |
includeZwsp: false,
|
| 1994 |
element.dom.nodeValue = value;
|
- |
|
| 1995 |
};
|
- |
|
| 1996 |
return {
|
- |
|
| 1997 |
get,
|
- |
|
| 1998 |
getOption,
|
- |
|
| 1999 |
set
|
- |
|
| 2000 |
};
|
2025 |
checkRootAsContent: false
|
| 2001 |
};
|
- |
|
| 2002 |
|
- |
|
| 2003 |
const api$1 = NodeValue(isText$b, 'text');
|
- |
|
| 2004 |
const get$3 = element => api$1.get(element);
|
- |
|
| 2005 |
const getOption = element => api$1.getOption(element);
|
- |
|
| 2006 |
const set = (element, value) => api$1.set(element, value);
|
- |
|
| 2007 |
|
- |
|
| 2008 |
const tableCells = [
|
- |
|
| 2009 |
'td',
|
- |
|
| 2010 |
'th'
|
- |
|
| 2011 |
];
|
- |
|
| 2012 |
const tableSections = [
|
- |
|
| 2013 |
'thead',
|
- |
|
| 2014 |
'tbody',
|
- |
|
| 2015 |
'tfoot'
|
- |
|
| 2016 |
];
|
- |
|
| 2017 |
const textBlocks = [
|
- |
|
| 2018 |
'h1',
|
- |
|
| 2019 |
'h2',
|
- |
|
| 2020 |
'h3',
|
- |
|
| 2021 |
'h4',
|
- |
|
| 2022 |
'h5',
|
- |
|
| 2023 |
'h6',
|
- |
|
| 2024 |
'p',
|
- |
|
| 2025 |
'div',
|
- |
|
| 2026 |
'address',
|
- |
|
| 2027 |
'pre',
|
- |
|
| 2028 |
'form',
|
- |
|
| 2029 |
'blockquote',
|
- |
|
| 2030 |
'center',
|
- |
|
| 2031 |
'dir',
|
- |
|
| 2032 |
'fieldset',
|
- |
|
| 2033 |
'header',
|
- |
|
| 2034 |
'footer',
|
- |
|
| 2035 |
'article',
|
- |
|
| 2036 |
'section',
|
- |
|
| 2037 |
'hgroup',
|
- |
|
| 2038 |
'aside',
|
- |
|
| 2039 |
'nav',
|
- |
|
| 2040 |
'figure'
|
- |
|
| 2041 |
];
|
- |
|
| 2042 |
const listItems$1 = [
|
- |
|
| 2043 |
'li',
|
- |
|
| 2044 |
'dd',
|
- |
|
| 2045 |
'dt'
|
- |
|
| 2046 |
];
|
- |
|
| 2047 |
const lists = [
|
- |
|
| 2048 |
'ul',
|
- |
|
| 2049 |
'ol',
|
- |
|
| 2050 |
'dl'
|
- |
|
| 2051 |
];
|
- |
|
| 2052 |
const wsElements = [
|
- |
|
| 2053 |
'pre',
|
- |
|
| 2054 |
'script',
|
- |
|
| 2055 |
'textarea',
|
- |
|
| 2056 |
'style'
|
- |
|
| 2057 |
];
|
- |
|
| 2058 |
const lazyLookup = items => {
|
- |
|
| 2059 |
let lookup;
|
- |
|
| 2060 |
return node => {
|
- |
|
| 2061 |
lookup = lookup ? lookup : mapToObject(items, always);
|
- |
|
| 2062 |
return has$2(lookup, name(node));
|
- |
|
| 2063 |
};
|
- |
|
| 2064 |
};
|
- |
|
| 2065 |
const isTable$1 = node => name(node) === 'table';
|
- |
|
| 2066 |
const isBr$5 = node => isElement$7(node) && name(node) === 'br';
|
- |
|
| 2067 |
const isTextBlock$2 = lazyLookup(textBlocks);
|
- |
|
| 2068 |
const isList = lazyLookup(lists);
|
- |
|
| 2069 |
const isListItem$1 = lazyLookup(listItems$1);
|
- |
|
| 2070 |
const isTableSection = lazyLookup(tableSections);
|
- |
|
| 2071 |
const isTableCell$2 = lazyLookup(tableCells);
|
2026 |
};
|
| 2072 |
const isWsPreserveElement = lazyLookup(wsElements);
|
- |
|
| 2073 |
|
- |
|
| 2074 |
const getLastChildren$1 = elm => {
|
- |
|
| 2075 |
const children = [];
|
- |
|
| 2076 |
let rawNode = elm.dom;
|
- |
|
| 2077 |
while (rawNode) {
|
2027 |
const hasWhitespacePreserveParent = (node, rootNode, schema) => {
|
| 2078 |
children.push(SugarElement.fromDom(rawNode));
|
- |
|
| 2079 |
rawNode = rawNode.lastChild;
|
- |
|
| 2080 |
}
|
- |
|
| 2081 |
return children;
|
- |
|
| 2082 |
};
|
- |
|
| 2083 |
const removeTrailingBr = elm => {
|
2028 |
const rootElement = SugarElement.fromDom(rootNode);
|
| 2084 |
const allBrs = descendants(elm, 'br');
|
2029 |
const startNode = SugarElement.fromDom(node);
|
| 2085 |
const brs = filter$5(getLastChildren$1(elm).slice(-1), isBr$5);
|
- |
|
| 2086 |
if (allBrs.length === brs.length) {
|
- |
|
| 2087 |
each$e(brs, remove$5);
|
- |
|
| 2088 |
}
|
- |
|
| 2089 |
};
|
- |
|
| 2090 |
const createPaddingBr = () => {
|
2030 |
const whitespaceElements = schema.getWhitespaceElements();
|
| 2091 |
const br = SugarElement.fromTag('br');
|
2031 |
const predicate = node => has$2(whitespaceElements, name(node));
|
| 2092 |
set$3(br, 'data-mce-bogus', '1');
|
- |
|
| 2093 |
return br;
|
2032 |
return ancestor$2(startNode, predicate, curry(eq, rootElement));
|
| 2094 |
};
|
2033 |
};
|
| 2095 |
const fillWithPaddingBr = elm => {
|
- |
|
| 2096 |
empty(elm);
|
2034 |
const isNamedAnchor = node => {
|
| 2097 |
append$1(elm, createPaddingBr());
|
2035 |
return isElement$6(node) && node.nodeName === 'A' && !node.hasAttribute('href') && (node.hasAttribute('name') || node.hasAttribute('id'));
|
| 2098 |
};
|
2036 |
};
|
| 2099 |
const trimBlockTrailingBr = (elm, schema) => {
|
- |
|
| 2100 |
lastChild(elm).each(lastChild => {
|
- |
|
| 2101 |
prevSibling(lastChild).each(lastChildPrevSibling => {
|
2037 |
const isNonEmptyElement$1 = (node, schema) => {
|
| 2102 |
if (schema.isBlock(name(elm)) && isBr$5(lastChild) && schema.isBlock(name(lastChildPrevSibling))) {
|
- |
|
| 2103 |
remove$5(lastChild);
|
- |
|
| 2104 |
}
|
- |
|
| 2105 |
});
|
- |
|
| 2106 |
});
|
2038 |
return isElement$6(node) && has$2(schema.getNonEmptyElements(), node.nodeName);
|
| 2107 |
};
|
- |
|
| 2108 |
|
- |
|
| 2109 |
const ZWSP$1 = zeroWidth;
|
- |
|
| 2110 |
const isZwsp$1 = isZwsp$2;
|
- |
|
| 2111 |
const trim$2 = removeZwsp;
|
- |
|
| 2112 |
const insert$5 = editor => editor.insertContent(ZWSP$1, { preserve_zwsp: true });
|
- |
|
| 2113 |
|
- |
|
| 2114 |
const isElement$5 = isElement$6;
|
- |
|
| 2115 |
const isText$9 = isText$a;
|
- |
|
| 2116 |
const isCaretContainerBlock$1 = node => {
|
- |
|
| 2117 |
if (isText$9(node)) {
|
- |
|
| 2118 |
node = node.parentNode;
|
- |
|
| 2119 |
}
|
2039 |
};
|
| 2120 |
return isElement$5(node) && node.hasAttribute('data-mce-caret');
|
- |
|
| 2121 |
};
|
2040 |
const isBookmark = hasAttribute('data-mce-bookmark');
|
| 2122 |
const isCaretContainerInline = node => isText$9(node) && isZwsp$1(node.data);
|
2041 |
const hasNonEditableParent = node => parentElement(SugarElement.fromDom(node)).exists(parent => !isEditable$2(parent));
|
| 2123 |
const isCaretContainer$2 = node => isCaretContainerBlock$1(node) || isCaretContainerInline(node);
|
2042 |
const isWhitespace$1 = (node, rootNode, schema) => isWhitespaceText(node.data) && !hasWhitespacePreserveParent(node, rootNode, schema);
|
| 2124 |
const hasContent = node => node.firstChild !== node.lastChild || !isBr$6(node.firstChild);
|
2043 |
const isText$a = (node, rootNode, schema, options) => isText$b(node) && !isWhitespace$1(node, rootNode, schema) && (!options.includeZwsp || !isZwsp$1(node.data));
|
| 2125 |
const insertInline$1 = (node, before) => {
|
- |
|
| 2126 |
var _a;
|
- |
|
| 2127 |
const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;
|
2044 |
const isContentNode = (schema, node, rootNode, options) => {
|
| 2128 |
const textNode = doc.createTextNode(ZWSP$1);
|
- |
|
| 2129 |
const parentNode = node.parentNode;
|
- |
|
| 2130 |
if (!before) {
|
- |
|
| 2131 |
const sibling = node.nextSibling;
|
- |
|
| 2132 |
if (isText$9(sibling)) {
|
- |
|
| 2133 |
if (isCaretContainer$2(sibling)) {
|
- |
|
| 2134 |
return sibling;
|
2045 |
return isFunction(options.isContent) && options.isContent(node) || isNonEmptyElement$1(node, schema) || isBookmark(node) || isNamedAnchor(node) || isText$a(node, rootNode, schema, options) || isContentEditableFalse$b(node) || isContentEditableTrue$3(node) && hasNonEditableParent(node);
|
| 2135 |
}
|
2046 |
};
|
| 2136 |
if (startsWithCaretContainer$1(sibling)) {
|
- |
|
| 2137 |
sibling.splitText(1);
|
2047 |
const isEmptyNode = (schema, targetNode, opts) => {
|
| 2138 |
return sibling;
|
- |
|
| 2139 |
}
|
- |
|
| 2140 |
}
|
2048 |
const options = {
|
| 2141 |
if (node.nextSibling) {
|
- |
|
| 2142 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(textNode, node.nextSibling);
|
2049 |
...defaultOptionValues,
|
| 2143 |
} else {
|
- |
|
| 2144 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(textNode);
|
2050 |
...opts
|
| 2145 |
}
|
- |
|
| 2146 |
} else {
|
- |
|
| 2147 |
const sibling = node.previousSibling;
|
2051 |
};
|
| 2148 |
if (isText$9(sibling)) {
|
2052 |
if (options.checkRootAsContent) {
|
| 2149 |
if (isCaretContainer$2(sibling)) {
|
2053 |
if (isContentNode(schema, targetNode, targetNode, options)) {
|
| 2150 |
return sibling;
|
- |
|
| 2151 |
}
|
- |
|
| 2152 |
if (endsWithCaretContainer$1(sibling)) {
|
- |
|
| 2153 |
return sibling.splitText(sibling.data.length - 1);
|
- |
|
| 2154 |
}
|
2054 |
return false;
|
| 2155 |
}
|
- |
|
| 2156 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(textNode, node);
|
2055 |
}
|
| 2157 |
}
|
- |
|
| 2158 |
return textNode;
|
- |
|
| 2159 |
};
|
- |
|
| 2160 |
const isBeforeInline = pos => {
|
2056 |
}
|
| 2161 |
const container = pos.container();
|
- |
|
| 2162 |
if (!isText$a(container)) {
|
2057 |
let node = targetNode.firstChild;
|
| 2163 |
return false;
|
- |
|
| 2164 |
}
|
- |
|
| 2165 |
return container.data.charAt(pos.offset()) === ZWSP$1 || pos.isAtStart() && isCaretContainerInline(container.previousSibling);
|
- |
|
| 2166 |
};
|
- |
|
| 2167 |
const isAfterInline = pos => {
|
- |
|
| 2168 |
const container = pos.container();
|
2058 |
let brCount = 0;
|
| 2169 |
if (!isText$a(container)) {
|
2059 |
if (!node) {
|
| 2170 |
return false;
|
2060 |
return true;
|
| 2171 |
}
|
- |
|
| 2172 |
return container.data.charAt(pos.offset() - 1) === ZWSP$1 || pos.isAtEnd() && isCaretContainerInline(container.nextSibling);
|
- |
|
| 2173 |
};
|
2061 |
}
|
| 2174 |
const insertBlock = (blockName, node, before) => {
|
2062 |
const walker = new DomTreeWalker(node, targetNode);
|
| 2175 |
var _a;
|
- |
|
| 2176 |
const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;
|
2063 |
do {
|
| 2177 |
const blockNode = doc.createElement(blockName);
|
- |
|
| 2178 |
blockNode.setAttribute('data-mce-caret', before ? 'before' : 'after');
|
2064 |
if (options.skipBogus && isElement$6(node)) {
|
| 2179 |
blockNode.setAttribute('data-mce-bogus', 'all');
|
2065 |
const bogusValue = node.getAttribute('data-mce-bogus');
|
| 2180 |
blockNode.appendChild(createPaddingBr().dom);
|
2066 |
if (bogusValue) {
|
| 2181 |
const parentNode = node.parentNode;
|
- |
|
| 2182 |
if (!before) {
|
2067 |
node = walker.next(bogusValue === 'all');
|
| 2183 |
if (node.nextSibling) {
|
- |
|
| 2184 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(blockNode, node.nextSibling);
|
2068 |
continue;
|
| 2185 |
} else {
|
- |
|
| 2186 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(blockNode);
|
2069 |
}
|
| 2187 |
}
|
- |
|
| 2188 |
} else {
|
- |
|
| 2189 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(blockNode, node);
|
- |
|
| 2190 |
}
|
- |
|
| 2191 |
return blockNode;
|
- |
|
| 2192 |
};
|
- |
|
| 2193 |
const startsWithCaretContainer$1 = node => isText$9(node) && node.data[0] === ZWSP$1;
|
- |
|
| 2194 |
const endsWithCaretContainer$1 = node => isText$9(node) && node.data[node.data.length - 1] === ZWSP$1;
|
- |
|
| 2195 |
const trimBogusBr = elm => {
|
- |
|
| 2196 |
var _a;
|
- |
|
| 2197 |
const brs = elm.getElementsByTagName('br');
|
- |
|
| 2198 |
const lastBr = brs[brs.length - 1];
|
- |
|
| 2199 |
if (isBogus$2(lastBr)) {
|
- |
|
| 2200 |
(_a = lastBr.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(lastBr);
|
- |
|
| 2201 |
}
|
- |
|
| 2202 |
};
|
- |
|
| 2203 |
const showCaretContainerBlock = caretContainer => {
|
- |
|
| 2204 |
if (caretContainer && caretContainer.hasAttribute('data-mce-caret')) {
|
- |
|
| 2205 |
trimBogusBr(caretContainer);
|
- |
|
| 2206 |
caretContainer.removeAttribute('data-mce-caret');
|
- |
|
| 2207 |
caretContainer.removeAttribute('data-mce-bogus');
|
- |
|
| 2208 |
caretContainer.removeAttribute('style');
|
- |
|
| 2209 |
caretContainer.removeAttribute('data-mce-style');
|
- |
|
| 2210 |
caretContainer.removeAttribute('_moz_abspos');
|
- |
|
| 2211 |
return caretContainer;
|
- |
|
| 2212 |
}
|
- |
|
| 2213 |
return null;
|
- |
|
| 2214 |
};
|
- |
|
| 2215 |
const isRangeInCaretContainerBlock = range => isCaretContainerBlock$1(range.startContainer);
|
- |
|
| 2216 |
|
- |
|
| 2217 |
const isContentEditableTrue$2 = isContentEditableTrue$3;
|
- |
|
| 2218 |
const isContentEditableFalse$a = isContentEditableFalse$b;
|
- |
|
| 2219 |
const isBr$4 = isBr$6;
|
- |
|
| 2220 |
const isText$8 = isText$a;
|
- |
|
| 2221 |
const isInvalidTextElement = matchNodeNames([
|
- |
|
| 2222 |
'script',
|
- |
|
| 2223 |
'style',
|
- |
|
| 2224 |
'textarea'
|
- |
|
| 2225 |
]);
|
- |
|
| 2226 |
const isAtomicInline = matchNodeNames([
|
- |
|
| 2227 |
'img',
|
- |
|
| 2228 |
'input',
|
- |
|
| 2229 |
'textarea',
|
- |
|
| 2230 |
'hr',
|
- |
|
| 2231 |
'iframe',
|
- |
|
| 2232 |
'video',
|
- |
|
| 2233 |
'audio',
|
- |
|
| 2234 |
'object',
|
- |
|
| 2235 |
'embed'
|
- |
|
| 2236 |
]);
|
- |
|
| 2237 |
const isTable = matchNodeNames(['table']);
|
- |
|
| 2238 |
const isCaretContainer$1 = isCaretContainer$2;
|
- |
|
| 2239 |
const isCaretCandidate$3 = node => {
|
- |
|
| 2240 |
if (isCaretContainer$1(node)) {
|
- |
|
| 2241 |
return false;
|
- |
|
| 2242 |
}
|
2070 |
}
|
| 2243 |
if (isText$8(node)) {
|
- |
|
| 2244 |
return !isInvalidTextElement(node.parentNode);
|
- |
|
| 2245 |
}
|
- |
|
| 2246 |
return isAtomicInline(node) || isBr$4(node) || isTable(node) || isNonUiContentEditableFalse(node);
|
- |
|
| 2247 |
};
|
- |
|
| 2248 |
const isUnselectable = node => isElement$6(node) && node.getAttribute('unselectable') === 'true';
|
- |
|
| 2249 |
const isNonUiContentEditableFalse = node => !isUnselectable(node) && isContentEditableFalse$a(node);
|
2071 |
if (isComment(node)) {
|
| 2250 |
const isInEditable = (node, root) => {
|
- |
|
| 2251 |
for (let tempNode = node.parentNode; tempNode && tempNode !== root; tempNode = tempNode.parentNode) {
|
- |
|
| 2252 |
if (isNonUiContentEditableFalse(tempNode)) {
|
2072 |
node = walker.next(true);
|
| 2253 |
return false;
|
2073 |
continue;
|
| 2254 |
}
|
2074 |
}
|
| 2255 |
if (isContentEditableTrue$2(tempNode)) {
|
2075 |
if (isBr$6(node)) {
|
| - |
|
2076 |
brCount++;
|
| - |
|
2077 |
node = walker.next();
|
| 2256 |
return true;
|
2078 |
continue;
|
| 2257 |
}
|
- |
|
| 2258 |
}
|
- |
|
| 2259 |
return true;
|
- |
|
| 2260 |
};
|
- |
|
| 2261 |
const isAtomicContentEditableFalse = node => {
|
2079 |
}
|
| 2262 |
if (!isNonUiContentEditableFalse(node)) {
|
- |
|
| 2263 |
return false;
|
- |
|
| 2264 |
}
|
- |
|
| 2265 |
return !foldl(from(node.getElementsByTagName('*')), (result, elm) => {
|
- |
|
| 2266 |
return result || isContentEditableTrue$2(elm);
|
- |
|
| 2267 |
}, false);
|
- |
|
| 2268 |
};
|
- |
|
| 2269 |
const isAtomic$1 = node => isAtomicInline(node) || isAtomicContentEditableFalse(node);
|
- |
|
| 2270 |
const isEditableCaretCandidate$1 = (node, root) => isCaretCandidate$3(node) && isInEditable(node, root);
|
- |
|
| 2271 |
|
- |
|
| 2272 |
const whiteSpaceRegExp = /^[ \t\r\n]*$/;
|
- |
|
| 2273 |
const isWhitespaceText = text => whiteSpaceRegExp.test(text);
|
- |
|
| 2274 |
const isZwsp = text => {
|
- |
|
| 2275 |
for (const c of text) {
|
- |
|
| 2276 |
if (!isZwsp$2(c)) {
|
2080 |
if (isContentNode(schema, node, targetNode, options)) {
|
| 2277 |
return false;
|
2081 |
return false;
|
| - |
|
2082 |
}
|
| - |
|
2083 |
node = walker.next();
|
| - |
|
2084 |
} while (node);
|
| 2278 |
}
|
2085 |
return brCount <= 1;
|
| - |
|
2086 |
};
|
| - |
|
2087 |
const isEmpty$2 = (schema, elm, options) => {
|
| - |
|
2088 |
return isEmptyNode(schema, elm.dom, {
|
| 2279 |
}
|
2089 |
checkRootAsContent: true,
|
| - |
|
2090 |
...options
|
| 2280 |
return true;
|
2091 |
});
|
| 2281 |
};
|
- |
|
| 2282 |
const isCollapsibleWhitespace$1 = c => ' \f\t\x0B'.indexOf(c) !== -1;
|
2092 |
};
|
| 2283 |
const isNewLineChar = c => c === '\n' || c === '\r';
|
- |
|
| 2284 |
const isNewline = (text, idx) => idx < text.length && idx >= 0 ? isNewLineChar(text[idx]) : false;
|
- |
|
| 2285 |
const normalize$4 = (text, tabSpaces = 4, isStartOfContent = true, isEndOfContent = true) => {
|
- |
|
| 2286 |
const tabSpace = repeat(' ', tabSpaces);
|
- |
|
| 2287 |
const normalizedText = text.replace(/\t/g, tabSpace);
|
2093 |
const isContent$1 = (schema, node, options) => {
|
| 2288 |
const result = foldl(normalizedText, (acc, c) => {
|
2094 |
return isContentNode(schema, node, node, {
|
| 2289 |
if (isCollapsibleWhitespace$1(c) || c === nbsp) {
|
- |
|
| 2290 |
if (acc.pcIsSpace || acc.str === '' && isStartOfContent || acc.str.length === normalizedText.length - 1 && isEndOfContent || isNewline(normalizedText, acc.str.length + 1)) {
|
- |
|
| 2291 |
return {
|
- |
|
| 2292 |
pcIsSpace: false,
|
- |
|
| 2293 |
str: acc.str + nbsp
|
- |
|
| 2294 |
};
|
- |
|
| 2295 |
} else {
|
- |
|
| 2296 |
return {
|
- |
|
| 2297 |
pcIsSpace: true,
|
- |
|
| 2298 |
str: acc.str + ' '
|
- |
|
| 2299 |
};
|
- |
|
| 2300 |
}
|
- |
|
| 2301 |
} else {
|
2095 |
includeZwsp: defaultOptionValues.includeZwsp,
|
| 2302 |
return {
|
- |
|
| 2303 |
pcIsSpace: isNewLineChar(c),
|
- |
|
| 2304 |
str: acc.str + c
|
- |
|
| 2305 |
};
|
- |
|
| 2306 |
}
|
- |
|
| 2307 |
}, {
|
- |
|
| 2308 |
pcIsSpace: false,
|
- |
|
| 2309 |
str: ''
|
2096 |
...options
|
| 2310 |
});
|
- |
|
| 2311 |
return result.str;
|
2097 |
});
|
| Línea 2312... |
Línea 2098... |
| 2312 |
};
|
2098 |
};
|
| 2313 |
|
2099 |
|
| 2314 |
const hasWhitespacePreserveParent = (node, rootNode) => {
|
2100 |
const Cell = initial => {
|
| 2315 |
const rootElement = SugarElement.fromDom(rootNode);
|
2101 |
let value = initial;
|
| - |
|
2102 |
const get = () => {
|
| - |
|
2103 |
return value;
|
| - |
|
2104 |
};
|
| - |
|
2105 |
const set = v => {
|
| - |
|
2106 |
value = v;
|
| - |
|
2107 |
};
|
| - |
|
2108 |
return {
|
| - |
|
2109 |
get,
|
| 2316 |
const startNode = SugarElement.fromDom(node);
|
2110 |
set
|
| - |
|
2111 |
};
|
| 2317 |
return ancestor$2(startNode, 'pre,code', curry(eq, rootElement));
|
2112 |
};
|
| - |
|
2113 |
|
| 2318 |
};
|
2114 |
const singleton = doRevoke => {
|
| - |
|
2115 |
const subject = Cell(Optional.none());
|
| - |
|
2116 |
const revoke = () => subject.get().each(doRevoke);
|
| - |
|
2117 |
const clear = () => {
|
| - |
|
2118 |
revoke();
|
| - |
|
2119 |
subject.set(Optional.none());
|
| - |
|
2120 |
};
|
| - |
|
2121 |
const isSet = () => subject.get().isSome();
|
| - |
|
2122 |
const get = () => subject.get();
|
| - |
|
2123 |
const set = s => {
|
| - |
|
2124 |
revoke();
|
| - |
|
2125 |
subject.set(Optional.some(s));
|
| - |
|
2126 |
};
|
| - |
|
2127 |
return {
|
| - |
|
2128 |
clear,
|
| - |
|
2129 |
isSet,
|
| - |
|
2130 |
get,
|
| 2319 |
const isWhitespace$1 = (node, rootNode) => {
|
2131 |
set
|
| 2320 |
return isText$a(node) && isWhitespaceText(node.data) && !hasWhitespacePreserveParent(node, rootNode);
|
2132 |
};
|
| - |
|
2133 |
};
|
| 2321 |
};
|
2134 |
const repeatable = delay => {
|
| - |
|
2135 |
const intervalId = Cell(Optional.none());
|
| - |
|
2136 |
const revoke = () => intervalId.get().each(id => clearInterval(id));
|
| - |
|
2137 |
const clear = () => {
|
| - |
|
2138 |
revoke();
|
| - |
|
2139 |
intervalId.set(Optional.none());
|
| - |
|
2140 |
};
|
| - |
|
2141 |
const isSet = () => intervalId.get().isSome();
|
| - |
|
2142 |
const get = () => intervalId.get();
|
| - |
|
2143 |
const set = functionToRepeat => {
|
| - |
|
2144 |
revoke();
|
| - |
|
2145 |
intervalId.set(Optional.some(setInterval(functionToRepeat, delay)));
|
| - |
|
2146 |
};
|
| - |
|
2147 |
return {
|
| - |
|
2148 |
clear,
|
| - |
|
2149 |
isSet,
|
| - |
|
2150 |
get,
|
| 2322 |
const isNamedAnchor = node => {
|
2151 |
set
|
| 2323 |
return isElement$6(node) && node.nodeName === 'A' && !node.hasAttribute('href') && (node.hasAttribute('name') || node.hasAttribute('id'));
|
2152 |
};
|
| - |
|
2153 |
};
|
| 2324 |
};
|
2154 |
const value$2 = () => {
|
| - |
|
2155 |
const subject = singleton(noop);
|
| - |
|
2156 |
const on = f => subject.get().each(f);
|
| - |
|
2157 |
return {
|
| - |
|
2158 |
...subject,
|
| 2325 |
const isContent$1 = (node, rootNode) => {
|
2159 |
on
|
| - |
|
2160 |
};
|
| 2326 |
return isCaretCandidate$3(node) && !isWhitespace$1(node, rootNode) || isNamedAnchor(node) || isBookmark(node);
|
2161 |
};
|
| 2327 |
};
|
2162 |
|
| 2328 |
const isBookmark = hasAttribute('data-mce-bookmark');
|
- |
|
| 2329 |
const isBogus$1 = hasAttribute('data-mce-bogus');
|
- |
|
| 2330 |
const isBogusAll = hasAttributeValue('data-mce-bogus', 'all');
|
2163 |
const nodeNameToNamespaceType = name => {
|
| 2331 |
const hasNonEditableParent = node => parentElement(SugarElement.fromDom(node)).exists(parent => !isEditable$2(parent));
|
2164 |
const lowerCaseName = name.toLowerCase();
|
| 2332 |
const isEmptyNode = (targetNode, skipBogus) => {
|
2165 |
if (lowerCaseName === 'svg') {
|
| 2333 |
let brCount = 0;
|
2166 |
return 'svg';
|
| 2334 |
if (isContent$1(targetNode, targetNode)) {
|
2167 |
} else if (lowerCaseName === 'math') {
|
| 2335 |
return false;
|
- |
|
| 2336 |
} else {
|
- |
|
| 2337 |
let node = targetNode.firstChild;
|
2168 |
return 'math';
|
| 2338 |
if (!node) {
|
- |
|
| 2339 |
return true;
|
- |
|
| 2340 |
}
|
- |
|
| 2341 |
const walker = new DomTreeWalker(node, targetNode);
|
- |
|
| 2342 |
do {
|
- |
|
| 2343 |
if (skipBogus) {
|
- |
|
| 2344 |
if (isBogusAll(node)) {
|
- |
|
| 2345 |
node = walker.next(true);
|
- |
|
| 2346 |
continue;
|
- |
|
| 2347 |
}
|
- |
|
| 2348 |
if (isBogus$1(node)) {
|
- |
|
| 2349 |
node = walker.next();
|
- |
|
| 2350 |
continue;
|
- |
|
| 2351 |
}
|
- |
|
| 2352 |
}
|
- |
|
| 2353 |
if (isContentEditableTrue$3(node) && hasNonEditableParent(node)) {
|
- |
|
| 2354 |
return false;
|
- |
|
| 2355 |
}
|
- |
|
| 2356 |
if (isBr$6(node)) {
|
- |
|
| 2357 |
brCount++;
|
- |
|
| 2358 |
node = walker.next();
|
- |
|
| 2359 |
continue;
|
- |
|
| 2360 |
}
|
- |
|
| 2361 |
if (isContent$1(node, targetNode)) {
|
- |
|
| 2362 |
return false;
|
- |
|
| 2363 |
}
|
- |
|
| 2364 |
node = walker.next();
|
- |
|
| 2365 |
} while (node);
|
2169 |
} else {
|
| 2366 |
return brCount <= 1;
|
2170 |
return 'html';
|
| 2367 |
}
|
- |
|
| 2368 |
};
|
- |
|
| 2369 |
const isEmpty$2 = (elm, skipBogus = true) => isEmptyNode(elm.dom, skipBogus);
|
2171 |
}
|
| 2370 |
|
2172 |
};
|
| 2371 |
const isNonHtmlElementRootName = name => name.toLowerCase() === 'svg';
|
2173 |
const isNonHtmlElementRootName = name => nodeNameToNamespaceType(name) !== 'html';
|
| 2372 |
const isNonHtmlElementRoot = node => isNonHtmlElementRootName(node.nodeName);
|
2174 |
const isNonHtmlElementRoot = node => isNonHtmlElementRootName(node.nodeName);
|
| - |
|
2175 |
const toScopeType = node => nodeNameToNamespaceType(node.nodeName);
|
| - |
|
2176 |
const namespaceElements = [
|
| - |
|
2177 |
'svg',
|
| 2373 |
const toScopeType = node => (node === null || node === void 0 ? void 0 : node.nodeName) === 'svg' ? 'svg' : 'html';
|
2178 |
'math'
|
| 2374 |
const namespaceElements = ['svg'];
|
2179 |
];
|
| 2375 |
const createNamespaceTracker = () => {
|
2180 |
const createNamespaceTracker = () => {
|
| 2376 |
let scopes = [];
|
2181 |
const currentScope = value$2();
|
| 2377 |
const peek = () => scopes[scopes.length - 1];
|
2182 |
const current = () => currentScope.get().map(toScopeType).getOr('html');
|
| 2378 |
const track = node => {
|
2183 |
const track = node => {
|
| - |
|
2184 |
if (isNonHtmlElementRoot(node)) {
|
| - |
|
2185 |
currentScope.set(node);
|
| 2379 |
if (isNonHtmlElementRoot(node)) {
|
2186 |
} else if (currentScope.get().exists(scopeNode => !scopeNode.contains(node))) {
|
| 2380 |
scopes.push(node);
|
- |
|
| 2381 |
}
|
- |
|
| 2382 |
let currentScope = peek();
|
- |
|
| 2383 |
if (currentScope && !currentScope.contains(node)) {
|
- |
|
| 2384 |
scopes.pop();
|
- |
|
| 2385 |
currentScope = peek();
|
2187 |
currentScope.clear();
|
| 2386 |
}
|
2188 |
}
|
| 2387 |
return toScopeType(currentScope);
|
- |
|
| 2388 |
};
|
2189 |
return current();
|
| 2389 |
const current = () => toScopeType(peek());
|
2190 |
};
|
| 2390 |
const reset = () => {
|
2191 |
const reset = () => {
|
| 2391 |
scopes = [];
|
2192 |
currentScope.clear();
|
| 2392 |
};
|
2193 |
};
|
| 2393 |
return {
|
2194 |
return {
|
| 2394 |
track,
|
2195 |
track,
|
| Línea 2398... |
Línea 2199... |
| 2398 |
};
|
2199 |
};
|
| Línea 2399... |
Línea 2200... |
| 2399 |
|
2200 |
|
| 2400 |
const transparentBlockAttr = 'data-mce-block';
|
2201 |
const transparentBlockAttr = 'data-mce-block';
|
| 2401 |
const elementNames = map => filter$5(keys(map), key => !/[A-Z]/.test(key));
|
2202 |
const elementNames = map => filter$5(keys(map), key => !/[A-Z]/.test(key));
|
| - |
|
2203 |
const makeSelectorFromSchemaMap = map => map$3(elementNames(map), name => {
|
| 2402 |
const makeSelectorFromSchemaMap = map => map$3(elementNames(map), name => {
|
2204 |
const escapedName = CSS.escape(name);
|
| 2403 |
return `${ name }:` + map$3(namespaceElements, ns => `not(${ ns } ${ name })`).join(':');
|
2205 |
return `${ escapedName }:` + map$3(namespaceElements, ns => `not(${ ns } ${ escapedName })`).join(':');
|
| 2404 |
}).join(',');
|
2206 |
}).join(',');
|
| 2405 |
const updateTransparent = (blocksSelector, transparent) => {
|
2207 |
const updateTransparent = (blocksSelector, transparent) => {
|
| 2406 |
if (isNonNullable(transparent.querySelector(blocksSelector))) {
|
2208 |
if (isNonNullable(transparent.querySelector(blocksSelector))) {
|
| 2407 |
transparent.setAttribute(transparentBlockAttr, 'true');
|
2209 |
transparent.setAttribute(transparentBlockAttr, 'true');
|
| Línea 2417... |
Línea 2219... |
| 2417 |
const updateBlockStateOnChildren = (schema, scope) => {
|
2219 |
const updateBlockStateOnChildren = (schema, scope) => {
|
| 2418 |
const transparentSelector = makeSelectorFromSchemaMap(schema.getTransparentElements());
|
2220 |
const transparentSelector = makeSelectorFromSchemaMap(schema.getTransparentElements());
|
| 2419 |
const blocksSelector = makeSelectorFromSchemaMap(schema.getBlockElements());
|
2221 |
const blocksSelector = makeSelectorFromSchemaMap(schema.getBlockElements());
|
| 2420 |
return filter$5(scope.querySelectorAll(transparentSelector), transparent => updateTransparent(blocksSelector, transparent));
|
2222 |
return filter$5(scope.querySelectorAll(transparentSelector), transparent => updateTransparent(blocksSelector, transparent));
|
| 2421 |
};
|
2223 |
};
|
| 2422 |
const trimEdge = (el, leftSide) => {
|
2224 |
const trimEdge = (schema, el, leftSide) => {
|
| 2423 |
var _a;
|
2225 |
var _a;
|
| 2424 |
const childPropertyName = leftSide ? 'lastChild' : 'firstChild';
|
2226 |
const childPropertyName = leftSide ? 'lastChild' : 'firstChild';
|
| 2425 |
for (let child = el[childPropertyName]; child; child = child[childPropertyName]) {
|
2227 |
for (let child = el[childPropertyName]; child; child = child[childPropertyName]) {
|
| 2426 |
if (isEmpty$2(SugarElement.fromDom(child))) {
|
2228 |
if (isEmptyNode(schema, child, { checkRootAsContent: true })) {
|
| 2427 |
(_a = child.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
2229 |
(_a = child.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
| 2428 |
return;
|
2230 |
return;
|
| 2429 |
}
|
2231 |
}
|
| 2430 |
}
|
2232 |
}
|
| 2431 |
};
|
2233 |
};
|
| 2432 |
const split$2 = (parentElm, splitElm) => {
|
2234 |
const split$2 = (schema, parentElm, splitElm) => {
|
| 2433 |
const range = document.createRange();
|
2235 |
const range = document.createRange();
|
| 2434 |
const parentNode = parentElm.parentNode;
|
2236 |
const parentNode = parentElm.parentNode;
|
| 2435 |
if (parentNode) {
|
2237 |
if (parentNode) {
|
| 2436 |
range.setStartBefore(parentElm);
|
2238 |
range.setStartBefore(parentElm);
|
| 2437 |
range.setEndBefore(splitElm);
|
2239 |
range.setEndBefore(splitElm);
|
| 2438 |
const beforeFragment = range.extractContents();
|
2240 |
const beforeFragment = range.extractContents();
|
| 2439 |
trimEdge(beforeFragment, true);
|
2241 |
trimEdge(schema, beforeFragment, true);
|
| 2440 |
range.setStartAfter(splitElm);
|
2242 |
range.setStartAfter(splitElm);
|
| 2441 |
range.setEndAfter(parentElm);
|
2243 |
range.setEndAfter(parentElm);
|
| 2442 |
const afterFragment = range.extractContents();
|
2244 |
const afterFragment = range.extractContents();
|
| 2443 |
trimEdge(afterFragment, false);
|
2245 |
trimEdge(schema, afterFragment, false);
|
| 2444 |
if (!isEmpty$2(SugarElement.fromDom(beforeFragment))) {
|
2246 |
if (!isEmptyNode(schema, beforeFragment, { checkRootAsContent: true })) {
|
| 2445 |
parentNode.insertBefore(beforeFragment, parentElm);
|
2247 |
parentNode.insertBefore(beforeFragment, parentElm);
|
| 2446 |
}
|
2248 |
}
|
| 2447 |
if (!isEmpty$2(SugarElement.fromDom(splitElm))) {
|
2249 |
if (!isEmptyNode(schema, splitElm, { checkRootAsContent: true })) {
|
| 2448 |
parentNode.insertBefore(splitElm, parentElm);
|
2250 |
parentNode.insertBefore(splitElm, parentElm);
|
| 2449 |
}
|
2251 |
}
|
| 2450 |
if (!isEmpty$2(SugarElement.fromDom(afterFragment))) {
|
2252 |
if (!isEmptyNode(schema, afterFragment, { checkRootAsContent: true })) {
|
| 2451 |
parentNode.insertBefore(afterFragment, parentElm);
|
2253 |
parentNode.insertBefore(afterFragment, parentElm);
|
| 2452 |
}
|
2254 |
}
|
| 2453 |
parentNode.removeChild(parentElm);
|
2255 |
parentNode.removeChild(parentElm);
|
| 2454 |
}
|
2256 |
}
|
| 2455 |
};
|
2257 |
};
|
| Línea 2463... |
Línea 2265... |
| 2463 |
const invalidChildren = children(transparentBlock, el => isBlock(el) && !schema.isValidChild(name(parentBlock), name(el)));
|
2265 |
const invalidChildren = children(transparentBlock, el => isBlock(el) && !schema.isValidChild(name(parentBlock), name(el)));
|
| 2464 |
if (invalidChildren.length > 0) {
|
2266 |
if (invalidChildren.length > 0) {
|
| 2465 |
const stateScope = parentElement(parentBlock);
|
2267 |
const stateScope = parentElement(parentBlock);
|
| 2466 |
each$e(invalidChildren, child => {
|
2268 |
each$e(invalidChildren, child => {
|
| 2467 |
ancestor$4(child, isBlock, isRoot).each(parentBlock => {
|
2269 |
ancestor$4(child, isBlock, isRoot).each(parentBlock => {
|
| 2468 |
split$2(parentBlock.dom, child.dom);
|
2270 |
split$2(schema, parentBlock.dom, child.dom);
|
| 2469 |
});
|
2271 |
});
|
| 2470 |
});
|
2272 |
});
|
| 2471 |
stateScope.each(scope => updateBlockStateOnChildren(schema, scope.dom));
|
2273 |
stateScope.each(scope => updateBlockStateOnChildren(schema, scope.dom));
|
| 2472 |
}
|
2274 |
}
|
| 2473 |
});
|
2275 |
});
|
| Línea 2504... |
Línea 2306... |
| 2504 |
const isTransparentElement = (schema, node) => isElement$6(node) && isTransparentElementName(schema, node.nodeName);
|
2306 |
const isTransparentElement = (schema, node) => isElement$6(node) && isTransparentElementName(schema, node.nodeName);
|
| 2505 |
const isTransparentBlock = (schema, node) => isTransparentElement(schema, node) && hasBlockAttr(node);
|
2307 |
const isTransparentBlock = (schema, node) => isTransparentElement(schema, node) && hasBlockAttr(node);
|
| 2506 |
const isTransparentInline = (schema, node) => isTransparentElement(schema, node) && !hasBlockAttr(node);
|
2308 |
const isTransparentInline = (schema, node) => isTransparentElement(schema, node) && !hasBlockAttr(node);
|
| 2507 |
const isTransparentAstBlock = (schema, node) => node.type === 1 && isTransparentElementName(schema, node.name) && isString(node.attr(transparentBlockAttr));
|
2309 |
const isTransparentAstBlock = (schema, node) => node.type === 1 && isTransparentElementName(schema, node.name) && isString(node.attr(transparentBlockAttr));
|
| Línea 2508... |
Línea 2310... |
| 2508 |
|
2310 |
|
| 2509 |
const browser$2 = detect$2().browser;
|
2311 |
const browser$2 = detect$1().browser;
|
| 2510 |
const firstElement = nodes => find$2(nodes, isElement$7);
|
2312 |
const firstElement = nodes => find$2(nodes, isElement$7);
|
| 2511 |
const getTableCaptionDeltaY = elm => {
|
2313 |
const getTableCaptionDeltaY = elm => {
|
| 2512 |
if (browser$2.isFirefox() && name(elm) === 'table') {
|
2314 |
if (browser$2.isFirefox() && name(elm) === 'table') {
|
| 2513 |
return firstElement(children$1(elm)).filter(elm => {
|
2315 |
return firstElement(children$1(elm)).filter(elm => {
|
| Línea 2574... |
Línea 2376... |
| 2574 |
const addStyle = element => {
|
2376 |
const addStyle = element => {
|
| 2575 |
append$1(getStyleContainer(edos), element);
|
2377 |
append$1(getStyleContainer(edos), element);
|
| 2576 |
};
|
2378 |
};
|
| 2577 |
const removeStyle = id => {
|
2379 |
const removeStyle = id => {
|
| 2578 |
const styleContainer = getStyleContainer(edos);
|
2380 |
const styleContainer = getStyleContainer(edos);
|
| 2579 |
descendant$1(styleContainer, '#' + id).each(remove$5);
|
2381 |
descendant$1(styleContainer, '#' + id).each(remove$4);
|
| 2580 |
};
|
2382 |
};
|
| 2581 |
const getOrCreateState = url => get$a(loadedStates, url).getOrThunk(() => ({
|
2383 |
const getOrCreateState = url => get$a(loadedStates, url).getOrThunk(() => ({
|
| 2582 |
id: 'mce-u' + idCount++,
|
2384 |
id: 'mce-u' + idCount++,
|
| 2583 |
passed: [],
|
2385 |
passed: [],
|
| 2584 |
failed: [],
|
2386 |
failed: [],
|
| Línea 2626... |
Línea 2428... |
| 2626 |
rel: 'stylesheet',
|
2428 |
rel: 'stylesheet',
|
| 2627 |
type: 'text/css',
|
2429 |
type: 'text/css',
|
| 2628 |
id: state.id
|
2430 |
id: state.id
|
| 2629 |
});
|
2431 |
});
|
| 2630 |
if (settings.contentCssCors) {
|
2432 |
if (settings.contentCssCors) {
|
| 2631 |
set$3(linkElem, 'crossOrigin', 'anonymous');
|
2433 |
set$4(linkElem, 'crossOrigin', 'anonymous');
|
| 2632 |
}
|
2434 |
}
|
| 2633 |
if (settings.referrerPolicy) {
|
2435 |
if (settings.referrerPolicy) {
|
| 2634 |
set$3(linkElem, 'referrerpolicy', settings.referrerPolicy);
|
2436 |
set$4(linkElem, 'referrerpolicy', settings.referrerPolicy);
|
| 2635 |
}
|
2437 |
}
|
| 2636 |
link = linkElem.dom;
|
2438 |
link = linkElem.dom;
|
| 2637 |
link.onload = passed;
|
2439 |
link.onload = passed;
|
| 2638 |
link.onerror = failed;
|
2440 |
link.onerror = failed;
|
| 2639 |
addStyle(linkElem);
|
2441 |
addStyle(linkElem);
|
| 2640 |
set$3(linkElem, 'href', urlWithSuffix);
|
2442 |
set$4(linkElem, 'href', urlWithSuffix);
|
| 2641 |
});
|
2443 |
});
|
| 2642 |
const loadRawCss = (key, css) => {
|
2444 |
const loadRawCss = (key, css) => {
|
| 2643 |
const state = getOrCreateState(key);
|
2445 |
const state = getOrCreateState(key);
|
| 2644 |
loadedStates[key] = state;
|
2446 |
loadedStates[key] = state;
|
| 2645 |
state.count++;
|
2447 |
state.count++;
|
| 2646 |
const styleElem = SugarElement.fromTag('style', doc.dom);
|
2448 |
const styleElem = SugarElement.fromTag('style', doc.dom);
|
| 2647 |
setAll$1(styleElem, {
|
2449 |
setAll$1(styleElem, {
|
| 2648 |
rel: 'stylesheet',
|
2450 |
'rel': 'stylesheet',
|
| 2649 |
type: 'text/css',
|
2451 |
'type': 'text/css',
|
| 2650 |
id: state.id
|
2452 |
'id': state.id,
|
| - |
|
2453 |
'data-mce-key': key
|
| 2651 |
});
|
2454 |
});
|
| 2652 |
styleElem.dom.innerHTML = css;
|
2455 |
styleElem.dom.innerHTML = css;
|
| 2653 |
addStyle(styleElem);
|
2456 |
addStyle(styleElem);
|
| 2654 |
};
|
2457 |
};
|
| 2655 |
const loadAll = urls => {
|
2458 |
const loadAll = urls => {
|
| Línea 2697... |
Línea 2500... |
| 2697 |
_setReferrerPolicy,
|
2500 |
_setReferrerPolicy,
|
| 2698 |
_setContentCssCors
|
2501 |
_setContentCssCors
|
| 2699 |
};
|
2502 |
};
|
| 2700 |
};
|
2503 |
};
|
| Línea 2701... |
Línea 2504... |
| 2701 |
|
2504 |
|
| 2702 |
const create$d = () => {
|
2505 |
const create$c = () => {
|
| 2703 |
const map = new WeakMap();
|
2506 |
const map = new WeakMap();
|
| 2704 |
const forElement = (referenceElement, settings) => {
|
2507 |
const forElement = (referenceElement, settings) => {
|
| 2705 |
const root = getRootNode(referenceElement);
|
2508 |
const root = getRootNode(referenceElement);
|
| 2706 |
const rootDom = root.dom;
|
2509 |
const rootDom = root.dom;
|
| Línea 2710... |
Línea 2513... |
| 2710 |
return sl;
|
2513 |
return sl;
|
| 2711 |
});
|
2514 |
});
|
| 2712 |
};
|
2515 |
};
|
| 2713 |
return { forElement };
|
2516 |
return { forElement };
|
| 2714 |
};
|
2517 |
};
|
| 2715 |
const instance = create$d();
|
2518 |
const instance = create$c();
|
| Línea 2716... |
Línea 2519... |
| 2716 |
|
2519 |
|
| 2717 |
const isSpan = node => node.nodeName.toLowerCase() === 'span';
|
2520 |
const isSpan = node => node.nodeName.toLowerCase() === 'span';
|
| 2718 |
const isInlineContent = (node, root, schema) => isNonNullable(node) && (isContent$1(node, root) || schema.isInline(node.nodeName.toLowerCase()));
|
2521 |
const isInlineContent = (node, schema) => isNonNullable(node) && (isContent$1(schema, node) || schema.isInline(node.nodeName.toLowerCase()));
|
| 2719 |
const surroundedByInlineContent = (node, root, schema) => {
|
2522 |
const surroundedByInlineContent = (node, root, schema) => {
|
| 2720 |
const prev = new DomTreeWalker(node, root).prev(false);
|
2523 |
const prev = new DomTreeWalker(node, root).prev(false);
|
| 2721 |
const next = new DomTreeWalker(node, root).next(false);
|
2524 |
const next = new DomTreeWalker(node, root).next(false);
|
| 2722 |
const prevIsInline = isUndefined(prev) || isInlineContent(prev, root, schema);
|
2525 |
const prevIsInline = isUndefined(prev) || isInlineContent(prev, schema);
|
| 2723 |
const nextIsInline = isUndefined(next) || isInlineContent(next, root, schema);
|
2526 |
const nextIsInline = isUndefined(next) || isInlineContent(next, schema);
|
| 2724 |
return prevIsInline && nextIsInline;
|
2527 |
return prevIsInline && nextIsInline;
|
| 2725 |
};
|
2528 |
};
|
| 2726 |
const isBookmarkNode$2 = node => isSpan(node) && node.getAttribute('data-mce-type') === 'bookmark';
|
2529 |
const isBookmarkNode$2 = node => isSpan(node) && node.getAttribute('data-mce-type') === 'bookmark';
|
| 2727 |
const isKeepTextNode = (node, root, schema) => isText$a(node) && node.data.length > 0 && surroundedByInlineContent(node, root, schema);
|
2530 |
const isKeepTextNode = (node, root, schema) => isText$b(node) && node.data.length > 0 && surroundedByInlineContent(node, root, schema);
|
| 2728 |
const isKeepElement = node => isElement$6(node) ? node.childNodes.length > 0 : false;
|
2531 |
const isKeepElement = node => isElement$6(node) ? node.childNodes.length > 0 : false;
|
| 2729 |
const isDocument = node => isDocumentFragment(node) || isDocument$1(node);
|
2532 |
const isDocument = node => isDocumentFragment(node) || isDocument$1(node);
|
| 2730 |
const trimNode = (dom, node, schema, root) => {
|
2533 |
const trimNode = (dom, node, schema, root) => {
|
| 2731 |
var _a;
|
2534 |
var _a;
|
| Línea 2741... |
Línea 2544... |
| 2741 |
const currentChildren = node.childNodes;
|
2544 |
const currentChildren = node.childNodes;
|
| 2742 |
if (currentChildren.length === 1 && isBookmarkNode$2(currentChildren[0])) {
|
2545 |
if (currentChildren.length === 1 && isBookmarkNode$2(currentChildren[0])) {
|
| 2743 |
(_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(currentChildren[0], node);
|
2546 |
(_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(currentChildren[0], node);
|
| 2744 |
}
|
2547 |
}
|
| 2745 |
}
|
2548 |
}
|
| 2746 |
if (!isDocument(node) && !isContent$1(node, rootNode) && !isKeepElement(node) && !isKeepTextNode(node, rootNode, schema)) {
|
2549 |
if (!isDocument(node) && !isContent$1(schema, node) && !isKeepElement(node) && !isKeepTextNode(node, rootNode, schema)) {
|
| 2747 |
dom.remove(node);
|
2550 |
dom.remove(node);
|
| 2748 |
}
|
2551 |
}
|
| 2749 |
return node;
|
2552 |
return node;
|
| 2750 |
};
|
2553 |
};
|
| Línea 2899... |
Línea 2702... |
| 2899 |
const split$1 = (items, delim) => {
|
2702 |
const split$1 = (items, delim) => {
|
| 2900 |
items = Tools.trim(items);
|
2703 |
items = Tools.trim(items);
|
| 2901 |
return items ? items.split(delim || ' ') : [];
|
2704 |
return items ? items.split(delim || ' ') : [];
|
| 2902 |
};
|
2705 |
};
|
| 2903 |
const patternToRegExp = str => new RegExp('^' + str.replace(/([?+*])/g, '.$1') + '$');
|
2706 |
const patternToRegExp = str => new RegExp('^' + str.replace(/([?+*])/g, '.$1') + '$');
|
| - |
|
2707 |
const isRegExp$1 = obj => isObject(obj) && obj.source && Object.prototype.toString.call(obj) === '[object RegExp]';
|
| - |
|
2708 |
const deepCloneElementRule = obj => {
|
| - |
|
2709 |
const helper = value => {
|
| - |
|
2710 |
if (isArray$1(value)) {
|
| - |
|
2711 |
return map$3(value, helper);
|
| - |
|
2712 |
} else if (isRegExp$1(value)) {
|
| - |
|
2713 |
return new RegExp(value.source, value.flags);
|
| - |
|
2714 |
} else if (isObject(value)) {
|
| - |
|
2715 |
return map$2(value, helper);
|
| - |
|
2716 |
} else {
|
| - |
|
2717 |
return value;
|
| - |
|
2718 |
}
|
| - |
|
2719 |
};
|
| - |
|
2720 |
return helper(obj);
|
| - |
|
2721 |
};
|
| Línea 2904... |
Línea 2722... |
| 2904 |
|
2722 |
|
| 2905 |
const parseCustomElementsRules = value => {
|
2723 |
const parseCustomElementsRules = value => {
|
| 2906 |
const customElementRegExp = /^(~)?(.+)$/;
|
2724 |
const customElementRegExp = /^(~)?(.+)$/;
|
| 2907 |
return bind$3(split$1(value, ','), rule => {
|
2725 |
return bind$3(split$1(value, ','), rule => {
|
| 2908 |
const matches = customElementRegExp.exec(rule);
|
2726 |
const matches = customElementRegExp.exec(rule);
|
| 2909 |
if (matches) {
|
2727 |
if (matches) {
|
| 2910 |
const inline = matches[1] === '~';
|
2728 |
const inline = matches[1] === '~';
|
| 2911 |
const cloneName = inline ? 'span' : 'div';
|
2729 |
const cloneName = inline ? 'span' : 'div';
|
| 2912 |
const name = matches[2];
|
2730 |
const name = matches[2];
|
| 2913 |
return [{
|
- |
|
| 2914 |
inline,
|
2731 |
return [{
|
| 2915 |
cloneName,
|
2732 |
cloneName,
|
| 2916 |
name
|
2733 |
name
|
| 2917 |
}];
|
2734 |
}];
|
| 2918 |
} else {
|
2735 |
} else {
|
| 2919 |
return [];
|
2736 |
return [];
|
| 2920 |
}
|
2737 |
}
|
| 2921 |
});
|
2738 |
});
|
| Línea -... |
Línea 2739... |
| - |
|
2739 |
};
|
| - |
|
2740 |
|
| - |
|
2741 |
const getGlobalAttributeSet = type => {
|
| - |
|
2742 |
return Object.freeze([
|
| - |
|
2743 |
'id',
|
| - |
|
2744 |
'accesskey',
|
| - |
|
2745 |
'class',
|
| - |
|
2746 |
'dir',
|
| - |
|
2747 |
'lang',
|
| - |
|
2748 |
'style',
|
| - |
|
2749 |
'tabindex',
|
| - |
|
2750 |
'title',
|
| - |
|
2751 |
'role',
|
| - |
|
2752 |
...type !== 'html4' ? [
|
| - |
|
2753 |
'contenteditable',
|
| - |
|
2754 |
'contextmenu',
|
| - |
|
2755 |
'draggable',
|
| - |
|
2756 |
'dropzone',
|
| - |
|
2757 |
'hidden',
|
| - |
|
2758 |
'spellcheck',
|
| - |
|
2759 |
'translate',
|
| - |
|
2760 |
'itemprop',
|
| - |
|
2761 |
'itemscope',
|
| - |
|
2762 |
'itemtype'
|
| - |
|
2763 |
] : [],
|
| - |
|
2764 |
...type !== 'html5-strict' ? ['xml:lang'] : []
|
| - |
|
2765 |
]);
|
| 2922 |
};
|
2766 |
};
|
| 2923 |
|
2767 |
|
| 2924 |
const getElementSetsAsStrings = type => {
|
2768 |
const getElementSetsAsStrings = type => {
|
| 2925 |
let globalAttributes, blockContent;
|
- |
|
| 2926 |
let phrasingContent;
|
2769 |
let blockContent;
|
| 2927 |
globalAttributes = 'id accesskey class dir lang style tabindex title role';
|
2770 |
let phrasingContent;
|
| 2928 |
blockContent = 'address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul';
|
2771 |
blockContent = 'address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul';
|
| 2929 |
phrasingContent = 'a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd ' + 'label map noscript object q s samp script select small span strong sub sup ' + 'textarea u var #text #comment';
|
2772 |
phrasingContent = 'a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd ' + 'label map noscript object q s samp script select small span strong sub sup ' + 'textarea u var #text #comment';
|
| 2930 |
if (type !== 'html4') {
|
- |
|
| 2931 |
const transparentContent = 'a ins del canvas map';
|
2773 |
if (type !== 'html4') {
|
| 2932 |
globalAttributes += ' contenteditable contextmenu draggable dropzone ' + 'hidden spellcheck translate';
|
2774 |
const transparentContent = 'a ins del canvas map';
|
| 2933 |
blockContent += ' article aside details dialog figure main header footer hgroup section nav ' + transparentContent;
|
2775 |
blockContent += ' article aside details dialog figure main header footer hgroup section nav ' + transparentContent;
|
| 2934 |
phrasingContent += ' audio canvas command datalist mark meter output picture ' + 'progress time wbr video ruby bdi keygen svg';
|
2776 |
phrasingContent += ' audio canvas command data datalist mark meter output picture ' + 'progress time wbr video ruby bdi keygen svg';
|
| 2935 |
}
|
- |
|
| 2936 |
if (type !== 'html5-strict') {
|
2777 |
}
|
| 2937 |
globalAttributes += ' xml:lang';
|
2778 |
if (type !== 'html5-strict') {
|
| 2938 |
const html4PhrasingContent = 'acronym applet basefont big font strike tt';
|
2779 |
const html4PhrasingContent = 'acronym applet basefont big font strike tt';
|
| 2939 |
phrasingContent = [
|
2780 |
phrasingContent = [
|
| 2940 |
phrasingContent,
|
2781 |
phrasingContent,
|
| Línea 2949... |
Línea 2790... |
| 2949 |
const flowContent = [
|
2790 |
const flowContent = [
|
| 2950 |
blockContent,
|
2791 |
blockContent,
|
| 2951 |
phrasingContent
|
2792 |
phrasingContent
|
| 2952 |
].join(' ');
|
2793 |
].join(' ');
|
| 2953 |
return {
|
2794 |
return {
|
| 2954 |
globalAttributes,
|
- |
|
| 2955 |
blockContent,
|
2795 |
blockContent,
|
| 2956 |
phrasingContent,
|
2796 |
phrasingContent,
|
| 2957 |
flowContent
|
2797 |
flowContent
|
| 2958 |
};
|
2798 |
};
|
| 2959 |
};
|
2799 |
};
|
| - |
|
2800 |
const getElementSets = type => {
|
| - |
|
2801 |
const {blockContent, phrasingContent, flowContent} = getElementSetsAsStrings(type);
|
| - |
|
2802 |
const toArr = value => {
|
| - |
|
2803 |
return Object.freeze(value.split(' '));
|
| - |
|
2804 |
};
|
| - |
|
2805 |
return Object.freeze({
|
| - |
|
2806 |
blockContent: toArr(blockContent),
|
| - |
|
2807 |
phrasingContent: toArr(phrasingContent),
|
| - |
|
2808 |
flowContent: toArr(flowContent)
|
| - |
|
2809 |
});
|
| - |
|
2810 |
};
|
| - |
|
2811 |
|
| - |
|
2812 |
const cachedSets = {
|
| - |
|
2813 |
'html4': cached(() => getElementSets('html4')),
|
| - |
|
2814 |
'html5': cached(() => getElementSets('html5')),
|
| - |
|
2815 |
'html5-strict': cached(() => getElementSets('html5-strict'))
|
| - |
|
2816 |
};
|
| - |
|
2817 |
const getElementsPreset = (type, name) => {
|
| - |
|
2818 |
const {blockContent, phrasingContent, flowContent} = cachedSets[type]();
|
| - |
|
2819 |
if (name === 'blocks') {
|
| - |
|
2820 |
return Optional.some(blockContent);
|
| - |
|
2821 |
} else if (name === 'phrasing') {
|
| - |
|
2822 |
return Optional.some(phrasingContent);
|
| - |
|
2823 |
} else if (name === 'flow') {
|
| - |
|
2824 |
return Optional.some(flowContent);
|
| - |
|
2825 |
} else {
|
| - |
|
2826 |
return Optional.none();
|
| - |
|
2827 |
}
|
| - |
|
2828 |
};
|
| Línea 2960... |
Línea 2829... |
| 2960 |
|
2829 |
|
| - |
|
2830 |
const makeSchema = type => {
|
| 2961 |
const makeSchema = type => {
|
2831 |
const globalAttributes = getGlobalAttributeSet(type);
|
| 2962 |
const {globalAttributes, phrasingContent, flowContent} = getElementSetsAsStrings(type);
|
2832 |
const {phrasingContent, flowContent} = getElementSetsAsStrings(type);
|
| 2963 |
const schema = {};
|
2833 |
const schema = {};
|
| 2964 |
const addElement = (name, attributes, children) => {
|
2834 |
const addElement = (name, attributes, children) => {
|
| 2965 |
schema[name] = {
|
2835 |
schema[name] = {
|
| 2966 |
attributes: mapToObject(attributes, constant({})),
|
2836 |
attributes: mapToObject(attributes, constant({})),
|
| Línea 2970... |
Línea 2840... |
| 2970 |
};
|
2840 |
};
|
| 2971 |
const add = (name, attributes = '', children = '') => {
|
2841 |
const add = (name, attributes = '', children = '') => {
|
| 2972 |
const childNames = split$1(children);
|
2842 |
const childNames = split$1(children);
|
| 2973 |
const names = split$1(name);
|
2843 |
const names = split$1(name);
|
| 2974 |
let ni = names.length;
|
2844 |
let ni = names.length;
|
| 2975 |
const allAttributes = split$1([
|
2845 |
const allAttributes = [
|
| 2976 |
globalAttributes,
|
2846 |
...globalAttributes,
|
| 2977 |
attributes
|
2847 |
...split$1(attributes)
|
| 2978 |
].join(' '));
|
2848 |
];
|
| 2979 |
while (ni--) {
|
2849 |
while (ni--) {
|
| 2980 |
addElement(names[ni], allAttributes.slice(), childNames);
|
2850 |
addElement(names[ni], allAttributes.slice(), childNames);
|
| 2981 |
}
|
2851 |
}
|
| 2982 |
};
|
2852 |
};
|
| 2983 |
const addAttrs = (name, attributes) => {
|
2853 |
const addAttrs = (name, attributes) => {
|
| Línea 3070... |
Línea 2940... |
| 3070 |
add('summary', '', [
|
2940 |
add('summary', '', [
|
| 3071 |
phrasingContent,
|
2941 |
phrasingContent,
|
| 3072 |
'h1 h2 h3 h4 h5 h6'
|
2942 |
'h1 h2 h3 h4 h5 h6'
|
| 3073 |
].join(' '));
|
2943 |
].join(' '));
|
| 3074 |
add('canvas', 'width height', flowContent);
|
2944 |
add('canvas', 'width height', flowContent);
|
| - |
|
2945 |
add('data', 'value', phrasingContent);
|
| 3075 |
add('video', 'src crossorigin poster preload autoplay mediagroup loop ' + 'muted controls width height buffered', [
|
2946 |
add('video', 'src crossorigin poster preload autoplay mediagroup loop ' + 'muted controls width height buffered', [
|
| 3076 |
flowContent,
|
2947 |
flowContent,
|
| 3077 |
'track source'
|
2948 |
'track source'
|
| 3078 |
].join(' '));
|
2949 |
].join(' '));
|
| 3079 |
add('audio', 'src crossorigin preload autoplay mediagroup loop muted controls ' + 'buffered volume', [
|
2950 |
add('audio', 'src crossorigin preload autoplay mediagroup loop muted controls ' + 'buffered volume', [
|
| Línea 3145... |
Línea 3016... |
| 3145 |
addAttrs('input button select textarea', 'autofocus');
|
3016 |
addAttrs('input button select textarea', 'autofocus');
|
| 3146 |
addAttrs('input textarea', 'placeholder');
|
3017 |
addAttrs('input textarea', 'placeholder');
|
| 3147 |
addAttrs('a', 'download');
|
3018 |
addAttrs('a', 'download');
|
| 3148 |
addAttrs('link script img', 'crossorigin');
|
3019 |
addAttrs('link script img', 'crossorigin');
|
| 3149 |
addAttrs('img', 'loading');
|
3020 |
addAttrs('img', 'loading');
|
| 3150 |
addAttrs('iframe', 'sandbox seamless allow allowfullscreen loading');
|
3021 |
addAttrs('iframe', 'sandbox seamless allow allowfullscreen loading referrerpolicy');
|
| 3151 |
}
|
3022 |
}
|
| 3152 |
if (type !== 'html4') {
|
3023 |
if (type !== 'html4') {
|
| 3153 |
each$e([
|
3024 |
each$e([
|
| 3154 |
schema.video,
|
3025 |
schema.video,
|
| 3155 |
schema.audio
|
3026 |
schema.audio
|
| Línea 3167... |
Línea 3038... |
| 3167 |
delete schema.script;
|
3038 |
delete schema.script;
|
| 3168 |
return schema;
|
3039 |
return schema;
|
| 3169 |
};
|
3040 |
};
|
| Línea 3170... |
Línea 3041... |
| 3170 |
|
3041 |
|
| - |
|
3042 |
const prefixToOperation = prefix => prefix === '-' ? 'remove' : 'add';
|
| - |
|
3043 |
const parseValidChild = name => {
|
| - |
|
3044 |
const validChildRegExp = /^(@?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)$/;
|
| - |
|
3045 |
return Optional.from(validChildRegExp.exec(name)).map(matches => ({
|
| - |
|
3046 |
preset: matches[1] === '@',
|
| - |
|
3047 |
name: matches[2]
|
| - |
|
3048 |
}));
|
| 3171 |
const prefixToOperation = prefix => prefix === '-' ? 'remove' : 'add';
|
3049 |
};
|
| 3172 |
const parseValidChildrenRules = value => {
|
3050 |
const parseValidChildrenRules = value => {
|
| 3173 |
const childRuleRegExp = /^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;
|
3051 |
const childRuleRegExp = /^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;
|
| 3174 |
return bind$3(split$1(value, ','), rule => {
|
3052 |
return bind$3(split$1(value, ','), rule => {
|
| 3175 |
const matches = childRuleRegExp.exec(rule);
|
3053 |
const matches = childRuleRegExp.exec(rule);
|
| 3176 |
if (matches) {
|
3054 |
if (matches) {
|
| 3177 |
const prefix = matches[1];
|
3055 |
const prefix = matches[1];
|
| 3178 |
const operation = prefix ? prefixToOperation(prefix) : 'replace';
|
3056 |
const operation = prefix ? prefixToOperation(prefix) : 'replace';
|
| 3179 |
const name = matches[2];
|
3057 |
const name = matches[2];
|
| 3180 |
const validChildren = split$1(matches[3], '|');
|
3058 |
const validChildren = bind$3(split$1(matches[3], '|'), validChild => parseValidChild(validChild).toArray());
|
| 3181 |
return [{
|
3059 |
return [{
|
| 3182 |
operation,
|
3060 |
operation,
|
| 3183 |
name,
|
3061 |
name,
|
| 3184 |
validChildren
|
3062 |
validChildren
|
| Línea 3352... |
Línea 3230... |
| 3352 |
const whitespaceElementsMap = createLookupTable('whitespace_elements', 'pre script noscript style textarea video audio iframe object code');
|
3230 |
const whitespaceElementsMap = createLookupTable('whitespace_elements', 'pre script noscript style textarea video audio iframe object code');
|
| 3353 |
const selfClosingElementsMap = createLookupTable('self_closing_elements', 'colgroup dd dt li option p td tfoot th thead tr');
|
3231 |
const selfClosingElementsMap = createLookupTable('self_closing_elements', 'colgroup dd dt li option p td tfoot th thead tr');
|
| 3354 |
const voidElementsMap = createLookupTable('void_elements', 'area base basefont br col frame hr img input isindex link ' + 'meta param embed source wbr track');
|
3232 |
const voidElementsMap = createLookupTable('void_elements', 'area base basefont br col frame hr img input isindex link ' + 'meta param embed source wbr track');
|
| 3355 |
const boolAttrMap = createLookupTable('boolean_attributes', 'checked compact declare defer disabled ismap multiple nohref noresize ' + 'noshade nowrap readonly selected autoplay loop controls allowfullscreen');
|
3233 |
const boolAttrMap = createLookupTable('boolean_attributes', 'checked compact declare defer disabled ismap multiple nohref noresize ' + 'noshade nowrap readonly selected autoplay loop controls allowfullscreen');
|
| 3356 |
const nonEmptyOrMoveCaretBeforeOnEnter = 'td th iframe video audio object script code';
|
3234 |
const nonEmptyOrMoveCaretBeforeOnEnter = 'td th iframe video audio object script code';
|
| 3357 |
const nonEmptyElementsMap = createLookupTable('non_empty_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' pre svg', voidElementsMap);
|
3235 |
const nonEmptyElementsMap = createLookupTable('non_empty_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' pre svg textarea summary', voidElementsMap);
|
| 3358 |
const moveCaretBeforeOnEnterElementsMap = createLookupTable('move_caret_before_on_enter_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' table', voidElementsMap);
|
3236 |
const moveCaretBeforeOnEnterElementsMap = createLookupTable('move_caret_before_on_enter_elements', nonEmptyOrMoveCaretBeforeOnEnter + ' table', voidElementsMap);
|
| 3359 |
const headings = 'h1 h2 h3 h4 h5 h6';
|
3237 |
const headings = 'h1 h2 h3 h4 h5 h6';
|
| 3360 |
const textBlockElementsMap = createLookupTable('text_block_elements', headings + ' p div address pre form ' + 'blockquote center dir fieldset header footer article section hgroup aside main nav figure');
|
3238 |
const textBlockElementsMap = createLookupTable('text_block_elements', headings + ' p div address pre form ' + 'blockquote center dir fieldset header footer article section hgroup aside main nav figure');
|
| 3361 |
const blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' + 'th tr td li ol ul caption dl dt dd noscript menu isindex option ' + 'datalist select optgroup figcaption details summary html body multicol listing', textBlockElementsMap);
|
3239 |
const blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' + 'th tr td li ol ul caption dl dt dd noscript menu isindex option ' + 'datalist select optgroup figcaption details summary html body multicol listing', textBlockElementsMap);
|
| 3362 |
const textInlineElementsMap = createLookupTable('text_inline_elements', 'span strong b em i font s strike u var cite ' + 'dfn code mark q sup sub samp');
|
3240 |
const textInlineElementsMap = createLookupTable('text_inline_elements', 'span strong b em i font s strike u var cite ' + 'dfn code mark q sup sub samp');
|
| Línea 3386... |
Línea 3264... |
| 3386 |
each$e(keys(elements), name => {
|
3264 |
each$e(keys(elements), name => {
|
| 3387 |
delete elements[name];
|
3265 |
delete elements[name];
|
| 3388 |
});
|
3266 |
});
|
| 3389 |
addValidElements(validElements);
|
3267 |
addValidElements(validElements);
|
| 3390 |
};
|
3268 |
};
|
| 3391 |
const addCustomElements = customElements => {
|
3269 |
const addCustomElement = (name, spec) => {
|
| - |
|
3270 |
var _a, _b;
|
| 3392 |
delete mapCache.text_block_elements;
|
3271 |
delete mapCache.text_block_elements;
|
| 3393 |
delete mapCache.block_elements;
|
3272 |
delete mapCache.block_elements;
|
| 3394 |
each$e(parseCustomElementsRules(customElements !== null && customElements !== void 0 ? customElements : ''), ({inline, name, cloneName}) => {
|
3273 |
const inline = spec.extends ? !isBlock(spec.extends) : false;
|
| - |
|
3274 |
const cloneName = spec.extends;
|
| 3395 |
children[name] = children[cloneName];
|
3275 |
children[name] = cloneName ? children[cloneName] : {};
|
| 3396 |
customElementsMap[name] = cloneName;
|
3276 |
customElementsMap[name] = cloneName !== null && cloneName !== void 0 ? cloneName : name;
|
| 3397 |
nonEmptyElementsMap[name.toUpperCase()] = {};
|
3277 |
nonEmptyElementsMap[name.toUpperCase()] = {};
|
| 3398 |
nonEmptyElementsMap[name] = {};
|
3278 |
nonEmptyElementsMap[name] = {};
|
| 3399 |
if (!inline) {
|
3279 |
if (!inline) {
|
| 3400 |
blockElementsMap[name.toUpperCase()] = {};
|
3280 |
blockElementsMap[name.toUpperCase()] = {};
|
| 3401 |
blockElementsMap[name] = {};
|
3281 |
blockElementsMap[name] = {};
|
| 3402 |
}
|
3282 |
}
|
| - |
|
3283 |
if (cloneName && !elements[name] && elements[cloneName]) {
|
| - |
|
3284 |
const customRule = deepCloneElementRule(elements[cloneName]);
|
| - |
|
3285 |
delete customRule.removeEmptyAttrs;
|
| - |
|
3286 |
delete customRule.removeEmpty;
|
| - |
|
3287 |
elements[name] = customRule;
|
| - |
|
3288 |
} else {
|
| 3403 |
if (!elements[name]) {
|
3289 |
elements[name] = {
|
| - |
|
3290 |
attributesOrder: [],
|
| - |
|
3291 |
attributes: {}
|
| - |
|
3292 |
};
|
| - |
|
3293 |
}
|
| - |
|
3294 |
if (isArray$1(spec.attributes)) {
|
| - |
|
3295 |
const processAttrName = name => {
|
| - |
|
3296 |
customRule.attributesOrder.push(name);
|
| - |
|
3297 |
customRule.attributes[name] = {};
|
| - |
|
3298 |
};
|
| - |
|
3299 |
const customRule = (_a = elements[name]) !== null && _a !== void 0 ? _a : {};
|
| 3404 |
let customRule = elements[cloneName];
|
3300 |
delete customRule.attributesDefault;
|
| 3405 |
customRule = extend$2({}, customRule);
|
3301 |
delete customRule.attributesForced;
|
| 3406 |
delete customRule.removeEmptyAttrs;
|
3302 |
delete customRule.attributePatterns;
|
| 3407 |
delete customRule.removeEmpty;
|
3303 |
delete customRule.attributesRequired;
|
| - |
|
3304 |
customRule.attributesOrder = [];
|
| - |
|
3305 |
customRule.attributes = {};
|
| - |
|
3306 |
each$e(spec.attributes, attrName => {
|
| - |
|
3307 |
const globalAttrs = getGlobalAttributeSet(schemaType);
|
| - |
|
3308 |
parseValidChild(attrName).each(({preset, name}) => {
|
| - |
|
3309 |
if (preset) {
|
| - |
|
3310 |
if (name === 'global') {
|
| - |
|
3311 |
each$e(globalAttrs, processAttrName);
|
| - |
|
3312 |
}
|
| - |
|
3313 |
} else {
|
| - |
|
3314 |
processAttrName(name);
|
| - |
|
3315 |
}
|
| - |
|
3316 |
});
|
| - |
|
3317 |
});
|
| 3408 |
elements[name] = customRule;
|
3318 |
elements[name] = customRule;
|
| - |
|
3319 |
}
|
| - |
|
3320 |
if (isBoolean(spec.padEmpty)) {
|
| - |
|
3321 |
const customRule = (_b = elements[name]) !== null && _b !== void 0 ? _b : {};
|
| - |
|
3322 |
customRule.paddEmpty = spec.padEmpty;
|
| - |
|
3323 |
elements[name] = customRule;
|
| - |
|
3324 |
}
|
| - |
|
3325 |
if (isArray$1(spec.children)) {
|
| - |
|
3326 |
const customElementChildren = {};
|
| - |
|
3327 |
const processNodeName = name => {
|
| - |
|
3328 |
customElementChildren[name] = {};
|
| - |
|
3329 |
};
|
| - |
|
3330 |
const processPreset = name => {
|
| - |
|
3331 |
getElementsPreset(schemaType, name).each(names => {
|
| - |
|
3332 |
each$e(names, processNodeName);
|
| - |
|
3333 |
});
|
| 3409 |
}
|
3334 |
};
|
| - |
|
3335 |
each$e(spec.children, child => {
|
| - |
|
3336 |
parseValidChild(child).each(({preset, name}) => {
|
| - |
|
3337 |
if (preset) {
|
| - |
|
3338 |
processPreset(name);
|
| - |
|
3339 |
} else {
|
| - |
|
3340 |
processNodeName(name);
|
| - |
|
3341 |
}
|
| - |
|
3342 |
});
|
| - |
|
3343 |
});
|
| - |
|
3344 |
children[name] = customElementChildren;
|
| - |
|
3345 |
}
|
| - |
|
3346 |
if (cloneName) {
|
| 3410 |
each$d(children, (element, elmName) => {
|
3347 |
each$d(children, (element, elmName) => {
|
| 3411 |
if (element[cloneName]) {
|
3348 |
if (element[cloneName]) {
|
| 3412 |
children[elmName] = element = extend$2({}, children[elmName]);
|
3349 |
children[elmName] = element = extend$2({}, children[elmName]);
|
| 3413 |
element[name] = element[cloneName];
|
3350 |
element[name] = element[cloneName];
|
| 3414 |
}
|
3351 |
}
|
| 3415 |
});
|
3352 |
});
|
| - |
|
3353 |
}
|
| - |
|
3354 |
};
|
| - |
|
3355 |
const addCustomElementsFromString = customElements => {
|
| - |
|
3356 |
each$e(parseCustomElementsRules(customElements !== null && customElements !== void 0 ? customElements : ''), ({name, cloneName}) => {
|
| - |
|
3357 |
addCustomElement(name, { extends: cloneName });
|
| 3416 |
});
|
3358 |
});
|
| 3417 |
};
|
3359 |
};
|
| - |
|
3360 |
const addCustomElements = customElements => {
|
| - |
|
3361 |
if (isObject(customElements)) {
|
| - |
|
3362 |
each$d(customElements, (spec, name) => addCustomElement(name, spec));
|
| - |
|
3363 |
} else if (isString(customElements)) {
|
| - |
|
3364 |
addCustomElementsFromString(customElements);
|
| - |
|
3365 |
}
|
| - |
|
3366 |
};
|
| 3418 |
const addValidChildren = validChildren => {
|
3367 |
const addValidChildren = validChildren => {
|
| 3419 |
each$e(parseValidChildrenRules(validChildren !== null && validChildren !== void 0 ? validChildren : ''), ({operation, name, validChildren}) => {
|
3368 |
each$e(parseValidChildrenRules(validChildren !== null && validChildren !== void 0 ? validChildren : ''), ({operation, name, validChildren}) => {
|
| 3420 |
const parent = operation === 'replace' ? { '#comment': {} } : children[name];
|
3369 |
const parent = operation === 'replace' ? { '#comment': {} } : children[name];
|
| 3421 |
each$e(validChildren, child => {
|
3370 |
const processNodeName = name => {
|
| 3422 |
if (operation === 'remove') {
|
3371 |
if (operation === 'remove') {
|
| 3423 |
delete parent[child];
|
3372 |
delete parent[name];
|
| 3424 |
} else {
|
3373 |
} else {
|
| 3425 |
parent[child] = {};
|
3374 |
parent[name] = {};
|
| - |
|
3375 |
}
|
| - |
|
3376 |
};
|
| - |
|
3377 |
const processPreset = name => {
|
| - |
|
3378 |
getElementsPreset(schemaType, name).each(names => {
|
| - |
|
3379 |
each$e(names, processNodeName);
|
| - |
|
3380 |
});
|
| - |
|
3381 |
};
|
| - |
|
3382 |
each$e(validChildren, ({preset, name}) => {
|
| - |
|
3383 |
if (preset) {
|
| - |
|
3384 |
processPreset(name);
|
| - |
|
3385 |
} else {
|
| - |
|
3386 |
processNodeName(name);
|
| 3426 |
}
|
3387 |
}
|
| 3427 |
});
|
3388 |
});
|
| 3428 |
children[name] = parent;
|
3389 |
children[name] = parent;
|
| 3429 |
});
|
3390 |
});
|
| 3430 |
};
|
3391 |
};
|
| Línea 3440... |
Línea 3401... |
| 3440 |
return patternElement;
|
3401 |
return patternElement;
|
| 3441 |
}
|
3402 |
}
|
| 3442 |
}
|
3403 |
}
|
| 3443 |
return undefined;
|
3404 |
return undefined;
|
| 3444 |
};
|
3405 |
};
|
| - |
|
3406 |
const setup = () => {
|
| 3445 |
if (!settings.valid_elements) {
|
3407 |
if (!settings.valid_elements) {
|
| 3446 |
each$b(schemaItems, (element, name) => {
|
3408 |
each$b(schemaItems, (element, name) => {
|
| 3447 |
elements[name] = {
|
3409 |
elements[name] = {
|
| 3448 |
attributes: element.attributes,
|
3410 |
attributes: element.attributes,
|
| 3449 |
attributesOrder: element.attributesOrder
|
3411 |
attributesOrder: element.attributesOrder
|
| 3450 |
};
|
3412 |
};
|
| 3451 |
children[name] = element.children;
|
3413 |
children[name] = element.children;
|
| 3452 |
});
|
3414 |
});
|
| 3453 |
each$b(split$1('strong/b em/i'), item => {
|
3415 |
each$b(split$1('strong/b em/i'), item => {
|
| 3454 |
const items = split$1(item, '/');
|
3416 |
const items = split$1(item, '/');
|
| 3455 |
elements[items[1]].outputName = items[0];
|
3417 |
elements[items[1]].outputName = items[0];
|
| 3456 |
});
|
3418 |
});
|
| 3457 |
each$b(textInlineElementsMap, (_val, name) => {
|
3419 |
each$b(textInlineElementsMap, (_val, name) => {
|
| 3458 |
if (elements[name]) {
|
3420 |
if (elements[name]) {
|
| 3459 |
if (settings.padd_empty_block_inline_children) {
|
3421 |
if (settings.padd_empty_block_inline_children) {
|
| 3460 |
elements[name].paddInEmptyBlock = true;
|
3422 |
elements[name].paddInEmptyBlock = true;
|
| 3461 |
}
|
3423 |
}
|
| 3462 |
elements[name].removeEmpty = true;
|
3424 |
elements[name].removeEmpty = true;
|
| 3463 |
}
|
3425 |
}
|
| 3464 |
});
|
3426 |
});
|
| 3465 |
each$b(split$1('ol ul blockquote a table tbody'), name => {
|
3427 |
each$b(split$1('ol ul blockquote a table tbody'), name => {
|
| 3466 |
if (elements[name]) {
|
3428 |
if (elements[name]) {
|
| 3467 |
elements[name].removeEmpty = true;
|
3429 |
elements[name].removeEmpty = true;
|
| 3468 |
}
|
3430 |
}
|
| 3469 |
});
|
3431 |
});
|
| 3470 |
each$b(split$1('p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary'), name => {
|
3432 |
each$b(split$1('p h1 h2 h3 h4 h5 h6 th td pre div address caption li summary'), name => {
|
| 3471 |
if (elements[name]) {
|
3433 |
if (elements[name]) {
|
| 3472 |
elements[name].paddEmpty = true;
|
3434 |
elements[name].paddEmpty = true;
|
| 3473 |
}
|
3435 |
}
|
| 3474 |
});
|
3436 |
});
|
| 3475 |
each$b(split$1('span'), name => {
|
3437 |
each$b(split$1('span'), name => {
|
| 3476 |
elements[name].removeEmptyAttrs = true;
|
3438 |
elements[name].removeEmptyAttrs = true;
|
| 3477 |
});
|
3439 |
});
|
| 3478 |
} else {
|
3440 |
} else {
|
| 3479 |
setValidElements(settings.valid_elements);
|
3441 |
setValidElements(settings.valid_elements);
|
| 3480 |
each$b(schemaItems, (element, name) => {
|
3442 |
each$b(schemaItems, (element, name) => {
|
| 3481 |
children[name] = element.children;
|
3443 |
children[name] = element.children;
|
| 3482 |
});
|
3444 |
});
|
| 3483 |
}
|
3445 |
}
|
| 3484 |
delete elements.svg;
|
3446 |
delete elements.svg;
|
| 3485 |
addCustomElements(settings.custom_elements);
|
3447 |
addCustomElements(settings.custom_elements);
|
| 3486 |
addValidChildren(settings.valid_children);
|
3448 |
addValidChildren(settings.valid_children);
|
| 3487 |
addValidElements(settings.extended_valid_elements);
|
3449 |
addValidElements(settings.extended_valid_elements);
|
| 3488 |
addValidChildren('+ol[ul|ol],+ul[ul|ol]');
|
3450 |
addValidChildren('+ol[ul|ol],+ul[ul|ol]');
|
| 3489 |
each$b({
|
3451 |
each$b({
|
| 3490 |
dd: 'dl',
|
3452 |
dd: 'dl',
|
| 3491 |
dt: 'dl',
|
3453 |
dt: 'dl',
|
| 3492 |
li: 'ul ol',
|
3454 |
li: 'ul ol',
|
| 3493 |
td: 'tr',
|
3455 |
td: 'tr',
|
| 3494 |
th: 'tr',
|
3456 |
th: 'tr',
|
| 3495 |
tr: 'tbody thead tfoot',
|
3457 |
tr: 'tbody thead tfoot',
|
| 3496 |
tbody: 'table',
|
3458 |
tbody: 'table',
|
| 3497 |
thead: 'table',
|
3459 |
thead: 'table',
|
| 3498 |
tfoot: 'table',
|
3460 |
tfoot: 'table',
|
| 3499 |
legend: 'fieldset',
|
3461 |
legend: 'fieldset',
|
| 3500 |
area: 'map',
|
3462 |
area: 'map',
|
| 3501 |
param: 'video audio object'
|
3463 |
param: 'video audio object'
|
| 3502 |
}, (parents, item) => {
|
3464 |
}, (parents, item) => {
|
| 3503 |
if (elements[item]) {
|
- |
|
| 3504 |
elements[item].parentsRequired = split$1(parents);
|
- |
|
| 3505 |
}
|
- |
|
| 3506 |
});
|
- |
|
| 3507 |
if (settings.invalid_elements) {
|
- |
|
| 3508 |
each$b(explode$2(settings.invalid_elements), item => {
|
- |
|
| 3509 |
if (elements[item]) {
|
3465 |
if (elements[item]) {
|
| 3510 |
delete elements[item];
|
3466 |
elements[item].parentsRequired = split$1(parents);
|
| 3511 |
}
|
3467 |
}
|
| 3512 |
});
|
3468 |
});
|
| - |
|
3469 |
if (settings.invalid_elements) {
|
| - |
|
3470 |
each$b(explode$2(settings.invalid_elements), item => {
|
| - |
|
3471 |
if (elements[item]) {
|
| - |
|
3472 |
delete elements[item];
|
| - |
|
3473 |
}
|
| - |
|
3474 |
});
|
| 3513 |
}
|
3475 |
}
|
| 3514 |
if (!getElementRule('span')) {
|
3476 |
if (!getElementRule('span')) {
|
| 3515 |
addValidElements('span[!data-mce-type|*]');
|
3477 |
addValidElements('span[!data-mce-type|*]');
|
| - |
|
3478 |
}
|
| 3516 |
}
|
3479 |
};
|
| 3517 |
const getValidStyles = constant(validStyles);
|
3480 |
const getValidStyles = constant(validStyles);
|
| 3518 |
const getInvalidStyles = constant(invalidStyles);
|
3481 |
const getInvalidStyles = constant(invalidStyles);
|
| 3519 |
const getValidClasses = constant(validClasses);
|
3482 |
const getValidClasses = constant(validClasses);
|
| 3520 |
const getBoolAttrs = constant(boolAttrMap);
|
3483 |
const getBoolAttrs = constant(boolAttrMap);
|
| 3521 |
const getBlockElements = constant(blockElementsMap);
|
3484 |
const getBlockElements = constant(blockElementsMap);
|
| Línea 3557... |
Línea 3520... |
| 3557 |
};
|
3520 |
};
|
| 3558 |
const isBlock = name => has$2(getBlockElements(), name);
|
3521 |
const isBlock = name => has$2(getBlockElements(), name);
|
| 3559 |
const isInline = name => !startsWith(name, '#') && isValid(name) && !isBlock(name);
|
3522 |
const isInline = name => !startsWith(name, '#') && isValid(name) && !isBlock(name);
|
| 3560 |
const isWrapper = name => has$2(getWrapBlockElements(), name) || isInline(name);
|
3523 |
const isWrapper = name => has$2(getWrapBlockElements(), name) || isInline(name);
|
| 3561 |
const getCustomElements = constant(customElementsMap);
|
3524 |
const getCustomElements = constant(customElementsMap);
|
| - |
|
3525 |
setup();
|
| 3562 |
return {
|
3526 |
return {
|
| 3563 |
type: schemaType,
|
3527 |
type: schemaType,
|
| 3564 |
children,
|
3528 |
children,
|
| 3565 |
elements,
|
3529 |
elements,
|
| 3566 |
getValidStyles,
|
3530 |
getValidStyles,
|
| Línea 3600... |
Línea 3564... |
| 3600 |
const fromRgba = rgbaColour => {
|
3564 |
const fromRgba = rgbaColour => {
|
| 3601 |
const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
|
3565 |
const value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
|
| 3602 |
return hexColour(value);
|
3566 |
return hexColour(value);
|
| 3603 |
};
|
3567 |
};
|
| Línea 3604... |
Línea 3568... |
| 3604 |
|
3568 |
|
| 3605 |
const rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i;
|
3569 |
const rgbRegex = /^\s*rgb\s*\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)\s*\)\s*$/i;
|
| 3606 |
const rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i;
|
3570 |
const rgbaRegex = /^\s*rgba\s*\(\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*(\d+)\s*[,\s]\s*((?:\d?\.\d+|\d+)%?)\s*\)\s*$/i;
|
| 3607 |
const rgbaColour = (red, green, blue, alpha) => ({
|
3571 |
const rgbaColour = (red, green, blue, alpha) => ({
|
| 3608 |
red,
|
3572 |
red,
|
| 3609 |
green,
|
3573 |
green,
|
| 3610 |
blue,
|
3574 |
blue,
|
| Línea 3615... |
Línea 3579... |
| 3615 |
const g = parseInt(green, 10);
|
3579 |
const g = parseInt(green, 10);
|
| 3616 |
const b = parseInt(blue, 10);
|
3580 |
const b = parseInt(blue, 10);
|
| 3617 |
const a = parseFloat(alpha);
|
3581 |
const a = parseFloat(alpha);
|
| 3618 |
return rgbaColour(r, g, b, a);
|
3582 |
return rgbaColour(r, g, b, a);
|
| 3619 |
};
|
3583 |
};
|
| 3620 |
const fromString = rgbaString => {
|
3584 |
const getColorFormat = colorString => {
|
| 3621 |
if (rgbaString === 'transparent') {
|
3585 |
if (rgbRegex.test(colorString)) {
|
| - |
|
3586 |
return 'rgb';
|
| 3622 |
return Optional.some(rgbaColour(0, 0, 0, 0));
|
3587 |
} else if (rgbaRegex.test(colorString)) {
|
| - |
|
3588 |
return 'rgba';
|
| 3623 |
}
|
3589 |
}
|
| - |
|
3590 |
return 'other';
|
| - |
|
3591 |
};
|
| - |
|
3592 |
const fromString = rgbaString => {
|
| 3624 |
const rgbMatch = rgbRegex.exec(rgbaString);
|
3593 |
const rgbMatch = rgbRegex.exec(rgbaString);
|
| 3625 |
if (rgbMatch !== null) {
|
3594 |
if (rgbMatch !== null) {
|
| 3626 |
return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
|
3595 |
return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
|
| 3627 |
}
|
3596 |
}
|
| 3628 |
const rgbaMatch = rgbaRegex.exec(rgbaString);
|
3597 |
const rgbaMatch = rgbaRegex.exec(rgbaString);
|
| Línea 3790... |
Línea 3759... |
| 3790 |
if (name === 'font-weight' && value === '700') {
|
3759 |
if (name === 'font-weight' && value === '700') {
|
| 3791 |
value = 'bold';
|
3760 |
value = 'bold';
|
| 3792 |
} else if (name === 'color' || name === 'background-color') {
|
3761 |
} else if (name === 'color' || name === 'background-color') {
|
| 3793 |
value = value.toLowerCase();
|
3762 |
value = value.toLowerCase();
|
| 3794 |
}
|
3763 |
}
|
| 3795 |
if (isString(settings.force_hex_color) && settings.force_hex_color !== 'off') {
|
3764 |
if (getColorFormat(value) === 'rgb') {
|
| 3796 |
fromString(value).each(rgba => {
|
3765 |
fromString(value).each(rgba => {
|
| 3797 |
if (settings.force_hex_color === 'always' || rgba.alpha === 1) {
|
- |
|
| 3798 |
value = rgbaToHexString(toString(rgba));
|
3766 |
value = rgbaToHexString(toString(rgba)).toLowerCase();
|
| 3799 |
}
|
- |
|
| 3800 |
});
|
3767 |
});
|
| 3801 |
}
|
3768 |
}
|
| 3802 |
value = value.replace(urlOrStrRegExp, processUrl);
|
3769 |
value = value.replace(urlOrStrRegExp, processUrl);
|
| 3803 |
styles[name] = isEncoded ? decode(value, true) : value;
|
3770 |
styles[name] = isEncoded ? decode(value, true) : value;
|
| 3804 |
}
|
3771 |
}
|
| Línea 3988... |
Línea 3955... |
| 3988 |
let callbackList;
|
3955 |
let callbackList;
|
| 3989 |
const win = window;
|
3956 |
const win = window;
|
| 3990 |
const defaultNativeHandler = evt => {
|
3957 |
const defaultNativeHandler = evt => {
|
| 3991 |
self.executeHandlers(fix(evt || win.event), id);
|
3958 |
self.executeHandlers(fix(evt || win.event), id);
|
| 3992 |
};
|
3959 |
};
|
| 3993 |
if (!target || isText$a(target) || isComment(target)) {
|
3960 |
if (!target || isText$b(target) || isComment(target)) {
|
| 3994 |
return callback;
|
3961 |
return callback;
|
| 3995 |
}
|
3962 |
}
|
| 3996 |
let id;
|
3963 |
let id;
|
| 3997 |
if (!target[self.expando]) {
|
3964 |
if (!target[self.expando]) {
|
| 3998 |
id = self.count++;
|
3965 |
id = self.count++;
|
| Línea 4052... |
Línea 4019... |
| 4052 |
}
|
4019 |
}
|
| 4053 |
target = callbackList = null;
|
4020 |
target = callbackList = null;
|
| 4054 |
return callback;
|
4021 |
return callback;
|
| 4055 |
}
|
4022 |
}
|
| 4056 |
unbind(target, names, callback) {
|
4023 |
unbind(target, names, callback) {
|
| 4057 |
if (!target || isText$a(target) || isComment(target)) {
|
4024 |
if (!target || isText$b(target) || isComment(target)) {
|
| 4058 |
return this;
|
4025 |
return this;
|
| 4059 |
}
|
4026 |
}
|
| 4060 |
const id = target[this.expando];
|
4027 |
const id = target[this.expando];
|
| 4061 |
if (id) {
|
4028 |
if (id) {
|
| 4062 |
let eventMap = this.events[id];
|
4029 |
let eventMap = this.events[id];
|
| Línea 4099... |
Línea 4066... |
| 4099 |
}
|
4066 |
}
|
| 4100 |
}
|
4067 |
}
|
| 4101 |
delete this.events[id];
|
4068 |
delete this.events[id];
|
| 4102 |
try {
|
4069 |
try {
|
| 4103 |
delete target[this.expando];
|
4070 |
delete target[this.expando];
|
| 4104 |
} catch (ex) {
|
4071 |
} catch (_a) {
|
| 4105 |
target[this.expando] = null;
|
4072 |
target[this.expando] = null;
|
| 4106 |
}
|
4073 |
}
|
| 4107 |
}
|
4074 |
}
|
| 4108 |
return this;
|
4075 |
return this;
|
| 4109 |
}
|
4076 |
}
|
| 4110 |
fire(target, name, args) {
|
4077 |
fire(target, name, args) {
|
| 4111 |
return this.dispatch(target, name, args);
|
4078 |
return this.dispatch(target, name, args);
|
| 4112 |
}
|
4079 |
}
|
| 4113 |
dispatch(target, name, args) {
|
4080 |
dispatch(target, name, args) {
|
| 4114 |
if (!target || isText$a(target) || isComment(target)) {
|
4081 |
if (!target || isText$b(target) || isComment(target)) {
|
| 4115 |
return this;
|
4082 |
return this;
|
| 4116 |
}
|
4083 |
}
|
| 4117 |
const event = fix({
|
4084 |
const event = fix({
|
| 4118 |
type: name,
|
4085 |
type: name,
|
| 4119 |
target
|
4086 |
target
|
| Línea 4126... |
Línea 4093... |
| 4126 |
target = target.parentNode || target.ownerDocument || target.defaultView || target.parentWindow;
|
4093 |
target = target.parentNode || target.ownerDocument || target.defaultView || target.parentWindow;
|
| 4127 |
} while (target && !event.isPropagationStopped());
|
4094 |
} while (target && !event.isPropagationStopped());
|
| 4128 |
return this;
|
4095 |
return this;
|
| 4129 |
}
|
4096 |
}
|
| 4130 |
clean(target) {
|
4097 |
clean(target) {
|
| 4131 |
if (!target || isText$a(target) || isComment(target)) {
|
4098 |
if (!target || isText$b(target) || isComment(target)) {
|
| 4132 |
return this;
|
4099 |
return this;
|
| 4133 |
}
|
4100 |
}
|
| 4134 |
if (target[this.expando]) {
|
4101 |
if (target[this.expando]) {
|
| 4135 |
this.unbind(target);
|
4102 |
this.unbind(target);
|
| 4136 |
}
|
4103 |
}
|
| Línea 4182... |
Línea 4149... |
| 4182 |
const grep = Tools.grep;
|
4149 |
const grep = Tools.grep;
|
| 4183 |
const internalStyleName = 'data-mce-style';
|
4150 |
const internalStyleName = 'data-mce-style';
|
| 4184 |
const numericalCssMap = Tools.makeMap('fill-opacity font-weight line-height opacity orphans widows z-index zoom', ' ');
|
4151 |
const numericalCssMap = Tools.makeMap('fill-opacity font-weight line-height opacity orphans widows z-index zoom', ' ');
|
| 4185 |
const legacySetAttribute = (elm, name, value) => {
|
4152 |
const legacySetAttribute = (elm, name, value) => {
|
| 4186 |
if (isNullable(value) || value === '') {
|
4153 |
if (isNullable(value) || value === '') {
|
| 4187 |
remove$a(elm, name);
|
4154 |
remove$9(elm, name);
|
| 4188 |
} else {
|
4155 |
} else {
|
| 4189 |
set$3(elm, name, value);
|
4156 |
set$4(elm, name, value);
|
| 4190 |
}
|
4157 |
}
|
| 4191 |
};
|
4158 |
};
|
| 4192 |
const camelCaseToHyphens = name => name.replace(/[A-Z]/g, v => '-' + v.toLowerCase());
|
4159 |
const camelCaseToHyphens = name => name.replace(/[A-Z]/g, v => '-' + v.toLowerCase());
|
| 4193 |
const findNodeIndex = (node, normalized) => {
|
4160 |
const findNodeIndex = (node, normalized) => {
|
| 4194 |
let idx = 0;
|
4161 |
let idx = 0;
|
| 4195 |
if (node) {
|
4162 |
if (node) {
|
| 4196 |
for (let lastNodeType = node.nodeType, tempNode = node.previousSibling; tempNode; tempNode = tempNode.previousSibling) {
|
4163 |
for (let lastNodeType = node.nodeType, tempNode = node.previousSibling; tempNode; tempNode = tempNode.previousSibling) {
|
| 4197 |
const nodeType = tempNode.nodeType;
|
4164 |
const nodeType = tempNode.nodeType;
|
| 4198 |
if (normalized && isText$a(tempNode)) {
|
4165 |
if (normalized && isText$b(tempNode)) {
|
| 4199 |
if (nodeType === lastNodeType || !tempNode.data.length) {
|
4166 |
if (nodeType === lastNodeType || !tempNode.data.length) {
|
| 4200 |
continue;
|
4167 |
continue;
|
| 4201 |
}
|
4168 |
}
|
| 4202 |
}
|
4169 |
}
|
| 4203 |
idx++;
|
4170 |
idx++;
|
| Línea 4219... |
Línea 4186... |
| 4219 |
}
|
4186 |
}
|
| 4220 |
};
|
4187 |
};
|
| 4221 |
const applyStyle$1 = ($elm, cssName, cssValue) => {
|
4188 |
const applyStyle$1 = ($elm, cssName, cssValue) => {
|
| 4222 |
const normalizedName = camelCaseToHyphens(cssName);
|
4189 |
const normalizedName = camelCaseToHyphens(cssName);
|
| 4223 |
if (isNullable(cssValue) || cssValue === '') {
|
4190 |
if (isNullable(cssValue) || cssValue === '') {
|
| 4224 |
remove$6($elm, normalizedName);
|
4191 |
remove$5($elm, normalizedName);
|
| 4225 |
} else {
|
4192 |
} else {
|
| 4226 |
set$2($elm, normalizedName, convertStyleToString(cssValue, normalizedName));
|
4193 |
set$2($elm, normalizedName, convertStyleToString(cssValue, normalizedName));
|
| 4227 |
}
|
4194 |
}
|
| 4228 |
};
|
4195 |
};
|
| 4229 |
const setupAttrHooks = (styles, settings, getContext) => {
|
4196 |
const setupAttrHooks = (styles, settings, getContext) => {
|
| Línea 4248... |
Línea 4215... |
| 4248 |
set: (elm, value) => {
|
4215 |
set: (elm, value) => {
|
| 4249 |
const sugarElm = SugarElement.fromDom(elm);
|
4216 |
const sugarElm = SugarElement.fromDom(elm);
|
| 4250 |
if (keepValues) {
|
4217 |
if (keepValues) {
|
| 4251 |
legacySetAttribute(sugarElm, internalStyleName, value);
|
4218 |
legacySetAttribute(sugarElm, internalStyleName, value);
|
| 4252 |
}
|
4219 |
}
|
| 4253 |
remove$a(sugarElm, 'style');
|
4220 |
remove$9(sugarElm, 'style');
|
| 4254 |
if (isString(value)) {
|
4221 |
if (isString(value)) {
|
| 4255 |
setAll(sugarElm, styles.parse(value));
|
4222 |
setAll(sugarElm, styles.parse(value));
|
| 4256 |
}
|
4223 |
}
|
| 4257 |
},
|
4224 |
},
|
| 4258 |
get: elm => {
|
4225 |
get: elm => {
|
| Línea 4280... |
Línea 4247... |
| 4280 |
});
|
4247 |
});
|
| 4281 |
const boundEvents = [];
|
4248 |
const boundEvents = [];
|
| 4282 |
const schema = settings.schema ? settings.schema : Schema({});
|
4249 |
const schema = settings.schema ? settings.schema : Schema({});
|
| 4283 |
const styles = Styles({
|
4250 |
const styles = Styles({
|
| 4284 |
url_converter: settings.url_converter,
|
4251 |
url_converter: settings.url_converter,
|
| 4285 |
url_converter_scope: settings.url_converter_scope,
|
4252 |
url_converter_scope: settings.url_converter_scope
|
| 4286 |
force_hex_color: settings.force_hex_color
|
- |
|
| 4287 |
}, settings.schema);
|
4253 |
}, settings.schema);
|
| 4288 |
const events = settings.ownEvents ? new EventUtils() : EventUtils.Event;
|
4254 |
const events = settings.ownEvents ? new EventUtils() : EventUtils.Event;
|
| 4289 |
const blockElementsMap = schema.getBlockElements();
|
4255 |
const blockElementsMap = schema.getBlockElements();
|
| 4290 |
const isBlock = node => {
|
4256 |
const isBlock = node => {
|
| 4291 |
if (isString(node)) {
|
4257 |
if (isString(node)) {
|
| Línea 4560... |
Línea 4526... |
| 4560 |
const remove = (node, keepChildren) => {
|
4526 |
const remove = (node, keepChildren) => {
|
| 4561 |
return run(node, n => {
|
4527 |
return run(node, n => {
|
| 4562 |
const $node = SugarElement.fromDom(n);
|
4528 |
const $node = SugarElement.fromDom(n);
|
| 4563 |
if (keepChildren) {
|
4529 |
if (keepChildren) {
|
| 4564 |
each$e(children$1($node), child => {
|
4530 |
each$e(children$1($node), child => {
|
| 4565 |
if (isText$b(child) && child.dom.length === 0) {
|
4531 |
if (isText$c(child) && child.dom.length === 0) {
|
| 4566 |
remove$5(child);
|
4532 |
remove$4(child);
|
| 4567 |
} else {
|
4533 |
} else {
|
| 4568 |
before$3($node, child);
|
4534 |
before$3($node, child);
|
| 4569 |
}
|
4535 |
}
|
| 4570 |
});
|
4536 |
});
|
| 4571 |
}
|
4537 |
}
|
| 4572 |
remove$5($node);
|
4538 |
remove$4($node);
|
| 4573 |
return $node.dom;
|
4539 |
return $node.dom;
|
| 4574 |
});
|
4540 |
});
|
| 4575 |
};
|
4541 |
};
|
| 4576 |
const removeAllAttribs = e => run(e, e => {
|
4542 |
const removeAllAttribs = e => run(e, e => {
|
| 4577 |
const attrs = e.attributes;
|
4543 |
const attrs = e.attributes;
|
| Línea 4620... |
Línea 4586... |
| 4620 |
if (isElement$6(e)) {
|
4586 |
if (isElement$6(e)) {
|
| 4621 |
const $elm = SugarElement.fromDom(e);
|
4587 |
const $elm = SugarElement.fromDom(e);
|
| 4622 |
const classes = cls.split(' ');
|
4588 |
const classes = cls.split(' ');
|
| 4623 |
each$e(classes, c => {
|
4589 |
each$e(classes, c => {
|
| 4624 |
if (isNonNullable(state)) {
|
4590 |
if (isNonNullable(state)) {
|
| 4625 |
const fn = state ? add$2 : remove$7;
|
4591 |
const fn = state ? add$2 : remove$6;
|
| 4626 |
fn($elm, c);
|
4592 |
fn($elm, c);
|
| 4627 |
} else {
|
4593 |
} else {
|
| 4628 |
toggle$1($elm, c);
|
4594 |
toggle$1($elm, c);
|
| 4629 |
}
|
4595 |
}
|
| 4630 |
});
|
4596 |
});
|
| Línea 4641... |
Línea 4607... |
| 4641 |
const $elm = _get(elm);
|
4607 |
const $elm = _get(elm);
|
| 4642 |
const classes = cls.split(' ');
|
4608 |
const classes = cls.split(' ');
|
| 4643 |
return isNonNullable($elm) && forall(classes, c => has($elm, c));
|
4609 |
return isNonNullable($elm) && forall(classes, c => has($elm, c));
|
| 4644 |
};
|
4610 |
};
|
| 4645 |
const show = elm => {
|
4611 |
const show = elm => {
|
| 4646 |
run(elm, e => remove$6(SugarElement.fromDom(e), 'display'));
|
4612 |
run(elm, e => remove$5(SugarElement.fromDom(e), 'display'));
|
| 4647 |
};
|
4613 |
};
|
| 4648 |
const hide = elm => {
|
4614 |
const hide = elm => {
|
| 4649 |
run(elm, e => set$2(SugarElement.fromDom(e), 'display', 'none'));
|
4615 |
run(elm, e => set$2(SugarElement.fromDom(e), 'display', 'none'));
|
| 4650 |
};
|
4616 |
};
|
| 4651 |
const isHidden = elm => {
|
4617 |
const isHidden = elm => {
|
| Línea 4722... |
Línea 4688... |
| 4722 |
return a.ownerDocument.documentElement;
|
4688 |
return a.ownerDocument.documentElement;
|
| 4723 |
} else {
|
4689 |
} else {
|
| 4724 |
return ps;
|
4690 |
return ps;
|
| 4725 |
}
|
4691 |
}
|
| 4726 |
};
|
4692 |
};
|
| 4727 |
const isNonEmptyElement = node => {
|
- |
|
| 4728 |
if (isElement$6(node)) {
|
- |
|
| 4729 |
const isNamedAnchor = node.nodeName.toLowerCase() === 'a' && !getAttrib(node, 'href') && getAttrib(node, 'id');
|
- |
|
| 4730 |
if (getAttrib(node, 'name') || getAttrib(node, 'data-mce-bookmark') || isNamedAnchor) {
|
- |
|
| 4731 |
return true;
|
- |
|
| 4732 |
}
|
- |
|
| 4733 |
}
|
- |
|
| 4734 |
return false;
|
- |
|
| 4735 |
};
|
- |
|
| 4736 |
const isEmpty = (node, elements, options) => {
|
4693 |
const isEmpty = (node, elements, options) => {
|
| 4737 |
let brCount = 0;
|
- |
|
| 4738 |
if (isNonEmptyElement(node)) {
|
4694 |
if (isPlainObject(elements)) {
|
| 4739 |
return false;
|
- |
|
| 4740 |
}
|
- |
|
| 4741 |
const firstChild = node.firstChild;
|
- |
|
| 4742 |
if (firstChild) {
|
- |
|
| 4743 |
const walker = new DomTreeWalker(firstChild, node);
|
- |
|
| 4744 |
const whitespaceElements = schema ? schema.getWhitespaceElements() : {};
|
- |
|
| 4745 |
const nonEmptyElements = elements || (schema ? schema.getNonEmptyElements() : null);
|
- |
|
| 4746 |
let tempNode = firstChild;
|
- |
|
| 4747 |
do {
|
- |
|
| 4748 |
if (isElement$6(tempNode)) {
|
4695 |
const isContent = node => {
|
| 4749 |
const bogusVal = tempNode.getAttribute('data-mce-bogus');
|
- |
|
| 4750 |
if (bogusVal) {
|
- |
|
| 4751 |
tempNode = walker.next(bogusVal === 'all');
|
- |
|
| 4752 |
continue;
|
- |
|
| 4753 |
}
|
- |
|
| 4754 |
const name = tempNode.nodeName.toLowerCase();
|
4696 |
const name = node.nodeName.toLowerCase();
|
| 4755 |
if (nonEmptyElements && nonEmptyElements[name]) {
|
- |
|
| 4756 |
if (name === 'br') {
|
- |
|
| 4757 |
brCount++;
|
- |
|
| 4758 |
tempNode = walker.next();
|
- |
|
| 4759 |
continue;
|
- |
|
| 4760 |
}
|
- |
|
| 4761 |
return false;
|
- |
|
| 4762 |
}
|
- |
|
| 4763 |
if (isNonEmptyElement(tempNode)) {
|
4697 |
return Boolean(elements[name]);
|
| 4764 |
return false;
|
- |
|
| 4765 |
}
|
- |
|
| 4766 |
}
|
4698 |
};
|
| 4767 |
if (isComment(tempNode)) {
|
4699 |
return isEmptyNode(schema, node, {
|
| 4768 |
return false;
|
4700 |
...options,
|
| 4769 |
}
|
4701 |
isContent
|
| 4770 |
if (isText$a(tempNode) && !isWhitespaceText(tempNode.data) && (!(options === null || options === void 0 ? void 0 : options.includeZwsp) || !isZwsp(tempNode.data))) {
|
- |
|
| 4771 |
return false;
|
- |
|
| 4772 |
}
|
4702 |
});
|
| 4773 |
if (isText$a(tempNode) && tempNode.parentNode && whitespaceElements[tempNode.parentNode.nodeName] && isWhitespaceText(tempNode.data)) {
|
- |
|
| 4774 |
return false;
|
- |
|
| 4775 |
}
|
4703 |
} else {
|
| 4776 |
tempNode = walker.next();
|
4704 |
return isEmptyNode(schema, node, options);
|
| 4777 |
} while (tempNode);
|
- |
|
| 4778 |
}
|
4705 |
}
|
| 4779 |
return brCount <= 1;
|
- |
|
| 4780 |
};
|
4706 |
};
|
| 4781 |
const createRng = () => doc.createRange();
|
4707 |
const createRng = () => doc.createRange();
|
| 4782 |
const split = (parentElm, splitElm, replacementElm) => {
|
4708 |
const split = (parentElm, splitElm, replacementElm) => {
|
| 4783 |
let range = createRng();
|
4709 |
let range = createRng();
|
| 4784 |
let beforeFragment;
|
4710 |
let beforeFragment;
|
| Línea 5124... |
Línea 5050... |
| 5124 |
}
|
5050 |
}
|
| 5125 |
}
|
5051 |
}
|
| 5126 |
}
|
5052 |
}
|
| 5127 |
ScriptLoader.ScriptLoader = new ScriptLoader();
|
5053 |
ScriptLoader.ScriptLoader = new ScriptLoader();
|
| Línea 5128... |
Línea -... |
| 5128 |
|
- |
|
| 5129 |
const Cell = initial => {
|
- |
|
| 5130 |
let value = initial;
|
- |
|
| 5131 |
const get = () => {
|
- |
|
| 5132 |
return value;
|
- |
|
| 5133 |
};
|
- |
|
| 5134 |
const set = v => {
|
- |
|
| 5135 |
value = v;
|
- |
|
| 5136 |
};
|
- |
|
| 5137 |
return {
|
- |
|
| 5138 |
get,
|
- |
|
| 5139 |
set
|
- |
|
| 5140 |
};
|
- |
|
| 5141 |
};
|
- |
|
| 5142 |
|
5054 |
|
| 5143 |
const isDuplicated = (items, item) => {
|
5055 |
const isDuplicated = (items, item) => {
|
| 5144 |
const firstIndex = items.indexOf(item);
|
5056 |
const firstIndex = items.indexOf(item);
|
| 5145 |
return firstIndex !== -1 && items.indexOf(item, firstIndex + 1) > firstIndex;
|
5057 |
return firstIndex !== -1 && items.indexOf(item, firstIndex + 1) > firstIndex;
|
| 5146 |
};
|
5058 |
};
|
| Línea 5323... |
Línea 5235... |
| 5323 |
AddOnManager.baseURL = '';
|
5235 |
AddOnManager.baseURL = '';
|
| 5324 |
AddOnManager.PluginManager = AddOnManager();
|
5236 |
AddOnManager.PluginManager = AddOnManager();
|
| 5325 |
AddOnManager.ThemeManager = AddOnManager();
|
5237 |
AddOnManager.ThemeManager = AddOnManager();
|
| 5326 |
AddOnManager.ModelManager = AddOnManager();
|
5238 |
AddOnManager.ModelManager = AddOnManager();
|
| Línea 5327... |
Línea -... |
| 5327 |
|
- |
|
| 5328 |
const singleton = doRevoke => {
|
- |
|
| 5329 |
const subject = Cell(Optional.none());
|
- |
|
| 5330 |
const revoke = () => subject.get().each(doRevoke);
|
- |
|
| 5331 |
const clear = () => {
|
- |
|
| 5332 |
revoke();
|
- |
|
| 5333 |
subject.set(Optional.none());
|
- |
|
| 5334 |
};
|
- |
|
| 5335 |
const isSet = () => subject.get().isSome();
|
- |
|
| 5336 |
const get = () => subject.get();
|
- |
|
| 5337 |
const set = s => {
|
- |
|
| 5338 |
revoke();
|
- |
|
| 5339 |
subject.set(Optional.some(s));
|
- |
|
| 5340 |
};
|
- |
|
| 5341 |
return {
|
- |
|
| 5342 |
clear,
|
- |
|
| 5343 |
isSet,
|
- |
|
| 5344 |
get,
|
- |
|
| 5345 |
set
|
- |
|
| 5346 |
};
|
- |
|
| 5347 |
};
|
- |
|
| 5348 |
const repeatable = delay => {
|
- |
|
| 5349 |
const intervalId = Cell(Optional.none());
|
- |
|
| 5350 |
const revoke = () => intervalId.get().each(id => clearInterval(id));
|
- |
|
| 5351 |
const clear = () => {
|
- |
|
| 5352 |
revoke();
|
- |
|
| 5353 |
intervalId.set(Optional.none());
|
- |
|
| 5354 |
};
|
- |
|
| 5355 |
const isSet = () => intervalId.get().isSome();
|
- |
|
| 5356 |
const get = () => intervalId.get();
|
- |
|
| 5357 |
const set = functionToRepeat => {
|
- |
|
| 5358 |
revoke();
|
- |
|
| 5359 |
intervalId.set(Optional.some(setInterval(functionToRepeat, delay)));
|
- |
|
| 5360 |
};
|
- |
|
| 5361 |
return {
|
- |
|
| 5362 |
clear,
|
- |
|
| 5363 |
isSet,
|
- |
|
| 5364 |
get,
|
- |
|
| 5365 |
set
|
- |
|
| 5366 |
};
|
- |
|
| 5367 |
};
|
- |
|
| 5368 |
const value$2 = () => {
|
- |
|
| 5369 |
const subject = singleton(noop);
|
- |
|
| 5370 |
const on = f => subject.get().each(f);
|
- |
|
| 5371 |
return {
|
- |
|
| 5372 |
...subject,
|
- |
|
| 5373 |
on
|
- |
|
| 5374 |
};
|
- |
|
| 5375 |
};
|
- |
|
| 5376 |
|
5239 |
|
| 5377 |
const first$1 = (fn, rate) => {
|
5240 |
const first$1 = (fn, rate) => {
|
| 5378 |
let timer = null;
|
5241 |
let timer = null;
|
| 5379 |
const cancel = () => {
|
5242 |
const cancel = () => {
|
| 5380 |
if (!isNull(timer)) {
|
5243 |
if (!isNull(timer)) {
|
| Línea 5393... |
Línea 5256... |
| 5393 |
return {
|
5256 |
return {
|
| 5394 |
cancel,
|
5257 |
cancel,
|
| 5395 |
throttle
|
5258 |
throttle
|
| 5396 |
};
|
5259 |
};
|
| 5397 |
};
|
5260 |
};
|
| 5398 |
const last$1 = (fn, rate) => {
|
5261 |
const last = (fn, rate) => {
|
| 5399 |
let timer = null;
|
5262 |
let timer = null;
|
| 5400 |
const cancel = () => {
|
5263 |
const cancel = () => {
|
| 5401 |
if (!isNull(timer)) {
|
5264 |
if (!isNull(timer)) {
|
| 5402 |
clearTimeout(timer);
|
5265 |
clearTimeout(timer);
|
| 5403 |
timer = null;
|
5266 |
timer = null;
|
| Línea 5414... |
Línea 5277... |
| 5414 |
cancel,
|
5277 |
cancel,
|
| 5415 |
throttle
|
5278 |
throttle
|
| 5416 |
};
|
5279 |
};
|
| 5417 |
};
|
5280 |
};
|
| Línea -... |
Línea 5281... |
| - |
|
5281 |
|
| - |
|
5282 |
const ancestor$1 = (scope, selector, isRoot) => ancestor$3(scope, selector, isRoot).isSome();
|
| 5418 |
|
5283 |
|
| 5419 |
const annotation = constant('mce-annotation');
|
5284 |
const annotation = constant('mce-annotation');
|
| 5420 |
const dataAnnotation = constant('data-mce-annotation');
|
5285 |
const dataAnnotation = constant('data-mce-annotation');
|
| 5421 |
const dataAnnotationId = constant('data-mce-annotation-uid');
|
5286 |
const dataAnnotationId = constant('data-mce-annotation-uid');
|
| 5422 |
const dataAnnotationActive = constant('data-mce-annotation-active');
|
5287 |
const dataAnnotationActive = constant('data-mce-annotation-active');
|
| Línea 5439... |
Línea 5304... |
| 5439 |
elements
|
5304 |
elements
|
| 5440 |
};
|
5305 |
};
|
| 5441 |
})));
|
5306 |
})));
|
| 5442 |
};
|
5307 |
};
|
| 5443 |
const isAnnotation = elem => isElement$7(elem) && has(elem, annotation());
|
5308 |
const isAnnotation = elem => isElement$7(elem) && has(elem, annotation());
|
| 5444 |
const isBogusElement = (elem, root) => has$1(elem, 'data-mce-bogus') || ancestor$2(elem, '[data-mce-bogus="all"]', isRoot$1(root));
|
5309 |
const isBogusElement = (elem, root) => has$1(elem, 'data-mce-bogus') || ancestor$1(elem, '[data-mce-bogus="all"]', isRoot$1(root));
|
| 5445 |
const findMarkers = (editor, uid) => {
|
5310 |
const findMarkers = (editor, uid) => {
|
| 5446 |
const body = SugarElement.fromDom(editor.getBody());
|
5311 |
const body = SugarElement.fromDom(editor.getBody());
|
| 5447 |
const descendants$1 = descendants(body, `[${ dataAnnotationId() }="${ uid }"]`);
|
5312 |
const descendants$1 = descendants(body, `[${ dataAnnotationId() }="${ uid }"]`);
|
| 5448 |
return filter$5(descendants$1, descendant => !isBogusElement(descendant, body));
|
5313 |
return filter$5(descendants$1, descendant => !isBogusElement(descendant, body));
|
| 5449 |
};
|
5314 |
};
|
| Línea 5494... |
Línea 5359... |
| 5494 |
});
|
5359 |
});
|
| 5495 |
};
|
5360 |
};
|
| 5496 |
const toggleActiveAttr = (uid, state) => {
|
5361 |
const toggleActiveAttr = (uid, state) => {
|
| 5497 |
each$e(findMarkers(editor, uid), elem => {
|
5362 |
each$e(findMarkers(editor, uid), elem => {
|
| 5498 |
if (state) {
|
5363 |
if (state) {
|
| 5499 |
set$3(elem, dataAnnotationActive(), 'true');
|
5364 |
set$4(elem, dataAnnotationActive(), 'true');
|
| 5500 |
} else {
|
5365 |
} else {
|
| 5501 |
remove$a(elem, dataAnnotationActive());
|
5366 |
remove$9(elem, dataAnnotationActive());
|
| 5502 |
}
|
5367 |
}
|
| 5503 |
});
|
5368 |
});
|
| 5504 |
};
|
5369 |
};
|
| 5505 |
const onNodeChange = last$1(() => {
|
5370 |
const onNodeChange = last(() => {
|
| 5506 |
const annotations = sort(registry.getNames());
|
5371 |
const annotations = sort(registry.getNames());
|
| 5507 |
each$e(annotations, name => {
|
5372 |
each$e(annotations, name => {
|
| 5508 |
updateCallbacks(name, data => {
|
5373 |
updateCallbacks(name, data => {
|
| 5509 |
const prev = data.previous.get();
|
5374 |
const prev = data.previous.get();
|
| 5510 |
identify(editor, Optional.some(name)).fold(() => {
|
5375 |
identify(editor, Optional.some(name)).fold(() => {
|
| Línea 5574... |
Línea 5439... |
| 5574 |
});
|
5439 |
});
|
| 5575 |
}
|
5440 |
}
|
| 5576 |
});
|
5441 |
});
|
| 5577 |
};
|
5442 |
};
|
| Línea 5578... |
Línea 5443... |
| 5578 |
|
5443 |
|
| 5579 |
const create$c = () => {
|
5444 |
const create$b = () => {
|
| 5580 |
const annotations = {};
|
5445 |
const annotations = {};
|
| 5581 |
const register = (name, settings) => {
|
5446 |
const register = (name, settings) => {
|
| 5582 |
annotations[name] = {
|
5447 |
annotations[name] = {
|
| 5583 |
name,
|
5448 |
name,
|
| Línea 5591... |
Línea 5456... |
| 5591 |
lookup,
|
5456 |
lookup,
|
| 5592 |
getNames
|
5457 |
getNames
|
| 5593 |
};
|
5458 |
};
|
| 5594 |
};
|
5459 |
};
|
| Línea -... |
Línea 5460... |
| - |
|
5460 |
|
| - |
|
5461 |
const clamp$2 = (value, min, max) => Math.min(Math.max(value, min), max);
|
| - |
|
5462 |
const random = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
|
| 5595 |
|
5463 |
|
| 5596 |
let unique = 0;
|
5464 |
let unique = 0;
|
| 5597 |
const generate$1 = prefix => {
|
5465 |
const generate$1 = prefix => {
|
| 5598 |
const date = new Date();
|
5466 |
const date = new Date();
|
| 5599 |
const time = date.getTime();
|
5467 |
const time = date.getTime();
|
| 5600 |
const random = Math.floor(Math.random() * 1000000000);
|
5468 |
const random$1 = Math.floor(random() * 1000000000);
|
| 5601 |
unique++;
|
5469 |
unique++;
|
| 5602 |
return prefix + '_' + random + unique + String(time);
|
5470 |
return prefix + '_' + random$1 + unique + String(time);
|
| Línea 5603... |
Línea 5471... |
| 5603 |
};
|
5471 |
};
|
| 5604 |
|
5472 |
|
| 5605 |
const add = (element, classes) => {
|
5473 |
const add = (element, classes) => {
|
| 5606 |
each$e(classes, x => {
|
5474 |
each$e(classes, x => {
|
| 5607 |
add$2(element, x);
|
5475 |
add$2(element, x);
|
| 5608 |
});
|
5476 |
});
|
| 5609 |
};
|
5477 |
};
|
| 5610 |
const remove$4 = (element, classes) => {
|
5478 |
const remove$3 = (element, classes) => {
|
| 5611 |
each$e(classes, x => {
|
5479 |
each$e(classes, x => {
|
| 5612 |
remove$7(element, x);
|
5480 |
remove$6(element, x);
|
| Línea 5613... |
Línea 5481... |
| 5613 |
});
|
5481 |
});
|
| 5614 |
};
|
5482 |
};
|
| Línea 5625... |
Línea 5493... |
| 5625 |
const mutate = (original, tag) => {
|
5493 |
const mutate = (original, tag) => {
|
| 5626 |
const nu = shallowAs(original, tag);
|
5494 |
const nu = shallowAs(original, tag);
|
| 5627 |
after$4(original, nu);
|
5495 |
after$4(original, nu);
|
| 5628 |
const children = children$1(original);
|
5496 |
const children = children$1(original);
|
| 5629 |
append(nu, children);
|
5497 |
append(nu, children);
|
| 5630 |
remove$5(original);
|
5498 |
remove$4(original);
|
| 5631 |
return nu;
|
5499 |
return nu;
|
| 5632 |
};
|
5500 |
};
|
| Línea 5633... |
Línea 5501... |
| 5633 |
|
5501 |
|
| 5634 |
const TextWalker = (startNode, rootNode, isBoundary = never) => {
|
5502 |
const TextWalker = (startNode, rootNode, isBoundary = never) => {
|
| 5635 |
const walker = new DomTreeWalker(startNode, rootNode);
|
5503 |
const walker = new DomTreeWalker(startNode, rootNode);
|
| 5636 |
const walk = direction => {
|
5504 |
const walk = direction => {
|
| 5637 |
let next;
|
5505 |
let next;
|
| 5638 |
do {
|
5506 |
do {
|
| 5639 |
next = walker[direction]();
|
5507 |
next = walker[direction]();
|
| 5640 |
} while (next && !isText$a(next) && !isBoundary(next));
|
5508 |
} while (next && !isText$b(next) && !isBoundary(next));
|
| 5641 |
return Optional.from(next).filter(isText$a);
|
5509 |
return Optional.from(next).filter(isText$b);
|
| 5642 |
};
|
5510 |
};
|
| 5643 |
return {
|
5511 |
return {
|
| 5644 |
current: () => Optional.from(walker.current()).filter(isText$a),
|
5512 |
current: () => Optional.from(walker.current()).filter(isText$b),
|
| 5645 |
next: () => walk('next'),
|
5513 |
next: () => walk('next'),
|
| 5646 |
prev: () => walk('prev'),
|
5514 |
prev: () => walk('prev'),
|
| 5647 |
prev2: () => walk('prev2')
|
5515 |
prev2: () => walk('prev2')
|
| 5648 |
};
|
5516 |
};
|
| Línea 5649... |
Línea 5517... |
| 5649 |
};
|
5517 |
};
|
| 5650 |
|
5518 |
|
| 5651 |
const TextSeeker = (dom, isBoundary) => {
|
5519 |
const TextSeeker = (dom, isBoundary) => {
|
| 5652 |
const isBlockBoundary = isBoundary ? isBoundary : node => dom.isBlock(node) || isBr$6(node) || isContentEditableFalse$b(node);
|
5520 |
const isBlockBoundary = isBoundary ? isBoundary : node => dom.isBlock(node) || isBr$6(node) || isContentEditableFalse$b(node);
|
| 5653 |
const walk = (node, offset, walker, process) => {
|
5521 |
const walk = (node, offset, walker, process) => {
|
| 5654 |
if (isText$a(node)) {
|
5522 |
if (isText$b(node)) {
|
| 5655 |
const newOffset = process(node, offset, node.data);
|
5523 |
const newOffset = process(node, offset, node.data);
|
| 5656 |
if (newOffset !== -1) {
|
5524 |
if (newOffset !== -1) {
|
| 5657 |
return Optional.some({
|
5525 |
return Optional.some({
|
| Línea 5680... |
Línea 5548... |
| 5680 |
backwards,
|
5548 |
backwards,
|
| 5681 |
forwards
|
5549 |
forwards
|
| 5682 |
};
|
5550 |
};
|
| 5683 |
};
|
5551 |
};
|
| Línea -... |
Línea 5552... |
| - |
|
5552 |
|
| - |
|
5553 |
const NodeValue = (is, name) => {
|
| - |
|
5554 |
const get = element => {
|
| - |
|
5555 |
if (!is(element)) {
|
| - |
|
5556 |
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
| - |
|
5557 |
}
|
| - |
|
5558 |
return getOption(element).getOr('');
|
| - |
|
5559 |
};
|
| - |
|
5560 |
const getOption = element => is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
| - |
|
5561 |
const set = (element, value) => {
|
| - |
|
5562 |
if (!is(element)) {
|
| - |
|
5563 |
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
| - |
|
5564 |
}
|
| - |
|
5565 |
element.dom.nodeValue = value;
|
| - |
|
5566 |
};
|
| - |
|
5567 |
return {
|
| - |
|
5568 |
get,
|
| - |
|
5569 |
getOption,
|
| - |
|
5570 |
set
|
| - |
|
5571 |
};
|
| - |
|
5572 |
};
|
| - |
|
5573 |
|
| - |
|
5574 |
const api$1 = NodeValue(isText$c, 'text');
|
| - |
|
5575 |
const get$3 = element => api$1.get(element);
|
| - |
|
5576 |
const getOption = element => api$1.getOption(element);
|
| - |
|
5577 |
const set = (element, value) => api$1.set(element, value);
|
| - |
|
5578 |
|
| - |
|
5579 |
const tableCells = [
|
| - |
|
5580 |
'td',
|
| - |
|
5581 |
'th'
|
| - |
|
5582 |
];
|
| - |
|
5583 |
const tableSections = [
|
| - |
|
5584 |
'thead',
|
| - |
|
5585 |
'tbody',
|
| - |
|
5586 |
'tfoot'
|
| - |
|
5587 |
];
|
| - |
|
5588 |
const textBlocks = [
|
| - |
|
5589 |
'h1',
|
| - |
|
5590 |
'h2',
|
| - |
|
5591 |
'h3',
|
| - |
|
5592 |
'h4',
|
| - |
|
5593 |
'h5',
|
| - |
|
5594 |
'h6',
|
| - |
|
5595 |
'p',
|
| - |
|
5596 |
'div',
|
| - |
|
5597 |
'address',
|
| - |
|
5598 |
'pre',
|
| - |
|
5599 |
'form',
|
| - |
|
5600 |
'blockquote',
|
| - |
|
5601 |
'center',
|
| - |
|
5602 |
'dir',
|
| - |
|
5603 |
'fieldset',
|
| - |
|
5604 |
'header',
|
| - |
|
5605 |
'footer',
|
| - |
|
5606 |
'article',
|
| - |
|
5607 |
'section',
|
| - |
|
5608 |
'hgroup',
|
| - |
|
5609 |
'aside',
|
| - |
|
5610 |
'nav',
|
| - |
|
5611 |
'figure'
|
| - |
|
5612 |
];
|
| - |
|
5613 |
const listItems$1 = [
|
| - |
|
5614 |
'li',
|
| - |
|
5615 |
'dd',
|
| - |
|
5616 |
'dt'
|
| - |
|
5617 |
];
|
| - |
|
5618 |
const lists = [
|
| - |
|
5619 |
'ul',
|
| - |
|
5620 |
'ol',
|
| - |
|
5621 |
'dl'
|
| - |
|
5622 |
];
|
| - |
|
5623 |
const wsElements = [
|
| - |
|
5624 |
'pre',
|
| - |
|
5625 |
'script',
|
| - |
|
5626 |
'textarea',
|
| - |
|
5627 |
'style'
|
| - |
|
5628 |
];
|
| - |
|
5629 |
const lazyLookup = items => {
|
| - |
|
5630 |
let lookup;
|
| - |
|
5631 |
return node => {
|
| - |
|
5632 |
lookup = lookup ? lookup : mapToObject(items, always);
|
| - |
|
5633 |
return has$2(lookup, name(node));
|
| - |
|
5634 |
};
|
| - |
|
5635 |
};
|
| - |
|
5636 |
const isTable$1 = node => name(node) === 'table';
|
| - |
|
5637 |
const isBr$5 = node => isElement$7(node) && name(node) === 'br';
|
| - |
|
5638 |
const isTextBlock$2 = lazyLookup(textBlocks);
|
| - |
|
5639 |
const isList = lazyLookup(lists);
|
| - |
|
5640 |
const isListItem$1 = lazyLookup(listItems$1);
|
| - |
|
5641 |
const isTableSection = lazyLookup(tableSections);
|
| - |
|
5642 |
const isTableCell$2 = lazyLookup(tableCells);
|
| - |
|
5643 |
const isWsPreserveElement = lazyLookup(wsElements);
|
| - |
|
5644 |
|
| - |
|
5645 |
const getLastChildren$1 = elm => {
|
| - |
|
5646 |
const children = [];
|
| - |
|
5647 |
let rawNode = elm.dom;
|
| - |
|
5648 |
while (rawNode) {
|
| - |
|
5649 |
children.push(SugarElement.fromDom(rawNode));
|
| - |
|
5650 |
rawNode = rawNode.lastChild;
|
| - |
|
5651 |
}
|
| - |
|
5652 |
return children;
|
| - |
|
5653 |
};
|
| - |
|
5654 |
const removeTrailingBr = elm => {
|
| - |
|
5655 |
const allBrs = descendants(elm, 'br');
|
| - |
|
5656 |
const brs = filter$5(getLastChildren$1(elm).slice(-1), isBr$5);
|
| - |
|
5657 |
if (allBrs.length === brs.length) {
|
| - |
|
5658 |
each$e(brs, remove$4);
|
| - |
|
5659 |
}
|
| - |
|
5660 |
};
|
| - |
|
5661 |
const createPaddingBr = () => {
|
| - |
|
5662 |
const br = SugarElement.fromTag('br');
|
| - |
|
5663 |
set$4(br, 'data-mce-bogus', '1');
|
| - |
|
5664 |
return br;
|
| - |
|
5665 |
};
|
| - |
|
5666 |
const fillWithPaddingBr = elm => {
|
| - |
|
5667 |
empty(elm);
|
| - |
|
5668 |
append$1(elm, createPaddingBr());
|
| - |
|
5669 |
};
|
| - |
|
5670 |
const trimBlockTrailingBr = (elm, schema) => {
|
| - |
|
5671 |
lastChild(elm).each(lastChild => {
|
| - |
|
5672 |
prevSibling(lastChild).each(lastChildPrevSibling => {
|
| - |
|
5673 |
if (schema.isBlock(name(elm)) && isBr$5(lastChild) && schema.isBlock(name(lastChildPrevSibling))) {
|
| - |
|
5674 |
remove$4(lastChild);
|
| - |
|
5675 |
}
|
| - |
|
5676 |
});
|
| - |
|
5677 |
});
|
| - |
|
5678 |
};
|
| - |
|
5679 |
|
| - |
|
5680 |
const ZWSP$1 = zeroWidth;
|
| - |
|
5681 |
const isZwsp = isZwsp$2;
|
| - |
|
5682 |
const trim$2 = removeZwsp;
|
| - |
|
5683 |
const insert$5 = editor => editor.insertContent(ZWSP$1, { preserve_zwsp: true });
|
| - |
|
5684 |
|
| - |
|
5685 |
const isElement$5 = isElement$6;
|
| - |
|
5686 |
const isText$9 = isText$b;
|
| - |
|
5687 |
const isCaretContainerBlock$1 = node => {
|
| - |
|
5688 |
if (isText$9(node)) {
|
| - |
|
5689 |
node = node.parentNode;
|
| - |
|
5690 |
}
|
| - |
|
5691 |
return isElement$5(node) && node.hasAttribute('data-mce-caret');
|
| - |
|
5692 |
};
|
| - |
|
5693 |
const isCaretContainerInline = node => isText$9(node) && isZwsp(node.data);
|
| - |
|
5694 |
const isCaretContainer$2 = node => isCaretContainerBlock$1(node) || isCaretContainerInline(node);
|
| - |
|
5695 |
const hasContent = node => node.firstChild !== node.lastChild || !isBr$6(node.firstChild);
|
| - |
|
5696 |
const insertInline$1 = (node, before) => {
|
| - |
|
5697 |
var _a;
|
| - |
|
5698 |
const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;
|
| - |
|
5699 |
const textNode = doc.createTextNode(ZWSP$1);
|
| - |
|
5700 |
const parentNode = node.parentNode;
|
| - |
|
5701 |
if (!before) {
|
| - |
|
5702 |
const sibling = node.nextSibling;
|
| - |
|
5703 |
if (isText$9(sibling)) {
|
| - |
|
5704 |
if (isCaretContainer$2(sibling)) {
|
| - |
|
5705 |
return sibling;
|
| - |
|
5706 |
}
|
| - |
|
5707 |
if (startsWithCaretContainer$1(sibling)) {
|
| - |
|
5708 |
sibling.splitText(1);
|
| - |
|
5709 |
return sibling;
|
| - |
|
5710 |
}
|
| - |
|
5711 |
}
|
| - |
|
5712 |
if (node.nextSibling) {
|
| - |
|
5713 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(textNode, node.nextSibling);
|
| - |
|
5714 |
} else {
|
| - |
|
5715 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(textNode);
|
| - |
|
5716 |
}
|
| - |
|
5717 |
} else {
|
| - |
|
5718 |
const sibling = node.previousSibling;
|
| - |
|
5719 |
if (isText$9(sibling)) {
|
| - |
|
5720 |
if (isCaretContainer$2(sibling)) {
|
| - |
|
5721 |
return sibling;
|
| - |
|
5722 |
}
|
| - |
|
5723 |
if (endsWithCaretContainer$1(sibling)) {
|
| - |
|
5724 |
return sibling.splitText(sibling.data.length - 1);
|
| - |
|
5725 |
}
|
| - |
|
5726 |
}
|
| - |
|
5727 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(textNode, node);
|
| - |
|
5728 |
}
|
| - |
|
5729 |
return textNode;
|
| - |
|
5730 |
};
|
| - |
|
5731 |
const isBeforeInline = pos => {
|
| - |
|
5732 |
const container = pos.container();
|
| - |
|
5733 |
if (!isText$b(container)) {
|
| - |
|
5734 |
return false;
|
| - |
|
5735 |
}
|
| - |
|
5736 |
return container.data.charAt(pos.offset()) === ZWSP$1 || pos.isAtStart() && isCaretContainerInline(container.previousSibling);
|
| - |
|
5737 |
};
|
| - |
|
5738 |
const isAfterInline = pos => {
|
| - |
|
5739 |
const container = pos.container();
|
| - |
|
5740 |
if (!isText$b(container)) {
|
| - |
|
5741 |
return false;
|
| - |
|
5742 |
}
|
| - |
|
5743 |
return container.data.charAt(pos.offset() - 1) === ZWSP$1 || pos.isAtEnd() && isCaretContainerInline(container.nextSibling);
|
| - |
|
5744 |
};
|
| - |
|
5745 |
const insertBlock = (blockName, node, before) => {
|
| - |
|
5746 |
var _a;
|
| - |
|
5747 |
const doc = (_a = node.ownerDocument) !== null && _a !== void 0 ? _a : document;
|
| - |
|
5748 |
const blockNode = doc.createElement(blockName);
|
| - |
|
5749 |
blockNode.setAttribute('data-mce-caret', before ? 'before' : 'after');
|
| - |
|
5750 |
blockNode.setAttribute('data-mce-bogus', 'all');
|
| - |
|
5751 |
blockNode.appendChild(createPaddingBr().dom);
|
| - |
|
5752 |
const parentNode = node.parentNode;
|
| - |
|
5753 |
if (!before) {
|
| - |
|
5754 |
if (node.nextSibling) {
|
| - |
|
5755 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(blockNode, node.nextSibling);
|
| - |
|
5756 |
} else {
|
| - |
|
5757 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.appendChild(blockNode);
|
| - |
|
5758 |
}
|
| - |
|
5759 |
} else {
|
| - |
|
5760 |
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insertBefore(blockNode, node);
|
| - |
|
5761 |
}
|
| - |
|
5762 |
return blockNode;
|
| - |
|
5763 |
};
|
| - |
|
5764 |
const startsWithCaretContainer$1 = node => isText$9(node) && node.data[0] === ZWSP$1;
|
| - |
|
5765 |
const endsWithCaretContainer$1 = node => isText$9(node) && node.data[node.data.length - 1] === ZWSP$1;
|
| - |
|
5766 |
const trimBogusBr = elm => {
|
| - |
|
5767 |
var _a;
|
| - |
|
5768 |
const brs = elm.getElementsByTagName('br');
|
| - |
|
5769 |
const lastBr = brs[brs.length - 1];
|
| - |
|
5770 |
if (isBogus$1(lastBr)) {
|
| - |
|
5771 |
(_a = lastBr.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(lastBr);
|
| - |
|
5772 |
}
|
| - |
|
5773 |
};
|
| - |
|
5774 |
const showCaretContainerBlock = caretContainer => {
|
| - |
|
5775 |
if (caretContainer && caretContainer.hasAttribute('data-mce-caret')) {
|
| - |
|
5776 |
trimBogusBr(caretContainer);
|
| - |
|
5777 |
caretContainer.removeAttribute('data-mce-caret');
|
| - |
|
5778 |
caretContainer.removeAttribute('data-mce-bogus');
|
| - |
|
5779 |
caretContainer.removeAttribute('style');
|
| - |
|
5780 |
caretContainer.removeAttribute('data-mce-style');
|
| - |
|
5781 |
caretContainer.removeAttribute('_moz_abspos');
|
| - |
|
5782 |
return caretContainer;
|
| - |
|
5783 |
}
|
| - |
|
5784 |
return null;
|
| - |
|
5785 |
};
|
| - |
|
5786 |
const isRangeInCaretContainerBlock = range => isCaretContainerBlock$1(range.startContainer);
|
| 5684 |
|
5787 |
|
| 5685 |
const round$2 = Math.round;
|
5788 |
const round$2 = Math.round;
|
| 5686 |
const clone$1 = rect => {
|
5789 |
const clone$1 = rect => {
|
| 5687 |
if (!rect) {
|
5790 |
if (!rect) {
|
| 5688 |
return {
|
5791 |
return {
|
| Línea 5759... |
Línea 5862... |
| 5759 |
const cy = Math.max(Math.min(y, rect.top + rect.height), rect.top);
|
5862 |
const cy = Math.max(Math.min(y, rect.top + rect.height), rect.top);
|
| 5760 |
return Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy));
|
5863 |
return Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy));
|
| 5761 |
};
|
5864 |
};
|
| 5762 |
const overlapY = (r1, r2) => Math.max(0, Math.min(r1.bottom, r2.bottom) - Math.max(r1.top, r2.top));
|
5865 |
const overlapY = (r1, r2) => Math.max(0, Math.min(r1.bottom, r2.bottom) - Math.max(r1.top, r2.top));
|
| Línea 5763... |
Línea -... |
| 5763 |
|
- |
|
| 5764 |
const clamp$2 = (value, min, max) => Math.min(Math.max(value, min), max);
|
- |
|
| 5765 |
|
5866 |
|
| 5766 |
const getSelectedNode = range => {
|
5867 |
const getSelectedNode = range => {
|
| 5767 |
const startContainer = range.startContainer, startOffset = range.startOffset;
|
5868 |
const startContainer = range.startContainer, startOffset = range.startOffset;
|
| 5768 |
if (startContainer === range.endContainer && startContainer.hasChildNodes() && range.endOffset === startOffset + 1) {
|
5869 |
if (startContainer === range.endContainer && startContainer.hasChildNodes() && range.endOffset === startOffset + 1) {
|
| 5769 |
return startContainer.childNodes[startOffset];
|
5870 |
return startContainer.childNodes[startOffset];
|
| Línea 5809... |
Línea 5910... |
| 5809 |
}
|
5910 |
}
|
| 5810 |
return true;
|
5911 |
return true;
|
| 5811 |
};
|
5912 |
};
|
| 5812 |
};
|
5913 |
};
|
| Línea -... |
Línea 5914... |
| - |
|
5914 |
|
| - |
|
5915 |
const isContentEditableTrue$2 = isContentEditableTrue$3;
|
| - |
|
5916 |
const isContentEditableFalse$a = isContentEditableFalse$b;
|
| - |
|
5917 |
const isBr$4 = isBr$6;
|
| - |
|
5918 |
const isText$8 = isText$b;
|
| - |
|
5919 |
const isInvalidTextElement = matchNodeNames([
|
| - |
|
5920 |
'script',
|
| - |
|
5921 |
'style',
|
| - |
|
5922 |
'textarea'
|
| - |
|
5923 |
]);
|
| - |
|
5924 |
const isAtomicInline = matchNodeNames([
|
| - |
|
5925 |
'img',
|
| - |
|
5926 |
'input',
|
| - |
|
5927 |
'textarea',
|
| - |
|
5928 |
'hr',
|
| - |
|
5929 |
'iframe',
|
| - |
|
5930 |
'video',
|
| - |
|
5931 |
'audio',
|
| - |
|
5932 |
'object',
|
| - |
|
5933 |
'embed'
|
| - |
|
5934 |
]);
|
| - |
|
5935 |
const isTable = matchNodeNames(['table']);
|
| - |
|
5936 |
const isCaretContainer$1 = isCaretContainer$2;
|
| - |
|
5937 |
const isCaretCandidate$3 = node => {
|
| - |
|
5938 |
if (isCaretContainer$1(node)) {
|
| - |
|
5939 |
return false;
|
| - |
|
5940 |
}
|
| - |
|
5941 |
if (isText$8(node)) {
|
| - |
|
5942 |
return !isInvalidTextElement(node.parentNode);
|
| - |
|
5943 |
}
|
| - |
|
5944 |
return isAtomicInline(node) || isBr$4(node) || isTable(node) || isNonUiContentEditableFalse(node);
|
| - |
|
5945 |
};
|
| - |
|
5946 |
const isUnselectable = node => isElement$6(node) && node.getAttribute('unselectable') === 'true';
|
| - |
|
5947 |
const isNonUiContentEditableFalse = node => !isUnselectable(node) && isContentEditableFalse$a(node);
|
| - |
|
5948 |
const isInEditable = (node, root) => {
|
| - |
|
5949 |
for (let tempNode = node.parentNode; tempNode && tempNode !== root; tempNode = tempNode.parentNode) {
|
| - |
|
5950 |
if (isNonUiContentEditableFalse(tempNode)) {
|
| - |
|
5951 |
return false;
|
| - |
|
5952 |
}
|
| - |
|
5953 |
if (isContentEditableTrue$2(tempNode)) {
|
| - |
|
5954 |
return true;
|
| - |
|
5955 |
}
|
| - |
|
5956 |
}
|
| - |
|
5957 |
return true;
|
| - |
|
5958 |
};
|
| - |
|
5959 |
const isAtomicContentEditableFalse = node => {
|
| - |
|
5960 |
if (!isNonUiContentEditableFalse(node)) {
|
| - |
|
5961 |
return false;
|
| - |
|
5962 |
}
|
| - |
|
5963 |
return !foldl(from(node.getElementsByTagName('*')), (result, elm) => {
|
| - |
|
5964 |
return result || isContentEditableTrue$2(elm);
|
| - |
|
5965 |
}, false);
|
| - |
|
5966 |
};
|
| - |
|
5967 |
const isAtomic$1 = node => isAtomicInline(node) || isAtomicContentEditableFalse(node);
|
| - |
|
5968 |
const isEditableCaretCandidate$1 = (node, root) => isCaretCandidate$3(node) && isInEditable(node, root);
|
| 5813 |
|
5969 |
|
| 5814 |
const isElement$4 = isElement$6;
|
5970 |
const isElement$4 = isElement$6;
|
| 5815 |
const isCaretCandidate$2 = isCaretCandidate$3;
|
5971 |
const isCaretCandidate$2 = isCaretCandidate$3;
|
| 5816 |
const isBlock$2 = matchStyleValues('display', 'block table');
|
5972 |
const isBlock$2 = matchStyleValues('display', 'block table');
|
| 5817 |
const isFloated = matchStyleValues('float', 'left right');
|
5973 |
const isFloated = matchStyleValues('float', 'left right');
|
| 5818 |
const isValidElementCaretCandidate = and(isElement$4, isCaretCandidate$2, not(isFloated));
|
5974 |
const isValidElementCaretCandidate = and(isElement$4, isCaretCandidate$2, not(isFloated));
|
| 5819 |
const isNotPre = not(matchStyleValues('white-space', 'pre pre-line pre-wrap'));
|
5975 |
const isNotPre = not(matchStyleValues('white-space', 'pre pre-line pre-wrap'));
|
| 5820 |
const isText$7 = isText$a;
|
5976 |
const isText$7 = isText$b;
|
| 5821 |
const isBr$3 = isBr$6;
|
5977 |
const isBr$3 = isBr$6;
|
| 5822 |
const nodeIndex$1 = DOMUtils.nodeIndex;
|
5978 |
const nodeIndex$1 = DOMUtils.nodeIndex;
|
| 5823 |
const resolveIndex$1 = getNodeUnsafe;
|
5979 |
const resolveIndex$1 = getNodeUnsafe;
|
| 5824 |
const createRange$1 = doc => doc ? doc.createRange() : DOMUtils.DOM.createRng();
|
5980 |
const createRange$1 = doc => doc ? doc.createRange() : DOMUtils.DOM.createRng();
|
| 5825 |
const isWhiteSpace$1 = chr => isString(chr) && /[\r\n\t ]/.test(chr);
|
5981 |
const isWhiteSpace$1 = chr => isString(chr) && /[\r\n\t ]/.test(chr);
|
| 5826 |
const isRange = rng => !!rng.setStart && !!rng.setEnd;
|
5982 |
const isRange = rng => !!rng.setStart && !!rng.setEnd;
|
| 5827 |
const isHiddenWhiteSpaceRange = range => {
|
5983 |
const isHiddenWhiteSpaceRange = range => {
|
| 5828 |
const container = range.startContainer;
|
5984 |
const container = range.startContainer;
|
| 5829 |
const offset = range.startOffset;
|
5985 |
const offset = range.startOffset;
|
| 5830 |
if (isWhiteSpace$1(range.toString()) && isNotPre(container.parentNode) && isText$a(container)) {
|
5986 |
if (isWhiteSpace$1(range.toString()) && isNotPre(container.parentNode) && isText$b(container)) {
|
| 5831 |
const text = container.data;
|
5987 |
const text = container.data;
|
| 5832 |
if (isWhiteSpace$1(text[offset - 1]) || isWhiteSpace$1(text[offset + 1])) {
|
5988 |
if (isWhiteSpace$1(text[offset - 1]) || isWhiteSpace$1(text[offset + 1])) {
|
| 5833 |
return true;
|
5989 |
return true;
|
| 5834 |
}
|
5990 |
}
|
| Línea 5850... |
Línea 6006... |
| 5850 |
const getBoundingClientRectWebKitText = rng => {
|
6006 |
const getBoundingClientRectWebKitText = rng => {
|
| 5851 |
const sc = rng.startContainer;
|
6007 |
const sc = rng.startContainer;
|
| 5852 |
const ec = rng.endContainer;
|
6008 |
const ec = rng.endContainer;
|
| 5853 |
const so = rng.startOffset;
|
6009 |
const so = rng.startOffset;
|
| 5854 |
const eo = rng.endOffset;
|
6010 |
const eo = rng.endOffset;
|
| 5855 |
if (sc === ec && isText$a(ec) && so === 0 && eo === 1) {
|
6011 |
if (sc === ec && isText$b(ec) && so === 0 && eo === 1) {
|
| 5856 |
const newRng = rng.cloneRange();
|
6012 |
const newRng = rng.cloneRange();
|
| 5857 |
newRng.setEndAfter(ec);
|
6013 |
newRng.setEndAfter(ec);
|
| 5858 |
return getBoundingClientRect$1(newRng);
|
6014 |
return getBoundingClientRect$1(newRng);
|
| 5859 |
} else {
|
6015 |
} else {
|
| 5860 |
return null;
|
6016 |
return null;
|
| Línea 6006... |
Línea 6162... |
| 6006 |
};
|
6162 |
};
|
| 6007 |
CaretPosition.fromRangeStart = range => CaretPosition(range.startContainer, range.startOffset);
|
6163 |
CaretPosition.fromRangeStart = range => CaretPosition(range.startContainer, range.startOffset);
|
| 6008 |
CaretPosition.fromRangeEnd = range => CaretPosition(range.endContainer, range.endOffset);
|
6164 |
CaretPosition.fromRangeEnd = range => CaretPosition(range.endContainer, range.endOffset);
|
| 6009 |
CaretPosition.after = node => CaretPosition(node.parentNode, nodeIndex$1(node) + 1);
|
6165 |
CaretPosition.after = node => CaretPosition(node.parentNode, nodeIndex$1(node) + 1);
|
| 6010 |
CaretPosition.before = node => CaretPosition(node.parentNode, nodeIndex$1(node));
|
6166 |
CaretPosition.before = node => CaretPosition(node.parentNode, nodeIndex$1(node));
|
| 6011 |
CaretPosition.isAbove = (pos1, pos2) => lift2(head(pos2.getClientRects()), last$3(pos1.getClientRects()), isAbove$1).getOr(false);
|
6167 |
CaretPosition.isAbove = (pos1, pos2) => lift2(head(pos2.getClientRects()), last$2(pos1.getClientRects()), isAbove$1).getOr(false);
|
| 6012 |
CaretPosition.isBelow = (pos1, pos2) => lift2(last$3(pos2.getClientRects()), head(pos1.getClientRects()), isBelow$1).getOr(false);
|
6168 |
CaretPosition.isBelow = (pos1, pos2) => lift2(last$2(pos2.getClientRects()), head(pos1.getClientRects()), isBelow$1).getOr(false);
|
| 6013 |
CaretPosition.isAtStart = pos => pos ? pos.isAtStart() : false;
|
6169 |
CaretPosition.isAtStart = pos => pos ? pos.isAtStart() : false;
|
| 6014 |
CaretPosition.isAtEnd = pos => pos ? pos.isAtEnd() : false;
|
6170 |
CaretPosition.isAtEnd = pos => pos ? pos.isAtEnd() : false;
|
| 6015 |
CaretPosition.isTextPosition = pos => pos ? isText$a(pos.container()) : false;
|
6171 |
CaretPosition.isTextPosition = pos => pos ? isText$b(pos.container()) : false;
|
| 6016 |
CaretPosition.isElementPosition = pos => !CaretPosition.isTextPosition(pos);
|
6172 |
CaretPosition.isElementPosition = pos => !CaretPosition.isTextPosition(pos);
|
| Línea 6017... |
Línea 6173... |
| 6017 |
|
6173 |
|
| 6018 |
const trimEmptyTextNode$1 = (dom, node) => {
|
6174 |
const trimEmptyTextNode$1 = (dom, node) => {
|
| 6019 |
if (isText$a(node) && node.data.length === 0) {
|
6175 |
if (isText$b(node) && node.data.length === 0) {
|
| 6020 |
dom.remove(node);
|
6176 |
dom.remove(node);
|
| 6021 |
}
|
6177 |
}
|
| 6022 |
};
|
6178 |
};
|
| 6023 |
const insertNode = (dom, rng, node) => {
|
6179 |
const insertNode = (dom, rng, node) => {
|
| Línea 6038... |
Línea 6194... |
| 6038 |
} else {
|
6194 |
} else {
|
| 6039 |
insertNode(dom, rng, node);
|
6195 |
insertNode(dom, rng, node);
|
| 6040 |
}
|
6196 |
}
|
| 6041 |
};
|
6197 |
};
|
| Línea 6042... |
Línea 6198... |
| 6042 |
|
6198 |
|
| 6043 |
const isText$6 = isText$a;
|
6199 |
const isText$6 = isText$b;
|
| 6044 |
const isBogus = isBogus$2;
|
6200 |
const isBogus = isBogus$1;
|
| 6045 |
const nodeIndex = DOMUtils.nodeIndex;
|
6201 |
const nodeIndex = DOMUtils.nodeIndex;
|
| 6046 |
const normalizedParent = node => {
|
6202 |
const normalizedParent = node => {
|
| 6047 |
const parentNode = node.parentNode;
|
6203 |
const parentNode = node.parentNode;
|
| 6048 |
if (isBogus(parentNode)) {
|
6204 |
if (isBogus(parentNode)) {
|
| Línea 6101... |
Línea 6257... |
| 6101 |
}
|
6257 |
}
|
| 6102 |
parents.push(tempNode);
|
6258 |
parents.push(tempNode);
|
| 6103 |
}
|
6259 |
}
|
| 6104 |
return parents;
|
6260 |
return parents;
|
| 6105 |
};
|
6261 |
};
|
| 6106 |
const create$b = (root, caretPosition) => {
|
6262 |
const create$a = (root, caretPosition) => {
|
| 6107 |
let path = [];
|
6263 |
let path = [];
|
| 6108 |
let container = caretPosition.container();
|
6264 |
let container = caretPosition.container();
|
| 6109 |
let offset = caretPosition.offset();
|
6265 |
let offset = caretPosition.offset();
|
| 6110 |
let outputOffset;
|
6266 |
let outputOffset;
|
| 6111 |
if (isText$6(container)) {
|
6267 |
if (isText$6(container)) {
|
| Línea 6120... |
Línea 6276... |
| 6120 |
}
|
6276 |
}
|
| 6121 |
container = childNodes[offset];
|
6277 |
container = childNodes[offset];
|
| 6122 |
}
|
6278 |
}
|
| 6123 |
path.push(createPathItem(container));
|
6279 |
path.push(createPathItem(container));
|
| 6124 |
let parents = parentsUntil$1(root, container);
|
6280 |
let parents = parentsUntil$1(root, container);
|
| 6125 |
parents = filter$3(parents, not(isBogus$2));
|
6281 |
parents = filter$3(parents, not(isBogus$1));
|
| 6126 |
path = path.concat(map$1(parents, node => {
|
6282 |
path = path.concat(map$1(parents, node => {
|
| 6127 |
return createPathItem(node);
|
6283 |
return createPathItem(node);
|
| 6128 |
}));
|
6284 |
}));
|
| 6129 |
return path.reverse().join('/') + ',' + outputOffset;
|
6285 |
return path.reverse().join('/') + ',' + outputOffset;
|
| 6130 |
};
|
6286 |
};
|
| Línea 6192... |
Línea 6348... |
| 6192 |
};
|
6348 |
};
|
| Línea 6193... |
Línea 6349... |
| 6193 |
|
6349 |
|
| 6194 |
const isContentEditableFalse$9 = isContentEditableFalse$b;
|
6350 |
const isContentEditableFalse$9 = isContentEditableFalse$b;
|
| 6195 |
const getNormalizedTextOffset$1 = (trim, container, offset) => {
|
6351 |
const getNormalizedTextOffset$1 = (trim, container, offset) => {
|
| 6196 |
let trimmedOffset = trim(container.data.slice(0, offset)).length;
|
6352 |
let trimmedOffset = trim(container.data.slice(0, offset)).length;
|
| 6197 |
for (let node = container.previousSibling; node && isText$a(node); node = node.previousSibling) {
|
6353 |
for (let node = container.previousSibling; node && isText$b(node); node = node.previousSibling) {
|
| 6198 |
trimmedOffset += trim(node.data).length;
|
6354 |
trimmedOffset += trim(node.data).length;
|
| 6199 |
}
|
6355 |
}
|
| 6200 |
return trimmedOffset;
|
6356 |
return trimmedOffset;
|
| 6201 |
};
|
6357 |
};
|
| 6202 |
const getPoint = (dom, trim, normalized, rng, start) => {
|
6358 |
const getPoint = (dom, trim, normalized, rng, start) => {
|
| 6203 |
const container = start ? rng.startContainer : rng.endContainer;
|
6359 |
const container = start ? rng.startContainer : rng.endContainer;
|
| 6204 |
let offset = start ? rng.startOffset : rng.endOffset;
|
6360 |
let offset = start ? rng.startOffset : rng.endOffset;
|
| 6205 |
const point = [];
|
6361 |
const point = [];
|
| 6206 |
const root = dom.getRoot();
|
6362 |
const root = dom.getRoot();
|
| 6207 |
if (isText$a(container)) {
|
6363 |
if (isText$b(container)) {
|
| 6208 |
point.push(normalized ? getNormalizedTextOffset$1(trim, container, offset) : offset);
|
6364 |
point.push(normalized ? getNormalizedTextOffset$1(trim, container, offset) : offset);
|
| 6209 |
} else {
|
6365 |
} else {
|
| 6210 |
let after = 0;
|
6366 |
let after = 0;
|
| 6211 |
const childNodes = container.childNodes;
|
6367 |
const childNodes = container.childNodes;
|
| Línea 6282... |
Línea 6438... |
| 6282 |
if (isContentEditableFalse$9(node)) {
|
6438 |
if (isContentEditableFalse$9(node)) {
|
| 6283 |
return node;
|
6439 |
return node;
|
| 6284 |
}
|
6440 |
}
|
| 6285 |
}
|
6441 |
}
|
| 6286 |
if (isCaretContainer$2(node)) {
|
6442 |
if (isCaretContainer$2(node)) {
|
| 6287 |
if (isText$a(node) && isCaretContainerBlock$1(node)) {
|
6443 |
if (isText$b(node) && isCaretContainerBlock$1(node)) {
|
| 6288 |
node = node.parentNode;
|
6444 |
node = node.parentNode;
|
| 6289 |
}
|
6445 |
}
|
| 6290 |
let sibling = node.previousSibling;
|
6446 |
let sibling = node.previousSibling;
|
| 6291 |
if (isContentEditableFalse$9(sibling)) {
|
6447 |
if (isContentEditableFalse$9(sibling)) {
|
| 6292 |
return sibling;
|
6448 |
return sibling;
|
| Línea 6322... |
Línea 6478... |
| 6322 |
return getLocation(trim, selection, normalized, rng);
|
6478 |
return getLocation(trim, selection, normalized, rng);
|
| 6323 |
};
|
6479 |
};
|
| 6324 |
const getCaretBookmark = selection => {
|
6480 |
const getCaretBookmark = selection => {
|
| 6325 |
const rng = selection.getRng();
|
6481 |
const rng = selection.getRng();
|
| 6326 |
return {
|
6482 |
return {
|
| 6327 |
start: create$b(selection.dom.getRoot(), CaretPosition.fromRangeStart(rng)),
|
6483 |
start: create$a(selection.dom.getRoot(), CaretPosition.fromRangeStart(rng)),
|
| 6328 |
end: create$b(selection.dom.getRoot(), CaretPosition.fromRangeEnd(rng)),
|
6484 |
end: create$a(selection.dom.getRoot(), CaretPosition.fromRangeEnd(rng)),
|
| 6329 |
forward: selection.isForward()
|
6485 |
forward: selection.isForward()
|
| 6330 |
};
|
6486 |
};
|
| 6331 |
};
|
6487 |
};
|
| 6332 |
const getRangeBookmark = selection => {
|
6488 |
const getRangeBookmark = selection => {
|
| 6333 |
return {
|
6489 |
return {
|
| Línea 6375... |
Línea 6531... |
| 6375 |
return {
|
6531 |
return {
|
| 6376 |
id,
|
6532 |
id,
|
| 6377 |
forward
|
6533 |
forward
|
| 6378 |
};
|
6534 |
};
|
| 6379 |
};
|
6535 |
};
|
| 6380 |
const getBookmark$2 = (selection, type, normalized = false) => {
|
6536 |
const getBookmark$3 = (selection, type, normalized = false) => {
|
| 6381 |
if (type === 2) {
|
6537 |
if (type === 2) {
|
| 6382 |
return getOffsetBookmark(trim$2, normalized, selection);
|
6538 |
return getOffsetBookmark(trim$2, normalized, selection);
|
| 6383 |
} else if (type === 3) {
|
6539 |
} else if (type === 3) {
|
| 6384 |
return getCaretBookmark(selection);
|
6540 |
return getCaretBookmark(selection);
|
| 6385 |
} else if (type) {
|
6541 |
} else if (type) {
|
| Línea 6554... |
Línea 6710... |
| 6554 |
};
|
6710 |
};
|
| 6555 |
};
|
6711 |
};
|
| Línea 6556... |
Línea 6712... |
| 6556 |
|
6712 |
|
| 6557 |
const isInlinePattern = pattern => pattern.type === 'inline-command' || pattern.type === 'inline-format';
|
6713 |
const isInlinePattern = pattern => pattern.type === 'inline-command' || pattern.type === 'inline-format';
|
| - |
|
6714 |
const isBlockPattern = pattern => pattern.type === 'block-command' || pattern.type === 'block-format';
|
| 6558 |
const isBlockPattern = pattern => pattern.type === 'block-command' || pattern.type === 'block-format';
|
6715 |
const hasBlockTrigger = (pattern, trigger) => (pattern.type === 'block-command' || pattern.type === 'block-format') && pattern.trigger === trigger;
|
| - |
|
6716 |
const normalizePattern = pattern => {
|
| 6559 |
const normalizePattern = pattern => {
|
6717 |
var _a;
|
| 6560 |
const err = message => Result.error({
|
6718 |
const err = message => Result.error({
|
| 6561 |
message,
|
6719 |
message,
|
| 6562 |
pattern
|
6720 |
pattern
|
| 6563 |
});
|
6721 |
});
|
| Línea 6628... |
Línea 6786... |
| 6628 |
end: pattern.start,
|
6786 |
end: pattern.start,
|
| 6629 |
cmd: 'mceInsertContent',
|
6787 |
cmd: 'mceInsertContent',
|
| 6630 |
value: pattern.replacement
|
6788 |
value: pattern.replacement
|
| 6631 |
});
|
6789 |
});
|
| 6632 |
} else {
|
6790 |
} else {
|
| - |
|
6791 |
const trigger = (_a = pattern.trigger) !== null && _a !== void 0 ? _a : 'space';
|
| 6633 |
if (pattern.start.length === 0) {
|
6792 |
if (pattern.start.length === 0) {
|
| 6634 |
return err('Block pattern has empty `start` parameter');
|
6793 |
return err('Block pattern has empty `start` parameter');
|
| 6635 |
}
|
6794 |
}
|
| 6636 |
return formatOrCmd('Block', formats => ({
|
6795 |
return formatOrCmd('Block', formats => ({
|
| 6637 |
type: 'block-format',
|
6796 |
type: 'block-format',
|
| 6638 |
start: pattern.start,
|
6797 |
start: pattern.start,
|
| 6639 |
format: formats[0]
|
6798 |
format: formats[0],
|
| - |
|
6799 |
trigger
|
| 6640 |
}), (command, commandValue) => ({
|
6800 |
}), (command, commandValue) => ({
|
| 6641 |
type: 'block-command',
|
6801 |
type: 'block-command',
|
| 6642 |
start: pattern.start,
|
6802 |
start: pattern.start,
|
| 6643 |
cmd: command,
|
6803 |
cmd: command,
|
| 6644 |
value: commandValue
|
6804 |
value: commandValue,
|
| - |
|
6805 |
trigger
|
| 6645 |
}));
|
6806 |
}));
|
| 6646 |
}
|
6807 |
}
|
| 6647 |
};
|
6808 |
};
|
| 6648 |
const getBlockPatterns = patterns => filter$5(patterns, isBlockPattern);
|
6809 |
const getBlockPatterns = patterns => filter$5(patterns, isBlockPattern);
|
| 6649 |
const getInlinePatterns = patterns => filter$5(patterns, isInlinePattern);
|
6810 |
const getInlinePatterns = patterns => filter$5(patterns, isInlinePattern);
|
| 6650 |
const createPatternSet = (patterns, dynamicPatternsLookup) => ({
|
6811 |
const createPatternSet = (patterns, dynamicPatternsLookup) => ({
|
| 6651 |
inlinePatterns: getInlinePatterns(patterns),
|
6812 |
inlinePatterns: getInlinePatterns(patterns),
|
| 6652 |
blockPatterns: getBlockPatterns(patterns),
|
6813 |
blockPatterns: getBlockPatterns(patterns),
|
| 6653 |
dynamicPatternsLookup
|
6814 |
dynamicPatternsLookup
|
| 6654 |
});
|
6815 |
});
|
| - |
|
6816 |
const filterByTrigger = (patterns, trigger) => {
|
| - |
|
6817 |
return {
|
| - |
|
6818 |
...patterns,
|
| - |
|
6819 |
blockPatterns: filter$5(patterns.blockPatterns, pattern => hasBlockTrigger(pattern, trigger))
|
| - |
|
6820 |
};
|
| - |
|
6821 |
};
|
| 6655 |
const fromRawPatterns = patterns => {
|
6822 |
const fromRawPatterns = patterns => {
|
| 6656 |
const normalized = partition$1(map$3(patterns, normalizePattern));
|
6823 |
const normalized = partition$1(map$3(patterns, normalizePattern));
|
| 6657 |
each$e(normalized.errors, err => console.error(err.message, err.pattern));
|
6824 |
each$e(normalized.errors, err => console.error(err.message, err.pattern));
|
| 6658 |
return normalized.values;
|
6825 |
return normalized.values;
|
| 6659 |
};
|
6826 |
};
|
| Línea 6662... |
Línea 6829... |
| 6662 |
const rawPatterns = lookupFn(ctx);
|
6829 |
const rawPatterns = lookupFn(ctx);
|
| 6663 |
return fromRawPatterns(rawPatterns);
|
6830 |
return fromRawPatterns(rawPatterns);
|
| 6664 |
};
|
6831 |
};
|
| 6665 |
};
|
6832 |
};
|
| Línea -... |
Línea 6833... |
| - |
|
6833 |
|
| - |
|
6834 |
const firePreProcess = (editor, args) => editor.dispatch('PreProcess', args);
|
| - |
|
6835 |
const firePostProcess = (editor, args) => editor.dispatch('PostProcess', args);
|
| - |
|
6836 |
const fireRemove = editor => {
|
| - |
|
6837 |
editor.dispatch('remove');
|
| - |
|
6838 |
};
|
| - |
|
6839 |
const fireDetach = editor => {
|
| - |
|
6840 |
editor.dispatch('detach');
|
| - |
|
6841 |
};
|
| - |
|
6842 |
const fireSwitchMode = (editor, mode) => {
|
| - |
|
6843 |
editor.dispatch('SwitchMode', { mode });
|
| - |
|
6844 |
};
|
| - |
|
6845 |
const fireObjectResizeStart = (editor, target, width, height, origin) => {
|
| - |
|
6846 |
editor.dispatch('ObjectResizeStart', {
|
| - |
|
6847 |
target,
|
| - |
|
6848 |
width,
|
| - |
|
6849 |
height,
|
| - |
|
6850 |
origin
|
| - |
|
6851 |
});
|
| - |
|
6852 |
};
|
| - |
|
6853 |
const fireObjectResized = (editor, target, width, height, origin) => {
|
| - |
|
6854 |
editor.dispatch('ObjectResized', {
|
| - |
|
6855 |
target,
|
| - |
|
6856 |
width,
|
| - |
|
6857 |
height,
|
| - |
|
6858 |
origin
|
| - |
|
6859 |
});
|
| - |
|
6860 |
};
|
| - |
|
6861 |
const firePreInit = editor => {
|
| - |
|
6862 |
editor.dispatch('PreInit');
|
| - |
|
6863 |
};
|
| - |
|
6864 |
const firePostRender = editor => {
|
| - |
|
6865 |
editor.dispatch('PostRender');
|
| - |
|
6866 |
};
|
| - |
|
6867 |
const fireInit = editor => {
|
| - |
|
6868 |
editor.dispatch('Init');
|
| - |
|
6869 |
};
|
| - |
|
6870 |
const firePlaceholderToggle = (editor, state) => {
|
| - |
|
6871 |
editor.dispatch('PlaceholderToggle', { state });
|
| - |
|
6872 |
};
|
| - |
|
6873 |
const fireError = (editor, errorType, error) => {
|
| - |
|
6874 |
editor.dispatch(errorType, error);
|
| - |
|
6875 |
};
|
| - |
|
6876 |
const fireFormatApply = (editor, format, node, vars) => {
|
| - |
|
6877 |
editor.dispatch('FormatApply', {
|
| - |
|
6878 |
format,
|
| - |
|
6879 |
node,
|
| - |
|
6880 |
vars
|
| - |
|
6881 |
});
|
| - |
|
6882 |
};
|
| - |
|
6883 |
const fireFormatRemove = (editor, format, node, vars) => {
|
| - |
|
6884 |
editor.dispatch('FormatRemove', {
|
| - |
|
6885 |
format,
|
| - |
|
6886 |
node,
|
| - |
|
6887 |
vars
|
| - |
|
6888 |
});
|
| - |
|
6889 |
};
|
| - |
|
6890 |
const fireBeforeSetContent = (editor, args) => editor.dispatch('BeforeSetContent', args);
|
| - |
|
6891 |
const fireSetContent = (editor, args) => editor.dispatch('SetContent', args);
|
| - |
|
6892 |
const fireBeforeGetContent = (editor, args) => editor.dispatch('BeforeGetContent', args);
|
| - |
|
6893 |
const fireGetContent = (editor, args) => editor.dispatch('GetContent', args);
|
| - |
|
6894 |
const fireAutocompleterStart = (editor, args) => {
|
| - |
|
6895 |
editor.dispatch('AutocompleterStart', args);
|
| - |
|
6896 |
};
|
| - |
|
6897 |
const fireAutocompleterUpdate = (editor, args) => {
|
| - |
|
6898 |
editor.dispatch('AutocompleterUpdate', args);
|
| - |
|
6899 |
};
|
| - |
|
6900 |
const fireAutocompleterUpdateActiveRange = (editor, args) => {
|
| - |
|
6901 |
editor.dispatch('AutocompleterUpdateActiveRange', args);
|
| - |
|
6902 |
};
|
| - |
|
6903 |
const fireAutocompleterEnd = editor => {
|
| - |
|
6904 |
editor.dispatch('AutocompleterEnd');
|
| - |
|
6905 |
};
|
| - |
|
6906 |
const firePastePreProcess = (editor, html, internal) => editor.dispatch('PastePreProcess', {
|
| - |
|
6907 |
content: html,
|
| - |
|
6908 |
internal
|
| - |
|
6909 |
});
|
| - |
|
6910 |
const firePastePostProcess = (editor, node, internal) => editor.dispatch('PastePostProcess', {
|
| - |
|
6911 |
node,
|
| - |
|
6912 |
internal
|
| - |
|
6913 |
});
|
| - |
|
6914 |
const firePastePlainTextToggle = (editor, state) => editor.dispatch('PastePlainTextToggle', { state });
|
| - |
|
6915 |
const fireEditableRootStateChange = (editor, state) => editor.dispatch('EditableRootStateChange', { state });
|
| - |
|
6916 |
const fireDisabledStateChange = (editor, state) => editor.dispatch('DisabledStateChange', { state });
|
| 6666 |
|
6917 |
|
| 6667 |
const deviceDetection$1 = detect$2().deviceType;
|
6918 |
const deviceDetection$1 = detect$1().deviceType;
|
| 6668 |
const isTouch = deviceDetection$1.isTouch();
|
6919 |
const isTouch = deviceDetection$1.isTouch();
|
| 6669 |
const DOM$a = DOMUtils.DOM;
|
6920 |
const DOM$a = DOMUtils.DOM;
|
| 6670 |
const getHash = value => {
|
6921 |
const getHash = value => {
|
| 6671 |
const items = value.indexOf('=') > 0 ? value.split(/[;,](?![^=;,]*(?:[;,]|$))/) : value.split(',');
|
6922 |
const items = value.indexOf('=') > 0 ? value.split(/[;,](?![^=;,]*(?:[;,]|$))/) : value.split(',');
|
| Línea 6993... |
Línea 7244... |
| 6993 |
});
|
7244 |
});
|
| 6994 |
registerOption('resize_img_proportional', {
|
7245 |
registerOption('resize_img_proportional', {
|
| 6995 |
processor: 'boolean',
|
7246 |
processor: 'boolean',
|
| 6996 |
default: true
|
7247 |
default: true
|
| 6997 |
});
|
7248 |
});
|
| 6998 |
registerOption('event_root', { processor: 'object' });
|
7249 |
registerOption('event_root', { processor: 'string' });
|
| 6999 |
registerOption('service_message', { processor: 'string' });
|
7250 |
registerOption('service_message', { processor: 'string' });
|
| 7000 |
registerOption('theme', {
|
7251 |
registerOption('theme', {
|
| 7001 |
processor: value => value === false || isString(value) || isFunction(value),
|
7252 |
processor: value => value === false || isString(value) || isFunction(value),
|
| 7002 |
default: 'silver'
|
7253 |
default: 'silver'
|
| 7003 |
});
|
7254 |
});
|
| Línea 7055... |
Línea 7306... |
| 7055 |
});
|
7306 |
});
|
| 7056 |
registerOption('disable_nodechange', {
|
7307 |
registerOption('disable_nodechange', {
|
| 7057 |
processor: 'boolean',
|
7308 |
processor: 'boolean',
|
| 7058 |
default: false
|
7309 |
default: false
|
| 7059 |
});
|
7310 |
});
|
| - |
|
7311 |
registerOption('disabled', {
|
| - |
|
7312 |
processor: value => {
|
| - |
|
7313 |
if (isBoolean(value)) {
|
| - |
|
7314 |
if (editor.initialized && isDisabled$1(editor) !== value) {
|
| - |
|
7315 |
Promise.resolve().then(() => {
|
| - |
|
7316 |
fireDisabledStateChange(editor, value);
|
| - |
|
7317 |
});
|
| - |
|
7318 |
}
|
| - |
|
7319 |
return {
|
| - |
|
7320 |
valid: true,
|
| - |
|
7321 |
value
|
| - |
|
7322 |
};
|
| - |
|
7323 |
}
|
| - |
|
7324 |
return {
|
| - |
|
7325 |
valid: false,
|
| - |
|
7326 |
message: 'The value must be a boolean.'
|
| - |
|
7327 |
};
|
| - |
|
7328 |
},
|
| - |
|
7329 |
default: false
|
| - |
|
7330 |
});
|
| 7060 |
registerOption('readonly', {
|
7331 |
registerOption('readonly', {
|
| 7061 |
processor: 'boolean',
|
7332 |
processor: 'boolean',
|
| 7062 |
default: false
|
7333 |
default: false
|
| 7063 |
});
|
7334 |
});
|
| 7064 |
registerOption('editable_root', {
|
7335 |
registerOption('editable_root', {
|
| Línea 7092... |
Línea 7363... |
| 7092 |
processor: 'string',
|
7363 |
processor: 'string',
|
| 7093 |
default: 'mce-item-anchor'
|
7364 |
default: 'mce-item-anchor'
|
| 7094 |
});
|
7365 |
});
|
| 7095 |
registerOption('iframe_aria_text', {
|
7366 |
registerOption('iframe_aria_text', {
|
| 7096 |
processor: 'string',
|
7367 |
processor: 'string',
|
| 7097 |
default: 'Rich Text Area. Press ALT-0 for help.'
|
7368 |
default: 'Rich Text Area'.concat(editor.hasPlugin('help') ? '. Press ALT-0 for help.' : '')
|
| 7098 |
});
|
7369 |
});
|
| 7099 |
registerOption('setup', { processor: 'function' });
|
7370 |
registerOption('setup', { processor: 'function' });
|
| 7100 |
registerOption('init_instance_callback', { processor: 'function' });
|
7371 |
registerOption('init_instance_callback', { processor: 'function' });
|
| 7101 |
registerOption('url_converter', {
|
7372 |
registerOption('url_converter', {
|
| 7102 |
processor: 'function',
|
7373 |
processor: 'function',
|
| Línea 7126... |
Línea 7397... |
| 7126 |
});
|
7397 |
});
|
| 7127 |
registerOption('allow_unsafe_link_target', {
|
7398 |
registerOption('allow_unsafe_link_target', {
|
| 7128 |
processor: 'boolean',
|
7399 |
processor: 'boolean',
|
| 7129 |
default: false
|
7400 |
default: false
|
| 7130 |
});
|
7401 |
});
|
| - |
|
7402 |
registerOption('allow_mathml_annotation_encodings', {
|
| - |
|
7403 |
processor: value => {
|
| - |
|
7404 |
const valid = isArrayOf(value, isString);
|
| - |
|
7405 |
return valid ? {
|
| - |
|
7406 |
value,
|
| - |
|
7407 |
valid
|
| - |
|
7408 |
} : {
|
| - |
|
7409 |
valid: false,
|
| - |
|
7410 |
message: 'Must be an array of strings.'
|
| - |
|
7411 |
};
|
| - |
|
7412 |
},
|
| - |
|
7413 |
default: []
|
| - |
|
7414 |
});
|
| 7131 |
registerOption('convert_fonts_to_spans', {
|
7415 |
registerOption('convert_fonts_to_spans', {
|
| 7132 |
processor: 'boolean',
|
7416 |
processor: 'boolean',
|
| 7133 |
default: true,
|
7417 |
default: true,
|
| 7134 |
deprecated: true
|
7418 |
deprecated: true
|
| 7135 |
});
|
7419 |
});
|
| Línea 7173... |
Línea 7457... |
| 7173 |
});
|
7457 |
});
|
| 7174 |
registerOption('remove_script_host', {
|
7458 |
registerOption('remove_script_host', {
|
| 7175 |
processor: 'boolean',
|
7459 |
processor: 'boolean',
|
| 7176 |
default: true
|
7460 |
default: true
|
| 7177 |
});
|
7461 |
});
|
| 7178 |
registerOption('custom_elements', { processor: 'string' });
|
7462 |
registerOption('custom_elements', { processor: stringOrObjectProcessor });
|
| 7179 |
registerOption('extended_valid_elements', { processor: 'string' });
|
7463 |
registerOption('extended_valid_elements', { processor: 'string' });
|
| 7180 |
registerOption('invalid_elements', { processor: 'string' });
|
7464 |
registerOption('invalid_elements', { processor: 'string' });
|
| 7181 |
registerOption('invalid_styles', { processor: stringOrObjectProcessor });
|
7465 |
registerOption('invalid_styles', { processor: stringOrObjectProcessor });
|
| 7182 |
registerOption('valid_children', { processor: 'string' });
|
7466 |
registerOption('valid_children', { processor: 'string' });
|
| 7183 |
registerOption('valid_classes', { processor: stringOrObjectProcessor });
|
7467 |
registerOption('valid_classes', { processor: stringOrObjectProcessor });
|
| Línea 7204... |
Línea 7488... |
| 7204 |
registerOption('a11y_advanced_options', {
|
7488 |
registerOption('a11y_advanced_options', {
|
| 7205 |
processor: 'boolean',
|
7489 |
processor: 'boolean',
|
| 7206 |
default: false
|
7490 |
default: false
|
| 7207 |
});
|
7491 |
});
|
| 7208 |
registerOption('api_key', { processor: 'string' });
|
7492 |
registerOption('api_key', { processor: 'string' });
|
| - |
|
7493 |
registerOption('license_key', { processor: 'string' });
|
| 7209 |
registerOption('paste_block_drop', {
|
7494 |
registerOption('paste_block_drop', {
|
| 7210 |
processor: 'boolean',
|
7495 |
processor: 'boolean',
|
| 7211 |
default: false
|
7496 |
default: false
|
| 7212 |
});
|
7497 |
});
|
| 7213 |
registerOption('paste_data_images', {
|
7498 |
registerOption('paste_data_images', {
|
| Línea 7266... |
Línea 7551... |
| 7266 |
end: '**',
|
7551 |
end: '**',
|
| 7267 |
format: 'bold'
|
7552 |
format: 'bold'
|
| 7268 |
},
|
7553 |
},
|
| 7269 |
{
|
7554 |
{
|
| 7270 |
start: '#',
|
7555 |
start: '#',
|
| 7271 |
format: 'h1'
|
7556 |
format: 'h1',
|
| - |
|
7557 |
trigger: 'space'
|
| 7272 |
},
|
7558 |
},
|
| 7273 |
{
|
7559 |
{
|
| 7274 |
start: '##',
|
7560 |
start: '##',
|
| 7275 |
format: 'h2'
|
7561 |
format: 'h2',
|
| - |
|
7562 |
trigger: 'space'
|
| 7276 |
},
|
7563 |
},
|
| 7277 |
{
|
7564 |
{
|
| 7278 |
start: '###',
|
7565 |
start: '###',
|
| 7279 |
format: 'h3'
|
7566 |
format: 'h3',
|
| - |
|
7567 |
trigger: 'space'
|
| 7280 |
},
|
7568 |
},
|
| 7281 |
{
|
7569 |
{
|
| 7282 |
start: '####',
|
7570 |
start: '####',
|
| 7283 |
format: 'h4'
|
7571 |
format: 'h4',
|
| - |
|
7572 |
trigger: 'space'
|
| 7284 |
},
|
7573 |
},
|
| 7285 |
{
|
7574 |
{
|
| 7286 |
start: '#####',
|
7575 |
start: '#####',
|
| 7287 |
format: 'h5'
|
7576 |
format: 'h5',
|
| - |
|
7577 |
trigger: 'space'
|
| 7288 |
},
|
7578 |
},
|
| 7289 |
{
|
7579 |
{
|
| 7290 |
start: '######',
|
7580 |
start: '######',
|
| 7291 |
format: 'h6'
|
7581 |
format: 'h6',
|
| - |
|
7582 |
trigger: 'space'
|
| 7292 |
},
|
7583 |
},
|
| 7293 |
{
|
7584 |
{
|
| 7294 |
start: '1. ',
|
7585 |
start: '1.',
|
| 7295 |
cmd: 'InsertOrderedList'
|
7586 |
cmd: 'InsertOrderedList',
|
| - |
|
7587 |
trigger: 'space'
|
| - |
|
7588 |
},
|
| - |
|
7589 |
{
|
| - |
|
7590 |
start: '*',
|
| - |
|
7591 |
cmd: 'InsertUnorderedList',
|
| - |
|
7592 |
trigger: 'space'
|
| 7296 |
},
|
7593 |
},
|
| 7297 |
{
|
7594 |
{
|
| 7298 |
start: '* ',
|
7595 |
start: '-',
|
| 7299 |
cmd: 'InsertUnorderedList'
|
7596 |
cmd: 'InsertUnorderedList',
|
| - |
|
7597 |
trigger: 'space'
|
| 7300 |
},
|
7598 |
},
|
| 7301 |
{
|
7599 |
{
|
| - |
|
7600 |
start: '>',
|
| - |
|
7601 |
cmd: 'mceBlockQuote',
|
| - |
|
7602 |
trigger: 'space'
|
| - |
|
7603 |
},
|
| - |
|
7604 |
{
|
| 7302 |
start: '- ',
|
7605 |
start: '---',
|
| 7303 |
cmd: 'InsertUnorderedList'
|
7606 |
cmd: 'InsertHorizontalRule',
|
| - |
|
7607 |
trigger: 'space'
|
| 7304 |
}
|
7608 |
}
|
| 7305 |
]
|
7609 |
]
|
| 7306 |
});
|
7610 |
});
|
| 7307 |
registerOption('text_patterns_lookup', {
|
7611 |
registerOption('text_patterns_lookup', {
|
| 7308 |
processor: value => {
|
7612 |
processor: value => {
|
| Línea 7353... |
Línea 7657... |
| 7353 |
processor: 'boolean',
|
7657 |
processor: 'boolean',
|
| 7354 |
default: true
|
7658 |
default: true
|
| 7355 |
});
|
7659 |
});
|
| 7356 |
registerOption('highlight_on_focus', {
|
7660 |
registerOption('highlight_on_focus', {
|
| 7357 |
processor: 'boolean',
|
7661 |
processor: 'boolean',
|
| 7358 |
default: false
|
7662 |
default: true
|
| 7359 |
});
|
7663 |
});
|
| 7360 |
registerOption('xss_sanitization', {
|
7664 |
registerOption('xss_sanitization', {
|
| 7361 |
processor: 'boolean',
|
7665 |
processor: 'boolean',
|
| 7362 |
default: true
|
7666 |
default: true
|
| 7363 |
});
|
7667 |
});
|
| Línea 7401... |
Línea 7705... |
| 7401 |
});
|
7705 |
});
|
| 7402 |
registerOption('newdocument_content', {
|
7706 |
registerOption('newdocument_content', {
|
| 7403 |
processor: 'string',
|
7707 |
processor: 'string',
|
| 7404 |
default: ''
|
7708 |
default: ''
|
| 7405 |
});
|
7709 |
});
|
| 7406 |
registerOption('force_hex_color', {
|
- |
|
| 7407 |
processor: value => {
|
- |
|
| 7408 |
const options = [
|
- |
|
| 7409 |
'always',
|
- |
|
| 7410 |
'rgb_only',
|
- |
|
| 7411 |
'off'
|
- |
|
| 7412 |
];
|
- |
|
| 7413 |
const valid = contains$2(options, value);
|
- |
|
| 7414 |
return valid ? {
|
- |
|
| 7415 |
value,
|
- |
|
| 7416 |
valid
|
- |
|
| 7417 |
} : {
|
- |
|
| 7418 |
valid: false,
|
- |
|
| 7419 |
message: `Must be one of: ${ options.join(', ') }.`
|
- |
|
| 7420 |
};
|
- |
|
| 7421 |
},
|
- |
|
| 7422 |
default: 'off'
|
- |
|
| 7423 |
});
|
- |
|
| 7424 |
registerOption('sandbox_iframes', {
|
7710 |
registerOption('sandbox_iframes', {
|
| 7425 |
processor: 'boolean',
|
7711 |
processor: 'boolean',
|
| 7426 |
default: false
|
7712 |
default: true
|
| - |
|
7713 |
});
|
| - |
|
7714 |
registerOption('sandbox_iframes_exclusions', {
|
| - |
|
7715 |
processor: 'string[]',
|
| - |
|
7716 |
default: [
|
| - |
|
7717 |
'youtube.com',
|
| - |
|
7718 |
'youtu.be',
|
| - |
|
7719 |
'vimeo.com',
|
| - |
|
7720 |
'player.vimeo.com',
|
| - |
|
7721 |
'dailymotion.com',
|
| - |
|
7722 |
'embed.music.apple.com',
|
| - |
|
7723 |
'open.spotify.com',
|
| - |
|
7724 |
'giphy.com',
|
| - |
|
7725 |
'dai.ly',
|
| - |
|
7726 |
'codepen.io'
|
| - |
|
7727 |
]
|
| 7427 |
});
|
7728 |
});
|
| 7428 |
registerOption('convert_unsafe_embeds', {
|
7729 |
registerOption('convert_unsafe_embeds', {
|
| 7429 |
processor: 'boolean',
|
7730 |
processor: 'boolean',
|
| 7430 |
default: false
|
7731 |
default: true
|
| 7431 |
});
|
7732 |
});
|
| 7432 |
editor.on('ScriptsLoaded', () => {
|
7733 |
editor.on('ScriptsLoaded', () => {
|
| 7433 |
registerOption('directionality', {
|
7734 |
registerOption('directionality', {
|
| 7434 |
processor: 'string',
|
7735 |
processor: 'string',
|
| 7435 |
default: I18n.isRtl() ? 'rtl' : undefined
|
7736 |
default: I18n.isRtl() ? 'rtl' : undefined
|
| Línea 7539... |
Línea 7840... |
| 7539 |
const isEncodingXml = editor => editor.options.get('encoding') === 'xml';
|
7840 |
const isEncodingXml = editor => editor.options.get('encoding') === 'xml';
|
| 7540 |
const getAllowedImageFileTypes = editor => Tools.explode(editor.options.get('images_file_types'));
|
7841 |
const getAllowedImageFileTypes = editor => Tools.explode(editor.options.get('images_file_types'));
|
| 7541 |
const hasTableTabNavigation = option('table_tab_navigation');
|
7842 |
const hasTableTabNavigation = option('table_tab_navigation');
|
| 7542 |
const getDetailsInitialState = option('details_initial_state');
|
7843 |
const getDetailsInitialState = option('details_initial_state');
|
| 7543 |
const getDetailsSerializedState = option('details_serialized_state');
|
7844 |
const getDetailsSerializedState = option('details_serialized_state');
|
| 7544 |
const shouldForceHexColor = option('force_hex_color');
|
- |
|
| 7545 |
const shouldSandboxIframes = option('sandbox_iframes');
|
7845 |
const shouldSandboxIframes = option('sandbox_iframes');
|
| - |
|
7846 |
const getSandboxIframesExclusions = editor => editor.options.get('sandbox_iframes_exclusions');
|
| - |
|
7847 |
const shouldConvertUnsafeEmbeds = option('convert_unsafe_embeds');
|
| - |
|
7848 |
const getLicenseKey = option('license_key');
|
| - |
|
7849 |
const getApiKey = option('api_key');
|
| - |
|
7850 |
const isDisabled$1 = option('disabled');
|
| Línea 7546... |
Línea 7851... |
| 7546 |
|
7851 |
|
| 7547 |
const isElement$3 = isElement$6;
|
7852 |
const isElement$3 = isElement$6;
|
| 7548 |
const isText$5 = isText$a;
|
7853 |
const isText$5 = isText$b;
|
| 7549 |
const removeNode$1 = node => {
|
7854 |
const removeNode$1 = node => {
|
| 7550 |
const parentNode = node.parentNode;
|
7855 |
const parentNode = node.parentNode;
|
| 7551 |
if (parentNode) {
|
7856 |
if (parentNode) {
|
| 7552 |
parentNode.removeChild(node);
|
7857 |
parentNode.removeChild(node);
|
| Línea 7564... |
Línea 7869... |
| 7564 |
while ((idx = caretContainer.data.lastIndexOf(ZWSP$1)) !== -1) {
|
7869 |
while ((idx = caretContainer.data.lastIndexOf(ZWSP$1)) !== -1) {
|
| 7565 |
caretContainer.deleteData(idx, 1);
|
7870 |
caretContainer.deleteData(idx, 1);
|
| 7566 |
}
|
7871 |
}
|
| 7567 |
};
|
7872 |
};
|
| 7568 |
const removeUnchanged = (caretContainer, pos) => {
|
7873 |
const removeUnchanged = (caretContainer, pos) => {
|
| 7569 |
remove$3(caretContainer);
|
7874 |
remove$2(caretContainer);
|
| 7570 |
return pos;
|
7875 |
return pos;
|
| 7571 |
};
|
7876 |
};
|
| 7572 |
const removeTextAndReposition = (caretContainer, pos) => {
|
7877 |
const removeTextAndReposition = (caretContainer, pos) => {
|
| 7573 |
const before = trimCount(caretContainer.data.substr(0, pos.offset()));
|
7878 |
const before = trimCount(caretContainer.data.substr(0, pos.offset()));
|
| 7574 |
const after = trimCount(caretContainer.data.substr(pos.offset()));
|
7879 |
const after = trimCount(caretContainer.data.substr(pos.offset()));
|
| Línea 7583... |
Línea 7888... |
| 7583 |
const removeElementAndReposition = (caretContainer, pos) => {
|
7888 |
const removeElementAndReposition = (caretContainer, pos) => {
|
| 7584 |
const parentNode = pos.container();
|
7889 |
const parentNode = pos.container();
|
| 7585 |
const newPosition = indexOf$1(from(parentNode.childNodes), caretContainer).map(index => {
|
7890 |
const newPosition = indexOf$1(from(parentNode.childNodes), caretContainer).map(index => {
|
| 7586 |
return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos;
|
7891 |
return index < pos.offset() ? CaretPosition(parentNode, pos.offset() - 1) : pos;
|
| 7587 |
}).getOr(pos);
|
7892 |
}).getOr(pos);
|
| 7588 |
remove$3(caretContainer);
|
7893 |
remove$2(caretContainer);
|
| 7589 |
return newPosition;
|
7894 |
return newPosition;
|
| 7590 |
};
|
7895 |
};
|
| 7591 |
const removeTextCaretContainer = (caretContainer, pos) => isText$5(caretContainer) && pos.container() === caretContainer ? removeTextAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);
|
7896 |
const removeTextCaretContainer = (caretContainer, pos) => isText$5(caretContainer) && pos.container() === caretContainer ? removeTextAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);
|
| 7592 |
const removeElementCaretContainer = (caretContainer, pos) => pos.container() === caretContainer.parentNode ? removeElementAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);
|
7897 |
const removeElementCaretContainer = (caretContainer, pos) => pos.container() === caretContainer.parentNode ? removeElementAndReposition(caretContainer, pos) : removeUnchanged(caretContainer, pos);
|
| 7593 |
const removeAndReposition = (container, pos) => CaretPosition.isTextPosition(pos) ? removeTextCaretContainer(container, pos) : removeElementCaretContainer(container, pos);
|
7898 |
const removeAndReposition = (container, pos) => CaretPosition.isTextPosition(pos) ? removeTextCaretContainer(container, pos) : removeElementCaretContainer(container, pos);
|
| 7594 |
const remove$3 = caretContainerNode => {
|
7899 |
const remove$2 = caretContainerNode => {
|
| 7595 |
if (isElement$3(caretContainerNode) && isCaretContainer$2(caretContainerNode)) {
|
7900 |
if (isElement$3(caretContainerNode) && isCaretContainer$2(caretContainerNode)) {
|
| 7596 |
if (hasContent(caretContainerNode)) {
|
7901 |
if (hasContent(caretContainerNode)) {
|
| 7597 |
caretContainerNode.removeAttribute('data-mce-caret');
|
7902 |
caretContainerNode.removeAttribute('data-mce-caret');
|
| 7598 |
} else {
|
7903 |
} else {
|
| 7599 |
removeNode$1(caretContainerNode);
|
7904 |
removeNode$1(caretContainerNode);
|
| Línea 7678... |
Línea 7983... |
| 7678 |
}
|
7983 |
}
|
| 7679 |
if (isBlock(element)) {
|
7984 |
if (isBlock(element)) {
|
| 7680 |
const caretContainer = insertBlock(caretBlock, element, before);
|
7985 |
const caretContainer = insertBlock(caretBlock, element, before);
|
| 7681 |
const clientRect = getAbsoluteClientRect(root, element, before);
|
7986 |
const clientRect = getAbsoluteClientRect(root, element, before);
|
| 7682 |
dom.setStyle(caretContainer, 'top', clientRect.top);
|
7987 |
dom.setStyle(caretContainer, 'top', clientRect.top);
|
| - |
|
7988 |
dom.setStyle(caretContainer, 'caret-color', 'transparent');
|
| 7683 |
caretContainerNode = caretContainer;
|
7989 |
caretContainerNode = caretContainer;
|
| 7684 |
const caret = dom.create('div', {
|
7990 |
const caret = dom.create('div', {
|
| 7685 |
'class': 'mce-visual-caret',
|
7991 |
'class': 'mce-visual-caret',
|
| 7686 |
'data-mce-bogus': 'all'
|
7992 |
'data-mce-bogus': 'all'
|
| 7687 |
});
|
7993 |
});
|
| Línea 7714... |
Línea 8020... |
| 7714 |
return rng;
|
8020 |
return rng;
|
| 7715 |
};
|
8021 |
};
|
| 7716 |
const hide = () => {
|
8022 |
const hide = () => {
|
| 7717 |
trimInlineCaretContainers(root);
|
8023 |
trimInlineCaretContainers(root);
|
| 7718 |
if (caretContainerNode) {
|
8024 |
if (caretContainerNode) {
|
| 7719 |
remove$3(caretContainerNode);
|
8025 |
remove$2(caretContainerNode);
|
| 7720 |
caretContainerNode = null;
|
8026 |
caretContainerNode = null;
|
| 7721 |
}
|
8027 |
}
|
| 7722 |
lastVisualCaret.on(caretState => {
|
8028 |
lastVisualCaret.on(caretState => {
|
| 7723 |
dom.remove(caretState.caret);
|
8029 |
dom.remove(caretState.caret);
|
| 7724 |
lastVisualCaret.clear();
|
8030 |
lastVisualCaret.clear();
|
| Línea 7763... |
Línea 8069... |
| 7763 |
};
|
8069 |
};
|
| Línea 7764... |
Línea 8070... |
| 7764 |
|
8070 |
|
| 7765 |
const isContentEditableTrue$1 = isContentEditableTrue$3;
|
8071 |
const isContentEditableTrue$1 = isContentEditableTrue$3;
|
| 7766 |
const isContentEditableFalse$7 = isContentEditableFalse$b;
|
8072 |
const isContentEditableFalse$7 = isContentEditableFalse$b;
|
| 7767 |
const isMedia = isMedia$2;
|
8073 |
const isMedia = isMedia$2;
|
| 7768 |
const isBlockLike = matchStyleValues('display', 'block table table-cell table-caption list-item');
|
8074 |
const isBlockLike = matchStyleValues('display', 'block table table-cell table-row table-caption list-item');
|
| 7769 |
const isCaretContainer = isCaretContainer$2;
|
8075 |
const isCaretContainer = isCaretContainer$2;
|
| 7770 |
const isCaretContainerBlock = isCaretContainerBlock$1;
|
8076 |
const isCaretContainerBlock = isCaretContainerBlock$1;
|
| 7771 |
const isElement$2 = isElement$6;
|
8077 |
const isElement$2 = isElement$6;
|
| 7772 |
const isText$4 = isText$a;
|
8078 |
const isText$4 = isText$b;
|
| 7773 |
const isCaretCandidate$1 = isCaretCandidate$3;
|
8079 |
const isCaretCandidate$1 = isCaretCandidate$3;
|
| 7774 |
const isForwards = direction => direction > 0;
|
8080 |
const isForwards = direction => direction === 1;
|
| 7775 |
const isBackwards = direction => direction < 0;
|
8081 |
const isBackwards = direction => direction === -1;
|
| 7776 |
const skipCaretContainers = (walk, shallow) => {
|
8082 |
const skipCaretContainers = (walk, shallow) => {
|
| 7777 |
let node;
|
8083 |
let node;
|
| 7778 |
while (node = walk(shallow)) {
|
8084 |
while (node = walk(shallow)) {
|
| 7779 |
if (!isCaretContainerBlock(node)) {
|
8085 |
if (!isCaretContainerBlock(node)) {
|
| Línea 7900... |
Línea 8206... |
| 7900 |
}
|
8206 |
}
|
| 7901 |
}
|
8207 |
}
|
| 7902 |
if (!range.collapsed) {
|
8208 |
if (!range.collapsed) {
|
| 7903 |
return range;
|
8209 |
return range;
|
| 7904 |
}
|
8210 |
}
|
| 7905 |
if (isText$a(container)) {
|
8211 |
if (isText$b(container)) {
|
| 7906 |
if (isCaretContainer(container)) {
|
8212 |
if (isCaretContainer(container)) {
|
| 7907 |
if (direction === 1) {
|
8213 |
if (direction === 1) {
|
| 7908 |
node = leanRight(container);
|
8214 |
node = leanRight(container);
|
| 7909 |
if (node) {
|
8215 |
if (node) {
|
| 7910 |
return before$2(node);
|
8216 |
return before$2(node);
|
| Línea 7983... |
Línea 8289... |
| 7983 |
return true;
|
8289 |
return true;
|
| 7984 |
}
|
8290 |
}
|
| 7985 |
return inSameBlock;
|
8291 |
return inSameBlock;
|
| 7986 |
};
|
8292 |
};
|
| Línea 7987... |
Línea -... |
| 7987 |
|
- |
|
| 7988 |
var HDirection;
|
- |
|
| 7989 |
(function (HDirection) {
|
- |
|
| 7990 |
HDirection[HDirection['Backwards'] = -1] = 'Backwards';
|
- |
|
| 7991 |
HDirection[HDirection['Forwards'] = 1] = 'Forwards';
|
- |
|
| 7992 |
}(HDirection || (HDirection = {})));
|
8293 |
|
| 7993 |
const isContentEditableFalse$6 = isContentEditableFalse$b;
|
8294 |
const isContentEditableFalse$6 = isContentEditableFalse$b;
|
| 7994 |
const isText$3 = isText$a;
|
8295 |
const isText$3 = isText$b;
|
| 7995 |
const isElement$1 = isElement$6;
|
8296 |
const isElement$1 = isElement$6;
|
| 7996 |
const isBr$2 = isBr$6;
|
8297 |
const isBr$2 = isBr$6;
|
| 7997 |
const isCaretCandidate = isCaretCandidate$3;
|
8298 |
const isCaretCandidate = isCaretCandidate$3;
|
| 7998 |
const isAtomic = isAtomic$1;
|
8299 |
const isAtomic = isAtomic$1;
|
| Línea 8044... |
Línea 8345... |
| 8044 |
return CaretPosition(nextSibling, 0);
|
8345 |
return CaretPosition(nextSibling, 0);
|
| 8045 |
} else {
|
8346 |
} else {
|
| 8046 |
return CaretPosition.before(nextSibling);
|
8347 |
return CaretPosition.before(nextSibling);
|
| 8047 |
}
|
8348 |
}
|
| 8048 |
} else {
|
8349 |
} else {
|
| 8049 |
return findCaretPosition$1(HDirection.Forwards, CaretPosition.after(nextNode), root);
|
8350 |
return findCaretPosition$1(1, CaretPosition.after(nextNode), root);
|
| 8050 |
}
|
8351 |
}
|
| 8051 |
};
|
8352 |
};
|
| 8052 |
const findCaretPosition$1 = (direction, startPos, root) => {
|
8353 |
const findCaretPosition$1 = (direction, startPos, root) => {
|
| 8053 |
let node;
|
8354 |
let node;
|
| 8054 |
let nextNode;
|
8355 |
let nextNode;
|
| Línea 8122... |
Línea 8423... |
| 8122 |
if (isEditableCaretCandidate(node, root)) {
|
8423 |
if (isEditableCaretCandidate(node, root)) {
|
| 8123 |
return getCaretCandidatePosition(direction, node);
|
8424 |
return getCaretCandidatePosition(direction, node);
|
| 8124 |
}
|
8425 |
}
|
| 8125 |
}
|
8426 |
}
|
| 8126 |
nextNode = node ? findNode(node, direction, isEditableCaretCandidate, root) : node;
|
8427 |
nextNode = node ? findNode(node, direction, isEditableCaretCandidate, root) : node;
|
| 8127 |
const rootContentEditableFalseElm = last$2(filter$5(getParents$3(container, root), isContentEditableFalse$6));
|
8428 |
const rootContentEditableFalseElm = last$1(filter$5(getParents$3(container, root), isContentEditableFalse$6));
|
| 8128 |
if (rootContentEditableFalseElm && (!nextNode || !rootContentEditableFalseElm.contains(nextNode))) {
|
8429 |
if (rootContentEditableFalseElm && (!nextNode || !rootContentEditableFalseElm.contains(nextNode))) {
|
| 8129 |
if (isForwards(direction)) {
|
8430 |
if (isForwards(direction)) {
|
| 8130 |
caretPosition = CaretPosition.after(rootContentEditableFalseElm);
|
8431 |
caretPosition = CaretPosition.after(rootContentEditableFalseElm);
|
| 8131 |
} else {
|
8432 |
} else {
|
| 8132 |
caretPosition = CaretPosition.before(rootContentEditableFalseElm);
|
8433 |
caretPosition = CaretPosition.before(rootContentEditableFalseElm);
|
| Línea 8138... |
Línea 8439... |
| 8138 |
}
|
8439 |
}
|
| 8139 |
return null;
|
8440 |
return null;
|
| 8140 |
};
|
8441 |
};
|
| 8141 |
const CaretWalker = root => ({
|
8442 |
const CaretWalker = root => ({
|
| 8142 |
next: caretPosition => {
|
8443 |
next: caretPosition => {
|
| 8143 |
return findCaretPosition$1(HDirection.Forwards, caretPosition, root);
|
8444 |
return findCaretPosition$1(1, caretPosition, root);
|
| 8144 |
},
|
8445 |
},
|
| 8145 |
prev: caretPosition => {
|
8446 |
prev: caretPosition => {
|
| 8146 |
return findCaretPosition$1(HDirection.Backwards, caretPosition, root);
|
8447 |
return findCaretPosition$1(-1, caretPosition, root);
|
| 8147 |
}
|
8448 |
}
|
| 8148 |
});
|
8449 |
});
|
| Línea 8149... |
Línea 8450... |
| 8149 |
|
8450 |
|
| 8150 |
const walkToPositionIn = (forward, root, start) => {
|
8451 |
const walkToPositionIn = (forward, root, start) => {
|
| Línea 8188... |
Línea 8489... |
| 8188 |
}
|
8489 |
}
|
| 8189 |
});
|
8490 |
});
|
| 8190 |
const navigateIgnore = (forward, root, from, ignoreFilter) => navigate(forward, root, from).bind(pos => ignoreFilter(pos) ? navigateIgnore(forward, root, pos, ignoreFilter) : Optional.some(pos));
|
8491 |
const navigateIgnore = (forward, root, from, ignoreFilter) => navigate(forward, root, from).bind(pos => ignoreFilter(pos) ? navigateIgnore(forward, root, pos, ignoreFilter) : Optional.some(pos));
|
| 8191 |
const positionIn = (forward, element) => {
|
8492 |
const positionIn = (forward, element) => {
|
| 8192 |
const startNode = forward ? element.firstChild : element.lastChild;
|
8493 |
const startNode = forward ? element.firstChild : element.lastChild;
|
| 8193 |
if (isText$a(startNode)) {
|
8494 |
if (isText$b(startNode)) {
|
| 8194 |
return Optional.some(CaretPosition(startNode, forward ? 0 : startNode.data.length));
|
8495 |
return Optional.some(CaretPosition(startNode, forward ? 0 : startNode.data.length));
|
| 8195 |
} else if (startNode) {
|
8496 |
} else if (startNode) {
|
| 8196 |
if (isCaretCandidate$3(startNode)) {
|
8497 |
if (isCaretCandidate$3(startNode)) {
|
| 8197 |
return Optional.some(forward ? CaretPosition.before(startNode) : afterElement(startNode));
|
8498 |
return Optional.some(forward ? CaretPosition.before(startNode) : afterElement(startNode));
|
| 8198 |
} else {
|
8499 |
} else {
|
| Línea 8285... |
Línea 8586... |
| 8285 |
}
|
8586 |
}
|
| 8286 |
return tryFindRangePosition(node, rng);
|
8587 |
return tryFindRangePosition(node, rng);
|
| 8287 |
}
|
8588 |
}
|
| 8288 |
node = children[point[i]];
|
8589 |
node = children[point[i]];
|
| 8289 |
}
|
8590 |
}
|
| 8290 |
if (isText$a(node)) {
|
8591 |
if (isText$b(node)) {
|
| 8291 |
offset = Math.min(point[0], node.data.length);
|
8592 |
offset = Math.min(point[0], node.data.length);
|
| 8292 |
}
|
8593 |
}
|
| 8293 |
if (isElement$6(node)) {
|
8594 |
if (isElement$6(node)) {
|
| 8294 |
offset = Math.min(point[0], node.childNodes.length);
|
8595 |
offset = Math.min(point[0], node.childNodes.length);
|
| 8295 |
}
|
8596 |
}
|
| Línea 8299... |
Línea 8600... |
| 8299 |
rng.setEnd(node, offset);
|
8600 |
rng.setEnd(node, offset);
|
| 8300 |
}
|
8601 |
}
|
| 8301 |
}
|
8602 |
}
|
| 8302 |
return true;
|
8603 |
return true;
|
| 8303 |
};
|
8604 |
};
|
| 8304 |
const isValidTextNode = node => isText$a(node) && node.data.length > 0;
|
8605 |
const isValidTextNode = node => isText$b(node) && node.data.length > 0;
|
| 8305 |
const restoreEndPoint = (dom, suffix, bookmark) => {
|
8606 |
const restoreEndPoint = (dom, suffix, bookmark) => {
|
| 8306 |
const marker = dom.get(bookmark.id + '_' + suffix);
|
8607 |
const marker = dom.get(bookmark.id + '_' + suffix);
|
| 8307 |
const markerParent = marker === null || marker === void 0 ? void 0 : marker.parentNode;
|
8608 |
const markerParent = marker === null || marker === void 0 ? void 0 : marker.parentNode;
|
| 8308 |
const keep = bookmark.keep;
|
8609 |
const keep = bookmark.keep;
|
| 8309 |
if (marker && markerParent) {
|
8610 |
if (marker && markerParent) {
|
| Línea 8347... |
Línea 8648... |
| 8347 |
}
|
8648 |
}
|
| 8348 |
if (!keep) {
|
8649 |
if (!keep) {
|
| 8349 |
const prev = marker.previousSibling;
|
8650 |
const prev = marker.previousSibling;
|
| 8350 |
const next = marker.nextSibling;
|
8651 |
const next = marker.nextSibling;
|
| 8351 |
Tools.each(Tools.grep(marker.childNodes), node => {
|
8652 |
Tools.each(Tools.grep(marker.childNodes), node => {
|
| 8352 |
if (isText$a(node)) {
|
8653 |
if (isText$b(node)) {
|
| 8353 |
node.data = node.data.replace(/\uFEFF/g, '');
|
8654 |
node.data = node.data.replace(/\uFEFF/g, '');
|
| 8354 |
}
|
8655 |
}
|
| 8355 |
});
|
8656 |
});
|
| 8356 |
let otherMarker;
|
8657 |
let otherMarker;
|
| 8357 |
while (otherMarker = dom.get(bookmark.id + '_' + suffix)) {
|
8658 |
while (otherMarker = dom.get(bookmark.id + '_' + suffix)) {
|
| 8358 |
dom.remove(otherMarker, true);
|
8659 |
dom.remove(otherMarker, true);
|
| 8359 |
}
|
8660 |
}
|
| 8360 |
if (isText$a(next) && isText$a(prev) && !Env.browser.isOpera()) {
|
8661 |
if (isText$b(next) && isText$b(prev) && !Env.browser.isOpera()) {
|
| 8361 |
const idx = prev.data.length;
|
8662 |
const idx = prev.data.length;
|
| 8362 |
prev.appendData(next.data);
|
8663 |
prev.appendData(next.data);
|
| 8363 |
dom.remove(next);
|
8664 |
dom.remove(next);
|
| 8364 |
container = prev;
|
8665 |
container = prev;
|
| 8365 |
offset = idx;
|
8666 |
offset = idx;
|
| Línea 8421... |
Línea 8722... |
| 8421 |
}
|
8722 |
}
|
| 8422 |
}
|
8723 |
}
|
| 8423 |
return Optional.none();
|
8724 |
return Optional.none();
|
| 8424 |
};
|
8725 |
};
|
| Línea 8425... |
Línea 8726... |
| 8425 |
|
8726 |
|
| 8426 |
const getBookmark$1 = (selection, type, normalized) => {
|
8727 |
const getBookmark$2 = (selection, type, normalized) => {
|
| 8427 |
return getBookmark$2(selection, type, normalized);
|
8728 |
return getBookmark$3(selection, type, normalized);
|
| 8428 |
};
|
8729 |
};
|
| 8429 |
const moveToBookmark = (selection, bookmark) => {
|
8730 |
const moveToBookmark = (selection, bookmark) => {
|
| 8430 |
resolve(selection, bookmark).each(({range, forward}) => {
|
8731 |
resolve(selection, bookmark).each(({range, forward}) => {
|
| 8431 |
selection.setRng(range, forward);
|
8732 |
selection.setRng(range, forward);
|
| Línea 8468... |
Línea 8769... |
| 8468 |
const getCellsFromEditor = editor => getCellsFromElementOrRanges(getRanges$1(editor.selection.getSel()), SugarElement.fromDom(editor.getBody()));
|
8769 |
const getCellsFromEditor = editor => getCellsFromElementOrRanges(getRanges$1(editor.selection.getSel()), SugarElement.fromDom(editor.getBody()));
|
| 8469 |
const getClosestTable = (cell, isRoot) => ancestor$3(cell, 'table', isRoot);
|
8770 |
const getClosestTable = (cell, isRoot) => ancestor$3(cell, 'table', isRoot);
|
| Línea 8470... |
Línea 8771... |
| 8470 |
|
8771 |
|
| 8471 |
const getStartNode = rng => {
|
8772 |
const getStartNode = rng => {
|
| 8472 |
const sc = rng.startContainer, so = rng.startOffset;
|
8773 |
const sc = rng.startContainer, so = rng.startOffset;
|
| 8473 |
if (isText$a(sc)) {
|
8774 |
if (isText$b(sc)) {
|
| 8474 |
return so === 0 ? Optional.some(SugarElement.fromDom(sc)) : Optional.none();
|
8775 |
return so === 0 ? Optional.some(SugarElement.fromDom(sc)) : Optional.none();
|
| 8475 |
} else {
|
8776 |
} else {
|
| 8476 |
return Optional.from(sc.childNodes[so]).map(SugarElement.fromDom);
|
8777 |
return Optional.from(sc.childNodes[so]).map(SugarElement.fromDom);
|
| 8477 |
}
|
8778 |
}
|
| 8478 |
};
|
8779 |
};
|
| 8479 |
const getEndNode = rng => {
|
8780 |
const getEndNode = rng => {
|
| 8480 |
const ec = rng.endContainer, eo = rng.endOffset;
|
8781 |
const ec = rng.endContainer, eo = rng.endOffset;
|
| 8481 |
if (isText$a(ec)) {
|
8782 |
if (isText$b(ec)) {
|
| 8482 |
return eo === ec.data.length ? Optional.some(SugarElement.fromDom(ec)) : Optional.none();
|
8783 |
return eo === ec.data.length ? Optional.some(SugarElement.fromDom(ec)) : Optional.none();
|
| 8483 |
} else {
|
8784 |
} else {
|
| 8484 |
return Optional.from(ec.childNodes[eo - 1]).map(SugarElement.fromDom);
|
8785 |
return Optional.from(ec.childNodes[eo - 1]).map(SugarElement.fromDom);
|
| 8485 |
}
|
8786 |
}
|
| Línea 8515... |
Línea 8816... |
| 8515 |
'th',
|
8816 |
'th',
|
| 8516 |
'table'
|
8817 |
'table'
|
| 8517 |
], name.toLowerCase()));
|
8818 |
], name.toLowerCase()));
|
| 8518 |
let currentNode = node;
|
8819 |
let currentNode = node;
|
| 8519 |
do {
|
8820 |
do {
|
| 8520 |
if (isText$a(currentNode) && Tools.trim(currentNode.data).length !== 0) {
|
8821 |
if (isText$b(currentNode) && Tools.trim(currentNode.data).length !== 0) {
|
| 8521 |
if (start) {
|
8822 |
if (start) {
|
| 8522 |
rng.setStart(currentNode, 0);
|
8823 |
rng.setStart(currentNode, 0);
|
| 8523 |
} else {
|
8824 |
} else {
|
| 8524 |
rng.setEnd(currentNode, currentNode.data.length);
|
8825 |
rng.setEnd(currentNode, currentNode.data.length);
|
| 8525 |
}
|
8826 |
}
|
| Línea 8569... |
Línea 8870... |
| 8569 |
executor(bookmark);
|
8870 |
executor(bookmark);
|
| 8570 |
selection.moveToBookmark(bookmark);
|
8871 |
selection.moveToBookmark(bookmark);
|
| 8571 |
};
|
8872 |
};
|
| Línea 8572... |
Línea 8873... |
| 8572 |
|
8873 |
|
| 8573 |
const isNode = node => isNumber(node === null || node === void 0 ? void 0 : node.nodeType);
|
8874 |
const isNode = node => isNumber(node === null || node === void 0 ? void 0 : node.nodeType);
|
| 8574 |
const isElementNode$1 = node => isElement$6(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node);
|
8875 |
const isElementNode$1 = node => isElement$6(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$1(node);
|
| 8575 |
const isElementDirectlySelected = (dom, node) => {
|
8876 |
const isElementDirectlySelected = (dom, node) => {
|
| 8576 |
if (isElementNode$1(node) && !/^(TD|TH)$/.test(node.nodeName)) {
|
8877 |
if (isElementNode$1(node) && !/^(TD|TH)$/.test(node.nodeName)) {
|
| 8577 |
const selectedAttr = dom.getAttrib(node, 'data-mce-selected');
|
8878 |
const selectedAttr = dom.getAttrib(node, 'data-mce-selected');
|
| 8578 |
const value = parseInt(selectedAttr, 10);
|
8879 |
const value = parseInt(selectedAttr, 10);
|
| Línea 8616... |
Línea 8917... |
| 8616 |
walker.next(true);
|
8917 |
walker.next(true);
|
| 8617 |
}
|
8918 |
}
|
| 8618 |
for (let node = walker.current(); node; node = walker.next()) {
|
8919 |
for (let node = walker.current(); node; node = walker.next()) {
|
| 8619 |
if (dom.getContentEditable(node) === 'false') {
|
8920 |
if (dom.getContentEditable(node) === 'false') {
|
| 8620 |
return;
|
8921 |
return;
|
| 8621 |
} else if (isText$a(node) && !isWhiteSpaceNode$1(node)) {
|
8922 |
} else if (isText$b(node) && !isWhiteSpaceNode$1(node)) {
|
| 8622 |
rng.setStart(node, 0);
|
8923 |
rng.setStart(node, 0);
|
| 8623 |
selection.setRng(rng);
|
8924 |
selection.setRng(rng);
|
| 8624 |
return;
|
8925 |
return;
|
| 8625 |
}
|
8926 |
}
|
| 8626 |
}
|
8927 |
}
|
| Línea 8640... |
Línea 8941... |
| 8640 |
const isTextBlock$1 = (schema, node) => !!schema.getTextBlockElements()[node.nodeName.toLowerCase()] || isTransparentBlock(schema, node);
|
8941 |
const isTextBlock$1 = (schema, node) => !!schema.getTextBlockElements()[node.nodeName.toLowerCase()] || isTransparentBlock(schema, node);
|
| 8641 |
const isValid = (ed, parent, child) => {
|
8942 |
const isValid = (ed, parent, child) => {
|
| 8642 |
return ed.schema.isValidChild(parent, child);
|
8943 |
return ed.schema.isValidChild(parent, child);
|
| 8643 |
};
|
8944 |
};
|
| 8644 |
const isWhiteSpaceNode$1 = (node, allowSpaces = false) => {
|
8945 |
const isWhiteSpaceNode$1 = (node, allowSpaces = false) => {
|
| 8645 |
if (isNonNullable(node) && isText$a(node)) {
|
8946 |
if (isNonNullable(node) && isText$b(node)) {
|
| 8646 |
const data = allowSpaces ? node.data.replace(/ /g, '\xA0') : node.data;
|
8947 |
const data = allowSpaces ? node.data.replace(/ /g, '\xA0') : node.data;
|
| 8647 |
return isWhitespaceText(data);
|
8948 |
return isWhitespaceText(data);
|
| 8648 |
} else {
|
8949 |
} else {
|
| 8649 |
return false;
|
8950 |
return false;
|
| 8650 |
}
|
8951 |
}
|
| 8651 |
};
|
8952 |
};
|
| 8652 |
const isEmptyTextNode$1 = node => {
|
8953 |
const isEmptyTextNode$1 = node => {
|
| 8653 |
return isNonNullable(node) && isText$a(node) && node.length === 0;
|
8954 |
return isNonNullable(node) && isText$b(node) && node.length === 0;
|
| 8654 |
};
|
8955 |
};
|
| 8655 |
const isWrapNoneditableTarget = (editor, node) => {
|
8956 |
const isWrapNoneditableTarget = (editor, node) => {
|
| 8656 |
const baseDataSelector = '[data-mce-cef-wrappable]';
|
8957 |
const baseDataSelector = '[data-mce-cef-wrappable]';
|
| 8657 |
const formatNoneditableSelector = getFormatNoneditableSelector(editor);
|
8958 |
const formatNoneditableSelector = getFormatNoneditableSelector(editor);
|
| 8658 |
const selector = isEmpty$3(formatNoneditableSelector) ? baseDataSelector : `${ baseDataSelector },${ formatNoneditableSelector }`;
|
8959 |
const selector = isEmpty$3(formatNoneditableSelector) ? baseDataSelector : `${ baseDataSelector },${ formatNoneditableSelector }`;
|
| Línea 8759... |
Línea 9060... |
| 8759 |
const shouldExpandToSelector = format => isSelectorFormat(format) && format.expand !== false && !isInlineFormat(format);
|
9060 |
const shouldExpandToSelector = format => isSelectorFormat(format) && format.expand !== false && !isInlineFormat(format);
|
| 8760 |
const getEmptyCaretContainers = node => {
|
9061 |
const getEmptyCaretContainers = node => {
|
| 8761 |
const nodes = [];
|
9062 |
const nodes = [];
|
| 8762 |
let tempNode = node;
|
9063 |
let tempNode = node;
|
| 8763 |
while (tempNode) {
|
9064 |
while (tempNode) {
|
| 8764 |
if (isText$a(tempNode) && tempNode.data !== ZWSP$1 || tempNode.childNodes.length > 1) {
|
9065 |
if (isText$b(tempNode) && tempNode.data !== ZWSP$1 || tempNode.childNodes.length > 1) {
|
| 8765 |
return [];
|
9066 |
return [];
|
| 8766 |
}
|
9067 |
}
|
| 8767 |
if (isElement$6(tempNode)) {
|
9068 |
if (isElement$6(tempNode)) {
|
| 8768 |
nodes.push(tempNode);
|
9069 |
nodes.push(tempNode);
|
| 8769 |
}
|
9070 |
}
|
| Línea 8814... |
Línea 9115... |
| 8814 |
};
|
9115 |
};
|
| 8815 |
const findSpace = (start, node, offset) => walkText(start, node, offset, c => isNbsp(c) || isWhiteSpace(c));
|
9116 |
const findSpace = (start, node, offset) => walkText(start, node, offset, c => isNbsp(c) || isWhiteSpace(c));
|
| 8816 |
const findContent = (start, node, offset) => walkText(start, node, offset, isContent);
|
9117 |
const findContent = (start, node, offset) => walkText(start, node, offset, isContent);
|
| 8817 |
const findWordEndPoint = (dom, body, container, offset, start, includeTrailingSpaces) => {
|
9118 |
const findWordEndPoint = (dom, body, container, offset, start, includeTrailingSpaces) => {
|
| 8818 |
let lastTextNode;
|
9119 |
let lastTextNode;
|
| - |
|
9120 |
const closestRoot = dom.getParent(container, node => isEditingHost(node) || dom.isBlock(node));
|
| 8819 |
const rootNode = dom.getParent(container, dom.isBlock) || body;
|
9121 |
const rootNode = isNonNullable(closestRoot) ? closestRoot : body;
|
| 8820 |
const walk = (container, offset, pred) => {
|
9122 |
const walk = (container, offset, pred) => {
|
| 8821 |
const textSeeker = TextSeeker(dom);
|
9123 |
const textSeeker = TextSeeker(dom);
|
| 8822 |
const walker = start ? textSeeker.backwards : textSeeker.forwards;
|
9124 |
const walker = start ? textSeeker.backwards : textSeeker.forwards;
|
| 8823 |
return Optional.from(walker(container, offset, (text, textOffset) => {
|
9125 |
return Optional.from(walker(container, offset, (text, textOffset) => {
|
| 8824 |
if (isBookmarkNode(text.parentNode)) {
|
9126 |
if (isBookmarkNode(text.parentNode)) {
|
| Línea 8835... |
Línea 9137... |
| 8835 |
offset: start ? 0 : lastTextNode.length
|
9137 |
offset: start ? 0 : lastTextNode.length
|
| 8836 |
}) : Optional.none());
|
9138 |
}) : Optional.none());
|
| 8837 |
};
|
9139 |
};
|
| 8838 |
const findSelectorEndPoint = (dom, formatList, rng, container, siblingName) => {
|
9140 |
const findSelectorEndPoint = (dom, formatList, rng, container, siblingName) => {
|
| 8839 |
const sibling = container[siblingName];
|
9141 |
const sibling = container[siblingName];
|
| 8840 |
if (isText$a(container) && isEmpty$3(container.data) && sibling) {
|
9142 |
if (isText$b(container) && isEmpty$3(container.data) && sibling) {
|
| 8841 |
container = sibling;
|
9143 |
container = sibling;
|
| 8842 |
}
|
9144 |
}
|
| 8843 |
const parents = getParents$1(dom, container);
|
9145 |
const parents = getParents$1(dom, container);
|
| 8844 |
for (let i = 0; i < parents.length; i++) {
|
9146 |
for (let i = 0; i < parents.length; i++) {
|
| 8845 |
for (let y = 0; y < formatList.length; y++) {
|
9147 |
for (let y = 0; y < formatList.length; y++) {
|
| Línea 8862... |
Línea 9164... |
| 8862 |
if (isBlockFormat(format)) {
|
9164 |
if (isBlockFormat(format)) {
|
| 8863 |
node = format.wrapper ? null : dom.getParent(container, format.block, root);
|
9165 |
node = format.wrapper ? null : dom.getParent(container, format.block, root);
|
| 8864 |
}
|
9166 |
}
|
| 8865 |
if (!node) {
|
9167 |
if (!node) {
|
| 8866 |
const scopeRoot = (_a = dom.getParent(container, 'LI,TD,TH,SUMMARY')) !== null && _a !== void 0 ? _a : root;
|
9168 |
const scopeRoot = (_a = dom.getParent(container, 'LI,TD,TH,SUMMARY')) !== null && _a !== void 0 ? _a : root;
|
| 8867 |
node = dom.getParent(isText$a(container) ? container.parentNode : container, node => node !== root && isTextBlock(dom.schema, node), scopeRoot);
|
9169 |
node = dom.getParent(isText$b(container) ? container.parentNode : container, node => node !== root && isTextBlock(dom.schema, node), scopeRoot);
|
| 8868 |
}
|
9170 |
}
|
| 8869 |
if (node && isBlockFormat(format) && format.wrapper) {
|
9171 |
if (node && isBlockFormat(format) && format.wrapper) {
|
| 8870 |
node = getParents$1(dom, node, 'ul,ol').reverse()[0] || node;
|
9172 |
node = getParents$1(dom, node, 'ul,ol').reverse()[0] || node;
|
| 8871 |
}
|
9173 |
}
|
| 8872 |
if (!node) {
|
9174 |
if (!node) {
|
| Línea 8888... |
Línea 9190... |
| 8888 |
return true;
|
9190 |
return true;
|
| 8889 |
} else {
|
9191 |
} else {
|
| 8890 |
return isAtBlockBoundary$1(dom, root, parent, siblingName);
|
9192 |
return isAtBlockBoundary$1(dom, root, parent, siblingName);
|
| 8891 |
}
|
9193 |
}
|
| 8892 |
};
|
9194 |
};
|
| 8893 |
const findParentContainer = (dom, formatList, container, offset, start) => {
|
9195 |
const findParentContainer = (dom, formatList, container, offset, start, expandToBlock) => {
|
| 8894 |
let parent = container;
|
9196 |
let parent = container;
|
| 8895 |
const siblingName = start ? 'previousSibling' : 'nextSibling';
|
9197 |
const siblingName = start ? 'previousSibling' : 'nextSibling';
|
| 8896 |
const root = dom.getRoot();
|
9198 |
const root = dom.getRoot();
|
| 8897 |
if (isText$a(container) && !isWhiteSpaceNode(container)) {
|
9199 |
if (isText$b(container) && !isWhiteSpaceNode(container)) {
|
| 8898 |
if (start ? offset > 0 : offset < container.data.length) {
|
9200 |
if (start ? offset > 0 : offset < container.data.length) {
|
| 8899 |
return container;
|
9201 |
return container;
|
| 8900 |
}
|
9202 |
}
|
| 8901 |
}
|
9203 |
}
|
| 8902 |
while (parent) {
|
9204 |
while (parent) {
|
| - |
|
9205 |
if (isEditingHost(parent)) {
|
| - |
|
9206 |
return container;
|
| - |
|
9207 |
}
|
| 8903 |
if (!formatList[0].block_expand && dom.isBlock(parent)) {
|
9208 |
if (!formatList[0].block_expand && dom.isBlock(parent)) {
|
| 8904 |
return parent;
|
9209 |
return expandToBlock ? parent : container;
|
| 8905 |
}
|
9210 |
}
|
| 8906 |
for (let sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {
|
9211 |
for (let sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {
|
| 8907 |
const allowSpaces = isText$a(sibling) && !isAtBlockBoundary$1(dom, root, sibling, siblingName);
|
9212 |
const allowSpaces = isText$b(sibling) && !isAtBlockBoundary$1(dom, root, sibling, siblingName);
|
| 8908 |
if (!isBookmarkNode(sibling) && !isBogusBr(sibling) && !isWhiteSpaceNode(sibling, allowSpaces)) {
|
9213 |
if (!isBookmarkNode(sibling) && !isBogusBr(sibling) && !isWhiteSpaceNode(sibling, allowSpaces)) {
|
| 8909 |
return parent;
|
9214 |
return parent;
|
| 8910 |
}
|
9215 |
}
|
| 8911 |
}
|
9216 |
}
|
| 8912 |
if (parent === root || parent.parentNode === root) {
|
9217 |
if (parent === root || parent.parentNode === root) {
|
| Línea 8916... |
Línea 9221... |
| 8916 |
parent = parent.parentNode;
|
9221 |
parent = parent.parentNode;
|
| 8917 |
}
|
9222 |
}
|
| 8918 |
return container;
|
9223 |
return container;
|
| 8919 |
};
|
9224 |
};
|
| 8920 |
const isSelfOrParentBookmark = container => isBookmarkNode(container.parentNode) || isBookmarkNode(container);
|
9225 |
const isSelfOrParentBookmark = container => isBookmarkNode(container.parentNode) || isBookmarkNode(container);
|
| 8921 |
const expandRng = (dom, rng, formatList, includeTrailingSpace = false) => {
|
9226 |
const expandRng = (dom, rng, formatList, expandOptions = {}) => {
|
| - |
|
9227 |
const {includeTrailingSpace = false, expandToBlock = true} = expandOptions;
|
| - |
|
9228 |
const editableHost = dom.getParent(rng.commonAncestorContainer, node => isEditingHost(node));
|
| - |
|
9229 |
const root = isNonNullable(editableHost) ? editableHost : dom.getRoot();
|
| 8922 |
let {startContainer, startOffset, endContainer, endOffset} = rng;
|
9230 |
let {startContainer, startOffset, endContainer, endOffset} = rng;
|
| 8923 |
const format = formatList[0];
|
9231 |
const format = formatList[0];
|
| 8924 |
if (isElement$6(startContainer) && startContainer.hasChildNodes()) {
|
9232 |
if (isElement$6(startContainer) && startContainer.hasChildNodes()) {
|
| 8925 |
startContainer = getNode$1(startContainer, startOffset);
|
9233 |
startContainer = getNode$1(startContainer, startOffset);
|
| 8926 |
if (isText$a(startContainer)) {
|
9234 |
if (isText$b(startContainer)) {
|
| 8927 |
startOffset = 0;
|
9235 |
startOffset = 0;
|
| 8928 |
}
|
9236 |
}
|
| 8929 |
}
|
9237 |
}
|
| 8930 |
if (isElement$6(endContainer) && endContainer.hasChildNodes()) {
|
9238 |
if (isElement$6(endContainer) && endContainer.hasChildNodes()) {
|
| 8931 |
endContainer = getNode$1(endContainer, rng.collapsed ? endOffset : endOffset - 1);
|
9239 |
endContainer = getNode$1(endContainer, rng.collapsed ? endOffset : endOffset - 1);
|
| 8932 |
if (isText$a(endContainer)) {
|
9240 |
if (isText$b(endContainer)) {
|
| 8933 |
endOffset = endContainer.data.length;
|
9241 |
endOffset = endContainer.data.length;
|
| 8934 |
}
|
9242 |
}
|
| 8935 |
}
|
9243 |
}
|
| 8936 |
startContainer = findParentContentEditable(dom, startContainer);
|
9244 |
startContainer = findParentContentEditable(dom, startContainer);
|
| 8937 |
endContainer = findParentContentEditable(dom, endContainer);
|
9245 |
endContainer = findParentContentEditable(dom, endContainer);
|
| Línea 8940... |
Línea 9248... |
| 8940 |
if (rng.collapsed) {
|
9248 |
if (rng.collapsed) {
|
| 8941 |
startContainer = startContainer.previousSibling || startContainer;
|
9249 |
startContainer = startContainer.previousSibling || startContainer;
|
| 8942 |
} else {
|
9250 |
} else {
|
| 8943 |
startContainer = startContainer.nextSibling || startContainer;
|
9251 |
startContainer = startContainer.nextSibling || startContainer;
|
| 8944 |
}
|
9252 |
}
|
| 8945 |
if (isText$a(startContainer)) {
|
9253 |
if (isText$b(startContainer)) {
|
| 8946 |
startOffset = rng.collapsed ? startContainer.length : 0;
|
9254 |
startOffset = rng.collapsed ? startContainer.length : 0;
|
| 8947 |
}
|
9255 |
}
|
| 8948 |
}
|
9256 |
}
|
| 8949 |
if (isSelfOrParentBookmark(endContainer)) {
|
9257 |
if (isSelfOrParentBookmark(endContainer)) {
|
| 8950 |
endContainer = isBookmarkNode(endContainer) ? endContainer : endContainer.parentNode;
|
9258 |
endContainer = isBookmarkNode(endContainer) ? endContainer : endContainer.parentNode;
|
| 8951 |
if (rng.collapsed) {
|
9259 |
if (rng.collapsed) {
|
| 8952 |
endContainer = endContainer.nextSibling || endContainer;
|
9260 |
endContainer = endContainer.nextSibling || endContainer;
|
| 8953 |
} else {
|
9261 |
} else {
|
| 8954 |
endContainer = endContainer.previousSibling || endContainer;
|
9262 |
endContainer = endContainer.previousSibling || endContainer;
|
| 8955 |
}
|
9263 |
}
|
| 8956 |
if (isText$a(endContainer)) {
|
9264 |
if (isText$b(endContainer)) {
|
| 8957 |
endOffset = rng.collapsed ? 0 : endContainer.length;
|
9265 |
endOffset = rng.collapsed ? 0 : endContainer.length;
|
| 8958 |
}
|
9266 |
}
|
| 8959 |
}
|
9267 |
}
|
| 8960 |
if (rng.collapsed) {
|
9268 |
if (rng.collapsed) {
|
| 8961 |
const startPoint = findWordEndPoint(dom, dom.getRoot(), startContainer, startOffset, true, includeTrailingSpace);
|
9269 |
const startPoint = findWordEndPoint(dom, root, startContainer, startOffset, true, includeTrailingSpace);
|
| 8962 |
startPoint.each(({container, offset}) => {
|
9270 |
startPoint.each(({container, offset}) => {
|
| 8963 |
startContainer = container;
|
9271 |
startContainer = container;
|
| 8964 |
startOffset = offset;
|
9272 |
startOffset = offset;
|
| 8965 |
});
|
9273 |
});
|
| 8966 |
const endPoint = findWordEndPoint(dom, dom.getRoot(), endContainer, endOffset, false, includeTrailingSpace);
|
9274 |
const endPoint = findWordEndPoint(dom, root, endContainer, endOffset, false, includeTrailingSpace);
|
| 8967 |
endPoint.each(({container, offset}) => {
|
9275 |
endPoint.each(({container, offset}) => {
|
| 8968 |
endContainer = container;
|
9276 |
endContainer = container;
|
| 8969 |
endOffset = offset;
|
9277 |
endOffset = offset;
|
| 8970 |
});
|
9278 |
});
|
| 8971 |
}
|
9279 |
}
|
| 8972 |
if (isInlineFormat(format) || format.block_expand) {
|
9280 |
if (isInlineFormat(format) || format.block_expand) {
|
| 8973 |
if (!isInlineFormat(format) || (!isText$a(startContainer) || startOffset === 0)) {
|
9281 |
if (!isInlineFormat(format) || (!isText$b(startContainer) || startOffset === 0)) {
|
| 8974 |
startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true);
|
9282 |
startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true, expandToBlock);
|
| 8975 |
}
|
9283 |
}
|
| 8976 |
if (!isInlineFormat(format) || (!isText$a(endContainer) || endOffset === endContainer.data.length)) {
|
9284 |
if (!isInlineFormat(format) || (!isText$b(endContainer) || endOffset === endContainer.data.length)) {
|
| 8977 |
endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false);
|
9285 |
endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false, expandToBlock);
|
| 8978 |
}
|
9286 |
}
|
| 8979 |
}
|
9287 |
}
|
| 8980 |
if (shouldExpandToSelector(format)) {
|
9288 |
if (shouldExpandToSelector(format)) {
|
| 8981 |
startContainer = findSelectorEndPoint(dom, formatList, rng, startContainer, 'previousSibling');
|
9289 |
startContainer = findSelectorEndPoint(dom, formatList, rng, startContainer, 'previousSibling');
|
| 8982 |
endContainer = findSelectorEndPoint(dom, formatList, rng, endContainer, 'nextSibling');
|
9290 |
endContainer = findSelectorEndPoint(dom, formatList, rng, endContainer, 'nextSibling');
|
| Línea 8984... |
Línea 9292... |
| 8984 |
if (isBlockFormat(format) || isSelectorFormat(format)) {
|
9292 |
if (isBlockFormat(format) || isSelectorFormat(format)) {
|
| 8985 |
startContainer = findBlockEndPoint(dom, formatList, startContainer, 'previousSibling');
|
9293 |
startContainer = findBlockEndPoint(dom, formatList, startContainer, 'previousSibling');
|
| 8986 |
endContainer = findBlockEndPoint(dom, formatList, endContainer, 'nextSibling');
|
9294 |
endContainer = findBlockEndPoint(dom, formatList, endContainer, 'nextSibling');
|
| 8987 |
if (isBlockFormat(format)) {
|
9295 |
if (isBlockFormat(format)) {
|
| 8988 |
if (!dom.isBlock(startContainer)) {
|
9296 |
if (!dom.isBlock(startContainer)) {
|
| 8989 |
startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true);
|
9297 |
startContainer = findParentContainer(dom, formatList, startContainer, startOffset, true, expandToBlock);
|
| - |
|
9298 |
if (isText$b(startContainer)) {
|
| - |
|
9299 |
startOffset = 0;
|
| - |
|
9300 |
}
|
| 8990 |
}
|
9301 |
}
|
| 8991 |
if (!dom.isBlock(endContainer)) {
|
9302 |
if (!dom.isBlock(endContainer)) {
|
| 8992 |
endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false);
|
9303 |
endContainer = findParentContainer(dom, formatList, endContainer, endOffset, false, expandToBlock);
|
| - |
|
9304 |
if (isText$b(endContainer)) {
|
| - |
|
9305 |
endOffset = endContainer.data.length;
|
| - |
|
9306 |
}
|
| 8993 |
}
|
9307 |
}
|
| 8994 |
}
|
9308 |
}
|
| 8995 |
}
|
9309 |
}
|
| 8996 |
if (isElement$6(startContainer) && startContainer.parentNode) {
|
9310 |
if (isElement$6(startContainer) && startContainer.parentNode) {
|
| 8997 |
startOffset = dom.nodeIndex(startContainer);
|
9311 |
startOffset = dom.nodeIndex(startContainer);
|
| Línea 9015... |
Línea 9329... |
| 9015 |
const startContainer = getNode$1(rng.startContainer, startOffset);
|
9329 |
const startContainer = getNode$1(rng.startContainer, startOffset);
|
| 9016 |
const endOffset = rng.endOffset;
|
9330 |
const endOffset = rng.endOffset;
|
| 9017 |
const endContainer = getNode$1(rng.endContainer, endOffset - 1);
|
9331 |
const endContainer = getNode$1(rng.endContainer, endOffset - 1);
|
| 9018 |
const exclude = nodes => {
|
9332 |
const exclude = nodes => {
|
| 9019 |
const firstNode = nodes[0];
|
9333 |
const firstNode = nodes[0];
|
| 9020 |
if (isText$a(firstNode) && firstNode === startContainer && startOffset >= firstNode.data.length) {
|
9334 |
if (isText$b(firstNode) && firstNode === startContainer && startOffset >= firstNode.data.length) {
|
| 9021 |
nodes.splice(0, 1);
|
9335 |
nodes.splice(0, 1);
|
| 9022 |
}
|
9336 |
}
|
| 9023 |
const lastNode = nodes[nodes.length - 1];
|
9337 |
const lastNode = nodes[nodes.length - 1];
|
| 9024 |
if (endOffset === 0 && nodes.length > 0 && lastNode === endContainer && isText$a(lastNode)) {
|
9338 |
if (endOffset === 0 && nodes.length > 0 && lastNode === endContainer && isText$b(lastNode)) {
|
| 9025 |
nodes.splice(nodes.length - 1, 1);
|
9339 |
nodes.splice(nodes.length - 1, 1);
|
| 9026 |
}
|
9340 |
}
|
| 9027 |
return nodes;
|
9341 |
return nodes;
|
| 9028 |
};
|
9342 |
};
|
| 9029 |
const collectSiblings = (node, name, endNode) => {
|
9343 |
const collectSiblings = (node, name, endNode) => {
|
| Línea 9073... |
Línea 9387... |
| 9073 |
'div[data-ephox-embed-iri]',
|
9387 |
'div[data-ephox-embed-iri]',
|
| 9074 |
'div.tiny-pageembed',
|
9388 |
'div.tiny-pageembed',
|
| 9075 |
'div.mce-toc',
|
9389 |
'div.mce-toc',
|
| 9076 |
'div[data-mce-toc]'
|
9390 |
'div[data-mce-toc]'
|
| 9077 |
];
|
9391 |
];
|
| 9078 |
const isZeroWidth = elem => isText$b(elem) && get$3(elem) === ZWSP$1;
|
9392 |
const isZeroWidth = elem => isText$c(elem) && get$3(elem) === ZWSP$1;
|
| 9079 |
const context = (editor, elem, wrapName, nodeName) => parent(elem).fold(() => 'skipping', parent => {
|
9393 |
const context = (editor, elem, wrapName, nodeName) => parent(elem).fold(() => 'skipping', parent => {
|
| 9080 |
if (nodeName === 'br' || isZeroWidth(elem)) {
|
9394 |
if (nodeName === 'br' || isZeroWidth(elem)) {
|
| 9081 |
return 'valid';
|
9395 |
return 'valid';
|
| 9082 |
} else if (isAnnotation(elem)) {
|
9396 |
} else if (isAnnotation(elem)) {
|
| 9083 |
return 'existing';
|
9397 |
return 'existing';
|
| Línea 9099... |
Línea 9413... |
| 9099 |
editor.selection.setRng(rng);
|
9413 |
editor.selection.setRng(rng);
|
| 9100 |
};
|
9414 |
};
|
| 9101 |
const applyAnnotation = (elem, masterUId, data, annotationName, decorate, directAnnotation) => {
|
9415 |
const applyAnnotation = (elem, masterUId, data, annotationName, decorate, directAnnotation) => {
|
| 9102 |
const {uid = masterUId, ...otherData} = data;
|
9416 |
const {uid = masterUId, ...otherData} = data;
|
| 9103 |
add$2(elem, annotation());
|
9417 |
add$2(elem, annotation());
|
| 9104 |
set$3(elem, `${ dataAnnotationId() }`, uid);
|
9418 |
set$4(elem, `${ dataAnnotationId() }`, uid);
|
| 9105 |
set$3(elem, `${ dataAnnotation() }`, annotationName);
|
9419 |
set$4(elem, `${ dataAnnotation() }`, annotationName);
|
| 9106 |
const {attributes = {}, classes = []} = decorate(uid, otherData);
|
9420 |
const {attributes = {}, classes = []} = decorate(uid, otherData);
|
| 9107 |
setAll$1(elem, attributes);
|
9421 |
setAll$1(elem, attributes);
|
| 9108 |
add(elem, classes);
|
9422 |
add(elem, classes);
|
| 9109 |
if (directAnnotation) {
|
9423 |
if (directAnnotation) {
|
| 9110 |
if (classes.length > 0) {
|
9424 |
if (classes.length > 0) {
|
| 9111 |
set$3(elem, `${ dataAnnotationClasses() }`, classes.join(','));
|
9425 |
set$4(elem, `${ dataAnnotationClasses() }`, classes.join(','));
|
| 9112 |
}
|
9426 |
}
|
| 9113 |
const attributeNames = keys(attributes);
|
9427 |
const attributeNames = keys(attributes);
|
| 9114 |
if (attributeNames.length > 0) {
|
9428 |
if (attributeNames.length > 0) {
|
| 9115 |
set$3(elem, `${ dataAnnotationAttributes() }`, attributeNames.join(','));
|
9429 |
set$4(elem, `${ dataAnnotationAttributes() }`, attributeNames.join(','));
|
| 9116 |
}
|
9430 |
}
|
| 9117 |
}
|
9431 |
}
|
| 9118 |
};
|
9432 |
};
|
| 9119 |
const removeDirectAnnotation = elem => {
|
9433 |
const removeDirectAnnotation = elem => {
|
| 9120 |
remove$7(elem, annotation());
|
9434 |
remove$6(elem, annotation());
|
| 9121 |
remove$a(elem, `${ dataAnnotationId() }`);
|
9435 |
remove$9(elem, `${ dataAnnotationId() }`);
|
| 9122 |
remove$a(elem, `${ dataAnnotation() }`);
|
9436 |
remove$9(elem, `${ dataAnnotation() }`);
|
| 9123 |
remove$a(elem, `${ dataAnnotationActive() }`);
|
9437 |
remove$9(elem, `${ dataAnnotationActive() }`);
|
| 9124 |
const customAttrNames = getOpt(elem, `${ dataAnnotationAttributes() }`).map(names => names.split(',')).getOr([]);
|
9438 |
const customAttrNames = getOpt(elem, `${ dataAnnotationAttributes() }`).map(names => names.split(',')).getOr([]);
|
| 9125 |
const customClasses = getOpt(elem, `${ dataAnnotationClasses() }`).map(names => names.split(',')).getOr([]);
|
9439 |
const customClasses = getOpt(elem, `${ dataAnnotationClasses() }`).map(names => names.split(',')).getOr([]);
|
| 9126 |
each$e(customAttrNames, name => remove$a(elem, name));
|
9440 |
each$e(customAttrNames, name => remove$9(elem, name));
|
| 9127 |
remove$4(elem, customClasses);
|
9441 |
remove$3(elem, customClasses);
|
| 9128 |
remove$a(elem, `${ dataAnnotationClasses() }`);
|
9442 |
remove$9(elem, `${ dataAnnotationClasses() }`);
|
| 9129 |
remove$a(elem, `${ dataAnnotationAttributes() }`);
|
9443 |
remove$9(elem, `${ dataAnnotationAttributes() }`);
|
| 9130 |
};
|
9444 |
};
|
| 9131 |
const makeAnnotation = (eDoc, uid, data, annotationName, decorate) => {
|
9445 |
const makeAnnotation = (eDoc, uid, data, annotationName, decorate) => {
|
| 9132 |
const master = SugarElement.fromTag('span', eDoc);
|
9446 |
const master = SugarElement.fromTag('span', eDoc);
|
| 9133 |
applyAnnotation(master, uid, data, annotationName, decorate, false);
|
9447 |
applyAnnotation(master, uid, data, annotationName, decorate, false);
|
| 9134 |
return master;
|
9448 |
return master;
|
| Línea 9204... |
Línea 9518... |
| 9204 |
}
|
9518 |
}
|
| 9205 |
});
|
9519 |
});
|
| 9206 |
};
|
9520 |
};
|
| Línea 9207... |
Línea 9521... |
| 9207 |
|
9521 |
|
| 9208 |
const Annotator = editor => {
|
9522 |
const Annotator = editor => {
|
| 9209 |
const registry = create$c();
|
9523 |
const registry = create$b();
|
| 9210 |
setup$x(editor, registry);
|
9524 |
setup$x(editor, registry);
|
| 9211 |
const changes = setup$y(editor, registry);
|
9525 |
const changes = setup$y(editor, registry);
|
| 9212 |
const isSpan = isTag('span');
|
9526 |
const isSpan = isTag('span');
|
| 9213 |
const removeAnnotations = elements => {
|
9527 |
const removeAnnotations = elements => {
|
| Línea 9252... |
Línea 9566... |
| 9252 |
};
|
9566 |
};
|
| 9253 |
};
|
9567 |
};
|
| Línea 9254... |
Línea 9568... |
| 9254 |
|
9568 |
|
| 9255 |
const BookmarkManager = selection => {
|
9569 |
const BookmarkManager = selection => {
|
| 9256 |
return {
|
9570 |
return {
|
| 9257 |
getBookmark: curry(getBookmark$1, selection),
|
9571 |
getBookmark: curry(getBookmark$2, selection),
|
| 9258 |
moveToBookmark: curry(moveToBookmark, selection)
|
9572 |
moveToBookmark: curry(moveToBookmark, selection)
|
| 9259 |
};
|
9573 |
};
|
| 9260 |
};
|
9574 |
};
|
| Línea 9266... |
Línea 9580... |
| 9266 |
} else {
|
9580 |
} else {
|
| 9267 |
return exists(range.getClientRects(), rect => containsXY(rect, clientX, clientY));
|
9581 |
return exists(range.getClientRects(), rect => containsXY(rect, clientX, clientY));
|
| 9268 |
}
|
9582 |
}
|
| 9269 |
};
|
9583 |
};
|
| Línea 9270... |
Línea 9584... |
| 9270 |
|
9584 |
|
| - |
|
9585 |
const getDocument = () => SugarElement.fromDom(document);
|
| 9271 |
const firePreProcess = (editor, args) => editor.dispatch('PreProcess', args);
|
9586 |
|
| 9272 |
const firePostProcess = (editor, args) => editor.dispatch('PostProcess', args);
|
9587 |
const focus$1 = (element, preventScroll = false) => element.dom.focus({ preventScroll });
|
| 9273 |
const fireRemove = editor => {
|
9588 |
const hasFocus$1 = element => {
|
| - |
|
9589 |
const root = getRootNode(element).dom;
|
| 9274 |
editor.dispatch('remove');
|
9590 |
return element.dom === root.activeElement;
|
| - |
|
9591 |
};
|
| - |
|
9592 |
const active$1 = (root = getDocument()) => Optional.from(root.dom.activeElement).map(SugarElement.fromDom);
|
| - |
|
9593 |
const search = element => active$1(getRootNode(element)).filter(e => element.dom.contains(e.dom));
|
| - |
|
9594 |
|
| - |
|
9595 |
const create$9 = (start, soffset, finish, foffset) => ({
|
| - |
|
9596 |
start,
|
| - |
|
9597 |
soffset,
|
| - |
|
9598 |
finish,
|
| - |
|
9599 |
foffset
|
| - |
|
9600 |
});
|
| - |
|
9601 |
const SimRange = { create: create$9 };
|
| - |
|
9602 |
|
| - |
|
9603 |
const adt$3 = Adt.generate([
|
| - |
|
9604 |
{ before: ['element'] },
|
| - |
|
9605 |
{
|
| - |
|
9606 |
on: [
|
| - |
|
9607 |
'element',
|
| - |
|
9608 |
'offset'
|
| - |
|
9609 |
]
|
| - |
|
9610 |
},
|
| - |
|
9611 |
{ after: ['element'] }
|
| - |
|
9612 |
]);
|
| - |
|
9613 |
const cata = (subject, onBefore, onOn, onAfter) => subject.fold(onBefore, onOn, onAfter);
|
| - |
|
9614 |
const getStart$2 = situ => situ.fold(identity, identity, identity);
|
| - |
|
9615 |
const before$1 = adt$3.before;
|
| 9275 |
};
|
9616 |
const on = adt$3.on;
|
| - |
|
9617 |
const after$1 = adt$3.after;
|
| - |
|
9618 |
const Situ = {
|
| - |
|
9619 |
before: before$1,
|
| - |
|
9620 |
on,
|
| - |
|
9621 |
after: after$1,
|
| 9276 |
const fireDetach = editor => {
|
9622 |
cata,
|
| 9277 |
editor.dispatch('detach');
|
9623 |
getStart: getStart$2
|
| - |
|
9624 |
};
|
| - |
|
9625 |
|
| - |
|
9626 |
const adt$2 = Adt.generate([
|
| - |
|
9627 |
{ domRange: ['rng'] },
|
| - |
|
9628 |
{
|
| - |
|
9629 |
relative: [
|
| - |
|
9630 |
'startSitu',
|
| - |
|
9631 |
'finishSitu'
|
| - |
|
9632 |
]
|
| - |
|
9633 |
},
|
| - |
|
9634 |
{
|
| - |
|
9635 |
exact: [
|
| - |
|
9636 |
'start',
|
| - |
|
9637 |
'soffset',
|
| - |
|
9638 |
'finish',
|
| - |
|
9639 |
'foffset'
|
| - |
|
9640 |
]
|
| - |
|
9641 |
}
|
| - |
|
9642 |
]);
|
| - |
|
9643 |
const exactFromRange = simRange => adt$2.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);
|
| - |
|
9644 |
const getStart$1 = selection => selection.match({
|
| - |
|
9645 |
domRange: rng => SugarElement.fromDom(rng.startContainer),
|
| - |
|
9646 |
relative: (startSitu, _finishSitu) => Situ.getStart(startSitu),
|
| - |
|
9647 |
exact: (start, _soffset, _finish, _foffset) => start
|
| - |
|
9648 |
});
|
| - |
|
9649 |
const domRange = adt$2.domRange;
|
| - |
|
9650 |
const relative = adt$2.relative;
|
| 9278 |
};
|
9651 |
const exact = adt$2.exact;
|
| 9279 |
const fireSwitchMode = (editor, mode) => {
|
9652 |
const getWin = selection => {
|
| - |
|
9653 |
const start = getStart$1(selection);
|
| 9280 |
editor.dispatch('SwitchMode', { mode });
|
9654 |
return defaultView(start);
|
| 9281 |
};
|
9655 |
};
|
| 9282 |
const fireObjectResizeStart = (editor, target, width, height, origin) => {
|
9656 |
const range = SimRange.create;
|
| 9283 |
editor.dispatch('ObjectResizeStart', {
|
9657 |
const SimSelection = {
|
| 9284 |
target,
|
9658 |
domRange,
|
| 9285 |
width,
|
9659 |
relative,
|
| - |
|
9660 |
exact,
|
| 9286 |
height,
|
9661 |
exactFromRange,
|
| 9287 |
origin
|
9662 |
getWin,
|
| 9288 |
});
|
9663 |
range
|
| - |
|
9664 |
};
|
| 9289 |
};
|
9665 |
|
| 9290 |
const fireObjectResized = (editor, target, width, height, origin) => {
|
9666 |
const clamp$1 = (offset, element) => {
|
| 9291 |
editor.dispatch('ObjectResized', {
|
9667 |
const max = isText$c(element) ? get$3(element).length : children$1(element).length + 1;
|
| 9292 |
target,
|
9668 |
if (offset > max) {
|
| 9293 |
width,
|
9669 |
return max;
|
| 9294 |
height,
|
9670 |
} else if (offset < 0) {
|
| 9295 |
origin
|
9671 |
return 0;
|
| - |
|
9672 |
}
|
| 9296 |
});
|
9673 |
return offset;
|
| - |
|
9674 |
};
|
| - |
|
9675 |
const normalizeRng = rng => SimSelection.range(rng.start, clamp$1(rng.soffset, rng.start), rng.finish, clamp$1(rng.foffset, rng.finish));
|
| - |
|
9676 |
const isOrContains = (root, elm) => !isRestrictedNode(elm.dom) && (contains(root, elm) || eq(root, elm));
|
| - |
|
9677 |
const isRngInRoot = root => rng => isOrContains(root, rng.start) && isOrContains(root, rng.finish);
|
| - |
|
9678 |
const shouldStore = editor => editor.inline || Env.browser.isFirefox();
|
| 9297 |
};
|
9679 |
const nativeRangeToSelectionRange = r => SimSelection.range(SugarElement.fromDom(r.startContainer), r.startOffset, SugarElement.fromDom(r.endContainer), r.endOffset);
|
| 9298 |
const firePreInit = editor => {
|
9680 |
const readRange = win => {
|
| - |
|
9681 |
const selection = win.getSelection();
|
| - |
|
9682 |
const rng = !selection || selection.rangeCount === 0 ? Optional.none() : Optional.from(selection.getRangeAt(0));
|
| 9299 |
editor.dispatch('PreInit');
|
9683 |
return rng.map(nativeRangeToSelectionRange);
|
| 9300 |
};
|
9684 |
};
|
| 9301 |
const firePostRender = editor => {
|
9685 |
const getBookmark$1 = root => {
|
| - |
|
9686 |
const win = defaultView(root);
|
| 9302 |
editor.dispatch('PostRender');
|
9687 |
return readRange(win.dom).filter(isRngInRoot(root));
|
| - |
|
9688 |
};
|
| 9303 |
};
|
9689 |
const validate = (root, bookmark) => Optional.from(bookmark).filter(isRngInRoot(root)).map(normalizeRng);
|
| - |
|
9690 |
const bookmarkToNativeRng = bookmark => {
|
| - |
|
9691 |
const rng = document.createRange();
|
| - |
|
9692 |
try {
|
| - |
|
9693 |
rng.setStart(bookmark.start.dom, bookmark.soffset);
|
| - |
|
9694 |
rng.setEnd(bookmark.finish.dom, bookmark.foffset);
|
| - |
|
9695 |
return Optional.some(rng);
|
| 9304 |
const fireInit = editor => {
|
9696 |
} catch (_a) {
|
| - |
|
9697 |
return Optional.none();
|
| 9305 |
editor.dispatch('Init');
|
9698 |
}
|
| 9306 |
};
|
9699 |
};
|
| - |
|
9700 |
const store = editor => {
|
| 9307 |
const firePlaceholderToggle = (editor, state) => {
|
9701 |
const newBookmark = shouldStore(editor) ? getBookmark$1(SugarElement.fromDom(editor.getBody())) : Optional.none();
|
| 9308 |
editor.dispatch('PlaceholderToggle', { state });
|
9702 |
editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;
|
| 9309 |
};
|
9703 |
};
|
| 9310 |
const fireError = (editor, errorType, error) => {
|
9704 |
const getRng = editor => {
|
| - |
|
9705 |
const bookmark = editor.bookmark ? editor.bookmark : Optional.none();
|
| 9311 |
editor.dispatch(errorType, error);
|
9706 |
return bookmark.bind(x => validate(SugarElement.fromDom(editor.getBody()), x)).bind(bookmarkToNativeRng);
|
| - |
|
9707 |
};
|
| - |
|
9708 |
const restore = editor => {
|
| - |
|
9709 |
getRng(editor).each(rng => editor.selection.setRng(rng));
|
| - |
|
9710 |
};
|
| - |
|
9711 |
|
| - |
|
9712 |
const isEditorUIElement$1 = elm => {
|
| - |
|
9713 |
const className = elm.className.toString();
|
| - |
|
9714 |
return className.indexOf('tox-') !== -1 || className.indexOf('mce-') !== -1;
|
| - |
|
9715 |
};
|
| - |
|
9716 |
const FocusManager = { isEditorUIElement: isEditorUIElement$1 };
|
| 9312 |
};
|
9717 |
|
| - |
|
9718 |
const wrappedSetTimeout = (callback, time) => {
|
| - |
|
9719 |
if (!isNumber(time)) {
|
| - |
|
9720 |
time = 0;
|
| - |
|
9721 |
}
|
| - |
|
9722 |
return setTimeout(callback, time);
|
| - |
|
9723 |
};
|
| 9313 |
const fireFormatApply = (editor, format, node, vars) => {
|
9724 |
const wrappedSetInterval = (callback, time) => {
|
| 9314 |
editor.dispatch('FormatApply', {
|
9725 |
if (!isNumber(time)) {
|
| - |
|
9726 |
time = 0;
|
| - |
|
9727 |
}
|
| - |
|
9728 |
return setInterval(callback, time);
|
| - |
|
9729 |
};
|
| - |
|
9730 |
const Delay = {
|
| - |
|
9731 |
setEditorTimeout: (editor, callback, time) => {
|
| - |
|
9732 |
return wrappedSetTimeout(() => {
|
| - |
|
9733 |
if (!editor.removed) {
|
| 9315 |
format,
|
9734 |
callback();
|
| - |
|
9735 |
}
|
| - |
|
9736 |
}, time);
|
| - |
|
9737 |
},
|
| - |
|
9738 |
setEditorInterval: (editor, callback, time) => {
|
| - |
|
9739 |
const timer = wrappedSetInterval(() => {
|
| - |
|
9740 |
if (!editor.removed) {
|
| - |
|
9741 |
callback();
|
| - |
|
9742 |
} else {
|
| 9316 |
node,
|
9743 |
clearInterval(timer);
|
| - |
|
9744 |
}
|
| - |
|
9745 |
}, time);
|
| - |
|
9746 |
return timer;
|
| - |
|
9747 |
}
|
| - |
|
9748 |
};
|
| - |
|
9749 |
|
| - |
|
9750 |
const isManualNodeChange = e => {
|
| - |
|
9751 |
return e.type === 'nodechange' && e.selectionChange;
|
| - |
|
9752 |
};
|
| - |
|
9753 |
const registerPageMouseUp = (editor, throttledStore) => {
|
| - |
|
9754 |
const mouseUpPage = () => {
|
| - |
|
9755 |
throttledStore.throttle();
|
| - |
|
9756 |
};
|
| - |
|
9757 |
DOMUtils.DOM.bind(document, 'mouseup', mouseUpPage);
|
| - |
|
9758 |
editor.on('remove', () => {
|
| 9317 |
vars
|
9759 |
DOMUtils.DOM.unbind(document, 'mouseup', mouseUpPage);
|
| 9318 |
});
|
9760 |
});
|
| 9319 |
};
|
9761 |
};
|
| 9320 |
const fireFormatRemove = (editor, format, node, vars) => {
|
9762 |
const registerMouseUp = (editor, throttledStore) => {
|
| 9321 |
editor.dispatch('FormatRemove', {
|
9763 |
editor.on('mouseup touchend', _e => {
|
| 9322 |
format,
|
- |
|
| 9323 |
node,
|
- |
|
| 9324 |
vars
|
9764 |
throttledStore.throttle();
|
| 9325 |
});
|
9765 |
});
|
| 9326 |
};
|
9766 |
};
|
| 9327 |
const fireBeforeSetContent = (editor, args) => editor.dispatch('BeforeSetContent', args);
|
9767 |
const registerEditorEvents = (editor, throttledStore) => {
|
| 9328 |
const fireSetContent = (editor, args) => editor.dispatch('SetContent', args);
|
9768 |
registerMouseUp(editor, throttledStore);
|
| 9329 |
const fireBeforeGetContent = (editor, args) => editor.dispatch('BeforeGetContent', args);
|
9769 |
editor.on('keyup NodeChange AfterSetSelectionRange', e => {
|
| 9330 |
const fireGetContent = (editor, args) => editor.dispatch('GetContent', args);
|
9770 |
if (!isManualNodeChange(e)) {
|
| - |
|
9771 |
store(editor);
|
| 9331 |
const fireAutocompleterStart = (editor, args) => {
|
9772 |
}
|
| 9332 |
editor.dispatch('AutocompleterStart', args);
|
9773 |
});
|
| 9333 |
};
|
9774 |
};
|
| - |
|
9775 |
const register$6 = editor => {
|
| - |
|
9776 |
const throttledStore = first$1(() => {
|
| - |
|
9777 |
store(editor);
|
| - |
|
9778 |
}, 0);
|
| - |
|
9779 |
editor.on('init', () => {
|
| - |
|
9780 |
if (editor.inline) {
|
| - |
|
9781 |
registerPageMouseUp(editor, throttledStore);
|
| 9334 |
const fireAutocompleterUpdate = (editor, args) => {
|
9782 |
}
|
| - |
|
9783 |
registerEditorEvents(editor, throttledStore);
|
| - |
|
9784 |
});
|
| - |
|
9785 |
editor.on('remove', () => {
|
| - |
|
9786 |
throttledStore.cancel();
|
| 9335 |
editor.dispatch('AutocompleterUpdate', args);
|
9787 |
});
|
| - |
|
9788 |
};
|
| - |
|
9789 |
|
| - |
|
9790 |
let documentFocusInHandler;
|
| 9336 |
};
|
9791 |
const DOM$9 = DOMUtils.DOM;
|
| 9337 |
const fireAutocompleterEnd = editor => {
|
9792 |
const isEditorUIElement = elm => {
|
| 9338 |
editor.dispatch('AutocompleterEnd');
|
9793 |
return isElement$6(elm) && FocusManager.isEditorUIElement(elm);
|
| - |
|
9794 |
};
|
| - |
|
9795 |
const isEditorContentAreaElement = elm => {
|
| - |
|
9796 |
const classList = elm.classList;
|
| - |
|
9797 |
if (classList !== undefined) {
|
| - |
|
9798 |
return classList.contains('tox-edit-area') || classList.contains('tox-edit-area__iframe') || classList.contains('mce-content-body');
|
| - |
|
9799 |
} else {
|
| - |
|
9800 |
return false;
|
| - |
|
9801 |
}
|
| - |
|
9802 |
};
|
| - |
|
9803 |
const isUIElement = (editor, elm) => {
|
| - |
|
9804 |
const customSelector = getCustomUiSelector(editor);
|
| 9339 |
};
|
9805 |
const parent = DOM$9.getParent(elm, elm => {
|
| - |
|
9806 |
return isEditorUIElement(elm) || (customSelector ? editor.dom.is(elm, customSelector) : false);
|
| 9340 |
const firePastePreProcess = (editor, html, internal) => editor.dispatch('PastePreProcess', {
|
9807 |
});
|
| - |
|
9808 |
return parent !== null;
|
| - |
|
9809 |
};
|
| 9341 |
content: html,
|
9810 |
const getActiveElement = editor => {
|
| - |
|
9811 |
try {
|
| - |
|
9812 |
const root = getRootNode(SugarElement.fromDom(editor.getElement()));
|
| - |
|
9813 |
return active$1(root).fold(() => document.body, x => x.dom);
|
| - |
|
9814 |
} catch (_a) {
|
| - |
|
9815 |
return document.body;
|
| 9342 |
internal
|
9816 |
}
|
| - |
|
9817 |
};
|
| - |
|
9818 |
const registerEvents$1 = (editorManager, e) => {
|
| - |
|
9819 |
const editor = e.editor;
|
| - |
|
9820 |
register$6(editor);
|
| - |
|
9821 |
const toggleContentAreaOnFocus = (editor, fn) => {
|
| - |
|
9822 |
if (shouldHighlightOnFocus(editor) && editor.inline !== true) {
|
| - |
|
9823 |
const contentArea = SugarElement.fromDom(editor.getContainer());
|
| - |
|
9824 |
fn(contentArea, 'tox-edit-focus');
|
| - |
|
9825 |
}
|
| - |
|
9826 |
};
|
| - |
|
9827 |
editor.on('focusin', () => {
|
| - |
|
9828 |
const focusedEditor = editorManager.focusedEditor;
|
| - |
|
9829 |
if (isEditorContentAreaElement(getActiveElement(editor))) {
|
| - |
|
9830 |
toggleContentAreaOnFocus(editor, add$2);
|
| - |
|
9831 |
}
|
| - |
|
9832 |
if (focusedEditor !== editor) {
|
| - |
|
9833 |
if (focusedEditor) {
|
| - |
|
9834 |
focusedEditor.dispatch('blur', { focusedEditor: editor });
|
| - |
|
9835 |
}
|
| - |
|
9836 |
editorManager.setActive(editor);
|
| - |
|
9837 |
editorManager.focusedEditor = editor;
|
| - |
|
9838 |
editor.dispatch('focus', { blurredEditor: focusedEditor });
|
| - |
|
9839 |
editor.focus(true);
|
| - |
|
9840 |
}
|
| - |
|
9841 |
});
|
| - |
|
9842 |
editor.on('focusout', () => {
|
| - |
|
9843 |
Delay.setEditorTimeout(editor, () => {
|
| - |
|
9844 |
const focusedEditor = editorManager.focusedEditor;
|
| - |
|
9845 |
if (!isEditorContentAreaElement(getActiveElement(editor)) || focusedEditor !== editor) {
|
| - |
|
9846 |
toggleContentAreaOnFocus(editor, remove$6);
|
| 9343 |
});
|
9847 |
}
|
| - |
|
9848 |
if (!isUIElement(editor, getActiveElement(editor)) && focusedEditor === editor) {
|
| - |
|
9849 |
editor.dispatch('blur', { focusedEditor: null });
|
| - |
|
9850 |
editorManager.focusedEditor = null;
|
| - |
|
9851 |
}
|
| - |
|
9852 |
});
|
| - |
|
9853 |
});
|
| - |
|
9854 |
if (!documentFocusInHandler) {
|
| - |
|
9855 |
documentFocusInHandler = e => {
|
| - |
|
9856 |
const activeEditor = editorManager.activeEditor;
|
| - |
|
9857 |
if (activeEditor) {
|
| - |
|
9858 |
getOriginalEventTarget(e).each(target => {
|
| - |
|
9859 |
const elem = target;
|
| - |
|
9860 |
if (elem.ownerDocument === document) {
|
| - |
|
9861 |
if (elem !== document.body && !isUIElement(activeEditor, elem) && editorManager.focusedEditor === activeEditor) {
|
| - |
|
9862 |
activeEditor.dispatch('blur', { focusedEditor: null });
|
| - |
|
9863 |
editorManager.focusedEditor = null;
|
| - |
|
9864 |
}
|
| - |
|
9865 |
}
|
| 9344 |
const firePastePostProcess = (editor, node, internal) => editor.dispatch('PastePostProcess', {
|
9866 |
});
|
| - |
|
9867 |
}
|
| - |
|
9868 |
};
|
| - |
|
9869 |
DOM$9.bind(document, 'focusin', documentFocusInHandler);
|
| - |
|
9870 |
}
|
| - |
|
9871 |
};
|
| - |
|
9872 |
const unregisterDocumentEvents = (editorManager, e) => {
|
| - |
|
9873 |
if (editorManager.focusedEditor === e.editor) {
|
| - |
|
9874 |
editorManager.focusedEditor = null;
|
| - |
|
9875 |
}
|
| - |
|
9876 |
if (!editorManager.activeEditor && documentFocusInHandler) {
|
| - |
|
9877 |
DOM$9.unbind(document, 'focusin', documentFocusInHandler);
|
| - |
|
9878 |
documentFocusInHandler = null;
|
| - |
|
9879 |
}
|
| - |
|
9880 |
};
|
| - |
|
9881 |
const setup$w = editorManager => {
|
| - |
|
9882 |
editorManager.on('AddEditor', curry(registerEvents$1, editorManager));
|
| - |
|
9883 |
editorManager.on('RemoveEditor', curry(unregisterDocumentEvents, editorManager));
|
| - |
|
9884 |
};
|
| - |
|
9885 |
|
| - |
|
9886 |
const getContentEditableHost = (editor, node) => editor.dom.getParent(node, node => editor.dom.getContentEditable(node) === 'true');
|
| - |
|
9887 |
const hasContentEditableFalseParent$1 = (editor, node) => editor.dom.getParent(node, node => editor.dom.getContentEditable(node) === 'false') !== null;
|
| - |
|
9888 |
const getCollapsedNode = rng => rng.collapsed ? Optional.from(getNode$1(rng.startContainer, rng.startOffset)).map(SugarElement.fromDom) : Optional.none();
|
| - |
|
9889 |
const getFocusInElement = (root, rng) => getCollapsedNode(rng).bind(node => {
|
| - |
|
9890 |
if (isTableSection(node)) {
|
| - |
|
9891 |
return Optional.some(node);
|
| - |
|
9892 |
} else if (!contains(root, node)) {
|
| 9345 |
node,
|
9893 |
return Optional.some(root);
|
| - |
|
9894 |
} else {
|
| - |
|
9895 |
return Optional.none();
|
| 9346 |
internal
|
9896 |
}
|
| - |
|
9897 |
});
|
| - |
|
9898 |
const normalizeSelection = (editor, rng) => {
|
| - |
|
9899 |
getFocusInElement(SugarElement.fromDom(editor.getBody()), rng).bind(elm => {
|
| - |
|
9900 |
return firstPositionIn(elm.dom);
|
| - |
|
9901 |
}).fold(() => {
|
| - |
|
9902 |
editor.selection.normalize();
|
| - |
|
9903 |
}, caretPos => editor.selection.setRng(caretPos.toRange()));
|
| - |
|
9904 |
};
|
| - |
|
9905 |
const focusBody = body => {
|
| - |
|
9906 |
if (body.setActive) {
|
| - |
|
9907 |
try {
|
| - |
|
9908 |
body.setActive();
|
| - |
|
9909 |
} catch (_a) {
|
| - |
|
9910 |
body.focus();
|
| - |
|
9911 |
}
|
| - |
|
9912 |
} else {
|
| - |
|
9913 |
body.focus();
|
| - |
|
9914 |
}
|
| - |
|
9915 |
};
|
| - |
|
9916 |
const hasElementFocus = elm => hasFocus$1(elm) || search(elm).isSome();
|
| - |
|
9917 |
const hasIframeFocus = editor => isNonNullable(editor.iframeElement) && hasFocus$1(SugarElement.fromDom(editor.iframeElement));
|
| - |
|
9918 |
const hasInlineFocus = editor => {
|
| - |
|
9919 |
const rawBody = editor.getBody();
|
| - |
|
9920 |
return rawBody && hasElementFocus(SugarElement.fromDom(rawBody));
|
| - |
|
9921 |
};
|
| - |
|
9922 |
const hasUiFocus = editor => {
|
| - |
|
9923 |
const dos = getRootNode(SugarElement.fromDom(editor.getElement()));
|
| - |
|
9924 |
return active$1(dos).filter(elem => !isEditorContentAreaElement(elem.dom) && isUIElement(editor, elem.dom)).isSome();
|
| 9347 |
});
|
9925 |
};
|
| - |
|
9926 |
const hasFocus = editor => editor.inline ? hasInlineFocus(editor) : hasIframeFocus(editor);
|
| - |
|
9927 |
const hasEditorOrUiFocus = editor => hasFocus(editor) || hasUiFocus(editor);
|
| - |
|
9928 |
const focusEditor = editor => {
|
| - |
|
9929 |
const selection = editor.selection;
|
| - |
|
9930 |
const body = editor.getBody();
|
| - |
|
9931 |
let rng = selection.getRng();
|
| - |
|
9932 |
editor.quirks.refreshContentEditable();
|
| - |
|
9933 |
const restoreBookmark = editor => {
|
| - |
|
9934 |
getRng(editor).each(bookmarkRng => {
|
| - |
|
9935 |
editor.selection.setRng(bookmarkRng);
|
| - |
|
9936 |
rng = bookmarkRng;
|
| - |
|
9937 |
});
|
| - |
|
9938 |
};
|
| - |
|
9939 |
if (!hasFocus(editor) && editor.hasEditableRoot()) {
|
| - |
|
9940 |
restoreBookmark(editor);
|
| - |
|
9941 |
}
|
| - |
|
9942 |
const contentEditableHost = getContentEditableHost(editor, selection.getNode());
|
| - |
|
9943 |
if (contentEditableHost && editor.dom.isChildOf(contentEditableHost, body)) {
|
| - |
|
9944 |
if (!hasContentEditableFalseParent$1(editor, contentEditableHost)) {
|
| - |
|
9945 |
focusBody(body);
|
| - |
|
9946 |
}
|
| - |
|
9947 |
focusBody(contentEditableHost);
|
| - |
|
9948 |
if (!editor.hasEditableRoot()) {
|
| - |
|
9949 |
restoreBookmark(editor);
|
| - |
|
9950 |
}
|
| - |
|
9951 |
normalizeSelection(editor, rng);
|
| - |
|
9952 |
activateEditor(editor);
|
| - |
|
9953 |
return;
|
| - |
|
9954 |
}
|
| - |
|
9955 |
if (!editor.inline) {
|
| - |
|
9956 |
if (!Env.browser.isOpera()) {
|
| - |
|
9957 |
focusBody(body);
|
| - |
|
9958 |
}
|
| - |
|
9959 |
editor.getWin().focus();
|
| - |
|
9960 |
}
|
| - |
|
9961 |
if (Env.browser.isFirefox() || editor.inline) {
|
| - |
|
9962 |
focusBody(body);
|
| - |
|
9963 |
normalizeSelection(editor, rng);
|
| - |
|
9964 |
}
|
| - |
|
9965 |
activateEditor(editor);
|
| 9348 |
const firePastePlainTextToggle = (editor, state) => editor.dispatch('PastePlainTextToggle', { state });
|
9966 |
};
|
| - |
|
9967 |
const activateEditor = editor => editor.editorManager.setActive(editor);
|
| - |
|
9968 |
const focus = (editor, skipFocus) => {
|
| - |
|
9969 |
if (editor.removed) {
|
| - |
|
9970 |
return;
|
| - |
|
9971 |
}
|
| - |
|
9972 |
if (skipFocus) {
|
| - |
|
9973 |
activateEditor(editor);
|
| - |
|
9974 |
} else {
|
| - |
|
9975 |
focusEditor(editor);
|
| - |
|
9976 |
}
|
| Línea 9349... |
Línea 9977... |
| 9349 |
const fireEditableRootStateChange = (editor, state) => editor.dispatch('EditableRootStateChange', { state });
|
9977 |
};
|
| 9350 |
|
9978 |
|
| 9351 |
const VK = {
|
9979 |
const VK = {
|
| 9352 |
BACKSPACE: 8,
|
9980 |
BACKSPACE: 8,
|
| Línea 9406... |
Línea 10034... |
| 9406 |
const dom = editor.dom;
|
10034 |
const dom = editor.dom;
|
| 9407 |
const editableDoc = editor.getDoc();
|
10035 |
const editableDoc = editor.getDoc();
|
| 9408 |
const rootDocument = document;
|
10036 |
const rootDocument = document;
|
| 9409 |
const rootElement = editor.getBody();
|
10037 |
const rootElement = editor.getBody();
|
| 9410 |
let selectedElm, selectedElmGhost, resizeHelper, selectedHandle, resizeBackdrop;
|
10038 |
let selectedElm, selectedElmGhost, resizeHelper, selectedHandle, resizeBackdrop;
|
| 9411 |
let startX, startY, selectedElmX, selectedElmY, startW, startH, ratio, resizeStarted;
|
10039 |
let startX, startY, startW, startH, ratio, resizeStarted;
|
| 9412 |
let width;
|
10040 |
let width;
|
| 9413 |
let height;
|
10041 |
let height;
|
| 9414 |
let startScrollWidth;
|
10042 |
let startScrollWidth;
|
| 9415 |
let startScrollHeight;
|
10043 |
let startScrollHeight;
|
| 9416 |
const isImage = elm => isNonNullable(elm) && (isImg(elm) || dom.is(elm, 'figure.image'));
|
10044 |
const isImage = elm => isNonNullable(elm) && (isImg(elm) || dom.is(elm, 'figure.image'));
|
| Línea 9441... |
Línea 10069... |
| 9441 |
return [elm];
|
10069 |
return [elm];
|
| 9442 |
}
|
10070 |
}
|
| 9443 |
};
|
10071 |
};
|
| 9444 |
const isResizable = elm => {
|
10072 |
const isResizable = elm => {
|
| 9445 |
const selector = getObjectResizing(editor);
|
10073 |
const selector = getObjectResizing(editor);
|
| 9446 |
if (!selector) {
|
10074 |
if (!selector || editor.mode.isReadOnly()) {
|
| 9447 |
return false;
|
10075 |
return false;
|
| 9448 |
}
|
10076 |
}
|
| 9449 |
if (elm.getAttribute('data-mce-resize') === 'false') {
|
10077 |
if (elm.getAttribute('data-mce-resize') === 'false') {
|
| 9450 |
return false;
|
10078 |
return false;
|
| 9451 |
}
|
10079 |
}
|
| Línea 9456... |
Línea 10084... |
| 9456 |
return is$1(SugarElement.fromDom(elm.firstElementChild), selector);
|
10084 |
return is$1(SugarElement.fromDom(elm.firstElementChild), selector);
|
| 9457 |
} else {
|
10085 |
} else {
|
| 9458 |
return is$1(SugarElement.fromDom(elm), selector);
|
10086 |
return is$1(SugarElement.fromDom(elm), selector);
|
| 9459 |
}
|
10087 |
}
|
| 9460 |
};
|
10088 |
};
|
| 9461 |
const createGhostElement = elm => {
|
10089 |
const createGhostElement = (dom, elm) => {
|
| 9462 |
if (isMedia(elm)) {
|
10090 |
if (isMedia(elm)) {
|
| 9463 |
return dom.create('img', { src: Env.transparentSrc });
|
10091 |
return dom.create('img', { src: Env.transparentSrc });
|
| - |
|
10092 |
} else if (isTable$2(elm)) {
|
| - |
|
10093 |
const isNorth = startsWith(selectedHandle.name, 'n');
|
| - |
|
10094 |
const rowSelect = isNorth ? head : last$2;
|
| - |
|
10095 |
const tableElm = elm.cloneNode(true);
|
| - |
|
10096 |
rowSelect(dom.select('tr', tableElm)).each(tr => {
|
| - |
|
10097 |
const cells = dom.select('td,th', tr);
|
| - |
|
10098 |
dom.setStyle(tr, 'height', null);
|
| - |
|
10099 |
each$e(cells, cell => dom.setStyle(cell, 'height', null));
|
| - |
|
10100 |
});
|
| - |
|
10101 |
return tableElm;
|
| 9464 |
} else {
|
10102 |
} else {
|
| 9465 |
return elm.cloneNode(true);
|
10103 |
return elm.cloneNode(true);
|
| 9466 |
}
|
10104 |
}
|
| 9467 |
};
|
10105 |
};
|
| 9468 |
const setSizeProp = (element, name, value) => {
|
10106 |
const setSizeProp = (element, name, value) => {
|
| Línea 9513... |
Línea 10151... |
| 9513 |
left: resizeHelperX,
|
10151 |
left: resizeHelperX,
|
| 9514 |
top: resizeHelperY,
|
10152 |
top: resizeHelperY,
|
| 9515 |
display: 'block'
|
10153 |
display: 'block'
|
| 9516 |
});
|
10154 |
});
|
| 9517 |
resizeHelper.innerHTML = width + ' × ' + height;
|
10155 |
resizeHelper.innerHTML = width + ' × ' + height;
|
| 9518 |
if (selectedHandle[2] < 0 && selectedElmGhost.clientWidth <= width) {
|
- |
|
| 9519 |
dom.setStyle(selectedElmGhost, 'left', selectedElmX + (startW - width));
|
- |
|
| 9520 |
}
|
- |
|
| 9521 |
if (selectedHandle[3] < 0 && selectedElmGhost.clientHeight <= height) {
|
- |
|
| 9522 |
dom.setStyle(selectedElmGhost, 'top', selectedElmY + (startH - height));
|
- |
|
| 9523 |
}
|
- |
|
| 9524 |
deltaX = rootElement.scrollWidth - startScrollWidth;
|
10156 |
deltaX = rootElement.scrollWidth - startScrollWidth;
|
| 9525 |
deltaY = rootElement.scrollHeight - startScrollHeight;
|
10157 |
deltaY = rootElement.scrollHeight - startScrollHeight;
|
| 9526 |
if (deltaX + deltaY !== 0) {
|
10158 |
if (deltaX + deltaY !== 0) {
|
| 9527 |
dom.setStyles(resizeHelper, {
|
10159 |
dom.setStyles(resizeHelper, {
|
| 9528 |
left: resizeHelperX - deltaX,
|
10160 |
left: resizeHelperX - deltaX,
|
| Línea 9597... |
Línea 10229... |
| 9597 |
left: '0',
|
10229 |
left: '0',
|
| 9598 |
top: '0',
|
10230 |
top: '0',
|
| 9599 |
width: '100%',
|
10231 |
width: '100%',
|
| 9600 |
height: '100%'
|
10232 |
height: '100%'
|
| 9601 |
});
|
10233 |
});
|
| 9602 |
selectedElmGhost = createGhostElement(selectedElm);
|
10234 |
selectedElmGhost = createGhostElement(dom, selectedElm);
|
| 9603 |
dom.addClass(selectedElmGhost, 'mce-clonedresizable');
|
10235 |
dom.addClass(selectedElmGhost, 'mce-clonedresizable');
|
| 9604 |
dom.setAttrib(selectedElmGhost, 'data-mce-bogus', 'all');
|
10236 |
dom.setAttrib(selectedElmGhost, 'data-mce-bogus', 'all');
|
| 9605 |
selectedElmGhost.contentEditable = 'false';
|
10237 |
selectedElmGhost.contentEditable = 'false';
|
| 9606 |
dom.setStyles(selectedElmGhost, {
|
10238 |
dom.setStyles(selectedElmGhost, {
|
| 9607 |
left: selectedElmX,
|
10239 |
left: selectedElmX,
|
| Línea 9672... |
Línea 10304... |
| 9672 |
const controlElm = closest$3(SugarElement.fromDom(targetElm), controlElmSelector).map(e => e.dom).filter(e => dom.isEditable(e.parentElement) || e.nodeName === 'IMG' && dom.isEditable(e)).getOrUndefined();
|
10304 |
const controlElm = closest$3(SugarElement.fromDom(targetElm), controlElmSelector).map(e => e.dom).filter(e => dom.isEditable(e.parentElement) || e.nodeName === 'IMG' && dom.isEditable(e)).getOrUndefined();
|
| 9673 |
const selectedValue = isNonNullable(controlElm) ? dom.getAttrib(controlElm, elementSelectionAttr, '1') : '1';
|
10305 |
const selectedValue = isNonNullable(controlElm) ? dom.getAttrib(controlElm, elementSelectionAttr, '1') : '1';
|
| 9674 |
each$e(dom.select(`img[${ elementSelectionAttr }],hr[${ elementSelectionAttr }]`), img => {
|
10306 |
each$e(dom.select(`img[${ elementSelectionAttr }],hr[${ elementSelectionAttr }]`), img => {
|
| 9675 |
img.removeAttribute(elementSelectionAttr);
|
10307 |
img.removeAttribute(elementSelectionAttr);
|
| 9676 |
});
|
10308 |
});
|
| 9677 |
if (isNonNullable(controlElm) && isChildOrEqual(controlElm, rootElement) && editor.hasFocus()) {
|
10309 |
if (isNonNullable(controlElm) && isChildOrEqual(controlElm, rootElement) && hasEditorOrUiFocus(editor)) {
|
| 9678 |
disableGeckoResize();
|
10310 |
disableGeckoResize();
|
| 9679 |
const startElm = selection.getStart(true);
|
10311 |
const startElm = selection.getStart(true);
|
| 9680 |
if (isChildOrEqual(startElm, controlElm) && isChildOrEqual(selection.getEnd(true), controlElm)) {
|
10312 |
if (isChildOrEqual(startElm, controlElm) && isChildOrEqual(selection.getEnd(true), controlElm)) {
|
| 9681 |
dom.setAttrib(controlElm, elementSelectionAttr, selectedValue);
|
10313 |
dom.setAttrib(controlElm, elementSelectionAttr, selectedValue);
|
| 9682 |
throttledShowResizeRect.throttle(controlElm);
|
10314 |
throttledShowResizeRect.throttle(controlElm);
|
| Línea 9694... |
Línea 10326... |
| 9694 |
});
|
10326 |
});
|
| 9695 |
};
|
10327 |
};
|
| 9696 |
const disableGeckoResize = () => {
|
10328 |
const disableGeckoResize = () => {
|
| 9697 |
try {
|
10329 |
try {
|
| 9698 |
editor.getDoc().execCommand('enableObjectResizing', false, 'false');
|
10330 |
editor.getDoc().execCommand('enableObjectResizing', false, 'false');
|
| 9699 |
} catch (ex) {
|
10331 |
} catch (_a) {
|
| 9700 |
}
|
10332 |
}
|
| 9701 |
};
|
10333 |
};
|
| 9702 |
editor.on('init', () => {
|
10334 |
editor.on('init', () => {
|
| 9703 |
disableGeckoResize();
|
10335 |
disableGeckoResize();
|
| 9704 |
editor.on('NodeChange ResizeEditor ResizeWindow ResizeContent drop', updateResizeRect);
|
10336 |
editor.on('NodeChange ResizeEditor ResizeWindow ResizeContent drop', updateResizeRect);
|
| Línea 9753... |
Línea 10385... |
| 9753 |
rng.setStart(start.dom, soffset);
|
10385 |
rng.setStart(start.dom, soffset);
|
| 9754 |
rng.setEnd(finish.dom, foffset);
|
10386 |
rng.setEnd(finish.dom, foffset);
|
| 9755 |
return rng;
|
10387 |
return rng;
|
| 9756 |
};
|
10388 |
};
|
| Línea 9757... |
Línea 10389... |
| 9757 |
|
10389 |
|
| 9758 |
const adt$3 = Adt.generate([
|
10390 |
const adt$1 = Adt.generate([
|
| 9759 |
{
|
10391 |
{
|
| 9760 |
ltr: [
|
10392 |
ltr: [
|
| 9761 |
'start',
|
10393 |
'start',
|
| 9762 |
'soffset',
|
10394 |
'soffset',
|
| Línea 9796... |
Línea 10428... |
| 9796 |
});
|
10428 |
});
|
| 9797 |
const doDiagnose = (win, ranges) => {
|
10429 |
const doDiagnose = (win, ranges) => {
|
| 9798 |
const rng = ranges.ltr();
|
10430 |
const rng = ranges.ltr();
|
| 9799 |
if (rng.collapsed) {
|
10431 |
if (rng.collapsed) {
|
| 9800 |
const reversed = ranges.rtl().filter(rev => rev.collapsed === false);
|
10432 |
const reversed = ranges.rtl().filter(rev => rev.collapsed === false);
|
| 9801 |
return reversed.map(rev => adt$3.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset)).getOrThunk(() => fromRange(win, adt$3.ltr, rng));
|
10433 |
return reversed.map(rev => adt$1.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset)).getOrThunk(() => fromRange(win, adt$1.ltr, rng));
|
| 9802 |
} else {
|
10434 |
} else {
|
| 9803 |
return fromRange(win, adt$3.ltr, rng);
|
10435 |
return fromRange(win, adt$1.ltr, rng);
|
| 9804 |
}
|
10436 |
}
|
| 9805 |
};
|
10437 |
};
|
| 9806 |
const diagnose = (win, selection) => {
|
10438 |
const diagnose = (win, selection) => {
|
| 9807 |
const ranges = getRanges(win, selection);
|
10439 |
const ranges = getRanges(win, selection);
|
| 9808 |
return doDiagnose(win, ranges);
|
10440 |
return doDiagnose(win, ranges);
|
| 9809 |
};
|
10441 |
};
|
| 9810 |
adt$3.ltr;
|
10442 |
adt$1.ltr;
|
| 9811 |
adt$3.rtl;
|
10443 |
adt$1.rtl;
|
| 9812 |
|
- |
|
| 9813 |
const create$a = (start, soffset, finish, foffset) => ({
|
- |
|
| 9814 |
start,
|
- |
|
| 9815 |
soffset,
|
- |
|
| 9816 |
finish,
|
- |
|
| 9817 |
foffset
|
- |
|
| 9818 |
});
|
- |
|
| 9819 |
const SimRange = { create: create$a };
|
- |
|
| Línea 9820... |
Línea 10444... |
| 9820 |
|
10444 |
|
| 9821 |
const caretPositionFromPoint = (doc, x, y) => {
|
10445 |
const caretPositionFromPoint = (doc, x, y) => {
|
| 9822 |
var _a, _b;
|
10446 |
var _a;
|
| 9823 |
return Optional.from((_b = (_a = doc.dom).caretPositionFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y)).bind(pos => {
|
10447 |
return Optional.from((_a = doc.caretPositionFromPoint) === null || _a === void 0 ? void 0 : _a.call(doc, x, y)).bind(pos => {
|
| 9824 |
if (pos.offsetNode === null) {
|
10448 |
if (pos.offsetNode === null) {
|
| 9825 |
return Optional.none();
|
10449 |
return Optional.none();
|
| 9826 |
}
|
10450 |
}
|
| 9827 |
const r = doc.dom.createRange();
|
10451 |
const r = doc.createRange();
|
| 9828 |
r.setStart(pos.offsetNode, pos.offset);
|
10452 |
r.setStart(pos.offsetNode, pos.offset);
|
| 9829 |
r.collapse();
|
10453 |
r.collapse();
|
| 9830 |
return Optional.some(r);
|
10454 |
return Optional.some(r);
|
| 9831 |
});
|
10455 |
});
|
| 9832 |
};
|
10456 |
};
|
| 9833 |
const caretRangeFromPoint = (doc, x, y) => {
|
10457 |
const caretRangeFromPoint = (doc, x, y) => {
|
| 9834 |
var _a, _b;
|
10458 |
var _a;
|
| 9835 |
return Optional.from((_b = (_a = doc.dom).caretRangeFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y));
|
10459 |
return Optional.from((_a = doc.caretRangeFromPoint) === null || _a === void 0 ? void 0 : _a.call(doc, x, y));
|
| 9836 |
};
|
10460 |
};
|
| 9837 |
const availableSearch = (() => {
|
10461 |
const availableSearch = (doc, x, y) => {
|
| 9838 |
if (document.caretPositionFromPoint) {
|
10462 |
if (doc.caretPositionFromPoint) {
|
| 9839 |
return caretPositionFromPoint;
|
10463 |
return caretPositionFromPoint(doc, x, y);
|
| 9840 |
} else if (document.caretRangeFromPoint) {
|
10464 |
} else if (doc.caretRangeFromPoint) {
|
| 9841 |
return caretRangeFromPoint;
|
10465 |
return caretRangeFromPoint(doc, x, y);
|
| 9842 |
} else {
|
10466 |
} else {
|
| 9843 |
return Optional.none;
|
10467 |
return Optional.none();
|
| 9844 |
}
|
10468 |
}
|
| 9845 |
})();
|
10469 |
};
|
| 9846 |
const fromPoint$1 = (win, x, y) => {
|
10470 |
const fromPoint$1 = (win, x, y) => {
|
| 9847 |
const doc = SugarElement.fromDom(win.document);
|
10471 |
const doc = win.document;
|
| 9848 |
return availableSearch(doc, x, y).map(rng => SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset));
|
10472 |
return availableSearch(doc, x, y).map(rng => SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset));
|
| Línea 9849... |
Línea -... |
| 9849 |
};
|
- |
|
| 9850 |
|
- |
|
| 9851 |
const adt$2 = Adt.generate([
|
- |
|
| 9852 |
{ before: ['element'] },
|
- |
|
| 9853 |
{
|
- |
|
| 9854 |
on: [
|
- |
|
| 9855 |
'element',
|
- |
|
| 9856 |
'offset'
|
- |
|
| 9857 |
]
|
- |
|
| 9858 |
},
|
- |
|
| 9859 |
{ after: ['element'] }
|
- |
|
| 9860 |
]);
|
- |
|
| 9861 |
const cata = (subject, onBefore, onOn, onAfter) => subject.fold(onBefore, onOn, onAfter);
|
- |
|
| 9862 |
const getStart$2 = situ => situ.fold(identity, identity, identity);
|
- |
|
| 9863 |
const before$1 = adt$2.before;
|
- |
|
| 9864 |
const on = adt$2.on;
|
- |
|
| 9865 |
const after$1 = adt$2.after;
|
- |
|
| 9866 |
const Situ = {
|
- |
|
| 9867 |
before: before$1,
|
- |
|
| 9868 |
on,
|
- |
|
| 9869 |
after: after$1,
|
- |
|
| 9870 |
cata,
|
- |
|
| 9871 |
getStart: getStart$2
|
- |
|
| 9872 |
};
|
- |
|
| 9873 |
|
- |
|
| 9874 |
const adt$1 = Adt.generate([
|
- |
|
| 9875 |
{ domRange: ['rng'] },
|
- |
|
| 9876 |
{
|
- |
|
| 9877 |
relative: [
|
- |
|
| 9878 |
'startSitu',
|
- |
|
| 9879 |
'finishSitu'
|
- |
|
| 9880 |
]
|
- |
|
| 9881 |
},
|
- |
|
| 9882 |
{
|
- |
|
| 9883 |
exact: [
|
- |
|
| 9884 |
'start',
|
- |
|
| 9885 |
'soffset',
|
- |
|
| 9886 |
'finish',
|
- |
|
| 9887 |
'foffset'
|
- |
|
| 9888 |
]
|
- |
|
| 9889 |
}
|
- |
|
| 9890 |
]);
|
- |
|
| 9891 |
const exactFromRange = simRange => adt$1.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);
|
- |
|
| 9892 |
const getStart$1 = selection => selection.match({
|
- |
|
| 9893 |
domRange: rng => SugarElement.fromDom(rng.startContainer),
|
- |
|
| 9894 |
relative: (startSitu, _finishSitu) => Situ.getStart(startSitu),
|
- |
|
| 9895 |
exact: (start, _soffset, _finish, _foffset) => start
|
- |
|
| 9896 |
});
|
- |
|
| 9897 |
const domRange = adt$1.domRange;
|
- |
|
| 9898 |
const relative = adt$1.relative;
|
- |
|
| 9899 |
const exact = adt$1.exact;
|
- |
|
| 9900 |
const getWin = selection => {
|
- |
|
| 9901 |
const start = getStart$1(selection);
|
- |
|
| 9902 |
return defaultView(start);
|
- |
|
| 9903 |
};
|
- |
|
| 9904 |
const range = SimRange.create;
|
- |
|
| 9905 |
const SimSelection = {
|
- |
|
| 9906 |
domRange,
|
- |
|
| 9907 |
relative,
|
- |
|
| 9908 |
exact,
|
- |
|
| 9909 |
exactFromRange,
|
- |
|
| 9910 |
getWin,
|
- |
|
| 9911 |
range
|
- |
|
| 9912 |
};
|
10473 |
};
|
| 9913 |
|
10474 |
|
| 9914 |
const beforeSpecial = (element, offset) => {
|
10475 |
const beforeSpecial = (element, offset) => {
|
| 9915 |
const name$1 = name(element);
|
10476 |
const name$1 = name(element);
|
| 9916 |
if ('input' === name$1) {
|
10477 |
if ('input' === name$1) {
|
| Línea 10034... |
Línea 10595... |
| 10034 |
const walker = new DomTreeWalker(startNode, parentBlockContainer);
|
10595 |
const walker = new DomTreeWalker(startNode, parentBlockContainer);
|
| 10035 |
while (node = walker[left ? 'prev' : 'next']()) {
|
10596 |
while (node = walker[left ? 'prev' : 'next']()) {
|
| 10036 |
if (dom.getContentEditableParent(node) === 'false' || isCeFalseCaretContainer(node, body)) {
|
10597 |
if (dom.getContentEditableParent(node) === 'false' || isCeFalseCaretContainer(node, body)) {
|
| 10037 |
return Optional.none();
|
10598 |
return Optional.none();
|
| 10038 |
}
|
10599 |
}
|
| 10039 |
if (isText$a(node) && node.data.length > 0) {
|
10600 |
if (isText$b(node) && node.data.length > 0) {
|
| 10040 |
if (!hasParentWithName(node, body, 'A')) {
|
10601 |
if (!hasParentWithName(node, body, 'A')) {
|
| 10041 |
return Optional.some(CaretPosition(node, left ? node.data.length : 0));
|
10602 |
return Optional.some(CaretPosition(node, left ? node.data.length : 0));
|
| 10042 |
}
|
10603 |
}
|
| 10043 |
return Optional.none();
|
10604 |
return Optional.none();
|
| 10044 |
}
|
10605 |
}
|
| Línea 10087... |
Línea 10648... |
| 10087 |
}
|
10648 |
}
|
| 10088 |
}
|
10649 |
}
|
| 10089 |
if (container.hasChildNodes()) {
|
10650 |
if (container.hasChildNodes()) {
|
| 10090 |
offset = Math.min(!directionLeft && offset > 0 ? offset - 1 : offset, container.childNodes.length - 1);
|
10651 |
offset = Math.min(!directionLeft && offset > 0 ? offset - 1 : offset, container.childNodes.length - 1);
|
| 10091 |
container = container.childNodes[offset];
|
10652 |
container = container.childNodes[offset];
|
| 10092 |
offset = isText$a(container) && isAfterNode ? container.data.length : 0;
|
10653 |
offset = isText$b(container) && isAfterNode ? container.data.length : 0;
|
| 10093 |
if (!collapsed && container === body.lastChild && isTable$2(container)) {
|
10654 |
if (!collapsed && container === body.lastChild && isTable$2(container)) {
|
| 10094 |
return Optional.none();
|
10655 |
return Optional.none();
|
| 10095 |
}
|
10656 |
}
|
| 10096 |
if (hasContentEditableFalseParent(body, container) || isCaretContainer$2(container)) {
|
10657 |
if (hasContentEditableFalseParent(body, container) || isCaretContainer$2(container)) {
|
| 10097 |
return Optional.none();
|
10658 |
return Optional.none();
|
| Línea 10105... |
Línea 10666... |
| 10105 |
do {
|
10666 |
do {
|
| 10106 |
if (isContentEditableFalse$b(node) || isCaretContainer$2(node)) {
|
10667 |
if (isContentEditableFalse$b(node) || isCaretContainer$2(node)) {
|
| 10107 |
normalized = false;
|
10668 |
normalized = false;
|
| 10108 |
break;
|
10669 |
break;
|
| 10109 |
}
|
10670 |
}
|
| 10110 |
if (isText$a(node) && node.data.length > 0) {
|
10671 |
if (isText$b(node) && node.data.length > 0) {
|
| 10111 |
offset = directionLeft ? 0 : node.data.length;
|
10672 |
offset = directionLeft ? 0 : node.data.length;
|
| 10112 |
container = node;
|
10673 |
container = node;
|
| 10113 |
normalized = true;
|
10674 |
normalized = true;
|
| 10114 |
break;
|
10675 |
break;
|
| 10115 |
}
|
10676 |
}
|
| Línea 10125... |
Línea 10686... |
| 10125 |
} while (node = directionLeft ? walker.next() : walker.prev());
|
10686 |
} while (node = directionLeft ? walker.next() : walker.prev());
|
| 10126 |
}
|
10687 |
}
|
| 10127 |
}
|
10688 |
}
|
| 10128 |
}
|
10689 |
}
|
| 10129 |
if (collapsed) {
|
10690 |
if (collapsed) {
|
| 10130 |
if (isText$a(container) && offset === 0) {
|
10691 |
if (isText$b(container) && offset === 0) {
|
| 10131 |
findTextNodeRelative(dom, isAfterNode, collapsed, true, container).each(pos => {
|
10692 |
findTextNodeRelative(dom, isAfterNode, collapsed, true, container).each(pos => {
|
| 10132 |
container = pos.container();
|
10693 |
container = pos.container();
|
| 10133 |
offset = pos.offset();
|
10694 |
offset = pos.offset();
|
| 10134 |
normalized = true;
|
10695 |
normalized = true;
|
| 10135 |
});
|
10696 |
});
|
| Línea 10146... |
Línea 10707... |
| 10146 |
normalized = true;
|
10707 |
normalized = true;
|
| 10147 |
});
|
10708 |
});
|
| 10148 |
}
|
10709 |
}
|
| 10149 |
}
|
10710 |
}
|
| 10150 |
}
|
10711 |
}
|
| 10151 |
if (directionLeft && !collapsed && isText$a(container) && offset === container.data.length) {
|
10712 |
if (directionLeft && !collapsed && isText$b(container) && offset === container.data.length) {
|
| 10152 |
findTextNodeRelative(dom, isAfterNode, collapsed, false, container).each(pos => {
|
10713 |
findTextNodeRelative(dom, isAfterNode, collapsed, false, container).each(pos => {
|
| 10153 |
container = pos.container();
|
10714 |
container = pos.container();
|
| 10154 |
offset = pos.offset();
|
10715 |
offset = pos.offset();
|
| 10155 |
normalized = true;
|
10716 |
normalized = true;
|
| 10156 |
});
|
10717 |
});
|
| Línea 10179... |
Línea 10740... |
| 10179 |
const splitText = (node, offset) => {
|
10740 |
const splitText = (node, offset) => {
|
| 10180 |
return node.splitText(offset);
|
10741 |
return node.splitText(offset);
|
| 10181 |
};
|
10742 |
};
|
| 10182 |
const split = rng => {
|
10743 |
const split = rng => {
|
| 10183 |
let startContainer = rng.startContainer, startOffset = rng.startOffset, endContainer = rng.endContainer, endOffset = rng.endOffset;
|
10744 |
let startContainer = rng.startContainer, startOffset = rng.startOffset, endContainer = rng.endContainer, endOffset = rng.endOffset;
|
| 10184 |
if (startContainer === endContainer && isText$a(startContainer)) {
|
10745 |
if (startContainer === endContainer && isText$b(startContainer)) {
|
| 10185 |
if (startOffset > 0 && startOffset < startContainer.data.length) {
|
10746 |
if (startOffset > 0 && startOffset < startContainer.data.length) {
|
| 10186 |
endContainer = splitText(startContainer, startOffset);
|
10747 |
endContainer = splitText(startContainer, startOffset);
|
| 10187 |
startContainer = endContainer.previousSibling;
|
10748 |
startContainer = endContainer.previousSibling;
|
| 10188 |
if (endOffset > startOffset) {
|
10749 |
if (endOffset > startOffset) {
|
| 10189 |
endOffset = endOffset - startOffset;
|
10750 |
endOffset = endOffset - startOffset;
|
| Línea 10194... |
Línea 10755... |
| 10194 |
} else {
|
10755 |
} else {
|
| 10195 |
endOffset = 0;
|
10756 |
endOffset = 0;
|
| 10196 |
}
|
10757 |
}
|
| 10197 |
}
|
10758 |
}
|
| 10198 |
} else {
|
10759 |
} else {
|
| 10199 |
if (isText$a(startContainer) && startOffset > 0 && startOffset < startContainer.data.length) {
|
10760 |
if (isText$b(startContainer) && startOffset > 0 && startOffset < startContainer.data.length) {
|
| 10200 |
startContainer = splitText(startContainer, startOffset);
|
10761 |
startContainer = splitText(startContainer, startOffset);
|
| 10201 |
startOffset = 0;
|
10762 |
startOffset = 0;
|
| 10202 |
}
|
10763 |
}
|
| 10203 |
if (isText$a(endContainer) && endOffset > 0 && endOffset < endContainer.data.length) {
|
10764 |
if (isText$b(endContainer) && endOffset > 0 && endOffset < endContainer.data.length) {
|
| 10204 |
const newContainer = splitText(endContainer, endOffset).previousSibling;
|
10765 |
const newContainer = splitText(endContainer, endOffset).previousSibling;
|
| 10205 |
endContainer = newContainer;
|
10766 |
endContainer = newContainer;
|
| 10206 |
endOffset = newContainer.data.length;
|
10767 |
endOffset = newContainer.data.length;
|
| 10207 |
}
|
10768 |
}
|
| 10208 |
}
|
10769 |
}
|
| Línea 10226... |
Línea 10787... |
| 10226 |
return true;
|
10787 |
return true;
|
| 10227 |
});
|
10788 |
});
|
| 10228 |
};
|
10789 |
};
|
| 10229 |
const expand = (rng, options = { type: 'word' }) => {
|
10790 |
const expand = (rng, options = { type: 'word' }) => {
|
| 10230 |
if (options.type === 'word') {
|
10791 |
if (options.type === 'word') {
|
| 10231 |
const rangeLike = expandRng(dom, rng, [{ inline: 'span' }]);
|
10792 |
const rangeLike = expandRng(dom, rng, [{ inline: 'span' }], {
|
| - |
|
10793 |
includeTrailingSpace: false,
|
| - |
|
10794 |
expandToBlock: false
|
| - |
|
10795 |
});
|
| 10232 |
const newRange = dom.createRng();
|
10796 |
const newRange = dom.createRng();
|
| 10233 |
newRange.setStart(rangeLike.startContainer, rangeLike.startOffset);
|
10797 |
newRange.setStart(rangeLike.startContainer, rangeLike.startOffset);
|
| 10234 |
newRange.setEnd(rangeLike.endContainer, rangeLike.endOffset);
|
10798 |
newRange.setEnd(rangeLike.endContainer, rangeLike.endOffset);
|
| 10235 |
return newRange;
|
10799 |
return newRange;
|
| 10236 |
}
|
10800 |
}
|
| Línea 10290... |
Línea 10854... |
| 10290 |
const dom = element.dom;
|
10854 |
const dom = element.dom;
|
| 10291 |
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
|
10855 |
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
|
| 10292 |
});
|
10856 |
});
|
| 10293 |
const get$2 = element => api.get(element);
|
10857 |
const get$2 = element => api.get(element);
|
| Línea 10294... |
Línea -... |
| 10294 |
|
- |
|
| 10295 |
const getDocument = () => SugarElement.fromDom(document);
|
- |
|
| 10296 |
|
10858 |
|
| 10297 |
const walkUp = (navigation, doc) => {
|
10859 |
const walkUp = (navigation, doc) => {
|
| 10298 |
const frame = navigation.view(doc);
|
10860 |
const frame = navigation.view(doc);
|
| 10299 |
return frame.fold(constant([]), f => {
|
10861 |
return frame.fold(constant([]), f => {
|
| 10300 |
const parent = navigation.owner(f);
|
10862 |
const parent = navigation.owner(f);
|
| Línea 10369... |
Línea 10931... |
| 10369 |
if (name(last) === 'img') {
|
10931 |
if (name(last) === 'img') {
|
| 10370 |
return {
|
10932 |
return {
|
| 10371 |
element: last,
|
10933 |
element: last,
|
| 10372 |
offset: 1
|
10934 |
offset: 1
|
| 10373 |
};
|
10935 |
};
|
| 10374 |
} else if (isText$b(last)) {
|
10936 |
} else if (isText$c(last)) {
|
| 10375 |
return {
|
10937 |
return {
|
| 10376 |
element: last,
|
10938 |
element: last,
|
| 10377 |
offset: get$3(last).length
|
10939 |
offset: get$3(last).length
|
| 10378 |
};
|
10940 |
};
|
| 10379 |
} else {
|
10941 |
} else {
|
| Línea 10398... |
Línea 10960... |
| 10398 |
};
|
10960 |
};
|
| 10399 |
const createMarker$1 = (element, offset) => {
|
10961 |
const createMarker$1 = (element, offset) => {
|
| 10400 |
const startPoint = descend(element, offset);
|
10962 |
const startPoint = descend(element, offset);
|
| 10401 |
const span = SugarElement.fromHtml('<span data-mce-bogus="all" style="display: inline-block;">' + ZWSP$1 + '</span>');
|
10963 |
const span = SugarElement.fromHtml('<span data-mce-bogus="all" style="display: inline-block;">' + ZWSP$1 + '</span>');
|
| 10402 |
before$3(startPoint.element, span);
|
10964 |
before$3(startPoint.element, span);
|
| 10403 |
return markerInfo(span, () => remove$5(span));
|
10965 |
return markerInfo(span, () => remove$4(span));
|
| 10404 |
};
|
10966 |
};
|
| 10405 |
const elementMarker = element => markerInfo(SugarElement.fromDom(element), noop);
|
10967 |
const elementMarker = element => markerInfo(SugarElement.fromDom(element), noop);
|
| 10406 |
const withMarker = (editor, f, rng, alignToTop) => {
|
10968 |
const withMarker = (editor, f, rng, alignToTop) => {
|
| 10407 |
preserveWith(editor, (_s, _e) => applyWithMarker(editor, f, rng, alignToTop), rng);
|
10969 |
preserveWith(editor, (_s, _e) => applyWithMarker(editor, f, rng, alignToTop), rng);
|
| 10408 |
};
|
10970 |
};
|
| Línea 10490... |
Línea 11052... |
| 10490 |
const scrollRangeIntoView = (editor, rng, alignToTop) => {
|
11052 |
const scrollRangeIntoView = (editor, rng, alignToTop) => {
|
| 10491 |
const scroller = editor.inline ? rangeIntoWindow : rangeIntoFrame;
|
11053 |
const scroller = editor.inline ? rangeIntoWindow : rangeIntoFrame;
|
| 10492 |
scroller(editor, rng, alignToTop);
|
11054 |
scroller(editor, rng, alignToTop);
|
| 10493 |
};
|
11055 |
};
|
| Línea 10494... |
Línea -... |
| 10494 |
|
- |
|
| 10495 |
const focus$1 = (element, preventScroll = false) => element.dom.focus({ preventScroll });
|
- |
|
| 10496 |
const hasFocus$1 = element => {
|
- |
|
| 10497 |
const root = getRootNode(element).dom;
|
- |
|
| 10498 |
return element.dom === root.activeElement;
|
- |
|
| 10499 |
};
|
- |
|
| 10500 |
const active$1 = (root = getDocument()) => Optional.from(root.dom.activeElement).map(SugarElement.fromDom);
|
- |
|
| 10501 |
const search = element => active$1(getRootNode(element)).filter(e => element.dom.contains(e.dom));
|
- |
|
| 10502 |
|
- |
|
| 10503 |
const clamp$1 = (offset, element) => {
|
- |
|
| 10504 |
const max = isText$b(element) ? get$3(element).length : children$1(element).length + 1;
|
- |
|
| 10505 |
if (offset > max) {
|
- |
|
| 10506 |
return max;
|
- |
|
| 10507 |
} else if (offset < 0) {
|
- |
|
| 10508 |
return 0;
|
- |
|
| 10509 |
}
|
- |
|
| 10510 |
return offset;
|
- |
|
| 10511 |
};
|
- |
|
| 10512 |
const normalizeRng = rng => SimSelection.range(rng.start, clamp$1(rng.soffset, rng.start), rng.finish, clamp$1(rng.foffset, rng.finish));
|
- |
|
| 10513 |
const isOrContains = (root, elm) => !isRestrictedNode(elm.dom) && (contains(root, elm) || eq(root, elm));
|
- |
|
| 10514 |
const isRngInRoot = root => rng => isOrContains(root, rng.start) && isOrContains(root, rng.finish);
|
- |
|
| 10515 |
const shouldStore = editor => editor.inline || Env.browser.isFirefox();
|
- |
|
| 10516 |
const nativeRangeToSelectionRange = r => SimSelection.range(SugarElement.fromDom(r.startContainer), r.startOffset, SugarElement.fromDom(r.endContainer), r.endOffset);
|
- |
|
| 10517 |
const readRange = win => {
|
- |
|
| 10518 |
const selection = win.getSelection();
|
- |
|
| 10519 |
const rng = !selection || selection.rangeCount === 0 ? Optional.none() : Optional.from(selection.getRangeAt(0));
|
- |
|
| 10520 |
return rng.map(nativeRangeToSelectionRange);
|
- |
|
| 10521 |
};
|
- |
|
| 10522 |
const getBookmark = root => {
|
- |
|
| 10523 |
const win = defaultView(root);
|
- |
|
| 10524 |
return readRange(win.dom).filter(isRngInRoot(root));
|
- |
|
| 10525 |
};
|
- |
|
| 10526 |
const validate = (root, bookmark) => Optional.from(bookmark).filter(isRngInRoot(root)).map(normalizeRng);
|
- |
|
| 10527 |
const bookmarkToNativeRng = bookmark => {
|
- |
|
| 10528 |
const rng = document.createRange();
|
- |
|
| 10529 |
try {
|
- |
|
| 10530 |
rng.setStart(bookmark.start.dom, bookmark.soffset);
|
- |
|
| 10531 |
rng.setEnd(bookmark.finish.dom, bookmark.foffset);
|
- |
|
| 10532 |
return Optional.some(rng);
|
- |
|
| 10533 |
} catch (_) {
|
- |
|
| 10534 |
return Optional.none();
|
- |
|
| 10535 |
}
|
- |
|
| 10536 |
};
|
- |
|
| 10537 |
const store = editor => {
|
- |
|
| 10538 |
const newBookmark = shouldStore(editor) ? getBookmark(SugarElement.fromDom(editor.getBody())) : Optional.none();
|
- |
|
| 10539 |
editor.bookmark = newBookmark.isSome() ? newBookmark : editor.bookmark;
|
- |
|
| 10540 |
};
|
- |
|
| 10541 |
const getRng = editor => {
|
- |
|
| 10542 |
const bookmark = editor.bookmark ? editor.bookmark : Optional.none();
|
- |
|
| 10543 |
return bookmark.bind(x => validate(SugarElement.fromDom(editor.getBody()), x)).bind(bookmarkToNativeRng);
|
- |
|
| 10544 |
};
|
- |
|
| 10545 |
const restore = editor => {
|
- |
|
| 10546 |
getRng(editor).each(rng => editor.selection.setRng(rng));
|
- |
|
| 10547 |
};
|
- |
|
| 10548 |
|
- |
|
| 10549 |
const isEditorUIElement$1 = elm => {
|
- |
|
| 10550 |
const className = elm.className.toString();
|
- |
|
| 10551 |
return className.indexOf('tox-') !== -1 || className.indexOf('mce-') !== -1;
|
- |
|
| 10552 |
};
|
- |
|
| 10553 |
const FocusManager = { isEditorUIElement: isEditorUIElement$1 };
|
- |
|
| 10554 |
|
- |
|
| 10555 |
const wrappedSetTimeout = (callback, time) => {
|
- |
|
| 10556 |
if (!isNumber(time)) {
|
- |
|
| 10557 |
time = 0;
|
- |
|
| 10558 |
}
|
- |
|
| 10559 |
return setTimeout(callback, time);
|
- |
|
| 10560 |
};
|
- |
|
| 10561 |
const wrappedSetInterval = (callback, time) => {
|
- |
|
| 10562 |
if (!isNumber(time)) {
|
- |
|
| 10563 |
time = 0;
|
- |
|
| 10564 |
}
|
- |
|
| 10565 |
return setInterval(callback, time);
|
- |
|
| 10566 |
};
|
- |
|
| 10567 |
const Delay = {
|
- |
|
| 10568 |
setEditorTimeout: (editor, callback, time) => {
|
- |
|
| 10569 |
return wrappedSetTimeout(() => {
|
- |
|
| 10570 |
if (!editor.removed) {
|
- |
|
| 10571 |
callback();
|
- |
|
| 10572 |
}
|
- |
|
| 10573 |
}, time);
|
- |
|
| 10574 |
},
|
- |
|
| 10575 |
setEditorInterval: (editor, callback, time) => {
|
- |
|
| 10576 |
const timer = wrappedSetInterval(() => {
|
- |
|
| 10577 |
if (!editor.removed) {
|
- |
|
| 10578 |
callback();
|
- |
|
| 10579 |
} else {
|
- |
|
| 10580 |
clearInterval(timer);
|
- |
|
| 10581 |
}
|
- |
|
| 10582 |
}, time);
|
- |
|
| 10583 |
return timer;
|
- |
|
| 10584 |
}
|
- |
|
| 10585 |
};
|
- |
|
| 10586 |
|
- |
|
| 10587 |
const isManualNodeChange = e => {
|
- |
|
| 10588 |
return e.type === 'nodechange' && e.selectionChange;
|
- |
|
| 10589 |
};
|
- |
|
| 10590 |
const registerPageMouseUp = (editor, throttledStore) => {
|
- |
|
| 10591 |
const mouseUpPage = () => {
|
- |
|
| 10592 |
throttledStore.throttle();
|
- |
|
| 10593 |
};
|
- |
|
| 10594 |
DOMUtils.DOM.bind(document, 'mouseup', mouseUpPage);
|
- |
|
| 10595 |
editor.on('remove', () => {
|
- |
|
| 10596 |
DOMUtils.DOM.unbind(document, 'mouseup', mouseUpPage);
|
- |
|
| 10597 |
});
|
- |
|
| 10598 |
};
|
- |
|
| 10599 |
const registerMouseUp = (editor, throttledStore) => {
|
- |
|
| 10600 |
editor.on('mouseup touchend', _e => {
|
- |
|
| 10601 |
throttledStore.throttle();
|
- |
|
| 10602 |
});
|
- |
|
| 10603 |
};
|
- |
|
| 10604 |
const registerEditorEvents = (editor, throttledStore) => {
|
- |
|
| 10605 |
registerMouseUp(editor, throttledStore);
|
- |
|
| 10606 |
editor.on('keyup NodeChange AfterSetSelectionRange', e => {
|
- |
|
| 10607 |
if (!isManualNodeChange(e)) {
|
- |
|
| 10608 |
store(editor);
|
- |
|
| 10609 |
}
|
- |
|
| 10610 |
});
|
- |
|
| 10611 |
};
|
- |
|
| 10612 |
const register$6 = editor => {
|
- |
|
| 10613 |
const throttledStore = first$1(() => {
|
- |
|
| 10614 |
store(editor);
|
- |
|
| 10615 |
}, 0);
|
- |
|
| 10616 |
editor.on('init', () => {
|
- |
|
| 10617 |
if (editor.inline) {
|
- |
|
| 10618 |
registerPageMouseUp(editor, throttledStore);
|
- |
|
| 10619 |
}
|
- |
|
| 10620 |
registerEditorEvents(editor, throttledStore);
|
- |
|
| 10621 |
});
|
- |
|
| 10622 |
editor.on('remove', () => {
|
- |
|
| 10623 |
throttledStore.cancel();
|
- |
|
| 10624 |
});
|
- |
|
| 10625 |
};
|
- |
|
| 10626 |
|
- |
|
| 10627 |
let documentFocusInHandler;
|
- |
|
| 10628 |
const DOM$9 = DOMUtils.DOM;
|
- |
|
| 10629 |
const isEditorUIElement = elm => {
|
- |
|
| 10630 |
return isElement$6(elm) && FocusManager.isEditorUIElement(elm);
|
- |
|
| 10631 |
};
|
- |
|
| 10632 |
const isEditorContentAreaElement = elm => {
|
- |
|
| 10633 |
const classList = elm.classList;
|
- |
|
| 10634 |
if (classList !== undefined) {
|
- |
|
| 10635 |
return classList.contains('tox-edit-area') || classList.contains('tox-edit-area__iframe') || classList.contains('mce-content-body');
|
- |
|
| 10636 |
} else {
|
- |
|
| 10637 |
return false;
|
- |
|
| 10638 |
}
|
- |
|
| 10639 |
};
|
- |
|
| 10640 |
const isUIElement = (editor, elm) => {
|
- |
|
| 10641 |
const customSelector = getCustomUiSelector(editor);
|
- |
|
| 10642 |
const parent = DOM$9.getParent(elm, elm => {
|
- |
|
| 10643 |
return isEditorUIElement(elm) || (customSelector ? editor.dom.is(elm, customSelector) : false);
|
- |
|
| 10644 |
});
|
- |
|
| 10645 |
return parent !== null;
|
- |
|
| 10646 |
};
|
- |
|
| 10647 |
const getActiveElement = editor => {
|
- |
|
| 10648 |
try {
|
- |
|
| 10649 |
const root = getRootNode(SugarElement.fromDom(editor.getElement()));
|
- |
|
| 10650 |
return active$1(root).fold(() => document.body, x => x.dom);
|
- |
|
| 10651 |
} catch (ex) {
|
- |
|
| 10652 |
return document.body;
|
- |
|
| 10653 |
}
|
- |
|
| 10654 |
};
|
- |
|
| 10655 |
const registerEvents$1 = (editorManager, e) => {
|
- |
|
| 10656 |
const editor = e.editor;
|
- |
|
| 10657 |
register$6(editor);
|
- |
|
| 10658 |
const toggleContentAreaOnFocus = (editor, fn) => {
|
- |
|
| 10659 |
if (shouldHighlightOnFocus(editor) && editor.inline !== true) {
|
- |
|
| 10660 |
const contentArea = SugarElement.fromDom(editor.getContainer());
|
- |
|
| 10661 |
fn(contentArea, 'tox-edit-focus');
|
- |
|
| 10662 |
}
|
- |
|
| 10663 |
};
|
- |
|
| 10664 |
editor.on('focusin', () => {
|
- |
|
| 10665 |
const focusedEditor = editorManager.focusedEditor;
|
- |
|
| 10666 |
if (isEditorContentAreaElement(getActiveElement(editor))) {
|
- |
|
| 10667 |
toggleContentAreaOnFocus(editor, add$2);
|
- |
|
| 10668 |
}
|
- |
|
| 10669 |
if (focusedEditor !== editor) {
|
- |
|
| 10670 |
if (focusedEditor) {
|
- |
|
| 10671 |
focusedEditor.dispatch('blur', { focusedEditor: editor });
|
- |
|
| 10672 |
}
|
- |
|
| 10673 |
editorManager.setActive(editor);
|
- |
|
| 10674 |
editorManager.focusedEditor = editor;
|
- |
|
| 10675 |
editor.dispatch('focus', { blurredEditor: focusedEditor });
|
- |
|
| 10676 |
editor.focus(true);
|
- |
|
| 10677 |
}
|
- |
|
| 10678 |
});
|
- |
|
| 10679 |
editor.on('focusout', () => {
|
- |
|
| 10680 |
Delay.setEditorTimeout(editor, () => {
|
- |
|
| 10681 |
const focusedEditor = editorManager.focusedEditor;
|
- |
|
| 10682 |
if (!isEditorContentAreaElement(getActiveElement(editor)) || focusedEditor !== editor) {
|
- |
|
| 10683 |
toggleContentAreaOnFocus(editor, remove$7);
|
- |
|
| 10684 |
}
|
- |
|
| 10685 |
if (!isUIElement(editor, getActiveElement(editor)) && focusedEditor === editor) {
|
- |
|
| 10686 |
editor.dispatch('blur', { focusedEditor: null });
|
- |
|
| 10687 |
editorManager.focusedEditor = null;
|
- |
|
| 10688 |
}
|
- |
|
| 10689 |
});
|
- |
|
| 10690 |
});
|
- |
|
| 10691 |
if (!documentFocusInHandler) {
|
- |
|
| 10692 |
documentFocusInHandler = e => {
|
- |
|
| 10693 |
const activeEditor = editorManager.activeEditor;
|
- |
|
| 10694 |
if (activeEditor) {
|
- |
|
| 10695 |
getOriginalEventTarget(e).each(target => {
|
- |
|
| 10696 |
const elem = target;
|
- |
|
| 10697 |
if (elem.ownerDocument === document) {
|
- |
|
| 10698 |
if (elem !== document.body && !isUIElement(activeEditor, elem) && editorManager.focusedEditor === activeEditor) {
|
- |
|
| 10699 |
activeEditor.dispatch('blur', { focusedEditor: null });
|
- |
|
| 10700 |
editorManager.focusedEditor = null;
|
- |
|
| 10701 |
}
|
- |
|
| 10702 |
}
|
- |
|
| 10703 |
});
|
- |
|
| 10704 |
}
|
- |
|
| 10705 |
};
|
- |
|
| 10706 |
DOM$9.bind(document, 'focusin', documentFocusInHandler);
|
- |
|
| 10707 |
}
|
- |
|
| 10708 |
};
|
- |
|
| 10709 |
const unregisterDocumentEvents = (editorManager, e) => {
|
- |
|
| 10710 |
if (editorManager.focusedEditor === e.editor) {
|
- |
|
| 10711 |
editorManager.focusedEditor = null;
|
- |
|
| 10712 |
}
|
- |
|
| 10713 |
if (!editorManager.activeEditor && documentFocusInHandler) {
|
- |
|
| 10714 |
DOM$9.unbind(document, 'focusin', documentFocusInHandler);
|
- |
|
| 10715 |
documentFocusInHandler = null;
|
- |
|
| 10716 |
}
|
- |
|
| 10717 |
};
|
- |
|
| 10718 |
const setup$w = editorManager => {
|
- |
|
| 10719 |
editorManager.on('AddEditor', curry(registerEvents$1, editorManager));
|
- |
|
| 10720 |
editorManager.on('RemoveEditor', curry(unregisterDocumentEvents, editorManager));
|
- |
|
| 10721 |
};
|
- |
|
| 10722 |
|
- |
|
| 10723 |
const getContentEditableHost = (editor, node) => editor.dom.getParent(node, node => editor.dom.getContentEditable(node) === 'true');
|
- |
|
| 10724 |
const getCollapsedNode = rng => rng.collapsed ? Optional.from(getNode$1(rng.startContainer, rng.startOffset)).map(SugarElement.fromDom) : Optional.none();
|
- |
|
| 10725 |
const getFocusInElement = (root, rng) => getCollapsedNode(rng).bind(node => {
|
- |
|
| 10726 |
if (isTableSection(node)) {
|
- |
|
| 10727 |
return Optional.some(node);
|
- |
|
| 10728 |
} else if (!contains(root, node)) {
|
- |
|
| 10729 |
return Optional.some(root);
|
- |
|
| 10730 |
} else {
|
- |
|
| 10731 |
return Optional.none();
|
- |
|
| 10732 |
}
|
- |
|
| 10733 |
});
|
- |
|
| 10734 |
const normalizeSelection = (editor, rng) => {
|
- |
|
| 10735 |
getFocusInElement(SugarElement.fromDom(editor.getBody()), rng).bind(elm => {
|
- |
|
| 10736 |
return firstPositionIn(elm.dom);
|
- |
|
| 10737 |
}).fold(() => {
|
- |
|
| 10738 |
editor.selection.normalize();
|
- |
|
| 10739 |
}, caretPos => editor.selection.setRng(caretPos.toRange()));
|
- |
|
| 10740 |
};
|
- |
|
| 10741 |
const focusBody = body => {
|
- |
|
| 10742 |
if (body.setActive) {
|
- |
|
| 10743 |
try {
|
- |
|
| 10744 |
body.setActive();
|
- |
|
| 10745 |
} catch (ex) {
|
- |
|
| 10746 |
body.focus();
|
- |
|
| 10747 |
}
|
- |
|
| 10748 |
} else {
|
- |
|
| 10749 |
body.focus();
|
- |
|
| 10750 |
}
|
- |
|
| 10751 |
};
|
- |
|
| 10752 |
const hasElementFocus = elm => hasFocus$1(elm) || search(elm).isSome();
|
- |
|
| 10753 |
const hasIframeFocus = editor => isNonNullable(editor.iframeElement) && hasFocus$1(SugarElement.fromDom(editor.iframeElement));
|
- |
|
| 10754 |
const hasInlineFocus = editor => {
|
- |
|
| 10755 |
const rawBody = editor.getBody();
|
- |
|
| 10756 |
return rawBody && hasElementFocus(SugarElement.fromDom(rawBody));
|
- |
|
| 10757 |
};
|
- |
|
| 10758 |
const hasUiFocus = editor => {
|
- |
|
| 10759 |
const dos = getRootNode(SugarElement.fromDom(editor.getElement()));
|
- |
|
| 10760 |
return active$1(dos).filter(elem => !isEditorContentAreaElement(elem.dom) && isUIElement(editor, elem.dom)).isSome();
|
- |
|
| 10761 |
};
|
- |
|
| 10762 |
const hasFocus = editor => editor.inline ? hasInlineFocus(editor) : hasIframeFocus(editor);
|
- |
|
| 10763 |
const hasEditorOrUiFocus = editor => hasFocus(editor) || hasUiFocus(editor);
|
- |
|
| 10764 |
const focusEditor = editor => {
|
- |
|
| 10765 |
const selection = editor.selection;
|
- |
|
| 10766 |
const body = editor.getBody();
|
- |
|
| 10767 |
let rng = selection.getRng();
|
- |
|
| 10768 |
editor.quirks.refreshContentEditable();
|
- |
|
| 10769 |
if (isNonNullable(editor.bookmark) && !hasFocus(editor)) {
|
- |
|
| 10770 |
getRng(editor).each(bookmarkRng => {
|
- |
|
| 10771 |
editor.selection.setRng(bookmarkRng);
|
- |
|
| 10772 |
rng = bookmarkRng;
|
- |
|
| 10773 |
});
|
- |
|
| 10774 |
}
|
- |
|
| 10775 |
const contentEditableHost = getContentEditableHost(editor, selection.getNode());
|
- |
|
| 10776 |
if (contentEditableHost && editor.dom.isChildOf(contentEditableHost, body)) {
|
- |
|
| 10777 |
focusBody(contentEditableHost);
|
- |
|
| 10778 |
normalizeSelection(editor, rng);
|
- |
|
| 10779 |
activateEditor(editor);
|
- |
|
| 10780 |
return;
|
- |
|
| 10781 |
}
|
- |
|
| 10782 |
if (!editor.inline) {
|
- |
|
| 10783 |
if (!Env.browser.isOpera()) {
|
- |
|
| 10784 |
focusBody(body);
|
- |
|
| 10785 |
}
|
- |
|
| 10786 |
editor.getWin().focus();
|
- |
|
| 10787 |
}
|
- |
|
| 10788 |
if (Env.browser.isFirefox() || editor.inline) {
|
- |
|
| 10789 |
focusBody(body);
|
- |
|
| 10790 |
normalizeSelection(editor, rng);
|
- |
|
| 10791 |
}
|
- |
|
| 10792 |
activateEditor(editor);
|
- |
|
| 10793 |
};
|
- |
|
| 10794 |
const activateEditor = editor => editor.editorManager.setActive(editor);
|
- |
|
| 10795 |
const focus = (editor, skipFocus) => {
|
- |
|
| 10796 |
if (editor.removed) {
|
- |
|
| 10797 |
return;
|
- |
|
| 10798 |
}
|
- |
|
| 10799 |
if (skipFocus) {
|
- |
|
| 10800 |
activateEditor(editor);
|
- |
|
| 10801 |
} else {
|
- |
|
| 10802 |
focusEditor(editor);
|
- |
|
| 10803 |
}
|
- |
|
| 10804 |
};
|
- |
|
| 10805 |
|
11056 |
|
| 10806 |
const isEditableRange = (dom, rng) => {
|
11057 |
const isEditableRange = (dom, rng) => {
|
| 10807 |
if (rng.collapsed) {
|
11058 |
if (rng.collapsed) {
|
| 10808 |
return dom.isEditable(rng.startContainer);
|
11059 |
return dom.isEditable(rng.startContainer);
|
| 10809 |
} else {
|
11060 |
} else {
|
| Línea 10815... |
Línea 11066... |
| 10815 |
const container = start ? rng.startContainer : rng.endContainer;
|
11066 |
const container = start ? rng.startContainer : rng.endContainer;
|
| 10816 |
const offset = start ? rng.startOffset : rng.endOffset;
|
11067 |
const offset = start ? rng.startOffset : rng.endOffset;
|
| 10817 |
return Optional.from(container).map(SugarElement.fromDom).map(elm => !real || !rng.collapsed ? child$1(elm, resolve(elm, offset)).getOr(elm) : elm).bind(elm => isElement$7(elm) ? Optional.some(elm) : parent(elm).filter(isElement$7)).map(elm => elm.dom).getOr(root);
|
11068 |
return Optional.from(container).map(SugarElement.fromDom).map(elm => !real || !rng.collapsed ? child$1(elm, resolve(elm, offset)).getOr(elm) : elm).bind(elm => isElement$7(elm) ? Optional.some(elm) : parent(elm).filter(isElement$7)).map(elm => elm.dom).getOr(root);
|
| 10818 |
};
|
11069 |
};
|
| 10819 |
const getStart = (root, rng, real = false) => getEndpointElement(root, rng, true, real, (elm, offset) => Math.min(childNodesCount(elm), offset));
|
11070 |
const getStart = (root, rng, real = false) => getEndpointElement(root, rng, true, real, (elm, offset) => Math.min(childNodesCount(elm), offset));
|
| 10820 |
const getEnd$1 = (root, rng, real = false) => getEndpointElement(root, rng, false, real, (elm, offset) => offset > 0 ? offset - 1 : offset);
|
11071 |
const getEnd = (root, rng, real = false) => getEndpointElement(root, rng, false, real, (elm, offset) => offset > 0 ? offset - 1 : offset);
|
| 10821 |
const skipEmptyTextNodes = (node, forwards) => {
|
11072 |
const skipEmptyTextNodes = (node, forwards) => {
|
| 10822 |
const orig = node;
|
11073 |
const orig = node;
|
| 10823 |
while (node && isText$a(node) && node.length === 0) {
|
11074 |
while (node && isText$b(node) && node.length === 0) {
|
| 10824 |
node = forwards ? node.nextSibling : node.previousSibling;
|
11075 |
node = forwards ? node.nextSibling : node.previousSibling;
|
| 10825 |
}
|
11076 |
}
|
| 10826 |
return node || orig;
|
11077 |
return node || orig;
|
| 10827 |
};
|
11078 |
};
|
| 10828 |
const getNode = (root, rng) => {
|
11079 |
const getNode = (root, rng) => {
|
| Línea 10840... |
Línea 11091... |
| 10840 |
if (startContainer.hasChildNodes()) {
|
11091 |
if (startContainer.hasChildNodes()) {
|
| 10841 |
node = startContainer.childNodes[startOffset];
|
11092 |
node = startContainer.childNodes[startOffset];
|
| 10842 |
}
|
11093 |
}
|
| 10843 |
}
|
11094 |
}
|
| 10844 |
}
|
11095 |
}
|
| 10845 |
if (isText$a(startContainer) && isText$a(endContainer)) {
|
11096 |
if (isText$b(startContainer) && isText$b(endContainer)) {
|
| 10846 |
if (startContainer.length === startOffset) {
|
11097 |
if (startContainer.length === startOffset) {
|
| 10847 |
startContainer = skipEmptyTextNodes(startContainer.nextSibling, true);
|
11098 |
startContainer = skipEmptyTextNodes(startContainer.nextSibling, true);
|
| 10848 |
} else {
|
11099 |
} else {
|
| 10849 |
startContainer = startContainer.parentNode;
|
11100 |
startContainer = startContainer.parentNode;
|
| 10850 |
}
|
11101 |
}
|
| Línea 10856... |
Línea 11107... |
| 10856 |
if (startContainer && startContainer === endContainer) {
|
11107 |
if (startContainer && startContainer === endContainer) {
|
| 10857 |
node = startContainer;
|
11108 |
node = startContainer;
|
| 10858 |
}
|
11109 |
}
|
| 10859 |
}
|
11110 |
}
|
| 10860 |
}
|
11111 |
}
|
| 10861 |
const elm = isText$a(node) ? node.parentNode : node;
|
11112 |
const elm = isText$b(node) ? node.parentNode : node;
|
| 10862 |
return isHTMLElement(elm) ? elm : root;
|
11113 |
return isHTMLElement(elm) ? elm : root;
|
| 10863 |
};
|
11114 |
};
|
| 10864 |
const getSelectedBlocks = (dom, rng, startElm, endElm) => {
|
11115 |
const getSelectedBlocks = (dom, rng, startElm, endElm) => {
|
| 10865 |
const selectedBlocks = [];
|
11116 |
const selectedBlocks = [];
|
| 10866 |
const root = dom.getRoot();
|
11117 |
const root = dom.getRoot();
|
| 10867 |
const start = dom.getParent(startElm || getStart(root, rng, rng.collapsed), dom.isBlock);
|
11118 |
const start = dom.getParent(startElm || getStart(root, rng, rng.collapsed), dom.isBlock);
|
| 10868 |
const end = dom.getParent(endElm || getEnd$1(root, rng, rng.collapsed), dom.isBlock);
|
11119 |
const end = dom.getParent(endElm || getEnd(root, rng, rng.collapsed), dom.isBlock);
|
| 10869 |
if (start && start !== root) {
|
11120 |
if (start && start !== root) {
|
| 10870 |
selectedBlocks.push(start);
|
11121 |
selectedBlocks.push(start);
|
| 10871 |
}
|
11122 |
}
|
| 10872 |
if (start && end && start !== end) {
|
11123 |
if (start && end && start !== end) {
|
| 10873 |
let node;
|
11124 |
let node;
|
| Línea 10898... |
Línea 11149... |
| 10898 |
const processRanges = (editor, ranges) => map$3(ranges, range => {
|
11149 |
const processRanges = (editor, ranges) => map$3(ranges, range => {
|
| 10899 |
const evt = editor.dispatch('GetSelectionRange', { range });
|
11150 |
const evt = editor.dispatch('GetSelectionRange', { range });
|
| 10900 |
return evt.range !== range ? evt.range : range;
|
11151 |
return evt.range !== range ? evt.range : range;
|
| 10901 |
});
|
11152 |
});
|
| Línea 10902... |
Línea -... |
| 10902 |
|
- |
|
| 10903 |
const getEnd = element => name(element) === 'img' ? 1 : getOption(element).fold(() => children$1(element).length, v => v.length);
|
- |
|
| 10904 |
const isTextNodeWithCursorPosition = el => getOption(el).filter(text => text.trim().length !== 0 || text.indexOf(nbsp) > -1).isSome();
|
- |
|
| 10905 |
const isContentEditableFalse$5 = elem => isHTMLElement$1(elem) && get$9(elem, 'contenteditable') === 'false';
|
- |
|
| 10906 |
const elementsWithCursorPosition = [
|
- |
|
| 10907 |
'img',
|
- |
|
| 10908 |
'br'
|
- |
|
| 10909 |
];
|
- |
|
| 10910 |
const isCursorPosition = elem => {
|
- |
|
| 10911 |
const hasCursorPosition = isTextNodeWithCursorPosition(elem);
|
- |
|
| 10912 |
return hasCursorPosition || contains$2(elementsWithCursorPosition, name(elem)) || isContentEditableFalse$5(elem);
|
- |
|
| 10913 |
};
|
- |
|
| 10914 |
|
- |
|
| 10915 |
const first = element => descendant$2(element, isCursorPosition);
|
- |
|
| 10916 |
const last = element => descendantRtl(element, isCursorPosition);
|
- |
|
| 10917 |
const descendantRtl = (scope, predicate) => {
|
- |
|
| 10918 |
const descend = element => {
|
- |
|
| 10919 |
const children = children$1(element);
|
- |
|
| 10920 |
for (let i = children.length - 1; i >= 0; i--) {
|
- |
|
| 10921 |
const child = children[i];
|
- |
|
| 10922 |
if (predicate(child)) {
|
- |
|
| 10923 |
return Optional.some(child);
|
- |
|
| 10924 |
}
|
- |
|
| 10925 |
const res = descend(child);
|
- |
|
| 10926 |
if (res.isSome()) {
|
- |
|
| 10927 |
return res;
|
- |
|
| 10928 |
}
|
- |
|
| 10929 |
}
|
- |
|
| 10930 |
return Optional.none();
|
- |
|
| 10931 |
};
|
- |
|
| 10932 |
return descend(scope);
|
- |
|
| 10933 |
};
|
- |
|
| 10934 |
|
- |
|
| 10935 |
const autocompleteSelector = '[data-mce-autocompleter]';
|
- |
|
| 10936 |
const create$9 = (editor, range) => {
|
- |
|
| 10937 |
if (findIn(SugarElement.fromDom(editor.getBody())).isNone()) {
|
- |
|
| 10938 |
const wrapper = SugarElement.fromHtml('<span data-mce-autocompleter="1" data-mce-bogus="1"></span>', editor.getDoc());
|
- |
|
| 10939 |
append$1(wrapper, SugarElement.fromDom(range.extractContents()));
|
- |
|
| 10940 |
range.insertNode(wrapper.dom);
|
- |
|
| 10941 |
parent(wrapper).each(elm => elm.dom.normalize());
|
- |
|
| 10942 |
last(wrapper).map(last => {
|
- |
|
| 10943 |
editor.selection.setCursorLocation(last.dom, getEnd(last));
|
- |
|
| 10944 |
});
|
- |
|
| 10945 |
}
|
- |
|
| 10946 |
};
|
- |
|
| 10947 |
const detect$1 = elm => closest$3(elm, autocompleteSelector);
|
- |
|
| 10948 |
const findIn = elm => descendant$1(elm, autocompleteSelector);
|
- |
|
| 10949 |
const remove$2 = (editor, elm) => findIn(elm).each(wrapper => {
|
- |
|
| 10950 |
const bookmark = editor.selection.getBookmark();
|
- |
|
| 10951 |
unwrap(wrapper);
|
- |
|
| 10952 |
editor.selection.moveToBookmark(bookmark);
|
- |
|
| 10953 |
});
|
- |
|
| 10954 |
|
11153 |
|
| 10955 |
const typeLookup = {
|
11154 |
const typeLookup = {
|
| 10956 |
'#text': 3,
|
11155 |
'#text': 3,
|
| 10957 |
'#comment': 8,
|
11156 |
'#comment': 8,
|
| 10958 |
'#cdata': 4,
|
11157 |
'#cdata': 4,
|
| Línea 11268... |
Línea 11467... |
| 11268 |
const hasTemporaryNode = (tempAttrs, body) => body.querySelector(getTemporaryNodeSelector(tempAttrs)) !== null;
|
11467 |
const hasTemporaryNode = (tempAttrs, body) => body.querySelector(getTemporaryNodeSelector(tempAttrs)) !== null;
|
| 11269 |
const trimTemporaryNodes = (tempAttrs, body) => {
|
11468 |
const trimTemporaryNodes = (tempAttrs, body) => {
|
| 11270 |
each$e(getTemporaryNodes(tempAttrs, body), elm => {
|
11469 |
each$e(getTemporaryNodes(tempAttrs, body), elm => {
|
| 11271 |
const element = SugarElement.fromDom(elm);
|
11470 |
const element = SugarElement.fromDom(elm);
|
| 11272 |
if (get$9(element, 'data-mce-bogus') === 'all') {
|
11471 |
if (get$9(element, 'data-mce-bogus') === 'all') {
|
| 11273 |
remove$5(element);
|
11472 |
remove$4(element);
|
| 11274 |
} else {
|
11473 |
} else {
|
| 11275 |
each$e(tempAttrs, attr => {
|
11474 |
each$e(tempAttrs, attr => {
|
| 11276 |
if (has$1(element, attr)) {
|
11475 |
if (has$1(element, attr)) {
|
| 11277 |
remove$a(element, attr);
|
11476 |
remove$9(element, attr);
|
| 11278 |
}
|
11477 |
}
|
| 11279 |
});
|
11478 |
});
|
| 11280 |
}
|
11479 |
}
|
| 11281 |
});
|
11480 |
});
|
| 11282 |
};
|
11481 |
};
|
| Línea 11321... |
Línea 11520... |
| 11321 |
const cleanupBogusElements = parent => {
|
11520 |
const cleanupBogusElements = parent => {
|
| 11322 |
const bogusElements = descendants(parent, '[data-mce-bogus]');
|
11521 |
const bogusElements = descendants(parent, '[data-mce-bogus]');
|
| 11323 |
each$e(bogusElements, elem => {
|
11522 |
each$e(bogusElements, elem => {
|
| 11324 |
const bogusValue = get$9(elem, 'data-mce-bogus');
|
11523 |
const bogusValue = get$9(elem, 'data-mce-bogus');
|
| 11325 |
if (bogusValue === 'all') {
|
11524 |
if (bogusValue === 'all') {
|
| 11326 |
remove$5(elem);
|
11525 |
remove$4(elem);
|
| 11327 |
} else if (isBr$5(elem)) {
|
11526 |
} else if (isBr$5(elem)) {
|
| 11328 |
before$3(elem, SugarElement.fromText(zeroWidth));
|
11527 |
before$3(elem, SugarElement.fromText(zeroWidth));
|
| 11329 |
remove$5(elem);
|
11528 |
remove$4(elem);
|
| 11330 |
} else {
|
11529 |
} else {
|
| 11331 |
unwrap(elem);
|
11530 |
unwrap(elem);
|
| 11332 |
}
|
11531 |
}
|
| 11333 |
});
|
11532 |
});
|
| 11334 |
};
|
11533 |
};
|
| 11335 |
const cleanupInputNames = parent => {
|
11534 |
const cleanupInputNames = parent => {
|
| 11336 |
const inputs = descendants(parent, 'input');
|
11535 |
const inputs = descendants(parent, 'input');
|
| 11337 |
each$e(inputs, input => {
|
11536 |
each$e(inputs, input => {
|
| 11338 |
remove$a(input, 'name');
|
11537 |
remove$9(input, 'name');
|
| 11339 |
});
|
11538 |
});
|
| 11340 |
};
|
11539 |
};
|
| Línea 11341... |
Línea 11540... |
| 11341 |
|
11540 |
|
| 11342 |
const trimEmptyContents = (editor, html) => {
|
11541 |
const trimEmptyContents = (editor, html) => {
|
| Línea 11346... |
Línea 11545... |
| 11346 |
};
|
11545 |
};
|
| 11347 |
const getPlainTextContent = (editor, body) => {
|
11546 |
const getPlainTextContent = (editor, body) => {
|
| 11348 |
const doc = editor.getDoc();
|
11547 |
const doc = editor.getDoc();
|
| 11349 |
const dos = getRootNode(SugarElement.fromDom(editor.getBody()));
|
11548 |
const dos = getRootNode(SugarElement.fromDom(editor.getBody()));
|
| 11350 |
const offscreenDiv = SugarElement.fromTag('div', doc);
|
11549 |
const offscreenDiv = SugarElement.fromTag('div', doc);
|
| 11351 |
set$3(offscreenDiv, 'data-mce-bogus', 'all');
|
11550 |
set$4(offscreenDiv, 'data-mce-bogus', 'all');
|
| 11352 |
setAll(offscreenDiv, {
|
11551 |
setAll(offscreenDiv, {
|
| 11353 |
position: 'fixed',
|
11552 |
position: 'fixed',
|
| 11354 |
left: '-9999999px',
|
11553 |
left: '-9999999px',
|
| 11355 |
top: '0'
|
11554 |
top: '0'
|
| 11356 |
});
|
11555 |
});
|
| Línea 11358... |
Línea 11557... |
| 11358 |
cleanupBogusElements(offscreenDiv);
|
11557 |
cleanupBogusElements(offscreenDiv);
|
| 11359 |
cleanupInputNames(offscreenDiv);
|
11558 |
cleanupInputNames(offscreenDiv);
|
| 11360 |
const root = getContentContainer(dos);
|
11559 |
const root = getContentContainer(dos);
|
| 11361 |
append$1(root, offscreenDiv);
|
11560 |
append$1(root, offscreenDiv);
|
| 11362 |
const content = trim$2(offscreenDiv.dom.innerText);
|
11561 |
const content = trim$2(offscreenDiv.dom.innerText);
|
| 11363 |
remove$5(offscreenDiv);
|
11562 |
remove$4(offscreenDiv);
|
| 11364 |
return content;
|
11563 |
return content;
|
| 11365 |
};
|
11564 |
};
|
| 11366 |
const getContentFromBody = (editor, args, body) => {
|
11565 |
const getContentFromBody = (editor, args, body) => {
|
| 11367 |
let content;
|
11566 |
let content;
|
| 11368 |
if (args.format === 'raw') {
|
11567 |
if (args.format === 'raw') {
|
| Línea 11584... |
Línea 11783... |
| 11584 |
'border-style',
|
11783 |
'border-style',
|
| 11585 |
'border-color',
|
11784 |
'border-color',
|
| 11586 |
'background',
|
11785 |
'background',
|
| 11587 |
'background-attachment',
|
11786 |
'background-attachment',
|
| 11588 |
'background-clip',
|
11787 |
'background-clip',
|
| 11589 |
'background-color',
|
- |
|
| 11590 |
'background-image',
|
11788 |
'background-image',
|
| 11591 |
'background-origin',
|
11789 |
'background-origin',
|
| 11592 |
'background-position',
|
11790 |
'background-position',
|
| 11593 |
'background-repeat',
|
11791 |
'background-repeat',
|
| 11594 |
'background-size',
|
11792 |
'background-size',
|
| Línea 11620... |
Línea 11818... |
| 11620 |
];
|
11818 |
];
|
| 11621 |
each$e(nonInheritableStylesArr, style => {
|
11819 |
each$e(nonInheritableStylesArr, style => {
|
| 11622 |
nonInheritableStyles.add(style);
|
11820 |
nonInheritableStyles.add(style);
|
| 11623 |
});
|
11821 |
});
|
| 11624 |
})();
|
11822 |
})();
|
| - |
|
11823 |
const conditionalNonInheritableStyles = new Set();
|
| - |
|
11824 |
(() => {
|
| - |
|
11825 |
const conditionalNonInheritableStylesArr = ['background-color'];
|
| - |
|
11826 |
each$e(conditionalNonInheritableStylesArr, style => {
|
| - |
|
11827 |
conditionalNonInheritableStyles.add(style);
|
| - |
|
11828 |
});
|
| - |
|
11829 |
})();
|
| 11625 |
const shorthandStyleProps = [
|
11830 |
const shorthandStyleProps = [
|
| 11626 |
'font',
|
11831 |
'font',
|
| 11627 |
'text-decoration',
|
11832 |
'text-decoration',
|
| 11628 |
'text-emphasis'
|
11833 |
'text-emphasis'
|
| 11629 |
];
|
11834 |
];
|
| 11630 |
const getStyleProps = (dom, node) => keys(dom.parseStyle(dom.getAttrib(node, 'style')));
|
11835 |
const getStyles$1 = (dom, node) => dom.parseStyle(dom.getAttrib(node, 'style'));
|
| - |
|
11836 |
const getStyleProps = (dom, node) => keys(getStyles$1(dom, node));
|
| 11631 |
const isNonInheritableStyle = style => nonInheritableStyles.has(style);
|
11837 |
const isNonInheritableStyle = style => nonInheritableStyles.has(style);
|
| - |
|
11838 |
const isConditionalNonInheritableStyle = style => conditionalNonInheritableStyles.has(style);
|
| 11632 |
const hasInheritableStyles = (dom, node) => forall(getStyleProps(dom, node), style => !isNonInheritableStyle(style));
|
11839 |
const hasNonInheritableStyles = (dom, node) => exists(getStyleProps(dom, node), style => isNonInheritableStyle(style));
|
| - |
|
11840 |
const hasConditionalNonInheritableStyles = (dom, node) => hasNonInheritableStyles(dom, node) && exists(getStyleProps(dom, node), style => isConditionalNonInheritableStyle(style));
|
| 11633 |
const getLonghandStyleProps = styles => filter$5(styles, style => exists(shorthandStyleProps, prop => startsWith(style, prop)));
|
11841 |
const getLonghandStyleProps = styles => filter$5(styles, style => exists(shorthandStyleProps, prop => startsWith(style, prop)));
|
| 11634 |
const hasStyleConflict = (dom, node, parentNode) => {
|
11842 |
const hasStyleConflict = (dom, node, parentNode) => {
|
| 11635 |
const nodeStyleProps = getStyleProps(dom, node);
|
11843 |
const nodeStyleProps = getStyleProps(dom, node);
|
| 11636 |
const parentNodeStyleProps = getStyleProps(dom, parentNode);
|
11844 |
const parentNodeStyleProps = getStyleProps(dom, parentNode);
|
| 11637 |
const valueMismatch = prop => {
|
11845 |
const valueMismatch = prop => {
|
| Línea 11649... |
Línea 11857... |
| 11649 |
return valueMismatch(nodeStyleProp);
|
11857 |
return valueMismatch(nodeStyleProp);
|
| 11650 |
}
|
11858 |
}
|
| 11651 |
});
|
11859 |
});
|
| 11652 |
};
|
11860 |
};
|
| Línea 11653... |
Línea 11861... |
| 11653 |
|
11861 |
|
| 11654 |
const isChar = (forward, predicate, pos) => Optional.from(pos.container()).filter(isText$a).exists(text => {
|
11862 |
const isChar = (forward, predicate, pos) => Optional.from(pos.container()).filter(isText$b).exists(text => {
|
| 11655 |
const delta = forward ? 0 : -1;
|
11863 |
const delta = forward ? 0 : -1;
|
| 11656 |
return predicate(text.data.charAt(pos.offset() + delta));
|
11864 |
return predicate(text.data.charAt(pos.offset() + delta));
|
| 11657 |
});
|
11865 |
});
|
| 11658 |
const isBeforeSpace = curry(isChar, true, isWhiteSpace);
|
11866 |
const isBeforeSpace = curry(isChar, true, isWhiteSpace);
|
| 11659 |
const isAfterSpace = curry(isChar, false, isWhiteSpace);
|
11867 |
const isAfterSpace = curry(isChar, false, isWhiteSpace);
|
| 11660 |
const isEmptyText = pos => {
|
11868 |
const isEmptyText = pos => {
|
| 11661 |
const container = pos.container();
|
11869 |
const container = pos.container();
|
| 11662 |
return isText$a(container) && (container.data.length === 0 || isZwsp$1(container.data) && BookmarkManager.isBookmarkNode(container.parentNode));
|
11870 |
return isText$b(container) && (container.data.length === 0 || isZwsp(container.data) && BookmarkManager.isBookmarkNode(container.parentNode));
|
| 11663 |
};
|
11871 |
};
|
| 11664 |
const matchesElementPosition = (before, predicate) => pos => getChildNodeAtRelativeOffset(before ? 0 : -1, pos).filter(predicate).isSome();
|
11872 |
const matchesElementPosition = (before, predicate) => pos => getChildNodeAtRelativeOffset(before ? 0 : -1, pos).filter(predicate).isSome();
|
| 11665 |
const isImageBlock = node => isImg(node) && get$7(SugarElement.fromDom(node), 'display') === 'block';
|
11873 |
const isImageBlock = node => isImg(node) && get$7(SugarElement.fromDom(node), 'display') === 'block';
|
| 11666 |
const isCefNode = node => isContentEditableFalse$b(node) && !isBogusAll$1(node);
|
11874 |
const isCefNode = node => isContentEditableFalse$b(node) && !isBogusAll(node);
|
| 11667 |
const isBeforeImageBlock = matchesElementPosition(true, isImageBlock);
|
11875 |
const isBeforeImageBlock = matchesElementPosition(true, isImageBlock);
|
| 11668 |
const isAfterImageBlock = matchesElementPosition(false, isImageBlock);
|
11876 |
const isAfterImageBlock = matchesElementPosition(false, isImageBlock);
|
| 11669 |
const isBeforeMedia = matchesElementPosition(true, isMedia$2);
|
11877 |
const isBeforeMedia = matchesElementPosition(true, isMedia$2);
|
| 11670 |
const isAfterMedia = matchesElementPosition(false, isMedia$2);
|
11878 |
const isAfterMedia = matchesElementPosition(false, isMedia$2);
|
| Línea 11763... |
Línea 11971... |
| 11763 |
}
|
11971 |
}
|
| 11764 |
};
|
11972 |
};
|
| 11765 |
const leanRight = pos => {
|
11973 |
const leanRight = pos => {
|
| 11766 |
const container = pos.container();
|
11974 |
const container = pos.container();
|
| 11767 |
const offset = pos.offset();
|
11975 |
const offset = pos.offset();
|
| 11768 |
if (isText$a(container) && offset < container.data.length) {
|
11976 |
if (isText$b(container) && offset < container.data.length) {
|
| 11769 |
return CaretPosition(container, offset + 1);
|
11977 |
return CaretPosition(container, offset + 1);
|
| 11770 |
} else {
|
11978 |
} else {
|
| 11771 |
return pos;
|
11979 |
return pos;
|
| 11772 |
}
|
11980 |
}
|
| 11773 |
};
|
11981 |
};
|
| Línea 11781... |
Línea 11989... |
| 11781 |
const needsToBeNbsp = (root, pos, schema) => needsToBeNbspLeft(root, pos, schema) || needsToBeNbspRight(root, leanRight(pos), schema);
|
11989 |
const needsToBeNbsp = (root, pos, schema) => needsToBeNbspLeft(root, pos, schema) || needsToBeNbspRight(root, leanRight(pos), schema);
|
| 11782 |
const isNbspAt = (text, offset) => isNbsp(text.charAt(offset));
|
11990 |
const isNbspAt = (text, offset) => isNbsp(text.charAt(offset));
|
| 11783 |
const isWhiteSpaceAt = (text, offset) => isWhiteSpace(text.charAt(offset));
|
11991 |
const isWhiteSpaceAt = (text, offset) => isWhiteSpace(text.charAt(offset));
|
| 11784 |
const hasNbsp = pos => {
|
11992 |
const hasNbsp = pos => {
|
| 11785 |
const container = pos.container();
|
11993 |
const container = pos.container();
|
| 11786 |
return isText$a(container) && contains$1(container.data, nbsp);
|
11994 |
return isText$b(container) && contains$1(container.data, nbsp);
|
| 11787 |
};
|
11995 |
};
|
| 11788 |
const normalizeNbspMiddle = text => {
|
11996 |
const normalizeNbspMiddle = text => {
|
| 11789 |
const chars = text.split('');
|
11997 |
const chars = text.split('');
|
| 11790 |
return map$3(chars, (chr, i) => {
|
11998 |
return map$3(chars, (chr, i) => {
|
| 11791 |
if (isNbsp(chr) && i > 0 && i < chars.length - 1 && isContent(chars[i - 1]) && isContent(chars[i + 1])) {
|
11999 |
if (isNbsp(chr) && i > 0 && i < chars.length - 1 && isContent(chars[i - 1]) && isContent(chars[i + 1])) {
|
| Línea 11829... |
Línea 12037... |
| 11829 |
return true;
|
12037 |
return true;
|
| 11830 |
} else {
|
12038 |
} else {
|
| 11831 |
return false;
|
12039 |
return false;
|
| 11832 |
}
|
12040 |
}
|
| 11833 |
};
|
12041 |
};
|
| 11834 |
const normalizeNbsps = (root, pos, schema) => {
|
12042 |
const normalizeNbsps$1 = (root, pos, schema) => {
|
| 11835 |
const container = pos.container();
|
12043 |
const container = pos.container();
|
| 11836 |
if (!isText$a(container)) {
|
12044 |
if (!isText$b(container)) {
|
| 11837 |
return Optional.none();
|
12045 |
return Optional.none();
|
| 11838 |
}
|
12046 |
}
|
| 11839 |
if (hasNbsp(pos)) {
|
12047 |
if (hasNbsp(pos)) {
|
| 11840 |
const normalized = normalizeNbspAtStart(root, container, false, schema) || normalizeNbspInMiddleOfTextNode(container) || normalizeNbspAtEnd(root, container, false, schema);
|
12048 |
const normalized = normalizeNbspAtStart(root, container, false, schema) || normalizeNbspInMiddleOfTextNode(container) || normalizeNbspAtEnd(root, container, false, schema);
|
| 11841 |
return someIf(normalized, pos);
|
12049 |
return someIf(normalized, pos);
|
| Línea 11847... |
Línea 12055... |
| 11847 |
}
|
12055 |
}
|
| 11848 |
};
|
12056 |
};
|
| 11849 |
const normalizeNbspsInEditor = editor => {
|
12057 |
const normalizeNbspsInEditor = editor => {
|
| 11850 |
const root = SugarElement.fromDom(editor.getBody());
|
12058 |
const root = SugarElement.fromDom(editor.getBody());
|
| 11851 |
if (editor.selection.isCollapsed()) {
|
12059 |
if (editor.selection.isCollapsed()) {
|
| 11852 |
normalizeNbsps(root, CaretPosition.fromRangeStart(editor.selection.getRng()), editor.schema).each(pos => {
|
12060 |
normalizeNbsps$1(root, CaretPosition.fromRangeStart(editor.selection.getRng()), editor.schema).each(pos => {
|
| 11853 |
editor.selection.setRng(pos.toRange());
|
12061 |
editor.selection.setRng(pos.toRange());
|
| 11854 |
});
|
12062 |
});
|
| 11855 |
}
|
12063 |
}
|
| 11856 |
};
|
12064 |
};
|
| Línea 11883... |
Línea 12091... |
| 11883 |
if (mergeToPrev) {
|
12091 |
if (mergeToPrev) {
|
| 11884 |
newNode.appendData(removeNode.data);
|
12092 |
newNode.appendData(removeNode.data);
|
| 11885 |
} else {
|
12093 |
} else {
|
| 11886 |
newNode.insertData(0, removeNode.data);
|
12094 |
newNode.insertData(0, removeNode.data);
|
| 11887 |
}
|
12095 |
}
|
| 11888 |
remove$5(SugarElement.fromDom(removeNode));
|
12096 |
remove$4(SugarElement.fromDom(removeNode));
|
| 11889 |
if (normalizeWhitespace) {
|
12097 |
if (normalizeWhitespace) {
|
| 11890 |
normalizeWhitespaceAfter(newNode, whitespaceOffset, schema);
|
12098 |
normalizeWhitespaceAfter(newNode, whitespaceOffset, schema);
|
| 11891 |
}
|
12099 |
}
|
| 11892 |
return newNode;
|
12100 |
return newNode;
|
| 11893 |
};
|
12101 |
};
|
| Línea 11896... |
Línea 12104... |
| 11896 |
const container = pos.container();
|
12104 |
const container = pos.container();
|
| 11897 |
const offset = pos.offset();
|
12105 |
const offset = pos.offset();
|
| 11898 |
return !CaretPosition.isTextPosition(pos) && container === elm.parentNode && offset > CaretPosition.before(elm).offset();
|
12106 |
return !CaretPosition.isTextPosition(pos) && container === elm.parentNode && offset > CaretPosition.before(elm).offset();
|
| 11899 |
};
|
12107 |
};
|
| 11900 |
const reposition = (elm, pos) => needsReposition(pos, elm) ? CaretPosition(pos.container(), pos.offset() - 1) : pos;
|
12108 |
const reposition = (elm, pos) => needsReposition(pos, elm) ? CaretPosition(pos.container(), pos.offset() - 1) : pos;
|
| 11901 |
const beforeOrStartOf = node => isText$a(node) ? CaretPosition(node, 0) : CaretPosition.before(node);
|
12109 |
const beforeOrStartOf = node => isText$b(node) ? CaretPosition(node, 0) : CaretPosition.before(node);
|
| 11902 |
const afterOrEndOf = node => isText$a(node) ? CaretPosition(node, node.data.length) : CaretPosition.after(node);
|
12110 |
const afterOrEndOf = node => isText$b(node) ? CaretPosition(node, node.data.length) : CaretPosition.after(node);
|
| 11903 |
const getPreviousSiblingCaretPosition = elm => {
|
12111 |
const getPreviousSiblingCaretPosition = elm => {
|
| 11904 |
if (isCaretCandidate$3(elm.previousSibling)) {
|
12112 |
if (isCaretCandidate$3(elm.previousSibling)) {
|
| 11905 |
return Optional.some(afterOrEndOf(elm.previousSibling));
|
12113 |
return Optional.some(afterOrEndOf(elm.previousSibling));
|
| 11906 |
} else {
|
12114 |
} else {
|
| 11907 |
return elm.previousSibling ? lastPositionIn(elm.previousSibling) : Optional.none();
|
12115 |
return elm.previousSibling ? lastPositionIn(elm.previousSibling) : Optional.none();
|
| Línea 11929... |
Línea 12137... |
| 11929 |
editor.selection.setRng(pos.toRange(), forward);
|
12137 |
editor.selection.setRng(pos.toRange(), forward);
|
| 11930 |
});
|
12138 |
});
|
| 11931 |
};
|
12139 |
};
|
| 11932 |
const eqRawNode = rawNode => elm => elm.dom === rawNode;
|
12140 |
const eqRawNode = rawNode => elm => elm.dom === rawNode;
|
| 11933 |
const isBlock = (editor, elm) => elm && has$2(editor.schema.getBlockElements(), name(elm));
|
12141 |
const isBlock = (editor, elm) => elm && has$2(editor.schema.getBlockElements(), name(elm));
|
| 11934 |
const paddEmptyBlock = (elm, preserveEmptyCaret) => {
|
12142 |
const paddEmptyBlock = (schema, elm, preserveEmptyCaret) => {
|
| 11935 |
if (isEmpty$2(elm)) {
|
12143 |
if (isEmpty$2(schema, elm)) {
|
| 11936 |
const br = SugarElement.fromHtml('<br data-mce-bogus="1">');
|
12144 |
const br = SugarElement.fromHtml('<br data-mce-bogus="1">');
|
| 11937 |
if (preserveEmptyCaret) {
|
12145 |
if (preserveEmptyCaret) {
|
| 11938 |
each$e(children$1(elm), node => {
|
12146 |
each$e(children$1(elm), node => {
|
| 11939 |
if (!isEmptyCaretFormatElement(node)) {
|
12147 |
if (!isEmptyCaretFormatElement(node)) {
|
| 11940 |
remove$5(node);
|
12148 |
remove$4(node);
|
| 11941 |
}
|
12149 |
}
|
| 11942 |
});
|
12150 |
});
|
| 11943 |
} else {
|
12151 |
} else {
|
| 11944 |
empty(elm);
|
12152 |
empty(elm);
|
| 11945 |
}
|
12153 |
}
|
| Línea 11948... |
Línea 12156... |
| 11948 |
} else {
|
12156 |
} else {
|
| 11949 |
return Optional.none();
|
12157 |
return Optional.none();
|
| 11950 |
}
|
12158 |
}
|
| 11951 |
};
|
12159 |
};
|
| 11952 |
const deleteNormalized = (elm, afterDeletePosOpt, schema, normalizeWhitespace) => {
|
12160 |
const deleteNormalized = (elm, afterDeletePosOpt, schema, normalizeWhitespace) => {
|
| 11953 |
const prevTextOpt = prevSibling(elm).filter(isText$b);
|
12161 |
const prevTextOpt = prevSibling(elm).filter(isText$c);
|
| 11954 |
const nextTextOpt = nextSibling(elm).filter(isText$b);
|
12162 |
const nextTextOpt = nextSibling(elm).filter(isText$c);
|
| 11955 |
remove$5(elm);
|
12163 |
remove$4(elm);
|
| 11956 |
return lift3(prevTextOpt, nextTextOpt, afterDeletePosOpt, (prev, next, pos) => {
|
12164 |
return lift3(prevTextOpt, nextTextOpt, afterDeletePosOpt, (prev, next, pos) => {
|
| 11957 |
const prevNode = prev.dom, nextNode = next.dom;
|
12165 |
const prevNode = prev.dom, nextNode = next.dom;
|
| 11958 |
const offset = prevNode.data.length;
|
12166 |
const offset = prevNode.data.length;
|
| 11959 |
mergeTextNodes(prevNode, nextNode, schema, normalizeWhitespace);
|
12167 |
mergeTextNodes(prevNode, nextNode, schema, normalizeWhitespace);
|
| 11960 |
return pos.container() === nextNode ? CaretPosition(prevNode, offset) : pos;
|
12168 |
return pos.container() === nextNode ? CaretPosition(prevNode, offset) : pos;
|
| Línea 11973... |
Línea 12181... |
| 11973 |
const normalizedAfterDeletePos = deleteNormalized(elm, afterDeletePos, editor.schema, isInlineElement(editor, elm));
|
12181 |
const normalizedAfterDeletePos = deleteNormalized(elm, afterDeletePos, editor.schema, isInlineElement(editor, elm));
|
| 11974 |
if (editor.dom.isEmpty(editor.getBody())) {
|
12182 |
if (editor.dom.isEmpty(editor.getBody())) {
|
| 11975 |
editor.setContent('');
|
12183 |
editor.setContent('');
|
| 11976 |
editor.selection.setCursorLocation();
|
12184 |
editor.selection.setCursorLocation();
|
| 11977 |
} else {
|
12185 |
} else {
|
| 11978 |
parentBlock.bind(elm => paddEmptyBlock(elm, preserveEmptyCaret)).fold(() => {
|
12186 |
parentBlock.bind(elm => paddEmptyBlock(editor.schema, elm, preserveEmptyCaret)).fold(() => {
|
| 11979 |
if (moveCaret) {
|
12187 |
if (moveCaret) {
|
| 11980 |
setSelection$1(editor, forward, normalizedAfterDeletePos);
|
12188 |
setSelection$1(editor, forward, normalizedAfterDeletePos);
|
| 11981 |
}
|
12189 |
}
|
| 11982 |
}, paddPos => {
|
12190 |
}, paddPos => {
|
| 11983 |
if (moveCaret) {
|
12191 |
if (moveCaret) {
|
| Línea 12008... |
Línea 12216... |
| 12008 |
const isAtZwsp = pos => isBeforeInline(pos) || isAfterInline(pos);
|
12216 |
const isAtZwsp = pos => isBeforeInline(pos) || isAfterInline(pos);
|
| 12009 |
const normalizePosition = (forward, pos) => {
|
12217 |
const normalizePosition = (forward, pos) => {
|
| 12010 |
const container = pos.container(), offset = pos.offset();
|
12218 |
const container = pos.container(), offset = pos.offset();
|
| 12011 |
if (forward) {
|
12219 |
if (forward) {
|
| 12012 |
if (isCaretContainerInline(container)) {
|
12220 |
if (isCaretContainerInline(container)) {
|
| 12013 |
if (isText$a(container.nextSibling)) {
|
12221 |
if (isText$b(container.nextSibling)) {
|
| 12014 |
return CaretPosition(container.nextSibling, 0);
|
12222 |
return CaretPosition(container.nextSibling, 0);
|
| 12015 |
} else {
|
12223 |
} else {
|
| 12016 |
return CaretPosition.after(container);
|
12224 |
return CaretPosition.after(container);
|
| 12017 |
}
|
12225 |
}
|
| 12018 |
} else {
|
12226 |
} else {
|
| 12019 |
return isBeforeInline(pos) ? CaretPosition(container, offset + 1) : pos;
|
12227 |
return isBeforeInline(pos) ? CaretPosition(container, offset + 1) : pos;
|
| 12020 |
}
|
12228 |
}
|
| 12021 |
} else {
|
12229 |
} else {
|
| 12022 |
if (isCaretContainerInline(container)) {
|
12230 |
if (isCaretContainerInline(container)) {
|
| 12023 |
if (isText$a(container.previousSibling)) {
|
12231 |
if (isText$b(container.previousSibling)) {
|
| 12024 |
return CaretPosition(container.previousSibling, container.previousSibling.data.length);
|
12232 |
return CaretPosition(container.previousSibling, container.previousSibling.data.length);
|
| 12025 |
} else {
|
12233 |
} else {
|
| 12026 |
return CaretPosition.before(container);
|
12234 |
return CaretPosition.before(container);
|
| 12027 |
}
|
12235 |
}
|
| 12028 |
} else {
|
12236 |
} else {
|
| Línea 12077... |
Línea 12285... |
| 12077 |
rng.deleteContents();
|
12285 |
rng.deleteContents();
|
| 12078 |
const lastNode = freefallRtl(root).getOr(root);
|
12286 |
const lastNode = freefallRtl(root).getOr(root);
|
| 12079 |
const lastBlock = SugarElement.fromDom((_a = editor.dom.getParent(lastNode.dom, editor.dom.isBlock)) !== null && _a !== void 0 ? _a : root.dom);
|
12287 |
const lastBlock = SugarElement.fromDom((_a = editor.dom.getParent(lastNode.dom, editor.dom.isBlock)) !== null && _a !== void 0 ? _a : root.dom);
|
| 12080 |
if (lastBlock.dom === editor.getBody()) {
|
12288 |
if (lastBlock.dom === editor.getBody()) {
|
| 12081 |
paddEmptyBody(editor, moveSelection);
|
12289 |
paddEmptyBody(editor, moveSelection);
|
| 12082 |
} else if (isEmpty$2(lastBlock)) {
|
12290 |
} else if (isEmpty$2(editor.schema, lastBlock, { checkRootAsContent: false })) {
|
| 12083 |
fillWithPaddingBr(lastBlock);
|
12291 |
fillWithPaddingBr(lastBlock);
|
| 12084 |
if (moveSelection) {
|
12292 |
if (moveSelection) {
|
| 12085 |
editor.selection.setCursorLocation(lastBlock.dom, 0);
|
12293 |
editor.selection.setCursorLocation(lastBlock.dom, 0);
|
| 12086 |
}
|
12294 |
}
|
| 12087 |
}
|
12295 |
}
|
| 12088 |
if (!eq(root, lastBlock)) {
|
12296 |
if (!eq(root, lastBlock)) {
|
| 12089 |
const additionalCleanupNodes = is$2(parent(lastBlock), root) ? [] : siblings(lastBlock);
|
12297 |
const additionalCleanupNodes = is$2(parent(lastBlock), root) ? [] : siblings(lastBlock);
|
| 12090 |
each$e(additionalCleanupNodes.concat(children$1(root)), node => {
|
12298 |
each$e(additionalCleanupNodes.concat(children$1(root)), node => {
|
| 12091 |
if (!eq(node, lastBlock) && !contains(node, lastBlock) && isEmpty$2(node)) {
|
12299 |
if (!eq(node, lastBlock) && !contains(node, lastBlock) && isEmpty$2(editor.schema, node)) {
|
| 12092 |
remove$5(node);
|
12300 |
remove$4(node);
|
| 12093 |
}
|
12301 |
}
|
| 12094 |
});
|
12302 |
});
|
| 12095 |
}
|
12303 |
}
|
| 12096 |
};
|
12304 |
};
|
| Línea 12097... |
Línea -... |
| 12097 |
|
- |
|
| 12098 |
const ancestor$1 = (scope, predicate, isRoot) => ancestor$4(scope, predicate, isRoot).isSome();
|
- |
|
| 12099 |
const sibling = (scope, predicate) => sibling$1(scope, predicate).isSome();
|
- |
|
| 12100 |
const descendant = (scope, predicate) => descendant$2(scope, predicate).isSome();
|
- |
|
| 12101 |
|
12305 |
|
| 12102 |
const isRootFromElement = root => cur => eq(root, cur);
|
12306 |
const isRootFromElement = root => cur => eq(root, cur);
|
| 12103 |
const getTableCells = table => descendants(table, 'td,th');
|
12307 |
const getTableCells = table => descendants(table, 'td,th');
|
| 12104 |
const getTable$1 = (node, isRoot) => getClosestTable(SugarElement.fromDom(node), isRoot);
|
12308 |
const getTable$1 = (node, isRoot) => getClosestTable(SugarElement.fromDom(node), isRoot);
|
| 12105 |
const selectionInTableWithNestedTable = details => {
|
12309 |
const selectionInTableWithNestedTable = details => {
|
| Línea 12176... |
Línea 12380... |
| 12176 |
const getCellRng = (rng, isRoot) => {
|
12380 |
const getCellRng = (rng, isRoot) => {
|
| 12177 |
const startCell = getClosestCell$1(rng.startContainer, isRoot);
|
12381 |
const startCell = getClosestCell$1(rng.startContainer, isRoot);
|
| 12178 |
const endCell = getClosestCell$1(rng.endContainer, isRoot);
|
12382 |
const endCell = getClosestCell$1(rng.endContainer, isRoot);
|
| 12179 |
return lift2(startCell, endCell, tableCellRng);
|
12383 |
return lift2(startCell, endCell, tableCellRng);
|
| 12180 |
};
|
12384 |
};
|
| 12181 |
const getCellRangeFromStartTable = isRoot => startCell => getClosestTable(startCell, isRoot).bind(table => last$3(getTableCells(table)).map(endCell => tableCellRng(startCell, endCell)));
|
12385 |
const getCellRangeFromStartTable = isRoot => startCell => getClosestTable(startCell, isRoot).bind(table => last$2(getTableCells(table)).map(endCell => tableCellRng(startCell, endCell)));
|
| 12182 |
const getCellRangeFromEndTable = isRoot => endCell => getClosestTable(endCell, isRoot).bind(table => head(getTableCells(table)).map(startCell => tableCellRng(startCell, endCell)));
|
12386 |
const getCellRangeFromEndTable = isRoot => endCell => getClosestTable(endCell, isRoot).bind(table => head(getTableCells(table)).map(startCell => tableCellRng(startCell, endCell)));
|
| 12183 |
const getTableSelectionFromCellRng = isRoot => cellRng => getTableFromCellRng(cellRng, isRoot).map(table => tableSelection(cellRng, table, getTableCells(table)));
|
12387 |
const getTableSelectionFromCellRng = isRoot => cellRng => getTableFromCellRng(cellRng, isRoot).map(table => tableSelection(cellRng, table, getTableCells(table)));
|
| 12184 |
const getTableSelections = (cellRng, selectionDetails, rng, isRoot) => {
|
12388 |
const getTableSelections = (cellRng, selectionDetails, rng, isRoot) => {
|
| 12185 |
if (rng.collapsed || !cellRng.forall(isExpandedCellRng)) {
|
12389 |
if (rng.collapsed || !cellRng.forall(isExpandedCellRng)) {
|
| 12186 |
return Optional.none();
|
12390 |
return Optional.none();
|
| Línea 12252... |
Línea 12456... |
| 12252 |
return handleSingleTable(optCellRng, selectionDetails, rng, isRoot);
|
12456 |
return handleSingleTable(optCellRng, selectionDetails, rng, isRoot);
|
| 12253 |
}
|
12457 |
}
|
| 12254 |
};
|
12458 |
};
|
| Línea 12255... |
Línea 12459... |
| 12255 |
|
12459 |
|
| 12256 |
const cleanCells = cells => each$e(cells, cell => {
|
12460 |
const cleanCells = cells => each$e(cells, cell => {
|
| 12257 |
remove$a(cell, 'contenteditable');
|
12461 |
remove$9(cell, 'contenteditable');
|
| 12258 |
fillWithPaddingBr(cell);
|
12462 |
fillWithPaddingBr(cell);
|
| 12259 |
});
|
12463 |
});
|
| 12260 |
const getOutsideBlock = (editor, container) => Optional.from(editor.dom.getParent(container, editor.dom.isBlock)).map(SugarElement.fromDom);
|
12464 |
const getOutsideBlock = (editor, container) => Optional.from(editor.dom.getParent(container, editor.dom.isBlock)).map(SugarElement.fromDom);
|
| 12261 |
const handleEmptyBlock = (editor, startInTable, emptyBlock) => {
|
12465 |
const handleEmptyBlock = (editor, startInTable, emptyBlock) => {
|
| 12262 |
emptyBlock.each(block => {
|
12466 |
emptyBlock.each(block => {
|
| 12263 |
if (startInTable) {
|
12467 |
if (startInTable) {
|
| 12264 |
remove$5(block);
|
12468 |
remove$4(block);
|
| 12265 |
} else {
|
12469 |
} else {
|
| 12266 |
fillWithPaddingBr(block);
|
12470 |
fillWithPaddingBr(block);
|
| 12267 |
editor.selection.setCursorLocation(block.dom, 0);
|
12471 |
editor.selection.setCursorLocation(block.dom, 0);
|
| 12268 |
}
|
12472 |
}
|
| Línea 12280... |
Línea 12484... |
| 12280 |
deleteCellContents(editor, insideTableRng, cell, false).each(action => action());
|
12484 |
deleteCellContents(editor, insideTableRng, cell, false).each(action => action());
|
| 12281 |
};
|
12485 |
};
|
| 12282 |
const collapseAndRestoreCellSelection = editor => {
|
12486 |
const collapseAndRestoreCellSelection = editor => {
|
| 12283 |
const selectedCells = getCellsFromEditor(editor);
|
12487 |
const selectedCells = getCellsFromEditor(editor);
|
| 12284 |
const selectedNode = SugarElement.fromDom(editor.selection.getNode());
|
12488 |
const selectedNode = SugarElement.fromDom(editor.selection.getNode());
|
| 12285 |
if (isTableCell$3(selectedNode.dom) && isEmpty$2(selectedNode)) {
|
12489 |
if (isTableCell$3(selectedNode.dom) && isEmpty$2(editor.schema, selectedNode)) {
|
| 12286 |
editor.selection.setCursorLocation(selectedNode.dom, 0);
|
12490 |
editor.selection.setCursorLocation(selectedNode.dom, 0);
|
| 12287 |
} else {
|
12491 |
} else {
|
| 12288 |
editor.selection.collapse(true);
|
12492 |
editor.selection.collapse(true);
|
| 12289 |
}
|
12493 |
}
|
| 12290 |
if (selectedCells.length > 1 && exists(selectedCells, cell => eq(cell, selectedNode))) {
|
12494 |
if (selectedCells.length > 1 && exists(selectedCells, cell => eq(cell, selectedNode))) {
|
| 12291 |
set$3(selectedNode, 'data-mce-selected', '1');
|
12495 |
set$4(selectedNode, 'data-mce-selected', '1');
|
| 12292 |
}
|
12496 |
}
|
| 12293 |
};
|
12497 |
};
|
| 12294 |
const emptySingleTableCells = (editor, cells, outsideDetails) => Optional.some(() => {
|
12498 |
const emptySingleTableCells = (editor, cells, outsideDetails) => Optional.some(() => {
|
| 12295 |
const editorRng = editor.selection.getRng();
|
12499 |
const editorRng = editor.selection.getRng();
|
| 12296 |
const cellsToClean = outsideDetails.bind(({rng, isStartInTable}) => {
|
12500 |
const cellsToClean = outsideDetails.bind(({rng, isStartInTable}) => {
|
| 12297 |
const outsideBlock = getOutsideBlock(editor, isStartInTable ? rng.endContainer : rng.startContainer);
|
12501 |
const outsideBlock = getOutsideBlock(editor, isStartInTable ? rng.endContainer : rng.startContainer);
|
| 12298 |
rng.deleteContents();
|
12502 |
rng.deleteContents();
|
| 12299 |
handleEmptyBlock(editor, isStartInTable, outsideBlock.filter(isEmpty$2));
|
12503 |
handleEmptyBlock(editor, isStartInTable, outsideBlock.filter(curry(isEmpty$2, editor.schema)));
|
| 12300 |
const endPointCell = isStartInTable ? cells[0] : cells[cells.length - 1];
|
12504 |
const endPointCell = isStartInTable ? cells[0] : cells[cells.length - 1];
|
| 12301 |
deleteContentInsideCell(editor, endPointCell, editorRng, isStartInTable);
|
12505 |
deleteContentInsideCell(editor, endPointCell, editorRng, isStartInTable);
|
| 12302 |
if (!isEmpty$2(endPointCell)) {
|
12506 |
if (!isEmpty$2(editor.schema, endPointCell)) {
|
| 12303 |
return Optional.some(isStartInTable ? cells.slice(1) : cells.slice(0, -1));
|
12507 |
return Optional.some(isStartInTable ? cells.slice(1) : cells.slice(0, -1));
|
| 12304 |
} else {
|
12508 |
} else {
|
| 12305 |
return Optional.none();
|
12509 |
return Optional.none();
|
| 12306 |
}
|
12510 |
}
|
| 12307 |
}).getOr(cells);
|
12511 |
}).getOr(cells);
|
| Línea 12312... |
Línea 12516... |
| 12312 |
const rng = editor.selection.getRng();
|
12516 |
const rng = editor.selection.getRng();
|
| 12313 |
const startCell = startTableCells[0];
|
12517 |
const startCell = startTableCells[0];
|
| 12314 |
const endCell = endTableCells[endTableCells.length - 1];
|
12518 |
const endCell = endTableCells[endTableCells.length - 1];
|
| 12315 |
deleteContentInsideCell(editor, startCell, rng, true);
|
12519 |
deleteContentInsideCell(editor, startCell, rng, true);
|
| 12316 |
deleteContentInsideCell(editor, endCell, rng, false);
|
12520 |
deleteContentInsideCell(editor, endCell, rng, false);
|
| 12317 |
const startTableCellsToClean = isEmpty$2(startCell) ? startTableCells : startTableCells.slice(1);
|
12521 |
const startTableCellsToClean = isEmpty$2(editor.schema, startCell) ? startTableCells : startTableCells.slice(1);
|
| 12318 |
const endTableCellsToClean = isEmpty$2(endCell) ? endTableCells : endTableCells.slice(0, -1);
|
12522 |
const endTableCellsToClean = isEmpty$2(editor.schema, endCell) ? endTableCells : endTableCells.slice(0, -1);
|
| 12319 |
cleanCells(startTableCellsToClean.concat(endTableCellsToClean));
|
12523 |
cleanCells(startTableCellsToClean.concat(endTableCellsToClean));
|
| 12320 |
betweenRng.deleteContents();
|
12524 |
betweenRng.deleteContents();
|
| 12321 |
collapseAndRestoreCellSelection(editor);
|
12525 |
collapseAndRestoreCellSelection(editor);
|
| 12322 |
});
|
12526 |
});
|
| 12323 |
const deleteCellContents = (editor, rng, cell, moveSelection = true) => Optional.some(() => {
|
12527 |
const deleteCellContents = (editor, rng, cell, moveSelection = true) => Optional.some(() => {
|
| Línea 12343... |
Línea 12547... |
| 12343 |
const emptyCaretCaption = (editor, elm) => emptyElement(editor, elm);
|
12547 |
const emptyCaretCaption = (editor, elm) => emptyElement(editor, elm);
|
| 12344 |
const validateCaretCaption = (rootElm, fromCaption, to) => getParentCaption(rootElm, SugarElement.fromDom(to.getNode())).fold(() => Optional.some(noop), toCaption => someIf(!eq(toCaption, fromCaption), noop));
|
12548 |
const validateCaretCaption = (rootElm, fromCaption, to) => getParentCaption(rootElm, SugarElement.fromDom(to.getNode())).fold(() => Optional.some(noop), toCaption => someIf(!eq(toCaption, fromCaption), noop));
|
| 12345 |
const deleteCaretInsideCaption = (editor, rootElm, forward, fromCaption, from) => navigate(forward, editor.getBody(), from).fold(() => Optional.some(noop), to => isDeleteOfLastCharPos(fromCaption, forward, from, to) ? emptyCaretCaption(editor, fromCaption) : validateCaretCaption(rootElm, fromCaption, to));
|
12549 |
const deleteCaretInsideCaption = (editor, rootElm, forward, fromCaption, from) => navigate(forward, editor.getBody(), from).fold(() => Optional.some(noop), to => isDeleteOfLastCharPos(fromCaption, forward, from, to) ? emptyCaretCaption(editor, fromCaption) : validateCaretCaption(rootElm, fromCaption, to));
|
| 12346 |
const deleteCaretCells = (editor, forward, rootElm, startElm) => {
|
12550 |
const deleteCaretCells = (editor, forward, rootElm, startElm) => {
|
| 12347 |
const from = CaretPosition.fromRangeStart(editor.selection.getRng());
|
12551 |
const from = CaretPosition.fromRangeStart(editor.selection.getRng());
|
| 12348 |
return getParentCell(rootElm, startElm).bind(fromCell => isEmpty$2(fromCell) ? emptyElement(editor, fromCell) : deleteBetweenCells(editor, rootElm, forward, fromCell, from));
|
12552 |
return getParentCell(rootElm, startElm).bind(fromCell => isEmpty$2(editor.schema, fromCell, { checkRootAsContent: false }) ? emptyElement(editor, fromCell) : deleteBetweenCells(editor, rootElm, forward, fromCell, from));
|
| 12349 |
};
|
12553 |
};
|
| 12350 |
const deleteCaretCaption = (editor, forward, rootElm, fromCaption) => {
|
12554 |
const deleteCaretCaption = (editor, forward, rootElm, fromCaption) => {
|
| 12351 |
const from = CaretPosition.fromRangeStart(editor.selection.getRng());
|
12555 |
const from = CaretPosition.fromRangeStart(editor.selection.getRng());
|
| 12352 |
return isEmpty$2(fromCaption) ? emptyElement(editor, fromCaption) : deleteCaretInsideCaption(editor, rootElm, forward, fromCaption, from);
|
12556 |
return isEmpty$2(editor.schema, fromCaption) ? emptyElement(editor, fromCaption) : deleteCaretInsideCaption(editor, rootElm, forward, fromCaption, from);
|
| 12353 |
};
|
12557 |
};
|
| 12354 |
const isNearTable = (forward, pos) => forward ? isBeforeTable(pos) : isAfterTable(pos);
|
12558 |
const isNearTable = (forward, pos) => forward ? isBeforeTable(pos) : isAfterTable(pos);
|
| 12355 |
const isBeforeOrAfterTable = (editor, forward) => {
|
12559 |
const isBeforeOrAfterTable = (editor, forward) => {
|
| 12356 |
const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());
|
12560 |
const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());
|
| 12357 |
return isNearTable(forward, fromPos) || fromPosition(forward, editor.getBody(), fromPos).exists(pos => isNearTable(forward, pos));
|
12561 |
return isNearTable(forward, fromPos) || fromPosition(forward, editor.getBody(), fromPos).exists(pos => isNearTable(forward, pos));
|
| 12358 |
};
|
12562 |
};
|
| 12359 |
const deleteCaret$3 = (editor, forward, startElm) => {
|
12563 |
const deleteCaret$3 = (editor, forward, startElm) => {
|
| 12360 |
const rootElm = SugarElement.fromDom(editor.getBody());
|
12564 |
const rootElm = SugarElement.fromDom(editor.getBody());
|
| 12361 |
return getParentCaption(rootElm, startElm).fold(() => deleteCaretCells(editor, forward, rootElm, startElm).orThunk(() => someIf(isBeforeOrAfterTable(editor, forward), noop)), fromCaption => deleteCaretCaption(editor, forward, rootElm, fromCaption));
|
12565 |
return getParentCaption(rootElm, startElm).fold(() => deleteCaretCells(editor, forward, rootElm, startElm).orThunk(() => someIf(isBeforeOrAfterTable(editor, forward), noop)), fromCaption => deleteCaretCaption(editor, forward, rootElm, fromCaption));
|
| 12362 |
};
|
12566 |
};
|
| 12363 |
const backspaceDelete$a = (editor, forward) => {
|
12567 |
const backspaceDelete$b = (editor, forward) => {
|
| 12364 |
const startElm = SugarElement.fromDom(editor.selection.getStart(true));
|
12568 |
const startElm = SugarElement.fromDom(editor.selection.getStart(true));
|
| 12365 |
const cells = getCellsFromEditor(editor);
|
12569 |
const cells = getCellsFromEditor(editor);
|
| 12366 |
return editor.selection.isCollapsed() && cells.length === 0 ? deleteCaret$3(editor, forward, startElm) : deleteRange$3(editor, startElm, cells);
|
12570 |
return editor.selection.isCollapsed() && cells.length === 0 ? deleteCaret$3(editor, forward, startElm) : deleteRange$3(editor, startElm, cells);
|
| 12367 |
};
|
12571 |
};
|
| Línea 12889... |
Línea 13093... |
| 12889 |
return cell === endCell && hasAllContentsSelected(SugarElement.fromDom(cell), rng);
|
13093 |
return cell === endCell && hasAllContentsSelected(SugarElement.fromDom(cell), rng);
|
| 12890 |
} else {
|
13094 |
} else {
|
| 12891 |
return false;
|
13095 |
return false;
|
| 12892 |
}
|
13096 |
}
|
| 12893 |
};
|
13097 |
};
|
| - |
|
13098 |
const isEditableEmptyBlock = (dom, node) => {
|
| - |
|
13099 |
if (dom.isBlock(node) && dom.isEditable(node)) {
|
| - |
|
13100 |
const childNodes = node.childNodes;
|
| - |
|
13101 |
return childNodes.length === 1 && isBr$6(childNodes[0]) || childNodes.length === 0;
|
| - |
|
13102 |
} else {
|
| - |
|
13103 |
return false;
|
| - |
|
13104 |
}
|
| - |
|
13105 |
};
|
| 12894 |
const validInsertion = (editor, value, parentNode) => {
|
13106 |
const validInsertion = (editor, value, parentNode) => {
|
| 12895 |
var _a;
|
13107 |
var _a;
|
| 12896 |
if (parentNode.getAttribute('data-mce-bogus') === 'all') {
|
13108 |
if (parentNode.getAttribute('data-mce-bogus') === 'all') {
|
| 12897 |
(_a = parentNode.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(editor.dom.createFragment(value), parentNode);
|
13109 |
(_a = parentNode.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(editor.dom.createFragment(value), parentNode);
|
| 12898 |
} else {
|
13110 |
} else {
|
| 12899 |
const node = parentNode.firstChild;
|
- |
|
| 12900 |
const node2 = parentNode.lastChild;
|
- |
|
| 12901 |
if (!node || node === node2 && node.nodeName === 'BR') {
|
13111 |
if (isEditableEmptyBlock(editor.dom, parentNode)) {
|
| 12902 |
editor.dom.setHTML(parentNode, value);
|
13112 |
editor.dom.setHTML(parentNode, value);
|
| 12903 |
} else {
|
13113 |
} else {
|
| 12904 |
editor.selection.setContent(value, { no_events: true });
|
13114 |
editor.selection.setContent(value, { no_events: true });
|
| 12905 |
}
|
13115 |
}
|
| 12906 |
}
|
13116 |
}
|
| Línea 12912... |
Línea 13122... |
| 12912 |
const textInlineElements = editor.schema.getTextInlineElements();
|
13122 |
const textInlineElements = editor.schema.getTextInlineElements();
|
| 12913 |
const dom = editor.dom;
|
13123 |
const dom = editor.dom;
|
| 12914 |
if (merge) {
|
13124 |
if (merge) {
|
| 12915 |
const root = editor.getBody();
|
13125 |
const root = editor.getBody();
|
| 12916 |
const elementUtils = ElementUtils(editor);
|
13126 |
const elementUtils = ElementUtils(editor);
|
| - |
|
13127 |
const fragmentSelector = '*[data-mce-fragment]';
|
| - |
|
13128 |
const fragments = dom.select(fragmentSelector);
|
| 12917 |
Tools.each(dom.select('*[data-mce-fragment]'), node => {
|
13129 |
Tools.each(fragments, node => {
|
| 12918 |
const isInline = isNonNullable(textInlineElements[node.nodeName.toLowerCase()]);
|
13130 |
const isInline = currentNode => isNonNullable(textInlineElements[currentNode.nodeName.toLowerCase()]);
|
| 12919 |
if (isInline && hasInheritableStyles(dom, node)) {
|
13131 |
const hasOneChild = currentNode => currentNode.childNodes.length === 1;
|
| 12920 |
for (let parentNode = node.parentElement; isNonNullable(parentNode) && parentNode !== root; parentNode = parentNode.parentElement) {
|
13132 |
const hasNoNonInheritableStyles = currentNode => !(hasNonInheritableStyles(dom, currentNode) || hasConditionalNonInheritableStyles(dom, currentNode));
|
| 12921 |
const styleConflict = hasStyleConflict(dom, node, parentNode);
|
13133 |
if (hasNoNonInheritableStyles(node) && isInline(node) && hasOneChild(node)) {
|
| 12922 |
if (styleConflict) {
|
13134 |
const styles = getStyleProps(dom, node);
|
| 12923 |
break;
|
13135 |
const isOverridden = (oldStyles, newStyles) => forall(oldStyles, style => contains$2(newStyles, style));
|
| 12924 |
}
|
13136 |
const overriddenByAllChildren = childNode => hasOneChild(node) && dom.is(childNode, fragmentSelector) && isInline(childNode) && (childNode.nodeName === node.nodeName && isOverridden(styles, getStyleProps(dom, childNode)) || overriddenByAllChildren(childNode.children[0]));
|
| - |
|
13137 |
const identicalToParent = parentNode => isNonNullable(parentNode) && parentNode !== root && (elementUtils.compare(node, parentNode) || identicalToParent(parentNode.parentElement));
|
| - |
|
13138 |
const conflictWithInsertedParent = parentNode => isNonNullable(parentNode) && parentNode !== root && dom.is(parentNode, fragmentSelector) && (hasStyleConflict(dom, node, parentNode) || conflictWithInsertedParent(parentNode.parentElement));
|
| 12925 |
if (elementUtils.compare(parentNode, node)) {
|
13139 |
if (overriddenByAllChildren(node.children[0]) || identicalToParent(node.parentElement) && !conflictWithInsertedParent(node.parentElement)) {
|
| 12926 |
dom.remove(node, true);
|
13140 |
dom.remove(node, true);
|
| 12927 |
break;
|
- |
|
| 12928 |
}
|
- |
|
| 12929 |
}
|
13141 |
}
|
| 12930 |
}
|
13142 |
}
|
| 12931 |
});
|
13143 |
});
|
| 12932 |
}
|
13144 |
}
|
| 12933 |
};
|
13145 |
};
|
| Línea 12965... |
Línea 13177... |
| 12965 |
selection.select(parentEditableElm);
|
13177 |
selection.select(parentEditableElm);
|
| 12966 |
return;
|
13178 |
return;
|
| 12967 |
}
|
13179 |
}
|
| 12968 |
let rng = dom.createRng();
|
13180 |
let rng = dom.createRng();
|
| 12969 |
const node = marker.previousSibling;
|
13181 |
const node = marker.previousSibling;
|
| 12970 |
if (isText$a(node)) {
|
13182 |
if (isText$b(node)) {
|
| 12971 |
rng.setStart(node, (_b = (_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
|
13183 |
rng.setStart(node, (_b = (_a = node.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0);
|
| 12972 |
const node2 = marker.nextSibling;
|
13184 |
const node2 = marker.nextSibling;
|
| 12973 |
if (isText$a(node2)) {
|
13185 |
if (isText$b(node2)) {
|
| 12974 |
node.appendData(node2.data);
|
13186 |
node.appendData(node2.data);
|
| 12975 |
(_c = node2.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(node2);
|
13187 |
(_c = node2.parentNode) === null || _c === void 0 ? void 0 : _c.removeChild(node2);
|
| 12976 |
}
|
13188 |
}
|
| 12977 |
} else {
|
13189 |
} else {
|
| 12978 |
rng.setStartBefore(marker);
|
13190 |
rng.setStartBefore(marker);
|
| Línea 13005... |
Línea 13217... |
| 13005 |
const rng = normalize(editor.selection.getRng());
|
13217 |
const rng = normalize(editor.selection.getRng());
|
| 13006 |
editor.selection.setRng(rng);
|
13218 |
editor.selection.setRng(rng);
|
| 13007 |
const startCell = dom.getParent(rng.startContainer, isTableCell);
|
13219 |
const startCell = dom.getParent(rng.startContainer, isTableCell);
|
| 13008 |
if (isTableCellContentSelected(dom, rng, startCell)) {
|
13220 |
if (isTableCellContentSelected(dom, rng, startCell)) {
|
| 13009 |
deleteCellContents(editor, rng, SugarElement.fromDom(startCell));
|
13221 |
deleteCellContents(editor, rng, SugarElement.fromDom(startCell));
|
| 13010 |
} else if (rng.startContainer === rng.endContainer && rng.endOffset - rng.startOffset === 1 && isText$a(rng.startContainer.childNodes[rng.startOffset])) {
|
13222 |
} else if (rng.startContainer === rng.endContainer && rng.endOffset - rng.startOffset === 1 && isText$b(rng.startContainer.childNodes[rng.startOffset])) {
|
| 13011 |
rng.deleteContents();
|
13223 |
rng.deleteContents();
|
| 13012 |
} else {
|
13224 |
} else {
|
| 13013 |
editor.getDoc().execCommand('Delete', false);
|
13225 |
editor.getDoc().execCommand('Delete', false);
|
| 13014 |
}
|
13226 |
}
|
| 13015 |
};
|
13227 |
};
|
| Línea 13074... |
Línea 13286... |
| 13074 |
markFragmentElements(fragment);
|
13286 |
markFragmentElements(fragment);
|
| 13075 |
let node = fragment.lastChild;
|
13287 |
let node = fragment.lastChild;
|
| 13076 |
if (node && node.attr('id') === 'mce_marker') {
|
13288 |
if (node && node.attr('id') === 'mce_marker') {
|
| 13077 |
const marker = node;
|
13289 |
const marker = node;
|
| 13078 |
for (node = node.prev; node; node = node.walk(true)) {
|
13290 |
for (node = node.prev; node; node = node.walk(true)) {
|
| - |
|
13291 |
if (node.name === 'table') {
|
| - |
|
13292 |
break;
|
| - |
|
13293 |
}
|
| 13079 |
if (node.type === 3 || !dom.isBlock(node.name)) {
|
13294 |
if (node.type === 3 || !dom.isBlock(node.name)) {
|
| 13080 |
if (node.parent && editor.schema.isValidChild(node.parent.name, 'span')) {
|
13295 |
if (node.parent && editor.schema.isValidChild(node.parent.name, 'span')) {
|
| 13081 |
node.parent.insert(marker, node, node.name === 'br');
|
13296 |
node.parent.insert(marker, node, node.name === 'br');
|
| 13082 |
}
|
13297 |
}
|
| 13083 |
break;
|
13298 |
break;
|
| Línea 13390... |
Línea 13605... |
| 13390 |
};
|
13605 |
};
|
| 13391 |
const findFirstTextNode = node => {
|
13606 |
const findFirstTextNode = node => {
|
| 13392 |
if (node) {
|
13607 |
if (node) {
|
| 13393 |
const walker = new DomTreeWalker(node, node);
|
13608 |
const walker = new DomTreeWalker(node, node);
|
| 13394 |
for (let tempNode = walker.current(); tempNode; tempNode = walker.next()) {
|
13609 |
for (let tempNode = walker.current(); tempNode; tempNode = walker.next()) {
|
| 13395 |
if (isText$a(tempNode)) {
|
13610 |
if (isText$b(tempNode)) {
|
| 13396 |
return tempNode;
|
13611 |
return tempNode;
|
| 13397 |
}
|
13612 |
}
|
| 13398 |
}
|
13613 |
}
|
| 13399 |
}
|
13614 |
}
|
| 13400 |
return null;
|
13615 |
return null;
|
| Línea 13497... |
Línea 13712... |
| 13497 |
return Optional.some(clonedFormatNode);
|
13712 |
return Optional.some(clonedFormatNode);
|
| 13498 |
} else {
|
13713 |
} else {
|
| 13499 |
return Optional.none();
|
13714 |
return Optional.none();
|
| 13500 |
}
|
13715 |
}
|
| 13501 |
};
|
13716 |
};
|
| - |
|
13717 |
const normalizeNbsps = node => set(node, get$3(node).replace(new RegExp(`${ nbsp }$`), ' '));
|
| - |
|
13718 |
const normalizeNbspsBetween = (editor, caretContainer) => {
|
| - |
|
13719 |
const handler = () => {
|
| - |
|
13720 |
if (caretContainer !== null && !editor.dom.isEmpty(caretContainer)) {
|
| - |
|
13721 |
prevSibling(SugarElement.fromDom(caretContainer)).each(node => {
|
| - |
|
13722 |
if (isText$c(node)) {
|
| - |
|
13723 |
normalizeNbsps(node);
|
| - |
|
13724 |
} else {
|
| - |
|
13725 |
descendant$2(node, e => isText$c(e)).each(textNode => {
|
| - |
|
13726 |
if (isText$c(textNode)) {
|
| - |
|
13727 |
normalizeNbsps(textNode);
|
| - |
|
13728 |
}
|
| - |
|
13729 |
});
|
| - |
|
13730 |
}
|
| - |
|
13731 |
});
|
| - |
|
13732 |
}
|
| - |
|
13733 |
};
|
| - |
|
13734 |
editor.once('input', e => {
|
| - |
|
13735 |
if (e.data && !isWhiteSpace(e.data)) {
|
| - |
|
13736 |
if (!e.isComposing) {
|
| - |
|
13737 |
handler();
|
| - |
|
13738 |
} else {
|
| - |
|
13739 |
editor.once('compositionend', () => {
|
| - |
|
13740 |
handler();
|
| - |
|
13741 |
});
|
| - |
|
13742 |
}
|
| - |
|
13743 |
}
|
| - |
|
13744 |
});
|
| - |
|
13745 |
};
|
| 13502 |
const applyCaretFormat = (editor, name, vars) => {
|
13746 |
const applyCaretFormat = (editor, name, vars) => {
|
| 13503 |
let caretContainer;
|
13747 |
let caretContainer;
|
| 13504 |
const selection = editor.selection;
|
13748 |
const selection = editor.selection;
|
| 13505 |
const formatList = editor.formatter.get(name);
|
13749 |
const formatList = editor.formatter.get(name);
|
| 13506 |
if (!formatList) {
|
13750 |
if (!formatList) {
|
| Línea 13524... |
Línea 13768... |
| 13524 |
if (!caretContainer || (textNode === null || textNode === void 0 ? void 0 : textNode.data) !== ZWSP) {
|
13768 |
if (!caretContainer || (textNode === null || textNode === void 0 ? void 0 : textNode.data) !== ZWSP) {
|
| 13525 |
caretContainer = importNode(editor.getDoc(), createCaretContainer(true).dom);
|
13769 |
caretContainer = importNode(editor.getDoc(), createCaretContainer(true).dom);
|
| 13526 |
textNode = caretContainer.firstChild;
|
13770 |
textNode = caretContainer.firstChild;
|
| 13527 |
selectionRng.insertNode(caretContainer);
|
13771 |
selectionRng.insertNode(caretContainer);
|
| 13528 |
offset = 1;
|
13772 |
offset = 1;
|
| - |
|
13773 |
normalizeNbspsBetween(editor, caretContainer);
|
| 13529 |
editor.formatter.apply(name, vars, caretContainer);
|
13774 |
editor.formatter.apply(name, vars, caretContainer);
|
| 13530 |
} else {
|
13775 |
} else {
|
| 13531 |
editor.formatter.apply(name, vars, caretContainer);
|
13776 |
editor.formatter.apply(name, vars, caretContainer);
|
| 13532 |
}
|
13777 |
}
|
| 13533 |
selection.setCursorLocation(textNode, offset);
|
13778 |
selection.setCursorLocation(textNode, offset);
|
| Línea 13543... |
Línea 13788... |
| 13543 |
}
|
13788 |
}
|
| 13544 |
const rng = selection.getRng();
|
13789 |
const rng = selection.getRng();
|
| 13545 |
const container = rng.startContainer;
|
13790 |
const container = rng.startContainer;
|
| 13546 |
const offset = rng.startOffset;
|
13791 |
const offset = rng.startOffset;
|
| 13547 |
let node = container;
|
13792 |
let node = container;
|
| 13548 |
if (isText$a(container)) {
|
13793 |
if (isText$b(container)) {
|
| 13549 |
if (offset !== container.data.length) {
|
13794 |
if (offset !== container.data.length) {
|
| 13550 |
hasContentAfter = true;
|
13795 |
hasContentAfter = true;
|
| 13551 |
}
|
13796 |
}
|
| 13552 |
node = node.parentNode;
|
13797 |
node = node.parentNode;
|
| 13553 |
}
|
13798 |
}
|
| Línea 13568... |
Línea 13813... |
| 13568 |
return;
|
13813 |
return;
|
| 13569 |
}
|
13814 |
}
|
| 13570 |
if (hasContentAfter) {
|
13815 |
if (hasContentAfter) {
|
| 13571 |
const bookmark = selection.getBookmark();
|
13816 |
const bookmark = selection.getBookmark();
|
| 13572 |
rng.collapse(true);
|
13817 |
rng.collapse(true);
|
| 13573 |
let expandedRng = expandRng(dom, rng, formatList, true);
|
13818 |
let expandedRng = expandRng(dom, rng, formatList, { includeTrailingSpace: true });
|
| 13574 |
expandedRng = split(expandedRng);
|
13819 |
expandedRng = split(expandedRng);
|
| 13575 |
editor.formatter.remove(name, vars, expandedRng, similar);
|
13820 |
editor.formatter.remove(name, vars, expandedRng, similar);
|
| 13576 |
selection.moveToBookmark(bookmark);
|
13821 |
selection.moveToBookmark(bookmark);
|
| 13577 |
} else {
|
13822 |
} else {
|
| 13578 |
const caretContainer = getParentCaretContainer(editor.getBody(), formatNode);
|
13823 |
const caretContainer = getParentCaretContainer(editor.getBody(), formatNode);
|
| Línea 13587... |
Línea 13832... |
| 13587 |
], newCaretContainer);
|
13832 |
], newCaretContainer);
|
| 13588 |
if (caretContainer) {
|
13833 |
if (caretContainer) {
|
| 13589 |
removeCaretContainerNode(editor, caretContainer, isNonNullable(caretContainer));
|
13834 |
removeCaretContainerNode(editor, caretContainer, isNonNullable(caretContainer));
|
| 13590 |
}
|
13835 |
}
|
| 13591 |
selection.setCursorLocation(caretTextNode, 1);
|
13836 |
selection.setCursorLocation(caretTextNode, 1);
|
| - |
|
13837 |
normalizeNbspsBetween(editor, newCaretContainer);
|
| 13592 |
if (dom.isEmpty(formatNode)) {
|
13838 |
if (dom.isEmpty(formatNode)) {
|
| 13593 |
dom.remove(formatNode);
|
13839 |
dom.remove(formatNode);
|
| 13594 |
}
|
13840 |
}
|
| 13595 |
}
|
13841 |
}
|
| 13596 |
};
|
13842 |
};
|
| Línea 13602... |
Línea 13848... |
| 13602 |
}
|
13848 |
}
|
| 13603 |
if (keyCode === 37 || keyCode === 39) {
|
13849 |
if (keyCode === 37 || keyCode === 39) {
|
| 13604 |
removeCaretContainer(editor, getParentCaretContainer(body, selection.getStart()), true);
|
13850 |
removeCaretContainer(editor, getParentCaretContainer(body, selection.getStart()), true);
|
| 13605 |
}
|
13851 |
}
|
| 13606 |
};
|
13852 |
};
|
| 13607 |
const endsWithNbsp = element => isText$a(element) && endsWith(element.data, nbsp);
|
13853 |
const endsWithNbsp = element => isText$b(element) && endsWith(element.data, nbsp);
|
| 13608 |
const setup$v = editor => {
|
13854 |
const setup$v = editor => {
|
| 13609 |
editor.on('mouseup keydown', e => {
|
13855 |
editor.on('mouseup keydown', e => {
|
| 13610 |
disableCaretContainer(editor, e.keyCode, endsWithNbsp(editor.selection.getRng().endContainer));
|
13856 |
disableCaretContainer(editor, e.keyCode, endsWithNbsp(editor.selection.getRng().endContainer));
|
| 13611 |
});
|
13857 |
});
|
| 13612 |
};
|
13858 |
};
|
| Línea 13619... |
Línea 13865... |
| 13619 |
};
|
13865 |
};
|
| 13620 |
};
|
13866 |
};
|
| 13621 |
const replaceWithCaretFormat = (targetNode, formatNodes) => {
|
13867 |
const replaceWithCaretFormat = (targetNode, formatNodes) => {
|
| 13622 |
const {caretContainer, caretPosition} = createCaretFormat(formatNodes);
|
13868 |
const {caretContainer, caretPosition} = createCaretFormat(formatNodes);
|
| 13623 |
before$3(SugarElement.fromDom(targetNode), caretContainer);
|
13869 |
before$3(SugarElement.fromDom(targetNode), caretContainer);
|
| 13624 |
remove$5(SugarElement.fromDom(targetNode));
|
13870 |
remove$4(SugarElement.fromDom(targetNode));
|
| 13625 |
return caretPosition;
|
13871 |
return caretPosition;
|
| 13626 |
};
|
13872 |
};
|
| 13627 |
const createCaretFormatAtStart$1 = (rng, formatNodes) => {
|
13873 |
const createCaretFormatAtStart$1 = (rng, formatNodes) => {
|
| 13628 |
const {caretContainer, caretPosition} = createCaretFormat(formatNodes);
|
13874 |
const {caretContainer, caretPosition} = createCaretFormat(formatNodes);
|
| 13629 |
rng.insertNode(caretContainer.dom);
|
13875 |
rng.insertNode(caretContainer.dom);
|
| Línea 13632... |
Línea 13878... |
| 13632 |
const isFormatElement = (editor, element) => {
|
13878 |
const isFormatElement = (editor, element) => {
|
| 13633 |
if (isCaretNode(element.dom)) {
|
13879 |
if (isCaretNode(element.dom)) {
|
| 13634 |
return false;
|
13880 |
return false;
|
| 13635 |
}
|
13881 |
}
|
| 13636 |
const inlineElements = editor.schema.getTextInlineElements();
|
13882 |
const inlineElements = editor.schema.getTextInlineElements();
|
| 13637 |
return has$2(inlineElements, name(element)) && !isCaretNode(element.dom) && !isBogus$2(element.dom);
|
13883 |
return has$2(inlineElements, name(element)) && !isCaretNode(element.dom) && !isBogus$1(element.dom);
|
| 13638 |
};
|
13884 |
};
|
| Línea 13639... |
Línea 13885... |
| 13639 |
|
13885 |
|
| 13640 |
const postProcessHooks = {};
|
13886 |
const postProcessHooks = {};
|
| 13641 |
const isPre = matchNodeNames(['pre']);
|
13887 |
const isPre = matchNodeNames(['pre']);
|
| Línea 13660... |
Línea 13906... |
| 13660 |
return isPre(prev) && contains$2(blocks, prev);
|
13906 |
return isPre(prev) && contains$2(blocks, prev);
|
| 13661 |
};
|
13907 |
};
|
| 13662 |
const joinPre = (pre1, pre2) => {
|
13908 |
const joinPre = (pre1, pre2) => {
|
| 13663 |
const sPre2 = SugarElement.fromDom(pre2);
|
13909 |
const sPre2 = SugarElement.fromDom(pre2);
|
| 13664 |
const doc = documentOrOwner(sPre2).dom;
|
13910 |
const doc = documentOrOwner(sPre2).dom;
|
| 13665 |
remove$5(sPre2);
|
13911 |
remove$4(sPre2);
|
| 13666 |
append(SugarElement.fromDom(pre1), [
|
13912 |
append(SugarElement.fromDom(pre1), [
|
| 13667 |
SugarElement.fromTag('br', doc),
|
13913 |
SugarElement.fromTag('br', doc),
|
| 13668 |
SugarElement.fromTag('br', doc),
|
13914 |
SugarElement.fromTag('br', doc),
|
| 13669 |
...children$1(sPre2)
|
13915 |
...children$1(sPre2)
|
| 13670 |
]);
|
13916 |
]);
|
| Línea 13704... |
Línea 13950... |
| 13704 |
}
|
13950 |
}
|
| 13705 |
if (blocks.length === 1) {
|
13951 |
if (blocks.length === 1) {
|
| 13706 |
return isRngStartAtStartOfElement(rng, blocks[0]) && isRngEndAtEndOfElement(rng, blocks[0]) ? blocks : [];
|
13952 |
return isRngStartAtStartOfElement(rng, blocks[0]) && isRngEndAtEndOfElement(rng, blocks[0]) ? blocks : [];
|
| 13707 |
} else {
|
13953 |
} else {
|
| 13708 |
const first = head(blocks).filter(elm => isRngStartAtStartOfElement(rng, elm)).toArray();
|
13954 |
const first = head(blocks).filter(elm => isRngStartAtStartOfElement(rng, elm)).toArray();
|
| 13709 |
const last = last$3(blocks).filter(elm => isRngEndAtEndOfElement(rng, elm)).toArray();
|
13955 |
const last = last$2(blocks).filter(elm => isRngEndAtEndOfElement(rng, elm)).toArray();
|
| 13710 |
const middle = blocks.slice(1, -1);
|
13956 |
const middle = blocks.slice(1, -1);
|
| 13711 |
return first.concat(middle).concat(last);
|
13957 |
return first.concat(middle).concat(last);
|
| 13712 |
}
|
13958 |
}
|
| 13713 |
};
|
13959 |
};
|
| 13714 |
const getFullySelectedListItems = selection => filter$5(getFullySelectedBlocks(selection), isEditableListItem(selection.dom));
|
13960 |
const getFullySelectedListItems = selection => filter$5(getFullySelectedBlocks(selection), isEditableListItem(selection.dom));
|
| 13715 |
const getPartiallySelectedListItems = selection => filter$5(selection.getSelectedBlocks(), isEditableListItem(selection.dom));
|
13961 |
const getPartiallySelectedListItems = selection => filter$5(selection.getSelectedBlocks(), isEditableListItem(selection.dom));
|
| Línea 13716... |
Línea 13962... |
| 13716 |
|
13962 |
|
| 13717 |
const each$8 = Tools.each;
|
13963 |
const each$8 = Tools.each;
|
| 13718 |
const isElementNode = node => isElement$6(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$2(node);
|
13964 |
const isElementNode = node => isElement$6(node) && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus$1(node);
|
| 13719 |
const findElementSibling = (node, siblingName) => {
|
13965 |
const findElementSibling = (node, siblingName) => {
|
| 13720 |
for (let sibling = node; sibling; sibling = sibling[siblingName]) {
|
13966 |
for (let sibling = node; sibling; sibling = sibling[siblingName]) {
|
| 13721 |
if (isText$a(sibling) && isNotEmpty(sibling.data)) {
|
13967 |
if (isText$b(sibling) && isNotEmpty(sibling.data)) {
|
| 13722 |
return node;
|
13968 |
return node;
|
| 13723 |
}
|
13969 |
}
|
| 13724 |
if (isElement$6(sibling) && !isBookmarkNode$1(sibling)) {
|
13970 |
if (isElement$6(sibling) && !isBookmarkNode$1(sibling)) {
|
| 13725 |
return sibling;
|
13971 |
return sibling;
|
| Línea 13812... |
Línea 14058... |
| 13812 |
if (!start && offset) {
|
14058 |
if (!start && offset) {
|
| 13813 |
offset--;
|
14059 |
offset--;
|
| 13814 |
}
|
14060 |
}
|
| 13815 |
container = container.childNodes[offset > lastIdx ? lastIdx : offset];
|
14061 |
container = container.childNodes[offset > lastIdx ? lastIdx : offset];
|
| 13816 |
}
|
14062 |
}
|
| 13817 |
if (isText$a(container) && start && offset >= container.data.length) {
|
14063 |
if (isText$b(container) && start && offset >= container.data.length) {
|
| 13818 |
container = new DomTreeWalker(container, ed.getBody()).next() || container;
|
14064 |
container = new DomTreeWalker(container, ed.getBody()).next() || container;
|
| 13819 |
}
|
14065 |
}
|
| 13820 |
if (isText$a(container) && !start && offset === 0) {
|
14066 |
if (isText$b(container) && !start && offset === 0) {
|
| 13821 |
container = new DomTreeWalker(container, ed.getBody()).prev() || container;
|
14067 |
container = new DomTreeWalker(container, ed.getBody()).prev() || container;
|
| 13822 |
}
|
14068 |
}
|
| 13823 |
return container;
|
14069 |
return container;
|
| 13824 |
};
|
14070 |
};
|
| 13825 |
const normalizeTableSelection = (node, start) => {
|
14071 |
const normalizeTableSelection = (node, start) => {
|
| Línea 14117... |
Línea 14363... |
| 14117 |
if (node) {
|
14363 |
if (node) {
|
| 14118 |
let out = node[start ? 'firstChild' : 'lastChild'];
|
14364 |
let out = node[start ? 'firstChild' : 'lastChild'];
|
| 14119 |
if (isRemoveBookmarkNode(out)) {
|
14365 |
if (isRemoveBookmarkNode(out)) {
|
| 14120 |
out = out[start ? 'firstChild' : 'lastChild'];
|
14366 |
out = out[start ? 'firstChild' : 'lastChild'];
|
| 14121 |
}
|
14367 |
}
|
| 14122 |
if (isText$a(out) && out.data.length === 0) {
|
14368 |
if (isText$b(out) && out.data.length === 0) {
|
| 14123 |
out = start ? node.previousSibling || node.nextSibling : node.nextSibling || node.previousSibling;
|
14369 |
out = start ? node.previousSibling || node.nextSibling : node.nextSibling || node.previousSibling;
|
| 14124 |
}
|
14370 |
}
|
| 14125 |
dom.remove(node, true);
|
14371 |
dom.remove(node, true);
|
| 14126 |
return out;
|
14372 |
return out;
|
| 14127 |
} else {
|
14373 |
} else {
|
| Línea 14129... |
Línea 14375... |
| 14129 |
}
|
14375 |
}
|
| 14130 |
};
|
14376 |
};
|
| 14131 |
const removeRngStyle = rng => {
|
14377 |
const removeRngStyle = rng => {
|
| 14132 |
let startContainer;
|
14378 |
let startContainer;
|
| 14133 |
let endContainer;
|
14379 |
let endContainer;
|
| 14134 |
let expandedRng = expandRng(dom, rng, formatList, rng.collapsed);
|
14380 |
let expandedRng = expandRng(dom, rng, formatList, { includeTrailingSpace: rng.collapsed });
|
| 14135 |
if (format.split) {
|
14381 |
if (format.split) {
|
| 14136 |
expandedRng = split(expandedRng);
|
14382 |
expandedRng = split(expandedRng);
|
| 14137 |
startContainer = getContainer(ed, expandedRng, true);
|
14383 |
startContainer = getContainer(ed, expandedRng, true);
|
| 14138 |
endContainer = getContainer(ed, expandedRng);
|
14384 |
endContainer = getContainer(ed, expandedRng);
|
| 14139 |
if (startContainer !== endContainer) {
|
14385 |
if (startContainer !== endContainer) {
|
| Línea 14289... |
Línea 14535... |
| 14289 |
const each$5 = Tools.each;
|
14535 |
const each$5 = Tools.each;
|
| 14290 |
const canFormatBR = (editor, format, node, parentName) => {
|
14536 |
const canFormatBR = (editor, format, node, parentName) => {
|
| 14291 |
if (canFormatEmptyLines(editor) && isInlineFormat(format) && node.parentNode) {
|
14537 |
if (canFormatEmptyLines(editor) && isInlineFormat(format) && node.parentNode) {
|
| 14292 |
const validBRParentElements = getTextRootBlockElements(editor.schema);
|
14538 |
const validBRParentElements = getTextRootBlockElements(editor.schema);
|
| 14293 |
const hasCaretNodeSibling = sibling(SugarElement.fromDom(node), sibling => isCaretNode(sibling.dom));
|
14539 |
const hasCaretNodeSibling = sibling(SugarElement.fromDom(node), sibling => isCaretNode(sibling.dom));
|
| 14294 |
return hasNonNullableKey(validBRParentElements, parentName) && isEmpty$2(SugarElement.fromDom(node.parentNode), false) && !hasCaretNodeSibling;
|
14540 |
return hasNonNullableKey(validBRParentElements, parentName) && isEmptyNode(editor.schema, node.parentNode, {
|
| - |
|
14541 |
skipBogus: false,
|
| - |
|
14542 |
includeZwsp: true
|
| - |
|
14543 |
}) && !hasCaretNodeSibling;
|
| 14295 |
} else {
|
14544 |
} else {
|
| 14296 |
return false;
|
14545 |
return false;
|
| 14297 |
}
|
14546 |
}
|
| 14298 |
};
|
14547 |
};
|
| 14299 |
const applyStyles = (dom, elm, format, vars) => {
|
14548 |
const applyStyles = (dom, elm, format, vars) => {
|
| Línea 14369... |
Línea 14618... |
| 14369 |
return isEditableDescendant && isValidBlockFormatForNode;
|
14618 |
return isEditableDescendant && isValidBlockFormatForNode;
|
| 14370 |
};
|
14619 |
};
|
| 14371 |
const canWrapNode = (node, parentName, isEditableDescendant, isWrappableNoneditableElm) => {
|
14620 |
const canWrapNode = (node, parentName, isEditableDescendant, isWrappableNoneditableElm) => {
|
| 14372 |
const nodeName = node.nodeName.toLowerCase();
|
14621 |
const nodeName = node.nodeName.toLowerCase();
|
| 14373 |
const isValidWrapNode = isValid(ed, wrapName, nodeName) && isValid(ed, parentName, wrapName);
|
14622 |
const isValidWrapNode = isValid(ed, wrapName, nodeName) && isValid(ed, parentName, wrapName);
|
| 14374 |
const isZwsp = !nodeSpecific && isText$a(node) && isZwsp$1(node.data);
|
14623 |
const isZwsp$1 = !nodeSpecific && isText$b(node) && isZwsp(node.data);
|
| 14375 |
const isCaret = isCaretNode(node);
|
14624 |
const isCaret = isCaretNode(node);
|
| 14376 |
const isCorrectFormatForNode = !isInlineFormat(format) || !dom.isBlock(node);
|
14625 |
const isCorrectFormatForNode = !isInlineFormat(format) || !dom.isBlock(node);
|
| 14377 |
return (isEditableDescendant || isWrappableNoneditableElm) && isValidWrapNode && !isZwsp && !isCaret && isCorrectFormatForNode;
|
14626 |
return (isEditableDescendant || isWrappableNoneditableElm) && isValidWrapNode && !isZwsp$1 && !isCaret && isCorrectFormatForNode;
|
| 14378 |
};
|
14627 |
};
|
| 14379 |
walk$3(dom, rng, nodes => {
|
14628 |
walk$3(dom, rng, nodes => {
|
| 14380 |
let currentWrapElm;
|
14629 |
let currentWrapElm;
|
| 14381 |
const process = node => {
|
14630 |
const process = node => {
|
| 14382 |
let hasContentEditableState = false;
|
14631 |
let hasContentEditableState = false;
|
| Línea 14566... |
Línea 14815... |
| 14566 |
};
|
14815 |
};
|
| 14567 |
return findUntil$1(parents, isMatchingNode, isUnableToMatch);
|
14816 |
return findUntil$1(parents, isMatchingNode, isUnableToMatch);
|
| 14568 |
};
|
14817 |
};
|
| 14569 |
const getParents = (editor, elm) => {
|
14818 |
const getParents = (editor, elm) => {
|
| 14570 |
const element = elm !== null && elm !== void 0 ? elm : fallbackElement(editor);
|
14819 |
const element = elm !== null && elm !== void 0 ? elm : fallbackElement(editor);
|
| 14571 |
return filter$5(getParents$2(editor.dom, element), node => isElement$6(node) && !isBogus$2(node));
|
14820 |
return filter$5(getParents$2(editor.dom, element), node => isElement$6(node) && !isBogus$1(node));
|
| 14572 |
};
|
14821 |
};
|
| 14573 |
const updateAndFireChangeCallbacks = (editor, elm, registeredCallbacks) => {
|
14822 |
const updateAndFireChangeCallbacks = (editor, elm, registeredCallbacks) => {
|
| 14574 |
const parents = getParents(editor, elm);
|
14823 |
const parents = getParents(editor, elm);
|
| 14575 |
each$d(registeredCallbacks, (data, format) => {
|
14824 |
each$d(registeredCallbacks, (data, format) => {
|
| 14576 |
const runIfChanged = spec => {
|
14825 |
const runIfChanged = spec => {
|
| Línea 14774... |
Línea 15023... |
| 14774 |
if (settings.inline_styles) {
|
15023 |
if (settings.inline_styles) {
|
| 14775 |
addFilters(domParser, settings, schema);
|
15024 |
addFilters(domParser, settings, schema);
|
| 14776 |
}
|
15025 |
}
|
| 14777 |
};
|
15026 |
};
|
| Línea 14778... |
Línea -... |
| 14778 |
|
- |
|
| 14779 |
const addNodeFilter = (settings, htmlParser, schema) => {
|
- |
|
| 14780 |
htmlParser.addNodeFilter('br', (nodes, _, args) => {
|
- |
|
| 14781 |
const blockElements = Tools.extend({}, schema.getBlockElements());
|
- |
|
| 14782 |
const nonEmptyElements = schema.getNonEmptyElements();
|
- |
|
| 14783 |
const whitespaceElements = schema.getWhitespaceElements();
|
- |
|
| 14784 |
blockElements.body = 1;
|
- |
|
| 14785 |
const isBlock = node => node.name in blockElements || isTransparentAstBlock(schema, node);
|
- |
|
| 14786 |
for (let i = 0, l = nodes.length; i < l; i++) {
|
- |
|
| 14787 |
let node = nodes[i];
|
- |
|
| 14788 |
let parent = node.parent;
|
- |
|
| 14789 |
if (parent && isBlock(parent) && node === parent.lastChild) {
|
- |
|
| 14790 |
let prev = node.prev;
|
- |
|
| 14791 |
while (prev) {
|
- |
|
| 14792 |
const prevName = prev.name;
|
- |
|
| 14793 |
if (prevName !== 'span' || prev.attr('data-mce-type') !== 'bookmark') {
|
- |
|
| 14794 |
if (prevName === 'br') {
|
- |
|
| 14795 |
node = null;
|
- |
|
| 14796 |
}
|
- |
|
| 14797 |
break;
|
- |
|
| 14798 |
}
|
- |
|
| 14799 |
prev = prev.prev;
|
- |
|
| 14800 |
}
|
- |
|
| 14801 |
if (node) {
|
- |
|
| 14802 |
node.remove();
|
- |
|
| 14803 |
if (isEmpty(schema, nonEmptyElements, whitespaceElements, parent)) {
|
- |
|
| 14804 |
const elementRule = schema.getElementRule(parent.name);
|
- |
|
| 14805 |
if (elementRule) {
|
- |
|
| 14806 |
if (elementRule.removeEmpty) {
|
- |
|
| 14807 |
parent.remove();
|
- |
|
| 14808 |
} else if (elementRule.paddEmpty) {
|
- |
|
| 14809 |
paddEmptyNode(settings, args, isBlock, parent);
|
- |
|
| 14810 |
}
|
- |
|
| 14811 |
}
|
- |
|
| 14812 |
}
|
- |
|
| 14813 |
}
|
- |
|
| 14814 |
} else {
|
- |
|
| 14815 |
let lastParent = node;
|
- |
|
| 14816 |
while (parent && parent.firstChild === lastParent && parent.lastChild === lastParent) {
|
- |
|
| 14817 |
lastParent = parent;
|
- |
|
| 14818 |
if (blockElements[parent.name]) {
|
- |
|
| 14819 |
break;
|
- |
|
| 14820 |
}
|
- |
|
| 14821 |
parent = parent.parent;
|
- |
|
| 14822 |
}
|
- |
|
| 14823 |
if (lastParent === parent) {
|
- |
|
| 14824 |
const textNode = new AstNode('#text', 3);
|
- |
|
| 14825 |
textNode.value = nbsp;
|
- |
|
| 14826 |
node.replace(textNode);
|
- |
|
| 14827 |
}
|
- |
|
| 14828 |
}
|
- |
|
| 14829 |
}
|
- |
|
| 14830 |
});
|
- |
|
| 14831 |
};
|
- |
|
| 14832 |
|
15027 |
|
| 14833 |
const blobUriToBlob = url => fetch(url).then(res => res.ok ? res.blob() : Promise.reject()).catch(() => Promise.reject({
|
15028 |
const blobUriToBlob = url => fetch(url).then(res => res.ok ? res.blob() : Promise.reject()).catch(() => Promise.reject({
|
| 14834 |
message: `Cannot convert ${ url } to Blob. Resource might not exist or is inaccessible.`,
|
15029 |
message: `Cannot convert ${ url } to Blob. Resource might not exist or is inaccessible.`,
|
| 14835 |
uriType: 'blob'
|
15030 |
uriType: 'blob'
|
| 14836 |
}));
|
15031 |
}));
|
| 14837 |
const extractBase64Data = data => {
|
15032 |
const extractBase64Data = data => {
|
| 14838 |
const matches = /([a-z0-9+\/=\s]+)/i.exec(data);
|
15033 |
const matches = /([a-z0-9+\/=\s]+)/i.exec(data);
|
| 14839 |
return matches ? matches[1] : '';
|
15034 |
return matches ? matches[1] : '';
|
| - |
|
15035 |
};
|
| - |
|
15036 |
const decodeData = data => {
|
| - |
|
15037 |
try {
|
| - |
|
15038 |
return decodeURIComponent(data);
|
| - |
|
15039 |
} catch (_a) {
|
| - |
|
15040 |
return data;
|
| - |
|
15041 |
}
|
| 14840 |
};
|
15042 |
};
|
| 14841 |
const parseDataUri = uri => {
|
15043 |
const parseDataUri = uri => {
|
| 14842 |
const [type, ...rest] = uri.split(',');
|
15044 |
const [type, ...rest] = uri.split(',');
|
| 14843 |
const data = rest.join(',');
|
15045 |
const data = rest.join(',');
|
| 14844 |
const matches = /data:([^/]+\/[^;]+)(;.+)?/.exec(type);
|
15046 |
const matches = /data:([^/]+\/[^;]+)(;.+)?/.exec(type);
|
| 14845 |
if (matches) {
|
15047 |
if (matches) {
|
| - |
|
15048 |
const base64Encoded = matches[2] === ';base64';
|
| 14846 |
const base64Encoded = matches[2] === ';base64';
|
15049 |
const decodedData = decodeData(data);
|
| 14847 |
const extractedData = base64Encoded ? extractBase64Data(data) : decodeURIComponent(data);
|
15050 |
const extractedData = base64Encoded ? extractBase64Data(decodedData) : decodedData;
|
| 14848 |
return Optional.some({
|
15051 |
return Optional.some({
|
| 14849 |
type: matches[1],
|
15052 |
type: matches[1],
|
| 14850 |
data: extractedData,
|
15053 |
data: extractedData,
|
| 14851 |
base64Encoded
|
15054 |
base64Encoded
|
| Línea 14857... |
Línea 15060... |
| 14857 |
const buildBlob = (type, data, base64Encoded = true) => {
|
15060 |
const buildBlob = (type, data, base64Encoded = true) => {
|
| 14858 |
let str = data;
|
15061 |
let str = data;
|
| 14859 |
if (base64Encoded) {
|
15062 |
if (base64Encoded) {
|
| 14860 |
try {
|
15063 |
try {
|
| 14861 |
str = atob(data);
|
15064 |
str = atob(data);
|
| 14862 |
} catch (e) {
|
15065 |
} catch (_a) {
|
| 14863 |
return Optional.none();
|
15066 |
return Optional.none();
|
| 14864 |
}
|
15067 |
}
|
| 14865 |
}
|
15068 |
}
|
| 14866 |
const arr = new Uint8Array(str.length);
|
15069 |
const arr = new Uint8Array(str.length);
|
| 14867 |
for (let i = 0; i < arr.length; i++) {
|
15070 |
for (let i = 0; i < arr.length; i++) {
|
| Línea 14939... |
Línea 15142... |
| 14939 |
} else {
|
15142 |
} else {
|
| 14940 |
return Promise.reject('Unknown image data format');
|
15143 |
return Promise.reject('Unknown image data format');
|
| 14941 |
}
|
15144 |
}
|
| 14942 |
};
|
15145 |
};
|
| Línea 14943... |
Línea 15146... |
| 14943 |
|
15146 |
|
| 14944 |
const isBogusImage = img => isNonNullable(img.attr('data-mce-bogus'));
|
15147 |
const hostCaptureRegex = /^(?:(?:(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)([A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*))(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+)?)?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+)?)?)$/;
|
| - |
|
15148 |
const extractHost = url => Optional.from(url.match(hostCaptureRegex)).bind(ms => get$b(ms, 1)).map(h => startsWith(h, 'www.') ? h.substring(4) : h);
|
| 14945 |
const isInternalImageSource = img => img.attr('src') === Env.transparentSrc || isNonNullable(img.attr('data-mce-placeholder'));
|
15149 |
|
| 14946 |
const registerBase64ImageFilter = (parser, settings) => {
|
- |
|
| 14947 |
const {blob_cache: blobCache} = settings;
|
- |
|
| 14948 |
if (blobCache) {
|
- |
|
| 14949 |
const processImage = img => {
|
- |
|
| 14950 |
const inputSrc = img.attr('src');
|
15150 |
const sandboxIframe = (iframeNode, exclusions) => {
|
| 14951 |
if (isInternalImageSource(img) || isBogusImage(img) || isNullable(inputSrc)) {
|
- |
|
| 14952 |
return;
|
- |
|
| 14953 |
}
|
- |
|
| 14954 |
dataUriToBlobInfo(blobCache, inputSrc, true).each(blobInfo => {
|
15151 |
if (Optional.from(iframeNode.attr('src')).bind(extractHost).forall(host => !contains$2(exclusions, host))) {
|
| 14955 |
img.attr('src', blobInfo.blobUri());
|
- |
|
| 14956 |
});
|
- |
|
| 14957 |
};
|
- |
|
| 14958 |
parser.addAttributeFilter('src', nodes => each$e(nodes, processImage));
|
15152 |
iframeNode.attr('sandbox', '');
|
| 14959 |
}
|
15153 |
}
|
| 14960 |
};
|
15154 |
};
|
| 14961 |
const isMimeType = (mime, type) => startsWith(mime, `${ type }/`);
|
15155 |
const isMimeType = (mime, type) => startsWith(mime, `${ type }/`);
|
| 14962 |
const createSafeEmbed = (mime, src, width, height, sandboxIframes) => {
|
- |
|
| 14963 |
let name;
|
15156 |
const getEmbedType = type => {
|
| 14964 |
if (isUndefined(mime)) {
|
15157 |
if (isUndefined(type)) {
|
| 14965 |
name = 'iframe';
|
15158 |
return 'iframe';
|
| 14966 |
} else if (isMimeType(mime, 'image')) {
|
15159 |
} else if (isMimeType(type, 'image')) {
|
| 14967 |
name = 'img';
|
15160 |
return 'img';
|
| 14968 |
} else if (isMimeType(mime, 'video')) {
|
15161 |
} else if (isMimeType(type, 'video')) {
|
| 14969 |
name = 'video';
|
15162 |
return 'video';
|
| 14970 |
} else if (isMimeType(mime, 'audio')) {
|
15163 |
} else if (isMimeType(type, 'audio')) {
|
| 14971 |
name = 'audio';
|
15164 |
return 'audio';
|
| 14972 |
} else {
|
15165 |
} else {
|
| 14973 |
name = 'iframe';
|
15166 |
return 'iframe';
|
| - |
|
15167 |
}
|
| - |
|
15168 |
};
|
| - |
|
15169 |
const createSafeEmbed = ({type, src, width, height} = {}, sandboxIframes, sandboxIframesExclusions) => {
|
| 14974 |
}
|
15170 |
const name = getEmbedType(type);
|
| 14975 |
const embed = new AstNode(name, 1);
|
15171 |
const embed = new AstNode(name, 1);
|
| 14976 |
embed.attr(name === 'audio' ? { src } : {
|
15172 |
embed.attr(name === 'audio' ? { src } : {
|
| 14977 |
src,
|
15173 |
src,
|
| 14978 |
width,
|
15174 |
width,
|
| 14979 |
height
|
15175 |
height
|
| 14980 |
});
|
15176 |
});
|
| 14981 |
if (name === 'audio' || name === 'video') {
|
15177 |
if (name === 'audio' || name === 'video') {
|
| 14982 |
embed.attr('controls', '');
|
15178 |
embed.attr('controls', '');
|
| 14983 |
}
|
15179 |
}
|
| 14984 |
if (name === 'iframe' && sandboxIframes) {
|
15180 |
if (name === 'iframe' && sandboxIframes) {
|
| 14985 |
embed.attr('sandbox', '');
|
15181 |
sandboxIframe(embed, sandboxIframesExclusions);
|
| 14986 |
}
|
15182 |
}
|
| 14987 |
return embed;
|
15183 |
return embed;
|
| - |
|
15184 |
};
|
| - |
|
15185 |
|
| - |
|
15186 |
const isBogusImage = img => isNonNullable(img.attr('data-mce-bogus'));
|
| - |
|
15187 |
const isInternalImageSource = img => img.attr('src') === Env.transparentSrc || isNonNullable(img.attr('data-mce-placeholder'));
|
| - |
|
15188 |
const registerBase64ImageFilter = (parser, settings) => {
|
| - |
|
15189 |
const {blob_cache: blobCache} = settings;
|
| - |
|
15190 |
if (blobCache) {
|
| - |
|
15191 |
const processImage = img => {
|
| - |
|
15192 |
const inputSrc = img.attr('src');
|
| - |
|
15193 |
if (isInternalImageSource(img) || isBogusImage(img) || isNullable(inputSrc)) {
|
| - |
|
15194 |
return;
|
| - |
|
15195 |
}
|
| - |
|
15196 |
dataUriToBlobInfo(blobCache, inputSrc, true).each(blobInfo => {
|
| - |
|
15197 |
img.attr('src', blobInfo.blobUri());
|
| - |
|
15198 |
});
|
| - |
|
15199 |
};
|
| - |
|
15200 |
parser.addAttributeFilter('src', nodes => each$e(nodes, processImage));
|
| - |
|
15201 |
}
|
| 14988 |
};
|
15202 |
};
|
| - |
|
15203 |
const register$4 = (parser, settings) => {
|
| 14989 |
const register$4 = (parser, settings) => {
|
15204 |
var _a, _b;
|
| 14990 |
const schema = parser.schema;
|
- |
|
| 14991 |
if (settings.remove_trailing_brs) {
|
- |
|
| 14992 |
addNodeFilter(settings, parser, schema);
|
- |
|
| 14993 |
}
|
15205 |
const schema = parser.schema;
|
| 14994 |
parser.addAttributeFilter('href', nodes => {
|
15206 |
parser.addAttributeFilter('href', nodes => {
|
| 14995 |
let i = nodes.length;
|
15207 |
let i = nodes.length;
|
| 14996 |
const appendRel = rel => {
|
15208 |
const appendRel = rel => {
|
| 14997 |
const parts = rel.split(' ').filter(p => p.length > 0);
|
15209 |
const parts = rel.split(' ').filter(p => p.length > 0);
|
| Línea 15083... |
Línea 15295... |
| 15083 |
node.attr('class', classValue);
|
15295 |
node.attr('class', classValue);
|
| 15084 |
}
|
15296 |
}
|
| 15085 |
});
|
15297 |
});
|
| 15086 |
}
|
15298 |
}
|
| 15087 |
registerBase64ImageFilter(parser, settings);
|
15299 |
registerBase64ImageFilter(parser, settings);
|
| - |
|
15300 |
const shouldSandboxIframes = (_a = settings.sandbox_iframes) !== null && _a !== void 0 ? _a : false;
|
| - |
|
15301 |
const sandboxIframesExclusions = unique$1((_b = settings.sandbox_iframes_exclusions) !== null && _b !== void 0 ? _b : []);
|
| 15088 |
if (settings.convert_unsafe_embeds) {
|
15302 |
if (settings.convert_unsafe_embeds) {
|
| 15089 |
parser.addNodeFilter('object,embed', nodes => each$e(nodes, node => {
|
15303 |
parser.addNodeFilter('object,embed', nodes => each$e(nodes, node => {
|
| - |
|
15304 |
node.replace(createSafeEmbed({
|
| - |
|
15305 |
type: node.attr('type'),
|
| 15090 |
node.replace(createSafeEmbed(node.attr('type'), node.name === 'object' ? node.attr('data') : node.attr('src'), node.attr('width'), node.attr('height'), settings.sandbox_iframes));
|
15306 |
src: node.name === 'object' ? node.attr('data') : node.attr('src'),
|
| - |
|
15307 |
width: node.attr('width'),
|
| - |
|
15308 |
height: node.attr('height')
|
| - |
|
15309 |
}, shouldSandboxIframes, sandboxIframesExclusions));
|
| 15091 |
}));
|
15310 |
}));
|
| 15092 |
}
|
15311 |
}
|
| 15093 |
if (settings.sandbox_iframes) {
|
15312 |
if (shouldSandboxIframes) {
|
| 15094 |
parser.addNodeFilter('iframe', nodes => each$e(nodes, node => node.attr('sandbox', '')));
|
15313 |
parser.addNodeFilter('iframe', nodes => each$e(nodes, node => sandboxIframe(node, sandboxIframesExclusions)));
|
| 15095 |
}
|
15314 |
}
|
| 15096 |
};
|
15315 |
};
|
| Línea 15097... |
Línea 15316... |
| 15097 |
|
15316 |
|
| - |
|
15317 |
/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
|
| - |
|
15318 |
|
| 15098 |
const {entries, setPrototypeOf, isFrozen, getPrototypeOf, getOwnPropertyDescriptor} = Object;
|
15319 |
const {
|
| 15099 |
let {freeze, seal, create: create$7} = Object;
|
15320 |
entries,
|
| 15100 |
let {apply, construct} = typeof Reflect !== 'undefined' && Reflect;
|
15321 |
setPrototypeOf,
|
| 15101 |
if (!apply) {
|
15322 |
isFrozen,
|
| 15102 |
apply = function apply(fun, thisValue, args) {
|
15323 |
getPrototypeOf,
|
| - |
|
15324 |
getOwnPropertyDescriptor
|
| - |
|
15325 |
} = Object;
|
| - |
|
15326 |
let {
|
| 15103 |
return fun.apply(thisValue, args);
|
15327 |
freeze,
|
| - |
|
15328 |
seal,
|
| - |
|
15329 |
create: create$7
|
| 15104 |
};
|
15330 |
} = Object; // eslint-disable-line import/no-mutable-exports
|
| - |
|
15331 |
let {
|
| - |
|
15332 |
apply,
|
| - |
|
15333 |
construct
|
| 15105 |
}
|
15334 |
} = typeof Reflect !== 'undefined' && Reflect;
|
| 15106 |
if (!freeze) {
|
15335 |
if (!freeze) {
|
| 15107 |
freeze = function freeze(x) {
|
15336 |
freeze = function freeze(x) {
|
| 15108 |
return x;
|
15337 |
return x;
|
| 15109 |
};
|
15338 |
};
|
| 15110 |
}
|
15339 |
}
|
| 15111 |
if (!seal) {
|
15340 |
if (!seal) {
|
| 15112 |
seal = function seal(x) {
|
15341 |
seal = function seal(x) {
|
| 15113 |
return x;
|
15342 |
return x;
|
| 15114 |
};
|
15343 |
};
|
| - |
|
15344 |
}
|
| - |
|
15345 |
if (!apply) {
|
| - |
|
15346 |
apply = function apply(fun, thisValue, args) {
|
| - |
|
15347 |
return fun.apply(thisValue, args);
|
| - |
|
15348 |
};
|
| 15115 |
}
|
15349 |
}
|
| 15116 |
if (!construct) {
|
15350 |
if (!construct) {
|
| 15117 |
construct = function construct(Func, args) {
|
15351 |
construct = function construct(Func, args) {
|
| 15118 |
return new Func(...args);
|
15352 |
return new Func(...args);
|
| 15119 |
};
|
15353 |
};
|
| 15120 |
}
|
15354 |
}
|
| - |
|
15355 |
const arrayForEach = unapply(Array.prototype.forEach);
|
| 15121 |
const arrayForEach = unapply(Array.prototype.forEach);
|
15356 |
const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
|
| 15122 |
const arrayPop = unapply(Array.prototype.pop);
|
15357 |
const arrayPop = unapply(Array.prototype.pop);
|
| - |
|
15358 |
const arrayPush = unapply(Array.prototype.push);
|
| 15123 |
const arrayPush = unapply(Array.prototype.push);
|
15359 |
const arraySplice = unapply(Array.prototype.splice);
|
| 15124 |
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
15360 |
const stringToLowerCase = unapply(String.prototype.toLowerCase);
|
| 15125 |
const stringToString = unapply(String.prototype.toString);
|
15361 |
const stringToString = unapply(String.prototype.toString);
|
| 15126 |
const stringMatch = unapply(String.prototype.match);
|
15362 |
const stringMatch = unapply(String.prototype.match);
|
| 15127 |
const stringReplace = unapply(String.prototype.replace);
|
15363 |
const stringReplace = unapply(String.prototype.replace);
|
| 15128 |
const stringIndexOf = unapply(String.prototype.indexOf);
|
15364 |
const stringIndexOf = unapply(String.prototype.indexOf);
|
| - |
|
15365 |
const stringTrim = unapply(String.prototype.trim);
|
| 15129 |
const stringTrim = unapply(String.prototype.trim);
|
15366 |
const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
|
| 15130 |
const regExpTest = unapply(RegExp.prototype.test);
|
15367 |
const regExpTest = unapply(RegExp.prototype.test);
|
| - |
|
15368 |
const typeErrorCreate = unconstruct(TypeError);
|
| - |
|
15369 |
/**
|
| - |
|
15370 |
* Creates a new function that calls the given function with a specified thisArg and arguments.
|
| - |
|
15371 |
*
|
| - |
|
15372 |
* @param func - The function to be wrapped and called.
|
| - |
|
15373 |
* @returns A new function that calls the given function with a specified thisArg and arguments.
|
| 15131 |
const typeErrorCreate = unconstruct(TypeError);
|
15374 |
*/
|
| 15132 |
function unapply(func) {
|
15375 |
function unapply(func) {
|
| 15133 |
return function (thisArg) {
|
15376 |
return function (thisArg) {
|
| 15134 |
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
15377 |
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
| 15135 |
args[_key - 1] = arguments[_key];
|
15378 |
args[_key - 1] = arguments[_key];
|
| 15136 |
}
|
15379 |
}
|
| 15137 |
return apply(func, thisArg, args);
|
15380 |
return apply(func, thisArg, args);
|
| 15138 |
};
|
15381 |
};
|
| - |
|
15382 |
}
|
| - |
|
15383 |
/**
|
| - |
|
15384 |
* Creates a new function that constructs an instance of the given constructor function with the provided arguments.
|
| - |
|
15385 |
*
|
| - |
|
15386 |
* @param func - The constructor function to be wrapped and called.
|
| - |
|
15387 |
* @returns A new function that constructs an instance of the given constructor function with the provided arguments.
|
| 15139 |
}
|
15388 |
*/
|
| 15140 |
function unconstruct(func) {
|
15389 |
function unconstruct(func) {
|
| 15141 |
return function () {
|
15390 |
return function () {
|
| 15142 |
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
15391 |
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
| 15143 |
args[_key2] = arguments[_key2];
|
15392 |
args[_key2] = arguments[_key2];
|
| 15144 |
}
|
15393 |
}
|
| 15145 |
return construct(func, args);
|
15394 |
return construct(func, args);
|
| 15146 |
};
|
15395 |
};
|
| - |
|
15396 |
}
|
| - |
|
15397 |
/**
|
| - |
|
15398 |
* Add properties to a lookup table
|
| - |
|
15399 |
*
|
| - |
|
15400 |
* @param set - The set to which elements will be added.
|
| - |
|
15401 |
* @param array - The array containing elements to be added to the set.
|
| 15147 |
}
|
15402 |
* @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
|
| - |
|
15403 |
* @returns The modified set with added elements.
|
| 15148 |
function addToSet(set, array, transformCaseFunc) {
|
15404 |
*/
|
| 15149 |
var _transformCaseFunc;
|
15405 |
function addToSet(set, array) {
|
| 15150 |
transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
|
15406 |
let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
|
| - |
|
15407 |
if (setPrototypeOf) {
|
| - |
|
15408 |
// Make 'in' and truthy checks like Boolean(set.constructor)
|
| - |
|
15409 |
// independent of any properties defined on Object.prototype.
|
| 15151 |
if (setPrototypeOf) {
|
15410 |
// Prevent prototype setters from intercepting set as a this value.
|
| 15152 |
setPrototypeOf(set, null);
|
15411 |
setPrototypeOf(set, null);
|
| 15153 |
}
|
15412 |
}
|
| 15154 |
let l = array.length;
|
15413 |
let l = array.length;
|
| 15155 |
while (l--) {
|
15414 |
while (l--) {
|
| 15156 |
let element = array[l];
|
15415 |
let element = array[l];
|
| 15157 |
if (typeof element === 'string') {
|
15416 |
if (typeof element === 'string') {
|
| 15158 |
const lcElement = transformCaseFunc(element);
|
15417 |
const lcElement = transformCaseFunc(element);
|
| - |
|
15418 |
if (lcElement !== element) {
|
| 15159 |
if (lcElement !== element) {
|
15419 |
// Config presets (e.g. tags.js, attrs.js) are immutable.
|
| 15160 |
if (!isFrozen(array)) {
|
15420 |
if (!isFrozen(array)) {
|
| 15161 |
array[l] = lcElement;
|
15421 |
array[l] = lcElement;
|
| 15162 |
}
|
15422 |
}
|
| 15163 |
element = lcElement;
|
15423 |
element = lcElement;
|
| 15164 |
}
|
15424 |
}
|
| 15165 |
}
|
15425 |
}
|
| 15166 |
set[element] = true;
|
15426 |
set[element] = true;
|
| 15167 |
}
|
15427 |
}
|
| 15168 |
return set;
|
15428 |
return set;
|
| - |
|
15429 |
}
|
| - |
|
15430 |
/**
|
| - |
|
15431 |
* Clean up an array to harden against CSPP
|
| - |
|
15432 |
*
|
| - |
|
15433 |
* @param array - The array to be cleaned.
|
| - |
|
15434 |
* @returns The cleaned version of the array
|
| - |
|
15435 |
*/
|
| - |
|
15436 |
function cleanArray(array) {
|
| - |
|
15437 |
for (let index = 0; index < array.length; index++) {
|
| - |
|
15438 |
const isPropertyExist = objectHasOwnProperty(array, index);
|
| - |
|
15439 |
if (!isPropertyExist) {
|
| - |
|
15440 |
array[index] = null;
|
| - |
|
15441 |
}
|
| - |
|
15442 |
}
|
| - |
|
15443 |
return array;
|
| - |
|
15444 |
}
|
| - |
|
15445 |
/**
|
| - |
|
15446 |
* Shallow clone an object
|
| - |
|
15447 |
*
|
| - |
|
15448 |
* @param object - The object to be cloned.
|
| - |
|
15449 |
* @returns A new object that copies the original.
|
| 15169 |
}
|
15450 |
*/
|
| 15170 |
function clone(object) {
|
15451 |
function clone(object) {
|
| 15171 |
const newObject = create$7(null);
|
15452 |
const newObject = create$7(null);
|
| - |
|
15453 |
for (const [property, value] of entries(object)) {
|
| - |
|
15454 |
const isPropertyExist = objectHasOwnProperty(object, property);
|
| - |
|
15455 |
if (isPropertyExist) {
|
| - |
|
15456 |
if (Array.isArray(value)) {
|
| - |
|
15457 |
newObject[property] = cleanArray(value);
|
| - |
|
15458 |
} else if (value && typeof value === 'object' && value.constructor === Object) {
|
| - |
|
15459 |
newObject[property] = clone(value);
|
| 15172 |
for (const [property, value] of entries(object)) {
|
15460 |
} else {
|
| - |
|
15461 |
newObject[property] = value;
|
| - |
|
15462 |
}
|
| 15173 |
newObject[property] = value;
|
15463 |
}
|
| 15174 |
}
|
15464 |
}
|
| 15175 |
return newObject;
|
15465 |
return newObject;
|
| - |
|
15466 |
}
|
| - |
|
15467 |
/**
|
| - |
|
15468 |
* This method automatically checks if the prop is function or getter and behaves accordingly.
|
| - |
|
15469 |
*
|
| - |
|
15470 |
* @param object - The object to look up the getter function in its prototype chain.
|
| - |
|
15471 |
* @param prop - The property name for which to find the getter function.
|
| - |
|
15472 |
* @returns The getter function found in the prototype chain or a fallback function.
|
| 15176 |
}
|
15473 |
*/
|
| 15177 |
function lookupGetter(object, prop) {
|
15474 |
function lookupGetter(object, prop) {
|
| 15178 |
while (object !== null) {
|
15475 |
while (object !== null) {
|
| 15179 |
const desc = getOwnPropertyDescriptor(object, prop);
|
15476 |
const desc = getOwnPropertyDescriptor(object, prop);
|
| 15180 |
if (desc) {
|
15477 |
if (desc) {
|
| Línea 15185... |
Línea 15482... |
| 15185 |
return unapply(desc.value);
|
15482 |
return unapply(desc.value);
|
| 15186 |
}
|
15483 |
}
|
| 15187 |
}
|
15484 |
}
|
| 15188 |
object = getPrototypeOf(object);
|
15485 |
object = getPrototypeOf(object);
|
| 15189 |
}
|
15486 |
}
|
| 15190 |
function fallbackValue(element) {
|
15487 |
function fallbackValue() {
|
| 15191 |
console.warn('fallback value for', element);
|
- |
|
| 15192 |
return null;
|
15488 |
return null;
|
| 15193 |
}
|
15489 |
}
|
| 15194 |
return fallbackValue;
|
15490 |
return fallbackValue;
|
| 15195 |
}
|
15491 |
}
|
| 15196 |
const html$1 = freeze([
|
- |
|
| 15197 |
'a',
|
- |
|
| 15198 |
'abbr',
|
- |
|
| 15199 |
'acronym',
|
- |
|
| 15200 |
'address',
|
- |
|
| 15201 |
'area',
|
- |
|
| 15202 |
'article',
|
- |
|
| 15203 |
'aside',
|
- |
|
| 15204 |
'audio',
|
- |
|
| 15205 |
'b',
|
- |
|
| 15206 |
'bdi',
|
- |
|
| 15207 |
'bdo',
|
- |
|
| 15208 |
'big',
|
- |
|
| 15209 |
'blink',
|
- |
|
| 15210 |
'blockquote',
|
- |
|
| 15211 |
'body',
|
- |
|
| 15212 |
'br',
|
- |
|
| 15213 |
'button',
|
- |
|
| 15214 |
'canvas',
|
- |
|
| 15215 |
'caption',
|
- |
|
| 15216 |
'center',
|
- |
|
| 15217 |
'cite',
|
- |
|
| 15218 |
'code',
|
- |
|
| 15219 |
'col',
|
- |
|
| 15220 |
'colgroup',
|
- |
|
| 15221 |
'content',
|
- |
|
| 15222 |
'data',
|
- |
|
| 15223 |
'datalist',
|
- |
|
| 15224 |
'dd',
|
- |
|
| 15225 |
'decorator',
|
- |
|
| 15226 |
'del',
|
- |
|
| 15227 |
'details',
|
- |
|
| 15228 |
'dfn',
|
- |
|
| 15229 |
'dialog',
|
- |
|
| 15230 |
'dir',
|
- |
|
| 15231 |
'div',
|
- |
|
| 15232 |
'dl',
|
- |
|
| 15233 |
'dt',
|
- |
|
| 15234 |
'element',
|
- |
|
| 15235 |
'em',
|
- |
|
| 15236 |
'fieldset',
|
- |
|
| 15237 |
'figcaption',
|
- |
|
| 15238 |
'figure',
|
- |
|
| 15239 |
'font',
|
- |
|
| 15240 |
'footer',
|
- |
|
| 15241 |
'form',
|
- |
|
| 15242 |
'h1',
|
- |
|
| 15243 |
'h2',
|
- |
|
| 15244 |
'h3',
|
- |
|
| 15245 |
'h4',
|
- |
|
| 15246 |
'h5',
|
- |
|
| 15247 |
'h6',
|
- |
|
| 15248 |
'head',
|
- |
|
| 15249 |
'header',
|
- |
|
| 15250 |
'hgroup',
|
- |
|
| 15251 |
'hr',
|
- |
|
| 15252 |
'html',
|
- |
|
| 15253 |
'i',
|
- |
|
| 15254 |
'img',
|
- |
|
| 15255 |
'input',
|
- |
|
| 15256 |
'ins',
|
- |
|
| 15257 |
'kbd',
|
- |
|
| 15258 |
'label',
|
- |
|
| 15259 |
'legend',
|
- |
|
| 15260 |
'li',
|
- |
|
| 15261 |
'main',
|
- |
|
| 15262 |
'map',
|
- |
|
| 15263 |
'mark',
|
- |
|
| 15264 |
'marquee',
|
- |
|
| 15265 |
'menu',
|
- |
|
| 15266 |
'menuitem',
|
- |
|
| 15267 |
'meter',
|
- |
|
| 15268 |
'nav',
|
- |
|
| 15269 |
'nobr',
|
- |
|
| 15270 |
'ol',
|
- |
|
| 15271 |
'optgroup',
|
- |
|
| 15272 |
'option',
|
- |
|
| 15273 |
'output',
|
- |
|
| 15274 |
'p',
|
- |
|
| 15275 |
'picture',
|
- |
|
| 15276 |
'pre',
|
- |
|
| 15277 |
'progress',
|
- |
|
| 15278 |
'q',
|
- |
|
| 15279 |
'rp',
|
- |
|
| 15280 |
'rt',
|
- |
|
| 15281 |
'ruby',
|
- |
|
| 15282 |
's',
|
- |
|
| 15283 |
'samp',
|
- |
|
| 15284 |
'section',
|
- |
|
| 15285 |
'select',
|
- |
|
| 15286 |
'shadow',
|
- |
|
| 15287 |
'small',
|
- |
|
| 15288 |
'source',
|
- |
|
| 15289 |
'spacer',
|
- |
|
| 15290 |
'span',
|
- |
|
| 15291 |
'strike',
|
- |
|
| 15292 |
'strong',
|
- |
|
| 15293 |
'style',
|
- |
|
| 15294 |
'sub',
|
- |
|
| 15295 |
'summary',
|
- |
|
| 15296 |
'sup',
|
- |
|
| 15297 |
'table',
|
- |
|
| 15298 |
'tbody',
|
- |
|
| 15299 |
'td',
|
- |
|
| 15300 |
'template',
|
- |
|
| 15301 |
'textarea',
|
- |
|
| 15302 |
'tfoot',
|
- |
|
| 15303 |
'th',
|
- |
|
| 15304 |
'thead',
|
- |
|
| 15305 |
'time',
|
- |
|
| 15306 |
'tr',
|
- |
|
| 15307 |
'track',
|
- |
|
| 15308 |
'tt',
|
- |
|
| 15309 |
'u',
|
- |
|
| 15310 |
'ul',
|
- |
|
| 15311 |
'var',
|
- |
|
| 15312 |
'video',
|
- |
|
| 15313 |
'wbr'
|
- |
|
| 15314 |
]);
|
15492 |
|
| 15315 |
const svg$1 = freeze([
|
15493 |
const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
|
| 15316 |
'svg',
|
- |
|
| 15317 |
'a',
|
- |
|
| 15318 |
'altglyph',
|
- |
|
| 15319 |
'altglyphdef',
|
- |
|
| 15320 |
'altglyphitem',
|
- |
|
| 15321 |
'animatecolor',
|
- |
|
| 15322 |
'animatemotion',
|
- |
|
| 15323 |
'animatetransform',
|
15494 |
const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
|
| 15324 |
'circle',
|
- |
|
| 15325 |
'clippath',
|
- |
|
| 15326 |
'defs',
|
- |
|
| 15327 |
'desc',
|
- |
|
| 15328 |
'ellipse',
|
- |
|
| 15329 |
'filter',
|
- |
|
| 15330 |
'font',
|
- |
|
| 15331 |
'g',
|
- |
|
| 15332 |
'glyph',
|
- |
|
| 15333 |
'glyphref',
|
- |
|
| 15334 |
'hkern',
|
- |
|
| 15335 |
'image',
|
- |
|
| 15336 |
'line',
|
- |
|
| 15337 |
'lineargradient',
|
15495 |
const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
|
| 15338 |
'marker',
|
- |
|
| 15339 |
'mask',
|
- |
|
| 15340 |
'metadata',
|
- |
|
| 15341 |
'mpath',
|
- |
|
| 15342 |
'path',
|
- |
|
| 15343 |
'pattern',
|
- |
|
| 15344 |
'polygon',
|
- |
|
| 15345 |
'polyline',
|
- |
|
| 15346 |
'radialgradient',
|
- |
|
| 15347 |
'rect',
|
- |
|
| 15348 |
'stop',
|
- |
|
| 15349 |
'style',
|
- |
|
| 15350 |
'switch',
|
- |
|
| 15351 |
'symbol',
|
- |
|
| 15352 |
'text',
|
- |
|
| 15353 |
'textpath',
|
- |
|
| 15354 |
'title',
|
- |
|
| 15355 |
'tref',
|
- |
|
| 15356 |
'tspan',
|
- |
|
| 15357 |
'view',
|
- |
|
| 15358 |
'vkern'
|
- |
|
| 15359 |
]);
|
- |
|
| 15360 |
const svgFilters = freeze([
|
15496 |
// List of SVG elements that are disallowed by default.
|
| 15361 |
'feBlend',
|
- |
|
| 15362 |
'feColorMatrix',
|
- |
|
| 15363 |
'feComponentTransfer',
|
15497 |
// We still need to know them so that we can do namespace
|
| 15364 |
'feComposite',
|
- |
|
| 15365 |
'feConvolveMatrix',
|
- |
|
| 15366 |
'feDiffuseLighting',
|
- |
|
| 15367 |
'feDisplacementMap',
|
15498 |
// checks properly in case one wants to add them to
|
| 15368 |
'feDistantLight',
|
- |
|
| 15369 |
'feDropShadow',
|
- |
|
| 15370 |
'feFlood',
|
- |
|
| 15371 |
'feFuncA',
|
- |
|
| 15372 |
'feFuncB',
|
- |
|
| 15373 |
'feFuncG',
|
- |
|
| 15374 |
'feFuncR',
|
15499 |
// allow-list.
|
| 15375 |
'feGaussianBlur',
|
15500 |
const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
|
| 15376 |
'feImage',
|
- |
|
| 15377 |
'feMerge',
|
- |
|
| 15378 |
'feMergeNode',
|
- |
|
| 15379 |
'feMorphology',
|
- |
|
| 15380 |
'feOffset',
|
- |
|
| 15381 |
'fePointLight',
|
15501 |
const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
|
| 15382 |
'feSpecularLighting',
|
15502 |
// Similarly to SVG, we want to know all MathML elements,
|
| 15383 |
'feSpotLight',
|
- |
|
| 15384 |
'feTile',
|
- |
|
| 15385 |
'feTurbulence'
|
- |
|
| 15386 |
]);
|
- |
|
| 15387 |
const svgDisallowed = freeze([
|
15503 |
// even those that we disallow by default.
|
| 15388 |
'animate',
|
- |
|
| 15389 |
'color-profile',
|
- |
|
| 15390 |
'cursor',
|
- |
|
| 15391 |
'discard',
|
- |
|
| 15392 |
'font-face',
|
- |
|
| 15393 |
'font-face-format',
|
- |
|
| 15394 |
'font-face-name',
|
- |
|
| 15395 |
'font-face-src',
|
- |
|
| 15396 |
'font-face-uri',
|
- |
|
| 15397 |
'foreignobject',
|
- |
|
| 15398 |
'hatch',
|
- |
|
| 15399 |
'hatchpath',
|
- |
|
| 15400 |
'mesh',
|
- |
|
| 15401 |
'meshgradient',
|
- |
|
| 15402 |
'meshpatch',
|
- |
|
| 15403 |
'meshrow',
|
- |
|
| 15404 |
'missing-glyph',
|
- |
|
| 15405 |
'script',
|
- |
|
| 15406 |
'set',
|
- |
|
| 15407 |
'solidcolor',
|
- |
|
| 15408 |
'unknown',
|
- |
|
| 15409 |
'use'
|
- |
|
| 15410 |
]);
|
- |
|
| 15411 |
const mathMl$1 = freeze([
|
- |
|
| 15412 |
'math',
|
- |
|
| 15413 |
'menclose',
|
- |
|
| 15414 |
'merror',
|
- |
|
| 15415 |
'mfenced',
|
- |
|
| 15416 |
'mfrac',
|
- |
|
| 15417 |
'mglyph',
|
- |
|
| 15418 |
'mi',
|
- |
|
| 15419 |
'mlabeledtr',
|
- |
|
| 15420 |
'mmultiscripts',
|
- |
|
| 15421 |
'mn',
|
- |
|
| 15422 |
'mo',
|
- |
|
| 15423 |
'mover',
|
- |
|
| 15424 |
'mpadded',
|
- |
|
| 15425 |
'mphantom',
|
- |
|
| 15426 |
'mroot',
|
- |
|
| 15427 |
'mrow',
|
- |
|
| 15428 |
'ms',
|
- |
|
| 15429 |
'mspace',
|
- |
|
| 15430 |
'msqrt',
|
- |
|
| 15431 |
'mstyle',
|
- |
|
| 15432 |
'msub',
|
- |
|
| 15433 |
'msup',
|
- |
|
| 15434 |
'msubsup',
|
- |
|
| 15435 |
'mtable',
|
- |
|
| 15436 |
'mtd',
|
- |
|
| 15437 |
'mtext',
|
- |
|
| 15438 |
'mtr',
|
- |
|
| 15439 |
'munder',
|
- |
|
| 15440 |
'munderover',
|
- |
|
| 15441 |
'mprescripts'
|
- |
|
| 15442 |
]);
|
- |
|
| 15443 |
const mathMlDisallowed = freeze([
|
15504 |
const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
|
| 15444 |
'maction',
|
- |
|
| 15445 |
'maligngroup',
|
- |
|
| 15446 |
'malignmark',
|
- |
|
| 15447 |
'mlongdiv',
|
- |
|
| 15448 |
'mscarries',
|
- |
|
| 15449 |
'mscarry',
|
- |
|
| 15450 |
'msgroup',
|
- |
|
| 15451 |
'mstack',
|
- |
|
| 15452 |
'msline',
|
- |
|
| 15453 |
'msrow',
|
- |
|
| 15454 |
'semantics',
|
- |
|
| 15455 |
'annotation',
|
- |
|
| 15456 |
'annotation-xml',
|
- |
|
| 15457 |
'mprescripts',
|
- |
|
| 15458 |
'none'
|
- |
|
| 15459 |
]);
|
- |
|
| 15460 |
const text = freeze(['#text']);
|
15505 |
const text = freeze(['#text']);
|
| 15461 |
const html = freeze([
|
- |
|
| 15462 |
'accept',
|
- |
|
| 15463 |
'action',
|
- |
|
| 15464 |
'align',
|
- |
|
| 15465 |
'alt',
|
- |
|
| 15466 |
'autocapitalize',
|
- |
|
| 15467 |
'autocomplete',
|
- |
|
| 15468 |
'autopictureinpicture',
|
- |
|
| 15469 |
'autoplay',
|
- |
|
| 15470 |
'background',
|
- |
|
| 15471 |
'bgcolor',
|
- |
|
| 15472 |
'border',
|
- |
|
| 15473 |
'capture',
|
- |
|
| 15474 |
'cellpadding',
|
- |
|
| 15475 |
'cellspacing',
|
- |
|
| 15476 |
'checked',
|
- |
|
| 15477 |
'cite',
|
- |
|
| 15478 |
'class',
|
- |
|
| 15479 |
'clear',
|
- |
|
| 15480 |
'color',
|
- |
|
| 15481 |
'cols',
|
- |
|
| 15482 |
'colspan',
|
- |
|
| 15483 |
'controls',
|
- |
|
| 15484 |
'controlslist',
|
- |
|
| 15485 |
'coords',
|
- |
|
| 15486 |
'crossorigin',
|
- |
|
| 15487 |
'datetime',
|
- |
|
| 15488 |
'decoding',
|
- |
|
| 15489 |
'default',
|
- |
|
| 15490 |
'dir',
|
- |
|
| 15491 |
'disabled',
|
- |
|
| 15492 |
'disablepictureinpicture',
|
- |
|
| 15493 |
'disableremoteplayback',
|
- |
|
| 15494 |
'download',
|
- |
|
| 15495 |
'draggable',
|
- |
|
| 15496 |
'enctype',
|
- |
|
| 15497 |
'enterkeyhint',
|
- |
|
| 15498 |
'face',
|
- |
|
| 15499 |
'for',
|
- |
|
| 15500 |
'headers',
|
- |
|
| 15501 |
'height',
|
- |
|
| 15502 |
'hidden',
|
- |
|
| 15503 |
'high',
|
- |
|
| 15504 |
'href',
|
- |
|
| 15505 |
'hreflang',
|
- |
|
| 15506 |
'id',
|
- |
|
| 15507 |
'inputmode',
|
- |
|
| 15508 |
'integrity',
|
- |
|
| 15509 |
'ismap',
|
- |
|
| 15510 |
'kind',
|
- |
|
| 15511 |
'label',
|
- |
|
| 15512 |
'lang',
|
- |
|
| 15513 |
'list',
|
- |
|
| 15514 |
'loading',
|
- |
|
| 15515 |
'loop',
|
- |
|
| 15516 |
'low',
|
- |
|
| 15517 |
'max',
|
- |
|
| 15518 |
'maxlength',
|
- |
|
| 15519 |
'media',
|
- |
|
| 15520 |
'method',
|
- |
|
| 15521 |
'min',
|
- |
|
| 15522 |
'minlength',
|
- |
|
| 15523 |
'multiple',
|
- |
|
| 15524 |
'muted',
|
- |
|
| 15525 |
'name',
|
- |
|
| 15526 |
'nonce',
|
- |
|
| 15527 |
'noshade',
|
- |
|
| 15528 |
'novalidate',
|
- |
|
| 15529 |
'nowrap',
|
- |
|
| 15530 |
'open',
|
- |
|
| 15531 |
'optimum',
|
- |
|
| 15532 |
'pattern',
|
- |
|
| 15533 |
'placeholder',
|
- |
|
| 15534 |
'playsinline',
|
- |
|
| 15535 |
'poster',
|
- |
|
| 15536 |
'preload',
|
- |
|
| 15537 |
'pubdate',
|
- |
|
| 15538 |
'radiogroup',
|
- |
|
| 15539 |
'readonly',
|
- |
|
| 15540 |
'rel',
|
- |
|
| 15541 |
'required',
|
- |
|
| 15542 |
'rev',
|
- |
|
| 15543 |
'reversed',
|
- |
|
| 15544 |
'role',
|
- |
|
| 15545 |
'rows',
|
- |
|
| 15546 |
'rowspan',
|
- |
|
| 15547 |
'spellcheck',
|
- |
|
| 15548 |
'scope',
|
- |
|
| 15549 |
'selected',
|
- |
|
| 15550 |
'shape',
|
- |
|
| 15551 |
'size',
|
- |
|
| 15552 |
'sizes',
|
- |
|
| 15553 |
'span',
|
- |
|
| 15554 |
'srclang',
|
- |
|
| 15555 |
'start',
|
- |
|
| 15556 |
'src',
|
- |
|
| 15557 |
'srcset',
|
- |
|
| 15558 |
'step',
|
- |
|
| 15559 |
'style',
|
- |
|
| 15560 |
'summary',
|
- |
|
| 15561 |
'tabindex',
|
- |
|
| 15562 |
'title',
|
- |
|
| 15563 |
'translate',
|
- |
|
| 15564 |
'type',
|
- |
|
| 15565 |
'usemap',
|
- |
|
| 15566 |
'valign',
|
- |
|
| 15567 |
'value',
|
- |
|
| 15568 |
'width',
|
- |
|
| 15569 |
'xmlns',
|
- |
|
| 15570 |
'slot'
|
- |
|
| 15571 |
]);
|
15506 |
|
| 15572 |
const svg = freeze([
|
15507 |
const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
|
| 15573 |
'accent-height',
|
- |
|
| 15574 |
'accumulate',
|
- |
|
| 15575 |
'additive',
|
- |
|
| 15576 |
'alignment-baseline',
|
15508 |
const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
|
| 15577 |
'ascent',
|
- |
|
| 15578 |
'attributename',
|
- |
|
| 15579 |
'attributetype',
|
- |
|
| 15580 |
'azimuth',
|
- |
|
| 15581 |
'basefrequency',
|
- |
|
| 15582 |
'baseline-shift',
|
- |
|
| 15583 |
'begin',
|
- |
|
| 15584 |
'bias',
|
- |
|
| 15585 |
'by',
|
- |
|
| 15586 |
'class',
|
- |
|
| 15587 |
'clip',
|
- |
|
| 15588 |
'clippathunits',
|
- |
|
| 15589 |
'clip-path',
|
- |
|
| 15590 |
'clip-rule',
|
- |
|
| 15591 |
'color',
|
- |
|
| 15592 |
'color-interpolation',
|
15509 |
const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
|
| 15593 |
'color-interpolation-filters',
|
15510 |
const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
|
| 15594 |
'color-profile',
|
- |
|
| 15595 |
'color-rendering',
|
- |
|
| 15596 |
'cx',
|
- |
|
| 15597 |
'cy',
|
- |
|
| 15598 |
'd',
|
- |
|
| 15599 |
'dx',
|
- |
|
| 15600 |
'dy',
|
- |
|
| 15601 |
'diffuseconstant',
|
- |
|
| 15602 |
'direction',
|
- |
|
| 15603 |
'display',
|
- |
|
| 15604 |
'divisor',
|
- |
|
| 15605 |
'dur',
|
- |
|
| 15606 |
'edgemode',
|
- |
|
| 15607 |
'elevation',
|
- |
|
| 15608 |
'end',
|
- |
|
| 15609 |
'fill',
|
- |
|
| 15610 |
'fill-opacity',
|
- |
|
| 15611 |
'fill-rule',
|
- |
|
| 15612 |
'filter',
|
- |
|
| 15613 |
'filterunits',
|
- |
|
| 15614 |
'flood-color',
|
- |
|
| 15615 |
'flood-opacity',
|
- |
|
| 15616 |
'font-family',
|
- |
|
| 15617 |
'font-size',
|
- |
|
| 15618 |
'font-size-adjust',
|
- |
|
| 15619 |
'font-stretch',
|
- |
|
| 15620 |
'font-style',
|
- |
|
| 15621 |
'font-variant',
|
- |
|
| 15622 |
'font-weight',
|
- |
|
| 15623 |
'fx',
|
- |
|
| 15624 |
'fy',
|
- |
|
| 15625 |
'g1',
|
- |
|
| 15626 |
'g2',
|
- |
|
| 15627 |
'glyph-name',
|
- |
|
| 15628 |
'glyphref',
|
- |
|
| 15629 |
'gradientunits',
|
- |
|
| 15630 |
'gradienttransform',
|
- |
|
| 15631 |
'height',
|
- |
|
| 15632 |
'href',
|
- |
|
| 15633 |
'id',
|
- |
|
| 15634 |
'image-rendering',
|
- |
|
| 15635 |
'in',
|
- |
|
| 15636 |
'in2',
|
- |
|
| 15637 |
'k',
|
- |
|
| 15638 |
'k1',
|
- |
|
| 15639 |
'k2',
|
- |
|
| 15640 |
'k3',
|
- |
|
| 15641 |
'k4',
|
- |
|
| 15642 |
'kerning',
|
- |
|
| 15643 |
'keypoints',
|
- |
|
| 15644 |
'keysplines',
|
- |
|
| 15645 |
'keytimes',
|
- |
|
| 15646 |
'lang',
|
- |
|
| 15647 |
'lengthadjust',
|
- |
|
| 15648 |
'letter-spacing',
|
- |
|
| 15649 |
'kernelmatrix',
|
- |
|
| 15650 |
'kernelunitlength',
|
- |
|
| 15651 |
'lighting-color',
|
- |
|
| 15652 |
'local',
|
- |
|
| 15653 |
'marker-end',
|
- |
|
| 15654 |
'marker-mid',
|
- |
|
| 15655 |
'marker-start',
|
- |
|
| 15656 |
'markerheight',
|
- |
|
| 15657 |
'markerunits',
|
- |
|
| 15658 |
'markerwidth',
|
- |
|
| 15659 |
'maskcontentunits',
|
- |
|
| 15660 |
'maskunits',
|
- |
|
| 15661 |
'max',
|
- |
|
| 15662 |
'mask',
|
- |
|
| 15663 |
'media',
|
- |
|
| 15664 |
'method',
|
- |
|
| 15665 |
'mode',
|
- |
|
| 15666 |
'min',
|
- |
|
| 15667 |
'name',
|
- |
|
| 15668 |
'numoctaves',
|
- |
|
| 15669 |
'offset',
|
- |
|
| 15670 |
'operator',
|
- |
|
| 15671 |
'opacity',
|
- |
|
| 15672 |
'order',
|
- |
|
| 15673 |
'orient',
|
- |
|
| 15674 |
'orientation',
|
- |
|
| 15675 |
'origin',
|
- |
|
| 15676 |
'overflow',
|
- |
|
| 15677 |
'paint-order',
|
- |
|
| 15678 |
'path',
|
- |
|
| 15679 |
'pathlength',
|
- |
|
| 15680 |
'patterncontentunits',
|
- |
|
| 15681 |
'patterntransform',
|
- |
|
| 15682 |
'patternunits',
|
- |
|
| 15683 |
'points',
|
- |
|
| 15684 |
'preservealpha',
|
- |
|
| 15685 |
'preserveaspectratio',
|
- |
|
| 15686 |
'primitiveunits',
|
- |
|
| 15687 |
'r',
|
- |
|
| 15688 |
'rx',
|
- |
|
| 15689 |
'ry',
|
- |
|
| 15690 |
'radius',
|
- |
|
| 15691 |
'refx',
|
- |
|
| 15692 |
'refy',
|
- |
|
| 15693 |
'repeatcount',
|
- |
|
| 15694 |
'repeatdur',
|
- |
|
| 15695 |
'restart',
|
- |
|
| 15696 |
'result',
|
- |
|
| 15697 |
'rotate',
|
- |
|
| 15698 |
'scale',
|
- |
|
| 15699 |
'seed',
|
- |
|
| 15700 |
'shape-rendering',
|
- |
|
| 15701 |
'specularconstant',
|
- |
|
| 15702 |
'specularexponent',
|
- |
|
| 15703 |
'spreadmethod',
|
- |
|
| 15704 |
'startoffset',
|
- |
|
| 15705 |
'stddeviation',
|
- |
|
| 15706 |
'stitchtiles',
|
- |
|
| 15707 |
'stop-color',
|
- |
|
| 15708 |
'stop-opacity',
|
- |
|
| 15709 |
'stroke-dasharray',
|
- |
|
| 15710 |
'stroke-dashoffset',
|
- |
|
| 15711 |
'stroke-linecap',
|
- |
|
| 15712 |
'stroke-linejoin',
|
- |
|
| 15713 |
'stroke-miterlimit',
|
- |
|
| 15714 |
'stroke-opacity',
|
- |
|
| 15715 |
'stroke',
|
- |
|
| 15716 |
'stroke-width',
|
- |
|
| 15717 |
'style',
|
- |
|
| 15718 |
'surfacescale',
|
- |
|
| 15719 |
'systemlanguage',
|
- |
|
| 15720 |
'tabindex',
|
- |
|
| 15721 |
'targetx',
|
- |
|
| 15722 |
'targety',
|
- |
|
| 15723 |
'transform',
|
- |
|
| 15724 |
'transform-origin',
|
- |
|
| 15725 |
'text-anchor',
|
- |
|
| 15726 |
'text-decoration',
|
- |
|
| 15727 |
'text-rendering',
|
- |
|
| 15728 |
'textlength',
|
- |
|
| 15729 |
'type',
|
- |
|
| 15730 |
'u1',
|
- |
|
| 15731 |
'u2',
|
- |
|
| 15732 |
'unicode',
|
- |
|
| 15733 |
'values',
|
- |
|
| 15734 |
'viewbox',
|
- |
|
| 15735 |
'visibility',
|
- |
|
| 15736 |
'version',
|
- |
|
| 15737 |
'vert-adv-y',
|
- |
|
| 15738 |
'vert-origin-x',
|
- |
|
| 15739 |
'vert-origin-y',
|
- |
|
| 15740 |
'width',
|
- |
|
| 15741 |
'word-spacing',
|
- |
|
| 15742 |
'wrap',
|
- |
|
| 15743 |
'writing-mode',
|
- |
|
| 15744 |
'xchannelselector',
|
- |
|
| 15745 |
'ychannelselector',
|
- |
|
| 15746 |
'x',
|
- |
|
| 15747 |
'x1',
|
- |
|
| 15748 |
'x2',
|
- |
|
| 15749 |
'xmlns',
|
- |
|
| 15750 |
'y',
|
- |
|
| 15751 |
'y1',
|
- |
|
| 15752 |
'y2',
|
- |
|
| 15753 |
'z',
|
- |
|
| 15754 |
'zoomandpan'
|
- |
|
| 15755 |
]);
|
15511 |
|
| 15756 |
const mathMl = freeze([
|
- |
|
| 15757 |
'accent',
|
- |
|
| 15758 |
'accentunder',
|
- |
|
| 15759 |
'align',
|
- |
|
| 15760 |
'bevelled',
|
- |
|
| 15761 |
'close',
|
- |
|
| 15762 |
'columnsalign',
|
- |
|
| 15763 |
'columnlines',
|
- |
|
| 15764 |
'columnspan',
|
- |
|
| 15765 |
'denomalign',
|
- |
|
| 15766 |
'depth',
|
- |
|
| 15767 |
'dir',
|
- |
|
| 15768 |
'display',
|
- |
|
| 15769 |
'displaystyle',
|
- |
|
| 15770 |
'encoding',
|
- |
|
| 15771 |
'fence',
|
- |
|
| 15772 |
'frame',
|
- |
|
| 15773 |
'height',
|
- |
|
| 15774 |
'href',
|
- |
|
| 15775 |
'id',
|
- |
|
| 15776 |
'largeop',
|
- |
|
| 15777 |
'length',
|
- |
|
| 15778 |
'linethickness',
|
- |
|
| 15779 |
'lspace',
|
- |
|
| 15780 |
'lquote',
|
- |
|
| 15781 |
'mathbackground',
|
- |
|
| 15782 |
'mathcolor',
|
- |
|
| 15783 |
'mathsize',
|
- |
|
| 15784 |
'mathvariant',
|
- |
|
| 15785 |
'maxsize',
|
- |
|
| 15786 |
'minsize',
|
- |
|
| 15787 |
'movablelimits',
|
- |
|
| 15788 |
'notation',
|
- |
|
| 15789 |
'numalign',
|
- |
|
| 15790 |
'open',
|
- |
|
| 15791 |
'rowalign',
|
- |
|
| 15792 |
'rowlines',
|
- |
|
| 15793 |
'rowspacing',
|
- |
|
| 15794 |
'rowspan',
|
- |
|
| 15795 |
'rspace',
|
- |
|
| 15796 |
'rquote',
|
- |
|
| 15797 |
'scriptlevel',
|
- |
|
| 15798 |
'scriptminsize',
|
- |
|
| 15799 |
'scriptsizemultiplier',
|
15512 |
// eslint-disable-next-line unicorn/better-regex
|
| 15800 |
'selection',
|
- |
|
| 15801 |
'separator',
|
- |
|
| 15802 |
'separators',
|
- |
|
| 15803 |
'stretchy',
|
- |
|
| 15804 |
'subscriptshift',
|
- |
|
| 15805 |
'supscriptshift',
|
- |
|
| 15806 |
'symmetric',
|
- |
|
| 15807 |
'voffset',
|
- |
|
| 15808 |
'width',
|
- |
|
| 15809 |
'xmlns'
|
- |
|
| 15810 |
]);
|
- |
|
| 15811 |
const xml = freeze([
|
- |
|
| 15812 |
'xlink:href',
|
- |
|
| 15813 |
'xml:id',
|
- |
|
| 15814 |
'xlink:title',
|
- |
|
| 15815 |
'xml:space',
|
- |
|
| 15816 |
'xmlns:xlink'
|
- |
|
| 15817 |
]);
|
- |
|
| 15818 |
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
|
15513 |
const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
|
| 15819 |
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
15514 |
const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
|
| 15820 |
const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
|
15515 |
const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
|
| 15821 |
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/);
|
15516 |
const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
|
| 15822 |
const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
|
15517 |
const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
|
| 15823 |
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
|
15518 |
const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
|
| - |
|
15519 |
);
|
| 15824 |
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
15520 |
const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
|
| 15825 |
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
|
15521 |
const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
|
| - |
|
15522 |
);
|
| 15826 |
const DOCTYPE_NAME = seal(/^html$/i);
|
15523 |
const DOCTYPE_NAME = seal(/^html$/i);
|
| - |
|
15524 |
const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
| - |
|
15525 |
|
| 15827 |
var EXPRESSIONS = Object.freeze({
|
15526 |
var EXPRESSIONS = /*#__PURE__*/Object.freeze({
|
| 15828 |
__proto__: null,
|
15527 |
__proto__: null,
|
| 15829 |
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
- |
|
| 15830 |
ERB_EXPR: ERB_EXPR,
|
- |
|
| 15831 |
TMPLIT_EXPR: TMPLIT_EXPR,
|
- |
|
| 15832 |
DATA_ATTR: DATA_ATTR,
|
- |
|
| 15833 |
ARIA_ATTR: ARIA_ATTR,
|
15528 |
ARIA_ATTR: ARIA_ATTR,
|
| - |
|
15529 |
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
| - |
|
15530 |
CUSTOM_ELEMENT: CUSTOM_ELEMENT,
|
| - |
|
15531 |
DATA_ATTR: DATA_ATTR,
|
| - |
|
15532 |
DOCTYPE_NAME: DOCTYPE_NAME,
|
| - |
|
15533 |
ERB_EXPR: ERB_EXPR,
|
| 15834 |
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
15534 |
IS_ALLOWED_URI: IS_ALLOWED_URI,
|
| 15835 |
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
15535 |
IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
|
| 15836 |
ATTR_WHITESPACE: ATTR_WHITESPACE,
|
15536 |
MUSTACHE_EXPR: MUSTACHE_EXPR,
|
| 15837 |
DOCTYPE_NAME: DOCTYPE_NAME
|
15537 |
TMPLIT_EXPR: TMPLIT_EXPR
|
| 15838 |
});
|
15538 |
});
|
| - |
|
15539 |
|
| - |
|
15540 |
/* eslint-disable @typescript-eslint/indent */
|
| - |
|
15541 |
// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
| - |
|
15542 |
const NODE_TYPE = {
|
| - |
|
15543 |
element: 1,
|
| - |
|
15544 |
attribute: 2,
|
| - |
|
15545 |
text: 3,
|
| - |
|
15546 |
cdataSection: 4,
|
| - |
|
15547 |
entityReference: 5,
|
| - |
|
15548 |
// Deprecated
|
| - |
|
15549 |
entityNode: 6,
|
| - |
|
15550 |
// Deprecated
|
| - |
|
15551 |
progressingInstruction: 7,
|
| - |
|
15552 |
comment: 8,
|
| - |
|
15553 |
document: 9,
|
| - |
|
15554 |
documentType: 10,
|
| - |
|
15555 |
documentFragment: 11,
|
| - |
|
15556 |
notation: 12 // Deprecated
|
| - |
|
15557 |
};
|
| - |
|
15558 |
const getGlobal = function getGlobal() {
|
| 15839 |
const getGlobal = () => typeof window === 'undefined' ? null : window;
|
15559 |
return typeof window === 'undefined' ? null : window;
|
| - |
|
15560 |
};
|
| - |
|
15561 |
/**
|
| - |
|
15562 |
* Creates a no-op policy for internal use only.
|
| - |
|
15563 |
* Don't export this function outside this module!
|
| - |
|
15564 |
* @param trustedTypes The policy factory.
|
| - |
|
15565 |
* @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
|
| - |
|
15566 |
* @return The policy created (or null, if Trusted Types
|
| - |
|
15567 |
* are not supported or creating the policy failed).
|
| - |
|
15568 |
*/
|
| 15840 |
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
15569 |
const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
|
| 15841 |
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
15570 |
if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
|
| 15842 |
return null;
|
15571 |
return null;
|
| 15843 |
}
|
15572 |
}
|
| - |
|
15573 |
// Allow the callers to control the unique policy name
|
| - |
|
15574 |
// by adding a data-tt-policy-suffix to the script element with the DOMPurify.
|
| - |
|
15575 |
// Policy creation with duplicate names throws in Trusted Types.
|
| 15844 |
let suffix = null;
|
15576 |
let suffix = null;
|
| 15845 |
const ATTR_NAME = 'data-tt-policy-suffix';
|
15577 |
const ATTR_NAME = 'data-tt-policy-suffix';
|
| 15846 |
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
15578 |
if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
|
| 15847 |
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
15579 |
suffix = purifyHostElement.getAttribute(ATTR_NAME);
|
| 15848 |
}
|
15580 |
}
|
| Línea 15855... |
Línea 15587... |
| 15855 |
createScriptURL(scriptUrl) {
|
15587 |
createScriptURL(scriptUrl) {
|
| 15856 |
return scriptUrl;
|
15588 |
return scriptUrl;
|
| 15857 |
}
|
15589 |
}
|
| 15858 |
});
|
15590 |
});
|
| 15859 |
} catch (_) {
|
15591 |
} catch (_) {
|
| - |
|
15592 |
// Policy creation failed (most likely another DOMPurify script has
|
| - |
|
15593 |
// already run). Skip creating the policy, as this will only cause errors
|
| - |
|
15594 |
// if TT are enforced.
|
| 15860 |
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
15595 |
console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
|
| 15861 |
return null;
|
15596 |
return null;
|
| 15862 |
}
|
15597 |
}
|
| 15863 |
};
|
15598 |
};
|
| - |
|
15599 |
const _createHooksMap = function _createHooksMap() {
|
| - |
|
15600 |
return {
|
| - |
|
15601 |
afterSanitizeAttributes: [],
|
| - |
|
15602 |
afterSanitizeElements: [],
|
| - |
|
15603 |
afterSanitizeShadowDOM: [],
|
| - |
|
15604 |
beforeSanitizeAttributes: [],
|
| - |
|
15605 |
beforeSanitizeElements: [],
|
| - |
|
15606 |
beforeSanitizeShadowDOM: [],
|
| - |
|
15607 |
uponSanitizeAttribute: [],
|
| - |
|
15608 |
uponSanitizeElement: [],
|
| - |
|
15609 |
uponSanitizeShadowNode: []
|
| - |
|
15610 |
};
|
| - |
|
15611 |
};
|
| 15864 |
function createDOMPurify() {
|
15612 |
function createDOMPurify() {
|
| 15865 |
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
15613 |
let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
|
| 15866 |
const DOMPurify = root => createDOMPurify(root);
|
15614 |
const DOMPurify = root => createDOMPurify(root);
|
| 15867 |
DOMPurify.version = '3.0.5';
|
15615 |
DOMPurify.version = '3.2.4';
|
| 15868 |
DOMPurify.removed = [];
|
15616 |
DOMPurify.removed = [];
|
| 15869 |
if (!window || !window.document || window.document.nodeType !== 9) {
|
15617 |
if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
|
| - |
|
15618 |
// Not running in a browser, provide a factory function
|
| - |
|
15619 |
// so that you can pass your own Window
|
| 15870 |
DOMPurify.isSupported = false;
|
15620 |
DOMPurify.isSupported = false;
|
| 15871 |
return DOMPurify;
|
15621 |
return DOMPurify;
|
| 15872 |
}
|
15622 |
}
|
| - |
|
15623 |
let {
|
| - |
|
15624 |
document
|
| - |
|
15625 |
} = window;
|
| 15873 |
const originalDocument = window.document;
|
15626 |
const originalDocument = document;
|
| 15874 |
const currentScript = originalDocument.currentScript;
|
15627 |
const currentScript = originalDocument.currentScript;
|
| - |
|
15628 |
const {
|
| 15875 |
let {document} = window;
|
15629 |
DocumentFragment,
|
| - |
|
15630 |
HTMLTemplateElement,
|
| - |
|
15631 |
Node,
|
| - |
|
15632 |
Element,
|
| - |
|
15633 |
NodeFilter,
|
| 15876 |
const {DocumentFragment, HTMLTemplateElement, Node, Element, NodeFilter, NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, HTMLFormElement, DOMParser, trustedTypes} = window;
|
15634 |
NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
|
| - |
|
15635 |
HTMLFormElement,
|
| - |
|
15636 |
DOMParser,
|
| - |
|
15637 |
trustedTypes
|
| - |
|
15638 |
} = window;
|
| 15877 |
const ElementPrototype = Element.prototype;
|
15639 |
const ElementPrototype = Element.prototype;
|
| 15878 |
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
15640 |
const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
|
| - |
|
15641 |
const remove = lookupGetter(ElementPrototype, 'remove');
|
| 15879 |
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
15642 |
const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
|
| 15880 |
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
15643 |
const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
|
| 15881 |
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
15644 |
const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
|
| - |
|
15645 |
// As per issue #47, the web-components registry is inherited by a
|
| - |
|
15646 |
// new document created via createHTMLDocument. As per the spec
|
| - |
|
15647 |
// (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
|
| - |
|
15648 |
// a new empty registry is used when creating a template contents owner
|
| - |
|
15649 |
// document, so we use that as our parent document to ensure nothing
|
| - |
|
15650 |
// is inherited.
|
| 15882 |
if (typeof HTMLTemplateElement === 'function') {
|
15651 |
if (typeof HTMLTemplateElement === 'function') {
|
| 15883 |
const template = document.createElement('template');
|
15652 |
const template = document.createElement('template');
|
| 15884 |
if (template.content && template.content.ownerDocument) {
|
15653 |
if (template.content && template.content.ownerDocument) {
|
| 15885 |
document = template.content.ownerDocument;
|
15654 |
document = template.content.ownerDocument;
|
| 15886 |
}
|
15655 |
}
|
| 15887 |
}
|
15656 |
}
|
| 15888 |
let trustedTypesPolicy;
|
15657 |
let trustedTypesPolicy;
|
| 15889 |
let emptyHTML = '';
|
15658 |
let emptyHTML = '';
|
| - |
|
15659 |
const {
|
| - |
|
15660 |
implementation,
|
| - |
|
15661 |
createNodeIterator,
|
| 15890 |
const {implementation, createNodeIterator, createDocumentFragment, getElementsByTagName} = document;
|
15662 |
createDocumentFragment,
|
| - |
|
15663 |
getElementsByTagName
|
| - |
|
15664 |
} = document;
|
| - |
|
15665 |
const {
|
| - |
|
15666 |
importNode
|
| 15891 |
const {importNode} = originalDocument;
|
15667 |
} = originalDocument;
|
| 15892 |
let hooks = {};
|
15668 |
let hooks = _createHooksMap();
|
| - |
|
15669 |
/**
|
| - |
|
15670 |
* Expose whether this browser supports running the full DOMPurify.
|
| - |
|
15671 |
*/
|
| 15893 |
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
15672 |
DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
|
| - |
|
15673 |
const {
|
| - |
|
15674 |
MUSTACHE_EXPR,
|
| - |
|
15675 |
ERB_EXPR,
|
| - |
|
15676 |
TMPLIT_EXPR,
|
| - |
|
15677 |
DATA_ATTR,
|
| - |
|
15678 |
ARIA_ATTR,
|
| 15894 |
const {MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR, DATA_ATTR, ARIA_ATTR, IS_SCRIPT_OR_DATA, ATTR_WHITESPACE} = EXPRESSIONS;
|
15679 |
IS_SCRIPT_OR_DATA,
|
| - |
|
15680 |
ATTR_WHITESPACE,
|
| - |
|
15681 |
CUSTOM_ELEMENT
|
| - |
|
15682 |
} = EXPRESSIONS;
|
| - |
|
15683 |
let {
|
| 15895 |
let {IS_ALLOWED_URI: IS_ALLOWED_URI$1} = EXPRESSIONS;
|
15684 |
IS_ALLOWED_URI: IS_ALLOWED_URI$1
|
| - |
|
15685 |
} = EXPRESSIONS;
|
| - |
|
15686 |
/**
|
| - |
|
15687 |
* We consider the elements and attributes below to be safe. Ideally
|
| - |
|
15688 |
* don't add any new ones but feel free to remove unwanted ones.
|
| - |
|
15689 |
*/
|
| - |
|
15690 |
/* allowed element names */
|
| 15896 |
let ALLOWED_TAGS = null;
|
15691 |
let ALLOWED_TAGS = null;
|
| 15897 |
const DEFAULT_ALLOWED_TAGS = addToSet({}, [
|
15692 |
const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
|
| 15898 |
...html$1,
|
- |
|
| 15899 |
...svg$1,
|
- |
|
| 15900 |
...svgFilters,
|
15693 |
/* Allowed attribute names */
|
| 15901 |
...mathMl$1,
|
- |
|
| 15902 |
...text
|
- |
|
| 15903 |
]);
|
- |
|
| 15904 |
let ALLOWED_ATTR = null;
|
15694 |
let ALLOWED_ATTR = null;
|
| 15905 |
const DEFAULT_ALLOWED_ATTR = addToSet({}, [
|
15695 |
const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
|
| 15906 |
...html,
|
- |
|
| 15907 |
...svg,
|
15696 |
/*
|
| 15908 |
...mathMl,
|
15697 |
* Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
|
| 15909 |
...xml
|
- |
|
| - |
|
15698 |
* @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
|
| - |
|
15699 |
* @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
|
| - |
|
15700 |
* @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
|
| 15910 |
]);
|
15701 |
*/
|
| 15911 |
let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
|
15702 |
let CUSTOM_ELEMENT_HANDLING = Object.seal(create$7(null, {
|
| 15912 |
tagNameCheck: {
|
15703 |
tagNameCheck: {
|
| 15913 |
writable: true,
|
15704 |
writable: true,
|
| 15914 |
configurable: false,
|
15705 |
configurable: false,
|
| 15915 |
enumerable: true,
|
15706 |
enumerable: true,
|
| 15916 |
value: null
|
15707 |
value: null
|
| Línea 15926... |
Línea 15717... |
| 15926 |
configurable: false,
|
15717 |
configurable: false,
|
| 15927 |
enumerable: true,
|
15718 |
enumerable: true,
|
| 15928 |
value: false
|
15719 |
value: false
|
| 15929 |
}
|
15720 |
}
|
| 15930 |
}));
|
15721 |
}));
|
| - |
|
15722 |
/* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
|
| 15931 |
let FORBID_TAGS = null;
|
15723 |
let FORBID_TAGS = null;
|
| - |
|
15724 |
/* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
|
| 15932 |
let FORBID_ATTR = null;
|
15725 |
let FORBID_ATTR = null;
|
| - |
|
15726 |
/* Decide if ARIA attributes are okay */
|
| 15933 |
let ALLOW_ARIA_ATTR = true;
|
15727 |
let ALLOW_ARIA_ATTR = true;
|
| - |
|
15728 |
/* Decide if custom data attributes are okay */
|
| 15934 |
let ALLOW_DATA_ATTR = true;
|
15729 |
let ALLOW_DATA_ATTR = true;
|
| - |
|
15730 |
/* Decide if unknown protocols are okay */
|
| 15935 |
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
15731 |
let ALLOW_UNKNOWN_PROTOCOLS = false;
|
| - |
|
15732 |
/* Decide if self-closing tags in attributes are allowed.
|
| - |
|
15733 |
* Usually removed due to a mXSS issue in jQuery 3.0 */
|
| 15936 |
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
15734 |
let ALLOW_SELF_CLOSE_IN_ATTR = true;
|
| - |
|
15735 |
/* Output should be safe for common template engines.
|
| - |
|
15736 |
* This means, DOMPurify removes data attributes, mustaches and ERB
|
| - |
|
15737 |
*/
|
| 15937 |
let SAFE_FOR_TEMPLATES = false;
|
15738 |
let SAFE_FOR_TEMPLATES = false;
|
| - |
|
15739 |
/* Output should be safe even for XML used within HTML and alike.
|
| - |
|
15740 |
* This means, DOMPurify removes comments when containing risky content.
|
| - |
|
15741 |
*/
|
| - |
|
15742 |
let SAFE_FOR_XML = true;
|
| - |
|
15743 |
/* Decide if document with <html>... should be returned */
|
| 15938 |
let WHOLE_DOCUMENT = false;
|
15744 |
let WHOLE_DOCUMENT = false;
|
| - |
|
15745 |
/* Track whether config is already set on this instance of DOMPurify. */
|
| 15939 |
let SET_CONFIG = false;
|
15746 |
let SET_CONFIG = false;
|
| - |
|
15747 |
/* Decide if all elements (e.g. style, script) must be children of
|
| - |
|
15748 |
* document.body. By default, browsers might move them to document.head */
|
| 15940 |
let FORCE_BODY = false;
|
15749 |
let FORCE_BODY = false;
|
| - |
|
15750 |
/* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
|
| - |
|
15751 |
* string (or a TrustedHTML object if Trusted Types are supported).
|
| - |
|
15752 |
* If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
|
| - |
|
15753 |
*/
|
| 15941 |
let RETURN_DOM = false;
|
15754 |
let RETURN_DOM = false;
|
| - |
|
15755 |
/* Decide if a DOM `DocumentFragment` should be returned, instead of a html
|
| - |
|
15756 |
* string (or a TrustedHTML object if Trusted Types are supported) */
|
| 15942 |
let RETURN_DOM_FRAGMENT = false;
|
15757 |
let RETURN_DOM_FRAGMENT = false;
|
| - |
|
15758 |
/* Try to return a Trusted Type object instead of a string, return a string in
|
| - |
|
15759 |
* case Trusted Types are not supported */
|
| 15943 |
let RETURN_TRUSTED_TYPE = false;
|
15760 |
let RETURN_TRUSTED_TYPE = false;
|
| - |
|
15761 |
/* Output should be free from DOM clobbering attacks?
|
| - |
|
15762 |
* This sanitizes markups named with colliding, clobberable built-in DOM APIs.
|
| - |
|
15763 |
*/
|
| 15944 |
let SANITIZE_DOM = true;
|
15764 |
let SANITIZE_DOM = true;
|
| - |
|
15765 |
/* Achieve full DOM Clobbering protection by isolating the namespace of named
|
| - |
|
15766 |
* properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
|
| - |
|
15767 |
*
|
| - |
|
15768 |
* HTML/DOM spec rules that enable DOM Clobbering:
|
| - |
|
15769 |
* - Named Access on Window (§7.3.3)
|
| - |
|
15770 |
* - DOM Tree Accessors (§3.1.5)
|
| - |
|
15771 |
* - Form Element Parent-Child Relations (§4.10.3)
|
| - |
|
15772 |
* - Iframe srcdoc / Nested WindowProxies (§4.8.5)
|
| - |
|
15773 |
* - HTMLCollection (§4.2.10.2)
|
| - |
|
15774 |
*
|
| - |
|
15775 |
* Namespace isolation is implemented by prefixing `id` and `name` attributes
|
| - |
|
15776 |
* with a constant string, i.e., `user-content-`
|
| - |
|
15777 |
*/
|
| 15945 |
let SANITIZE_NAMED_PROPS = false;
|
15778 |
let SANITIZE_NAMED_PROPS = false;
|
| 15946 |
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
15779 |
const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
|
| - |
|
15780 |
/* Keep element content when removing element? */
|
| 15947 |
let KEEP_CONTENT = true;
|
15781 |
let KEEP_CONTENT = true;
|
| - |
|
15782 |
/* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
|
| - |
|
15783 |
* of importing it into a new Document and returning a sanitized copy */
|
| 15948 |
let IN_PLACE = false;
|
15784 |
let IN_PLACE = false;
|
| - |
|
15785 |
/* Allow usage of profiles like html, svg and mathMl */
|
| 15949 |
let USE_PROFILES = {};
|
15786 |
let USE_PROFILES = {};
|
| - |
|
15787 |
/* Tags to ignore content of when KEEP_CONTENT is true */
|
| 15950 |
let FORBID_CONTENTS = null;
|
15788 |
let FORBID_CONTENTS = null;
|
| 15951 |
const DEFAULT_FORBID_CONTENTS = addToSet({}, [
|
15789 |
const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
|
| 15952 |
'annotation-xml',
|
15790 |
/* Tags that are safe for data: URIs */
|
| 15953 |
'audio',
|
- |
|
| 15954 |
'colgroup',
|
- |
|
| 15955 |
'desc',
|
- |
|
| 15956 |
'foreignobject',
|
- |
|
| 15957 |
'head',
|
- |
|
| 15958 |
'iframe',
|
- |
|
| 15959 |
'math',
|
- |
|
| 15960 |
'mi',
|
- |
|
| 15961 |
'mn',
|
- |
|
| 15962 |
'mo',
|
- |
|
| 15963 |
'ms',
|
- |
|
| 15964 |
'mtext',
|
- |
|
| 15965 |
'noembed',
|
- |
|
| 15966 |
'noframes',
|
- |
|
| 15967 |
'noscript',
|
- |
|
| 15968 |
'plaintext',
|
- |
|
| 15969 |
'script',
|
- |
|
| 15970 |
'style',
|
- |
|
| 15971 |
'svg',
|
- |
|
| 15972 |
'template',
|
- |
|
| 15973 |
'thead',
|
- |
|
| 15974 |
'title',
|
- |
|
| 15975 |
'video',
|
- |
|
| 15976 |
'xmp'
|
- |
|
| 15977 |
]);
|
- |
|
| 15978 |
let DATA_URI_TAGS = null;
|
15791 |
let DATA_URI_TAGS = null;
|
| 15979 |
const DEFAULT_DATA_URI_TAGS = addToSet({}, [
|
15792 |
const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
|
| 15980 |
'audio',
|
- |
|
| 15981 |
'video',
|
- |
|
| 15982 |
'img',
|
- |
|
| 15983 |
'source',
|
15793 |
/* Attributes safe for values like "javascript:" */
|
| 15984 |
'image',
|
- |
|
| 15985 |
'track'
|
- |
|
| 15986 |
]);
|
- |
|
| 15987 |
let URI_SAFE_ATTRIBUTES = null;
|
15794 |
let URI_SAFE_ATTRIBUTES = null;
|
| 15988 |
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
|
15795 |
const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
|
| 15989 |
'alt',
|
- |
|
| 15990 |
'class',
|
- |
|
| 15991 |
'for',
|
- |
|
| 15992 |
'id',
|
- |
|
| 15993 |
'label',
|
- |
|
| 15994 |
'name',
|
- |
|
| 15995 |
'pattern',
|
- |
|
| 15996 |
'placeholder',
|
- |
|
| 15997 |
'role',
|
- |
|
| 15998 |
'summary',
|
- |
|
| 15999 |
'title',
|
- |
|
| 16000 |
'value',
|
- |
|
| 16001 |
'style',
|
- |
|
| 16002 |
'xmlns'
|
- |
|
| 16003 |
]);
|
- |
|
| 16004 |
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
15796 |
const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
|
| 16005 |
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
15797 |
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
| 16006 |
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
15798 |
const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
|
| - |
|
15799 |
/* Document namespace */
|
| 16007 |
let NAMESPACE = HTML_NAMESPACE;
|
15800 |
let NAMESPACE = HTML_NAMESPACE;
|
| 16008 |
let IS_EMPTY_INPUT = false;
|
15801 |
let IS_EMPTY_INPUT = false;
|
| - |
|
15802 |
/* Allowed XHTML+XML namespaces */
|
| 16009 |
let ALLOWED_NAMESPACES = null;
|
15803 |
let ALLOWED_NAMESPACES = null;
|
| - |
|
15804 |
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
|
| - |
|
15805 |
let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
|
| 16010 |
const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
|
15806 |
let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
|
| 16011 |
MATHML_NAMESPACE,
|
15807 |
// Certain elements are allowed in both SVG and HTML
|
| 16012 |
SVG_NAMESPACE,
|
15808 |
// namespace. We need to specify them explicitly
|
| - |
|
15809 |
// so that they don't get erroneously deleted from
|
| 16013 |
HTML_NAMESPACE
|
15810 |
// HTML namespace.
|
| - |
|
15811 |
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
|
| 16014 |
], stringToString);
|
15812 |
/* Parsing of strict XHTML documents */
|
| 16015 |
let PARSER_MEDIA_TYPE;
|
15813 |
let PARSER_MEDIA_TYPE = null;
|
| 16016 |
const SUPPORTED_PARSER_MEDIA_TYPES = [
|
15814 |
const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
|
| 16017 |
'application/xhtml+xml',
|
- |
|
| 16018 |
'text/html'
|
- |
|
| 16019 |
];
|
- |
|
| 16020 |
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
15815 |
const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
|
| 16021 |
let transformCaseFunc;
|
15816 |
let transformCaseFunc = null;
|
| - |
|
15817 |
/* Keep a reference to config to pass to hooks */
|
| 16022 |
let CONFIG = null;
|
15818 |
let CONFIG = null;
|
| - |
|
15819 |
/* Ideally, do not touch anything below this line */
|
| - |
|
15820 |
/* ______________________________________________ */
|
| 16023 |
const formElement = document.createElement('form');
|
15821 |
const formElement = document.createElement('form');
|
| 16024 |
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
15822 |
const isRegexOrFunction = function isRegexOrFunction(testValue) {
|
| 16025 |
return testValue instanceof RegExp || testValue instanceof Function;
|
15823 |
return testValue instanceof RegExp || testValue instanceof Function;
|
| 16026 |
};
|
15824 |
};
|
| - |
|
15825 |
/**
|
| - |
|
15826 |
* _parseConfig
|
| - |
|
15827 |
*
|
| - |
|
15828 |
* @param cfg optional config literal
|
| - |
|
15829 |
*/
|
| - |
|
15830 |
// eslint-disable-next-line complexity
|
| 16027 |
const _parseConfig = function _parseConfig(cfg) {
|
15831 |
const _parseConfig = function _parseConfig() {
|
| - |
|
15832 |
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
| 16028 |
if (CONFIG && CONFIG === cfg) {
|
15833 |
if (CONFIG && CONFIG === cfg) {
|
| 16029 |
return;
|
15834 |
return;
|
| 16030 |
}
|
15835 |
}
|
| - |
|
15836 |
/* Shield configuration object from tampering */
|
| 16031 |
if (!cfg || typeof cfg !== 'object') {
|
15837 |
if (!cfg || typeof cfg !== 'object') {
|
| 16032 |
cfg = {};
|
15838 |
cfg = {};
|
| 16033 |
}
|
15839 |
}
|
| - |
|
15840 |
/* Shield configuration object from prototype pollution */
|
| 16034 |
cfg = clone(cfg);
|
15841 |
cfg = clone(cfg);
|
| - |
|
15842 |
PARSER_MEDIA_TYPE =
|
| - |
|
15843 |
// eslint-disable-next-line unicorn/prefer-includes
|
| 16035 |
PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE;
|
15844 |
SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
|
| - |
|
15845 |
// HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
|
| 16036 |
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
15846 |
transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
|
| - |
|
15847 |
/* Set configuration parameters */
|
| 16037 |
ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
15848 |
ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
|
| 16038 |
ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
15849 |
ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
|
| 16039 |
ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
15850 |
ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
|
| 16040 |
URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
15851 |
URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
|
| 16041 |
DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
15852 |
DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
|
| 16042 |
FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
15853 |
FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
|
| 16043 |
FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
15854 |
FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
|
| 16044 |
FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
15855 |
FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
|
| 16045 |
USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
|
15856 |
USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
|
| 16046 |
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
|
15857 |
ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
|
| 16047 |
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
|
15858 |
ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
|
| 16048 |
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
|
15859 |
ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
|
| 16049 |
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
|
15860 |
ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
|
| 16050 |
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
|
15861 |
SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
|
| - |
|
15862 |
SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
|
| 16051 |
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
|
15863 |
WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
|
| 16052 |
RETURN_DOM = cfg.RETURN_DOM || false;
|
15864 |
RETURN_DOM = cfg.RETURN_DOM || false; // Default false
|
| 16053 |
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
|
15865 |
RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
|
| 16054 |
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
|
15866 |
RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
|
| 16055 |
FORCE_BODY = cfg.FORCE_BODY || false;
|
15867 |
FORCE_BODY = cfg.FORCE_BODY || false; // Default false
|
| 16056 |
SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
|
15868 |
SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
|
| 16057 |
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
|
15869 |
SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
|
| 16058 |
KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
|
15870 |
KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
|
| 16059 |
IN_PLACE = cfg.IN_PLACE || false;
|
15871 |
IN_PLACE = cfg.IN_PLACE || false; // Default false
|
| 16060 |
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
15872 |
IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
|
| 16061 |
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
15873 |
NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
|
| - |
|
15874 |
MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
|
| - |
|
15875 |
HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
|
| 16062 |
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
15876 |
CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
|
| 16063 |
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
15877 |
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
|
| 16064 |
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
15878 |
CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
|
| 16065 |
}
|
15879 |
}
|
| 16066 |
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
15880 |
if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
|
| Línea 16073... |
Línea 15887... |
| 16073 |
ALLOW_DATA_ATTR = false;
|
15887 |
ALLOW_DATA_ATTR = false;
|
| 16074 |
}
|
15888 |
}
|
| 16075 |
if (RETURN_DOM_FRAGMENT) {
|
15889 |
if (RETURN_DOM_FRAGMENT) {
|
| 16076 |
RETURN_DOM = true;
|
15890 |
RETURN_DOM = true;
|
| 16077 |
}
|
15891 |
}
|
| - |
|
15892 |
/* Parse profile info */
|
| 16078 |
if (USE_PROFILES) {
|
15893 |
if (USE_PROFILES) {
|
| 16079 |
ALLOWED_TAGS = addToSet({}, [...text]);
|
15894 |
ALLOWED_TAGS = addToSet({}, text);
|
| 16080 |
ALLOWED_ATTR = [];
|
15895 |
ALLOWED_ATTR = [];
|
| 16081 |
if (USE_PROFILES.html === true) {
|
15896 |
if (USE_PROFILES.html === true) {
|
| 16082 |
addToSet(ALLOWED_TAGS, html$1);
|
15897 |
addToSet(ALLOWED_TAGS, html$1);
|
| 16083 |
addToSet(ALLOWED_ATTR, html);
|
15898 |
addToSet(ALLOWED_ATTR, html);
|
| 16084 |
}
|
15899 |
}
|
| Línea 16096... |
Línea 15911... |
| 16096 |
addToSet(ALLOWED_TAGS, mathMl$1);
|
15911 |
addToSet(ALLOWED_TAGS, mathMl$1);
|
| 16097 |
addToSet(ALLOWED_ATTR, mathMl);
|
15912 |
addToSet(ALLOWED_ATTR, mathMl);
|
| 16098 |
addToSet(ALLOWED_ATTR, xml);
|
15913 |
addToSet(ALLOWED_ATTR, xml);
|
| 16099 |
}
|
15914 |
}
|
| 16100 |
}
|
15915 |
}
|
| - |
|
15916 |
/* Merge configuration parameters */
|
| 16101 |
if (cfg.ADD_TAGS) {
|
15917 |
if (cfg.ADD_TAGS) {
|
| 16102 |
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
15918 |
if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
|
| 16103 |
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
15919 |
ALLOWED_TAGS = clone(ALLOWED_TAGS);
|
| 16104 |
}
|
15920 |
}
|
| 16105 |
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
15921 |
addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
|
| Línea 16117... |
Línea 15933... |
| 16117 |
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
15933 |
if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
|
| 16118 |
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
15934 |
FORBID_CONTENTS = clone(FORBID_CONTENTS);
|
| 16119 |
}
|
15935 |
}
|
| 16120 |
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
15936 |
addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
|
| 16121 |
}
|
15937 |
}
|
| - |
|
15938 |
/* Add #text in case KEEP_CONTENT is set to true */
|
| 16122 |
if (KEEP_CONTENT) {
|
15939 |
if (KEEP_CONTENT) {
|
| 16123 |
ALLOWED_TAGS['#text'] = true;
|
15940 |
ALLOWED_TAGS['#text'] = true;
|
| 16124 |
}
|
15941 |
}
|
| - |
|
15942 |
/* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
|
| 16125 |
if (WHOLE_DOCUMENT) {
|
15943 |
if (WHOLE_DOCUMENT) {
|
| 16126 |
addToSet(ALLOWED_TAGS, [
|
15944 |
addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
|
| 16127 |
'html',
|
- |
|
| 16128 |
'head',
|
- |
|
| 16129 |
'body'
|
- |
|
| 16130 |
]);
|
- |
|
| 16131 |
}
|
15945 |
}
|
| - |
|
15946 |
/* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
|
| 16132 |
if (ALLOWED_TAGS.table) {
|
15947 |
if (ALLOWED_TAGS.table) {
|
| 16133 |
addToSet(ALLOWED_TAGS, ['tbody']);
|
15948 |
addToSet(ALLOWED_TAGS, ['tbody']);
|
| 16134 |
delete FORBID_TAGS.tbody;
|
15949 |
delete FORBID_TAGS.tbody;
|
| 16135 |
}
|
15950 |
}
|
| 16136 |
if (cfg.TRUSTED_TYPES_POLICY) {
|
15951 |
if (cfg.TRUSTED_TYPES_POLICY) {
|
| Línea 16138... |
Línea 15953... |
| 16138 |
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
15953 |
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
| 16139 |
}
|
15954 |
}
|
| 16140 |
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
15955 |
if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
|
| 16141 |
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
15956 |
throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
| 16142 |
}
|
15957 |
}
|
| - |
|
15958 |
// Overwrite existing TrustedTypes policy.
|
| 16143 |
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
15959 |
trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
|
| - |
|
15960 |
// Sign local variables required by `sanitize`.
|
| 16144 |
emptyHTML = trustedTypesPolicy.createHTML('');
|
15961 |
emptyHTML = trustedTypesPolicy.createHTML('');
|
| 16145 |
} else {
|
15962 |
} else {
|
| - |
|
15963 |
// Uninitialized policy, attempt to initialize the internal dompurify policy.
|
| 16146 |
if (trustedTypesPolicy === undefined) {
|
15964 |
if (trustedTypesPolicy === undefined) {
|
| 16147 |
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
15965 |
trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
|
| 16148 |
}
|
15966 |
}
|
| - |
|
15967 |
// If creating the internal policy succeeded sign internal variables.
|
| 16149 |
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
15968 |
if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
|
| 16150 |
emptyHTML = trustedTypesPolicy.createHTML('');
|
15969 |
emptyHTML = trustedTypesPolicy.createHTML('');
|
| 16151 |
}
|
15970 |
}
|
| 16152 |
}
|
15971 |
}
|
| - |
|
15972 |
// Prevent further manipulation of configuration.
|
| - |
|
15973 |
// Not available in IE8, Safari 5, etc.
|
| 16153 |
if (freeze) {
|
15974 |
if (freeze) {
|
| 16154 |
freeze(cfg);
|
15975 |
freeze(cfg);
|
| 16155 |
}
|
15976 |
}
|
| 16156 |
CONFIG = cfg;
|
15977 |
CONFIG = cfg;
|
| 16157 |
};
|
15978 |
};
|
| 16158 |
const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, [
|
15979 |
/* Keep track of all possible SVG and MathML tags
|
| 16159 |
'mi',
|
- |
|
| 16160 |
'mo',
|
- |
|
| 16161 |
'mn',
|
- |
|
| 16162 |
'ms',
|
- |
|
| 16163 |
'mtext'
|
- |
|
| 16164 |
]);
|
- |
|
| 16165 |
const HTML_INTEGRATION_POINTS = addToSet({}, [
|
15980 |
* so that we can perform the namespace checks
|
| 16166 |
'foreignobject',
|
- |
|
| 16167 |
'desc',
|
- |
|
| 16168 |
'title',
|
15981 |
* correctly. */
|
| 16169 |
'annotation-xml'
|
15982 |
const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
|
| 16170 |
]);
|
- |
|
| 16171 |
const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
|
15983 |
const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
|
| 16172 |
'title',
|
- |
|
| 16173 |
'style',
|
- |
|
| 16174 |
'font',
|
- |
|
| 16175 |
'a',
|
- |
|
| 16176 |
'script'
|
- |
|
| 16177 |
]);
|
15984 |
/**
|
| 16178 |
const ALL_SVG_TAGS = addToSet({}, svg$1);
|
15985 |
* @param element a DOM element whose namespace is being checked
|
| 16179 |
addToSet(ALL_SVG_TAGS, svgFilters);
|
15986 |
* @returns Return false if the element has a
|
| 16180 |
addToSet(ALL_SVG_TAGS, svgDisallowed);
|
15987 |
* namespace that a spec-compliant parser would never
|
| 16181 |
const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
|
15988 |
* return. Return true otherwise.
|
| 16182 |
addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
|
15989 |
*/
|
| 16183 |
const _checkValidNamespace = function _checkValidNamespace(element) {
|
15990 |
const _checkValidNamespace = function _checkValidNamespace(element) {
|
| 16184 |
let parent = getParentNode(element);
|
15991 |
let parent = getParentNode(element);
|
| - |
|
15992 |
// In JSDOM, if we're inside shadow DOM, then parentNode
|
| - |
|
15993 |
// can be null. We just simulate parent in this case.
|
| 16185 |
if (!parent || !parent.tagName) {
|
15994 |
if (!parent || !parent.tagName) {
|
| 16186 |
parent = {
|
15995 |
parent = {
|
| 16187 |
namespaceURI: NAMESPACE,
|
15996 |
namespaceURI: NAMESPACE,
|
| 16188 |
tagName: 'template'
|
15997 |
tagName: 'template'
|
| 16189 |
};
|
15998 |
};
|
| Línea 16192... |
Línea 16001... |
| 16192 |
const parentTagName = stringToLowerCase(parent.tagName);
|
16001 |
const parentTagName = stringToLowerCase(parent.tagName);
|
| 16193 |
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
16002 |
if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
|
| 16194 |
return false;
|
16003 |
return false;
|
| 16195 |
}
|
16004 |
}
|
| 16196 |
if (element.namespaceURI === SVG_NAMESPACE) {
|
16005 |
if (element.namespaceURI === SVG_NAMESPACE) {
|
| - |
|
16006 |
// The only way to switch from HTML namespace to SVG
|
| - |
|
16007 |
// is via <svg>. If it happens via any other tag, then
|
| - |
|
16008 |
// it should be killed.
|
| 16197 |
if (parent.namespaceURI === HTML_NAMESPACE) {
|
16009 |
if (parent.namespaceURI === HTML_NAMESPACE) {
|
| 16198 |
return tagName === 'svg';
|
16010 |
return tagName === 'svg';
|
| 16199 |
}
|
16011 |
}
|
| - |
|
16012 |
// The only way to switch from MathML to SVG is via`
|
| - |
|
16013 |
// svg if parent is either <annotation-xml> or MathML
|
| - |
|
16014 |
// text integration points.
|
| 16200 |
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
16015 |
if (parent.namespaceURI === MATHML_NAMESPACE) {
|
| 16201 |
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
16016 |
return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
|
| 16202 |
}
|
16017 |
}
|
| - |
|
16018 |
// We only allow elements that are defined in SVG
|
| - |
|
16019 |
// spec. All others are disallowed in SVG namespace.
|
| 16203 |
return Boolean(ALL_SVG_TAGS[tagName]);
|
16020 |
return Boolean(ALL_SVG_TAGS[tagName]);
|
| 16204 |
}
|
16021 |
}
|
| 16205 |
if (element.namespaceURI === MATHML_NAMESPACE) {
|
16022 |
if (element.namespaceURI === MATHML_NAMESPACE) {
|
| - |
|
16023 |
// The only way to switch from HTML namespace to MathML
|
| - |
|
16024 |
// is via <math>. If it happens via any other tag, then
|
| - |
|
16025 |
// it should be killed.
|
| 16206 |
if (parent.namespaceURI === HTML_NAMESPACE) {
|
16026 |
if (parent.namespaceURI === HTML_NAMESPACE) {
|
| 16207 |
return tagName === 'math';
|
16027 |
return tagName === 'math';
|
| 16208 |
}
|
16028 |
}
|
| - |
|
16029 |
// The only way to switch from SVG to MathML is via
|
| - |
|
16030 |
// <math> and HTML integration points
|
| 16209 |
if (parent.namespaceURI === SVG_NAMESPACE) {
|
16031 |
if (parent.namespaceURI === SVG_NAMESPACE) {
|
| 16210 |
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
16032 |
return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
|
| 16211 |
}
|
16033 |
}
|
| - |
|
16034 |
// We only allow elements that are defined in MathML
|
| - |
|
16035 |
// spec. All others are disallowed in MathML namespace.
|
| 16212 |
return Boolean(ALL_MATHML_TAGS[tagName]);
|
16036 |
return Boolean(ALL_MATHML_TAGS[tagName]);
|
| 16213 |
}
|
16037 |
}
|
| 16214 |
if (element.namespaceURI === HTML_NAMESPACE) {
|
16038 |
if (element.namespaceURI === HTML_NAMESPACE) {
|
| - |
|
16039 |
// The only way to switch from SVG to HTML is via
|
| - |
|
16040 |
// HTML integration points, and from MathML to HTML
|
| - |
|
16041 |
// is via MathML text integration points
|
| 16215 |
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
16042 |
if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
|
| 16216 |
return false;
|
16043 |
return false;
|
| 16217 |
}
|
16044 |
}
|
| 16218 |
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
16045 |
if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
|
| 16219 |
return false;
|
16046 |
return false;
|
| 16220 |
}
|
16047 |
}
|
| - |
|
16048 |
// We disallow tags that are specific for MathML
|
| - |
|
16049 |
// or SVG and should never appear in HTML namespace
|
| 16221 |
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
16050 |
return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
|
| 16222 |
}
|
16051 |
}
|
| - |
|
16052 |
// For XHTML and XML documents that support custom namespaces
|
| 16223 |
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
16053 |
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
|
| 16224 |
return true;
|
16054 |
return true;
|
| 16225 |
}
|
16055 |
}
|
| - |
|
16056 |
// The code should never reach this place (this means
|
| - |
|
16057 |
// that the element somehow got namespace that is not
|
| - |
|
16058 |
// HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
|
| - |
|
16059 |
// Return false just in case.
|
| 16226 |
return false;
|
16060 |
return false;
|
| 16227 |
};
|
16061 |
};
|
| - |
|
16062 |
/**
|
| - |
|
16063 |
* _forceRemove
|
| - |
|
16064 |
*
|
| - |
|
16065 |
* @param node a DOM node
|
| - |
|
16066 |
*/
|
| 16228 |
const _forceRemove = function _forceRemove(node) {
|
16067 |
const _forceRemove = function _forceRemove(node) {
|
| 16229 |
arrayPush(DOMPurify.removed, { element: node });
|
16068 |
arrayPush(DOMPurify.removed, {
|
| - |
|
16069 |
element: node
|
| - |
|
16070 |
});
|
| 16230 |
try {
|
16071 |
try {
|
| - |
|
16072 |
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
| 16231 |
node.parentNode.removeChild(node);
|
16073 |
getParentNode(node).removeChild(node);
|
| 16232 |
} catch (_) {
|
16074 |
} catch (_) {
|
| 16233 |
node.remove();
|
16075 |
remove(node);
|
| 16234 |
}
|
16076 |
}
|
| 16235 |
};
|
16077 |
};
|
| - |
|
16078 |
/**
|
| - |
|
16079 |
* _removeAttribute
|
| - |
|
16080 |
*
|
| - |
|
16081 |
* @param name an Attribute name
|
| - |
|
16082 |
* @param element a DOM node
|
| - |
|
16083 |
*/
|
| 16236 |
const _removeAttribute = function _removeAttribute(name, node) {
|
16084 |
const _removeAttribute = function _removeAttribute(name, element) {
|
| 16237 |
try {
|
16085 |
try {
|
| 16238 |
arrayPush(DOMPurify.removed, {
|
16086 |
arrayPush(DOMPurify.removed, {
|
| 16239 |
attribute: node.getAttributeNode(name),
|
16087 |
attribute: element.getAttributeNode(name),
|
| 16240 |
from: node
|
16088 |
from: element
|
| 16241 |
});
|
16089 |
});
|
| 16242 |
} catch (_) {
|
16090 |
} catch (_) {
|
| 16243 |
arrayPush(DOMPurify.removed, {
|
16091 |
arrayPush(DOMPurify.removed, {
|
| 16244 |
attribute: null,
|
16092 |
attribute: null,
|
| 16245 |
from: node
|
16093 |
from: element
|
| 16246 |
});
|
16094 |
});
|
| 16247 |
}
|
16095 |
}
|
| 16248 |
node.removeAttribute(name);
|
16096 |
element.removeAttribute(name);
|
| - |
|
16097 |
// We void attribute values for unremovable "is" attributes
|
| 16249 |
if (name === 'is' && !ALLOWED_ATTR[name]) {
|
16098 |
if (name === 'is') {
|
| 16250 |
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
16099 |
if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
|
| 16251 |
try {
|
16100 |
try {
|
| 16252 |
_forceRemove(node);
|
16101 |
_forceRemove(element);
|
| 16253 |
} catch (_) {
|
16102 |
} catch (_) {}
|
| 16254 |
}
|
- |
|
| 16255 |
} else {
|
16103 |
} else {
|
| 16256 |
try {
|
16104 |
try {
|
| 16257 |
node.setAttribute(name, '');
|
16105 |
element.setAttribute(name, '');
|
| 16258 |
} catch (_) {
|
16106 |
} catch (_) {}
|
| 16259 |
}
|
- |
|
| 16260 |
}
|
16107 |
}
|
| 16261 |
}
|
16108 |
}
|
| 16262 |
};
|
16109 |
};
|
| - |
|
16110 |
/**
|
| - |
|
16111 |
* _initDocument
|
| - |
|
16112 |
*
|
| - |
|
16113 |
* @param dirty - a string of dirty markup
|
| - |
|
16114 |
* @return a DOM, filled with the dirty markup
|
| - |
|
16115 |
*/
|
| 16263 |
const _initDocument = function _initDocument(dirty) {
|
16116 |
const _initDocument = function _initDocument(dirty) {
|
| - |
|
16117 |
/* Create a HTML document */
|
| 16264 |
let doc;
|
16118 |
let doc = null;
|
| 16265 |
let leadingWhitespace;
|
16119 |
let leadingWhitespace = null;
|
| 16266 |
if (FORCE_BODY) {
|
16120 |
if (FORCE_BODY) {
|
| 16267 |
dirty = '<remove></remove>' + dirty;
|
16121 |
dirty = '<remove></remove>' + dirty;
|
| 16268 |
} else {
|
16122 |
} else {
|
| - |
|
16123 |
/* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
|
| 16269 |
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
16124 |
const matches = stringMatch(dirty, /^[\r\n\t ]+/);
|
| 16270 |
leadingWhitespace = matches && matches[0];
|
16125 |
leadingWhitespace = matches && matches[0];
|
| 16271 |
}
|
16126 |
}
|
| 16272 |
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
|
16127 |
if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
|
| - |
|
16128 |
// Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
|
| 16273 |
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
16129 |
dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
|
| 16274 |
}
|
16130 |
}
|
| 16275 |
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
16131 |
const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
| - |
|
16132 |
/*
|
| - |
|
16133 |
* Use the DOMParser API by default, fallback later if needs be
|
| - |
|
16134 |
* DOMParser not work for svg when has multiple root element.
|
| - |
|
16135 |
*/
|
| 16276 |
if (NAMESPACE === HTML_NAMESPACE) {
|
16136 |
if (NAMESPACE === HTML_NAMESPACE) {
|
| 16277 |
try {
|
16137 |
try {
|
| 16278 |
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
16138 |
doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
|
| 16279 |
} catch (_) {
|
16139 |
} catch (_) {}
|
| 16280 |
}
|
- |
|
| 16281 |
}
|
16140 |
}
|
| - |
|
16141 |
/* Use createHTMLDocument in case DOMParser is not available */
|
| 16282 |
if (!doc || !doc.documentElement) {
|
16142 |
if (!doc || !doc.documentElement) {
|
| 16283 |
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
16143 |
doc = implementation.createDocument(NAMESPACE, 'template', null);
|
| 16284 |
try {
|
16144 |
try {
|
| 16285 |
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
16145 |
doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
|
| 16286 |
} catch (_) {
|
16146 |
} catch (_) {
|
| - |
|
16147 |
// Syntax error if dirtyPayload is invalid xml
|
| 16287 |
}
|
16148 |
}
|
| 16288 |
}
|
16149 |
}
|
| 16289 |
const body = doc.body || doc.documentElement;
|
16150 |
const body = doc.body || doc.documentElement;
|
| 16290 |
if (dirty && leadingWhitespace) {
|
16151 |
if (dirty && leadingWhitespace) {
|
| 16291 |
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
16152 |
body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
|
| 16292 |
}
|
16153 |
}
|
| - |
|
16154 |
/* Work on whole document or just its body */
|
| 16293 |
if (NAMESPACE === HTML_NAMESPACE) {
|
16155 |
if (NAMESPACE === HTML_NAMESPACE) {
|
| 16294 |
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
16156 |
return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
|
| 16295 |
}
|
16157 |
}
|
| 16296 |
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
16158 |
return WHOLE_DOCUMENT ? doc.documentElement : body;
|
| 16297 |
};
|
16159 |
};
|
| - |
|
16160 |
/**
|
| - |
|
16161 |
* Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
|
| - |
|
16162 |
*
|
| - |
|
16163 |
* @param root The root element or node to start traversing on.
|
| - |
|
16164 |
* @return The created NodeIterator
|
| - |
|
16165 |
*/
|
| 16298 |
const _createIterator = function _createIterator(root) {
|
16166 |
const _createNodeIterator = function _createNodeIterator(root) {
|
| - |
|
16167 |
return createNodeIterator.call(root.ownerDocument || root, root,
|
| - |
|
16168 |
// eslint-disable-next-line no-bitwise
|
| - |
|
16169 |
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
|
| - |
|
16170 |
};
|
| - |
|
16171 |
/**
|
| - |
|
16172 |
* _isClobbered
|
| - |
|
16173 |
*
|
| - |
|
16174 |
* @param element element to check for clobbering attacks
|
| - |
|
16175 |
* @return true if clobbered, false if safe
|
| - |
|
16176 |
*/
|
| - |
|
16177 |
const _isClobbered = function _isClobbered(element) {
|
| 16299 |
return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
|
16178 |
return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
|
| - |
|
16179 |
};
|
| - |
|
16180 |
/**
|
| - |
|
16181 |
* Checks whether the given object is a DOM node.
|
| - |
|
16182 |
*
|
| - |
|
16183 |
* @param value object to check whether it's a DOM node
|
| - |
|
16184 |
* @return true is object is a DOM node
|
| - |
|
16185 |
*/
|
| - |
|
16186 |
const _isNode = function _isNode(value) {
|
| - |
|
16187 |
return typeof Node === 'function' && value instanceof Node;
|
| 16300 |
};
|
16188 |
};
|
| 16301 |
const _isClobbered = function _isClobbered(elm) {
|
- |
|
| 16302 |
return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
|
16189 |
function _executeHooks(hooks, currentNode, data) {
|
| 16303 |
};
|
- |
|
| 16304 |
const _isNode = function _isNode(object) {
|
- |
|
| 16305 |
return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
|
- |
|
| 16306 |
};
|
- |
|
| 16307 |
const _executeHook = function _executeHook(entryPoint, currentNode, data) {
|
- |
|
| 16308 |
if (!hooks[entryPoint]) {
|
- |
|
| 16309 |
return;
|
- |
|
| 16310 |
}
|
- |
|
| 16311 |
arrayForEach(hooks[entryPoint], hook => {
|
16190 |
arrayForEach(hooks, hook => {
|
| 16312 |
hook.call(DOMPurify, currentNode, data, CONFIG);
|
16191 |
hook.call(DOMPurify, currentNode, data, CONFIG);
|
| 16313 |
});
|
16192 |
});
|
| 16314 |
};
|
16193 |
}
|
| - |
|
16194 |
/**
|
| - |
|
16195 |
* _sanitizeElements
|
| - |
|
16196 |
*
|
| - |
|
16197 |
* @protect nodeName
|
| - |
|
16198 |
* @protect textContent
|
| - |
|
16199 |
* @protect removeChild
|
| - |
|
16200 |
* @param currentNode to check for permission to exist
|
| - |
|
16201 |
* @return true if node was killed, false if left alive
|
| - |
|
16202 |
*/
|
| 16315 |
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
16203 |
const _sanitizeElements = function _sanitizeElements(currentNode) {
|
| 16316 |
let content;
|
16204 |
let content = null;
|
| - |
|
16205 |
/* Execute a hook if present */
|
| 16317 |
_executeHook('beforeSanitizeElements', currentNode, null);
|
16206 |
_executeHooks(hooks.beforeSanitizeElements, currentNode, null);
|
| - |
|
16207 |
/* Check if element is clobbered or can clobber */
|
| 16318 |
if (_isClobbered(currentNode)) {
|
16208 |
if (_isClobbered(currentNode)) {
|
| 16319 |
_forceRemove(currentNode);
|
16209 |
_forceRemove(currentNode);
|
| 16320 |
return true;
|
16210 |
return true;
|
| 16321 |
}
|
16211 |
}
|
| - |
|
16212 |
/* Now let's check the element's type and name */
|
| 16322 |
const tagName = transformCaseFunc(currentNode.nodeName);
|
16213 |
const tagName = transformCaseFunc(currentNode.nodeName);
|
| - |
|
16214 |
/* Execute a hook if present */
|
| 16323 |
_executeHook('uponSanitizeElement', currentNode, {
|
16215 |
_executeHooks(hooks.uponSanitizeElement, currentNode, {
|
| 16324 |
tagName,
|
16216 |
tagName,
|
| 16325 |
allowedTags: ALLOWED_TAGS
|
16217 |
allowedTags: ALLOWED_TAGS
|
| 16326 |
});
|
16218 |
});
|
| - |
|
16219 |
/* Detect mXSS attempts abusing namespace confusion */
|
| 16327 |
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
16220 |
if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
|
| - |
|
16221 |
_forceRemove(currentNode);
|
| - |
|
16222 |
return true;
|
| - |
|
16223 |
}
|
| - |
|
16224 |
/* Remove any occurrence of processing instructions */
|
| - |
|
16225 |
if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
|
| 16328 |
_forceRemove(currentNode);
|
16226 |
_forceRemove(currentNode);
|
| 16329 |
return true;
|
16227 |
return true;
|
| 16330 |
}
|
16228 |
}
|
| - |
|
16229 |
/* Remove any kind of possibly harmful comments */
|
| - |
|
16230 |
if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
|
| - |
|
16231 |
_forceRemove(currentNode);
|
| - |
|
16232 |
return true;
|
| - |
|
16233 |
}
|
| - |
|
16234 |
/* Remove element if anything forbids its presence */
|
| 16331 |
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
16235 |
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
| - |
|
16236 |
/* Check if we have a custom element to handle */
|
| 16332 |
if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
|
16237 |
if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
|
| 16333 |
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName))
|
16238 |
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
|
| 16334 |
return false;
|
16239 |
return false;
|
| - |
|
16240 |
}
|
| 16335 |
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName))
|
16241 |
if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
|
| 16336 |
return false;
|
16242 |
return false;
|
| - |
|
16243 |
}
|
| 16337 |
}
|
16244 |
}
|
| - |
|
16245 |
/* Keep content except for bad-listed elements */
|
| 16338 |
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
16246 |
if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
|
| 16339 |
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
16247 |
const parentNode = getParentNode(currentNode) || currentNode.parentNode;
|
| 16340 |
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
16248 |
const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
|
| 16341 |
if (childNodes && parentNode) {
|
16249 |
if (childNodes && parentNode) {
|
| 16342 |
const childCount = childNodes.length;
|
16250 |
const childCount = childNodes.length;
|
| 16343 |
for (let i = childCount - 1; i >= 0; --i) {
|
16251 |
for (let i = childCount - 1; i >= 0; --i) {
|
| - |
|
16252 |
const childClone = cloneNode(childNodes[i], true);
|
| - |
|
16253 |
childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
|
| 16344 |
parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
|
16254 |
parentNode.insertBefore(childClone, getNextSibling(currentNode));
|
| 16345 |
}
|
16255 |
}
|
| 16346 |
}
|
16256 |
}
|
| 16347 |
}
|
16257 |
}
|
| 16348 |
_forceRemove(currentNode);
|
16258 |
_forceRemove(currentNode);
|
| 16349 |
return true;
|
16259 |
return true;
|
| 16350 |
}
|
16260 |
}
|
| - |
|
16261 |
/* Check whether element has a valid namespace */
|
| 16351 |
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
16262 |
if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
|
| 16352 |
_forceRemove(currentNode);
|
16263 |
_forceRemove(currentNode);
|
| 16353 |
return true;
|
16264 |
return true;
|
| 16354 |
}
|
16265 |
}
|
| - |
|
16266 |
/* Make sure that older browsers don't get fallback-tag mXSS */
|
| 16355 |
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
16267 |
if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
|
| 16356 |
_forceRemove(currentNode);
|
16268 |
_forceRemove(currentNode);
|
| 16357 |
return true;
|
16269 |
return true;
|
| 16358 |
}
|
16270 |
}
|
| - |
|
16271 |
/* Sanitize element content to be template-safe */
|
| 16359 |
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
|
16272 |
if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
|
| - |
|
16273 |
/* Get the element's text content */
|
| 16360 |
content = currentNode.textContent;
|
16274 |
content = currentNode.textContent;
|
| 16361 |
content = stringReplace(content, MUSTACHE_EXPR, ' ');
|
16275 |
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
| 16362 |
content = stringReplace(content, ERB_EXPR, ' ');
|
16276 |
content = stringReplace(content, expr, ' ');
|
| 16363 |
content = stringReplace(content, TMPLIT_EXPR, ' ');
|
16277 |
});
|
| 16364 |
if (currentNode.textContent !== content) {
|
16278 |
if (currentNode.textContent !== content) {
|
| - |
|
16279 |
arrayPush(DOMPurify.removed, {
|
| 16365 |
arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
|
16280 |
element: currentNode.cloneNode()
|
| - |
|
16281 |
});
|
| 16366 |
currentNode.textContent = content;
|
16282 |
currentNode.textContent = content;
|
| 16367 |
}
|
16283 |
}
|
| 16368 |
}
|
16284 |
}
|
| - |
|
16285 |
/* Execute a hook if present */
|
| 16369 |
_executeHook('afterSanitizeElements', currentNode, null);
|
16286 |
_executeHooks(hooks.afterSanitizeElements, currentNode, null);
|
| 16370 |
return false;
|
16287 |
return false;
|
| 16371 |
};
|
16288 |
};
|
| - |
|
16289 |
/**
|
| - |
|
16290 |
* _isValidAttribute
|
| - |
|
16291 |
*
|
| - |
|
16292 |
* @param lcTag Lowercase tag name of containing element.
|
| - |
|
16293 |
* @param lcName Lowercase attribute name.
|
| - |
|
16294 |
* @param value Attribute value.
|
| - |
|
16295 |
* @return Returns true if `value` is valid, otherwise false.
|
| - |
|
16296 |
*/
|
| - |
|
16297 |
// eslint-disable-next-line complexity
|
| 16372 |
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
16298 |
const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
|
| - |
|
16299 |
/* Make sure attribute cannot clobber */
|
| 16373 |
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
16300 |
if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
|
| 16374 |
return false;
|
16301 |
return false;
|
| 16375 |
}
|
16302 |
}
|
| 16376 |
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName));
|
16303 |
/* Allow valid data-* attributes: At least one character after "-"
|
| - |
|
16304 |
(https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
|
| - |
|
16305 |
XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
|
| 16377 |
else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName));
|
16306 |
We don't need to check the value; it's always URI safe. */
|
| - |
|
16307 |
if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
| - |
|
16308 |
if (
|
| - |
|
16309 |
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
| - |
|
16310 |
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
| - |
|
16311 |
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
| 16378 |
else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
|
16312 |
_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
|
| - |
|
16313 |
// Alternative, second condition checks if it's an `is`-attribute, AND
|
| 16379 |
if (_basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value)));
|
16314 |
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
| 16380 |
else {
|
16315 |
lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
|
| 16381 |
return false;
|
16316 |
return false;
|
| 16382 |
}
|
16317 |
}
|
| 16383 |
} else if (URI_SAFE_ATTRIBUTES[lcName]);
|
16318 |
/* Check value is safe. First, is attr inert? If so, is safe */
|
| 16384 |
else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, '')));
|
- |
|
| 16385 |
else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]);
|
16319 |
} else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
|
| 16386 |
else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, '')));
|
- |
|
| 16387 |
else if (value) {
|
- |
|
| 16388 |
return false;
|
16320 |
return false;
|
| 16389 |
} else ;
|
16321 |
} else ;
|
| 16390 |
return true;
|
16322 |
return true;
|
| 16391 |
};
|
16323 |
};
|
| - |
|
16324 |
/**
|
| - |
|
16325 |
* _isBasicCustomElement
|
| - |
|
16326 |
* checks if at least one dash is included in tagName, and it's not the first char
|
| - |
|
16327 |
* for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
|
| - |
|
16328 |
*
|
| - |
|
16329 |
* @param tagName name of the tag of the node to sanitize
|
| - |
|
16330 |
* @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
|
| - |
|
16331 |
*/
|
| 16392 |
const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
|
16332 |
const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
|
| 16393 |
return tagName.indexOf('-') > 0;
|
16333 |
return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
|
| 16394 |
};
|
16334 |
};
|
| - |
|
16335 |
/**
|
| - |
|
16336 |
* _sanitizeAttributes
|
| - |
|
16337 |
*
|
| - |
|
16338 |
* @protect attributes
|
| - |
|
16339 |
* @protect nodeName
|
| - |
|
16340 |
* @protect removeAttribute
|
| - |
|
16341 |
* @protect setAttribute
|
| - |
|
16342 |
*
|
| - |
|
16343 |
* @param currentNode to sanitize
|
| - |
|
16344 |
*/
|
| 16395 |
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
16345 |
const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
|
| 16396 |
let attr;
|
16346 |
/* Execute a hook if present */
|
| - |
|
16347 |
_executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
|
| 16397 |
let value;
|
16348 |
const {
|
| 16398 |
let lcName;
|
16349 |
attributes
|
| 16399 |
let l;
|
16350 |
} = currentNode;
|
| 16400 |
_executeHook('beforeSanitizeAttributes', currentNode, null);
|
16351 |
/* Check if we have attributes; if not we might have a text node */
|
| 16401 |
const {attributes} = currentNode;
|
16352 |
if (!attributes || _isClobbered(currentNode)) {
|
| 16402 |
if (!attributes) {
|
- |
|
| 16403 |
return;
|
16353 |
return;
|
| 16404 |
}
|
16354 |
}
|
| 16405 |
const hookEvent = {
|
16355 |
const hookEvent = {
|
| 16406 |
attrName: '',
|
16356 |
attrName: '',
|
| 16407 |
attrValue: '',
|
16357 |
attrValue: '',
|
| 16408 |
keepAttr: true,
|
16358 |
keepAttr: true,
|
| 16409 |
allowedAttributes: ALLOWED_ATTR
|
16359 |
allowedAttributes: ALLOWED_ATTR,
|
| - |
|
16360 |
forceKeepAttr: undefined
|
| 16410 |
};
|
16361 |
};
|
| 16411 |
l = attributes.length;
|
16362 |
let l = attributes.length;
|
| - |
|
16363 |
/* Go backwards over all attributes; safely remove bad ones */
|
| 16412 |
while (l--) {
|
16364 |
while (l--) {
|
| 16413 |
attr = attributes[l];
|
16365 |
const attr = attributes[l];
|
| - |
|
16366 |
const {
|
| - |
|
16367 |
name,
|
| - |
|
16368 |
namespaceURI,
|
| - |
|
16369 |
value: attrValue
|
| - |
|
16370 |
} = attr;
|
| 16414 |
const {name, namespaceURI} = attr;
|
16371 |
const lcName = transformCaseFunc(name);
|
| 16415 |
value = name === 'value' ? attr.value : stringTrim(attr.value);
|
16372 |
let value = name === 'value' ? attrValue : stringTrim(attrValue);
|
| 16416 |
const initValue = value;
|
16373 |
const initValue = value;
|
| 16417 |
lcName = transformCaseFunc(name);
|
16374 |
/* Execute a hook if present */
|
| 16418 |
hookEvent.attrName = lcName;
|
16375 |
hookEvent.attrName = lcName;
|
| 16419 |
hookEvent.attrValue = value;
|
16376 |
hookEvent.attrValue = value;
|
| 16420 |
hookEvent.keepAttr = true;
|
16377 |
hookEvent.keepAttr = true;
|
| 16421 |
hookEvent.forceKeepAttr = undefined;
|
16378 |
hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
|
| 16422 |
_executeHook('uponSanitizeAttribute', currentNode, hookEvent);
|
16379 |
_executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
|
| 16423 |
value = hookEvent.attrValue;
|
16380 |
value = hookEvent.attrValue;
|
| - |
|
16381 |
/* Full DOM Clobbering protection via namespace isolation,
|
| - |
|
16382 |
* Prefix id and name attributes with `user-content-`
|
| - |
|
16383 |
*/
|
| - |
|
16384 |
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
| - |
|
16385 |
// Remove the attribute with this value
|
| - |
|
16386 |
_removeAttribute(name, currentNode);
|
| - |
|
16387 |
// Prefix the value and later re-create the attribute with the sanitized value
|
| - |
|
16388 |
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
| - |
|
16389 |
}
|
| - |
|
16390 |
/* Work around a security issue with comments inside attributes */
|
| - |
|
16391 |
if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
|
| - |
|
16392 |
_removeAttribute(name, currentNode);
|
| - |
|
16393 |
continue;
|
| - |
|
16394 |
}
|
| - |
|
16395 |
/* Did the hooks approve of the attribute? */
|
| 16424 |
if (hookEvent.forceKeepAttr) {
|
16396 |
if (hookEvent.forceKeepAttr) {
|
| 16425 |
continue;
|
16397 |
continue;
|
| 16426 |
}
|
16398 |
}
|
| - |
|
16399 |
/* Remove attribute */
|
| - |
|
16400 |
/* Did the hooks approve of the attribute? */
|
| 16427 |
if (!hookEvent.keepAttr) {
|
16401 |
if (!hookEvent.keepAttr) {
|
| 16428 |
_removeAttribute(name, currentNode);
|
16402 |
_removeAttribute(name, currentNode);
|
| 16429 |
continue;
|
16403 |
continue;
|
| 16430 |
}
|
16404 |
}
|
| - |
|
16405 |
/* Work around a security issue in jQuery 3.0 */
|
| 16431 |
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
16406 |
if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
|
| 16432 |
_removeAttribute(name, currentNode);
|
16407 |
_removeAttribute(name, currentNode);
|
| 16433 |
continue;
|
16408 |
continue;
|
| 16434 |
}
|
16409 |
}
|
| - |
|
16410 |
/* Sanitize attribute content to be template-safe */
|
| 16435 |
if (SAFE_FOR_TEMPLATES) {
|
16411 |
if (SAFE_FOR_TEMPLATES) {
|
| 16436 |
value = stringReplace(value, MUSTACHE_EXPR, ' ');
|
16412 |
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
| 16437 |
value = stringReplace(value, ERB_EXPR, ' ');
|
16413 |
value = stringReplace(value, expr, ' ');
|
| 16438 |
value = stringReplace(value, TMPLIT_EXPR, ' ');
|
16414 |
});
|
| 16439 |
}
|
16415 |
}
|
| - |
|
16416 |
/* Is `value` valid for this attribute? */
|
| 16440 |
const lcTag = transformCaseFunc(currentNode.nodeName);
|
16417 |
const lcTag = transformCaseFunc(currentNode.nodeName);
|
| 16441 |
if (!_isValidAttribute(lcTag, lcName, value)) {
|
16418 |
if (!_isValidAttribute(lcTag, lcName, value)) {
|
| 16442 |
_removeAttribute(name, currentNode);
|
16419 |
_removeAttribute(name, currentNode);
|
| 16443 |
continue;
|
16420 |
continue;
|
| 16444 |
}
|
16421 |
}
|
| 16445 |
if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
|
- |
|
| 16446 |
_removeAttribute(name, currentNode);
|
16422 |
/* Handle attributes that require Trusted Types */
|
| 16447 |
value = SANITIZE_NAMED_PROPS_PREFIX + value;
|
- |
|
| 16448 |
}
|
- |
|
| 16449 |
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
16423 |
if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
|
| 16450 |
if (namespaceURI);
|
16424 |
if (namespaceURI) ; else {
|
| 16451 |
else {
|
- |
|
| 16452 |
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
16425 |
switch (trustedTypes.getAttributeType(lcTag, lcName)) {
|
| 16453 |
case 'TrustedHTML': {
|
16426 |
case 'TrustedHTML':
|
| - |
|
16427 |
{
|
| 16454 |
value = trustedTypesPolicy.createHTML(value);
|
16428 |
value = trustedTypesPolicy.createHTML(value);
|
| 16455 |
break;
|
16429 |
break;
|
| 16456 |
}
|
16430 |
}
|
| 16457 |
case 'TrustedScriptURL': {
|
16431 |
case 'TrustedScriptURL':
|
| - |
|
16432 |
{
|
| 16458 |
value = trustedTypesPolicy.createScriptURL(value);
|
16433 |
value = trustedTypesPolicy.createScriptURL(value);
|
| 16459 |
break;
|
16434 |
break;
|
| 16460 |
}
|
16435 |
}
|
| 16461 |
}
|
16436 |
}
|
| 16462 |
}
|
16437 |
}
|
| 16463 |
}
|
16438 |
}
|
| - |
|
16439 |
/* Handle invalid data-* attribute set by try-catching it */
|
| 16464 |
if (value !== initValue) {
|
16440 |
if (value !== initValue) {
|
| 16465 |
try {
|
16441 |
try {
|
| 16466 |
if (namespaceURI) {
|
16442 |
if (namespaceURI) {
|
| 16467 |
currentNode.setAttributeNS(namespaceURI, name, value);
|
16443 |
currentNode.setAttributeNS(namespaceURI, name, value);
|
| 16468 |
} else {
|
16444 |
} else {
|
| - |
|
16445 |
/* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
|
| 16469 |
currentNode.setAttribute(name, value);
|
16446 |
currentNode.setAttribute(name, value);
|
| 16470 |
}
|
16447 |
}
|
| - |
|
16448 |
if (_isClobbered(currentNode)) {
|
| - |
|
16449 |
_forceRemove(currentNode);
|
| 16471 |
} catch (_) {
|
16450 |
} else {
|
| 16472 |
_removeAttribute(name, currentNode);
|
16451 |
arrayPop(DOMPurify.removed);
|
| 16473 |
}
|
16452 |
}
|
| - |
|
16453 |
} catch (_) {}
|
| 16474 |
}
|
16454 |
}
|
| 16475 |
}
|
16455 |
}
|
| - |
|
16456 |
/* Execute a hook if present */
|
| 16476 |
_executeHook('afterSanitizeAttributes', currentNode, null);
|
16457 |
_executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
|
| 16477 |
};
|
16458 |
};
|
| - |
|
16459 |
/**
|
| - |
|
16460 |
* _sanitizeShadowDOM
|
| - |
|
16461 |
*
|
| - |
|
16462 |
* @param fragment to iterate over recursively
|
| - |
|
16463 |
*/
|
| 16478 |
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
16464 |
const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
|
| 16479 |
let shadowNode;
|
16465 |
let shadowNode = null;
|
| 16480 |
const shadowIterator = _createIterator(fragment);
|
16466 |
const shadowIterator = _createNodeIterator(fragment);
|
| - |
|
16467 |
/* Execute a hook if present */
|
| 16481 |
_executeHook('beforeSanitizeShadowDOM', fragment, null);
|
16468 |
_executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
|
| 16482 |
while (shadowNode = shadowIterator.nextNode()) {
|
16469 |
while (shadowNode = shadowIterator.nextNode()) {
|
| - |
|
16470 |
/* Execute a hook if present */
|
| 16483 |
_executeHook('uponSanitizeShadowNode', shadowNode, null);
|
16471 |
_executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
|
| - |
|
16472 |
/* Sanitize tags and elements */
|
| 16484 |
if (_sanitizeElements(shadowNode)) {
|
16473 |
_sanitizeElements(shadowNode);
|
| 16485 |
continue;
|
16474 |
/* Check attributes next */
|
| - |
|
16475 |
_sanitizeAttributes(shadowNode);
|
| 16486 |
}
|
16476 |
/* Deep shadow DOM detected */
|
| 16487 |
if (shadowNode.content instanceof DocumentFragment) {
|
16477 |
if (shadowNode.content instanceof DocumentFragment) {
|
| 16488 |
_sanitizeShadowDOM(shadowNode.content);
|
16478 |
_sanitizeShadowDOM(shadowNode.content);
|
| 16489 |
}
|
16479 |
}
|
| 16490 |
_sanitizeAttributes(shadowNode);
|
- |
|
| 16491 |
}
|
16480 |
}
|
| - |
|
16481 |
/* Execute a hook if present */
|
| 16492 |
_executeHook('afterSanitizeShadowDOM', fragment, null);
|
16482 |
_executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
|
| 16493 |
};
|
16483 |
};
|
| - |
|
16484 |
// eslint-disable-next-line complexity
|
| 16494 |
DOMPurify.sanitize = function (dirty) {
|
16485 |
DOMPurify.sanitize = function (dirty) {
|
| 16495 |
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
16486 |
let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
| 16496 |
let body;
|
16487 |
let body = null;
|
| 16497 |
let importedNode;
|
16488 |
let importedNode = null;
|
| 16498 |
let currentNode;
|
16489 |
let currentNode = null;
|
| 16499 |
let returnNode;
|
16490 |
let returnNode = null;
|
| - |
|
16491 |
/* Make sure we have a string to sanitize.
|
| - |
|
16492 |
DO NOT return early, as this will return the wrong type if
|
| - |
|
16493 |
the user has requested a DOM object rather than a string */
|
| 16500 |
IS_EMPTY_INPUT = !dirty;
|
16494 |
IS_EMPTY_INPUT = !dirty;
|
| 16501 |
if (IS_EMPTY_INPUT) {
|
16495 |
if (IS_EMPTY_INPUT) {
|
| 16502 |
dirty = '<!-->';
|
16496 |
dirty = '<!-->';
|
| 16503 |
}
|
16497 |
}
|
| - |
|
16498 |
/* Stringify, in case dirty is an object */
|
| 16504 |
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
16499 |
if (typeof dirty !== 'string' && !_isNode(dirty)) {
|
| 16505 |
if (typeof dirty.toString === 'function') {
|
16500 |
if (typeof dirty.toString === 'function') {
|
| 16506 |
dirty = dirty.toString();
|
16501 |
dirty = dirty.toString();
|
| 16507 |
if (typeof dirty !== 'string') {
|
16502 |
if (typeof dirty !== 'string') {
|
| 16508 |
throw typeErrorCreate('dirty is not a string, aborting');
|
16503 |
throw typeErrorCreate('dirty is not a string, aborting');
|
| 16509 |
}
|
16504 |
}
|
| 16510 |
} else {
|
16505 |
} else {
|
| 16511 |
throw typeErrorCreate('toString is not a function');
|
16506 |
throw typeErrorCreate('toString is not a function');
|
| 16512 |
}
|
16507 |
}
|
| 16513 |
}
|
16508 |
}
|
| - |
|
16509 |
/* Return dirty HTML if DOMPurify cannot run */
|
| 16514 |
if (!DOMPurify.isSupported) {
|
16510 |
if (!DOMPurify.isSupported) {
|
| 16515 |
return dirty;
|
16511 |
return dirty;
|
| 16516 |
}
|
16512 |
}
|
| - |
|
16513 |
/* Assign config vars */
|
| 16517 |
if (!SET_CONFIG) {
|
16514 |
if (!SET_CONFIG) {
|
| 16518 |
_parseConfig(cfg);
|
16515 |
_parseConfig(cfg);
|
| 16519 |
}
|
16516 |
}
|
| - |
|
16517 |
/* Clean up removed elements */
|
| 16520 |
DOMPurify.removed = [];
|
16518 |
DOMPurify.removed = [];
|
| - |
|
16519 |
/* Check if dirty is correctly typed for IN_PLACE */
|
| 16521 |
if (typeof dirty === 'string') {
|
16520 |
if (typeof dirty === 'string') {
|
| 16522 |
IN_PLACE = false;
|
16521 |
IN_PLACE = false;
|
| 16523 |
}
|
16522 |
}
|
| 16524 |
if (IN_PLACE) {
|
16523 |
if (IN_PLACE) {
|
| - |
|
16524 |
/* Do some early pre-sanitization to avoid unsafe root nodes */
|
| 16525 |
if (dirty.nodeName) {
|
16525 |
if (dirty.nodeName) {
|
| 16526 |
const tagName = transformCaseFunc(dirty.nodeName);
|
16526 |
const tagName = transformCaseFunc(dirty.nodeName);
|
| 16527 |
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
16527 |
if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
|
| 16528 |
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
16528 |
throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
|
| 16529 |
}
|
16529 |
}
|
| 16530 |
}
|
16530 |
}
|
| 16531 |
} else if (dirty instanceof Node) {
|
16531 |
} else if (dirty instanceof Node) {
|
| - |
|
16532 |
/* If dirty is a DOM element, append to an empty document to avoid
|
| - |
|
16533 |
elements being stripped by the parser */
|
| 16532 |
body = _initDocument('<!---->');
|
16534 |
body = _initDocument('<!---->');
|
| 16533 |
importedNode = body.ownerDocument.importNode(dirty, true);
|
16535 |
importedNode = body.ownerDocument.importNode(dirty, true);
|
| 16534 |
if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
|
16536 |
if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
|
| - |
|
16537 |
/* Node is already a body, use as is */
|
| 16535 |
body = importedNode;
|
16538 |
body = importedNode;
|
| 16536 |
} else if (importedNode.nodeName === 'HTML') {
|
16539 |
} else if (importedNode.nodeName === 'HTML') {
|
| 16537 |
body = importedNode;
|
16540 |
body = importedNode;
|
| 16538 |
} else {
|
16541 |
} else {
|
| - |
|
16542 |
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
| 16539 |
body.appendChild(importedNode);
|
16543 |
body.appendChild(importedNode);
|
| 16540 |
}
|
16544 |
}
|
| 16541 |
} else {
|
16545 |
} else {
|
| - |
|
16546 |
/* Exit directly if we have nothing to do */
|
| 16542 |
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf('<') === -1) {
|
16547 |
if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
|
| - |
|
16548 |
// eslint-disable-next-line unicorn/prefer-includes
|
| - |
|
16549 |
dirty.indexOf('<') === -1) {
|
| 16543 |
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
16550 |
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
|
| 16544 |
}
|
16551 |
}
|
| - |
|
16552 |
/* Initialize the document to work on */
|
| 16545 |
body = _initDocument(dirty);
|
16553 |
body = _initDocument(dirty);
|
| - |
|
16554 |
/* Check we have a DOM node from the data */
|
| 16546 |
if (!body) {
|
16555 |
if (!body) {
|
| 16547 |
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
16556 |
return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
|
| 16548 |
}
|
16557 |
}
|
| 16549 |
}
|
16558 |
}
|
| - |
|
16559 |
/* Remove first element node (ours) if FORCE_BODY is set */
|
| 16550 |
if (body && FORCE_BODY) {
|
16560 |
if (body && FORCE_BODY) {
|
| 16551 |
_forceRemove(body.firstChild);
|
16561 |
_forceRemove(body.firstChild);
|
| 16552 |
}
|
16562 |
}
|
| - |
|
16563 |
/* Get node iterator */
|
| 16553 |
const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
|
16564 |
const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
|
| - |
|
16565 |
/* Now start iterating over the created document */
|
| 16554 |
while (currentNode = nodeIterator.nextNode()) {
|
16566 |
while (currentNode = nodeIterator.nextNode()) {
|
| - |
|
16567 |
/* Sanitize tags and elements */
|
| 16555 |
if (_sanitizeElements(currentNode)) {
|
16568 |
_sanitizeElements(currentNode);
|
| 16556 |
continue;
|
16569 |
/* Check attributes next */
|
| 16557 |
}
|
16570 |
_sanitizeAttributes(currentNode);
|
| - |
|
16571 |
/* Shadow DOM detected, sanitize it */
|
| 16558 |
if (currentNode.content instanceof DocumentFragment) {
|
16572 |
if (currentNode.content instanceof DocumentFragment) {
|
| 16559 |
_sanitizeShadowDOM(currentNode.content);
|
16573 |
_sanitizeShadowDOM(currentNode.content);
|
| 16560 |
}
|
16574 |
}
|
| 16561 |
_sanitizeAttributes(currentNode);
|
- |
|
| 16562 |
}
|
16575 |
}
|
| - |
|
16576 |
/* If we sanitized `dirty` in-place, return it. */
|
| 16563 |
if (IN_PLACE) {
|
16577 |
if (IN_PLACE) {
|
| 16564 |
return dirty;
|
16578 |
return dirty;
|
| 16565 |
}
|
16579 |
}
|
| - |
|
16580 |
/* Return sanitized string or DOM */
|
| 16566 |
if (RETURN_DOM) {
|
16581 |
if (RETURN_DOM) {
|
| 16567 |
if (RETURN_DOM_FRAGMENT) {
|
16582 |
if (RETURN_DOM_FRAGMENT) {
|
| 16568 |
returnNode = createDocumentFragment.call(body.ownerDocument);
|
16583 |
returnNode = createDocumentFragment.call(body.ownerDocument);
|
| 16569 |
while (body.firstChild) {
|
16584 |
while (body.firstChild) {
|
| - |
|
16585 |
// eslint-disable-next-line unicorn/prefer-dom-node-append
|
| 16570 |
returnNode.appendChild(body.firstChild);
|
16586 |
returnNode.appendChild(body.firstChild);
|
| 16571 |
}
|
16587 |
}
|
| 16572 |
} else {
|
16588 |
} else {
|
| 16573 |
returnNode = body;
|
16589 |
returnNode = body;
|
| 16574 |
}
|
16590 |
}
|
| 16575 |
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
16591 |
if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
|
| - |
|
16592 |
/*
|
| - |
|
16593 |
AdoptNode() is not used because internal state is not reset
|
| - |
|
16594 |
(e.g. the past names map of a HTMLFormElement), this is safe
|
| - |
|
16595 |
in theory but we would rather not risk another attack vector.
|
| - |
|
16596 |
The state that is cloned by importNode() is explicitly defined
|
| - |
|
16597 |
by the specs.
|
| - |
|
16598 |
*/
|
| 16576 |
returnNode = importNode.call(originalDocument, returnNode, true);
|
16599 |
returnNode = importNode.call(originalDocument, returnNode, true);
|
| 16577 |
}
|
16600 |
}
|
| 16578 |
return returnNode;
|
16601 |
return returnNode;
|
| 16579 |
}
|
16602 |
}
|
| 16580 |
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
16603 |
let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
|
| - |
|
16604 |
/* Serialize doctype if allowed */
|
| 16581 |
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
16605 |
if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
|
| 16582 |
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
16606 |
serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
|
| 16583 |
}
|
16607 |
}
|
| - |
|
16608 |
/* Sanitize final string template-safe */
|
| 16584 |
if (SAFE_FOR_TEMPLATES) {
|
16609 |
if (SAFE_FOR_TEMPLATES) {
|
| 16585 |
serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
|
16610 |
arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
|
| 16586 |
serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
|
16611 |
serializedHTML = stringReplace(serializedHTML, expr, ' ');
|
| 16587 |
serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
|
16612 |
});
|
| 16588 |
}
|
16613 |
}
|
| 16589 |
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
16614 |
return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
|
| 16590 |
};
|
16615 |
};
|
| 16591 |
DOMPurify.setConfig = function (cfg) {
|
16616 |
DOMPurify.setConfig = function () {
|
| - |
|
16617 |
let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
| 16592 |
_parseConfig(cfg);
|
16618 |
_parseConfig(cfg);
|
| 16593 |
SET_CONFIG = true;
|
16619 |
SET_CONFIG = true;
|
| 16594 |
};
|
16620 |
};
|
| 16595 |
DOMPurify.clearConfig = function () {
|
16621 |
DOMPurify.clearConfig = function () {
|
| 16596 |
CONFIG = null;
|
16622 |
CONFIG = null;
|
| 16597 |
SET_CONFIG = false;
|
16623 |
SET_CONFIG = false;
|
| 16598 |
};
|
16624 |
};
|
| 16599 |
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
16625 |
DOMPurify.isValidAttribute = function (tag, attr, value) {
|
| - |
|
16626 |
/* Initialize shared config vars if necessary. */
|
| 16600 |
if (!CONFIG) {
|
16627 |
if (!CONFIG) {
|
| 16601 |
_parseConfig({});
|
16628 |
_parseConfig({});
|
| 16602 |
}
|
16629 |
}
|
| 16603 |
const lcTag = transformCaseFunc(tag);
|
16630 |
const lcTag = transformCaseFunc(tag);
|
| 16604 |
const lcName = transformCaseFunc(attr);
|
16631 |
const lcName = transformCaseFunc(attr);
|
| Línea 16606... |
Línea 16633... |
| 16606 |
};
|
16633 |
};
|
| 16607 |
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
16634 |
DOMPurify.addHook = function (entryPoint, hookFunction) {
|
| 16608 |
if (typeof hookFunction !== 'function') {
|
16635 |
if (typeof hookFunction !== 'function') {
|
| 16609 |
return;
|
16636 |
return;
|
| 16610 |
}
|
16637 |
}
|
| 16611 |
hooks[entryPoint] = hooks[entryPoint] || [];
|
- |
|
| 16612 |
arrayPush(hooks[entryPoint], hookFunction);
|
16638 |
arrayPush(hooks[entryPoint], hookFunction);
|
| 16613 |
};
|
16639 |
};
|
| 16614 |
DOMPurify.removeHook = function (entryPoint) {
|
16640 |
DOMPurify.removeHook = function (entryPoint, hookFunction) {
|
| 16615 |
if (hooks[entryPoint]) {
|
16641 |
if (hookFunction !== undefined) {
|
| 16616 |
return arrayPop(hooks[entryPoint]);
|
16642 |
const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
|
| - |
|
16643 |
return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
|
| 16617 |
}
|
16644 |
}
|
| - |
|
16645 |
return arrayPop(hooks[entryPoint]);
|
| 16618 |
};
|
16646 |
};
|
| 16619 |
DOMPurify.removeHooks = function (entryPoint) {
|
16647 |
DOMPurify.removeHooks = function (entryPoint) {
|
| 16620 |
if (hooks[entryPoint]) {
|
- |
|
| 16621 |
hooks[entryPoint] = [];
|
16648 |
hooks[entryPoint] = [];
|
| 16622 |
}
|
- |
|
| 16623 |
};
|
16649 |
};
|
| 16624 |
DOMPurify.removeAllHooks = function () {
|
16650 |
DOMPurify.removeAllHooks = function () {
|
| 16625 |
hooks = {};
|
16651 |
hooks = _createHooksMap();
|
| 16626 |
};
|
16652 |
};
|
| 16627 |
return DOMPurify;
|
16653 |
return DOMPurify;
|
| 16628 |
}
|
16654 |
}
|
| 16629 |
var purify = createDOMPurify();
|
16655 |
var purify = createDOMPurify();
|
| Línea 16663... |
Línea 16689... |
| 16663 |
}
|
16689 |
}
|
| 16664 |
};
|
16690 |
};
|
| 16665 |
const decodeUri = encodedUri => {
|
16691 |
const decodeUri = encodedUri => {
|
| 16666 |
try {
|
16692 |
try {
|
| 16667 |
return decodeURIComponent(encodedUri);
|
16693 |
return decodeURIComponent(encodedUri);
|
| 16668 |
} catch (ex) {
|
16694 |
} catch (_a) {
|
| 16669 |
return unescape(encodedUri);
|
16695 |
return unescape(encodedUri);
|
| 16670 |
}
|
16696 |
}
|
| 16671 |
};
|
16697 |
};
|
| 16672 |
const isInvalidUri = (settings, uri, tagName) => {
|
16698 |
const isInvalidUri = (settings, uri, tagName) => {
|
| 16673 |
const decodedUri = decodeUri(uri).replace(/\s/g, '');
|
16699 |
const decodedUri = decodeUri(uri).replace(/\s/g, '');
|
| Línea 16957... |
Línea 16983... |
| 16957 |
const element = SugarElement.fromDom(node);
|
16983 |
const element = SugarElement.fromDom(node);
|
| 16958 |
const isInternalElement = has$1(element, internalElementAttr);
|
16984 |
const isInternalElement = has$1(element, internalElementAttr);
|
| 16959 |
const bogus = get$9(element, 'data-mce-bogus');
|
16985 |
const bogus = get$9(element, 'data-mce-bogus');
|
| 16960 |
if (!isInternalElement && isString(bogus)) {
|
16986 |
if (!isInternalElement && isString(bogus)) {
|
| 16961 |
if (bogus === 'all') {
|
16987 |
if (bogus === 'all') {
|
| 16962 |
remove$5(element);
|
16988 |
remove$4(element);
|
| 16963 |
} else {
|
16989 |
} else {
|
| 16964 |
unwrap(element);
|
16990 |
unwrap(element);
|
| 16965 |
}
|
16991 |
}
|
| 16966 |
return;
|
16992 |
return;
|
| 16967 |
}
|
16993 |
}
|
| 16968 |
const rule = schema.getElementRule(lcTagName);
|
16994 |
const rule = schema.getElementRule(lcTagName);
|
| 16969 |
if (validate && !rule) {
|
16995 |
if (validate && !rule) {
|
| 16970 |
if (has$2(specialElements, lcTagName)) {
|
16996 |
if (has$2(specialElements, lcTagName)) {
|
| 16971 |
remove$5(element);
|
16997 |
remove$4(element);
|
| 16972 |
} else {
|
16998 |
} else {
|
| 16973 |
unwrap(element);
|
16999 |
unwrap(element);
|
| 16974 |
}
|
17000 |
}
|
| 16975 |
return;
|
17001 |
return;
|
| 16976 |
} else {
|
17002 |
} else {
|
| Línea 16978... |
Línea 17004... |
| 16978 |
evt.allowedTags[lcTagName] = true;
|
17004 |
evt.allowedTags[lcTagName] = true;
|
| 16979 |
}
|
17005 |
}
|
| 16980 |
}
|
17006 |
}
|
| 16981 |
if (validate && rule && !isInternalElement) {
|
17007 |
if (validate && rule && !isInternalElement) {
|
| 16982 |
each$e((_c = rule.attributesForced) !== null && _c !== void 0 ? _c : [], attr => {
|
17008 |
each$e((_c = rule.attributesForced) !== null && _c !== void 0 ? _c : [], attr => {
|
| 16983 |
set$3(element, attr.name, attr.value === '{$uid}' ? `mce_${ uid++ }` : attr.value);
|
17009 |
set$4(element, attr.name, attr.value === '{$uid}' ? `mce_${ uid++ }` : attr.value);
|
| 16984 |
});
|
17010 |
});
|
| 16985 |
each$e((_d = rule.attributesDefault) !== null && _d !== void 0 ? _d : [], attr => {
|
17011 |
each$e((_d = rule.attributesDefault) !== null && _d !== void 0 ? _d : [], attr => {
|
| 16986 |
if (!has$1(element, attr.name)) {
|
17012 |
if (!has$1(element, attr.name)) {
|
| 16987 |
set$3(element, attr.name, attr.value === '{$uid}' ? `mce_${ uid++ }` : attr.value);
|
17013 |
set$4(element, attr.name, attr.value === '{$uid}' ? `mce_${ uid++ }` : attr.value);
|
| 16988 |
}
|
17014 |
}
|
| 16989 |
});
|
17015 |
});
|
| 16990 |
if (rule.attributesRequired && !exists(rule.attributesRequired, attr => has$1(element, attr))) {
|
17016 |
if (rule.attributesRequired && !exists(rule.attributesRequired, attr => has$1(element, attr))) {
|
| 16991 |
unwrap(element);
|
17017 |
unwrap(element);
|
| 16992 |
return;
|
17018 |
return;
|
| Línea 17054... |
Línea 17080... |
| 17054 |
ALLOWED_TAGS: [
|
17080 |
ALLOWED_TAGS: [
|
| 17055 |
'#comment',
|
17081 |
'#comment',
|
| 17056 |
'#cdata-section',
|
17082 |
'#cdata-section',
|
| 17057 |
'body'
|
17083 |
'body'
|
| 17058 |
],
|
17084 |
],
|
| 17059 |
ALLOWED_ATTR: []
|
17085 |
ALLOWED_ATTR: [],
|
| - |
|
17086 |
SAFE_FOR_XML: false
|
| 17060 |
};
|
17087 |
};
|
| 17061 |
const config = { ...basePurifyConfig };
|
17088 |
const config = { ...basePurifyConfig };
|
| 17062 |
config.PARSER_MEDIA_TYPE = mimeType;
|
17089 |
config.PARSER_MEDIA_TYPE = mimeType;
|
| 17063 |
if (settings.allow_script_urls) {
|
17090 |
if (settings.allow_script_urls) {
|
| 17064 |
config.ALLOWED_URI_REGEXP = /.*/;
|
17091 |
config.ALLOWED_URI_REGEXP = /.*/;
|
| 17065 |
} else if (settings.allow_html_data_urls) {
|
17092 |
} else if (settings.allow_html_data_urls) {
|
| 17066 |
config.ALLOWED_URI_REGEXP = /^(?!(\w+script|mhtml):)/i;
|
17093 |
config.ALLOWED_URI_REGEXP = /^(?!(\w+script|mhtml):)/i;
|
| 17067 |
}
|
17094 |
}
|
| 17068 |
return config;
|
17095 |
return config;
|
| 17069 |
};
|
17096 |
};
|
| 17070 |
const sanitizeNamespaceElement = ele => {
|
17097 |
const sanitizeSvgElement = ele => {
|
| 17071 |
const xlinkAttrs = [
|
17098 |
const xlinkAttrs = [
|
| 17072 |
'type',
|
17099 |
'type',
|
| 17073 |
'href',
|
17100 |
'href',
|
| 17074 |
'role',
|
17101 |
'role',
|
| 17075 |
'arcrole',
|
17102 |
'arcrole',
|
| Línea 17088... |
Línea 17115... |
| 17088 |
svgFilters: true
|
17115 |
svgFilters: true
|
| 17089 |
},
|
17116 |
},
|
| 17090 |
ALLOWED_ATTR: xlinkAttrs
|
17117 |
ALLOWED_ATTR: xlinkAttrs
|
| 17091 |
};
|
17118 |
};
|
| 17092 |
purify().sanitize(ele, config);
|
17119 |
purify().sanitize(ele, config);
|
| - |
|
17120 |
};
|
| - |
|
17121 |
const sanitizeMathmlElement = (node, settings) => {
|
| - |
|
17122 |
const config = {
|
| - |
|
17123 |
IN_PLACE: true,
|
| - |
|
17124 |
USE_PROFILES: { mathMl: true }
|
| - |
|
17125 |
};
|
| - |
|
17126 |
const purify$1 = purify();
|
| - |
|
17127 |
const allowedEncodings = settings.allow_mathml_annotation_encodings;
|
| - |
|
17128 |
const hasAllowedEncodings = isArray$1(allowedEncodings) && allowedEncodings.length > 0;
|
| - |
|
17129 |
const hasValidEncoding = el => {
|
| - |
|
17130 |
const encoding = el.getAttribute('encoding');
|
| - |
|
17131 |
return hasAllowedEncodings && isString(encoding) && contains$2(allowedEncodings, encoding);
|
| - |
|
17132 |
};
|
| - |
|
17133 |
purify$1.addHook('uponSanitizeElement', (node, evt) => {
|
| - |
|
17134 |
var _a;
|
| - |
|
17135 |
const lcTagName = (_a = evt.tagName) !== null && _a !== void 0 ? _a : node.nodeName.toLowerCase();
|
| - |
|
17136 |
if (hasAllowedEncodings && lcTagName === 'semantics') {
|
| - |
|
17137 |
evt.allowedTags[lcTagName] = true;
|
| - |
|
17138 |
}
|
| - |
|
17139 |
if (lcTagName === 'annotation') {
|
| - |
|
17140 |
const elm = node;
|
| - |
|
17141 |
const keepElement = hasValidEncoding(elm);
|
| - |
|
17142 |
evt.allowedTags[lcTagName] = keepElement;
|
| - |
|
17143 |
if (!keepElement) {
|
| 17093 |
return ele.innerHTML;
|
17144 |
elm.remove();
|
| - |
|
17145 |
}
|
| - |
|
17146 |
}
|
| - |
|
17147 |
});
|
| - |
|
17148 |
purify$1.sanitize(node, config);
|
| - |
|
17149 |
};
|
| - |
|
17150 |
const mkSanitizeNamespaceElement = settings => ele => {
|
| - |
|
17151 |
const namespaceType = toScopeType(ele);
|
| - |
|
17152 |
if (namespaceType === 'svg') {
|
| - |
|
17153 |
sanitizeSvgElement(ele);
|
| - |
|
17154 |
} else if (namespaceType === 'math') {
|
| - |
|
17155 |
sanitizeMathmlElement(ele, settings);
|
| - |
|
17156 |
} else {
|
| - |
|
17157 |
throw new Error('Not a namespace element');
|
| - |
|
17158 |
}
|
| 17094 |
};
|
17159 |
};
|
| 17095 |
const getSanitizer = (settings, schema) => {
|
17160 |
const getSanitizer = (settings, schema) => {
|
| 17096 |
const namespaceTracker = createNamespaceTracker();
|
17161 |
const namespaceTracker = createNamespaceTracker();
|
| 17097 |
if (settings.sanitize) {
|
17162 |
if (settings.sanitize) {
|
| 17098 |
const purify = setupPurify(settings, schema, namespaceTracker);
|
17163 |
const purify = setupPurify(settings, schema, namespaceTracker);
|
| Línea 17101... |
Línea 17166... |
| 17101 |
purify.removed = [];
|
17166 |
purify.removed = [];
|
| 17102 |
namespaceTracker.reset();
|
17167 |
namespaceTracker.reset();
|
| 17103 |
};
|
17168 |
};
|
| 17104 |
return {
|
17169 |
return {
|
| 17105 |
sanitizeHtmlElement,
|
17170 |
sanitizeHtmlElement,
|
| 17106 |
sanitizeNamespaceElement
|
17171 |
sanitizeNamespaceElement: mkSanitizeNamespaceElement(settings)
|
| 17107 |
};
|
17172 |
};
|
| 17108 |
} else {
|
17173 |
} else {
|
| 17109 |
const sanitizeHtmlElement = (body, _mimeType) => {
|
17174 |
const sanitizeHtmlElement = (body, _mimeType) => {
|
| 17110 |
const nodeIterator = document.createNodeIterator(body, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT);
|
17175 |
const nodeIterator = document.createNodeIterator(body, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT);
|
| 17111 |
let node;
|
17176 |
let node;
|
| Línea 17127... |
Línea 17192... |
| 17127 |
};
|
17192 |
};
|
| Línea 17128... |
Línea 17193... |
| 17128 |
|
17193 |
|
| 17129 |
const makeMap = Tools.makeMap, extend$1 = Tools.extend;
|
17194 |
const makeMap = Tools.makeMap, extend$1 = Tools.extend;
|
| 17130 |
const transferChildren = (parent, nativeParent, specialElements, nsSanitizer) => {
|
17195 |
const transferChildren = (parent, nativeParent, specialElements, nsSanitizer) => {
|
| 17131 |
const parentName = parent.name;
|
17196 |
const parentName = parent.name;
|
| 17132 |
const isSpecial = parentName in specialElements && parentName !== 'title' && parentName !== 'textarea';
|
17197 |
const isSpecial = parentName in specialElements && parentName !== 'title' && parentName !== 'textarea' && parentName !== 'noscript';
|
| 17133 |
const childNodes = nativeParent.childNodes;
|
17198 |
const childNodes = nativeParent.childNodes;
|
| 17134 |
for (let ni = 0, nl = childNodes.length; ni < nl; ni++) {
|
17199 |
for (let ni = 0, nl = childNodes.length; ni < nl; ni++) {
|
| 17135 |
const nativeChild = childNodes[ni];
|
17200 |
const nativeChild = childNodes[ni];
|
| 17136 |
const child = new AstNode(nativeChild.nodeName.toLowerCase(), nativeChild.nodeType);
|
17201 |
const child = new AstNode(nativeChild.nodeName.toLowerCase(), nativeChild.nodeType);
|
| Línea 17142... |
Línea 17207... |
| 17142 |
}
|
17207 |
}
|
| 17143 |
if (isNonHtmlElementRootName(child.name)) {
|
17208 |
if (isNonHtmlElementRootName(child.name)) {
|
| 17144 |
nsSanitizer(nativeChild);
|
17209 |
nsSanitizer(nativeChild);
|
| 17145 |
child.value = nativeChild.innerHTML;
|
17210 |
child.value = nativeChild.innerHTML;
|
| 17146 |
}
|
17211 |
}
|
| 17147 |
} else if (isText$a(nativeChild)) {
|
17212 |
} else if (isText$b(nativeChild)) {
|
| 17148 |
child.value = nativeChild.data;
|
17213 |
child.value = nativeChild.data;
|
| 17149 |
if (isSpecial) {
|
17214 |
if (isSpecial) {
|
| 17150 |
child.raw = true;
|
17215 |
child.raw = true;
|
| 17151 |
}
|
17216 |
}
|
| 17152 |
} else if (isComment(nativeChild) || isCData(nativeChild) || isPi(nativeChild)) {
|
17217 |
} else if (isComment(nativeChild) || isCData(nativeChild) || isPi(nativeChild)) {
|
| Línea 17222... |
Línea 17287... |
| 17222 |
if (isLineBreakNode(node.prev, isBlock) || isAtEdgeOfBlock(node, true)) {
|
17287 |
if (isLineBreakNode(node.prev, isBlock) || isAtEdgeOfBlock(node, true)) {
|
| 17223 |
text = text.replace(startWhiteSpaceRegExp, '');
|
17288 |
text = text.replace(startWhiteSpaceRegExp, '');
|
| 17224 |
}
|
17289 |
}
|
| 17225 |
if (text.length === 0) {
|
17290 |
if (text.length === 0) {
|
| 17226 |
node.remove();
|
17291 |
node.remove();
|
| - |
|
17292 |
} else if (text === ' ' && node.prev && node.prev.type === COMMENT && node.next && node.next.type === COMMENT) {
|
| - |
|
17293 |
node.remove();
|
| 17227 |
} else {
|
17294 |
} else {
|
| 17228 |
node.value = text;
|
17295 |
node.value = text;
|
| 17229 |
}
|
17296 |
}
|
| 17230 |
}
|
17297 |
}
|
| 17231 |
}
|
17298 |
}
|
| Línea 17291... |
Línea 17358... |
| 17291 |
const sanitizer = getSanitizer(defaultedSettings, schema);
|
17358 |
const sanitizer = getSanitizer(defaultedSettings, schema);
|
| 17292 |
const parseAndSanitizeWithContext = (html, rootName, format = 'html') => {
|
17359 |
const parseAndSanitizeWithContext = (html, rootName, format = 'html') => {
|
| 17293 |
const mimeType = format === 'xhtml' ? 'application/xhtml+xml' : 'text/html';
|
17360 |
const mimeType = format === 'xhtml' ? 'application/xhtml+xml' : 'text/html';
|
| 17294 |
const isSpecialRoot = has$2(schema.getSpecialElements(), rootName.toLowerCase());
|
17361 |
const isSpecialRoot = has$2(schema.getSpecialElements(), rootName.toLowerCase());
|
| 17295 |
const content = isSpecialRoot ? `<${ rootName }>${ html }</${ rootName }>` : html;
|
17362 |
const content = isSpecialRoot ? `<${ rootName }>${ html }</${ rootName }>` : html;
|
| - |
|
17363 |
const makeWrap = () => {
|
| - |
|
17364 |
if (format === 'xhtml') {
|
| 17296 |
const wrappedHtml = format === 'xhtml' ? `<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>${ content }</body></html>` : `<body>${ content }</body>`;
|
17365 |
return `<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>${ content }</body></html>`;
|
| - |
|
17366 |
} else if (/^[\s]*<head/i.test(html) || /^[\s]*<html/i.test(html) || /^[\s]*<!DOCTYPE/i.test(html)) {
|
| - |
|
17367 |
return `<html>${ content }</html>`;
|
| - |
|
17368 |
} else {
|
| - |
|
17369 |
return `<body>${ content }</body>`;
|
| - |
|
17370 |
}
|
| - |
|
17371 |
};
|
| 17297 |
const body = parser.parseFromString(wrappedHtml, mimeType).body;
|
17372 |
const body = parser.parseFromString(makeWrap(), mimeType).body;
|
| 17298 |
sanitizer.sanitizeHtmlElement(body, mimeType);
|
17373 |
sanitizer.sanitizeHtmlElement(body, mimeType);
|
| 17299 |
return isSpecialRoot ? body.firstChild : body;
|
17374 |
return isSpecialRoot ? body.firstChild : body;
|
| 17300 |
};
|
17375 |
};
|
| 17301 |
const addNodeFilter = nodeFilterRegistry.addFilter;
|
17376 |
const addNodeFilter = nodeFilterRegistry.addFilter;
|
| 17302 |
const getNodeFilters = nodeFilterRegistry.getFilters;
|
17377 |
const getNodeFilters = nodeFilterRegistry.getFilters;
|
| Línea 17440... |
Línea 17515... |
| 17440 |
}
|
17515 |
}
|
| 17441 |
} else {
|
17516 |
} else {
|
| 17442 |
return eventArgs;
|
17517 |
return eventArgs;
|
| 17443 |
}
|
17518 |
}
|
| 17444 |
};
|
17519 |
};
|
| - |
|
17520 |
const makeParserSettings = editor => ({
|
| - |
|
17521 |
sanitize: shouldSanitizeXss(editor),
|
| - |
|
17522 |
sandbox_iframes: shouldSandboxIframes(editor),
|
| - |
|
17523 |
sandbox_iframes_exclusions: getSandboxIframesExclusions(editor)
|
| - |
|
17524 |
});
|
| 17445 |
const preProcessGetContent = (editor, args) => {
|
17525 |
const preProcessGetContent = (editor, args) => {
|
| 17446 |
if (args.no_events) {
|
17526 |
if (args.no_events) {
|
| 17447 |
return Result.value(args);
|
17527 |
return Result.value(args);
|
| 17448 |
} else {
|
17528 |
} else {
|
| 17449 |
const eventArgs = fireBeforeGetContent(editor, args);
|
17529 |
const eventArgs = fireBeforeGetContent(editor, args);
|
| Línea 17462... |
Línea 17542... |
| 17462 |
return content;
|
17542 |
return content;
|
| 17463 |
} else {
|
17543 |
} else {
|
| 17464 |
const processedEventArgs = withSerializedContent(content, content => fireGetContent(editor, {
|
17544 |
const processedEventArgs = withSerializedContent(content, content => fireGetContent(editor, {
|
| 17465 |
...args,
|
17545 |
...args,
|
| 17466 |
content
|
17546 |
content
|
| 17467 |
}), {
|
- |
|
| 17468 |
sanitize: shouldSanitizeXss(editor),
|
17547 |
}), makeParserSettings(editor));
|
| 17469 |
sandbox_iframes: shouldSandboxIframes(editor)
|
- |
|
| 17470 |
});
|
- |
|
| 17471 |
return processedEventArgs.content;
|
17548 |
return processedEventArgs.content;
|
| 17472 |
}
|
17549 |
}
|
| 17473 |
};
|
17550 |
};
|
| 17474 |
const preProcessSetContent = (editor, args) => {
|
17551 |
const preProcessSetContent = (editor, args) => {
|
| 17475 |
if (args.no_events) {
|
17552 |
if (args.no_events) {
|
| 17476 |
return Result.value(args);
|
17553 |
return Result.value(args);
|
| 17477 |
} else {
|
17554 |
} else {
|
| 17478 |
const processedEventArgs = withSerializedContent(args.content, content => fireBeforeSetContent(editor, {
|
17555 |
const processedEventArgs = withSerializedContent(args.content, content => fireBeforeSetContent(editor, {
|
| 17479 |
...args,
|
17556 |
...args,
|
| 17480 |
content
|
17557 |
content
|
| 17481 |
}), {
|
- |
|
| 17482 |
sanitize: shouldSanitizeXss(editor),
|
17558 |
}), makeParserSettings(editor));
|
| 17483 |
sandbox_iframes: shouldSandboxIframes(editor)
|
- |
|
| 17484 |
});
|
- |
|
| 17485 |
if (processedEventArgs.isDefaultPrevented()) {
|
17559 |
if (processedEventArgs.isDefaultPrevented()) {
|
| 17486 |
fireSetContent(editor, processedEventArgs);
|
17560 |
fireSetContent(editor, processedEventArgs);
|
| 17487 |
return Result.error(undefined);
|
17561 |
return Result.error(undefined);
|
| 17488 |
} else {
|
17562 |
} else {
|
| 17489 |
return Result.value(processedEventArgs);
|
17563 |
return Result.value(processedEventArgs);
|
| Línea 17582... |
Línea 17656... |
| 17582 |
};
|
17656 |
};
|
| 17583 |
const modelRowsToDomRows = table => {
|
17657 |
const modelRowsToDomRows = table => {
|
| 17584 |
return map$3(table.rows, row => {
|
17658 |
return map$3(table.rows, row => {
|
| 17585 |
const cells = map$3(row.cells, cell => {
|
17659 |
const cells = map$3(row.cells, cell => {
|
| 17586 |
const td = deep$1(cell);
|
17660 |
const td = deep$1(cell);
|
| 17587 |
remove$a(td, 'colspan');
|
17661 |
remove$9(td, 'colspan');
|
| 17588 |
remove$a(td, 'rowspan');
|
17662 |
remove$9(td, 'rowspan');
|
| 17589 |
return td;
|
17663 |
return td;
|
| 17590 |
});
|
17664 |
});
|
| 17591 |
const tr = shallow$1(row.element);
|
17665 |
const tr = shallow$1(row.element);
|
| 17592 |
append(tr, cells);
|
17666 |
append(tr, cells);
|
| 17593 |
return tr;
|
17667 |
return tr;
|
| Línea 17854... |
Línea 17928... |
| 17854 |
};
|
17928 |
};
|
| Línea 17855... |
Línea 17929... |
| 17855 |
|
17929 |
|
| 17856 |
const getOuterHtml = elm => {
|
17930 |
const getOuterHtml = elm => {
|
| 17857 |
if (isElement$6(elm)) {
|
17931 |
if (isElement$6(elm)) {
|
| 17858 |
return elm.outerHTML;
|
17932 |
return elm.outerHTML;
|
| 17859 |
} else if (isText$a(elm)) {
|
17933 |
} else if (isText$b(elm)) {
|
| 17860 |
return Entities.encodeRaw(elm.data, false);
|
17934 |
return Entities.encodeRaw(elm.data, false);
|
| 17861 |
} else if (isComment(elm)) {
|
17935 |
} else if (isComment(elm)) {
|
| 17862 |
return '<!--' + elm.data + '-->';
|
17936 |
return '<!--' + elm.data + '-->';
|
| 17863 |
}
|
17937 |
}
|
| Línea 18179... |
Línea 18253... |
| 18179 |
insertContent: (value, details) => insertHtmlAtCaret(editor, value, details),
|
18253 |
insertContent: (value, details) => insertHtmlAtCaret(editor, value, details),
|
| 18180 |
addVisual: elm => addVisualInternal(editor, elm)
|
18254 |
addVisual: elm => addVisualInternal(editor, elm)
|
| 18181 |
},
|
18255 |
},
|
| 18182 |
selection: { getContent: (format, args) => getSelectedContentInternal(editor, format, args) },
|
18256 |
selection: { getContent: (format, args) => getSelectedContentInternal(editor, format, args) },
|
| 18183 |
autocompleter: {
|
18257 |
autocompleter: {
|
| 18184 |
addDecoration: range => create$9(editor, range),
|
18258 |
addDecoration: noop,
|
| 18185 |
removeDecoration: () => remove$2(editor, SugarElement.fromDom(editor.getBody()))
|
18259 |
removeDecoration: noop
|
| 18186 |
},
|
18260 |
},
|
| 18187 |
raw: { getModel: () => Optional.none() }
|
18261 |
raw: { getModel: () => Optional.none() }
|
| 18188 |
});
|
18262 |
});
|
| 18189 |
const makeRtcAdaptor = rtcEditor => {
|
18263 |
const makeRtcAdaptor = rtcEditor => {
|
| 18190 |
const defaultVars = vars => isObject(vars) ? vars : {};
|
18264 |
const defaultVars = vars => isObject(vars) ? vars : {};
|
| Línea 18347... |
Línea 18421... |
| 18347 |
const setContent$2 = (editor, content, args) => getRtcInstanceWithFallback(editor).editor.setContent(content, args);
|
18421 |
const setContent$2 = (editor, content, args) => getRtcInstanceWithFallback(editor).editor.setContent(content, args);
|
| 18348 |
const insertContent$1 = (editor, value, details) => getRtcInstanceWithFallback(editor).editor.insertContent(value, details);
|
18422 |
const insertContent$1 = (editor, value, details) => getRtcInstanceWithFallback(editor).editor.insertContent(value, details);
|
| 18349 |
const getSelectedContent = (editor, format, args) => getRtcInstanceWithError(editor).selection.getContent(format, args);
|
18423 |
const getSelectedContent = (editor, format, args) => getRtcInstanceWithError(editor).selection.getContent(format, args);
|
| 18350 |
const addVisual$1 = (editor, elm) => getRtcInstanceWithError(editor).editor.addVisual(elm);
|
18424 |
const addVisual$1 = (editor, elm) => getRtcInstanceWithError(editor).editor.addVisual(elm);
|
| 18351 |
const bindEvents = editor => getRtcInstanceWithError(editor).init.bindEvents();
|
18425 |
const bindEvents = editor => getRtcInstanceWithError(editor).init.bindEvents();
|
| 18352 |
const addAutocompleterDecoration = (editor, range) => getRtcInstanceWithError(editor).autocompleter.addDecoration(range);
|
- |
|
| 18353 |
const removeAutocompleterDecoration = editor => getRtcInstanceWithError(editor).autocompleter.removeDecoration();
|
- |
|
| Línea 18354... |
Línea 18426... |
| 18354 |
|
18426 |
|
| 18355 |
const getContent$1 = (editor, args = {}) => {
|
18427 |
const getContent$1 = (editor, args = {}) => {
|
| 18356 |
const format = args.format ? args.format : 'html';
|
18428 |
const format = args.format ? args.format : 'html';
|
| 18357 |
return getSelectedContent(editor, format, args);
|
18429 |
return getSelectedContent(editor, format, args);
|
| Línea 18358... |
Línea 18430... |
| 18358 |
};
|
18430 |
};
|
| 18359 |
|
18431 |
|
| 18360 |
const removeEmpty = text => {
|
18432 |
const removeEmpty = text => {
|
| 18361 |
if (text.dom.length === 0) {
|
18433 |
if (text.dom.length === 0) {
|
| 18362 |
remove$5(text);
|
18434 |
remove$4(text);
|
| 18363 |
return Optional.none();
|
18435 |
return Optional.none();
|
| 18364 |
} else {
|
18436 |
} else {
|
| 18365 |
return Optional.some(text);
|
18437 |
return Optional.some(text);
|
| Línea 18390... |
Línea 18462... |
| 18390 |
};
|
18462 |
};
|
| 18391 |
const mergeAndNormalizeText = (outerNode, innerNode, rng, start, schema) => {
|
18463 |
const mergeAndNormalizeText = (outerNode, innerNode, rng, start, schema) => {
|
| 18392 |
outerNode.bind(outer => {
|
18464 |
outerNode.bind(outer => {
|
| 18393 |
const normalizer = start ? normalizeWhitespaceBefore : normalizeWhitespaceAfter;
|
18465 |
const normalizer = start ? normalizeWhitespaceBefore : normalizeWhitespaceAfter;
|
| 18394 |
normalizer(outer.dom, start ? outer.dom.length : 0, schema);
|
18466 |
normalizer(outer.dom, start ? outer.dom.length : 0, schema);
|
| 18395 |
return innerNode.filter(isText$b).map(inner => merge$1(outer, inner, rng, start, schema));
|
18467 |
return innerNode.filter(isText$c).map(inner => merge$1(outer, inner, rng, start, schema));
|
| 18396 |
}).orThunk(() => {
|
18468 |
}).orThunk(() => {
|
| 18397 |
const innerTextNode = walkPastBookmark(innerNode, start).or(innerNode).filter(isText$b);
|
18469 |
const innerTextNode = walkPastBookmark(innerNode, start).or(innerNode).filter(isText$c);
|
| 18398 |
return innerTextNode.map(inner => normalizeTextIfRequired(inner, start, schema));
|
18470 |
return innerTextNode.map(inner => normalizeTextIfRequired(inner, start, schema));
|
| 18399 |
});
|
18471 |
});
|
| 18400 |
};
|
18472 |
};
|
| 18401 |
const rngSetContent = (rng, fragment, schema) => {
|
18473 |
const rngSetContent = (rng, fragment, schema) => {
|
| 18402 |
const firstChild = Optional.from(fragment.firstChild).map(SugarElement.fromDom);
|
18474 |
const firstChild = Optional.from(fragment.firstChild).map(SugarElement.fromDom);
|
| 18403 |
const lastChild = Optional.from(fragment.lastChild).map(SugarElement.fromDom);
|
18475 |
const lastChild = Optional.from(fragment.lastChild).map(SugarElement.fromDom);
|
| 18404 |
rng.deleteContents();
|
18476 |
rng.deleteContents();
|
| 18405 |
rng.insertNode(fragment);
|
18477 |
rng.insertNode(fragment);
|
| 18406 |
const prevText = firstChild.bind(prevSibling).filter(isText$b).bind(removeEmpty);
|
18478 |
const prevText = firstChild.bind(prevSibling).filter(isText$c).bind(removeEmpty);
|
| 18407 |
const nextText = lastChild.bind(nextSibling).filter(isText$b).bind(removeEmpty);
|
18479 |
const nextText = lastChild.bind(nextSibling).filter(isText$c).bind(removeEmpty);
|
| 18408 |
mergeAndNormalizeText(prevText, firstChild, rng, true, schema);
|
18480 |
mergeAndNormalizeText(prevText, firstChild, rng, true, schema);
|
| 18409 |
mergeAndNormalizeText(nextText, lastChild, rng, false, schema);
|
18481 |
mergeAndNormalizeText(nextText, lastChild, rng, false, schema);
|
| 18410 |
rng.collapse(false);
|
18482 |
rng.collapse(false);
|
| 18411 |
};
|
18483 |
};
|
| 18412 |
const setupArgs$2 = (args, content) => ({
|
18484 |
const setupArgs$2 = (args, content) => ({
|
| Línea 18543... |
Línea 18615... |
| 18543 |
}
|
18615 |
}
|
| 18544 |
};
|
18616 |
};
|
| 18545 |
const getContent = args => getContent$1(editor, args);
|
18617 |
const getContent = args => getContent$1(editor, args);
|
| 18546 |
const setContent = (content, args) => setContent$1(editor, content, args);
|
18618 |
const setContent = (content, args) => setContent$1(editor, content, args);
|
| 18547 |
const getStart$1 = real => getStart(editor.getBody(), getRng$1(), real);
|
18619 |
const getStart$1 = real => getStart(editor.getBody(), getRng$1(), real);
|
| 18548 |
const getEnd = real => getEnd$1(editor.getBody(), getRng$1(), real);
|
18620 |
const getEnd$1 = real => getEnd(editor.getBody(), getRng$1(), real);
|
| 18549 |
const getBookmark = (type, normalized) => bookmarkManager.getBookmark(type, normalized);
|
18621 |
const getBookmark = (type, normalized) => bookmarkManager.getBookmark(type, normalized);
|
| 18550 |
const moveToBookmark = bookmark => bookmarkManager.moveToBookmark(bookmark);
|
18622 |
const moveToBookmark = bookmark => bookmarkManager.moveToBookmark(bookmark);
|
| 18551 |
const select$1 = (node, content) => {
|
18623 |
const select$1 = (node, content) => {
|
| 18552 |
select(dom, node, content).each(setRng);
|
18624 |
select(dom, node, content).each(setRng);
|
| 18553 |
return node;
|
18625 |
return node;
|
| Línea 18561... |
Línea 18633... |
| 18561 |
return rng.compareEndPoints('StartToEnd', rng) === 0;
|
18633 |
return rng.compareEndPoints('StartToEnd', rng) === 0;
|
| 18562 |
}
|
18634 |
}
|
| 18563 |
return !sel || rng.collapsed;
|
18635 |
return !sel || rng.collapsed;
|
| 18564 |
};
|
18636 |
};
|
| 18565 |
const isEditable = () => {
|
18637 |
const isEditable = () => {
|
| - |
|
18638 |
if (editor.mode.isReadOnly()) {
|
| - |
|
18639 |
return false;
|
| - |
|
18640 |
}
|
| 18566 |
const rng = getRng$1();
|
18641 |
const rng = getRng$1();
|
| 18567 |
const fakeSelectedElements = editor.getBody().querySelectorAll('[data-mce-selected="1"]');
|
18642 |
const fakeSelectedElements = editor.getBody().querySelectorAll('[data-mce-selected="1"]');
|
| 18568 |
if (fakeSelectedElements.length > 0) {
|
18643 |
if (fakeSelectedElements.length > 0) {
|
| 18569 |
return forall(fakeSelectedElements, el => dom.isEditable(el.parentElement));
|
18644 |
return forall(fakeSelectedElements, el => dom.isEditable(el.parentElement));
|
| 18570 |
} else {
|
18645 |
} else {
|
| Línea 18580... |
Línea 18655... |
| 18580 |
const getRng$1 = () => {
|
18655 |
const getRng$1 = () => {
|
| 18581 |
let rng;
|
18656 |
let rng;
|
| 18582 |
const tryCompareBoundaryPoints = (how, sourceRange, destinationRange) => {
|
18657 |
const tryCompareBoundaryPoints = (how, sourceRange, destinationRange) => {
|
| 18583 |
try {
|
18658 |
try {
|
| 18584 |
return sourceRange.compareBoundaryPoints(how, destinationRange);
|
18659 |
return sourceRange.compareBoundaryPoints(how, destinationRange);
|
| 18585 |
} catch (ex) {
|
18660 |
} catch (_a) {
|
| 18586 |
return -1;
|
18661 |
return -1;
|
| 18587 |
}
|
18662 |
}
|
| 18588 |
};
|
18663 |
};
|
| 18589 |
const doc = win.document;
|
18664 |
const doc = win.document;
|
| 18590 |
if (isNonNullable(editor.bookmark) && !hasFocus(editor)) {
|
18665 |
if (isNonNullable(editor.bookmark) && !hasFocus(editor)) {
|
| Línea 18601... |
Línea 18676... |
| 18601 |
} else {
|
18676 |
} else {
|
| 18602 |
rng = doc.createRange();
|
18677 |
rng = doc.createRange();
|
| 18603 |
}
|
18678 |
}
|
| 18604 |
rng = processRanges(editor, [rng])[0];
|
18679 |
rng = processRanges(editor, [rng])[0];
|
| 18605 |
}
|
18680 |
}
|
| 18606 |
} catch (ex) {
|
18681 |
} catch (_a) {
|
| 18607 |
}
|
18682 |
}
|
| 18608 |
if (!rng) {
|
18683 |
if (!rng) {
|
| 18609 |
rng = doc.createRange();
|
18684 |
rng = doc.createRange();
|
| 18610 |
}
|
18685 |
}
|
| 18611 |
if (isDocument$1(rng.startContainer) && rng.collapsed) {
|
18686 |
if (isDocument$1(rng.startContainer) && rng.collapsed) {
|
| Línea 18636... |
Línea 18711... |
| 18636 |
if (sel) {
|
18711 |
if (sel) {
|
| 18637 |
explicitRange = rng;
|
18712 |
explicitRange = rng;
|
| 18638 |
try {
|
18713 |
try {
|
| 18639 |
sel.removeAllRanges();
|
18714 |
sel.removeAllRanges();
|
| 18640 |
sel.addRange(rng);
|
18715 |
sel.addRange(rng);
|
| 18641 |
} catch (ex) {
|
18716 |
} catch (_a) {
|
| 18642 |
}
|
18717 |
}
|
| 18643 |
if (forward === false && sel.extend) {
|
18718 |
if (forward === false && sel.extend) {
|
| 18644 |
sel.collapse(rng.endContainer, rng.endOffset);
|
18719 |
sel.collapse(rng.endContainer, rng.endOffset);
|
| 18645 |
sel.extend(rng.startContainer, rng.startOffset);
|
18720 |
sel.extend(rng.startContainer, rng.startOffset);
|
| 18646 |
}
|
18721 |
}
|
| Línea 18682... |
Línea 18757... |
| 18682 |
try {
|
18757 |
try {
|
| 18683 |
anchorRange.setStart(anchorNode, sel.anchorOffset);
|
18758 |
anchorRange.setStart(anchorNode, sel.anchorOffset);
|
| 18684 |
anchorRange.collapse(true);
|
18759 |
anchorRange.collapse(true);
|
| 18685 |
focusRange.setStart(focusNode, sel.focusOffset);
|
18760 |
focusRange.setStart(focusNode, sel.focusOffset);
|
| 18686 |
focusRange.collapse(true);
|
18761 |
focusRange.collapse(true);
|
| 18687 |
} catch (e) {
|
18762 |
} catch (_a) {
|
| 18688 |
return true;
|
18763 |
return true;
|
| 18689 |
}
|
18764 |
}
|
| 18690 |
return anchorRange.compareBoundaryPoints(anchorRange.START_TO_START, focusRange) <= 0;
|
18765 |
return anchorRange.compareBoundaryPoints(anchorRange.START_TO_START, focusRange) <= 0;
|
| 18691 |
};
|
18766 |
};
|
| 18692 |
const normalize = () => {
|
18767 |
const normalize = () => {
|
| Línea 18754... |
Línea 18829... |
| 18754 |
getNode: getNode$1,
|
18829 |
getNode: getNode$1,
|
| 18755 |
getSel,
|
18830 |
getSel,
|
| 18756 |
setRng,
|
18831 |
setRng,
|
| 18757 |
getRng: getRng$1,
|
18832 |
getRng: getRng$1,
|
| 18758 |
getStart: getStart$1,
|
18833 |
getStart: getStart$1,
|
| 18759 |
getEnd,
|
18834 |
getEnd: getEnd$1,
|
| 18760 |
getSelectedBlocks: getSelectedBlocks$1,
|
18835 |
getSelectedBlocks: getSelectedBlocks$1,
|
| 18761 |
normalize,
|
18836 |
normalize,
|
| 18762 |
selectorChanged,
|
18837 |
selectorChanged,
|
| 18763 |
selectorChangedWithUnbind,
|
18838 |
selectorChangedWithUnbind,
|
| 18764 |
getScrollContainer,
|
18839 |
getScrollContainer,
|
| Línea 18772... |
Línea 18847... |
| 18772 |
exports.bookmarkManager = bookmarkManager;
|
18847 |
exports.bookmarkManager = bookmarkManager;
|
| 18773 |
exports.controlSelection = controlSelection;
|
18848 |
exports.controlSelection = controlSelection;
|
| 18774 |
return exports;
|
18849 |
return exports;
|
| 18775 |
};
|
18850 |
};
|
| Línea -... |
Línea 18851... |
| - |
|
18851 |
|
| - |
|
18852 |
const addNodeFilter = (settings, htmlParser, schema) => {
|
| - |
|
18853 |
htmlParser.addNodeFilter('br', (nodes, _, args) => {
|
| - |
|
18854 |
const blockElements = Tools.extend({}, schema.getBlockElements());
|
| - |
|
18855 |
const nonEmptyElements = schema.getNonEmptyElements();
|
| - |
|
18856 |
const whitespaceElements = schema.getWhitespaceElements();
|
| - |
|
18857 |
blockElements.body = 1;
|
| - |
|
18858 |
const isBlock = node => node.name in blockElements || isTransparentAstBlock(schema, node);
|
| - |
|
18859 |
for (let i = 0, l = nodes.length; i < l; i++) {
|
| - |
|
18860 |
let node = nodes[i];
|
| - |
|
18861 |
let parent = node.parent;
|
| - |
|
18862 |
if (parent && isBlock(parent) && node === parent.lastChild) {
|
| - |
|
18863 |
let prev = node.prev;
|
| - |
|
18864 |
while (prev) {
|
| - |
|
18865 |
const prevName = prev.name;
|
| - |
|
18866 |
if (prevName !== 'span' || prev.attr('data-mce-type') !== 'bookmark') {
|
| - |
|
18867 |
if (prevName === 'br') {
|
| - |
|
18868 |
node = null;
|
| - |
|
18869 |
}
|
| - |
|
18870 |
break;
|
| - |
|
18871 |
}
|
| - |
|
18872 |
prev = prev.prev;
|
| - |
|
18873 |
}
|
| - |
|
18874 |
if (node) {
|
| - |
|
18875 |
node.remove();
|
| - |
|
18876 |
if (isEmpty(schema, nonEmptyElements, whitespaceElements, parent)) {
|
| - |
|
18877 |
const elementRule = schema.getElementRule(parent.name);
|
| - |
|
18878 |
if (elementRule) {
|
| - |
|
18879 |
if (elementRule.removeEmpty) {
|
| - |
|
18880 |
parent.remove();
|
| - |
|
18881 |
} else if (elementRule.paddEmpty) {
|
| - |
|
18882 |
paddEmptyNode(settings, args, isBlock, parent);
|
| - |
|
18883 |
}
|
| - |
|
18884 |
}
|
| - |
|
18885 |
}
|
| - |
|
18886 |
}
|
| - |
|
18887 |
} else {
|
| - |
|
18888 |
let lastParent = node;
|
| - |
|
18889 |
while (parent && parent.firstChild === lastParent && parent.lastChild === lastParent) {
|
| - |
|
18890 |
lastParent = parent;
|
| - |
|
18891 |
if (blockElements[parent.name]) {
|
| - |
|
18892 |
break;
|
| - |
|
18893 |
}
|
| - |
|
18894 |
parent = parent.parent;
|
| - |
|
18895 |
}
|
| - |
|
18896 |
if (lastParent === parent) {
|
| - |
|
18897 |
const textNode = new AstNode('#text', 3);
|
| - |
|
18898 |
textNode.value = nbsp;
|
| - |
|
18899 |
node.replace(textNode);
|
| - |
|
18900 |
}
|
| - |
|
18901 |
}
|
| - |
|
18902 |
}
|
| - |
|
18903 |
});
|
| - |
|
18904 |
};
|
| 18776 |
|
18905 |
|
| 18777 |
const register$3 = (htmlParser, settings, dom) => {
|
18906 |
const register$3 = (htmlParser, settings, dom) => {
|
| 18778 |
htmlParser.addAttributeFilter('data-mce-tabindex', (nodes, name) => {
|
18907 |
htmlParser.addAttributeFilter('data-mce-tabindex', (nodes, name) => {
|
| 18779 |
let i = nodes.length;
|
18908 |
let i = nodes.length;
|
| 18780 |
while (i--) {
|
18909 |
while (i--) {
|
| Línea 18821... |
Línea 18950... |
| 18821 |
while (i--) {
|
18950 |
while (i--) {
|
| 18822 |
const node = nodes[i];
|
18951 |
const node = nodes[i];
|
| 18823 |
if (node.attr('data-mce-type') === 'bookmark' && !args.cleanup) {
|
18952 |
if (node.attr('data-mce-type') === 'bookmark' && !args.cleanup) {
|
| 18824 |
const hasChildren = Optional.from(node.firstChild).exists(firstChild => {
|
18953 |
const hasChildren = Optional.from(node.firstChild).exists(firstChild => {
|
| 18825 |
var _a;
|
18954 |
var _a;
|
| 18826 |
return !isZwsp$1((_a = firstChild.value) !== null && _a !== void 0 ? _a : '');
|
18955 |
return !isZwsp((_a = firstChild.value) !== null && _a !== void 0 ? _a : '');
|
| 18827 |
});
|
18956 |
});
|
| 18828 |
if (hasChildren) {
|
18957 |
if (hasChildren) {
|
| 18829 |
node.unwrap();
|
18958 |
node.unwrap();
|
| 18830 |
} else {
|
18959 |
} else {
|
| 18831 |
node.remove();
|
18960 |
node.remove();
|
| 18832 |
}
|
18961 |
}
|
| 18833 |
}
|
18962 |
}
|
| 18834 |
}
|
18963 |
}
|
| 18835 |
});
|
18964 |
});
|
| 18836 |
htmlParser.addNodeFilter('noscript', nodes => {
|
- |
|
| 18837 |
var _a;
|
- |
|
| 18838 |
let i = nodes.length;
|
- |
|
| 18839 |
while (i--) {
|
- |
|
| 18840 |
const node = nodes[i].firstChild;
|
- |
|
| 18841 |
if (node) {
|
- |
|
| 18842 |
node.value = Entities.decode((_a = node.value) !== null && _a !== void 0 ? _a : '');
|
- |
|
| 18843 |
}
|
- |
|
| 18844 |
}
|
- |
|
| 18845 |
});
|
- |
|
| 18846 |
htmlParser.addNodeFilter('script,style', (nodes, name) => {
|
18965 |
htmlParser.addNodeFilter('script,style', (nodes, name) => {
|
| 18847 |
var _a;
|
18966 |
var _a;
|
| 18848 |
const trim = value => {
|
18967 |
const trim = value => {
|
| 18849 |
return value.replace(/(<!--\[CDATA\[|\]\]-->)/g, '\n').replace(/^[\r\n]*|[\r\n]*$/g, '').replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi, '').replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g, '');
|
18968 |
return value.replace(/(<!--\[CDATA\[|\]\]-->)/g, '\n').replace(/^[\r\n]*|[\r\n]*$/g, '').replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi, '').replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g, '');
|
| 18850 |
};
|
18969 |
};
|
| Línea 19096... |
Línea 19215... |
| 19096 |
postProcessSetContent(editor, result.html, updatedArgs);
|
19215 |
postProcessSetContent(editor, result.html, updatedArgs);
|
| 19097 |
return result.content;
|
19216 |
return result.content;
|
| 19098 |
}).getOr(content);
|
19217 |
}).getOr(content);
|
| 19099 |
};
|
19218 |
};
|
| Línea 19100... |
Línea 19219... |
| 19100 |
|
19219 |
|
| 19101 |
const removedOptions = ('autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,' + 'boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,' + 'force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,' + 'non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,' + 'tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,' + 'paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists').split(',');
|
19220 |
const removedOptions = ('autoresize_on_init,content_editable_state,padd_empty_with_br,block_elements,' + 'boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,' + 'force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,' + 'non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,' + 'tab_focus,tabfocus_elements,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,' + 'paste_enable_default_filters,paste_filter_drop,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists,' + 'template_cdate_classes,template_mdate_classes,template_selected_content_classes,template_preview_replace_values,template_replace_values,templates,template_cdate_format,template_mdate_format').split(',');
|
| 19102 |
const deprecatedOptions = 'template_cdate_classes,template_mdate_classes,template_selected_content_classes,template_preview_replace_values,template_replace_values,templates,template_cdate_format,template_mdate_format'.split(',');
|
19221 |
const deprecatedOptions = [];
|
| 19103 |
const removedPlugins = 'bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor'.split(',');
|
19222 |
const removedPlugins = 'bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,template,textcolor,rtc'.split(',');
|
| 19104 |
const deprecatedPlugins = [
|
- |
|
| 19105 |
{
|
- |
|
| 19106 |
name: 'template',
|
- |
|
| 19107 |
replacedWith: 'Advanced Template'
|
- |
|
| 19108 |
},
|
- |
|
| 19109 |
{ name: 'rtc' }
|
- |
|
| 19110 |
];
|
19223 |
const deprecatedPlugins = [];
|
| 19111 |
const getMatchingOptions = (options, searchingFor) => {
|
19224 |
const getMatchingOptions = (options, searchingFor) => {
|
| 19112 |
const settingNames = filter$5(searchingFor, setting => has$2(options, setting));
|
19225 |
const settingNames = filter$5(searchingFor, setting => has$2(options, setting));
|
| 19113 |
return sort(settingNames);
|
19226 |
return sort(settingNames);
|
| 19114 |
};
|
19227 |
};
|
| Línea 19138... |
Línea 19251... |
| 19138 |
if (hasRemovedPlugins || hasRemovedOptions || isLegacyMobileTheme) {
|
19251 |
if (hasRemovedPlugins || hasRemovedOptions || isLegacyMobileTheme) {
|
| 19139 |
const listJoiner = '\n- ';
|
19252 |
const listJoiner = '\n- ';
|
| 19140 |
const themesMessage = isLegacyMobileTheme ? `\n\nThemes:${ listJoiner }mobile` : '';
|
19253 |
const themesMessage = isLegacyMobileTheme ? `\n\nThemes:${ listJoiner }mobile` : '';
|
| 19141 |
const pluginsMessage = hasRemovedPlugins ? `\n\nPlugins:${ listJoiner }${ removedPlugins.join(listJoiner) }` : '';
|
19254 |
const pluginsMessage = hasRemovedPlugins ? `\n\nPlugins:${ listJoiner }${ removedPlugins.join(listJoiner) }` : '';
|
| 19142 |
const optionsMessage = hasRemovedOptions ? `\n\nOptions:${ listJoiner }${ removedOptions.join(listJoiner) }` : '';
|
19255 |
const optionsMessage = hasRemovedOptions ? `\n\nOptions:${ listJoiner }${ removedOptions.join(listJoiner) }` : '';
|
| 19143 |
console.warn('The following deprecated features are currently enabled and have been removed in TinyMCE 6.0. These features will no longer work and should be removed from the TinyMCE configuration. ' + 'See https://www.tiny.cloud/docs/tinymce/6/migration-from-5x/ for more information.' + themesMessage + pluginsMessage + optionsMessage);
|
19256 |
console.warn('The following deprecated features are currently enabled and have been removed in TinyMCE 7.0. These features will no longer work and should be removed from the TinyMCE configuration. ' + 'See https://www.tiny.cloud/docs/tinymce/7/migration-from-6x/ for more information.' + themesMessage + pluginsMessage + optionsMessage);
|
| 19144 |
}
|
19257 |
}
|
| 19145 |
};
|
19258 |
};
|
| 19146 |
const getPluginDescription = name => find$2(deprecatedPlugins, entry => entry.name === name).fold(() => name, entry => {
|
19259 |
const getPluginDescription = name => find$2(deprecatedPlugins, entry => entry.name === name).fold(() => name, entry => {
|
| 19147 |
if (entry.replacedWith) {
|
19260 |
if (entry.replacedWith) {
|
| 19148 |
return `${ name }, replaced by ${ entry.replacedWith }`;
|
19261 |
return `${ name }, replaced by ${ entry.replacedWith }`;
|
| Línea 19323... |
Línea 19436... |
| 19323 |
};
|
19436 |
};
|
| 19324 |
const isEqual = (a, b) => {
|
19437 |
const isEqual = (a, b) => {
|
| 19325 |
return a.type === b.type && a.text === b.text && !a.progressBar && !a.timeout && !b.progressBar && !b.timeout;
|
19438 |
return a.type === b.type && a.text === b.text && !a.progressBar && !a.timeout && !b.progressBar && !b.timeout;
|
| 19326 |
};
|
19439 |
};
|
| 19327 |
const reposition = () => {
|
19440 |
const reposition = () => {
|
| 19328 |
each$e(notifications, notification => {
|
19441 |
getTopNotification().each(notification => {
|
| 19329 |
notification.reposition();
|
19442 |
notification.reposition();
|
| 19330 |
});
|
19443 |
});
|
| 19331 |
};
|
19444 |
};
|
| 19332 |
const addNotification = notification => {
|
19445 |
const addNotification = notification => {
|
| 19333 |
notifications.push(notification);
|
19446 |
notifications.push(notification);
|
| Línea 19350... |
Línea 19463... |
| 19350 |
return isEqual(getImplementation().getArgs(notification), spec);
|
19463 |
return isEqual(getImplementation().getArgs(notification), spec);
|
| 19351 |
}).getOrThunk(() => {
|
19464 |
}).getOrThunk(() => {
|
| 19352 |
editor.editorManager.setActive(editor);
|
19465 |
editor.editorManager.setActive(editor);
|
| 19353 |
const notification = getImplementation().open(spec, () => {
|
19466 |
const notification = getImplementation().open(spec, () => {
|
| 19354 |
closeNotification(notification);
|
19467 |
closeNotification(notification);
|
| 19355 |
reposition();
|
- |
|
| 19356 |
if (hasEditorOrUiFocus(editor)) {
|
19468 |
}, () => hasEditorOrUiFocus(editor));
|
| 19357 |
getTopNotification().fold(() => editor.focus(), top => focus$1(SugarElement.fromDom(top.getEl())));
|
- |
|
| 19358 |
}
|
- |
|
| 19359 |
});
|
- |
|
| 19360 |
addNotification(notification);
|
19469 |
addNotification(notification);
|
| 19361 |
reposition();
|
19470 |
reposition();
|
| 19362 |
editor.dispatch('OpenNotification', { notification: { ...notification } });
|
19471 |
editor.dispatch('OpenNotification', { notification: { ...notification } });
|
| 19363 |
return notification;
|
19472 |
return notification;
|
| 19364 |
});
|
19473 |
});
|
| Línea 19381... |
Línea 19490... |
| 19381 |
timeout: 0
|
19490 |
timeout: 0
|
| 19382 |
}, false);
|
19491 |
}, false);
|
| 19383 |
}
|
19492 |
}
|
| 19384 |
reposition();
|
19493 |
reposition();
|
| 19385 |
});
|
19494 |
});
|
| 19386 |
editor.on('show ResizeEditor ResizeWindow NodeChange', () => {
|
19495 |
editor.on('show ResizeEditor ResizeWindow NodeChange ToggleView FullscreenStateChanged', () => {
|
| 19387 |
requestAnimationFrame(reposition);
|
19496 |
requestAnimationFrame(reposition);
|
| 19388 |
});
|
19497 |
});
|
| 19389 |
editor.on('remove', () => {
|
19498 |
editor.on('remove', () => {
|
| 19390 |
each$e(notifications.slice(), notification => {
|
19499 |
each$e(notifications.slice(), notification => {
|
| 19391 |
getImplementation().close(notification);
|
19500 |
getImplementation().close(notification);
|
| 19392 |
});
|
19501 |
});
|
| 19393 |
});
|
19502 |
});
|
| - |
|
19503 |
editor.on('keydown', e => {
|
| - |
|
19504 |
var _a;
|
| - |
|
19505 |
const isF12 = ((_a = e.key) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'f12' || e.keyCode === 123;
|
| - |
|
19506 |
if (e.altKey && isF12) {
|
| - |
|
19507 |
e.preventDefault();
|
| - |
|
19508 |
getTopNotification().map(notificationApi => SugarElement.fromDom(notificationApi.getEl())).each(elm => focus$1(elm));
|
| - |
|
19509 |
}
|
| - |
|
19510 |
});
|
| 19394 |
};
|
19511 |
};
|
| 19395 |
registerEvents(editor);
|
19512 |
registerEvents(editor);
|
| 19396 |
return {
|
19513 |
return {
|
| 19397 |
open,
|
19514 |
open,
|
| 19398 |
close,
|
19515 |
close,
|
| Línea 19551... |
Línea 19668... |
| 19551 |
console.log(message, ...x);
|
19668 |
console.log(message, ...x);
|
| 19552 |
}
|
19669 |
}
|
| 19553 |
}
|
19670 |
}
|
| 19554 |
};
|
19671 |
};
|
| Línea -... |
Línea 19672... |
| - |
|
19672 |
|
| - |
|
19673 |
const removeFakeSelection = editor => {
|
| - |
|
19674 |
Optional.from(editor.selection.getNode()).each(elm => {
|
| - |
|
19675 |
elm.removeAttribute('data-mce-selected');
|
| - |
|
19676 |
});
|
| - |
|
19677 |
};
|
| - |
|
19678 |
const setEditorCommandState = (editor, cmd, state) => {
|
| - |
|
19679 |
try {
|
| - |
|
19680 |
editor.getDoc().execCommand(cmd, false, String(state));
|
| - |
|
19681 |
} catch (_a) {
|
| - |
|
19682 |
}
|
| - |
|
19683 |
};
|
| - |
|
19684 |
const setCommonEditorCommands = (editor, state) => {
|
| - |
|
19685 |
setEditorCommandState(editor, 'StyleWithCSS', state);
|
| - |
|
19686 |
setEditorCommandState(editor, 'enableInlineTableEditing', state);
|
| - |
|
19687 |
setEditorCommandState(editor, 'enableObjectResizing', state);
|
| - |
|
19688 |
};
|
| - |
|
19689 |
const restoreFakeSelection = editor => {
|
| - |
|
19690 |
editor.selection.setRng(editor.selection.getRng());
|
| - |
|
19691 |
};
|
| - |
|
19692 |
const toggleClass = (elm, cls, state) => {
|
| - |
|
19693 |
if (has(elm, cls) && !state) {
|
| - |
|
19694 |
remove$6(elm, cls);
|
| - |
|
19695 |
} else if (state) {
|
| - |
|
19696 |
add$2(elm, cls);
|
| - |
|
19697 |
}
|
| - |
|
19698 |
};
|
| - |
|
19699 |
const disableEditor = editor => {
|
| - |
|
19700 |
const body = SugarElement.fromDom(editor.getBody());
|
| - |
|
19701 |
toggleClass(body, 'mce-content-readonly', true);
|
| - |
|
19702 |
editor.selection.controlSelection.hideResizeRect();
|
| - |
|
19703 |
editor._selectionOverrides.hideFakeCaret();
|
| - |
|
19704 |
removeFakeSelection(editor);
|
| - |
|
19705 |
};
|
| - |
|
19706 |
const enableEditor = editor => {
|
| - |
|
19707 |
const body = SugarElement.fromDom(editor.getBody());
|
| - |
|
19708 |
toggleClass(body, 'mce-content-readonly', false);
|
| - |
|
19709 |
if (editor.hasEditableRoot()) {
|
| - |
|
19710 |
set$3(body, true);
|
| - |
|
19711 |
}
|
| - |
|
19712 |
setCommonEditorCommands(editor, false);
|
| - |
|
19713 |
if (hasEditorOrUiFocus(editor)) {
|
| - |
|
19714 |
editor.focus();
|
| - |
|
19715 |
}
|
| - |
|
19716 |
restoreFakeSelection(editor);
|
| - |
|
19717 |
editor.nodeChanged();
|
| - |
|
19718 |
};
|
| - |
|
19719 |
|
| - |
|
19720 |
const isDisabled = editor => isDisabled$1(editor);
|
| - |
|
19721 |
const internalContentEditableAttr = 'data-mce-contenteditable';
|
| - |
|
19722 |
const switchOffContentEditableTrue = elm => {
|
| - |
|
19723 |
each$e(descendants(elm, '*[contenteditable="true"]'), elm => {
|
| - |
|
19724 |
set$4(elm, internalContentEditableAttr, 'true');
|
| - |
|
19725 |
set$3(elm, false);
|
| - |
|
19726 |
});
|
| - |
|
19727 |
};
|
| - |
|
19728 |
const switchOnContentEditableTrue = elm => {
|
| - |
|
19729 |
each$e(descendants(elm, `*[${ internalContentEditableAttr }="true"]`), elm => {
|
| - |
|
19730 |
remove$9(elm, internalContentEditableAttr);
|
| - |
|
19731 |
set$3(elm, true);
|
| - |
|
19732 |
});
|
| - |
|
19733 |
};
|
| - |
|
19734 |
const toggleDisabled = (editor, state) => {
|
| - |
|
19735 |
const body = SugarElement.fromDom(editor.getBody());
|
| - |
|
19736 |
if (state) {
|
| - |
|
19737 |
disableEditor(editor);
|
| - |
|
19738 |
set$3(body, false);
|
| - |
|
19739 |
switchOffContentEditableTrue(body);
|
| - |
|
19740 |
} else {
|
| - |
|
19741 |
switchOnContentEditableTrue(body);
|
| - |
|
19742 |
enableEditor(editor);
|
| - |
|
19743 |
}
|
| - |
|
19744 |
};
|
| - |
|
19745 |
const registerDisabledContentFilters = editor => {
|
| - |
|
19746 |
if (editor.serializer) {
|
| - |
|
19747 |
registerFilters(editor);
|
| - |
|
19748 |
} else {
|
| - |
|
19749 |
editor.on('PreInit', () => {
|
| - |
|
19750 |
registerFilters(editor);
|
| - |
|
19751 |
});
|
| - |
|
19752 |
}
|
| - |
|
19753 |
};
|
| - |
|
19754 |
const registerFilters = editor => {
|
| - |
|
19755 |
editor.parser.addAttributeFilter('contenteditable', nodes => {
|
| - |
|
19756 |
if (isDisabled(editor)) {
|
| - |
|
19757 |
each$e(nodes, node => {
|
| - |
|
19758 |
node.attr(internalContentEditableAttr, node.attr('contenteditable'));
|
| - |
|
19759 |
node.attr('contenteditable', 'false');
|
| - |
|
19760 |
});
|
| - |
|
19761 |
}
|
| - |
|
19762 |
});
|
| - |
|
19763 |
editor.serializer.addAttributeFilter(internalContentEditableAttr, nodes => {
|
| - |
|
19764 |
if (isDisabled(editor)) {
|
| - |
|
19765 |
each$e(nodes, node => {
|
| - |
|
19766 |
node.attr('contenteditable', node.attr(internalContentEditableAttr));
|
| - |
|
19767 |
});
|
| - |
|
19768 |
}
|
| - |
|
19769 |
});
|
| - |
|
19770 |
editor.serializer.addTempAttr(internalContentEditableAttr);
|
| - |
|
19771 |
};
|
| - |
|
19772 |
const isClickEvent = e => e.type === 'click';
|
| - |
|
19773 |
const allowedEvents = ['copy'];
|
| - |
|
19774 |
const isAllowedEventInDisabledMode = e => contains$2(allowedEvents, e.type);
|
| - |
|
19775 |
const getAnchorHrefOpt = (editor, elm) => {
|
| - |
|
19776 |
const isRoot = elm => eq(elm, SugarElement.fromDom(editor.getBody()));
|
| - |
|
19777 |
return closest$3(elm, 'a', isRoot).bind(a => getOpt(a, 'href'));
|
| - |
|
19778 |
};
|
| - |
|
19779 |
const processDisabledEvents = (editor, e) => {
|
| - |
|
19780 |
if (isClickEvent(e) && !VK.metaKeyPressed(e)) {
|
| - |
|
19781 |
const elm = SugarElement.fromDom(e.target);
|
| - |
|
19782 |
getAnchorHrefOpt(editor, elm).each(href => {
|
| - |
|
19783 |
e.preventDefault();
|
| - |
|
19784 |
if (/^#/.test(href)) {
|
| - |
|
19785 |
const targetEl = editor.dom.select(`${ href },[name="${ removeLeading(href, '#') }"]`);
|
| - |
|
19786 |
if (targetEl.length) {
|
| - |
|
19787 |
editor.selection.scrollIntoView(targetEl[0], true);
|
| - |
|
19788 |
}
|
| - |
|
19789 |
} else {
|
| - |
|
19790 |
window.open(href, '_blank', 'rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');
|
| - |
|
19791 |
}
|
| - |
|
19792 |
});
|
| - |
|
19793 |
} else if (isAllowedEventInDisabledMode(e)) {
|
| - |
|
19794 |
editor.dispatch(e.type, e);
|
| - |
|
19795 |
}
|
| - |
|
19796 |
};
|
| - |
|
19797 |
const registerDisabledModeEventHandlers = editor => {
|
| - |
|
19798 |
editor.on('ShowCaret ObjectSelected', e => {
|
| - |
|
19799 |
if (isDisabled(editor)) {
|
| - |
|
19800 |
e.preventDefault();
|
| - |
|
19801 |
}
|
| - |
|
19802 |
});
|
| - |
|
19803 |
editor.on('DisabledStateChange', e => {
|
| - |
|
19804 |
if (!e.isDefaultPrevented()) {
|
| - |
|
19805 |
toggleDisabled(editor, e.state);
|
| - |
|
19806 |
}
|
| - |
|
19807 |
});
|
| - |
|
19808 |
};
|
| - |
|
19809 |
const registerEventsAndFilters$1 = editor => {
|
| - |
|
19810 |
registerDisabledContentFilters(editor);
|
| - |
|
19811 |
registerDisabledModeEventHandlers(editor);
|
| - |
|
19812 |
};
|
| 19555 |
|
19813 |
|
| 19556 |
const isContentCssSkinName = url => /^[a-z0-9\-]+$/i.test(url);
|
19814 |
const isContentCssSkinName = url => /^[a-z0-9\-]+$/i.test(url);
|
| 19557 |
const toContentSkinResourceName = url => 'content/' + url + '/content.css';
|
19815 |
const toContentSkinResourceName = url => 'content/' + url + '/content.css';
|
| 19558 |
const isBundledCssSkinName = url => tinymce.Resource.has(toContentSkinResourceName(url));
|
19816 |
const isBundledCssSkinName = url => tinymce.Resource.has(toContentSkinResourceName(url));
|
| 19559 |
const getContentCssUrls = editor => {
|
19817 |
const getContentCssUrls = editor => {
|
| Línea 19685... |
Línea 19943... |
| 19685 |
};
|
19943 |
};
|
| Línea 19686... |
Línea 19944... |
| 19686 |
|
19944 |
|
| 19687 |
let count = 0;
|
19945 |
let count = 0;
|
| 19688 |
const seed = () => {
|
19946 |
const seed = () => {
|
| 19689 |
const rnd = () => {
|
19947 |
const rnd = () => {
|
| 19690 |
return Math.round(Math.random() * 4294967295).toString(36);
|
19948 |
return Math.round(random() * 4294967295).toString(36);
|
| 19691 |
};
|
19949 |
};
|
| 19692 |
const now = new Date().getTime();
|
19950 |
const now = new Date().getTime();
|
| 19693 |
return 's' + now.toString(36) + rnd() + rnd() + rnd();
|
19951 |
return 's' + now.toString(36) + rnd() + rnd() + rnd();
|
| 19694 |
};
|
19952 |
};
|
| Línea 20004... |
Línea 20262... |
| 20004 |
});
|
20262 |
});
|
| 20005 |
if (imagesToRemove.length > 0 && !isRtc(editor)) {
|
20263 |
if (imagesToRemove.length > 0 && !isRtc(editor)) {
|
| 20006 |
editor.undoManager.transact(() => {
|
20264 |
editor.undoManager.transact(() => {
|
| 20007 |
each$e(fromDom$1(imagesToRemove), sugarElement => {
|
20265 |
each$e(fromDom$1(imagesToRemove), sugarElement => {
|
| 20008 |
const parentOpt = parent(sugarElement);
|
20266 |
const parentOpt = parent(sugarElement);
|
| 20009 |
remove$5(sugarElement);
|
20267 |
remove$4(sugarElement);
|
| 20010 |
parentOpt.each(addPaddingToEmpty(editor));
|
20268 |
parentOpt.each(addPaddingToEmpty(editor));
|
| 20011 |
blobCache.removeByUri(sugarElement.dom.src);
|
20269 |
blobCache.removeByUri(sugarElement.dom.src);
|
| 20012 |
});
|
20270 |
});
|
| 20013 |
});
|
20271 |
});
|
| 20014 |
} else if (shouldDispatchChange) {
|
20272 |
} else if (shouldDispatchChange) {
|
| Línea 20147... |
Línea 20405... |
| 20147 |
collapsed: false,
|
20405 |
collapsed: false,
|
| 20148 |
styles: { float: 'left' },
|
20406 |
styles: { float: 'left' },
|
| 20149 |
preview: 'font-family font-size'
|
20407 |
preview: 'font-family font-size'
|
| 20150 |
},
|
20408 |
},
|
| 20151 |
{
|
20409 |
{
|
| - |
|
20410 |
selector: '.mce-placeholder',
|
| - |
|
20411 |
styles: { float: 'left' },
|
| - |
|
20412 |
ceFalseOverride: true
|
| - |
|
20413 |
},
|
| - |
|
20414 |
{
|
| 20152 |
selector: 'table',
|
20415 |
selector: 'table',
|
| 20153 |
collapsed: false,
|
20416 |
collapsed: false,
|
| 20154 |
styles: {
|
20417 |
styles: {
|
| 20155 |
marginLeft: '0px',
|
20418 |
marginLeft: '0px',
|
| 20156 |
marginRight: 'auto'
|
20419 |
marginRight: 'auto'
|
| Línea 20189... |
Línea 20452... |
| 20189 |
marginRight: 'auto'
|
20452 |
marginRight: 'auto'
|
| 20190 |
},
|
20453 |
},
|
| 20191 |
preview: false
|
20454 |
preview: false
|
| 20192 |
},
|
20455 |
},
|
| 20193 |
{
|
20456 |
{
|
| - |
|
20457 |
selector: '.mce-placeholder',
|
| - |
|
20458 |
styles: {
|
| - |
|
20459 |
display: 'block',
|
| - |
|
20460 |
marginLeft: 'auto',
|
| - |
|
20461 |
marginRight: 'auto'
|
| - |
|
20462 |
},
|
| - |
|
20463 |
ceFalseOverride: true
|
| - |
|
20464 |
},
|
| - |
|
20465 |
{
|
| 20194 |
selector: 'table',
|
20466 |
selector: 'table',
|
| 20195 |
collapsed: false,
|
20467 |
collapsed: false,
|
| 20196 |
styles: {
|
20468 |
styles: {
|
| 20197 |
marginLeft: 'auto',
|
20469 |
marginLeft: 'auto',
|
| 20198 |
marginRight: 'auto'
|
20470 |
marginRight: 'auto'
|
| Línea 20238... |
Línea 20510... |
| 20238 |
collapsed: false,
|
20510 |
collapsed: false,
|
| 20239 |
styles: { float: 'right' },
|
20511 |
styles: { float: 'right' },
|
| 20240 |
preview: 'font-family font-size'
|
20512 |
preview: 'font-family font-size'
|
| 20241 |
},
|
20513 |
},
|
| 20242 |
{
|
20514 |
{
|
| - |
|
20515 |
selector: '.mce-placeholder',
|
| - |
|
20516 |
styles: { float: 'right' },
|
| - |
|
20517 |
ceFalseOverride: true
|
| - |
|
20518 |
},
|
| - |
|
20519 |
{
|
| 20243 |
selector: 'table',
|
20520 |
selector: 'table',
|
| 20244 |
collapsed: false,
|
20521 |
collapsed: false,
|
| 20245 |
styles: {
|
20522 |
styles: {
|
| 20246 |
marginRight: '0px',
|
20523 |
marginRight: '0px',
|
| 20247 |
marginLeft: 'auto'
|
20524 |
marginLeft: 'auto'
|
| Línea 20395... |
Línea 20672... |
| 20395 |
remove: 'all'
|
20672 |
remove: 'all'
|
| 20396 |
},
|
20673 |
},
|
| 20397 |
subscript: { inline: 'sub' },
|
20674 |
subscript: { inline: 'sub' },
|
| 20398 |
superscript: { inline: 'sup' },
|
20675 |
superscript: { inline: 'sup' },
|
| 20399 |
code: { inline: 'code' },
|
20676 |
code: { inline: 'code' },
|
| - |
|
20677 |
samp: { inline: 'samp' },
|
| 20400 |
link: {
|
20678 |
link: {
|
| 20401 |
inline: 'a',
|
20679 |
inline: 'a',
|
| 20402 |
selector: 'a',
|
20680 |
selector: 'a',
|
| 20403 |
remove: 'all',
|
20681 |
remove: 'all',
|
| 20404 |
split: true,
|
20682 |
split: true,
|
| Línea 20454... |
Línea 20732... |
| 20454 |
expand: false,
|
20732 |
expand: false,
|
| 20455 |
deep: true
|
20733 |
deep: true
|
| 20456 |
}
|
20734 |
}
|
| 20457 |
]
|
20735 |
]
|
| 20458 |
};
|
20736 |
};
|
| 20459 |
Tools.each('p h1 h2 h3 h4 h5 h6 div address pre dt dd samp'.split(/\s/), name => {
|
20737 |
Tools.each('p h1 h2 h3 h4 h5 h6 div address pre dt dd'.split(/\s/), name => {
|
| 20460 |
formats[name] = {
|
20738 |
formats[name] = {
|
| 20461 |
block: name,
|
20739 |
block: name,
|
| 20462 |
remove: 'all'
|
20740 |
remove: 'all'
|
| 20463 |
};
|
20741 |
};
|
| 20464 |
});
|
20742 |
});
|
| Línea 21038... |
Línea 21316... |
| 21038 |
return false;
|
21316 |
return false;
|
| 21039 |
}
|
21317 |
}
|
| 21040 |
};
|
21318 |
};
|
| 21041 |
const isTypingKeyboardEvent = e => isKeyboardEvent(e) && !(isDeleteEvent(e) || e.type === 'keyup' && e.keyCode === 229);
|
21319 |
const isTypingKeyboardEvent = e => isKeyboardEvent(e) && !(isDeleteEvent(e) || e.type === 'keyup' && e.keyCode === 229);
|
| 21042 |
const isVisuallyEmpty = (dom, rootElm, forcedRootBlock) => {
|
21320 |
const isVisuallyEmpty = (dom, rootElm, forcedRootBlock) => {
|
| 21043 |
if (isEmpty$2(SugarElement.fromDom(rootElm), false)) {
|
21321 |
if (dom.isEmpty(rootElm, undefined, {
|
| - |
|
21322 |
skipBogus: false,
|
| - |
|
21323 |
includeZwsp: true
|
| - |
|
21324 |
})) {
|
| 21044 |
const firstElement = rootElm.firstElementChild;
|
21325 |
const firstElement = rootElm.firstElementChild;
|
| 21045 |
if (!firstElement) {
|
21326 |
if (!firstElement) {
|
| 21046 |
return true;
|
21327 |
return true;
|
| 21047 |
} else if (dom.getStyle(rootElm.firstElementChild, 'padding-left') || dom.getStyle(rootElm.firstElementChild, 'padding-right')) {
|
21328 |
} else if (dom.getStyle(rootElm.firstElementChild, 'padding-left') || dom.getStyle(rootElm.firstElementChild, 'padding-right')) {
|
| 21048 |
return false;
|
21329 |
return false;
|
| Línea 21065... |
Línea 21346... |
| 21065 |
const body = editor.getBody();
|
21346 |
const body = editor.getBody();
|
| 21066 |
const showPlaceholder = isTypingKeyboardEvent(e) ? false : isVisuallyEmpty(dom, body, rootBlock);
|
21347 |
const showPlaceholder = isTypingKeyboardEvent(e) ? false : isVisuallyEmpty(dom, body, rootBlock);
|
| 21067 |
const isPlaceholderShown = dom.getAttrib(body, placeholderAttr) !== '';
|
21348 |
const isPlaceholderShown = dom.getAttrib(body, placeholderAttr) !== '';
|
| 21068 |
if (isPlaceholderShown !== showPlaceholder || initial) {
|
21349 |
if (isPlaceholderShown !== showPlaceholder || initial) {
|
| 21069 |
dom.setAttrib(body, placeholderAttr, showPlaceholder ? placeholder : null);
|
21350 |
dom.setAttrib(body, placeholderAttr, showPlaceholder ? placeholder : null);
|
| 21070 |
dom.setAttrib(body, 'aria-placeholder', showPlaceholder ? placeholder : null);
|
- |
|
| 21071 |
firePlaceholderToggle(editor, showPlaceholder);
|
21351 |
firePlaceholderToggle(editor, showPlaceholder);
|
| 21072 |
editor.on(showPlaceholder ? 'keydown' : 'keyup', updatePlaceholder);
|
21352 |
editor.on(showPlaceholder ? 'keydown' : 'keyup', updatePlaceholder);
|
| 21073 |
editor.off(showPlaceholder ? 'keyup' : 'keydown', updatePlaceholder);
|
21353 |
editor.off(showPlaceholder ? 'keyup' : 'keydown', updatePlaceholder);
|
| 21074 |
}
|
21354 |
}
|
| 21075 |
};
|
21355 |
};
|
| Línea 21093... |
Línea 21373... |
| 21093 |
const getBlockPosition = (rootNode, pos) => {
|
21373 |
const getBlockPosition = (rootNode, pos) => {
|
| 21094 |
const rootElm = SugarElement.fromDom(rootNode);
|
21374 |
const rootElm = SugarElement.fromDom(rootNode);
|
| 21095 |
const containerElm = SugarElement.fromDom(pos.container());
|
21375 |
const containerElm = SugarElement.fromDom(pos.container());
|
| 21096 |
return getParentBlock$2(rootElm, containerElm).map(block => blockPosition(block, pos));
|
21376 |
return getParentBlock$2(rootElm, containerElm).map(block => blockPosition(block, pos));
|
| 21097 |
};
|
21377 |
};
|
| - |
|
21378 |
const isNotAncestorial = blockBoundary => !(contains(blockBoundary.to.block, blockBoundary.from.block) || contains(blockBoundary.from.block, blockBoundary.to.block));
|
| 21098 |
const isDifferentBlocks = blockBoundary => !eq(blockBoundary.from.block, blockBoundary.to.block);
|
21379 |
const isDifferentBlocks = blockBoundary => !eq(blockBoundary.from.block, blockBoundary.to.block);
|
| 21099 |
const getClosestHost = (root, scope) => {
|
21380 |
const getClosestHost = (root, scope) => {
|
| 21100 |
const isRoot = node => eq(node, root);
|
21381 |
const isRoot = node => eq(node, root);
|
| 21101 |
const isHost = node => isTableCell$2(node) || isContentEditableTrue$3(node.dom);
|
21382 |
const isHost = node => isTableCell$2(node) || isContentEditableTrue$3(node.dom);
|
| 21102 |
return closest$4(scope, isHost, isRoot).filter(isElement$7).getOr(root);
|
21383 |
return closest$4(scope, isHost, isRoot).filter(isElement$7).getOr(root);
|
| Línea 21105... |
Línea 21386... |
| 21105 |
const root = SugarElement.fromDom(rootNode);
|
21386 |
const root = SugarElement.fromDom(rootNode);
|
| 21106 |
return eq(getClosestHost(root, blockBoundary.from.block), getClosestHost(root, blockBoundary.to.block));
|
21387 |
return eq(getClosestHost(root, blockBoundary.from.block), getClosestHost(root, blockBoundary.to.block));
|
| 21107 |
};
|
21388 |
};
|
| 21108 |
const isEditable$1 = blockBoundary => isContentEditableFalse$b(blockBoundary.from.block.dom) === false && isContentEditableFalse$b(blockBoundary.to.block.dom) === false;
|
21389 |
const isEditable$1 = blockBoundary => isContentEditableFalse$b(blockBoundary.from.block.dom) === false && isContentEditableFalse$b(blockBoundary.to.block.dom) === false;
|
| 21109 |
const hasValidBlocks = blockBoundary => {
|
21390 |
const hasValidBlocks = blockBoundary => {
|
| 21110 |
const isValidBlock = block => isTextBlock$2(block) || hasBlockAttr(block.dom);
|
21391 |
const isValidBlock = block => isTextBlock$2(block) || hasBlockAttr(block.dom) || isListItem$1(block);
|
| 21111 |
return isValidBlock(blockBoundary.from.block) && isValidBlock(blockBoundary.to.block);
|
21392 |
return isValidBlock(blockBoundary.from.block) && isValidBlock(blockBoundary.to.block);
|
| 21112 |
};
|
21393 |
};
|
| 21113 |
const skipLastBr = (rootNode, forward, blockPosition) => {
|
21394 |
const skipLastBr = (schema, rootNode, forward, blockPosition) => {
|
| 21114 |
if (isBr$6(blockPosition.position.getNode()) && !isEmpty$2(blockPosition.block)) {
|
21395 |
if (isBr$6(blockPosition.position.getNode()) && !isEmpty$2(schema, blockPosition.block)) {
|
| 21115 |
return positionIn(false, blockPosition.block.dom).bind(lastPositionInBlock => {
|
21396 |
return positionIn(false, blockPosition.block.dom).bind(lastPositionInBlock => {
|
| 21116 |
if (lastPositionInBlock.isEqual(blockPosition.position)) {
|
21397 |
if (lastPositionInBlock.isEqual(blockPosition.position)) {
|
| 21117 |
return fromPosition(forward, rootNode, lastPositionInBlock).bind(to => getBlockPosition(rootNode, to));
|
21398 |
return fromPosition(forward, rootNode, lastPositionInBlock).bind(to => getBlockPosition(rootNode, to));
|
| 21118 |
} else {
|
21399 |
} else {
|
| 21119 |
return Optional.some(blockPosition);
|
21400 |
return Optional.some(blockPosition);
|
| Línea 21121... |
Línea 21402... |
| 21121 |
}).getOr(blockPosition);
|
21402 |
}).getOr(blockPosition);
|
| 21122 |
} else {
|
21403 |
} else {
|
| 21123 |
return blockPosition;
|
21404 |
return blockPosition;
|
| 21124 |
}
|
21405 |
}
|
| 21125 |
};
|
21406 |
};
|
| 21126 |
const readFromRange = (rootNode, forward, rng) => {
|
21407 |
const readFromRange = (schema, rootNode, forward, rng) => {
|
| 21127 |
const fromBlockPos = getBlockPosition(rootNode, CaretPosition.fromRangeStart(rng));
|
21408 |
const fromBlockPos = getBlockPosition(rootNode, CaretPosition.fromRangeStart(rng));
|
| 21128 |
const toBlockPos = fromBlockPos.bind(blockPos => fromPosition(forward, rootNode, blockPos.position).bind(to => getBlockPosition(rootNode, to).map(blockPos => skipLastBr(rootNode, forward, blockPos))));
|
21409 |
const toBlockPos = fromBlockPos.bind(blockPos => fromPosition(forward, rootNode, blockPos.position).bind(to => getBlockPosition(rootNode, to).map(blockPos => skipLastBr(schema, rootNode, forward, blockPos))));
|
| 21129 |
return lift2(fromBlockPos, toBlockPos, blockBoundary).filter(blockBoundary => isDifferentBlocks(blockBoundary) && hasSameHost(rootNode, blockBoundary) && isEditable$1(blockBoundary) && hasValidBlocks(blockBoundary));
|
21410 |
return lift2(fromBlockPos, toBlockPos, blockBoundary).filter(blockBoundary => isDifferentBlocks(blockBoundary) && hasSameHost(rootNode, blockBoundary) && isEditable$1(blockBoundary) && hasValidBlocks(blockBoundary) && isNotAncestorial(blockBoundary));
|
| 21130 |
};
|
21411 |
};
|
| 21131 |
const read$1 = (rootNode, forward, rng) => rng.collapsed ? readFromRange(rootNode, forward, rng) : Optional.none();
|
21412 |
const read$1 = (schema, rootNode, forward, rng) => rng.collapsed ? readFromRange(schema, rootNode, forward, rng) : Optional.none();
|
| Línea 21132... |
Línea 21413... |
| 21132 |
|
21413 |
|
| 21133 |
const getChildrenUntilBlockBoundary = (block, schema) => {
|
21414 |
const getChildrenUntilBlockBoundary = (block, schema) => {
|
| 21134 |
const children = children$1(block);
|
21415 |
const children = children$1(block);
|
| 21135 |
return findIndex$2(children, el => schema.isBlock(name(el))).fold(constant(children), index => children.slice(0, index));
|
21416 |
return findIndex$2(children, el => schema.isBlock(name(el))).fold(constant(children), index => children.slice(0, index));
|
| 21136 |
};
|
21417 |
};
|
| 21137 |
const extractChildren = (block, schema) => {
|
21418 |
const extractChildren = (block, schema) => {
|
| 21138 |
const children = getChildrenUntilBlockBoundary(block, schema);
|
21419 |
const children = getChildrenUntilBlockBoundary(block, schema);
|
| 21139 |
each$e(children, remove$5);
|
21420 |
each$e(children, remove$4);
|
| 21140 |
return children;
|
21421 |
return children;
|
| 21141 |
};
|
21422 |
};
|
| 21142 |
const removeEmptyRoot = (rootNode, block) => {
|
21423 |
const removeEmptyRoot = (schema, rootNode, block) => {
|
| 21143 |
const parents = parentsAndSelf(block, rootNode);
|
21424 |
const parents = parentsAndSelf(block, rootNode);
|
| 21144 |
return find$2(parents.reverse(), element => isEmpty$2(element)).each(remove$5);
|
21425 |
return find$2(parents.reverse(), element => isEmpty$2(schema, element)).each(remove$4);
|
| 21145 |
};
|
21426 |
};
|
| 21146 |
const isEmptyBefore = el => filter$5(prevSiblings(el), el => !isEmpty$2(el)).length === 0;
|
21427 |
const isEmptyBefore = (schema, el) => filter$5(prevSiblings(el), el => !isEmpty$2(schema, el)).length === 0;
|
| 21147 |
const nestedBlockMerge = (rootNode, fromBlock, toBlock, schema, insertionPoint) => {
|
21428 |
const nestedBlockMerge = (rootNode, fromBlock, toBlock, schema, insertionPoint) => {
|
| 21148 |
if (isEmpty$2(toBlock)) {
|
21429 |
if (isEmpty$2(schema, toBlock)) {
|
| 21149 |
fillWithPaddingBr(toBlock);
|
21430 |
fillWithPaddingBr(toBlock);
|
| 21150 |
return firstPositionIn(toBlock.dom);
|
21431 |
return firstPositionIn(toBlock.dom);
|
| 21151 |
}
|
21432 |
}
|
| 21152 |
if (isEmptyBefore(insertionPoint) && isEmpty$2(fromBlock)) {
|
21433 |
if (isEmptyBefore(schema, insertionPoint) && isEmpty$2(schema, fromBlock)) {
|
| 21153 |
before$3(insertionPoint, SugarElement.fromTag('br'));
|
21434 |
before$3(insertionPoint, SugarElement.fromTag('br'));
|
| 21154 |
}
|
21435 |
}
|
| 21155 |
const position = prevPosition(toBlock.dom, CaretPosition.before(insertionPoint.dom));
|
21436 |
const position = prevPosition(toBlock.dom, CaretPosition.before(insertionPoint.dom));
|
| 21156 |
each$e(extractChildren(fromBlock, schema), child => {
|
21437 |
each$e(extractChildren(fromBlock, schema), child => {
|
| 21157 |
before$3(insertionPoint, child);
|
21438 |
before$3(insertionPoint, child);
|
| 21158 |
});
|
21439 |
});
|
| 21159 |
removeEmptyRoot(rootNode, fromBlock);
|
21440 |
removeEmptyRoot(schema, rootNode, fromBlock);
|
| 21160 |
return position;
|
21441 |
return position;
|
| 21161 |
};
|
21442 |
};
|
| 21162 |
const isInline = (schema, node) => schema.isInline(name(node));
|
21443 |
const isInline = (schema, node) => schema.isInline(name(node));
|
| 21163 |
const sidelongBlockMerge = (rootNode, fromBlock, toBlock, schema) => {
|
21444 |
const sidelongBlockMerge = (rootNode, fromBlock, toBlock, schema) => {
|
| 21164 |
if (isEmpty$2(toBlock)) {
|
21445 |
if (isEmpty$2(schema, toBlock)) {
|
| 21165 |
if (isEmpty$2(fromBlock)) {
|
21446 |
if (isEmpty$2(schema, fromBlock)) {
|
| 21166 |
const getInlineToBlockDescendants = el => {
|
21447 |
const getInlineToBlockDescendants = el => {
|
| 21167 |
const helper = (node, elements) => firstChild(node).fold(() => elements, child => isInline(schema, child) ? helper(child, elements.concat(shallow$1(child))) : elements);
|
21448 |
const helper = (node, elements) => firstChild(node).fold(() => elements, child => isInline(schema, child) ? helper(child, elements.concat(shallow$1(child))) : elements);
|
| 21168 |
return helper(el, []);
|
21449 |
return helper(el, []);
|
| 21169 |
};
|
21450 |
};
|
| Línea 21172... |
Línea 21453... |
| 21172 |
return descendant;
|
21453 |
return descendant;
|
| 21173 |
}, createPaddingBr());
|
21454 |
}, createPaddingBr());
|
| 21174 |
empty(fromBlock);
|
21455 |
empty(fromBlock);
|
| 21175 |
append$1(fromBlock, newFromBlockDescendants);
|
21456 |
append$1(fromBlock, newFromBlockDescendants);
|
| 21176 |
}
|
21457 |
}
|
| 21177 |
remove$5(toBlock);
|
21458 |
remove$4(toBlock);
|
| 21178 |
return firstPositionIn(fromBlock.dom);
|
21459 |
return firstPositionIn(fromBlock.dom);
|
| 21179 |
}
|
21460 |
}
|
| 21180 |
const position = lastPositionIn(toBlock.dom);
|
21461 |
const position = lastPositionIn(toBlock.dom);
|
| 21181 |
each$e(extractChildren(fromBlock, schema), child => {
|
21462 |
each$e(extractChildren(fromBlock, schema), child => {
|
| 21182 |
append$1(toBlock, child);
|
21463 |
append$1(toBlock, child);
|
| 21183 |
});
|
21464 |
});
|
| 21184 |
removeEmptyRoot(rootNode, fromBlock);
|
21465 |
removeEmptyRoot(schema, rootNode, fromBlock);
|
| 21185 |
return position;
|
21466 |
return position;
|
| 21186 |
};
|
21467 |
};
|
| 21187 |
const findInsertionPoint = (toBlock, block) => {
|
21468 |
const findInsertionPoint = (toBlock, block) => {
|
| 21188 |
const parentsAndSelf$1 = parentsAndSelf(block, toBlock);
|
21469 |
const parentsAndSelf$1 = parentsAndSelf(block, toBlock);
|
| 21189 |
return Optional.from(parentsAndSelf$1[parentsAndSelf$1.length - 1]);
|
21470 |
return Optional.from(parentsAndSelf$1[parentsAndSelf$1.length - 1]);
|
| 21190 |
};
|
21471 |
};
|
| 21191 |
const getInsertionPoint = (fromBlock, toBlock) => contains(toBlock, fromBlock) ? findInsertionPoint(toBlock, fromBlock) : Optional.none();
|
21472 |
const getInsertionPoint = (fromBlock, toBlock) => contains(toBlock, fromBlock) ? findInsertionPoint(toBlock, fromBlock) : Optional.none();
|
| 21192 |
const trimBr = (first, block) => {
|
21473 |
const trimBr = (first, block) => {
|
| 21193 |
positionIn(first, block.dom).bind(position => Optional.from(position.getNode())).map(SugarElement.fromDom).filter(isBr$5).each(remove$5);
|
21474 |
positionIn(first, block.dom).bind(position => Optional.from(position.getNode())).map(SugarElement.fromDom).filter(isBr$5).each(remove$4);
|
| 21194 |
};
|
21475 |
};
|
| 21195 |
const mergeBlockInto = (rootNode, fromBlock, toBlock, schema) => {
|
21476 |
const mergeBlockInto = (rootNode, fromBlock, toBlock, schema) => {
|
| 21196 |
trimBr(true, fromBlock);
|
21477 |
trimBr(true, fromBlock);
|
| 21197 |
trimBr(false, toBlock);
|
21478 |
trimBr(false, toBlock);
|
| 21198 |
return getInsertionPoint(fromBlock, toBlock).fold(curry(sidelongBlockMerge, rootNode, fromBlock, toBlock, schema), curry(nestedBlockMerge, rootNode, fromBlock, toBlock, schema));
|
21479 |
return getInsertionPoint(fromBlock, toBlock).fold(curry(sidelongBlockMerge, rootNode, fromBlock, toBlock, schema), curry(nestedBlockMerge, rootNode, fromBlock, toBlock, schema));
|
| 21199 |
};
|
21480 |
};
|
| 21200 |
const mergeBlocks = (rootNode, forward, block1, block2, schema) => forward ? mergeBlockInto(rootNode, block2, block1, schema) : mergeBlockInto(rootNode, block1, block2, schema);
|
21481 |
const mergeBlocks = (rootNode, forward, block1, block2, schema) => forward ? mergeBlockInto(rootNode, block2, block1, schema) : mergeBlockInto(rootNode, block1, block2, schema);
|
| Línea 21201... |
Línea 21482... |
| 21201 |
|
21482 |
|
| 21202 |
const backspaceDelete$9 = (editor, forward) => {
|
21483 |
const backspaceDelete$a = (editor, forward) => {
|
| 21203 |
const rootNode = SugarElement.fromDom(editor.getBody());
|
21484 |
const rootNode = SugarElement.fromDom(editor.getBody());
|
| 21204 |
const position = read$1(rootNode.dom, forward, editor.selection.getRng()).map(blockBoundary => () => {
|
21485 |
const position = read$1(editor.schema, rootNode.dom, forward, editor.selection.getRng()).map(blockBoundary => () => {
|
| 21205 |
mergeBlocks(rootNode, forward, blockBoundary.from.block, blockBoundary.to.block, editor.schema).each(pos => {
|
21486 |
mergeBlocks(rootNode, forward, blockBoundary.from.block, blockBoundary.to.block, editor.schema).each(pos => {
|
| 21206 |
editor.selection.setRng(pos.toRange());
|
21487 |
editor.selection.setRng(pos.toRange());
|
| 21207 |
});
|
21488 |
});
|
| 21208 |
});
|
21489 |
});
|
| Línea 21244... |
Línea 21525... |
| 21244 |
const deleteRange$2 = editor => {
|
21525 |
const deleteRange$2 = editor => {
|
| 21245 |
const rootNode = SugarElement.fromDom(editor.getBody());
|
21526 |
const rootNode = SugarElement.fromDom(editor.getBody());
|
| 21246 |
const rng = editor.selection.getRng();
|
21527 |
const rng = editor.selection.getRng();
|
| 21247 |
return isEverythingSelected(rootNode, rng) ? emptyEditor(editor) : deleteRangeMergeBlocks(rootNode, editor.selection, editor.schema);
|
21528 |
return isEverythingSelected(rootNode, rng) ? emptyEditor(editor) : deleteRangeMergeBlocks(rootNode, editor.selection, editor.schema);
|
| 21248 |
};
|
21529 |
};
|
| 21249 |
const backspaceDelete$8 = (editor, _forward) => editor.selection.isCollapsed() ? Optional.none() : deleteRange$2(editor);
|
21530 |
const backspaceDelete$9 = (editor, _forward) => editor.selection.isCollapsed() ? Optional.none() : deleteRange$2(editor);
|
| Línea 21250... |
Línea 21531... |
| 21250 |
|
21531 |
|
| 21251 |
const showCaret = (direction, editor, node, before, scrollIntoView) => Optional.from(editor._selectionOverrides.showCaret(direction, node, before, scrollIntoView));
|
21532 |
const showCaret = (direction, editor, node, before, scrollIntoView) => Optional.from(editor._selectionOverrides.showCaret(direction, node, before, scrollIntoView));
|
| 21252 |
const getNodeRange = node => {
|
21533 |
const getNodeRange = node => {
|
| 21253 |
const rng = node.ownerDocument.createRange();
|
21534 |
const rng = node.ownerDocument.createRange();
|
| Línea 21281... |
Línea 21562... |
| 21281 |
const renderRangeCaret = (editor, range, scrollIntoView) => range.collapsed ? renderCaretAtRange(editor, range, scrollIntoView).getOr(range) : range;
|
21562 |
const renderRangeCaret = (editor, range, scrollIntoView) => range.collapsed ? renderCaretAtRange(editor, range, scrollIntoView).getOr(range) : range;
|
| Línea 21282... |
Línea 21563... |
| 21282 |
|
21563 |
|
| 21283 |
const isBeforeBoundary = pos => isBeforeContentEditableFalse(pos) || isBeforeMedia(pos);
|
21564 |
const isBeforeBoundary = pos => isBeforeContentEditableFalse(pos) || isBeforeMedia(pos);
|
| 21284 |
const isAfterBoundary = pos => isAfterContentEditableFalse(pos) || isAfterMedia(pos);
|
21565 |
const isAfterBoundary = pos => isAfterContentEditableFalse(pos) || isAfterMedia(pos);
|
| 21285 |
const trimEmptyTextNode = (dom, node) => {
|
21566 |
const trimEmptyTextNode = (dom, node) => {
|
| 21286 |
if (isText$a(node) && node.data.length === 0) {
|
21567 |
if (isText$b(node) && node.data.length === 0) {
|
| 21287 |
dom.remove(node);
|
21568 |
dom.remove(node);
|
| 21288 |
}
|
21569 |
}
|
| 21289 |
};
|
21570 |
};
|
| 21290 |
const deleteContentAndShowCaret = (editor, range, node, direction, forward, peekCaretPosition) => {
|
21571 |
const deleteContentAndShowCaret = (editor, range, node, direction, forward, peekCaretPosition) => {
|
| Línea 21304... |
Línea 21585... |
| 21304 |
});
|
21585 |
});
|
| 21305 |
trimEmptyTextNode(editor.dom, node);
|
21586 |
trimEmptyTextNode(editor.dom, node);
|
| 21306 |
};
|
21587 |
};
|
| 21307 |
const deleteBoundaryText = (editor, forward) => {
|
21588 |
const deleteBoundaryText = (editor, forward) => {
|
| 21308 |
const range = editor.selection.getRng();
|
21589 |
const range = editor.selection.getRng();
|
| 21309 |
if (!isText$a(range.commonAncestorContainer)) {
|
21590 |
if (!isText$b(range.commonAncestorContainer)) {
|
| 21310 |
return Optional.none();
|
21591 |
return Optional.none();
|
| 21311 |
}
|
21592 |
}
|
| 21312 |
const direction = forward ? HDirection.Forwards : HDirection.Backwards;
|
21593 |
const direction = forward ? 1 : -1;
|
| 21313 |
const caretWalker = CaretWalker(editor.getBody());
|
21594 |
const caretWalker = CaretWalker(editor.getBody());
|
| 21314 |
const getNextPosFn = curry(getVisualCaretPosition, forward ? caretWalker.next : caretWalker.prev);
|
21595 |
const getNextPosFn = curry(getVisualCaretPosition, forward ? caretWalker.next : caretWalker.prev);
|
| 21315 |
const isBeforeFn = forward ? isBeforeBoundary : isAfterBoundary;
|
21596 |
const isBeforeFn = forward ? isBeforeBoundary : isAfterBoundary;
|
| 21316 |
const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);
|
21597 |
const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);
|
| 21317 |
const nextCaretPosition = getNextPosFn(caretPosition);
|
21598 |
const nextCaretPosition = getNextPosFn(caretPosition);
|
| Línea 21327... |
Línea 21608... |
| 21327 |
return Optional.some(() => deleteContentAndShowCaret(editor, range, caretPosition.getNode(), direction, forward, peekCaretPosition));
|
21608 |
return Optional.some(() => deleteContentAndShowCaret(editor, range, caretPosition.getNode(), direction, forward, peekCaretPosition));
|
| 21328 |
}
|
21609 |
}
|
| 21329 |
}
|
21610 |
}
|
| 21330 |
return Optional.none();
|
21611 |
return Optional.none();
|
| 21331 |
};
|
21612 |
};
|
| 21332 |
const backspaceDelete$7 = (editor, forward) => deleteBoundaryText(editor, forward);
|
21613 |
const backspaceDelete$8 = (editor, forward) => deleteBoundaryText(editor, forward);
|
| Línea 21333... |
Línea 21614... |
| 21333 |
|
21614 |
|
| 21334 |
const getEdgeCefPosition = (editor, atStart) => {
|
21615 |
const getEdgeCefPosition = (editor, atStart) => {
|
| 21335 |
const root = editor.getBody();
|
21616 |
const root = editor.getBody();
|
| 21336 |
return atStart ? firstPositionIn(root).filter(isBeforeContentEditableFalse) : lastPositionIn(root).filter(isAfterContentEditableFalse);
|
21617 |
return atStart ? firstPositionIn(root).filter(isBeforeContentEditableFalse) : lastPositionIn(root).filter(isAfterContentEditableFalse);
|
| Línea 21353... |
Línea 21634... |
| 21353 |
};
|
21634 |
};
|
| 21354 |
const isDeleteFromCefDifferentBlocks = (root, forward, from, to, schema) => {
|
21635 |
const isDeleteFromCefDifferentBlocks = (root, forward, from, to, schema) => {
|
| 21355 |
const inSameBlock = elm => schema.isInline(elm.nodeName.toLowerCase()) && !isInSameBlock(from, to, root);
|
21636 |
const inSameBlock = elm => schema.isInline(elm.nodeName.toLowerCase()) && !isInSameBlock(from, to, root);
|
| 21356 |
return getRelativeCefElm(!forward, from).fold(() => getRelativeCefElm(forward, to).fold(never, inSameBlock), inSameBlock);
|
21637 |
return getRelativeCefElm(!forward, from).fold(() => getRelativeCefElm(forward, to).fold(never, inSameBlock), inSameBlock);
|
| 21357 |
};
|
21638 |
};
|
| 21358 |
const deleteEmptyBlockOrMoveToCef = (root, forward, from, to) => {
|
21639 |
const deleteEmptyBlockOrMoveToCef = (schema, root, forward, from, to) => {
|
| 21359 |
const toCefElm = to.getNode(!forward);
|
21640 |
const toCefElm = to.getNode(!forward);
|
| 21360 |
return getParentBlock$2(SugarElement.fromDom(root), SugarElement.fromDom(from.getNode())).map(blockElm => isEmpty$2(blockElm) ? DeleteAction.remove(blockElm.dom) : DeleteAction.moveToElement(toCefElm)).orThunk(() => Optional.some(DeleteAction.moveToElement(toCefElm)));
|
21641 |
return getParentBlock$2(SugarElement.fromDom(root), SugarElement.fromDom(from.getNode())).map(blockElm => isEmpty$2(schema, blockElm) ? DeleteAction.remove(blockElm.dom) : DeleteAction.moveToElement(toCefElm)).orThunk(() => Optional.some(DeleteAction.moveToElement(toCefElm)));
|
| 21361 |
};
|
21642 |
};
|
| 21362 |
const findCefPosition = (root, forward, from, schema) => fromPosition(forward, root, from).bind(to => {
|
21643 |
const findCefPosition = (root, forward, from, schema) => fromPosition(forward, root, from).bind(to => {
|
| 21363 |
if (isCompoundElement(to.getNode())) {
|
21644 |
if (isCompoundElement(to.getNode())) {
|
| 21364 |
return Optional.none();
|
21645 |
return Optional.none();
|
| 21365 |
} else if (isDeleteFromCefDifferentBlocks(root, forward, from, to, schema)) {
|
21646 |
} else if (isDeleteFromCefDifferentBlocks(root, forward, from, to, schema)) {
|
| 21366 |
return Optional.none();
|
21647 |
return Optional.none();
|
| 21367 |
} else if (forward && isContentEditableFalse$b(to.getNode())) {
|
21648 |
} else if (forward && isContentEditableFalse$b(to.getNode())) {
|
| 21368 |
return deleteEmptyBlockOrMoveToCef(root, forward, from, to);
|
21649 |
return deleteEmptyBlockOrMoveToCef(schema, root, forward, from, to);
|
| 21369 |
} else if (!forward && isContentEditableFalse$b(to.getNode(true))) {
|
21650 |
} else if (!forward && isContentEditableFalse$b(to.getNode(true))) {
|
| 21370 |
return deleteEmptyBlockOrMoveToCef(root, forward, from, to);
|
21651 |
return deleteEmptyBlockOrMoveToCef(schema, root, forward, from, to);
|
| 21371 |
} else if (forward && isAfterContentEditableFalse(from)) {
|
21652 |
} else if (forward && isAfterContentEditableFalse(from)) {
|
| 21372 |
return Optional.some(DeleteAction.moveToPosition(to));
|
21653 |
return Optional.some(DeleteAction.moveToPosition(to));
|
| 21373 |
} else if (!forward && isBeforeContentEditableFalse(from)) {
|
21654 |
} else if (!forward && isBeforeContentEditableFalse(from)) {
|
| 21374 |
return Optional.some(DeleteAction.moveToPosition(to));
|
21655 |
return Optional.some(DeleteAction.moveToPosition(to));
|
| 21375 |
} else {
|
21656 |
} else {
|
| Línea 21436... |
Línea 21717... |
| 21436 |
const backspaceDeleteCaret = (editor, forward) => {
|
21717 |
const backspaceDeleteCaret = (editor, forward) => {
|
| 21437 |
const selectedNode = editor.selection.getNode();
|
21718 |
const selectedNode = editor.selection.getNode();
|
| 21438 |
return getAncestorCe(editor, selectedNode).filter(isContentEditableFalse$b).fold(() => read(editor.getBody(), forward, editor.selection.getRng(), editor.schema).map(deleteAction => () => deleteAction.fold(deleteElement$1(editor, forward), moveToElement(editor, forward), moveToPosition(editor))), () => Optional.some(noop));
|
21719 |
return getAncestorCe(editor, selectedNode).filter(isContentEditableFalse$b).fold(() => read(editor.getBody(), forward, editor.selection.getRng(), editor.schema).map(deleteAction => () => deleteAction.fold(deleteElement$1(editor, forward), moveToElement(editor, forward), moveToPosition(editor))), () => Optional.some(noop));
|
| 21439 |
};
|
21720 |
};
|
| 21440 |
const deleteOffscreenSelection = rootElement => {
|
21721 |
const deleteOffscreenSelection = rootElement => {
|
| 21441 |
each$e(descendants(rootElement, '.mce-offscreen-selection'), remove$5);
|
21722 |
each$e(descendants(rootElement, '.mce-offscreen-selection'), remove$4);
|
| 21442 |
};
|
21723 |
};
|
| 21443 |
const backspaceDeleteRange = (editor, forward) => {
|
21724 |
const backspaceDeleteRange = (editor, forward) => {
|
| 21444 |
const selectedNode = editor.selection.getNode();
|
21725 |
const selectedNode = editor.selection.getNode();
|
| 21445 |
if (isContentEditableFalse$b(selectedNode) && !isTableCell$3(selectedNode)) {
|
21726 |
if (isContentEditableFalse$b(selectedNode) && !isTableCell$3(selectedNode)) {
|
| 21446 |
const hasCefAncestor = getAncestorCe(editor, selectedNode.parentNode).filter(isContentEditableFalse$b);
|
21727 |
const hasCefAncestor = getAncestorCe(editor, selectedNode.parentNode).filter(isContentEditableFalse$b);
|
| Línea 21466... |
Línea 21747... |
| 21466 |
ceRoot.appendChild(br);
|
21747 |
ceRoot.appendChild(br);
|
| 21467 |
selection.setRng(CaretPosition.before(br).toRange());
|
21748 |
selection.setRng(CaretPosition.before(br).toRange());
|
| 21468 |
}
|
21749 |
}
|
| 21469 |
return true;
|
21750 |
return true;
|
| 21470 |
};
|
21751 |
};
|
| 21471 |
const backspaceDelete$6 = (editor, forward) => {
|
21752 |
const backspaceDelete$7 = (editor, forward) => {
|
| 21472 |
if (editor.selection.isCollapsed()) {
|
21753 |
if (editor.selection.isCollapsed()) {
|
| 21473 |
return backspaceDeleteCaret(editor, forward);
|
21754 |
return backspaceDeleteCaret(editor, forward);
|
| 21474 |
} else {
|
21755 |
} else {
|
| 21475 |
return backspaceDeleteRange(editor, forward);
|
21756 |
return backspaceDeleteRange(editor, forward);
|
| 21476 |
}
|
21757 |
}
|
| 21477 |
};
|
21758 |
};
|
| Línea -... |
Línea 21759... |
| - |
|
21759 |
|
| - |
|
21760 |
const isTextEndpoint = endpoint => endpoint.hasOwnProperty('text');
|
| - |
|
21761 |
const isElementEndpoint = endpoint => endpoint.hasOwnProperty('marker');
|
| - |
|
21762 |
const getBookmark = (range, createMarker) => {
|
| - |
|
21763 |
const getEndpoint = (container, offset) => {
|
| - |
|
21764 |
if (isText$b(container)) {
|
| - |
|
21765 |
return {
|
| - |
|
21766 |
text: container,
|
| - |
|
21767 |
offset
|
| - |
|
21768 |
};
|
| - |
|
21769 |
} else {
|
| - |
|
21770 |
const marker = createMarker();
|
| - |
|
21771 |
const children = container.childNodes;
|
| - |
|
21772 |
if (offset < children.length) {
|
| - |
|
21773 |
container.insertBefore(marker, children[offset]);
|
| - |
|
21774 |
return {
|
| - |
|
21775 |
marker,
|
| - |
|
21776 |
before: true
|
| - |
|
21777 |
};
|
| - |
|
21778 |
} else {
|
| - |
|
21779 |
container.appendChild(marker);
|
| - |
|
21780 |
return {
|
| - |
|
21781 |
marker,
|
| - |
|
21782 |
before: false
|
| - |
|
21783 |
};
|
| - |
|
21784 |
}
|
| - |
|
21785 |
}
|
| - |
|
21786 |
};
|
| - |
|
21787 |
const end = getEndpoint(range.endContainer, range.endOffset);
|
| - |
|
21788 |
const start = getEndpoint(range.startContainer, range.startOffset);
|
| - |
|
21789 |
return {
|
| - |
|
21790 |
start,
|
| - |
|
21791 |
end
|
| - |
|
21792 |
};
|
| - |
|
21793 |
};
|
| - |
|
21794 |
const resolveBookmark = bm => {
|
| - |
|
21795 |
var _a, _b;
|
| - |
|
21796 |
const {start, end} = bm;
|
| - |
|
21797 |
const rng = new window.Range();
|
| - |
|
21798 |
if (isTextEndpoint(start)) {
|
| - |
|
21799 |
rng.setStart(start.text, start.offset);
|
| - |
|
21800 |
} else {
|
| - |
|
21801 |
if (isElementEndpoint(start)) {
|
| - |
|
21802 |
if (start.before) {
|
| - |
|
21803 |
rng.setStartBefore(start.marker);
|
| - |
|
21804 |
} else {
|
| - |
|
21805 |
rng.setStartAfter(start.marker);
|
| - |
|
21806 |
}
|
| - |
|
21807 |
(_a = start.marker.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(start.marker);
|
| - |
|
21808 |
}
|
| - |
|
21809 |
}
|
| - |
|
21810 |
if (isTextEndpoint(end)) {
|
| - |
|
21811 |
rng.setEnd(end.text, end.offset);
|
| - |
|
21812 |
} else {
|
| - |
|
21813 |
if (isElementEndpoint(end)) {
|
| - |
|
21814 |
if (end.before) {
|
| - |
|
21815 |
rng.setEndBefore(end.marker);
|
| - |
|
21816 |
} else {
|
| - |
|
21817 |
rng.setEndAfter(end.marker);
|
| - |
|
21818 |
}
|
| - |
|
21819 |
(_b = end.marker.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(end.marker);
|
| - |
|
21820 |
}
|
| - |
|
21821 |
}
|
| - |
|
21822 |
return rng;
|
| - |
|
21823 |
};
|
| - |
|
21824 |
|
| - |
|
21825 |
const backspaceDelete$6 = (editor, forward) => {
|
| - |
|
21826 |
var _a;
|
| - |
|
21827 |
const dom = editor.dom;
|
| - |
|
21828 |
const startBlock = dom.getParent(editor.selection.getStart(), dom.isBlock);
|
| - |
|
21829 |
const endBlock = dom.getParent(editor.selection.getEnd(), dom.isBlock);
|
| - |
|
21830 |
const body = editor.getBody();
|
| - |
|
21831 |
const startBlockName = (_a = startBlock === null || startBlock === void 0 ? void 0 : startBlock.nodeName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
| - |
|
21832 |
if (startBlockName === 'div' && startBlock && endBlock && startBlock === body.firstChild && endBlock === body.lastChild && !dom.isEmpty(body)) {
|
| - |
|
21833 |
const wrapper = startBlock.cloneNode(false);
|
| - |
|
21834 |
const deleteAction = () => {
|
| - |
|
21835 |
if (forward) {
|
| - |
|
21836 |
execNativeForwardDeleteCommand(editor);
|
| - |
|
21837 |
} else {
|
| - |
|
21838 |
execNativeDeleteCommand(editor);
|
| - |
|
21839 |
}
|
| - |
|
21840 |
if (body.firstChild !== startBlock) {
|
| - |
|
21841 |
const bookmark = getBookmark(editor.selection.getRng(), () => document.createElement('span'));
|
| - |
|
21842 |
Array.from(body.childNodes).forEach(node => wrapper.appendChild(node));
|
| - |
|
21843 |
body.appendChild(wrapper);
|
| - |
|
21844 |
editor.selection.setRng(resolveBookmark(bookmark));
|
| - |
|
21845 |
}
|
| - |
|
21846 |
};
|
| - |
|
21847 |
return Optional.some(deleteAction);
|
| - |
|
21848 |
}
|
| - |
|
21849 |
return Optional.none();
|
| - |
|
21850 |
};
|
| 21478 |
|
21851 |
|
| 21479 |
const deleteCaret$2 = (editor, forward) => {
|
21852 |
const deleteCaret$2 = (editor, forward) => {
|
| 21480 |
const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());
|
21853 |
const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());
|
| 21481 |
return fromPosition(forward, editor.getBody(), fromPos).filter(pos => forward ? isBeforeImageBlock(pos) : isAfterImageBlock(pos)).bind(pos => getChildNodeAtRelativeOffset(forward ? 0 : -1, pos)).map(elm => () => editor.selection.select(elm));
|
21854 |
return fromPosition(forward, editor.getBody(), fromPos).filter(pos => forward ? isBeforeImageBlock(pos) : isAfterImageBlock(pos)).bind(pos => getChildNodeAtRelativeOffset(forward ? 0 : -1, pos)).map(elm => () => editor.selection.select(elm));
|
| 21482 |
};
|
21855 |
};
|
| Línea 21483... |
Línea 21856... |
| 21483 |
const backspaceDelete$5 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret$2(editor, forward) : Optional.none();
|
21856 |
const backspaceDelete$5 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret$2(editor, forward) : Optional.none();
|
| 21484 |
|
21857 |
|
| 21485 |
const isText$2 = isText$a;
|
21858 |
const isText$2 = isText$b;
|
| 21486 |
const startsWithCaretContainer = node => isText$2(node) && node.data[0] === ZWSP$1;
|
21859 |
const startsWithCaretContainer = node => isText$2(node) && node.data[0] === ZWSP$1;
|
| 21487 |
const endsWithCaretContainer = node => isText$2(node) && node.data[node.data.length - 1] === ZWSP$1;
|
21860 |
const endsWithCaretContainer = node => isText$2(node) && node.data[node.data.length - 1] === ZWSP$1;
|
| 21488 |
const createZwsp = node => {
|
21861 |
const createZwsp = node => {
|
| Línea 21541... |
Línea 21914... |
| 21541 |
const insertInline = (before, node) => before ? insertBefore$1(node) : insertAfter$1(node);
|
21914 |
const insertInline = (before, node) => before ? insertBefore$1(node) : insertAfter$1(node);
|
| 21542 |
const insertInlineBefore = curry(insertInline, true);
|
21915 |
const insertInlineBefore = curry(insertInline, true);
|
| 21543 |
const insertInlineAfter = curry(insertInline, false);
|
21916 |
const insertInlineAfter = curry(insertInline, false);
|
| Línea 21544... |
Línea 21917... |
| 21544 |
|
21917 |
|
| 21545 |
const insertInlinePos = (pos, before) => {
|
21918 |
const insertInlinePos = (pos, before) => {
|
| 21546 |
if (isText$a(pos.container())) {
|
21919 |
if (isText$b(pos.container())) {
|
| 21547 |
return insertInline(before, pos.container());
|
21920 |
return insertInline(before, pos.container());
|
| 21548 |
} else {
|
21921 |
} else {
|
| 21549 |
return insertInline(before, pos.getNode());
|
21922 |
return insertInline(before, pos.getNode());
|
| 21550 |
}
|
21923 |
}
|
| 21551 |
};
|
21924 |
};
|
| 21552 |
const isPosCaretContainer = (pos, caret) => {
|
21925 |
const isPosCaretContainer = (pos, caret) => {
|
| 21553 |
const caretNode = caret.get();
|
21926 |
const caretNode = caret.get();
|
| 21554 |
return caretNode && pos.container() === caretNode && isCaretContainerInline(caretNode);
|
21927 |
return caretNode && pos.container() === caretNode && isCaretContainerInline(caretNode);
|
| 21555 |
};
|
21928 |
};
|
| 21556 |
const renderCaret = (caret, location) => location.fold(element => {
|
21929 |
const renderCaret = (caret, location) => location.fold(element => {
|
| 21557 |
remove$3(caret.get());
|
21930 |
remove$2(caret.get());
|
| 21558 |
const text = insertInlineBefore(element);
|
21931 |
const text = insertInlineBefore(element);
|
| 21559 |
caret.set(text);
|
21932 |
caret.set(text);
|
| 21560 |
return Optional.some(CaretPosition(text, text.length - 1));
|
21933 |
return Optional.some(CaretPosition(text, text.length - 1));
|
| 21561 |
}, element => firstPositionIn(element).map(pos => {
|
21934 |
}, element => firstPositionIn(element).map(pos => {
|
| 21562 |
if (!isPosCaretContainer(pos, caret)) {
|
21935 |
if (!isPosCaretContainer(pos, caret)) {
|
| 21563 |
remove$3(caret.get());
|
21936 |
remove$2(caret.get());
|
| 21564 |
const text = insertInlinePos(pos, true);
|
21937 |
const text = insertInlinePos(pos, true);
|
| 21565 |
caret.set(text);
|
21938 |
caret.set(text);
|
| 21566 |
return CaretPosition(text, 1);
|
21939 |
return CaretPosition(text, 1);
|
| 21567 |
} else {
|
21940 |
} else {
|
| 21568 |
const node = caret.get();
|
21941 |
const node = caret.get();
|
| 21569 |
return CaretPosition(node, 1);
|
21942 |
return CaretPosition(node, 1);
|
| 21570 |
}
|
21943 |
}
|
| 21571 |
}), element => lastPositionIn(element).map(pos => {
|
21944 |
}), element => lastPositionIn(element).map(pos => {
|
| 21572 |
if (!isPosCaretContainer(pos, caret)) {
|
21945 |
if (!isPosCaretContainer(pos, caret)) {
|
| 21573 |
remove$3(caret.get());
|
21946 |
remove$2(caret.get());
|
| 21574 |
const text = insertInlinePos(pos, false);
|
21947 |
const text = insertInlinePos(pos, false);
|
| 21575 |
caret.set(text);
|
21948 |
caret.set(text);
|
| 21576 |
return CaretPosition(text, text.length - 1);
|
21949 |
return CaretPosition(text, text.length - 1);
|
| 21577 |
} else {
|
21950 |
} else {
|
| 21578 |
const node = caret.get();
|
21951 |
const node = caret.get();
|
| 21579 |
return CaretPosition(node, node.length - 1);
|
21952 |
return CaretPosition(node, node.length - 1);
|
| 21580 |
}
|
21953 |
}
|
| 21581 |
}), element => {
|
21954 |
}), element => {
|
| 21582 |
remove$3(caret.get());
|
21955 |
remove$2(caret.get());
|
| 21583 |
const text = insertInlineAfter(element);
|
21956 |
const text = insertInlineAfter(element);
|
| 21584 |
caret.set(text);
|
21957 |
caret.set(text);
|
| 21585 |
return Optional.some(CaretPosition(text, 1));
|
21958 |
return Optional.some(CaretPosition(text, 1));
|
| Línea 21705... |
Línea 22078... |
| 21705 |
BreakType[BreakType['Br'] = 0] = 'Br';
|
22078 |
BreakType[BreakType['Br'] = 0] = 'Br';
|
| 21706 |
BreakType[BreakType['Block'] = 1] = 'Block';
|
22079 |
BreakType[BreakType['Block'] = 1] = 'Block';
|
| 21707 |
BreakType[BreakType['Wrap'] = 2] = 'Wrap';
|
22080 |
BreakType[BreakType['Wrap'] = 2] = 'Wrap';
|
| 21708 |
BreakType[BreakType['Eol'] = 3] = 'Eol';
|
22081 |
BreakType[BreakType['Eol'] = 3] = 'Eol';
|
| 21709 |
}(BreakType || (BreakType = {})));
|
22082 |
}(BreakType || (BreakType = {})));
|
| 21710 |
const flip = (direction, positions) => direction === HDirection.Backwards ? reverse(positions) : positions;
|
22083 |
const flip = (direction, positions) => direction === -1 ? reverse(positions) : positions;
|
| 21711 |
const walk$1 = (direction, caretWalker, pos) => direction === HDirection.Forwards ? caretWalker.next(pos) : caretWalker.prev(pos);
|
22084 |
const walk$1 = (direction, caretWalker, pos) => direction === 1 ? caretWalker.next(pos) : caretWalker.prev(pos);
|
| 21712 |
const getBreakType = (scope, direction, currentPos, nextPos) => {
|
22085 |
const getBreakType = (scope, direction, currentPos, nextPos) => {
|
| 21713 |
if (isBr$6(nextPos.getNode(direction === HDirection.Forwards))) {
|
22086 |
if (isBr$6(nextPos.getNode(direction === 1))) {
|
| 21714 |
return BreakType.Br;
|
22087 |
return BreakType.Br;
|
| 21715 |
} else if (isInSameBlock(currentPos, nextPos) === false) {
|
22088 |
} else if (isInSameBlock(currentPos, nextPos) === false) {
|
| 21716 |
return BreakType.Block;
|
22089 |
return BreakType.Block;
|
| 21717 |
} else {
|
22090 |
} else {
|
| 21718 |
return BreakType.Wrap;
|
22091 |
return BreakType.Wrap;
|
| Línea 21726... |
Línea 22099... |
| 21726 |
const nextPos = walk$1(direction, caretWalker, currentPos);
|
22099 |
const nextPos = walk$1(direction, caretWalker, currentPos);
|
| 21727 |
if (!nextPos) {
|
22100 |
if (!nextPos) {
|
| 21728 |
break;
|
22101 |
break;
|
| 21729 |
}
|
22102 |
}
|
| 21730 |
if (isBr$6(nextPos.getNode(false))) {
|
22103 |
if (isBr$6(nextPos.getNode(false))) {
|
| 21731 |
if (direction === HDirection.Forwards) {
|
22104 |
if (direction === 1) {
|
| 21732 |
return {
|
22105 |
return {
|
| 21733 |
positions: flip(direction, positions).concat([nextPos]),
|
22106 |
positions: flip(direction, positions).concat([nextPos]),
|
| 21734 |
breakType: BreakType.Br,
|
22107 |
breakType: BreakType.Br,
|
| 21735 |
breakAt: Optional.some(nextPos)
|
22108 |
breakAt: Optional.some(nextPos)
|
| 21736 |
};
|
22109 |
};
|
| Línea 21763... |
Línea 22136... |
| 21763 |
breakAt: Optional.none()
|
22136 |
breakAt: Optional.none()
|
| 21764 |
};
|
22137 |
};
|
| 21765 |
};
|
22138 |
};
|
| 21766 |
const getAdjacentLinePositions = (direction, getPositionsUntilBreak, scope, start) => getPositionsUntilBreak(scope, start).breakAt.map(pos => {
|
22139 |
const getAdjacentLinePositions = (direction, getPositionsUntilBreak, scope, start) => getPositionsUntilBreak(scope, start).breakAt.map(pos => {
|
| 21767 |
const positions = getPositionsUntilBreak(scope, pos).positions;
|
22140 |
const positions = getPositionsUntilBreak(scope, pos).positions;
|
| 21768 |
return direction === HDirection.Backwards ? positions.concat(pos) : [pos].concat(positions);
|
22141 |
return direction === -1 ? positions.concat(pos) : [pos].concat(positions);
|
| 21769 |
}).getOr([]);
|
22142 |
}).getOr([]);
|
| 21770 |
const findClosestHorizontalPositionFromPoint = (positions, x) => foldl(positions, (acc, newPos) => acc.fold(() => Optional.some(newPos), lastPos => lift2(head(lastPos.getClientRects()), head(newPos.getClientRects()), (lastRect, newRect) => {
|
22143 |
const findClosestHorizontalPositionFromPoint = (positions, x) => foldl(positions, (acc, newPos) => acc.fold(() => Optional.some(newPos), lastPos => lift2(head(lastPos.getClientRects()), head(newPos.getClientRects()), (lastRect, newRect) => {
|
| 21771 |
const lastDist = Math.abs(x - lastRect.left);
|
22144 |
const lastDist = Math.abs(x - lastRect.left);
|
| 21772 |
const newDist = Math.abs(x - newRect.left);
|
22145 |
const newDist = Math.abs(x - newRect.left);
|
| 21773 |
return newDist <= lastDist ? newPos : lastPos;
|
22146 |
return newDist <= lastDist ? newPos : lastPos;
|
| Línea 21782... |
Línea 22155... |
| 21782 |
const getFirstLinePositions = scope => firstPositionIn(scope).map(pos => [pos].concat(getPositionsUntilNextLine(scope, pos).positions)).getOr([]);
|
22155 |
const getFirstLinePositions = scope => firstPositionIn(scope).map(pos => [pos].concat(getPositionsUntilNextLine(scope, pos).positions)).getOr([]);
|
| 21783 |
const getLastLinePositions = scope => lastPositionIn(scope).map(pos => getPositionsUntilPreviousLine(scope, pos).positions.concat(pos)).getOr([]);
|
22156 |
const getLastLinePositions = scope => lastPositionIn(scope).map(pos => getPositionsUntilPreviousLine(scope, pos).positions.concat(pos)).getOr([]);
|
| 21784 |
const getClosestPositionAbove = (scope, pos) => findClosestHorizontalPosition(getPositionsAbove(scope, pos), pos);
|
22157 |
const getClosestPositionAbove = (scope, pos) => findClosestHorizontalPosition(getPositionsAbove(scope, pos), pos);
|
| 21785 |
const getClosestPositionBelow = (scope, pos) => findClosestHorizontalPosition(getPositionsBelow(scope, pos), pos);
|
22158 |
const getClosestPositionBelow = (scope, pos) => findClosestHorizontalPosition(getPositionsBelow(scope, pos), pos);
|
| Línea 21786... |
Línea 22159... |
| 21786 |
|
22159 |
|
| 21787 |
const isContentEditableFalse$4 = isContentEditableFalse$b;
|
22160 |
const isContentEditableFalse$5 = isContentEditableFalse$b;
|
| 21788 |
const distanceToRectLeft$1 = (clientRect, clientX) => Math.abs(clientRect.left - clientX);
|
22161 |
const distanceToRectLeft$1 = (clientRect, clientX) => Math.abs(clientRect.left - clientX);
|
| 21789 |
const distanceToRectRight$1 = (clientRect, clientX) => Math.abs(clientRect.right - clientX);
|
22162 |
const distanceToRectRight$1 = (clientRect, clientX) => Math.abs(clientRect.right - clientX);
|
| 21790 |
const isNodeClientRect = rect => hasNonNullableKey(rect, 'node');
|
22163 |
const isNodeClientRect = rect => hasNonNullableKey(rect, 'node');
|
| 21791 |
const findClosestClientRect = (clientRects, clientX) => reduce(clientRects, (oldClientRect, clientRect) => {
|
22164 |
const findClosestClientRect = (clientRects, clientX) => reduce(clientRects, (oldClientRect, clientRect) => {
|
| 21792 |
const oldDistance = Math.min(distanceToRectLeft$1(oldClientRect, clientX), distanceToRectRight$1(oldClientRect, clientX));
|
22165 |
const oldDistance = Math.min(distanceToRectLeft$1(oldClientRect, clientX), distanceToRectRight$1(oldClientRect, clientX));
|
| 21793 |
const newDistance = Math.min(distanceToRectLeft$1(clientRect, clientX), distanceToRectRight$1(clientRect, clientX));
|
22166 |
const newDistance = Math.min(distanceToRectLeft$1(clientRect, clientX), distanceToRectRight$1(clientRect, clientX));
|
| 21794 |
if (newDistance === oldDistance && isNodeClientRect(clientRect) && isContentEditableFalse$4(clientRect.node)) {
|
22167 |
if (newDistance === oldDistance && isNodeClientRect(clientRect) && isContentEditableFalse$5(clientRect.node)) {
|
| 21795 |
return clientRect;
|
22168 |
return clientRect;
|
| 21796 |
}
|
22169 |
}
|
| 21797 |
if (newDistance < oldDistance) {
|
22170 |
if (newDistance < oldDistance) {
|
| 21798 |
return clientRect;
|
22171 |
return clientRect;
|
| Línea 21808... |
Línea 22181... |
| 21808 |
return clientRect;
|
22181 |
return clientRect;
|
| 21809 |
});
|
22182 |
});
|
| 21810 |
};
|
22183 |
};
|
| 21811 |
if (isElement$6(node)) {
|
22184 |
if (isElement$6(node)) {
|
| 21812 |
return toArrayWithNode(node.getClientRects());
|
22185 |
return toArrayWithNode(node.getClientRects());
|
| 21813 |
} else if (isText$a(node)) {
|
22186 |
} else if (isText$b(node)) {
|
| 21814 |
const rng = node.ownerDocument.createRange();
|
22187 |
const rng = node.ownerDocument.createRange();
|
| 21815 |
rng.setStart(node, 0);
|
22188 |
rng.setStart(node, 0);
|
| 21816 |
rng.setEnd(node, node.data.length);
|
22189 |
rng.setEnd(node, node.data.length);
|
| 21817 |
return toArrayWithNode(rng.getClientRects());
|
22190 |
return toArrayWithNode(rng.getClientRects());
|
| 21818 |
} else {
|
22191 |
} else {
|
| Línea 21837... |
Línea 22210... |
| 21837 |
const walkUntil = (direction, isAboveFn, isBeflowFn, root, predicateFn, caretPosition) => {
|
22210 |
const walkUntil = (direction, isAboveFn, isBeflowFn, root, predicateFn, caretPosition) => {
|
| 21838 |
let line = 0;
|
22211 |
let line = 0;
|
| 21839 |
const result = [];
|
22212 |
const result = [];
|
| 21840 |
const add = node => {
|
22213 |
const add = node => {
|
| 21841 |
let clientRects = getClientRects([node]);
|
22214 |
let clientRects = getClientRects([node]);
|
| 21842 |
if (direction === -1) {
|
22215 |
if (direction === VDirection.Up) {
|
| 21843 |
clientRects = clientRects.reverse();
|
22216 |
clientRects = clientRects.reverse();
|
| 21844 |
}
|
22217 |
}
|
| 21845 |
for (let i = 0; i < clientRects.length; i++) {
|
22218 |
for (let i = 0; i < clientRects.length; i++) {
|
| 21846 |
const clientRect = clientRects[i];
|
22219 |
const clientRect = clientRects[i];
|
| 21847 |
if (isBeflowFn(clientRect, targetClientRect)) {
|
22220 |
if (isBeflowFn(clientRect, targetClientRect)) {
|
| 21848 |
continue;
|
22221 |
continue;
|
| 21849 |
}
|
22222 |
}
|
| 21850 |
if (result.length > 0 && isAboveFn(clientRect, last$2(result))) {
|
22223 |
if (result.length > 0 && isAboveFn(clientRect, last$1(result))) {
|
| 21851 |
line++;
|
22224 |
line++;
|
| 21852 |
}
|
22225 |
}
|
| 21853 |
clientRect.line = line;
|
22226 |
clientRect.line = line;
|
| 21854 |
if (predicateFn(clientRect)) {
|
22227 |
if (predicateFn(clientRect)) {
|
| 21855 |
return true;
|
22228 |
return true;
|
| 21856 |
}
|
22229 |
}
|
| 21857 |
result.push(clientRect);
|
22230 |
result.push(clientRect);
|
| 21858 |
}
|
22231 |
}
|
| 21859 |
return false;
|
22232 |
return false;
|
| 21860 |
};
|
22233 |
};
|
| 21861 |
const targetClientRect = last$2(caretPosition.getClientRects());
|
22234 |
const targetClientRect = last$1(caretPosition.getClientRects());
|
| 21862 |
if (!targetClientRect) {
|
22235 |
if (!targetClientRect) {
|
| 21863 |
return result;
|
22236 |
return result;
|
| 21864 |
}
|
22237 |
}
|
| 21865 |
const node = caretPosition.getNode();
|
22238 |
const node = caretPosition.getNode();
|
| 21866 |
if (node) {
|
22239 |
if (node) {
|
| Línea 21872... |
Línea 22245... |
| 21872 |
const aboveLineNumber = (lineNumber, clientRect) => clientRect.line > lineNumber;
|
22245 |
const aboveLineNumber = (lineNumber, clientRect) => clientRect.line > lineNumber;
|
| 21873 |
const isLineNumber = (lineNumber, clientRect) => clientRect.line === lineNumber;
|
22246 |
const isLineNumber = (lineNumber, clientRect) => clientRect.line === lineNumber;
|
| 21874 |
const upUntil = curry(walkUntil, VDirection.Up, isAbove$1, isBelow$1);
|
22247 |
const upUntil = curry(walkUntil, VDirection.Up, isAbove$1, isBelow$1);
|
| 21875 |
const downUntil = curry(walkUntil, VDirection.Down, isBelow$1, isAbove$1);
|
22248 |
const downUntil = curry(walkUntil, VDirection.Down, isBelow$1, isAbove$1);
|
| 21876 |
const getLastClientRect = caretPosition => {
|
22249 |
const getLastClientRect = caretPosition => {
|
| 21877 |
return last$2(caretPosition.getClientRects());
|
22250 |
return last$1(caretPosition.getClientRects());
|
| 21878 |
};
|
22251 |
};
|
| 21879 |
const positionsUntil = (direction, root, predicateFn, node) => {
|
22252 |
const positionsUntil = (direction, root, predicateFn, node) => {
|
| 21880 |
const caretWalker = CaretWalker(root);
|
22253 |
const caretWalker = CaretWalker(root);
|
| 21881 |
let walkFn;
|
22254 |
let walkFn;
|
| 21882 |
let isBelowFn;
|
22255 |
let isBelowFn;
|
| 21883 |
let isAboveFn;
|
22256 |
let isAboveFn;
|
| 21884 |
let caretPosition;
|
22257 |
let caretPosition;
|
| 21885 |
const result = [];
|
22258 |
const result = [];
|
| 21886 |
let line = 0;
|
22259 |
let line = 0;
|
| 21887 |
if (direction === 1) {
|
22260 |
if (direction === VDirection.Down) {
|
| 21888 |
walkFn = caretWalker.next;
|
22261 |
walkFn = caretWalker.next;
|
| 21889 |
isBelowFn = isBelow$1;
|
22262 |
isBelowFn = isBelow$1;
|
| 21890 |
isAboveFn = isAbove$1;
|
22263 |
isAboveFn = isAbove$1;
|
| 21891 |
caretPosition = CaretPosition.after(node);
|
22264 |
caretPosition = CaretPosition.after(node);
|
| 21892 |
} else {
|
22265 |
} else {
|
| Línea 21902... |
Línea 22275... |
| 21902 |
}
|
22275 |
}
|
| 21903 |
const rect = getLastClientRect(caretPosition);
|
22276 |
const rect = getLastClientRect(caretPosition);
|
| 21904 |
if (isAboveFn(rect, targetClientRect)) {
|
22277 |
if (isAboveFn(rect, targetClientRect)) {
|
| 21905 |
continue;
|
22278 |
continue;
|
| 21906 |
}
|
22279 |
}
|
| 21907 |
if (result.length > 0 && isBelowFn(rect, last$2(result))) {
|
22280 |
if (result.length > 0 && isBelowFn(rect, last$1(result))) {
|
| 21908 |
line++;
|
22281 |
line++;
|
| 21909 |
}
|
22282 |
}
|
| 21910 |
const clientRect = clone$1(rect);
|
22283 |
const clientRect = clone$1(rect);
|
| 21911 |
clientRect.position = caretPosition;
|
22284 |
clientRect.position = caretPosition;
|
| 21912 |
clientRect.line = line;
|
22285 |
clientRect.line = line;
|
| Línea 21924... |
Línea 22297... |
| 21924 |
editor.selection.setRng(rng);
|
22297 |
editor.selection.setRng(rng);
|
| 21925 |
scrollRangeIntoView(editor, editor.selection.getRng());
|
22298 |
scrollRangeIntoView(editor, editor.selection.getRng());
|
| 21926 |
};
|
22299 |
};
|
| 21927 |
const renderRangeCaretOpt = (editor, range, scrollIntoView) => Optional.some(renderRangeCaret(editor, range, scrollIntoView));
|
22300 |
const renderRangeCaretOpt = (editor, range, scrollIntoView) => Optional.some(renderRangeCaret(editor, range, scrollIntoView));
|
| 21928 |
const moveHorizontally = (editor, direction, range, isBefore, isAfter, isElement) => {
|
22301 |
const moveHorizontally = (editor, direction, range, isBefore, isAfter, isElement) => {
|
| 21929 |
const forwards = direction === HDirection.Forwards;
|
22302 |
const forwards = direction === 1;
|
| 21930 |
const caretWalker = CaretWalker(editor.getBody());
|
22303 |
const caretWalker = CaretWalker(editor.getBody());
|
| 21931 |
const getNextPosFn = curry(getVisualCaretPosition, forwards ? caretWalker.next : caretWalker.prev);
|
22304 |
const getNextPosFn = curry(getVisualCaretPosition, forwards ? caretWalker.next : caretWalker.prev);
|
| 21932 |
const isBeforeFn = forwards ? isBefore : isAfter;
|
22305 |
const isBeforeFn = forwards ? isBefore : isAfter;
|
| 21933 |
if (!range.collapsed) {
|
22306 |
if (!range.collapsed) {
|
| 21934 |
const node = getSelectedNode(range);
|
22307 |
const node = getSelectedNode(range);
|
| 21935 |
if (isElement(node)) {
|
22308 |
if (isElement(node)) {
|
| 21936 |
return showCaret(direction, editor, node, direction === HDirection.Backwards, false);
|
22309 |
return showCaret(direction, editor, node, direction === -1, false);
|
| 21937 |
} else if (isCefAtEdgeSelected(editor)) {
|
22310 |
} else if (isCefAtEdgeSelected(editor)) {
|
| 21938 |
const newRange = range.cloneRange();
|
22311 |
const newRange = range.cloneRange();
|
| 21939 |
newRange.collapse(direction === HDirection.Backwards);
|
22312 |
newRange.collapse(direction === -1);
|
| 21940 |
return Optional.from(newRange);
|
22313 |
return Optional.from(newRange);
|
| 21941 |
}
|
22314 |
}
|
| 21942 |
}
|
22315 |
}
|
| 21943 |
const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);
|
22316 |
const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);
|
| 21944 |
if (isBeforeFn(caretPosition)) {
|
22317 |
if (isBeforeFn(caretPosition)) {
|
| Línea 21965... |
Línea 22338... |
| 21965 |
}
|
22338 |
}
|
| 21966 |
return Optional.none();
|
22339 |
return Optional.none();
|
| 21967 |
};
|
22340 |
};
|
| 21968 |
const moveVertically = (editor, direction, range, isBefore, isAfter, isElement) => {
|
22341 |
const moveVertically = (editor, direction, range, isBefore, isAfter, isElement) => {
|
| 21969 |
const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);
|
22342 |
const caretPosition = getNormalizedRangeEndPoint(direction, editor.getBody(), range);
|
| 21970 |
const caretClientRect = last$2(caretPosition.getClientRects());
|
22343 |
const caretClientRect = last$1(caretPosition.getClientRects());
|
| 21971 |
const forwards = direction === VDirection.Down;
|
22344 |
const forwards = direction === VDirection.Down;
|
| 21972 |
const root = editor.getBody();
|
22345 |
const root = editor.getBody();
|
| 21973 |
if (!caretClientRect) {
|
22346 |
if (!caretClientRect) {
|
| 21974 |
return Optional.none();
|
22347 |
return Optional.none();
|
| 21975 |
}
|
22348 |
}
|
| Línea 22000... |
Línea 22373... |
| 22000 |
const caretPositions = positionsUntil(direction, root, isAboveLine(1), currentNode);
|
22373 |
const caretPositions = positionsUntil(direction, root, isAboveLine(1), currentNode);
|
| 22001 |
let closestNextLineRect = findClosestClientRect(filter$5(caretPositions, isLine(1)), clientX);
|
22374 |
let closestNextLineRect = findClosestClientRect(filter$5(caretPositions, isLine(1)), clientX);
|
| 22002 |
if (closestNextLineRect) {
|
22375 |
if (closestNextLineRect) {
|
| 22003 |
return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);
|
22376 |
return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);
|
| 22004 |
}
|
22377 |
}
|
| 22005 |
closestNextLineRect = last$2(filter$5(caretPositions, isLine(0)));
|
22378 |
closestNextLineRect = last$1(filter$5(caretPositions, isLine(0)));
|
| 22006 |
if (closestNextLineRect) {
|
22379 |
if (closestNextLineRect) {
|
| 22007 |
return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);
|
22380 |
return renderRangeCaretOpt(editor, closestNextLineRect.position.toRange(), false);
|
| 22008 |
}
|
22381 |
}
|
| 22009 |
}
|
22382 |
}
|
| 22010 |
if (nextLinePositions.length === 0) {
|
22383 |
if (nextLinePositions.length === 0) {
|
| Línea 22016... |
Línea 22389... |
| 22016 |
const rng = editor.selection.getRng();
|
22389 |
const rng = editor.selection.getRng();
|
| 22017 |
const from = forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);
|
22390 |
const from = forward ? CaretPosition.fromRangeEnd(rng) : CaretPosition.fromRangeStart(rng);
|
| 22018 |
const host = getEditingHost(from.container(), editor.getBody());
|
22391 |
const host = getEditingHost(from.container(), editor.getBody());
|
| 22019 |
if (forward) {
|
22392 |
if (forward) {
|
| 22020 |
const lineInfo = getPositionsUntilNextLine(host, from);
|
22393 |
const lineInfo = getPositionsUntilNextLine(host, from);
|
| 22021 |
return last$3(lineInfo.positions);
|
22394 |
return last$2(lineInfo.positions);
|
| 22022 |
} else {
|
22395 |
} else {
|
| 22023 |
const lineInfo = getPositionsUntilPreviousLine(host, from);
|
22396 |
const lineInfo = getPositionsUntilPreviousLine(host, from);
|
| 22024 |
return head(lineInfo.positions);
|
22397 |
return head(lineInfo.positions);
|
| 22025 |
}
|
22398 |
}
|
| 22026 |
};
|
22399 |
};
|
| Línea 22216... |
Línea 22589... |
| 22216 |
editor.selection.setRng(pos.toRange());
|
22589 |
editor.selection.setRng(pos.toRange());
|
| 22217 |
}
|
22590 |
}
|
| 22218 |
};
|
22591 |
};
|
| 22219 |
const deleteCaret$1 = (editor, forward) => {
|
22592 |
const deleteCaret$1 = (editor, forward) => {
|
| 22220 |
const parentInlines = filter$5(getParentInlinesUntilMultichildInline(editor), hasOnlyOneChild);
|
22593 |
const parentInlines = filter$5(getParentInlinesUntilMultichildInline(editor), hasOnlyOneChild);
|
| 22221 |
return last$3(parentInlines).bind(target => {
|
22594 |
return last$2(parentInlines).bind(target => {
|
| 22222 |
const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());
|
22595 |
const fromPos = CaretPosition.fromRangeStart(editor.selection.getRng());
|
| 22223 |
if (willDeleteLastPositionInElement(forward, fromPos, target.dom) && !isEmptyCaretFormatElement(target)) {
|
22596 |
if (willDeleteLastPositionInElement(forward, fromPos, target.dom) && !isEmptyCaretFormatElement(target)) {
|
| 22224 |
return Optional.some(() => deleteLastPosition(forward, editor, target, parentInlines));
|
22597 |
return Optional.some(() => deleteLastPosition(forward, editor, target, parentInlines));
|
| 22225 |
} else {
|
22598 |
} else {
|
| 22226 |
return Optional.none();
|
22599 |
return Optional.none();
|
| Línea 22241... |
Línea 22614... |
| 22241 |
const missingFormats = difference(updateFormats, getFormatNodesAtStart(editor));
|
22614 |
const missingFormats = difference(updateFormats, getFormatNodesAtStart(editor));
|
| 22242 |
if (missingFormats.length > 0) {
|
22615 |
if (missingFormats.length > 0) {
|
| 22243 |
createCaretFormatAtStart(editor, missingFormats);
|
22616 |
createCaretFormatAtStart(editor, missingFormats);
|
| 22244 |
}
|
22617 |
}
|
| 22245 |
};
|
22618 |
};
|
| 22246 |
const rangeStartsAtTextContainer = rng => isText$a(rng.startContainer);
|
22619 |
const rangeStartsAtTextContainer = rng => isText$b(rng.startContainer);
|
| 22247 |
const rangeStartsAtStartOfTextContainer = rng => rng.startOffset === 0 && rangeStartsAtTextContainer(rng);
|
22620 |
const rangeStartsAtStartOfTextContainer = rng => rng.startOffset === 0 && rangeStartsAtTextContainer(rng);
|
| 22248 |
const rangeStartParentIsFormatElement = (editor, rng) => {
|
22621 |
const rangeStartParentIsFormatElement = (editor, rng) => {
|
| 22249 |
const startParent = rng.startContainer.parentElement;
|
22622 |
const startParent = rng.startContainer.parentElement;
|
| 22250 |
return !isNull(startParent) && isFormatElement(editor, SugarElement.fromDom(startParent));
|
22623 |
return !isNull(startParent) && isFormatElement(editor, SugarElement.fromDom(startParent));
|
| 22251 |
};
|
22624 |
};
|
| Línea 22254... |
Línea 22627... |
| 22254 |
const endParent = rng.endContainer.parentNode;
|
22627 |
const endParent = rng.endContainer.parentNode;
|
| 22255 |
return !isNull(startParent) && !isNull(endParent) && startParent.isEqualNode(endParent);
|
22628 |
return !isNull(startParent) && !isNull(endParent) && startParent.isEqualNode(endParent);
|
| 22256 |
};
|
22629 |
};
|
| 22257 |
const rangeEndsAtEndOfEndContainer = rng => {
|
22630 |
const rangeEndsAtEndOfEndContainer = rng => {
|
| 22258 |
const endContainer = rng.endContainer;
|
22631 |
const endContainer = rng.endContainer;
|
| 22259 |
return rng.endOffset === (isText$a(endContainer) ? endContainer.length : endContainer.childNodes.length);
|
22632 |
return rng.endOffset === (isText$b(endContainer) ? endContainer.length : endContainer.childNodes.length);
|
| 22260 |
};
|
22633 |
};
|
| 22261 |
const rangeEndsAtEndOfStartContainer = rng => rangeStartAndEndHaveSameParent(rng) && rangeEndsAtEndOfEndContainer(rng);
|
22634 |
const rangeEndsAtEndOfStartContainer = rng => rangeStartAndEndHaveSameParent(rng) && rangeEndsAtEndOfEndContainer(rng);
|
| 22262 |
const rangeEndsAfterEndOfStartContainer = rng => !rng.endContainer.isEqualNode(rng.commonAncestorContainer);
|
22635 |
const rangeEndsAfterEndOfStartContainer = rng => !rng.endContainer.isEqualNode(rng.commonAncestorContainer);
|
| 22263 |
const rangeEndsAtOrAfterEndOfStartContainer = rng => rangeEndsAtEndOfStartContainer(rng) || rangeEndsAfterEndOfStartContainer(rng);
|
22636 |
const rangeEndsAtOrAfterEndOfStartContainer = rng => rangeEndsAtEndOfStartContainer(rng) || rangeEndsAfterEndOfStartContainer(rng);
|
| 22264 |
const requiresDeleteRangeOverride = editor => {
|
22637 |
const requiresDeleteRangeOverride = editor => {
|
| Línea 22275... |
Línea 22648... |
| 22275 |
} else {
|
22648 |
} else {
|
| 22276 |
return Optional.none();
|
22649 |
return Optional.none();
|
| 22277 |
}
|
22650 |
}
|
| 22278 |
};
|
22651 |
};
|
| 22279 |
const backspaceDelete$3 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret$1(editor, forward) : deleteRange$1(editor);
|
22652 |
const backspaceDelete$3 = (editor, forward) => editor.selection.isCollapsed() ? deleteCaret$1(editor, forward) : deleteRange$1(editor);
|
| 22280 |
const hasAncestorInlineCaret = (elm, schema) => ancestor$1(elm, node => isCaretNode(node.dom), el => schema.isBlock(name(el)));
|
22653 |
const hasAncestorInlineCaret = (elm, schema) => ancestor$2(elm, node => isCaretNode(node.dom), el => schema.isBlock(name(el)));
|
| 22281 |
const hasAncestorInlineCaretAtStart = editor => hasAncestorInlineCaret(SugarElement.fromDom(editor.selection.getStart()), editor.schema);
|
22654 |
const hasAncestorInlineCaretAtStart = editor => hasAncestorInlineCaret(SugarElement.fromDom(editor.selection.getStart()), editor.schema);
|
| 22282 |
const requiresRefreshCaretOverride = editor => {
|
22655 |
const requiresRefreshCaretOverride = editor => {
|
| 22283 |
const rng = editor.selection.getRng();
|
22656 |
const rng = editor.selection.getRng();
|
| 22284 |
return rng.collapsed && (rangeStartsAtTextContainer(rng) || editor.dom.isEmpty(rng.startContainer)) && !hasAncestorInlineCaretAtStart(editor);
|
22657 |
return rng.collapsed && (rangeStartsAtTextContainer(rng) || editor.dom.isEmpty(rng.startContainer)) && !hasAncestorInlineCaretAtStart(editor);
|
| 22285 |
};
|
22658 |
};
|
| Línea 22300... |
Línea 22673... |
| 22300 |
return Optional.none();
|
22673 |
return Optional.none();
|
| 22301 |
}
|
22674 |
}
|
| 22302 |
};
|
22675 |
};
|
| 22303 |
const deleteCaret = (editor, forward) => {
|
22676 |
const deleteCaret = (editor, forward) => {
|
| 22304 |
const isNearMedia = forward ? isBeforeMedia : isAfterMedia;
|
22677 |
const isNearMedia = forward ? isBeforeMedia : isAfterMedia;
|
| 22305 |
const direction = forward ? HDirection.Forwards : HDirection.Backwards;
|
22678 |
const direction = forward ? 1 : -1;
|
| 22306 |
const fromPos = getNormalizedRangeEndPoint(direction, editor.getBody(), editor.selection.getRng());
|
22679 |
const fromPos = getNormalizedRangeEndPoint(direction, editor.getBody(), editor.selection.getRng());
|
| 22307 |
if (isNearMedia(fromPos)) {
|
22680 |
if (isNearMedia(fromPos)) {
|
| 22308 |
return deleteElement(editor, forward, fromPos.getNode(!forward));
|
22681 |
return deleteElement(editor, forward, fromPos.getNode(!forward));
|
| 22309 |
} else {
|
22682 |
} else {
|
| 22310 |
return Optional.from(normalizePosition(forward, fromPos)).filter(pos => isNearMedia(pos) && isMoveInsideSameBlock(fromPos, pos)).bind(pos => deleteElement(editor, forward, pos.getNode(!forward)));
|
22683 |
return Optional.from(normalizePosition(forward, fromPos)).filter(pos => isNearMedia(pos) && isMoveInsideSameBlock(fromPos, pos)).bind(pos => deleteElement(editor, forward, pos.getNode(!forward)));
|
| Línea 22347... |
Línea 22720... |
| 22347 |
const isListComponent = el => isList(el) || isListItem$1(el);
|
22720 |
const isListComponent = el => isList(el) || isListItem$1(el);
|
| 22348 |
const parentIsListComponent = el => parent(el).exists(isListComponent);
|
22721 |
const parentIsListComponent = el => parent(el).exists(isListComponent);
|
| 22349 |
const getBlocksToIndent = editor => filter$5(fromDom$1(editor.selection.getSelectedBlocks()), el => !isListComponent(el) && !parentIsListComponent(el) && isEditable(el));
|
22722 |
const getBlocksToIndent = editor => filter$5(fromDom$1(editor.selection.getSelectedBlocks()), el => !isListComponent(el) && !parentIsListComponent(el) && isEditable(el));
|
| 22350 |
const handle = (editor, command) => {
|
22723 |
const handle = (editor, command) => {
|
| 22351 |
var _a, _b;
|
22724 |
var _a, _b;
|
| - |
|
22725 |
if (editor.mode.isReadOnly()) {
|
| - |
|
22726 |
return;
|
| - |
|
22727 |
}
|
| 22352 |
const {dom} = editor;
|
22728 |
const {dom} = editor;
|
| 22353 |
const indentation = getIndentation(editor);
|
22729 |
const indentation = getIndentation(editor);
|
| 22354 |
const indentUnit = (_b = (_a = /[a-z%]+$/i.exec(indentation)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'px';
|
22730 |
const indentUnit = (_b = (_a = /[a-z%]+$/i.exec(indentation)) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : 'px';
|
| 22355 |
const indentValue = parseIndentValue(indentation);
|
22731 |
const indentValue = parseIndentValue(indentation);
|
| 22356 |
const useMargin = shouldIndentUseMargin(editor);
|
22732 |
const useMargin = shouldIndentUseMargin(editor);
|
| Línea 22374... |
Línea 22750... |
| 22374 |
return Optional.none();
|
22750 |
return Optional.none();
|
| 22375 |
};
|
22751 |
};
|
| Línea 22376... |
Línea 22752... |
| 22376 |
|
22752 |
|
| 22377 |
const findAction = (editor, caret, forward) => findMap([
|
22753 |
const findAction = (editor, caret, forward) => findMap([
|
| 22378 |
backspaceDelete$1,
|
- |
|
| 22379 |
backspaceDelete$6,
|
22754 |
backspaceDelete$1,
|
| - |
|
22755 |
backspaceDelete$7,
|
| 22380 |
backspaceDelete$7,
|
22756 |
backspaceDelete$8,
|
| 22381 |
(editor, forward) => backspaceDelete$4(editor, caret, forward),
|
- |
|
| 22382 |
backspaceDelete$9,
|
22757 |
(editor, forward) => backspaceDelete$4(editor, caret, forward),
|
| - |
|
22758 |
backspaceDelete$a,
|
| 22383 |
backspaceDelete$a,
|
22759 |
backspaceDelete$b,
|
| 22384 |
backspaceDelete$5,
|
22760 |
backspaceDelete$5,
|
| 22385 |
backspaceDelete$2,
|
22761 |
backspaceDelete$2,
|
| 22386 |
backspaceDelete$8,
|
22762 |
backspaceDelete$9,
|
| - |
|
22763 |
backspaceDelete$3,
|
| 22387 |
backspaceDelete$3
|
22764 |
backspaceDelete$6
|
| 22388 |
], item => item(editor, forward)).filter(_ => editor.selection.isEditable());
|
22765 |
], item => item(editor, forward)).filter(_ => editor.selection.isEditable());
|
| 22389 |
const deleteCommand = (editor, caret) => {
|
22766 |
const deleteCommand = (editor, caret) => {
|
| 22390 |
const result = findAction(editor, caret, false);
|
22767 |
const result = findAction(editor, caret, false);
|
| 22391 |
result.fold(() => {
|
22768 |
result.fold(() => {
|
| Línea 22426... |
Línea 22803... |
| 22426 |
return distX > SIGNIFICANT_MOVE || distY > SIGNIFICANT_MOVE;
|
22803 |
return distX > SIGNIFICANT_MOVE || distY > SIGNIFICANT_MOVE;
|
| 22427 |
};
|
22804 |
};
|
| 22428 |
const setup$p = editor => {
|
22805 |
const setup$p = editor => {
|
| 22429 |
const startData = value$2();
|
22806 |
const startData = value$2();
|
| 22430 |
const longpressFired = Cell(false);
|
22807 |
const longpressFired = Cell(false);
|
| 22431 |
const debounceLongpress = last$1(e => {
|
22808 |
const debounceLongpress = last(e => {
|
| 22432 |
editor.dispatch('longpress', {
|
22809 |
editor.dispatch('longpress', {
|
| 22433 |
...e,
|
22810 |
...e,
|
| 22434 |
type: 'longpress'
|
22811 |
type: 'longpress'
|
| 22435 |
});
|
22812 |
});
|
| 22436 |
longpressFired.set(true);
|
22813 |
longpressFired.set(true);
|
| Línea 22478... |
Línea 22855... |
| 22478 |
}, true);
|
22855 |
}, true);
|
| 22479 |
};
|
22856 |
};
|
| Línea 22480... |
Línea 22857... |
| 22480 |
|
22857 |
|
| 22481 |
const isBlockElement = (blockElements, node) => has$2(blockElements, node.nodeName);
|
22858 |
const isBlockElement = (blockElements, node) => has$2(blockElements, node.nodeName);
|
| 22482 |
const isValidTarget = (schema, node) => {
|
22859 |
const isValidTarget = (schema, node) => {
|
| 22483 |
if (isText$a(node)) {
|
22860 |
if (isText$b(node)) {
|
| 22484 |
return true;
|
22861 |
return true;
|
| 22485 |
} else if (isElement$6(node)) {
|
22862 |
} else if (isElement$6(node)) {
|
| 22486 |
return !isBlockElement(schema.getBlockElements(), node) && !isBookmarkNode$1(node) && !isTransparentBlock(schema, node) && !isNonHtmlElementRoot(node);
|
22863 |
return !isBlockElement(schema.getBlockElements(), node) && !isBookmarkNode$1(node) && !isTransparentBlock(schema, node) && !isNonHtmlElementRoot(node);
|
| 22487 |
} else {
|
22864 |
} else {
|
| Línea 22492... |
Línea 22869... |
| 22492 |
return exists(parents(SugarElement.fromDom(node), SugarElement.fromDom(root)), elm => {
|
22869 |
return exists(parents(SugarElement.fromDom(node), SugarElement.fromDom(root)), elm => {
|
| 22493 |
return isBlockElement(blockElements, elm.dom);
|
22870 |
return isBlockElement(blockElements, elm.dom);
|
| 22494 |
});
|
22871 |
});
|
| 22495 |
};
|
22872 |
};
|
| 22496 |
const shouldRemoveTextNode = (blockElements, node) => {
|
22873 |
const shouldRemoveTextNode = (blockElements, node) => {
|
| 22497 |
if (isText$a(node)) {
|
22874 |
if (isText$b(node)) {
|
| 22498 |
if (node.data.length === 0) {
|
22875 |
if (node.data.length === 0) {
|
| 22499 |
return true;
|
22876 |
return true;
|
| 22500 |
} else if (/^\s+$/.test(node.data)) {
|
22877 |
} else if (/^\s+$/.test(node.data)) {
|
| 22501 |
return !node.nextSibling || isBlockElement(blockElements, node.nextSibling) || isNonHtmlElementRoot(node.nextSibling);
|
22878 |
return !node.nextSibling || isBlockElement(blockElements, node.nextSibling) || isNonHtmlElementRoot(node.nextSibling);
|
| 22502 |
}
|
22879 |
}
|
| Línea 22510... |
Línea 22887... |
| 22510 |
const blockElements = schema.getBlockElements();
|
22887 |
const blockElements = schema.getBlockElements();
|
| 22511 |
const startNode = selection.getStart();
|
22888 |
const startNode = selection.getStart();
|
| 22512 |
const rootNode = editor.getBody();
|
22889 |
const rootNode = editor.getBody();
|
| 22513 |
let rootBlockNode;
|
22890 |
let rootBlockNode;
|
| 22514 |
let tempNode;
|
22891 |
let tempNode;
|
| 22515 |
let wrapped = false;
|
22892 |
let bm = null;
|
| 22516 |
const forcedRootBlock = getForcedRootBlock(editor);
|
22893 |
const forcedRootBlock = getForcedRootBlock(editor);
|
| 22517 |
if (!startNode || !isElement$6(startNode)) {
|
22894 |
if (!startNode || !isElement$6(startNode)) {
|
| 22518 |
return;
|
22895 |
return;
|
| 22519 |
}
|
22896 |
}
|
| 22520 |
const rootNodeName = rootNode.nodeName.toLowerCase();
|
22897 |
const rootNodeName = rootNode.nodeName.toLowerCase();
|
| 22521 |
if (!schema.isValidChild(rootNodeName, forcedRootBlock.toLowerCase()) || hasBlockParent(blockElements, rootNode, startNode)) {
|
22898 |
if (!schema.isValidChild(rootNodeName, forcedRootBlock.toLowerCase()) || hasBlockParent(blockElements, rootNode, startNode)) {
|
| 22522 |
return;
|
22899 |
return;
|
| 22523 |
}
|
22900 |
}
|
| - |
|
22901 |
if (rootNode.firstChild === rootNode.lastChild && isBr$6(rootNode.firstChild)) {
|
| 22524 |
const rng = selection.getRng();
|
22902 |
rootBlockNode = createRootBlock(editor);
|
| - |
|
22903 |
rootBlockNode.appendChild(createPaddingBr().dom);
|
| 22525 |
const {startContainer, startOffset, endContainer, endOffset} = rng;
|
22904 |
rootNode.replaceChild(rootBlockNode, rootNode.firstChild);
|
| 22526 |
const restoreSelection = hasFocus(editor);
|
22905 |
editor.selection.setCursorLocation(rootBlockNode, 0);
|
| - |
|
22906 |
editor.nodeChanged();
|
| - |
|
22907 |
return;
|
| - |
|
22908 |
}
|
| 22527 |
let node = rootNode.firstChild;
|
22909 |
let node = rootNode.firstChild;
|
| 22528 |
while (node) {
|
22910 |
while (node) {
|
| 22529 |
if (isElement$6(node)) {
|
22911 |
if (isElement$6(node)) {
|
| 22530 |
updateElement(schema, node);
|
22912 |
updateElement(schema, node);
|
| 22531 |
}
|
22913 |
}
|
| Línea 22535... |
Línea 22917... |
| 22535 |
node = node.nextSibling;
|
22917 |
node = node.nextSibling;
|
| 22536 |
dom.remove(tempNode);
|
22918 |
dom.remove(tempNode);
|
| 22537 |
continue;
|
22919 |
continue;
|
| 22538 |
}
|
22920 |
}
|
| 22539 |
if (!rootBlockNode) {
|
22921 |
if (!rootBlockNode) {
|
| - |
|
22922 |
if (!bm && editor.hasFocus()) {
|
| - |
|
22923 |
bm = getBookmark(editor.selection.getRng(), () => document.createElement('span'));
|
| - |
|
22924 |
}
|
| - |
|
22925 |
if (!node.parentNode) {
|
| - |
|
22926 |
node = null;
|
| - |
|
22927 |
break;
|
| - |
|
22928 |
}
|
| 22540 |
rootBlockNode = createRootBlock(editor);
|
22929 |
rootBlockNode = createRootBlock(editor);
|
| 22541 |
rootNode.insertBefore(rootBlockNode, node);
|
22930 |
rootNode.insertBefore(rootBlockNode, node);
|
| 22542 |
wrapped = true;
|
- |
|
| 22543 |
}
|
22931 |
}
|
| 22544 |
tempNode = node;
|
22932 |
tempNode = node;
|
| 22545 |
node = node.nextSibling;
|
22933 |
node = node.nextSibling;
|
| 22546 |
rootBlockNode.appendChild(tempNode);
|
22934 |
rootBlockNode.appendChild(tempNode);
|
| 22547 |
} else {
|
22935 |
} else {
|
| 22548 |
rootBlockNode = null;
|
22936 |
rootBlockNode = null;
|
| 22549 |
node = node.nextSibling;
|
22937 |
node = node.nextSibling;
|
| 22550 |
}
|
22938 |
}
|
| 22551 |
}
|
22939 |
}
|
| 22552 |
if (wrapped && restoreSelection) {
|
22940 |
if (bm) {
|
| 22553 |
rng.setStart(startContainer, startOffset);
|
- |
|
| 22554 |
rng.setEnd(endContainer, endOffset);
|
- |
|
| 22555 |
selection.setRng(rng);
|
22941 |
editor.selection.setRng(resolveBookmark(bm));
|
| 22556 |
editor.nodeChanged();
|
22942 |
editor.nodeChanged();
|
| 22557 |
}
|
22943 |
}
|
| 22558 |
};
|
22944 |
};
|
| 22559 |
const insertEmptyLine = (editor, root, insertBlock) => {
|
22945 |
const insertEmptyLine = (editor, root, insertBlock) => {
|
| 22560 |
const block = SugarElement.fromDom(createRootBlock(editor));
|
22946 |
const block = SugarElement.fromDom(createRootBlock(editor));
|
| Línea 22565... |
Línea 22951... |
| 22565 |
rng.setStartBefore(br.dom);
|
22951 |
rng.setStartBefore(br.dom);
|
| 22566 |
rng.setEndBefore(br.dom);
|
22952 |
rng.setEndBefore(br.dom);
|
| 22567 |
return rng;
|
22953 |
return rng;
|
| 22568 |
};
|
22954 |
};
|
| 22569 |
const setup$o = editor => {
|
22955 |
const setup$o = editor => {
|
| 22570 |
editor.on('NodeChange', curry(addRootBlocks, editor));
|
22956 |
editor.on('NodeChange', () => addRootBlocks(editor));
|
| 22571 |
};
|
22957 |
};
|
| Línea 22572... |
Línea 22958... |
| 22572 |
|
22958 |
|
| 22573 |
const hasClass = checkClassName => node => (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1;
|
22959 |
const hasClass = checkClassName => node => (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1;
|
| 22574 |
const replaceMatchWithSpan = (editor, content, cls) => {
|
22960 |
const replaceMatchWithSpan = (editor, content, cls) => {
|
| Línea 22598... |
Línea 22984... |
| 22598 |
while (i--) {
|
22984 |
while (i--) {
|
| 22599 |
content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor)));
|
22985 |
content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor)));
|
| 22600 |
}
|
22986 |
}
|
| 22601 |
e.content = content;
|
22987 |
e.content = content;
|
| 22602 |
};
|
22988 |
};
|
| - |
|
22989 |
const isValidContent = (nonEditableRegExps, content) => {
|
| - |
|
22990 |
return forall(nonEditableRegExps, re => {
|
| - |
|
22991 |
const matches = content.match(re);
|
| - |
|
22992 |
return matches !== null && matches[0].length === content.length;
|
| - |
|
22993 |
});
|
| - |
|
22994 |
};
|
| 22603 |
const setup$n = editor => {
|
22995 |
const setup$n = editor => {
|
| 22604 |
const contentEditableAttrName = 'contenteditable';
|
22996 |
const contentEditableAttrName = 'contenteditable';
|
| 22605 |
const editClass = ' ' + Tools.trim(getEditableClass(editor)) + ' ';
|
22997 |
const editClass = ' ' + Tools.trim(getEditableClass(editor)) + ' ';
|
| 22606 |
const nonEditClass = ' ' + Tools.trim(getNonEditableClass(editor)) + ' ';
|
22998 |
const nonEditClass = ' ' + Tools.trim(getNonEditableClass(editor)) + ' ';
|
| 22607 |
const hasEditClass = hasClass(editClass);
|
22999 |
const hasEditClass = hasClass(editClass);
|
| Línea 22628... |
Línea 23020... |
| 22628 |
while (i--) {
|
23020 |
while (i--) {
|
| 22629 |
const node = nodes[i];
|
23021 |
const node = nodes[i];
|
| 22630 |
if (!hasEditClass(node) && !hasNonEditClass(node)) {
|
23022 |
if (!hasEditClass(node) && !hasNonEditClass(node)) {
|
| 22631 |
continue;
|
23023 |
continue;
|
| 22632 |
}
|
23024 |
}
|
| - |
|
23025 |
const content = node.attr('data-mce-content');
|
| 22633 |
if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) {
|
23026 |
if (nonEditableRegExps.length > 0 && content) {
|
| - |
|
23027 |
if (isValidContent(nonEditableRegExps, content)) {
|
| 22634 |
node.name = '#text';
|
23028 |
node.name = '#text';
|
| 22635 |
node.type = 3;
|
23029 |
node.type = 3;
|
| 22636 |
node.raw = true;
|
23030 |
node.raw = true;
|
| 22637 |
node.value = node.attr('data-mce-content');
|
23031 |
node.value = content;
|
| - |
|
23032 |
} else {
|
| - |
|
23033 |
node.remove();
|
| - |
|
23034 |
}
|
| 22638 |
} else {
|
23035 |
} else {
|
| 22639 |
node.attr(contentEditableAttrName, null);
|
23036 |
node.attr(contentEditableAttrName, null);
|
| 22640 |
}
|
23037 |
}
|
| 22641 |
}
|
23038 |
}
|
| 22642 |
});
|
23039 |
});
|
| Línea 22668... |
Línea 23065... |
| 22668 |
};
|
23065 |
};
|
| 22669 |
const setup$m = editor => {
|
23066 |
const setup$m = editor => {
|
| 22670 |
editor.on('keyup compositionstart', curry(handleBlockContainer, editor));
|
23067 |
editor.on('keyup compositionstart', curry(handleBlockContainer, editor));
|
| 22671 |
};
|
23068 |
};
|
| Línea 22672... |
Línea 23069... |
| 22672 |
|
23069 |
|
| 22673 |
const isContentEditableFalse$3 = isContentEditableFalse$b;
|
23070 |
const isContentEditableFalse$4 = isContentEditableFalse$b;
|
| 22674 |
const moveToCeFalseHorizontally = (direction, editor, range) => moveHorizontally(editor, direction, range, isBeforeContentEditableFalse, isAfterContentEditableFalse, isContentEditableFalse$3);
|
23071 |
const moveToCeFalseHorizontally = (direction, editor, range) => moveHorizontally(editor, direction, range, isBeforeContentEditableFalse, isAfterContentEditableFalse, isContentEditableFalse$4);
|
| 22675 |
const moveToCeFalseVertically = (direction, editor, range) => {
|
23072 |
const moveToCeFalseVertically = (direction, editor, range) => {
|
| 22676 |
const isBefore = caretPosition => isBeforeContentEditableFalse(caretPosition) || isBeforeTable(caretPosition);
|
23073 |
const isBefore = caretPosition => isBeforeContentEditableFalse(caretPosition) || isBeforeTable(caretPosition);
|
| 22677 |
const isAfter = caretPosition => isAfterContentEditableFalse(caretPosition) || isAfterTable(caretPosition);
|
23074 |
const isAfter = caretPosition => isAfterContentEditableFalse(caretPosition) || isAfterTable(caretPosition);
|
| 22678 |
return moveVertically(editor, direction, range, isBefore, isAfter, isContentEditableFalse$3);
|
23075 |
return moveVertically(editor, direction, range, isBefore, isAfter, isContentEditableFalse$4);
|
| 22679 |
};
|
23076 |
};
|
| 22680 |
const createTextBlock = editor => {
|
23077 |
const createTextBlock = editor => {
|
| 22681 |
const textBlock = editor.dom.create(getForcedRootBlock(editor));
|
23078 |
const textBlock = editor.dom.create(getForcedRootBlock(editor));
|
| 22682 |
textBlock.innerHTML = '<br data-mce-bogus="1">';
|
23079 |
textBlock.innerHTML = '<br data-mce-bogus="1">';
|
| Línea 22702... |
Línea 23099... |
| 22702 |
editor.selection.collapse();
|
23099 |
editor.selection.collapse();
|
| 22703 |
}
|
23100 |
}
|
| 22704 |
}
|
23101 |
}
|
| 22705 |
};
|
23102 |
};
|
| 22706 |
const getHorizontalRange = (editor, forward) => {
|
23103 |
const getHorizontalRange = (editor, forward) => {
|
| 22707 |
const direction = forward ? HDirection.Forwards : HDirection.Backwards;
|
23104 |
const direction = forward ? 1 : -1;
|
| 22708 |
const range = editor.selection.getRng();
|
23105 |
const range = editor.selection.getRng();
|
| 22709 |
return moveToCeFalseHorizontally(direction, editor, range).orThunk(() => {
|
23106 |
return moveToCeFalseHorizontally(direction, editor, range).orThunk(() => {
|
| 22710 |
exitPreBlock(editor, direction, range);
|
23107 |
exitPreBlock(editor, direction, range);
|
| 22711 |
return Optional.none();
|
23108 |
return Optional.none();
|
| 22712 |
});
|
23109 |
});
|
| Línea 22829... |
Línea 23226... |
| 22829 |
const action = (f, ...x) => () => f.apply(null, x);
|
23226 |
const action = (f, ...x) => () => f.apply(null, x);
|
| 22830 |
const execute = (patterns, evt) => find$2(match$1(patterns, evt), pattern => pattern.action());
|
23227 |
const execute = (patterns, evt) => find$2(match$1(patterns, evt), pattern => pattern.action());
|
| 22831 |
const executeWithDelayedAction = (patterns, evt) => findMap(matchDelayed(patterns, evt), pattern => pattern.action());
|
23228 |
const executeWithDelayedAction = (patterns, evt) => findMap(matchDelayed(patterns, evt), pattern => pattern.action());
|
| Línea 22832... |
Línea 23229... |
| 22832 |
|
23229 |
|
| 22833 |
const moveH$1 = (editor, forward) => {
|
23230 |
const moveH$1 = (editor, forward) => {
|
| 22834 |
const direction = forward ? HDirection.Forwards : HDirection.Backwards;
|
23231 |
const direction = forward ? 1 : -1;
|
| 22835 |
const range = editor.selection.getRng();
|
23232 |
const range = editor.selection.getRng();
|
| 22836 |
return moveHorizontally(editor, direction, range, isBeforeMedia, isAfterMedia, isMedia$2).exists(newRange => {
|
23233 |
return moveHorizontally(editor, direction, range, isBeforeMedia, isAfterMedia, isMedia$2).exists(newRange => {
|
| 22837 |
moveToRange(editor, newRange);
|
23234 |
moveToRange(editor, newRange);
|
| 22838 |
return true;
|
23235 |
return true;
|
| Línea 22935... |
Línea 23332... |
| 22935 |
}, info => {
|
23332 |
}, info => {
|
| 22936 |
return walk(info.all, current, info.index, -1, isEligible);
|
23333 |
return walk(info.all, current, info.index, -1, isEligible);
|
| 22937 |
});
|
23334 |
});
|
| 22938 |
};
|
23335 |
};
|
| Línea -... |
Línea 23336... |
| - |
|
23336 |
|
| - |
|
23337 |
const isTextNodeWithCursorPosition = el => getOption(el).filter(text => text.trim().length !== 0 || text.indexOf(nbsp) > -1).isSome();
|
| - |
|
23338 |
const isContentEditableFalse$3 = elem => isHTMLElement$1(elem) && get$9(elem, 'contenteditable') === 'false';
|
| - |
|
23339 |
const elementsWithCursorPosition = [
|
| - |
|
23340 |
'img',
|
| - |
|
23341 |
'br'
|
| - |
|
23342 |
];
|
| - |
|
23343 |
const isCursorPosition = elem => {
|
| - |
|
23344 |
const hasCursorPosition = isTextNodeWithCursorPosition(elem);
|
| - |
|
23345 |
return hasCursorPosition || contains$2(elementsWithCursorPosition, name(elem)) || isContentEditableFalse$3(elem);
|
| - |
|
23346 |
};
|
| - |
|
23347 |
|
| - |
|
23348 |
const first = element => descendant$2(element, isCursorPosition);
|
| 22939 |
|
23349 |
|
| 22940 |
const deflate = (rect, delta) => ({
|
23350 |
const deflate = (rect, delta) => ({
|
| 22941 |
left: rect.left - delta,
|
23351 |
left: rect.left - delta,
|
| 22942 |
top: rect.top - delta,
|
23352 |
top: rect.top - delta,
|
| 22943 |
right: rect.right + delta * 2,
|
23353 |
right: rect.right + delta * 2,
|
| Línea 22975... |
Línea 23385... |
| 22975 |
const isAbove = (corner, y) => corner.y < y;
|
23385 |
const isAbove = (corner, y) => corner.y < y;
|
| 22976 |
const isBelow = (corner, y) => corner.y > y;
|
23386 |
const isBelow = (corner, y) => corner.y > y;
|
| 22977 |
const getClosestCellAbove = curry(getClosestCell, getBottomValue, isAbove);
|
23387 |
const getClosestCellAbove = curry(getClosestCell, getBottomValue, isAbove);
|
| 22978 |
const getClosestCellBelow = curry(getClosestCell, getTopValue, isBelow);
|
23388 |
const getClosestCellBelow = curry(getClosestCell, getTopValue, isBelow);
|
| 22979 |
const findClosestPositionInAboveCell = (table, pos) => head(pos.getClientRects()).bind(rect => getClosestCellAbove(table, rect.left, rect.top)).bind(cell => findClosestHorizontalPosition(getLastLinePositions(cell), pos));
|
23389 |
const findClosestPositionInAboveCell = (table, pos) => head(pos.getClientRects()).bind(rect => getClosestCellAbove(table, rect.left, rect.top)).bind(cell => findClosestHorizontalPosition(getLastLinePositions(cell), pos));
|
| 22980 |
const findClosestPositionInBelowCell = (table, pos) => last$3(pos.getClientRects()).bind(rect => getClosestCellBelow(table, rect.left, rect.top)).bind(cell => findClosestHorizontalPosition(getFirstLinePositions(cell), pos));
|
23390 |
const findClosestPositionInBelowCell = (table, pos) => last$2(pos.getClientRects()).bind(rect => getClosestCellBelow(table, rect.left, rect.top)).bind(cell => findClosestHorizontalPosition(getFirstLinePositions(cell), pos));
|
| Línea 22981... |
Línea 23391... |
| 22981 |
|
23391 |
|
| 22982 |
const hasNextBreak = (getPositionsUntil, scope, lineInfo) => lineInfo.breakAt.exists(breakPos => getPositionsUntil(scope, breakPos).breakAt.isSome());
|
23392 |
const hasNextBreak = (getPositionsUntil, scope, lineInfo) => lineInfo.breakAt.exists(breakPos => getPositionsUntil(scope, breakPos).breakAt.isSome());
|
| 22983 |
const startsWithWrapBreak = lineInfo => lineInfo.breakType === BreakType.Wrap && lineInfo.positions.length === 0;
|
23393 |
const startsWithWrapBreak = lineInfo => lineInfo.breakType === BreakType.Wrap && lineInfo.positions.length === 0;
|
| 22984 |
const startsWithBrBreak = lineInfo => lineInfo.breakType === BreakType.Br && lineInfo.positions.length === 1;
|
23394 |
const startsWithBrBreak = lineInfo => lineInfo.breakType === BreakType.Br && lineInfo.positions.length === 1;
|
| Línea 23052... |
Línea 23462... |
| 23052 |
return cell.fold(Optional.none, Optional.none, (_current, next) => {
|
23462 |
return cell.fold(Optional.none, Optional.none, (_current, next) => {
|
| 23053 |
return first(next).map(cell => {
|
23463 |
return first(next).map(cell => {
|
| 23054 |
return getCellFirstCursorPosition(cell);
|
23464 |
return getCellFirstCursorPosition(cell);
|
| 23055 |
});
|
23465 |
});
|
| 23056 |
}, current => {
|
23466 |
}, current => {
|
| - |
|
23467 |
if (editor.mode.isReadOnly()) {
|
| - |
|
23468 |
return Optional.none();
|
| - |
|
23469 |
}
|
| 23057 |
editor.execCommand('mceTableInsertRowAfter');
|
23470 |
editor.execCommand('mceTableInsertRowAfter');
|
| 23058 |
return tabForward(editor, isRoot, current);
|
23471 |
return tabForward(editor, isRoot, current);
|
| 23059 |
});
|
23472 |
});
|
| 23060 |
};
|
23473 |
};
|
| 23061 |
const tabForward = (editor, isRoot, cell) => tabGo(editor, isRoot, next(cell, isEditable$2));
|
23474 |
const tabForward = (editor, isRoot, cell) => tabGo(editor, isRoot, next(cell, isEditable$2));
|
| Línea 23216... |
Línea 23629... |
| 23216 |
'IMG',
|
23629 |
'IMG',
|
| 23217 |
'HR',
|
23630 |
'HR',
|
| 23218 |
'INPUT'
|
23631 |
'INPUT'
|
| 23219 |
], node.nodeName) || dom.getContentEditable(node) === 'false';
|
23632 |
], node.nodeName) || dom.getContentEditable(node) === 'false';
|
| 23220 |
const textBefore = (node, offset, rootNode) => {
|
23633 |
const textBefore = (node, offset, rootNode) => {
|
| 23221 |
if (isText$a(node) && offset >= 0) {
|
23634 |
if (isText$b(node) && offset >= 0) {
|
| 23222 |
return Optional.some(point(node, offset));
|
23635 |
return Optional.some(point(node, offset));
|
| 23223 |
} else {
|
23636 |
} else {
|
| 23224 |
const textSeeker = TextSeeker(DOM$7);
|
23637 |
const textSeeker = TextSeeker(DOM$7);
|
| 23225 |
return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).map(prev => point(prev.container, prev.container.data.length));
|
23638 |
return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).map(prev => point(prev.container, prev.container.data.length));
|
| 23226 |
}
|
23639 |
}
|
| 23227 |
};
|
23640 |
};
|
| 23228 |
const textAfter = (node, offset, rootNode) => {
|
23641 |
const textAfter = (node, offset, rootNode) => {
|
| 23229 |
if (isText$a(node) && offset >= node.length) {
|
23642 |
if (isText$b(node) && offset >= node.length) {
|
| 23230 |
return Optional.some(point(node, offset));
|
23643 |
return Optional.some(point(node, offset));
|
| 23231 |
} else {
|
23644 |
} else {
|
| 23232 |
const textSeeker = TextSeeker(DOM$7);
|
23645 |
const textSeeker = TextSeeker(DOM$7);
|
| 23233 |
return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).map(prev => point(prev.container, 0));
|
23646 |
return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).map(prev => point(prev.container, 0));
|
| 23234 |
}
|
23647 |
}
|
| 23235 |
};
|
23648 |
};
|
| 23236 |
const scanLeft = (node, offset, rootNode) => {
|
23649 |
const scanLeft = (node, offset, rootNode) => {
|
| 23237 |
if (!isText$a(node)) {
|
23650 |
if (!isText$b(node)) {
|
| 23238 |
return Optional.none();
|
23651 |
return Optional.none();
|
| 23239 |
}
|
23652 |
}
|
| 23240 |
const text = node.data;
|
23653 |
const text = node.data;
|
| 23241 |
if (offset >= 0 && offset <= text.length) {
|
23654 |
if (offset >= 0 && offset <= text.length) {
|
| 23242 |
return Optional.some(point(node, offset));
|
23655 |
return Optional.some(point(node, offset));
|
| Línea 23247... |
Línea 23660... |
| 23247 |
return scanLeft(prev.container, offset + prevText.length, rootNode);
|
23660 |
return scanLeft(prev.container, offset + prevText.length, rootNode);
|
| 23248 |
});
|
23661 |
});
|
| 23249 |
}
|
23662 |
}
|
| 23250 |
};
|
23663 |
};
|
| 23251 |
const scanRight = (node, offset, rootNode) => {
|
23664 |
const scanRight = (node, offset, rootNode) => {
|
| 23252 |
if (!isText$a(node)) {
|
23665 |
if (!isText$b(node)) {
|
| 23253 |
return Optional.none();
|
23666 |
return Optional.none();
|
| 23254 |
}
|
23667 |
}
|
| 23255 |
const text = node.data;
|
23668 |
const text = node.data;
|
| 23256 |
if (offset <= text.length) {
|
23669 |
if (offset <= text.length) {
|
| 23257 |
return Optional.some(point(node, offset));
|
23670 |
return Optional.some(point(node, offset));
|
| Línea 23263... |
Línea 23676... |
| 23263 |
const repeatLeft = (dom, node, offset, process, rootNode) => {
|
23676 |
const repeatLeft = (dom, node, offset, process, rootNode) => {
|
| 23264 |
const search = TextSeeker(dom, isBoundary(dom));
|
23677 |
const search = TextSeeker(dom, isBoundary(dom));
|
| 23265 |
return Optional.from(search.backwards(node, offset, process, rootNode));
|
23678 |
return Optional.from(search.backwards(node, offset, process, rootNode));
|
| 23266 |
};
|
23679 |
};
|
| Línea 23267... |
Línea 23680... |
| 23267 |
|
23680 |
|
| 23268 |
const isValidTextRange = rng => rng.collapsed && isText$a(rng.startContainer);
|
23681 |
const isValidTextRange = rng => rng.collapsed && isText$b(rng.startContainer);
|
| 23269 |
const getText = rng => trim$2(rng.toString().replace(/\u00A0/g, ' '));
|
23682 |
const getText = rng => trim$2(rng.toString().replace(/\u00A0/g, ' '));
|
| Línea 23270... |
Línea 23683... |
| 23270 |
const isWhitespace = chr => chr !== '' && ' \xA0\f\n\r\t\x0B'.indexOf(chr) !== -1;
|
23683 |
const isWhitespace = chr => chr !== '' && ' \xA0\uFEFF\f\n\r\t\x0B'.indexOf(chr) !== -1;
|
| 23271 |
|
23684 |
|
| 23272 |
const stripTrigger = (text, trigger) => text.substring(trigger.length);
|
23685 |
const stripTrigger = (text, trigger) => text.substring(trigger.length);
|
| 23273 |
const findTrigger = (text, index, trigger) => {
|
23686 |
const findTrigger = (text, index, trigger, includeWhitespace = false) => {
|
| 23274 |
let i;
|
23687 |
let i;
|
| 23275 |
const firstChar = trigger.charAt(0);
|
23688 |
const firstChar = trigger.charAt(0);
|
| 23276 |
for (i = index - 1; i >= 0; i--) {
|
23689 |
for (i = index - 1; i >= 0; i--) {
|
| 23277 |
const char = text.charAt(i);
|
23690 |
const char = text.charAt(i);
|
| 23278 |
if (isWhitespace(char)) {
|
23691 |
if (!includeWhitespace && isWhitespace(char)) {
|
| 23279 |
return Optional.none();
|
23692 |
return Optional.none();
|
| 23280 |
}
|
23693 |
}
|
| 23281 |
if (firstChar === char && contains$1(text, trigger, i, index)) {
|
23694 |
if (firstChar === char && contains$1(text, trigger, i, index)) {
|
| 23282 |
break;
|
23695 |
break;
|
| 23283 |
}
|
23696 |
}
|
| 23284 |
}
|
23697 |
}
|
| 23285 |
return Optional.some(i);
|
23698 |
return Optional.some(i);
|
| 23286 |
};
|
23699 |
};
|
| 23287 |
const findStart = (dom, initRange, trigger, minChars = 0) => {
|
23700 |
const getContext = (dom, initRange, trigger, includeWhitespace = false) => {
|
| 23288 |
if (!isValidTextRange(initRange)) {
|
23701 |
if (!isValidTextRange(initRange)) {
|
| 23289 |
return Optional.none();
|
23702 |
return Optional.none();
|
| 23290 |
}
|
23703 |
}
|
| 23291 |
const buffer = {
|
23704 |
const buffer = {
|
| 23292 |
text: '',
|
23705 |
text: '',
|
| 23293 |
offset: 0
|
23706 |
offset: 0
|
| 23294 |
};
|
23707 |
};
|
| 23295 |
const findTriggerIndex = (element, offset, text) => {
|
23708 |
const findTriggerIndex = (element, offset, text) => {
|
| 23296 |
buffer.text = text + buffer.text;
|
23709 |
buffer.text = text + buffer.text;
|
| 23297 |
buffer.offset += offset;
|
23710 |
buffer.offset += offset;
|
| 23298 |
return findTrigger(buffer.text, buffer.offset, trigger).getOr(offset);
|
23711 |
return findTrigger(buffer.text, buffer.offset, trigger, includeWhitespace).getOr(offset);
|
| 23299 |
};
|
23712 |
};
|
| 23300 |
const root = dom.getParent(initRange.startContainer, dom.isBlock) || dom.getRoot();
|
23713 |
const root = dom.getParent(initRange.startContainer, dom.isBlock) || dom.getRoot();
|
| 23301 |
return repeatLeft(dom, initRange.startContainer, initRange.startOffset, findTriggerIndex, root).bind(spot => {
|
23714 |
return repeatLeft(dom, initRange.startContainer, initRange.startOffset, findTriggerIndex, root).bind(spot => {
|
| Línea 23305... |
Línea 23718... |
| 23305 |
if (range.collapsed) {
|
23718 |
if (range.collapsed) {
|
| 23306 |
return Optional.none();
|
23719 |
return Optional.none();
|
| 23307 |
}
|
23720 |
}
|
| 23308 |
const text = getText(range);
|
23721 |
const text = getText(range);
|
| 23309 |
const triggerIndex = text.lastIndexOf(trigger);
|
23722 |
const triggerIndex = text.lastIndexOf(trigger);
|
| 23310 |
if (triggerIndex !== 0 || stripTrigger(text, trigger).length < minChars) {
|
23723 |
if (triggerIndex !== 0) {
|
| 23311 |
return Optional.none();
|
23724 |
return Optional.none();
|
| 23312 |
} else {
|
23725 |
} else {
|
| 23313 |
return Optional.some({
|
23726 |
return Optional.some({
|
| 23314 |
text: stripTrigger(text, trigger),
|
23727 |
text: stripTrigger(text, trigger),
|
| 23315 |
range,
|
23728 |
range,
|
| 23316 |
trigger
|
23729 |
trigger
|
| 23317 |
});
|
23730 |
});
|
| 23318 |
}
|
23731 |
}
|
| 23319 |
});
|
23732 |
});
|
| 23320 |
};
|
23733 |
};
|
| 23321 |
const getContext = (dom, initRange, trigger, minChars = 0) => detect$1(SugarElement.fromDom(initRange.startContainer)).fold(() => findStart(dom, initRange, trigger, minChars), elm => {
|
- |
|
| 23322 |
const range = dom.createRng();
|
- |
|
| 23323 |
range.selectNode(elm.dom);
|
- |
|
| 23324 |
const text = getText(range);
|
- |
|
| 23325 |
return Optional.some({
|
- |
|
| 23326 |
range,
|
- |
|
| 23327 |
text: stripTrigger(text, trigger),
|
- |
|
| 23328 |
trigger
|
- |
|
| 23329 |
});
|
- |
|
| 23330 |
});
|
- |
|
| Línea 23331... |
Línea 23734... |
| 23331 |
|
23734 |
|
| 23332 |
const isText$1 = node => node.nodeType === TEXT;
|
23735 |
const isText$1 = node => node.nodeType === TEXT;
|
| 23333 |
const isElement = node => node.nodeType === ELEMENT;
|
23736 |
const isElement = node => node.nodeType === ELEMENT;
|
| 23334 |
const toLast = node => {
|
23737 |
const toLast = node => {
|
| Línea 23666... |
Línea 24069... |
| 23666 |
return {
|
24069 |
return {
|
| 23667 |
extract,
|
24070 |
extract,
|
| 23668 |
toString
|
24071 |
toString
|
| 23669 |
};
|
24072 |
};
|
| 23670 |
};
|
24073 |
};
|
| - |
|
24074 |
const oneOf = (props, rawF) => {
|
| - |
|
24075 |
const f = rawF !== undefined ? rawF : identity;
|
| - |
|
24076 |
const extract = (path, val) => {
|
| - |
|
24077 |
const errors = [];
|
| - |
|
24078 |
for (const prop of props) {
|
| - |
|
24079 |
const res = prop.extract(path, val);
|
| - |
|
24080 |
if (res.stype === SimpleResultType.Value) {
|
| - |
|
24081 |
return {
|
| - |
|
24082 |
stype: SimpleResultType.Value,
|
| - |
|
24083 |
svalue: f(res.svalue)
|
| - |
|
24084 |
};
|
| - |
|
24085 |
}
|
| - |
|
24086 |
errors.push(res);
|
| - |
|
24087 |
}
|
| - |
|
24088 |
return ResultCombine.consolidateArr(errors);
|
| - |
|
24089 |
};
|
| - |
|
24090 |
const toString = () => 'oneOf(' + map$3(props, prop => prop.toString()).join(', ') + ')';
|
| - |
|
24091 |
return {
|
| - |
|
24092 |
extract,
|
| - |
|
24093 |
toString
|
| - |
|
24094 |
};
|
| - |
|
24095 |
};
|
| - |
|
24096 |
const arrOfObj = compose(arrOf, objOf);
|
| Línea 23671... |
Línea 24097... |
| 23671 |
|
24097 |
|
| 23672 |
const valueOf = validator => value(v => validator(v).fold(SimpleResult.serror, SimpleResult.svalue));
|
24098 |
const valueOf = validator => value(v => validator(v).fold(SimpleResult.serror, SimpleResult.svalue));
|
| 23673 |
const extractValue = (label, prop, obj) => {
|
24099 |
const extractValue = (label, prop, obj) => {
|
| 23674 |
const res = prop.extract([label], obj);
|
24100 |
const res = prop.extract([label], obj);
|
| Línea 23696... |
Línea 24122... |
| 23696 |
const field = field$1;
|
24122 |
const field = field$1;
|
| 23697 |
const customField = customField$1;
|
24123 |
const customField = customField$1;
|
| 23698 |
const validateEnum = values => valueOf(value => contains$2(values, value) ? Result.value(value) : Result.error(`Unsupported value: "${ value }", choose one of "${ values.join(', ') }".`));
|
24124 |
const validateEnum = values => valueOf(value => contains$2(values, value) ? Result.value(value) : Result.error(`Unsupported value: "${ value }", choose one of "${ values.join(', ') }".`));
|
| 23699 |
const requiredOf = (key, schema) => field(key, key, required(), schema);
|
24125 |
const requiredOf = (key, schema) => field(key, key, required(), schema);
|
| 23700 |
const requiredString = key => requiredOf(key, string);
|
24126 |
const requiredString = key => requiredOf(key, string);
|
| - |
|
24127 |
const requiredStringEnum = (key, values) => field(key, key, required(), validateEnum(values));
|
| 23701 |
const requiredFunction = key => requiredOf(key, functionProcessor);
|
24128 |
const requiredFunction = key => requiredOf(key, functionProcessor);
|
| 23702 |
const requiredArrayOf = (key, schema) => field(key, key, required(), arrOf(schema));
|
24129 |
const requiredArrayOf = (key, schema) => field(key, key, required(), arrOf(schema));
|
| 23703 |
const optionOf = (key, schema) => field(key, key, asOption(), schema);
|
24130 |
const optionOf = (key, schema) => field(key, key, asOption(), schema);
|
| 23704 |
const optionString = key => optionOf(key, string);
|
24131 |
const optionString = key => optionOf(key, string);
|
| 23705 |
const optionFunction = key => optionOf(key, functionProcessor);
|
24132 |
const optionFunction = key => optionOf(key, functionProcessor);
|
| Línea 23735... |
Línea 24162... |
| 23735 |
optionFunction('matches'),
|
24162 |
optionFunction('matches'),
|
| 23736 |
fetch$1,
|
24163 |
fetch$1,
|
| 23737 |
onAction,
|
24164 |
onAction,
|
| 23738 |
defaultedArrayOf('highlightOn', [], string)
|
24165 |
defaultedArrayOf('highlightOn', [], string)
|
| 23739 |
]);
|
24166 |
]);
|
| 23740 |
const createAutocompleter = spec => asRaw('Autocompleter', autocompleterSchema, {
|
24167 |
const createAutocompleter = spec => asRaw('Autocompleter', autocompleterSchema, spec);
|
| 23741 |
trigger: spec.ch,
|
- |
|
| 23742 |
...spec
|
- |
|
| 23743 |
});
|
- |
|
| Línea 23744... |
Línea 24168... |
| 23744 |
|
24168 |
|
| 23745 |
const baseToolbarButtonFields = [
|
24169 |
const baseToolbarButtonFields = [
|
| 23746 |
enabled,
|
24170 |
enabled,
|
| 23747 |
optionalTooltip,
|
24171 |
optionalTooltip,
|
| 23748 |
optionalIcon,
|
24172 |
optionalIcon,
|
| 23749 |
optionalText,
|
24173 |
optionalText,
|
| - |
|
24174 |
onSetup,
|
| 23750 |
onSetup
|
24175 |
defaultedString('context', 'mode:design')
|
| Línea 23751... |
Línea 24176... |
| 23751 |
];
|
24176 |
];
|
| Línea 23752... |
Línea 24177... |
| 23752 |
|
24177 |
|
| Línea 23765... |
Línea 24190... |
| 23765 |
])
|
24190 |
])
|
| 23766 |
];
|
24191 |
];
|
| Línea 23767... |
Línea 24192... |
| 23767 |
|
24192 |
|
| 23768 |
const contextButtonFields = baseToolbarButtonFields.concat([
|
24193 |
const contextButtonFields = baseToolbarButtonFields.concat([
|
| - |
|
24194 |
defaultedType('contextformbutton'),
|
| 23769 |
defaultedType('contextformbutton'),
|
24195 |
defaultedString('align', 'end'),
|
| 23770 |
primary,
|
24196 |
primary,
|
| 23771 |
onAction,
|
24197 |
onAction,
|
| 23772 |
customField('original', identity)
|
24198 |
customField('original', identity)
|
| 23773 |
]);
|
24199 |
]);
|
| 23774 |
const contextToggleButtonFields = baseToolbarToggleButtonFields.concat([
|
24200 |
const contextToggleButtonFields = baseToolbarToggleButtonFields.concat([
|
| - |
|
24201 |
defaultedType('contextformbutton'),
|
| 23775 |
defaultedType('contextformbutton'),
|
24202 |
defaultedString('align', 'end'),
|
| 23776 |
primary,
|
24203 |
primary,
|
| 23777 |
onAction,
|
24204 |
onAction,
|
| 23778 |
customField('original', identity)
|
24205 |
customField('original', identity)
|
| 23779 |
]);
|
24206 |
]);
|
| 23780 |
const launchButtonFields = baseToolbarButtonFields.concat([defaultedType('contextformbutton')]);
|
24207 |
const launchButtonFields = baseToolbarButtonFields.concat([defaultedType('contextformbutton')]);
|
| 23781 |
const launchToggleButtonFields = baseToolbarToggleButtonFields.concat([defaultedType('contextformtogglebutton')]);
|
24208 |
const launchToggleButtonFields = baseToolbarToggleButtonFields.concat([defaultedType('contextformtogglebutton')]);
|
| 23782 |
const toggleOrNormal = choose('type', {
|
24209 |
const toggleOrNormal = choose('type', {
|
| 23783 |
contextformbutton: contextButtonFields,
|
24210 |
contextformbutton: contextButtonFields,
|
| 23784 |
contextformtogglebutton: contextToggleButtonFields
|
24211 |
contextformtogglebutton: contextToggleButtonFields
|
| 23785 |
});
|
- |
|
| 23786 |
objOf([
|
24212 |
});
|
| 23787 |
defaultedType('contextform'),
|
- |
|
| 23788 |
defaultedFunction('initValue', constant('')),
|
24213 |
const baseContextFormFields = [
|
| 23789 |
optionalLabel,
|
24214 |
optionalLabel,
|
| 23790 |
requiredArrayOf('commands', toggleOrNormal),
|
24215 |
requiredArrayOf('commands', toggleOrNormal),
|
| 23791 |
optionOf('launch', choose('type', {
|
24216 |
optionOf('launch', choose('type', {
|
| 23792 |
contextformbutton: launchButtonFields,
|
24217 |
contextformbutton: launchButtonFields,
|
| - |
|
24218 |
contextformtogglebutton: launchToggleButtonFields
|
| - |
|
24219 |
})),
|
| - |
|
24220 |
defaultedFunction('onInput', noop),
|
| - |
|
24221 |
defaultedFunction('onSetup', noop)
|
| - |
|
24222 |
];
|
| - |
|
24223 |
const contextFormFields = [
|
| - |
|
24224 |
...contextBarFields,
|
| - |
|
24225 |
...baseContextFormFields,
|
| - |
|
24226 |
requiredStringEnum('type', ['contextform']),
|
| - |
|
24227 |
defaultedFunction('initValue', constant('')),
|
| - |
|
24228 |
optionString('placeholder')
|
| - |
|
24229 |
];
|
| - |
|
24230 |
const contextSliderFormFields = [
|
| - |
|
24231 |
...contextBarFields,
|
| - |
|
24232 |
...baseContextFormFields,
|
| - |
|
24233 |
requiredStringEnum('type', ['contextsliderform']),
|
| - |
|
24234 |
defaultedFunction('initValue', constant(0)),
|
| - |
|
24235 |
defaultedFunction('min', constant(0)),
|
| - |
|
24236 |
defaultedFunction('max', constant(100))
|
| - |
|
24237 |
];
|
| - |
|
24238 |
const contextSizeInputFormFields = [
|
| - |
|
24239 |
...contextBarFields,
|
| - |
|
24240 |
...baseContextFormFields,
|
| - |
|
24241 |
requiredStringEnum('type', ['contextsizeinputform']),
|
| - |
|
24242 |
defaultedFunction('initValue', constant({
|
| - |
|
24243 |
width: '',
|
| 23793 |
contextformtogglebutton: launchToggleButtonFields
|
24244 |
height: ''
|
| - |
|
24245 |
}))
|
| - |
|
24246 |
];
|
| - |
|
24247 |
choose('type', {
|
| - |
|
24248 |
contextform: contextFormFields,
|
| - |
|
24249 |
contextsliderform: contextSliderFormFields,
|
| - |
|
24250 |
contextsizeinputform: contextSizeInputFormFields
|
| - |
|
24251 |
});
|
| - |
|
24252 |
|
| - |
|
24253 |
objOf([
|
| - |
|
24254 |
defaultedType('contexttoolbar'),
|
| - |
|
24255 |
requiredOf('items', oneOf([
|
| - |
|
24256 |
string,
|
| - |
|
24257 |
arrOfObj([
|
| - |
|
24258 |
optionString('name'),
|
| - |
|
24259 |
optionString('label'),
|
| - |
|
24260 |
requiredArrayOf('items', string)
|
| - |
|
24261 |
])
|
| 23794 |
}))
|
24262 |
]))
|
| Línea 23795... |
Línea 24263... |
| 23795 |
].concat(contextBarFields));
|
24263 |
].concat(contextBarFields));
|
| 23796 |
|
24264 |
|
| 23797 |
const register$2 = editor => {
|
24265 |
const register$2 = editor => {
|
| Línea 23808... |
Línea 24276... |
| 23808 |
lookupByTrigger
|
24276 |
lookupByTrigger
|
| 23809 |
};
|
24277 |
};
|
| 23810 |
};
|
24278 |
};
|
| Línea 23811... |
Línea 24279... |
| 23811 |
|
24279 |
|
| 23812 |
const setupEditorInput = (editor, api) => {
|
24280 |
const setupEditorInput = (editor, api) => {
|
| 23813 |
const update = last$1(api.load, 50);
|
24281 |
const update = last(api.load, 50);
|
| 23814 |
editor.on('keypress compositionend', e => {
|
24282 |
editor.on('input', e => {
|
| 23815 |
if (e.which === 27) {
|
24283 |
if (e.inputType === 'insertCompositionText' && !editor.composing) {
|
| 23816 |
return;
|
24284 |
return;
|
| 23817 |
}
|
24285 |
}
|
| 23818 |
update.throttle();
|
24286 |
update.throttle();
|
| 23819 |
});
|
24287 |
});
|
| 23820 |
editor.on('keydown', e => {
|
24288 |
editor.on('keydown', e => {
|
| 23821 |
const keyCode = e.which;
|
24289 |
const keyCode = e.which;
|
| 23822 |
if (keyCode === 8) {
|
24290 |
if (keyCode === 8) {
|
| 23823 |
update.throttle();
|
24291 |
update.throttle();
|
| - |
|
24292 |
} else if (keyCode === 27) {
|
| 23824 |
} else if (keyCode === 27) {
|
24293 |
update.cancel();
|
| - |
|
24294 |
api.cancelIfNecessary();
|
| - |
|
24295 |
} else if (keyCode === 38 || keyCode === 40) {
|
| 23825 |
api.cancelIfNecessary();
|
24296 |
update.cancel();
|
| 23826 |
}
|
24297 |
}
|
| 23827 |
});
|
24298 |
}, true);
|
| 23828 |
editor.on('remove', update.cancel);
|
24299 |
editor.on('remove', update.cancel);
|
| 23829 |
};
|
24300 |
};
|
| 23830 |
const setup$k = editor => {
|
24301 |
const setup$k = editor => {
|
| 23831 |
const activeAutocompleter = value$2();
|
24302 |
const activeAutocompleter = value$2();
|
| 23832 |
const uiActive = Cell(false);
|
24303 |
const uiActive = Cell(false);
|
| 23833 |
const isActive = activeAutocompleter.isSet;
|
24304 |
const isActive = activeAutocompleter.isSet;
|
| 23834 |
const cancelIfNecessary = () => {
|
24305 |
const cancelIfNecessary = () => {
|
| 23835 |
if (isActive()) {
|
- |
|
| 23836 |
removeAutocompleterDecoration(editor);
|
24306 |
if (isActive()) {
|
| 23837 |
fireAutocompleterEnd(editor);
|
24307 |
fireAutocompleterEnd(editor);
|
| 23838 |
uiActive.set(false);
|
24308 |
uiActive.set(false);
|
| 23839 |
activeAutocompleter.clear();
|
24309 |
activeAutocompleter.clear();
|
| 23840 |
}
|
24310 |
}
|
| 23841 |
};
|
24311 |
};
|
| 23842 |
const commenceIfNecessary = context => {
|
24312 |
const commenceIfNecessary = context => {
|
| 23843 |
if (!isActive()) {
|
- |
|
| 23844 |
addAutocompleterDecoration(editor, context.range);
|
24313 |
if (!isActive()) {
|
| 23845 |
activeAutocompleter.set({
|
24314 |
activeAutocompleter.set({
|
| 23846 |
trigger: context.trigger,
|
24315 |
trigger: context.trigger,
|
| 23847 |
matchLength: context.text.length
|
24316 |
matchLength: context.text.length
|
| 23848 |
});
|
24317 |
});
|
| 23849 |
}
|
24318 |
}
|
| 23850 |
};
|
24319 |
};
|
| 23851 |
const getAutocompleters = cached(() => register$2(editor));
|
24320 |
const getAutocompleters = cached(() => register$2(editor));
|
| 23852 |
const doLookup = fetchOptions => activeAutocompleter.get().map(ac => getContext(editor.dom, editor.selection.getRng(), ac.trigger).bind(newContext => lookupWithContext(editor, getAutocompleters, newContext, fetchOptions))).getOrThunk(() => lookup(editor, getAutocompleters));
|
24321 |
const doLookup = fetchOptions => activeAutocompleter.get().map(ac => getContext(editor.dom, editor.selection.getRng(), ac.trigger, true).bind(newContext => lookupWithContext(editor, getAutocompleters, newContext, fetchOptions))).getOrThunk(() => lookup(editor, getAutocompleters));
|
| 23853 |
const load = fetchOptions => {
|
24322 |
const load = fetchOptions => {
|
| 23854 |
doLookup(fetchOptions).fold(cancelIfNecessary, lookupInfo => {
|
24323 |
doLookup(fetchOptions).fold(cancelIfNecessary, lookupInfo => {
|
| 23855 |
commenceIfNecessary(lookupInfo.context);
|
24324 |
commenceIfNecessary(lookupInfo.context);
|
| 23856 |
lookupInfo.lookupData.then(lookupData => {
|
24325 |
lookupInfo.lookupData.then(lookupData => {
|
| 23857 |
activeAutocompleter.get().map(ac => {
|
24326 |
activeAutocompleter.get().map(ac => {
|
| 23858 |
const context = lookupInfo.context;
|
24327 |
const context = lookupInfo.context;
|
| 23859 |
if (ac.trigger === context.trigger) {
|
- |
|
| 23860 |
if (context.text.length - ac.matchLength >= 10) {
|
24328 |
if (ac.trigger !== context.trigger) {
|
| 23861 |
cancelIfNecessary();
|
24329 |
return;
|
| 23862 |
} else {
|
24330 |
}
|
| 23863 |
activeAutocompleter.set({
|
24331 |
activeAutocompleter.set({
|
| 23864 |
...ac,
|
24332 |
...ac,
|
| 23865 |
matchLength: context.text.length
|
24333 |
matchLength: context.text.length
|
| 23866 |
});
|
24334 |
});
|
| - |
|
24335 |
if (uiActive.get()) {
|
| 23867 |
if (uiActive.get()) {
|
24336 |
fireAutocompleterUpdateActiveRange(editor, { range: context.range });
|
| 23868 |
fireAutocompleterUpdate(editor, { lookupData });
|
24337 |
fireAutocompleterUpdate(editor, { lookupData });
|
| 23869 |
} else {
|
24338 |
} else {
|
| 23870 |
uiActive.set(true);
|
24339 |
uiActive.set(true);
|
| 23871 |
fireAutocompleterStart(editor, { lookupData });
|
24340 |
fireAutocompleterUpdateActiveRange(editor, { range: context.range });
|
| 23872 |
}
|
- |
|
| 23873 |
}
|
24341 |
fireAutocompleterStart(editor, { lookupData });
|
| 23874 |
}
|
24342 |
}
|
| 23875 |
});
|
24343 |
});
|
| 23876 |
});
|
24344 |
});
|
| 23877 |
});
|
24345 |
});
|
| - |
|
24346 |
};
|
| - |
|
24347 |
const isRangeInsideOrEqual = (innerRange, outerRange) => {
|
| - |
|
24348 |
const startComparison = innerRange.compareBoundaryPoints(window.Range.START_TO_START, outerRange);
|
| - |
|
24349 |
const endComparison = innerRange.compareBoundaryPoints(window.Range.END_TO_END, outerRange);
|
| - |
|
24350 |
return startComparison >= 0 && endComparison <= 0;
|
| - |
|
24351 |
};
|
| - |
|
24352 |
const readActiveRange = () => {
|
| - |
|
24353 |
return activeAutocompleter.get().bind(({trigger}) => {
|
| - |
|
24354 |
const selRange = editor.selection.getRng();
|
| - |
|
24355 |
return getContext(editor.dom, selRange, trigger, uiActive.get()).filter(({range}) => isRangeInsideOrEqual(selRange, range)).map(({range}) => range);
|
| - |
|
24356 |
});
|
| 23878 |
};
|
24357 |
};
|
| 23879 |
editor.addCommand('mceAutocompleterReload', (_ui, value) => {
|
24358 |
editor.addCommand('mceAutocompleterReload', (_ui, value) => {
|
| 23880 |
const fetchOptions = isObject(value) ? value.fetchOptions : {};
|
24359 |
const fetchOptions = isObject(value) ? value.fetchOptions : {};
|
| 23881 |
load(fetchOptions);
|
24360 |
load(fetchOptions);
|
| 23882 |
});
|
24361 |
});
|
| - |
|
24362 |
editor.addCommand('mceAutocompleterClose', cancelIfNecessary);
|
| - |
|
24363 |
editor.addCommand('mceAutocompleterRefreshActiveRange', () => {
|
| - |
|
24364 |
readActiveRange().each(range => {
|
| - |
|
24365 |
fireAutocompleterUpdateActiveRange(editor, { range });
|
| - |
|
24366 |
});
|
| - |
|
24367 |
});
|
| 23883 |
editor.addCommand('mceAutocompleterClose', cancelIfNecessary);
|
24368 |
editor.editorCommands.addQueryStateHandler('mceAutoCompleterInRange', () => readActiveRange().isSome());
|
| 23884 |
setupEditorInput(editor, {
|
24369 |
setupEditorInput(editor, {
|
| 23885 |
cancelIfNecessary,
|
24370 |
cancelIfNecessary,
|
| 23886 |
load
|
24371 |
load
|
| 23887 |
});
|
24372 |
});
|
| Línea 23888... |
Línea 24373... |
| 23888 |
};
|
24373 |
};
|
| 23889 |
|
24374 |
|
| 23890 |
const browser$1 = detect$2().browser;
|
24375 |
const browser$1 = detect$1().browser;
|
| 23891 |
const isSafari = browser$1.isSafari();
|
24376 |
const isSafari = browser$1.isSafari();
|
| 23892 |
const emptyNodeContents = node => fillWithPaddingBr(SugarElement.fromDom(node));
|
24377 |
const emptyNodeContents = node => fillWithPaddingBr(SugarElement.fromDom(node));
|
| 23893 |
const isEntireNodeSelected = (rng, node) => {
|
24378 |
const isEntireNodeSelected = (rng, node) => {
|
| Línea 24093... |
Línea 24578... |
| 24093 |
});
|
24578 |
});
|
| 24094 |
};
|
24579 |
};
|
| 24095 |
const fireInputEvent = createAndFireInputEvent('input');
|
24580 |
const fireInputEvent = createAndFireInputEvent('input');
|
| 24096 |
const fireBeforeInputEvent = createAndFireInputEvent('beforeinput');
|
24581 |
const fireBeforeInputEvent = createAndFireInputEvent('beforeinput');
|
| Línea 24097... |
Línea 24582... |
| 24097 |
|
24582 |
|
| 24098 |
const platform$2 = detect$2();
|
24583 |
const platform$2 = detect$1();
|
| 24099 |
const os = platform$2.os;
|
24584 |
const os = platform$2.os;
|
| 24100 |
const isMacOSOriOS = os.isMacOS() || os.isiOS();
|
24585 |
const isMacOSOriOS = os.isMacOS() || os.isiOS();
|
| 24101 |
const browser = platform$2.browser;
|
24586 |
const browser = platform$2.browser;
|
| 24102 |
const isFirefox = browser.isFirefox();
|
24587 |
const isFirefox = browser.isFirefox();
|
| Línea 24116... |
Línea 24601... |
| 24116 |
keyCode: VK.BACKSPACE,
|
24601 |
keyCode: VK.BACKSPACE,
|
| 24117 |
action: action(backspaceDelete$1, editor)
|
24602 |
action: action(backspaceDelete$1, editor)
|
| 24118 |
},
|
24603 |
},
|
| 24119 |
{
|
24604 |
{
|
| 24120 |
keyCode: VK.BACKSPACE,
|
24605 |
keyCode: VK.BACKSPACE,
|
| 24121 |
action: action(backspaceDelete$6, editor, false)
|
24606 |
action: action(backspaceDelete$7, editor, false)
|
| 24122 |
},
|
24607 |
},
|
| 24123 |
{
|
24608 |
{
|
| 24124 |
keyCode: VK.DELETE,
|
24609 |
keyCode: VK.DELETE,
|
| 24125 |
action: action(backspaceDelete$6, editor, true)
|
24610 |
action: action(backspaceDelete$7, editor, true)
|
| 24126 |
},
|
24611 |
},
|
| 24127 |
{
|
24612 |
{
|
| 24128 |
keyCode: VK.BACKSPACE,
|
24613 |
keyCode: VK.BACKSPACE,
|
| 24129 |
action: action(backspaceDelete$7, editor, false)
|
24614 |
action: action(backspaceDelete$8, editor, false)
|
| 24130 |
},
|
24615 |
},
|
| 24131 |
{
|
24616 |
{
|
| 24132 |
keyCode: VK.DELETE,
|
24617 |
keyCode: VK.DELETE,
|
| 24133 |
action: action(backspaceDelete$7, editor, true)
|
24618 |
action: action(backspaceDelete$8, editor, true)
|
| 24134 |
},
|
24619 |
},
|
| 24135 |
{
|
24620 |
{
|
| 24136 |
keyCode: VK.BACKSPACE,
|
24621 |
keyCode: VK.BACKSPACE,
|
| 24137 |
action: action(backspaceDelete$4, editor, caret, false)
|
24622 |
action: action(backspaceDelete$4, editor, caret, false)
|
| 24138 |
},
|
24623 |
},
|
| Línea 24140... |
Línea 24625... |
| 24140 |
keyCode: VK.DELETE,
|
24625 |
keyCode: VK.DELETE,
|
| 24141 |
action: action(backspaceDelete$4, editor, caret, true)
|
24626 |
action: action(backspaceDelete$4, editor, caret, true)
|
| 24142 |
},
|
24627 |
},
|
| 24143 |
{
|
24628 |
{
|
| 24144 |
keyCode: VK.BACKSPACE,
|
24629 |
keyCode: VK.BACKSPACE,
|
| 24145 |
action: action(backspaceDelete$a, editor, false)
|
24630 |
action: action(backspaceDelete$b, editor, false)
|
| 24146 |
},
|
24631 |
},
|
| 24147 |
{
|
24632 |
{
|
| 24148 |
keyCode: VK.DELETE,
|
24633 |
keyCode: VK.DELETE,
|
| 24149 |
action: action(backspaceDelete$a, editor, true)
|
24634 |
action: action(backspaceDelete$b, editor, true)
|
| 24150 |
},
|
24635 |
},
|
| 24151 |
{
|
24636 |
{
|
| 24152 |
keyCode: VK.BACKSPACE,
|
24637 |
keyCode: VK.BACKSPACE,
|
| 24153 |
action: action(backspaceDelete, editor, false, unmodifiedGranularity)
|
24638 |
action: action(backspaceDelete, editor, false, unmodifiedGranularity)
|
| 24154 |
},
|
24639 |
},
|
| Línea 24200... |
Línea 24685... |
| 24200 |
keyCode: VK.DELETE,
|
24685 |
keyCode: VK.DELETE,
|
| 24201 |
action: action(backspaceDelete$2, editor, true)
|
24686 |
action: action(backspaceDelete$2, editor, true)
|
| 24202 |
},
|
24687 |
},
|
| 24203 |
{
|
24688 |
{
|
| 24204 |
keyCode: VK.BACKSPACE,
|
24689 |
keyCode: VK.BACKSPACE,
|
| 24205 |
action: action(backspaceDelete$8, editor, false)
|
24690 |
action: action(backspaceDelete$9, editor, false)
|
| 24206 |
},
|
24691 |
},
|
| 24207 |
{
|
24692 |
{
|
| 24208 |
keyCode: VK.DELETE,
|
24693 |
keyCode: VK.DELETE,
|
| 24209 |
action: action(backspaceDelete$8, editor, true)
|
24694 |
action: action(backspaceDelete$9, editor, true)
|
| 24210 |
},
|
24695 |
},
|
| 24211 |
{
|
24696 |
{
|
| 24212 |
keyCode: VK.BACKSPACE,
|
24697 |
keyCode: VK.BACKSPACE,
|
| 24213 |
action: action(backspaceDelete$9, editor, false)
|
24698 |
action: action(backspaceDelete$a, editor, false)
|
| 24214 |
},
|
24699 |
},
|
| 24215 |
{
|
24700 |
{
|
| 24216 |
keyCode: VK.DELETE,
|
24701 |
keyCode: VK.DELETE,
|
| 24217 |
action: action(backspaceDelete$9, editor, true)
|
24702 |
action: action(backspaceDelete$a, editor, true)
|
| 24218 |
},
|
24703 |
},
|
| 24219 |
{
|
24704 |
{
|
| 24220 |
keyCode: VK.BACKSPACE,
|
24705 |
keyCode: VK.BACKSPACE,
|
| 24221 |
action: action(backspaceDelete$3, editor, false)
|
24706 |
action: action(backspaceDelete$3, editor, false)
|
| 24222 |
},
|
24707 |
},
|
| 24223 |
{
|
24708 |
{
|
| 24224 |
keyCode: VK.DELETE,
|
24709 |
keyCode: VK.DELETE,
|
| 24225 |
action: action(backspaceDelete$3, editor, true)
|
24710 |
action: action(backspaceDelete$3, editor, true)
|
| - |
|
24711 |
},
|
| - |
|
24712 |
{
|
| - |
|
24713 |
keyCode: VK.BACKSPACE,
|
| - |
|
24714 |
action: action(backspaceDelete$6, editor, false)
|
| - |
|
24715 |
},
|
| - |
|
24716 |
{
|
| - |
|
24717 |
keyCode: VK.DELETE,
|
| - |
|
24718 |
action: action(backspaceDelete$6, editor, true)
|
| 24226 |
}
|
24719 |
}
|
| 24227 |
], evt).filter(_ => editor.selection.isEditable()).each(applyAction => {
|
24720 |
], evt).filter(_ => editor.selection.isEditable()).each(applyAction => {
|
| 24228 |
evt.preventDefault();
|
24721 |
evt.preventDefault();
|
| 24229 |
const beforeInput = fireBeforeInputEvent(editor, inputType);
|
24722 |
const beforeInput = fireBeforeInputEvent(editor, inputType);
|
| 24230 |
if (!beforeInput.isDefaultPrevented()) {
|
24723 |
if (!beforeInput.isDefaultPrevented()) {
|
| Línea 24286... |
Línea 24779... |
| 24286 |
});
|
24779 |
});
|
| 24287 |
};
|
24780 |
};
|
| Línea 24288... |
Línea 24781... |
| 24288 |
|
24781 |
|
| 24289 |
const firstNonWhiteSpaceNodeSibling = node => {
|
24782 |
const firstNonWhiteSpaceNodeSibling = node => {
|
| 24290 |
while (node) {
|
24783 |
while (node) {
|
| 24291 |
if (isElement$6(node) || isText$a(node) && node.data && /[\r\n\s]/.test(node.data)) {
|
24784 |
if (isElement$6(node) || isText$b(node) && node.data && /[\r\n\s]/.test(node.data)) {
|
| 24292 |
return node;
|
24785 |
return node;
|
| 24293 |
}
|
24786 |
}
|
| 24294 |
node = node.nextSibling;
|
24787 |
node = node.nextSibling;
|
| 24295 |
}
|
24788 |
}
|
| Línea 24312... |
Línea 24805... |
| 24312 |
if (root.hasChildNodes()) {
|
24805 |
if (root.hasChildNodes()) {
|
| 24313 |
const walker = new DomTreeWalker(root, root);
|
24806 |
const walker = new DomTreeWalker(root, root);
|
| 24314 |
let lastNode = root;
|
24807 |
let lastNode = root;
|
| 24315 |
let node;
|
24808 |
let node;
|
| 24316 |
while (node = walker.current()) {
|
24809 |
while (node = walker.current()) {
|
| 24317 |
if (isText$a(node)) {
|
24810 |
if (isText$b(node)) {
|
| 24318 |
rng.setStart(node, 0);
|
24811 |
rng.setStart(node, 0);
|
| 24319 |
rng.setEnd(node, 0);
|
24812 |
rng.setEnd(node, 0);
|
| 24320 |
break;
|
24813 |
break;
|
| 24321 |
}
|
24814 |
}
|
| 24322 |
if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) {
|
24815 |
if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) {
|
| Línea 24571... |
Línea 25064... |
| 24571 |
}
|
25064 |
}
|
| 24572 |
moveToCaretPosition(editor, newBlock);
|
25065 |
moveToCaretPosition(editor, newBlock);
|
| 24573 |
};
|
25066 |
};
|
| Línea 24574... |
Línea 25067... |
| 24574 |
|
25067 |
|
| 24575 |
const trimZwsp = fragment => {
|
25068 |
const trimZwsp = fragment => {
|
| 24576 |
each$e(descendants$1(SugarElement.fromDom(fragment), isText$b), text => {
|
25069 |
each$e(descendants$1(SugarElement.fromDom(fragment), isText$c), text => {
|
| 24577 |
const rawNode = text.dom;
|
25070 |
const rawNode = text.dom;
|
| 24578 |
rawNode.nodeValue = trim$2(rawNode.data);
|
25071 |
rawNode.nodeValue = trim$2(rawNode.data);
|
| 24579 |
});
|
25072 |
});
|
| 24580 |
};
|
25073 |
};
|
| Línea 24583... |
Línea 25076... |
| 24583 |
return parentList !== null && editor.dom.getContentEditableParent(parentList) === 'false';
|
25076 |
return parentList !== null && editor.dom.getContentEditableParent(parentList) === 'false';
|
| 24584 |
};
|
25077 |
};
|
| 24585 |
const isEmptyAnchor = (dom, elm) => {
|
25078 |
const isEmptyAnchor = (dom, elm) => {
|
| 24586 |
return elm && elm.nodeName === 'A' && dom.isEmpty(elm);
|
25079 |
return elm && elm.nodeName === 'A' && dom.isEmpty(elm);
|
| 24587 |
};
|
25080 |
};
|
| 24588 |
const containerAndSiblingName = (container, nodeName) => {
|
25081 |
const containerAndPreviousSiblingName = (container, nodeName) => {
|
| 24589 |
return container.nodeName === nodeName || container.previousSibling && container.previousSibling.nodeName === nodeName;
|
25082 |
return container.nodeName === nodeName || container.previousSibling && container.previousSibling.nodeName === nodeName;
|
| 24590 |
};
|
25083 |
};
|
| - |
|
25084 |
const containerAndNextSiblingName = (container, nodeName) => {
|
| - |
|
25085 |
return container.nodeName === nodeName || container.nextSibling && container.nextSibling.nodeName === nodeName;
|
| - |
|
25086 |
};
|
| 24591 |
const canSplitBlock = (dom, node) => {
|
25087 |
const canSplitBlock = (dom, node) => {
|
| 24592 |
return isNonNullable(node) && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.isEditable(node.parentNode) && dom.getContentEditable(node) !== 'false';
|
25088 |
return isNonNullable(node) && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.isEditable(node.parentNode) && dom.getContentEditable(node) !== 'false';
|
| 24593 |
};
|
25089 |
};
|
| 24594 |
const trimInlineElementsOnLeftSideOfBlock = (dom, nonEmptyElementsMap, block) => {
|
25090 |
const trimInlineElementsOnLeftSideOfBlock = (dom, nonEmptyElementsMap, block) => {
|
| 24595 |
var _a;
|
25091 |
var _a;
|
| Línea 24617... |
Línea 25113... |
| 24617 |
}
|
25113 |
}
|
| 24618 |
}
|
25114 |
}
|
| 24619 |
}
|
25115 |
}
|
| 24620 |
};
|
25116 |
};
|
| 24621 |
const normalizeZwspOffset = (start, container, offset) => {
|
25117 |
const normalizeZwspOffset = (start, container, offset) => {
|
| 24622 |
if (!isText$a(container)) {
|
25118 |
if (!isText$b(container)) {
|
| 24623 |
return offset;
|
25119 |
return offset;
|
| 24624 |
} else if (start) {
|
25120 |
} else if (start) {
|
| 24625 |
return offset === 1 && container.data.charAt(offset - 1) === ZWSP$1 ? 0 : offset;
|
25121 |
return offset === 1 && container.data.charAt(offset - 1) === ZWSP$1 ? 0 : offset;
|
| 24626 |
} else {
|
25122 |
} else {
|
| 24627 |
return offset === container.data.length - 1 && container.data.charAt(offset) === ZWSP$1 ? container.data.length : offset;
|
25123 |
return offset === container.data.length - 1 && container.data.charAt(offset) === ZWSP$1 ? container.data.length : offset;
|
| Línea 24634... |
Línea 25130... |
| 24634 |
return newRng;
|
25130 |
return newRng;
|
| 24635 |
};
|
25131 |
};
|
| 24636 |
const trimLeadingLineBreaks = node => {
|
25132 |
const trimLeadingLineBreaks = node => {
|
| 24637 |
let currentNode = node;
|
25133 |
let currentNode = node;
|
| 24638 |
do {
|
25134 |
do {
|
| 24639 |
if (isText$a(currentNode)) {
|
25135 |
if (isText$b(currentNode)) {
|
| 24640 |
currentNode.data = currentNode.data.replace(/^[\r\n]+/, '');
|
25136 |
currentNode.data = currentNode.data.replace(/^[\r\n]+/, '');
|
| 24641 |
}
|
25137 |
}
|
| 24642 |
currentNode = currentNode.firstChild;
|
25138 |
currentNode = currentNode.firstChild;
|
| 24643 |
} while (currentNode);
|
25139 |
} while (currentNode);
|
| 24644 |
};
|
25140 |
};
|
| Línea 24718... |
Línea 25214... |
| 24718 |
const createNewBlock$1 = (name, styles) => {
|
25214 |
const createNewBlock$1 = (name, styles) => {
|
| 24719 |
return createNewBlock(editor, container, parentBlock, editableRoot, shouldKeepStyles(editor), name, styles);
|
25215 |
return createNewBlock(editor, container, parentBlock, editableRoot, shouldKeepStyles(editor), name, styles);
|
| 24720 |
};
|
25216 |
};
|
| 24721 |
const isCaretAtStartOrEndOfBlock = start => {
|
25217 |
const isCaretAtStartOrEndOfBlock = start => {
|
| 24722 |
const normalizedOffset = normalizeZwspOffset(start, container, offset);
|
25218 |
const normalizedOffset = normalizeZwspOffset(start, container, offset);
|
| 24723 |
if (isText$a(container) && (start ? normalizedOffset > 0 : normalizedOffset < container.data.length)) {
|
25219 |
if (isText$b(container) && (start ? normalizedOffset > 0 : normalizedOffset < container.data.length)) {
|
| 24724 |
return false;
|
25220 |
return false;
|
| 24725 |
}
|
25221 |
}
|
| 24726 |
if (container.parentNode === parentBlock && isAfterLastNodeInContainer && !start) {
|
25222 |
if ((container.parentNode === parentBlock || container === parentBlock) && isAfterLastNodeInContainer && !start) {
|
| 24727 |
return true;
|
25223 |
return true;
|
| 24728 |
}
|
25224 |
}
|
| 24729 |
if (start && isElement$6(container) && container === parentBlock.firstChild) {
|
25225 |
if (start && isElement$6(container) && container === parentBlock.firstChild) {
|
| 24730 |
return true;
|
25226 |
return true;
|
| 24731 |
}
|
25227 |
}
|
| 24732 |
if (containerAndSiblingName(container, 'TABLE') || containerAndSiblingName(container, 'HR')) {
|
25228 |
if (containerAndPreviousSiblingName(container, 'TABLE') || containerAndPreviousSiblingName(container, 'HR')) {
|
| - |
|
25229 |
if (containerAndNextSiblingName(container, 'BR')) {
|
| - |
|
25230 |
return !start;
|
| - |
|
25231 |
}
|
| 24733 |
return isAfterLastNodeInContainer && !start || !isAfterLastNodeInContainer && start;
|
25232 |
return isAfterLastNodeInContainer && !start || !isAfterLastNodeInContainer && start;
|
| 24734 |
}
|
25233 |
}
|
| 24735 |
const walker = new DomTreeWalker(container, parentBlock);
|
25234 |
const walker = new DomTreeWalker(container, parentBlock);
|
| 24736 |
if (isText$a(container)) {
|
25235 |
if (isText$b(container)) {
|
| 24737 |
if (start && normalizedOffset === 0) {
|
25236 |
if (start && normalizedOffset === 0) {
|
| 24738 |
walker.prev();
|
25237 |
walker.prev();
|
| 24739 |
} else if (!start && normalizedOffset === container.data.length) {
|
25238 |
} else if (!start && normalizedOffset === container.data.length) {
|
| 24740 |
walker.next();
|
25239 |
walker.next();
|
| 24741 |
}
|
25240 |
}
|
| Línea 24747... |
Línea 25246... |
| 24747 |
const name = node.nodeName.toLowerCase();
|
25246 |
const name = node.nodeName.toLowerCase();
|
| 24748 |
if (nonEmptyElementsMap[name] && name !== 'br') {
|
25247 |
if (nonEmptyElementsMap[name] && name !== 'br') {
|
| 24749 |
return false;
|
25248 |
return false;
|
| 24750 |
}
|
25249 |
}
|
| 24751 |
}
|
25250 |
}
|
| 24752 |
} else if (isText$a(node) && !isWhitespaceText(node.data)) {
|
25251 |
} else if (isText$b(node) && !isWhitespaceText(node.data)) {
|
| 24753 |
return false;
|
25252 |
return false;
|
| 24754 |
}
|
25253 |
}
|
| 24755 |
if (start) {
|
25254 |
if (start) {
|
| 24756 |
walker.prev();
|
25255 |
walker.prev();
|
| 24757 |
} else {
|
25256 |
} else {
|
| Línea 24784... |
Línea 25283... |
| 24784 |
const shiftKey = !!(evt && evt.shiftKey);
|
25283 |
const shiftKey = !!(evt && evt.shiftKey);
|
| 24785 |
const ctrlKey = !!(evt && evt.ctrlKey);
|
25284 |
const ctrlKey = !!(evt && evt.ctrlKey);
|
| 24786 |
if (isElement$6(container) && container.hasChildNodes() && !collapsedAndCef) {
|
25285 |
if (isElement$6(container) && container.hasChildNodes() && !collapsedAndCef) {
|
| 24787 |
isAfterLastNodeInContainer = offset > container.childNodes.length - 1;
|
25286 |
isAfterLastNodeInContainer = offset > container.childNodes.length - 1;
|
| 24788 |
container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
|
25287 |
container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
|
| 24789 |
if (isAfterLastNodeInContainer && isText$a(container)) {
|
25288 |
if (isAfterLastNodeInContainer && isText$b(container)) {
|
| 24790 |
offset = container.data.length;
|
25289 |
offset = container.data.length;
|
| 24791 |
} else {
|
25290 |
} else {
|
| 24792 |
offset = 0;
|
25291 |
offset = 0;
|
| 24793 |
}
|
25292 |
}
|
| 24794 |
}
|
25293 |
}
|
| Línea 24839... |
Línea 25338... |
| 24839 |
setForcedBlockAttrs(editor, newBlock);
|
25338 |
setForcedBlockAttrs(editor, newBlock);
|
| 24840 |
moveToCaretPosition(editor, newBlock);
|
25339 |
moveToCaretPosition(editor, newBlock);
|
| 24841 |
} else if (isCaretAtStartOrEndOfBlock(false)) {
|
25340 |
} else if (isCaretAtStartOrEndOfBlock(false)) {
|
| 24842 |
newBlock = insertNewBlockAfter();
|
25341 |
newBlock = insertNewBlockAfter();
|
| 24843 |
} else if (isCaretAtStartOrEndOfBlock(true) && parentBlockParent) {
|
25342 |
} else if (isCaretAtStartOrEndOfBlock(true) && parentBlockParent) {
|
| - |
|
25343 |
const caretPos = CaretPosition.fromRangeStart(rng);
|
| - |
|
25344 |
const afterTable = isAfterTable(caretPos);
|
| - |
|
25345 |
const parentBlockSugar = SugarElement.fromDom(parentBlock);
|
| - |
|
25346 |
const afterBr = isAfterBr(parentBlockSugar, caretPos, editor.schema);
|
| - |
|
25347 |
const prevBrOpt = afterBr ? findPreviousBr(parentBlockSugar, caretPos, editor.schema).bind(pos => Optional.from(pos.getNode())) : Optional.none();
|
| 24844 |
newBlock = parentBlockParent.insertBefore(createNewBlock$1(), parentBlock);
|
25348 |
newBlock = parentBlockParent.insertBefore(createNewBlock$1(), parentBlock);
|
| 24845 |
const isNearChildren = hasChildNodes(SugarElement.fromDom(rng.startContainer)) && rng.collapsed;
|
25349 |
const root = containerAndPreviousSiblingName(parentBlock, 'HR') || afterTable ? newBlock : prevBrOpt.getOr(parentBlock);
|
| 24846 |
moveToCaretPosition(editor, containerAndSiblingName(parentBlock, 'HR') || isNearChildren ? newBlock : parentBlock);
|
25350 |
moveToCaretPosition(editor, root);
|
| 24847 |
} else {
|
25351 |
} else {
|
| 24848 |
const tmpRng = includeZwspInRange(rng).cloneRange();
|
25352 |
const tmpRng = includeZwspInRange(rng).cloneRange();
|
| 24849 |
tmpRng.setEndAfter(parentBlock);
|
25353 |
tmpRng.setEndAfter(parentBlock);
|
| 24850 |
const fragment = tmpRng.extractContents();
|
25354 |
const fragment = tmpRng.extractContents();
|
| 24851 |
trimZwsp(fragment);
|
25355 |
trimZwsp(fragment);
|
| Línea 24878... |
Línea 25382... |
| 24878 |
const hasRightSideContent = (schema, container, parentBlock) => {
|
25382 |
const hasRightSideContent = (schema, container, parentBlock) => {
|
| 24879 |
const walker = new DomTreeWalker(container, parentBlock);
|
25383 |
const walker = new DomTreeWalker(container, parentBlock);
|
| 24880 |
let node;
|
25384 |
let node;
|
| 24881 |
const nonEmptyElementsMap = schema.getNonEmptyElements();
|
25385 |
const nonEmptyElementsMap = schema.getNonEmptyElements();
|
| 24882 |
while (node = walker.next()) {
|
25386 |
while (node = walker.next()) {
|
| 24883 |
if (nonEmptyElementsMap[node.nodeName.toLowerCase()] || isText$a(node) && node.length > 0) {
|
25387 |
if (nonEmptyElementsMap[node.nodeName.toLowerCase()] || isText$b(node) && node.length > 0) {
|
| 24884 |
return true;
|
25388 |
return true;
|
| 24885 |
}
|
25389 |
}
|
| 24886 |
}
|
25390 |
}
|
| 24887 |
return false;
|
25391 |
return false;
|
| 24888 |
};
|
25392 |
};
|
| Línea 24911... |
Línea 25415... |
| 24911 |
let offset = rng.startOffset;
|
25415 |
let offset = rng.startOffset;
|
| 24912 |
let container = rng.startContainer;
|
25416 |
let container = rng.startContainer;
|
| 24913 |
if (isElement$6(container) && container.hasChildNodes()) {
|
25417 |
if (isElement$6(container) && container.hasChildNodes()) {
|
| 24914 |
const isAfterLastNodeInContainer = offset > container.childNodes.length - 1;
|
25418 |
const isAfterLastNodeInContainer = offset > container.childNodes.length - 1;
|
| 24915 |
container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
|
25419 |
container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
|
| 24916 |
if (isAfterLastNodeInContainer && isText$a(container)) {
|
25420 |
if (isAfterLastNodeInContainer && isText$b(container)) {
|
| 24917 |
offset = container.data.length;
|
25421 |
offset = container.data.length;
|
| 24918 |
} else {
|
25422 |
} else {
|
| 24919 |
offset = 0;
|
25423 |
offset = 0;
|
| 24920 |
}
|
25424 |
}
|
| 24921 |
}
|
25425 |
}
|
| Línea 24924... |
Línea 25428... |
| 24924 |
const containerBlockName = containerBlock ? containerBlock.nodeName.toUpperCase() : '';
|
25428 |
const containerBlockName = containerBlock ? containerBlock.nodeName.toUpperCase() : '';
|
| 24925 |
const isControlKey = !!(evt && evt.ctrlKey);
|
25429 |
const isControlKey = !!(evt && evt.ctrlKey);
|
| 24926 |
if (containerBlockName === 'LI' && !isControlKey) {
|
25430 |
if (containerBlockName === 'LI' && !isControlKey) {
|
| 24927 |
parentBlock = containerBlock;
|
25431 |
parentBlock = containerBlock;
|
| 24928 |
}
|
25432 |
}
|
| 24929 |
if (isText$a(container) && offset >= container.data.length) {
|
25433 |
if (isText$b(container) && offset >= container.data.length) {
|
| 24930 |
if (!hasRightSideContent(editor.schema, container, parentBlock || dom.getRoot())) {
|
25434 |
if (!hasRightSideContent(editor.schema, container, parentBlock || dom.getRoot())) {
|
| 24931 |
brElm = dom.create('br');
|
25435 |
brElm = dom.create('br');
|
| 24932 |
rng.insertNode(brElm);
|
25436 |
rng.insertNode(brElm);
|
| 24933 |
rng.setStartAfter(brElm);
|
25437 |
rng.setStartAfter(brElm);
|
| 24934 |
rng.setEndAfter(brElm);
|
25438 |
rng.setEndAfter(brElm);
|
| Línea 25100... |
Línea 25604... |
| 25100 |
!!(evt && evt.shiftKey)
|
25604 |
!!(evt && evt.shiftKey)
|
| 25101 |
]).getOr(newLineAction.none());
|
25605 |
]).getOr(newLineAction.none());
|
| 25102 |
};
|
25606 |
};
|
| Línea 25103... |
Línea 25607... |
| 25103 |
|
25607 |
|
| - |
|
25608 |
const insertBreak = (breakType, editor, evt) => {
|
| - |
|
25609 |
if (editor.mode.isReadOnly()) {
|
| - |
|
25610 |
return;
|
| 25104 |
const insertBreak = (breakType, editor, evt) => {
|
25611 |
}
|
| 25105 |
if (!editor.selection.isCollapsed()) {
|
25612 |
if (!editor.selection.isCollapsed()) {
|
| 25106 |
execEditorDeleteCommand(editor);
|
25613 |
execEditorDeleteCommand(editor);
|
| 25107 |
}
|
25614 |
}
|
| 25108 |
if (isNonNullable(evt)) {
|
25615 |
if (isNonNullable(evt)) {
|
| Línea 25115... |
Línea 25622... |
| 25115 |
if (isNonNullable(evt)) {
|
25622 |
if (isNonNullable(evt)) {
|
| 25116 |
fireInputEvent(editor, breakType.fakeEventName);
|
25623 |
fireInputEvent(editor, breakType.fakeEventName);
|
| 25117 |
}
|
25624 |
}
|
| 25118 |
};
|
25625 |
};
|
| 25119 |
const insert$1 = (editor, evt) => {
|
25626 |
const insert$1 = (editor, evt) => {
|
| - |
|
25627 |
if (editor.mode.isReadOnly()) {
|
| - |
|
25628 |
return;
|
| - |
|
25629 |
}
|
| 25120 |
const br = () => insertBreak(linebreak, editor, evt);
|
25630 |
const br = () => insertBreak(linebreak, editor, evt);
|
| 25121 |
const block = () => insertBreak(blockbreak, editor, evt);
|
25631 |
const block = () => insertBreak(blockbreak, editor, evt);
|
| 25122 |
const logicalAction = getAction(editor, evt);
|
25632 |
const logicalAction = getAction(editor, evt);
|
| 25123 |
switch (getNewlineBehavior(editor)) {
|
25633 |
switch (getNewlineBehavior(editor)) {
|
| 25124 |
case 'linebreak':
|
25634 |
case 'linebreak':
|
| Línea 25134... |
Línea 25644... |
| 25134 |
logicalAction.fold(br, block, noop);
|
25644 |
logicalAction.fold(br, block, noop);
|
| 25135 |
break;
|
25645 |
break;
|
| 25136 |
}
|
25646 |
}
|
| 25137 |
};
|
25647 |
};
|
| Línea 25138... |
Línea 25648... |
| 25138 |
|
25648 |
|
| 25139 |
const platform$1 = detect$2();
|
25649 |
const platform$1 = detect$1();
|
| 25140 |
const isIOSSafari = platform$1.os.isiOS() && platform$1.browser.isSafari();
|
25650 |
const isIOSSafari = platform$1.os.isiOS() && platform$1.browser.isSafari();
|
| 25141 |
const handleEnterKeyEvent = (editor, event) => {
|
25651 |
const handleEnterKeyEvent = (editor, event) => {
|
| 25142 |
if (event.isDefaultPrevented()) {
|
25652 |
if (event.isDefaultPrevented()) {
|
| 25143 |
return;
|
25653 |
return;
|
| Línea 25151... |
Línea 25661... |
| 25151 |
const isCaretAfterKoreanCharacter = rng => {
|
25661 |
const isCaretAfterKoreanCharacter = rng => {
|
| 25152 |
if (!rng.collapsed) {
|
25662 |
if (!rng.collapsed) {
|
| 25153 |
return false;
|
25663 |
return false;
|
| 25154 |
}
|
25664 |
}
|
| 25155 |
const startContainer = rng.startContainer;
|
25665 |
const startContainer = rng.startContainer;
|
| 25156 |
if (isText$a(startContainer)) {
|
25666 |
if (isText$b(startContainer)) {
|
| 25157 |
const koreanCharRegex = /^[\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]$/;
|
25667 |
const koreanCharRegex = /^[\uAC00-\uD7AF\u1100-\u11FF\u3130-\u318F\uA960-\uA97F\uD7B0-\uD7FF]$/;
|
| 25158 |
const char = startContainer.data.charAt(rng.startOffset - 1);
|
25668 |
const char = startContainer.data.charAt(rng.startOffset - 1);
|
| 25159 |
return koreanCharRegex.test(char);
|
25669 |
return koreanCharRegex.test(char);
|
| 25160 |
} else {
|
25670 |
} else {
|
| 25161 |
return false;
|
25671 |
return false;
|
| Línea 25248... |
Línea 25758... |
| 25248 |
normalizeNbspsInEditor(editor);
|
25758 |
normalizeNbspsInEditor(editor);
|
| 25249 |
}
|
25759 |
}
|
| 25250 |
});
|
25760 |
});
|
| 25251 |
};
|
25761 |
};
|
| Línea 25252... |
Línea 25762... |
| 25252 |
|
25762 |
|
| 25253 |
const platform = detect$2();
|
25763 |
const platform = detect$1();
|
| 25254 |
const executeKeyupAction = (editor, caret, evt) => {
|
25764 |
const executeKeyupAction = (editor, caret, evt) => {
|
| 25255 |
execute([
|
25765 |
execute([
|
| 25256 |
{
|
25766 |
{
|
| 25257 |
keyCode: VK.PAGE_UP,
|
25767 |
keyCode: VK.PAGE_UP,
|
| Línea 25292... |
Línea 25802... |
| 25292 |
editor.nodeChanged();
|
25802 |
editor.nodeChanged();
|
| 25293 |
}
|
25803 |
}
|
| 25294 |
});
|
25804 |
});
|
| 25295 |
};
|
25805 |
};
|
| Línea -... |
Línea 25806... |
| - |
|
25806 |
|
| - |
|
25807 |
const isValidContainer = (root, container) => root === container || root.contains(container);
|
| - |
|
25808 |
const isInEditableRange = (editor, range) => {
|
| - |
|
25809 |
if (!isValidContainer(editor.getBody(), range.startContainer) || !isValidContainer(editor.getBody(), range.endContainer)) {
|
| - |
|
25810 |
return true;
|
| - |
|
25811 |
}
|
| - |
|
25812 |
return isEditableRange(editor.dom, range);
|
| 25296 |
|
25813 |
};
|
| 25297 |
const setup$e = editor => {
|
25814 |
const setup$e = editor => {
|
| 25298 |
editor.on('beforeinput', e => {
|
25815 |
editor.on('beforeinput', e => {
|
| 25299 |
if (!editor.selection.isEditable() || exists(e.getTargetRanges(), rng => !isEditableRange(editor.dom, rng))) {
|
25816 |
if (!editor.selection.isEditable() || exists(e.getTargetRanges(), rng => !isInEditableRange(editor, rng))) {
|
| 25300 |
e.preventDefault();
|
25817 |
e.preventDefault();
|
| 25301 |
}
|
25818 |
}
|
| 25302 |
});
|
25819 |
});
|
| Línea 25303... |
Línea 25820... |
| 25303 |
};
|
25820 |
};
|
| 25304 |
|
25821 |
|
| 25305 |
const insertTextAtPosition = (text, pos) => {
|
25822 |
const insertTextAtPosition = (text, pos) => {
|
| 25306 |
const container = pos.container();
|
25823 |
const container = pos.container();
|
| 25307 |
const offset = pos.offset();
|
25824 |
const offset = pos.offset();
|
| 25308 |
if (isText$a(container)) {
|
25825 |
if (isText$b(container)) {
|
| 25309 |
container.insertData(offset, text);
|
25826 |
container.insertData(offset, text);
|
| 25310 |
return Optional.some(CaretPosition(container, offset + text.length));
|
25827 |
return Optional.some(CaretPosition(container, offset + text.length));
|
| 25311 |
} else {
|
25828 |
} else {
|
| Línea 25452... |
Línea 25969... |
| 25452 |
}
|
25969 |
}
|
| 25453 |
lastRng = fakeRng;
|
25970 |
lastRng = fakeRng;
|
| 25454 |
});
|
25971 |
});
|
| 25455 |
}
|
25972 |
}
|
| 25456 |
editor.on('contextmenu', () => {
|
25973 |
editor.on('contextmenu', () => {
|
| - |
|
25974 |
store(editor);
|
| 25457 |
editor.dispatch('SelectionChange');
|
25975 |
editor.dispatch('SelectionChange');
|
| 25458 |
});
|
25976 |
});
|
| 25459 |
editor.on('SelectionChange', () => {
|
25977 |
editor.on('SelectionChange', () => {
|
| 25460 |
const startElm = editor.selection.getStart(true);
|
25978 |
const startElm = editor.selection.getStart(true);
|
| 25461 |
if (!startElm) {
|
25979 |
if (!startElm) {
|
| Línea 25476... |
Línea 25994... |
| 25476 |
}
|
25994 |
}
|
| 25477 |
}
|
25995 |
}
|
| 25478 |
});
|
25996 |
});
|
| 25479 |
}
|
25997 |
}
|
| 25480 |
nodeChanged(args = {}) {
|
25998 |
nodeChanged(args = {}) {
|
| - |
|
25999 |
const editor = this.editor;
|
| 25481 |
const selection = this.editor.selection;
|
26000 |
const selection = editor.selection;
|
| 25482 |
let node;
|
26001 |
let node;
|
| 25483 |
if (this.editor.initialized && selection && !shouldDisableNodeChange(this.editor) && !this.editor.mode.isReadOnly()) {
|
26002 |
if (editor.initialized && selection && !shouldDisableNodeChange(editor) && !isDisabled$1(editor)) {
|
| 25484 |
const root = this.editor.getBody();
|
26003 |
const root = editor.getBody();
|
| 25485 |
node = selection.getStart(true) || root;
|
26004 |
node = selection.getStart(true) || root;
|
| 25486 |
if (node.ownerDocument !== this.editor.getDoc() || !this.editor.dom.isChildOf(node, root)) {
|
26005 |
if (node.ownerDocument !== editor.getDoc() || !editor.dom.isChildOf(node, root)) {
|
| 25487 |
node = root;
|
26006 |
node = root;
|
| 25488 |
}
|
26007 |
}
|
| 25489 |
const parents = [];
|
26008 |
const parents = [];
|
| 25490 |
this.editor.dom.getParent(node, node => {
|
26009 |
editor.dom.getParent(node, node => {
|
| 25491 |
if (node === root) {
|
26010 |
if (node === root) {
|
| 25492 |
return true;
|
26011 |
return true;
|
| 25493 |
} else {
|
26012 |
} else {
|
| 25494 |
parents.push(node);
|
26013 |
parents.push(node);
|
| 25495 |
return false;
|
26014 |
return false;
|
| 25496 |
}
|
26015 |
}
|
| 25497 |
});
|
26016 |
});
|
| 25498 |
this.editor.dispatch('NodeChange', {
|
26017 |
editor.dispatch('NodeChange', {
|
| 25499 |
...args,
|
26018 |
...args,
|
| 25500 |
element: node,
|
26019 |
element: node,
|
| 25501 |
parents
|
26020 |
parents
|
| 25502 |
});
|
26021 |
});
|
| 25503 |
}
|
26022 |
}
|
| Línea 25912... |
Línea 26431... |
| 25912 |
};
|
26431 |
};
|
| Línea 25913... |
Línea 26432... |
| 25913 |
|
26432 |
|
| 25914 |
const preProcess = (editor, html) => {
|
26433 |
const preProcess = (editor, html) => {
|
| 25915 |
const parser = DomParser({
|
26434 |
const parser = DomParser({
|
| 25916 |
sanitize: shouldSanitizeXss(editor),
|
26435 |
sanitize: shouldSanitizeXss(editor),
|
| - |
|
26436 |
sandbox_iframes: shouldSandboxIframes(editor),
|
| - |
|
26437 |
sandbox_iframes_exclusions: getSandboxIframesExclusions(editor),
|
| 25917 |
sandbox_iframes: shouldSandboxIframes(editor)
|
26438 |
convert_unsafe_embeds: shouldConvertUnsafeEmbeds(editor)
|
| 25918 |
}, editor.schema);
|
26439 |
}, editor.schema);
|
| 25919 |
parser.addNodeFilter('meta', nodes => {
|
26440 |
parser.addNodeFilter('meta', nodes => {
|
| 25920 |
Tools.each(nodes, node => {
|
26441 |
Tools.each(nodes, node => {
|
| 25921 |
node.remove();
|
26442 |
node.remove();
|
| Línea 26033... |
Línea 26554... |
| 26033 |
if (dataTransfer && dataTransfer.types) {
|
26554 |
if (dataTransfer && dataTransfer.types) {
|
| 26034 |
for (let i = 0; i < dataTransfer.types.length; i++) {
|
26555 |
for (let i = 0; i < dataTransfer.types.length; i++) {
|
| 26035 |
const contentType = dataTransfer.types[i];
|
26556 |
const contentType = dataTransfer.types[i];
|
| 26036 |
try {
|
26557 |
try {
|
| 26037 |
items[contentType] = dataTransfer.getData(contentType);
|
26558 |
items[contentType] = dataTransfer.getData(contentType);
|
| 26038 |
} catch (ex) {
|
26559 |
} catch (_a) {
|
| 26039 |
items[contentType] = '';
|
26560 |
items[contentType] = '';
|
| 26040 |
}
|
26561 |
}
|
| 26041 |
}
|
26562 |
}
|
| 26042 |
}
|
26563 |
}
|
| 26043 |
return items;
|
26564 |
return items;
|
| Línea 26226... |
Línea 26747... |
| 26226 |
clipboardData.clearData();
|
26747 |
clipboardData.clearData();
|
| 26227 |
clipboardData.setData('text/html', html);
|
26748 |
clipboardData.setData('text/html', html);
|
| 26228 |
clipboardData.setData('text/plain', text);
|
26749 |
clipboardData.setData('text/plain', text);
|
| 26229 |
clipboardData.setData(internalHtmlMime(), html);
|
26750 |
clipboardData.setData(internalHtmlMime(), html);
|
| 26230 |
return true;
|
26751 |
return true;
|
| 26231 |
} catch (e) {
|
26752 |
} catch (_a) {
|
| 26232 |
return false;
|
26753 |
return false;
|
| 26233 |
}
|
26754 |
}
|
| 26234 |
} else {
|
26755 |
} else {
|
| 26235 |
return false;
|
26756 |
return false;
|
| 26236 |
}
|
26757 |
}
|
| Línea 26481... |
Línea 27002... |
| 26481 |
const pasteFormat = Cell(isPasteAsTextEnabled(editor) ? 'text' : 'html');
|
27002 |
const pasteFormat = Cell(isPasteAsTextEnabled(editor) ? 'text' : 'html');
|
| 26482 |
const pasteBin = PasteBin(editor);
|
27003 |
const pasteBin = PasteBin(editor);
|
| 26483 |
setup$8(editor);
|
27004 |
setup$8(editor);
|
| 26484 |
register$1(editor, pasteFormat);
|
27005 |
register$1(editor, pasteFormat);
|
| 26485 |
setup$9(editor);
|
27006 |
setup$9(editor);
|
| - |
|
27007 |
editor.addQueryStateHandler('mceTogglePlainTextPaste', () => pasteFormat.get() === 'text');
|
| 26486 |
editor.on('PreInit', () => {
|
27008 |
editor.on('PreInit', () => {
|
| 26487 |
register(editor);
|
27009 |
register(editor);
|
| 26488 |
setup$a(editor, draggingInternallyState);
|
27010 |
setup$a(editor, draggingInternallyState);
|
| 26489 |
registerEventsAndFilters(editor, pasteBin, pasteFormat);
|
27011 |
registerEventsAndFilters(editor, pasteBin, pasteFormat);
|
| 26490 |
});
|
27012 |
});
|
| Línea 26523... |
Línea 27045... |
| 26523 |
preventSummaryToggle(editor);
|
27045 |
preventSummaryToggle(editor);
|
| 26524 |
filterDetails(editor);
|
27046 |
filterDetails(editor);
|
| 26525 |
};
|
27047 |
};
|
| Línea 26526... |
Línea 27048... |
| 26526 |
|
27048 |
|
| 26527 |
const isBr = isBr$6;
|
27049 |
const isBr = isBr$6;
|
| 26528 |
const isText = isText$a;
|
27050 |
const isText = isText$b;
|
| 26529 |
const isContentEditableFalse$2 = elm => isContentEditableFalse$b(elm.dom);
|
27051 |
const isContentEditableFalse$2 = elm => isContentEditableFalse$b(elm.dom);
|
| 26530 |
const isContentEditableTrue = elm => isContentEditableTrue$3(elm.dom);
|
27052 |
const isContentEditableTrue = elm => isContentEditableTrue$3(elm.dom);
|
| 26531 |
const isRoot = rootNode => elm => eq(SugarElement.fromDom(rootNode), elm);
|
27053 |
const isRoot = rootNode => elm => eq(SugarElement.fromDom(rootNode), elm);
|
| 26532 |
const getClosestScope = (node, rootNode, schema) => closest$4(SugarElement.fromDom(node), elm => isContentEditableTrue(elm) || schema.isBlock(name(elm)), isRoot(rootNode)).getOr(SugarElement.fromDom(rootNode)).dom;
|
27054 |
const getClosestScope = (node, rootNode, schema) => closest$4(SugarElement.fromDom(node), elm => isContentEditableTrue(elm) || schema.isBlock(name(elm)), isRoot(rootNode)).getOr(SugarElement.fromDom(rootNode)).dom;
|
| Línea 26625... |
Línea 27147... |
| 26625 |
}
|
27147 |
}
|
| 26626 |
};
|
27148 |
};
|
| 26627 |
const tryFindSecondBestTextNode = (closest, sndClosest, distance) => {
|
27149 |
const tryFindSecondBestTextNode = (closest, sndClosest, distance) => {
|
| 26628 |
return caretCandidateRect(sndClosest).filter(rect => {
|
27150 |
return caretCandidateRect(sndClosest).filter(rect => {
|
| 26629 |
const deltaDistance = Math.abs(distance(closest, clientX, clientY) - distance(rect, clientX, clientY));
|
27151 |
const deltaDistance = Math.abs(distance(closest, clientX, clientY) - distance(rect, clientX, clientY));
|
| 26630 |
return deltaDistance < 2 && isText$a(rect.node);
|
27152 |
return deltaDistance < 2 && isText$b(rect.node);
|
| 26631 |
});
|
27153 |
});
|
| 26632 |
};
|
27154 |
};
|
| 26633 |
const findClosestCaretCandidateNodeRect = (rects, distance) => {
|
27155 |
const findClosestCaretCandidateNodeRect = (rects, distance) => {
|
| 26634 |
const sortedRects = sort(rects, (r1, r2) => distance(r1, clientX, clientY) - distance(r2, clientX, clientY));
|
27156 |
const sortedRects = sort(rects, (r1, r2) => distance(r1, clientX, clientY) - distance(r2, clientX, clientY));
|
| 26635 |
return findMap(sortedRects, caretCandidateRect).map(closest => {
|
27157 |
return findMap(sortedRects, caretCandidateRect).map(closest => {
|
| 26636 |
if (findCloserTextNode && !isText$a(closest.node) && sortedRects.length > 1) {
|
27158 |
if (findCloserTextNode && !isText$b(closest.node) && sortedRects.length > 1) {
|
| 26637 |
return tryFindSecondBestTextNode(closest, sortedRects[1], distance).getOr(closest);
|
27159 |
return tryFindSecondBestTextNode(closest, sortedRects[1], distance).getOr(closest);
|
| 26638 |
} else {
|
27160 |
} else {
|
| 26639 |
return closest;
|
27161 |
return closest;
|
| 26640 |
}
|
27162 |
}
|
| 26641 |
});
|
27163 |
});
|
| Línea 26764... |
Línea 27286... |
| 26764 |
button: 0,
|
27286 |
button: 0,
|
| 26765 |
buttons: 0,
|
27287 |
buttons: 0,
|
| 26766 |
clientX: 0,
|
27288 |
clientX: 0,
|
| 26767 |
clientY: 0,
|
27289 |
clientY: 0,
|
| 26768 |
ctrlKey: false,
|
27290 |
ctrlKey: false,
|
| - |
|
27291 |
layerX: 0,
|
| - |
|
27292 |
layerY: 0,
|
| 26769 |
metaKey: false,
|
27293 |
metaKey: false,
|
| 26770 |
movementX: 0,
|
27294 |
movementX: 0,
|
| 26771 |
movementY: 0,
|
27295 |
movementY: 0,
|
| 26772 |
offsetX: 0,
|
27296 |
offsetX: 0,
|
| 26773 |
offsetY: 0,
|
27297 |
offsetY: 0,
|
| Línea 27001... |
Línea 27525... |
| 27001 |
const getRawTarget = selection => {
|
27525 |
const getRawTarget = selection => {
|
| 27002 |
const sel = selection.getSel();
|
27526 |
const sel = selection.getSel();
|
| 27003 |
if (isNonNullable(sel)) {
|
27527 |
if (isNonNullable(sel)) {
|
| 27004 |
const rng = sel.getRangeAt(0);
|
27528 |
const rng = sel.getRangeAt(0);
|
| 27005 |
const startContainer = rng.startContainer;
|
27529 |
const startContainer = rng.startContainer;
|
| 27006 |
return isText$a(startContainer) ? startContainer.parentNode : startContainer;
|
27530 |
return isText$b(startContainer) ? startContainer.parentNode : startContainer;
|
| 27007 |
} else {
|
27531 |
} else {
|
| 27008 |
return null;
|
27532 |
return null;
|
| 27009 |
}
|
27533 |
}
|
| 27010 |
};
|
27534 |
};
|
| 27011 |
const drop = (state, editor) => e => {
|
27535 |
const drop = (state, editor) => e => {
|
| Línea 27306... |
Línea 27830... |
| 27306 |
const setupOffscreenSelection = (node, targetClone) => {
|
27830 |
const setupOffscreenSelection = (node, targetClone) => {
|
| 27307 |
const body = SugarElement.fromDom(editor.getBody());
|
27831 |
const body = SugarElement.fromDom(editor.getBody());
|
| 27308 |
const doc = editor.getDoc();
|
27832 |
const doc = editor.getDoc();
|
| 27309 |
const realSelectionContainer = descendant$1(body, '#' + realSelectionId).getOrThunk(() => {
|
27833 |
const realSelectionContainer = descendant$1(body, '#' + realSelectionId).getOrThunk(() => {
|
| 27310 |
const newContainer = SugarElement.fromHtml('<div data-mce-bogus="all" class="mce-offscreen-selection"></div>', doc);
|
27834 |
const newContainer = SugarElement.fromHtml('<div data-mce-bogus="all" class="mce-offscreen-selection"></div>', doc);
|
| 27311 |
set$3(newContainer, 'id', realSelectionId);
|
27835 |
set$4(newContainer, 'id', realSelectionId);
|
| 27312 |
append$1(body, newContainer);
|
27836 |
append$1(body, newContainer);
|
| 27313 |
return newContainer;
|
27837 |
return newContainer;
|
| 27314 |
});
|
27838 |
});
|
| 27315 |
const newRange = dom.createRng();
|
27839 |
const newRange = dom.createRng();
|
| 27316 |
empty(realSelectionContainer);
|
27840 |
empty(realSelectionContainer);
|
| Línea 27341... |
Línea 27865... |
| 27341 |
}
|
27865 |
}
|
| 27342 |
const range = setupOffscreenSelection(elm, e.targetClone);
|
27866 |
const range = setupOffscreenSelection(elm, e.targetClone);
|
| 27343 |
const nodeElm = SugarElement.fromDom(elm);
|
27867 |
const nodeElm = SugarElement.fromDom(elm);
|
| 27344 |
each$e(descendants(SugarElement.fromDom(editor.getBody()), `*[${ elementSelectionAttr }]`), elm => {
|
27868 |
each$e(descendants(SugarElement.fromDom(editor.getBody()), `*[${ elementSelectionAttr }]`), elm => {
|
| 27345 |
if (!eq(nodeElm, elm)) {
|
27869 |
if (!eq(nodeElm, elm)) {
|
| 27346 |
remove$a(elm, elementSelectionAttr);
|
27870 |
remove$9(elm, elementSelectionAttr);
|
| 27347 |
}
|
27871 |
}
|
| 27348 |
});
|
27872 |
});
|
| 27349 |
if (!dom.getAttrib(elm, elementSelectionAttr)) {
|
27873 |
if (!dom.getAttrib(elm, elementSelectionAttr)) {
|
| 27350 |
elm.setAttribute(elementSelectionAttr, '1');
|
27874 |
elm.setAttribute(elementSelectionAttr, '1');
|
| 27351 |
}
|
27875 |
}
|
| Línea 27389... |
Línea 27913... |
| 27389 |
return null;
|
27913 |
return null;
|
| 27390 |
}
|
27914 |
}
|
| 27391 |
let startContainer = range.startContainer;
|
27915 |
let startContainer = range.startContainer;
|
| 27392 |
let startOffset = range.startOffset;
|
27916 |
let startOffset = range.startOffset;
|
| 27393 |
const endOffset = range.endOffset;
|
27917 |
const endOffset = range.endOffset;
|
| 27394 |
if (isText$a(startContainer) && startOffset === 0 && isContentEditableFalse(startContainer.parentNode)) {
|
27918 |
if (isText$b(startContainer) && startOffset === 0 && isContentEditableFalse(startContainer.parentNode)) {
|
| 27395 |
startContainer = startContainer.parentNode;
|
27919 |
startContainer = startContainer.parentNode;
|
| 27396 |
startOffset = dom.nodeIndex(startContainer);
|
27920 |
startOffset = dom.nodeIndex(startContainer);
|
| 27397 |
startContainer = startContainer.parentNode;
|
27921 |
startContainer = startContainer.parentNode;
|
| 27398 |
}
|
27922 |
}
|
| 27399 |
if (!isElement$6(startContainer)) {
|
27923 |
if (!isElement$6(startContainer)) {
|
| Línea 27409... |
Línea 27933... |
| 27409 |
};
|
27933 |
};
|
| 27410 |
const removeElementSelection = () => {
|
27934 |
const removeElementSelection = () => {
|
| 27411 |
if (selectedElement) {
|
27935 |
if (selectedElement) {
|
| 27412 |
selectedElement.removeAttribute(elementSelectionAttr);
|
27936 |
selectedElement.removeAttribute(elementSelectionAttr);
|
| 27413 |
}
|
27937 |
}
|
| 27414 |
descendant$1(SugarElement.fromDom(editor.getBody()), '#' + realSelectionId).each(remove$5);
|
27938 |
descendant$1(SugarElement.fromDom(editor.getBody()), '#' + realSelectionId).each(remove$4);
|
| 27415 |
selectedElement = null;
|
27939 |
selectedElement = null;
|
| 27416 |
};
|
27940 |
};
|
| 27417 |
const destroy = () => {
|
27941 |
const destroy = () => {
|
| 27418 |
fakeCaret.destroy();
|
27942 |
fakeCaret.destroy();
|
| 27419 |
selectedElement = null;
|
27943 |
selectedElement = null;
|
| Línea 27432... |
Línea 27956... |
| 27432 |
};
|
27956 |
};
|
| 27433 |
};
|
27957 |
};
|
| Línea 27434... |
Línea 27958... |
| 27434 |
|
27958 |
|
| 27435 |
const getNormalizedTextOffset = (container, offset) => {
|
27959 |
const getNormalizedTextOffset = (container, offset) => {
|
| 27436 |
let normalizedOffset = offset;
|
27960 |
let normalizedOffset = offset;
|
| 27437 |
for (let node = container.previousSibling; isText$a(node); node = node.previousSibling) {
|
27961 |
for (let node = container.previousSibling; isText$b(node); node = node.previousSibling) {
|
| 27438 |
normalizedOffset += node.data.length;
|
27962 |
normalizedOffset += node.data.length;
|
| 27439 |
}
|
27963 |
}
|
| 27440 |
return normalizedOffset;
|
27964 |
return normalizedOffset;
|
| 27441 |
};
|
27965 |
};
|
| 27442 |
const generatePath = (dom, root, node, offset, normalized) => {
|
27966 |
const generatePath = (dom, root, node, offset, normalized) => {
|
| 27443 |
if (isText$a(node) && (offset < 0 || offset > node.data.length)) {
|
27967 |
if (isText$b(node) && (offset < 0 || offset > node.data.length)) {
|
| 27444 |
return [];
|
27968 |
return [];
|
| 27445 |
}
|
27969 |
}
|
| 27446 |
const p = normalized && isText$a(node) ? [getNormalizedTextOffset(node, offset)] : [offset];
|
27970 |
const p = normalized && isText$b(node) ? [getNormalizedTextOffset(node, offset)] : [offset];
|
| 27447 |
let current = node;
|
27971 |
let current = node;
|
| 27448 |
while (current !== root && current.parentNode) {
|
27972 |
while (current !== root && current.parentNode) {
|
| 27449 |
p.push(dom.nodeIndex(current, normalized));
|
27973 |
p.push(dom.nodeIndex(current, normalized));
|
| 27450 |
current = current.parentNode;
|
27974 |
current = current.parentNode;
|
| Línea 27465... |
Línea 27989... |
| 27465 |
if (!isNumber(offset)) {
|
27989 |
if (!isNumber(offset)) {
|
| 27466 |
return Optional.none();
|
27990 |
return Optional.none();
|
| 27467 |
} else {
|
27991 |
} else {
|
| 27468 |
const resolvedNode = foldl(nodePath, (optNode, index) => optNode.bind(node => Optional.from(node.childNodes[index])), Optional.some(root));
|
27992 |
const resolvedNode = foldl(nodePath, (optNode, index) => optNode.bind(node => Optional.from(node.childNodes[index])), Optional.some(root));
|
| 27469 |
return resolvedNode.bind(node => {
|
27993 |
return resolvedNode.bind(node => {
|
| 27470 |
if (isText$a(node) && (offset < 0 || offset > node.data.length)) {
|
27994 |
if (isText$b(node) && (offset < 0 || offset > node.data.length)) {
|
| 27471 |
return Optional.none();
|
27995 |
return Optional.none();
|
| 27472 |
} else {
|
27996 |
} else {
|
| 27473 |
return Optional.some({
|
27997 |
return Optional.some({
|
| 27474 |
node,
|
27998 |
node,
|
| 27475 |
offset
|
27999 |
offset
|
| Línea 27493... |
Línea 28017... |
| 27493 |
const generatePathRangeFromRange = (dom, root, range, normalized = false) => generatePathRange(dom, root, range.startContainer, range.startOffset, range.endContainer, range.endOffset, normalized);
|
28017 |
const generatePathRangeFromRange = (dom, root, range, normalized = false) => generatePathRange(dom, root, range.startContainer, range.startOffset, range.endContainer, range.endOffset, normalized);
|
| Línea 27494... |
Línea 28018... |
| 27494 |
|
28018 |
|
| 27495 |
const cleanEmptyNodes = (dom, node, isRoot) => {
|
28019 |
const cleanEmptyNodes = (dom, node, isRoot) => {
|
| 27496 |
if (node && dom.isEmpty(node) && !isRoot(node)) {
|
28020 |
if (node && dom.isEmpty(node) && !isRoot(node)) {
|
| 27497 |
const parent = node.parentNode;
|
28021 |
const parent = node.parentNode;
|
| 27498 |
dom.remove(node, isText$a(node.firstChild) && isWhitespaceText(node.firstChild.data));
|
28022 |
dom.remove(node, isText$b(node.firstChild) && isWhitespaceText(node.firstChild.data));
|
| 27499 |
cleanEmptyNodes(dom, parent, isRoot);
|
28023 |
cleanEmptyNodes(dom, parent, isRoot);
|
| 27500 |
}
|
28024 |
}
|
| 27501 |
};
|
28025 |
};
|
| 27502 |
const deleteRng = (dom, rng, isRoot, clean = true) => {
|
28026 |
const deleteRng = (dom, rng, isRoot, clean = true) => {
|
| 27503 |
const startParent = rng.startContainer.parentNode;
|
28027 |
const startParent = rng.startContainer.parentNode;
|
| 27504 |
const endParent = rng.endContainer.parentNode;
|
28028 |
const endParent = rng.endContainer.parentNode;
|
| 27505 |
rng.deleteContents();
|
28029 |
rng.deleteContents();
|
| 27506 |
if (clean && !isRoot(rng.startContainer)) {
|
28030 |
if (clean && !isRoot(rng.startContainer)) {
|
| 27507 |
if (isText$a(rng.startContainer) && rng.startContainer.data.length === 0) {
|
28031 |
if (isText$b(rng.startContainer) && rng.startContainer.data.length === 0) {
|
| 27508 |
dom.remove(rng.startContainer);
|
28032 |
dom.remove(rng.startContainer);
|
| 27509 |
}
|
28033 |
}
|
| 27510 |
if (isText$a(rng.endContainer) && rng.endContainer.data.length === 0) {
|
28034 |
if (isText$b(rng.endContainer) && rng.endContainer.data.length === 0) {
|
| 27511 |
dom.remove(rng.endContainer);
|
28035 |
dom.remove(rng.endContainer);
|
| 27512 |
}
|
28036 |
}
|
| 27513 |
cleanEmptyNodes(dom, startParent, isRoot);
|
28037 |
cleanEmptyNodes(dom, startParent, isRoot);
|
| 27514 |
if (startParent !== endParent) {
|
28038 |
if (startParent !== endParent) {
|
| Línea 27533... |
Línea 28057... |
| 27533 |
rng.setStart(block, 0);
|
28057 |
rng.setStart(block, 0);
|
| 27534 |
rng.setEnd(node, offset);
|
28058 |
rng.setEnd(node, offset);
|
| 27535 |
return rng.toString();
|
28059 |
return rng.toString();
|
| 27536 |
};
|
28060 |
};
|
| Línea 27537... |
Línea -... |
| 27537 |
|
- |
|
| 27538 |
const startsWithSingleSpace = s => /^\s[^\s]/.test(s);
|
- |
|
| 27539 |
const stripPattern = (dom, block, pattern) => {
|
- |
|
| 27540 |
const firstTextNode = textAfter(block, 0, block);
|
- |
|
| 27541 |
firstTextNode.each(spot => {
|
- |
|
| 27542 |
const node = spot.container;
|
- |
|
| 27543 |
scanRight(node, pattern.start.length, block).each(end => {
|
- |
|
| 27544 |
const rng = dom.createRng();
|
- |
|
| 27545 |
rng.setStart(node, 0);
|
- |
|
| 27546 |
rng.setEnd(end.container, end.offset);
|
- |
|
| 27547 |
deleteRng(dom, rng, e => e === block);
|
- |
|
| 27548 |
});
|
- |
|
| 27549 |
const text = SugarElement.fromDom(node);
|
- |
|
| 27550 |
const textContent = get$3(text);
|
- |
|
| 27551 |
if (startsWithSingleSpace(textContent)) {
|
- |
|
| 27552 |
set(text, textContent.slice(1));
|
- |
|
| 27553 |
}
|
- |
|
| 27554 |
});
|
- |
|
| 27555 |
};
|
- |
|
| 27556 |
const applyPattern$1 = (editor, match) => {
|
- |
|
| 27557 |
const dom = editor.dom;
|
- |
|
| 27558 |
const pattern = match.pattern;
|
- |
|
| 27559 |
const rng = resolvePathRange(dom.getRoot(), match.range).getOrDie('Unable to resolve path range');
|
- |
|
| 27560 |
const isBlockFormatName = (name, formatter) => {
|
- |
|
| 27561 |
const formatSet = formatter.get(name);
|
- |
|
| 27562 |
return isArray$1(formatSet) && head(formatSet).exists(format => has$2(format, 'block'));
|
- |
|
| 27563 |
};
|
- |
|
| 27564 |
getParentBlock(editor, rng).each(block => {
|
- |
|
| 27565 |
if (pattern.type === 'block-format') {
|
- |
|
| 27566 |
if (isBlockFormatName(pattern.format, editor.formatter)) {
|
- |
|
| 27567 |
editor.undoManager.transact(() => {
|
- |
|
| 27568 |
stripPattern(editor.dom, block, pattern);
|
- |
|
| 27569 |
editor.formatter.apply(pattern.format);
|
- |
|
| 27570 |
});
|
- |
|
| 27571 |
}
|
- |
|
| 27572 |
} else if (pattern.type === 'block-command') {
|
- |
|
| 27573 |
editor.undoManager.transact(() => {
|
- |
|
| 27574 |
stripPattern(editor.dom, block, pattern);
|
- |
|
| 27575 |
editor.execCommand(pattern.cmd, false, pattern.value);
|
- |
|
| 27576 |
});
|
- |
|
| 27577 |
}
|
- |
|
| 27578 |
});
|
- |
|
| 27579 |
return true;
|
- |
|
| 27580 |
};
|
- |
|
| 27581 |
const sortPatterns$1 = patterns => sort(patterns, (a, b) => b.start.length - a.start.length);
|
- |
|
| 27582 |
const findPattern$1 = (patterns, text) => {
|
- |
|
| 27583 |
const sortedPatterns = sortPatterns$1(patterns);
|
- |
|
| 27584 |
const nuText = text.replace(nbsp, ' ');
|
- |
|
| 27585 |
return find$2(sortedPatterns, pattern => text.indexOf(pattern.start) === 0 || nuText.indexOf(pattern.start) === 0);
|
- |
|
| 27586 |
};
|
- |
|
| 27587 |
const findPatterns$1 = (editor, block, patternSet, normalizedMatches) => {
|
- |
|
| 27588 |
var _a;
|
- |
|
| 27589 |
const dom = editor.dom;
|
- |
|
| 27590 |
const forcedRootBlock = getForcedRootBlock(editor);
|
- |
|
| 27591 |
if (!dom.is(block, forcedRootBlock)) {
|
- |
|
| 27592 |
return [];
|
- |
|
| 27593 |
}
|
- |
|
| 27594 |
const blockText = (_a = block.textContent) !== null && _a !== void 0 ? _a : '';
|
- |
|
| 27595 |
return findPattern$1(patternSet.blockPatterns, blockText).map(pattern => {
|
- |
|
| 27596 |
if (Tools.trim(blockText).length === pattern.start.length) {
|
- |
|
| 27597 |
return [];
|
- |
|
| 27598 |
}
|
- |
|
| 27599 |
return [{
|
- |
|
| 27600 |
pattern,
|
- |
|
| 27601 |
range: generatePathRange(dom, dom.getRoot(), block, 0, block, 0, normalizedMatches)
|
- |
|
| 27602 |
}];
|
- |
|
| 27603 |
}).getOr([]);
|
- |
|
| 27604 |
};
|
- |
|
| 27605 |
const applyMatches$1 = (editor, matches) => {
|
- |
|
| 27606 |
if (matches.length === 0) {
|
- |
|
| 27607 |
return;
|
- |
|
| 27608 |
}
|
- |
|
| 27609 |
const bookmark = editor.selection.getBookmark();
|
- |
|
| 27610 |
each$e(matches, match => applyPattern$1(editor, match));
|
- |
|
| 27611 |
editor.selection.moveToBookmark(bookmark);
|
- |
|
| 27612 |
};
|
- |
|
| 27613 |
|
28061 |
|
| 27614 |
const newMarker = (dom, id) => dom.create('span', {
|
28062 |
const newMarker = (dom, id) => dom.create('span', {
|
| 27615 |
'data-mce-type': 'bookmark',
|
28063 |
'data-mce-type': 'bookmark',
|
| 27616 |
id
|
28064 |
id
|
| 27617 |
});
|
28065 |
});
|
| Línea 27697... |
Línea 28145... |
| 27697 |
}
|
28145 |
}
|
| 27698 |
return Optional.some(startRange);
|
28146 |
return Optional.some(startRange);
|
| 27699 |
});
|
28147 |
});
|
| 27700 |
});
|
28148 |
});
|
| 27701 |
};
|
28149 |
};
|
| 27702 |
const findPattern = (editor, block, details, normalizedMatches) => {
|
28150 |
const findPattern$3 = (editor, block, details, normalizedMatches) => {
|
| 27703 |
const dom = editor.dom;
|
28151 |
const dom = editor.dom;
|
| 27704 |
const root = dom.getRoot();
|
28152 |
const root = dom.getRoot();
|
| 27705 |
const pattern = details.pattern;
|
28153 |
const pattern = details.pattern;
|
| 27706 |
const endNode = details.position.container;
|
28154 |
const endNode = details.position.container;
|
| 27707 |
const endOffset = details.position.offset;
|
28155 |
const endOffset = details.position.offset;
|
| Línea 27747... |
Línea 28195... |
| 27747 |
if (!endsWith(text, pattern.end)) {
|
28195 |
if (!endsWith(text, pattern.end)) {
|
| 27748 |
continue;
|
28196 |
continue;
|
| 27749 |
}
|
28197 |
}
|
| 27750 |
const patternsWithoutCurrent = patterns.slice();
|
28198 |
const patternsWithoutCurrent = patterns.slice();
|
| 27751 |
patternsWithoutCurrent.splice(i, 1);
|
28199 |
patternsWithoutCurrent.splice(i, 1);
|
| 27752 |
const result = findPattern(editor, block, {
|
28200 |
const result = findPattern$3(editor, block, {
|
| 27753 |
pattern,
|
28201 |
pattern,
|
| 27754 |
remainingPatterns: patternsWithoutCurrent,
|
28202 |
remainingPatterns: patternsWithoutCurrent,
|
| 27755 |
position: endSpot
|
28203 |
position: endSpot
|
| 27756 |
}, normalizedMatches);
|
28204 |
}, normalizedMatches);
|
| 27757 |
if (result.isNone() && offset > 0) {
|
28205 |
if (result.isNone() && offset > 0) {
|
| Línea 27762... |
Línea 28210... |
| 27762 |
}
|
28210 |
}
|
| 27763 |
}
|
28211 |
}
|
| 27764 |
return Optional.none();
|
28212 |
return Optional.none();
|
| 27765 |
});
|
28213 |
});
|
| 27766 |
};
|
28214 |
};
|
| 27767 |
const applyPattern = (editor, pattern, patternRange) => {
|
28215 |
const applyPattern$2 = (editor, pattern, patternRange) => {
|
| 27768 |
editor.selection.setRng(patternRange);
|
28216 |
editor.selection.setRng(patternRange);
|
| 27769 |
if (pattern.type === 'inline-format') {
|
28217 |
if (pattern.type === 'inline-format') {
|
| 27770 |
each$e(pattern.format, format => {
|
28218 |
each$e(pattern.format, format => {
|
| 27771 |
editor.formatter.apply(format);
|
28219 |
editor.formatter.apply(format);
|
| 27772 |
});
|
28220 |
});
|
| Línea 27775... |
Línea 28223... |
| 27775 |
}
|
28223 |
}
|
| 27776 |
};
|
28224 |
};
|
| 27777 |
const applyReplacementPattern = (editor, pattern, marker, isRoot) => {
|
28225 |
const applyReplacementPattern = (editor, pattern, marker, isRoot) => {
|
| 27778 |
const markerRange = rangeFromMarker(editor.dom, marker);
|
28226 |
const markerRange = rangeFromMarker(editor.dom, marker);
|
| 27779 |
deleteRng(editor.dom, markerRange, isRoot);
|
28227 |
deleteRng(editor.dom, markerRange, isRoot);
|
| 27780 |
applyPattern(editor, pattern, markerRange);
|
28228 |
applyPattern$2(editor, pattern, markerRange);
|
| 27781 |
};
|
28229 |
};
|
| 27782 |
const applyPatternWithContent = (editor, pattern, startMarker, endMarker, isRoot) => {
|
28230 |
const applyPatternWithContent = (editor, pattern, startMarker, endMarker, isRoot) => {
|
| 27783 |
const dom = editor.dom;
|
28231 |
const dom = editor.dom;
|
| 27784 |
const markerEndRange = rangeFromMarker(dom, endMarker);
|
28232 |
const markerEndRange = rangeFromMarker(dom, endMarker);
|
| 27785 |
const markerStartRange = rangeFromMarker(dom, startMarker);
|
28233 |
const markerStartRange = rangeFromMarker(dom, startMarker);
|
| Línea 27789... |
Línea 28237... |
| 27789 |
prefix: startMarker.prefix,
|
28237 |
prefix: startMarker.prefix,
|
| 27790 |
start: startMarker.end,
|
28238 |
start: startMarker.end,
|
| 27791 |
end: endMarker.start
|
28239 |
end: endMarker.start
|
| 27792 |
};
|
28240 |
};
|
| 27793 |
const patternRange = rangeFromMarker(dom, patternMarker);
|
28241 |
const patternRange = rangeFromMarker(dom, patternMarker);
|
| 27794 |
applyPattern(editor, pattern, patternRange);
|
28242 |
applyPattern$2(editor, pattern, patternRange);
|
| 27795 |
};
|
28243 |
};
|
| 27796 |
const addMarkers = (dom, matches) => {
|
28244 |
const addMarkers = (dom, matches) => {
|
| 27797 |
const markerPrefix = generate$1('mce_textpattern');
|
28245 |
const markerPrefix = generate$1('mce_textpattern');
|
| 27798 |
const matchesWithEnds = foldr(matches, (acc, match) => {
|
28246 |
const matchesWithEnds = foldr(matches, (acc, match) => {
|
| 27799 |
const endMarker = createMarker(dom, markerPrefix + `_end${ acc.length }`, match.endRng);
|
28247 |
const endMarker = createMarker(dom, markerPrefix + `_end${ acc.length }`, match.endRng);
|
| Línea 27809... |
Línea 28257... |
| 27809 |
...match,
|
28257 |
...match,
|
| 27810 |
startMarker
|
28258 |
startMarker
|
| 27811 |
}]);
|
28259 |
}]);
|
| 27812 |
}, []);
|
28260 |
}, []);
|
| 27813 |
};
|
28261 |
};
|
| 27814 |
const sortPatterns = patterns => sort(patterns, (a, b) => b.end.length - a.end.length);
|
28262 |
const sortPatterns$1 = patterns => sort(patterns, (a, b) => b.end.length - a.end.length);
|
| 27815 |
const getBestMatches = (matches, matchesWithSortedPatterns) => {
|
28263 |
const getBestMatches = (matches, matchesWithSortedPatterns) => {
|
| 27816 |
const hasSameMatches = forall(matches, match => exists(matchesWithSortedPatterns, sortedMatch => match.pattern.start === sortedMatch.pattern.start && match.pattern.end === sortedMatch.pattern.end));
|
28264 |
const hasSameMatches = forall(matches, match => exists(matchesWithSortedPatterns, sortedMatch => match.pattern.start === sortedMatch.pattern.start && match.pattern.end === sortedMatch.pattern.end));
|
| 27817 |
if (matches.length === matchesWithSortedPatterns.length) {
|
28265 |
if (matches.length === matchesWithSortedPatterns.length) {
|
| 27818 |
if (hasSameMatches) {
|
28266 |
if (hasSameMatches) {
|
| 27819 |
return matches;
|
28267 |
return matches;
|
| Línea 27821... |
Línea 28269... |
| 27821 |
return matchesWithSortedPatterns;
|
28269 |
return matchesWithSortedPatterns;
|
| 27822 |
}
|
28270 |
}
|
| 27823 |
}
|
28271 |
}
|
| 27824 |
return matches.length > matchesWithSortedPatterns.length ? matches : matchesWithSortedPatterns;
|
28272 |
return matches.length > matchesWithSortedPatterns.length ? matches : matchesWithSortedPatterns;
|
| 27825 |
};
|
28273 |
};
|
| 27826 |
const findPatterns = (editor, block, node, offset, patternSet, normalizedMatches) => {
|
28274 |
const findPatterns$2 = (editor, block, node, offset, patternSet, normalizedMatches) => {
|
| 27827 |
const matches = findPatternsRec(editor, patternSet.inlinePatterns, node, offset, block, normalizedMatches).fold(() => [], result => result.matches);
|
28275 |
const matches = findPatternsRec(editor, patternSet.inlinePatterns, node, offset, block, normalizedMatches).fold(() => [], result => result.matches);
|
| 27828 |
const matchesWithSortedPatterns = findPatternsRec(editor, sortPatterns(patternSet.inlinePatterns), node, offset, block, normalizedMatches).fold(() => [], result => result.matches);
|
28276 |
const matchesWithSortedPatterns = findPatternsRec(editor, sortPatterns$1(patternSet.inlinePatterns), node, offset, block, normalizedMatches).fold(() => [], result => result.matches);
|
| 27829 |
return getBestMatches(matches, matchesWithSortedPatterns);
|
28277 |
return getBestMatches(matches, matchesWithSortedPatterns);
|
| 27830 |
};
|
28278 |
};
|
| 27831 |
const applyMatches = (editor, matches) => {
|
28279 |
const applyMatches$2 = (editor, matches) => {
|
| 27832 |
if (matches.length === 0) {
|
28280 |
if (matches.length === 0) {
|
| 27833 |
return;
|
28281 |
return;
|
| 27834 |
}
|
28282 |
}
|
| 27835 |
const dom = editor.dom;
|
28283 |
const dom = editor.dom;
|
| 27836 |
const bookmark = editor.selection.getBookmark();
|
28284 |
const bookmark = editor.selection.getBookmark();
|
| Línea 27847... |
Línea 28295... |
| 27847 |
removeMarker(dom, match.startMarker, isRoot);
|
28295 |
removeMarker(dom, match.startMarker, isRoot);
|
| 27848 |
});
|
28296 |
});
|
| 27849 |
editor.selection.moveToBookmark(bookmark);
|
28297 |
editor.selection.moveToBookmark(bookmark);
|
| 27850 |
};
|
28298 |
};
|
| Línea -... |
Línea 28299... |
| - |
|
28299 |
|
| - |
|
28300 |
const stripPattern$1 = (dom, block, pattern) => {
|
| - |
|
28301 |
return textAfter(block, 0, block).map(spot => {
|
| - |
|
28302 |
const node = spot.container;
|
| - |
|
28303 |
scanRight(node, pattern.start.length, block).each(end => {
|
| - |
|
28304 |
const rng = dom.createRng();
|
| - |
|
28305 |
rng.setStart(node, 0);
|
| - |
|
28306 |
rng.setEnd(end.container, end.offset);
|
| - |
|
28307 |
deleteRng(dom, rng, e => e === block);
|
| - |
|
28308 |
});
|
| - |
|
28309 |
return node;
|
| - |
|
28310 |
});
|
| - |
|
28311 |
};
|
| - |
|
28312 |
const createApplyPattern = stripPattern => (editor, match) => {
|
| - |
|
28313 |
const dom = editor.dom;
|
| - |
|
28314 |
const pattern = match.pattern;
|
| - |
|
28315 |
const rng = resolvePathRange(dom.getRoot(), match.range).getOrDie('Unable to resolve path range');
|
| - |
|
28316 |
const isBlockFormatName = (name, formatter) => {
|
| - |
|
28317 |
const formatSet = formatter.get(name);
|
| - |
|
28318 |
return isArray$1(formatSet) && head(formatSet).exists(format => has$2(format, 'block'));
|
| - |
|
28319 |
};
|
| - |
|
28320 |
getParentBlock(editor, rng).each(block => {
|
| - |
|
28321 |
if (pattern.type === 'block-format') {
|
| - |
|
28322 |
if (isBlockFormatName(pattern.format, editor.formatter)) {
|
| - |
|
28323 |
editor.undoManager.transact(() => {
|
| - |
|
28324 |
stripPattern(editor.dom, block, pattern);
|
| - |
|
28325 |
editor.formatter.apply(pattern.format);
|
| - |
|
28326 |
});
|
| - |
|
28327 |
}
|
| - |
|
28328 |
} else if (pattern.type === 'block-command') {
|
| - |
|
28329 |
editor.undoManager.transact(() => {
|
| - |
|
28330 |
stripPattern(editor.dom, block, pattern);
|
| - |
|
28331 |
editor.execCommand(pattern.cmd, false, pattern.value);
|
| - |
|
28332 |
});
|
| - |
|
28333 |
}
|
| - |
|
28334 |
});
|
| - |
|
28335 |
return true;
|
| - |
|
28336 |
};
|
| - |
|
28337 |
const sortPatterns = patterns => sort(patterns, (a, b) => b.start.length - a.start.length);
|
| - |
|
28338 |
const findPattern$2 = predicate => (patterns, text) => {
|
| - |
|
28339 |
const sortedPatterns = sortPatterns(patterns);
|
| - |
|
28340 |
const nuText = text.replace(nbsp, ' ');
|
| - |
|
28341 |
return find$2(sortedPatterns, pattern => predicate(pattern, text, nuText));
|
| - |
|
28342 |
};
|
| - |
|
28343 |
const createFindPatterns = (findPattern, skipFullMatch) => (editor, block, patternSet, normalizedMatches, text) => {
|
| - |
|
28344 |
var _a;
|
| - |
|
28345 |
if (text === void 0) {
|
| - |
|
28346 |
text = (_a = block.textContent) !== null && _a !== void 0 ? _a : '';
|
| - |
|
28347 |
}
|
| - |
|
28348 |
const dom = editor.dom;
|
| - |
|
28349 |
const forcedRootBlock = getForcedRootBlock(editor);
|
| - |
|
28350 |
if (!dom.is(block, forcedRootBlock)) {
|
| - |
|
28351 |
return [];
|
| - |
|
28352 |
}
|
| - |
|
28353 |
return findPattern(patternSet.blockPatterns, text).map(pattern => {
|
| - |
|
28354 |
if (skipFullMatch && Tools.trim(text).length === pattern.start.length) {
|
| - |
|
28355 |
return [];
|
| - |
|
28356 |
}
|
| - |
|
28357 |
return [{
|
| - |
|
28358 |
pattern,
|
| - |
|
28359 |
range: generatePathRange(dom, dom.getRoot(), block, 0, block, 0, normalizedMatches)
|
| - |
|
28360 |
}];
|
| - |
|
28361 |
}).getOr([]);
|
| - |
|
28362 |
};
|
| - |
|
28363 |
|
| - |
|
28364 |
const startsWithSingleSpace = s => /^\s[^\s]/.test(s);
|
| - |
|
28365 |
const stripPattern = (dom, block, pattern) => {
|
| - |
|
28366 |
stripPattern$1(dom, block, pattern).each(node => {
|
| - |
|
28367 |
const text = SugarElement.fromDom(node);
|
| - |
|
28368 |
const textContent = get$3(text);
|
| - |
|
28369 |
if (startsWithSingleSpace(textContent)) {
|
| - |
|
28370 |
set(text, textContent.slice(1));
|
| - |
|
28371 |
}
|
| - |
|
28372 |
});
|
| - |
|
28373 |
};
|
| - |
|
28374 |
const applyPattern$1 = createApplyPattern(stripPattern);
|
| - |
|
28375 |
const findPattern$1 = findPattern$2((pattern, text, nuText) => text.indexOf(pattern.start) === 0 || nuText.indexOf(pattern.start) === 0);
|
| 27851 |
|
28376 |
const findPatterns$1 = createFindPatterns(findPattern$1, true);
|
| 27852 |
const handleEnter = (editor, patternSet) => {
|
28377 |
const getMatches$1 = (editor, patternSet) => {
|
| 27853 |
const rng = editor.selection.getRng();
|
28378 |
const rng = editor.selection.getRng();
|
| 27854 |
return getParentBlock(editor, rng).map(block => {
|
28379 |
return getParentBlock(editor, rng).map(block => {
|
| 27855 |
var _a;
|
28380 |
var _a;
|
| 27856 |
const offset = Math.max(0, rng.startOffset);
|
28381 |
const offset = Math.max(0, rng.startOffset);
|
| 27857 |
const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, (_a = block.textContent) !== null && _a !== void 0 ? _a : '');
|
28382 |
const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, (_a = block.textContent) !== null && _a !== void 0 ? _a : '');
|
| 27858 |
const inlineMatches = findPatterns(editor, block, rng.startContainer, offset, dynamicPatternSet, true);
|
28383 |
const inlineMatches = findPatterns$2(editor, block, rng.startContainer, offset, dynamicPatternSet, true);
|
| 27859 |
const blockMatches = findPatterns$1(editor, block, dynamicPatternSet, true);
|
- |
|
| 27860 |
if (blockMatches.length > 0 || inlineMatches.length > 0) {
|
28384 |
const blockMatches = findPatterns$1(editor, block, dynamicPatternSet, true);
|
| 27861 |
editor.undoManager.add();
|
28385 |
return {
|
| 27862 |
editor.undoManager.extra(() => {
|
- |
|
| 27863 |
editor.execCommand('mceInsertNewLine');
|
28386 |
inlineMatches,
|
| 27864 |
}, () => {
|
28387 |
blockMatches
|
| 27865 |
insert$5(editor);
|
28388 |
};
|
| - |
|
28389 |
}).filter(({inlineMatches, blockMatches}) => blockMatches.length > 0 || inlineMatches.length > 0);
|
| 27866 |
applyMatches(editor, inlineMatches);
|
28390 |
};
|
| 27867 |
applyMatches$1(editor, blockMatches);
|
- |
|
| 27868 |
const range = editor.selection.getRng();
|
- |
|
| 27869 |
const spot = textBefore(range.startContainer, range.startOffset, editor.dom.getRoot());
|
- |
|
| 27870 |
editor.execCommand('mceInsertNewLine');
|
28391 |
const applyMatches$1 = (editor, matches) => {
|
| 27871 |
spot.each(s => {
|
- |
|
| 27872 |
const node = s.container;
|
- |
|
| 27873 |
if (node.data.charAt(s.offset - 1) === zeroWidth) {
|
- |
|
| 27874 |
node.deleteData(s.offset - 1, 1);
|
- |
|
| 27875 |
cleanEmptyNodes(editor.dom, node.parentNode, e => e === editor.dom.getRoot());
|
- |
|
| 27876 |
}
|
28392 |
if (matches.length === 0) {
|
| 27877 |
});
|
28393 |
return;
|
| 27878 |
});
|
28394 |
}
|
| 27879 |
return true;
|
- |
|
| 27880 |
}
|
28395 |
const bookmark = editor.selection.getBookmark();
|
| 27881 |
return false;
|
28396 |
each$e(matches, match => applyPattern$1(editor, match));
|
| 27882 |
}).getOr(false);
|
28397 |
editor.selection.moveToBookmark(bookmark);
|
| - |
|
28398 |
};
|
| - |
|
28399 |
|
| - |
|
28400 |
const applyPattern = createApplyPattern(stripPattern$1);
|
| - |
|
28401 |
const findPattern = findPattern$2((pattern, text, nuText) => text === pattern.start || nuText === pattern.start);
|
| - |
|
28402 |
const findPatterns = createFindPatterns(findPattern, false);
|
| - |
|
28403 |
const getMatches = (editor, patternSet) => {
|
| - |
|
28404 |
const rng = editor.selection.getRng();
|
| - |
|
28405 |
return getParentBlock(editor, rng).map(block => {
|
| - |
|
28406 |
const offset = Math.max(0, rng.startOffset);
|
| - |
|
28407 |
const beforeText = getBeforeText(editor.dom, block, rng.startContainer, offset);
|
| - |
|
28408 |
const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, beforeText);
|
| - |
|
28409 |
return findPatterns(editor, block, dynamicPatternSet, false, beforeText);
|
| - |
|
28410 |
}).filter(matches => matches.length > 0);
|
| - |
|
28411 |
};
|
| - |
|
28412 |
const applyMatches = (editor, matches) => {
|
| - |
|
28413 |
each$e(matches, match => applyPattern(editor, match));
|
| - |
|
28414 |
};
|
| - |
|
28415 |
|
| - |
|
28416 |
const handleEnter = (editor, patternSet) => getMatches$1(editor, patternSet).fold(never, ({inlineMatches, blockMatches}) => {
|
| - |
|
28417 |
editor.undoManager.add();
|
| - |
|
28418 |
editor.undoManager.extra(() => {
|
| - |
|
28419 |
editor.execCommand('mceInsertNewLine');
|
| - |
|
28420 |
}, () => {
|
| - |
|
28421 |
insert$5(editor);
|
| - |
|
28422 |
applyMatches$2(editor, inlineMatches);
|
| - |
|
28423 |
applyMatches$1(editor, blockMatches);
|
| - |
|
28424 |
const range = editor.selection.getRng();
|
| - |
|
28425 |
const spot = textBefore(range.startContainer, range.startOffset, editor.dom.getRoot());
|
| - |
|
28426 |
editor.execCommand('mceInsertNewLine');
|
| - |
|
28427 |
spot.each(s => {
|
| - |
|
28428 |
const node = s.container;
|
| - |
|
28429 |
if (node.data.charAt(s.offset - 1) === zeroWidth) {
|
| - |
|
28430 |
node.deleteData(s.offset - 1, 1);
|
| - |
|
28431 |
cleanEmptyNodes(editor.dom, node.parentNode, e => e === editor.dom.getRoot());
|
| - |
|
28432 |
}
|
| - |
|
28433 |
});
|
| - |
|
28434 |
});
|
| - |
|
28435 |
return true;
|
| 27883 |
};
|
28436 |
});
|
| 27884 |
const handleInlineKey = (editor, patternSet) => {
|
28437 |
const handleInlineKey = (editor, patternSet) => {
|
| 27885 |
const rng = editor.selection.getRng();
|
28438 |
const rng = editor.selection.getRng();
|
| 27886 |
getParentBlock(editor, rng).map(block => {
|
28439 |
getParentBlock(editor, rng).map(block => {
|
| 27887 |
const offset = Math.max(0, rng.startOffset - 1);
|
28440 |
const offset = Math.max(0, rng.startOffset - 1);
|
| 27888 |
const beforeText = getBeforeText(editor.dom, block, rng.startContainer, offset);
|
28441 |
const beforeText = getBeforeText(editor.dom, block, rng.startContainer, offset);
|
| 27889 |
const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, beforeText);
|
28442 |
const dynamicPatternSet = resolveFromDynamicPatterns(patternSet, block, beforeText);
|
| 27890 |
const inlineMatches = findPatterns(editor, block, rng.startContainer, offset, dynamicPatternSet, false);
|
28443 |
const inlineMatches = findPatterns$2(editor, block, rng.startContainer, offset, dynamicPatternSet, false);
|
| 27891 |
if (inlineMatches.length > 0) {
|
28444 |
if (inlineMatches.length > 0) {
|
| 27892 |
editor.undoManager.transact(() => {
|
28445 |
editor.undoManager.transact(() => {
|
| 27893 |
applyMatches(editor, inlineMatches);
|
28446 |
applyMatches$2(editor, inlineMatches);
|
| 27894 |
});
|
28447 |
});
|
| 27895 |
}
|
28448 |
}
|
| 27896 |
});
|
28449 |
});
|
| - |
|
28450 |
};
|
| - |
|
28451 |
const handleBlockPatternOnSpace = (editor, patternSet) => getMatches(editor, patternSet).fold(never, matches => {
|
| - |
|
28452 |
editor.undoManager.transact(() => {
|
| - |
|
28453 |
applyMatches(editor, matches);
|
| - |
|
28454 |
});
|
| - |
|
28455 |
return true;
|
| 27897 |
};
|
28456 |
});
|
| 27898 |
const checkKeyEvent = (codes, event, predicate) => {
|
28457 |
const checkKeyEvent = (codes, event, predicate) => {
|
| 27899 |
for (let i = 0; i < codes.length; i++) {
|
28458 |
for (let i = 0; i < codes.length; i++) {
|
| 27900 |
if (predicate(codes[i], event)) {
|
28459 |
if (predicate(codes[i], event)) {
|
| 27901 |
return true;
|
28460 |
return true;
|
| Línea 27918... |
Línea 28477... |
| 27918 |
':',
|
28477 |
':',
|
| 27919 |
'!',
|
28478 |
'!',
|
| 27920 |
'?'
|
28479 |
'?'
|
| 27921 |
];
|
28480 |
];
|
| 27922 |
const keyCodes = [32];
|
28481 |
const keyCodes = [32];
|
| 27923 |
const getPatternSet = () => createPatternSet(getTextPatterns(editor), getTextPatternsLookup(editor));
|
28482 |
const getPatternSet = () => createPatternSet(getTextPatterns(editor).filter(pattern => {
|
| - |
|
28483 |
if (pattern.type === 'inline-command' || pattern.type === 'block-command') {
|
| - |
|
28484 |
return editor.queryCommandSupported(pattern.cmd);
|
| - |
|
28485 |
}
|
| - |
|
28486 |
return true;
|
| - |
|
28487 |
}), getTextPatternsLookup(editor));
|
| 27924 |
const hasDynamicPatterns = () => hasTextPatternsLookup(editor);
|
28488 |
const hasDynamicPatterns = () => hasTextPatternsLookup(editor);
|
| 27925 |
editor.on('keydown', e => {
|
28489 |
editor.on('keydown', e => {
|
| 27926 |
if (e.keyCode === 13 && !VK.modifierPressed(e) && editor.selection.isCollapsed()) {
|
28490 |
if (e.keyCode === 13 && !VK.modifierPressed(e) && editor.selection.isCollapsed() && editor.selection.isEditable()) {
|
| 27927 |
const patternSet = getPatternSet();
|
28491 |
const patternSet = filterByTrigger(getPatternSet(), 'enter');
|
| 27928 |
const hasPatterns = patternSet.inlinePatterns.length > 0 || patternSet.blockPatterns.length > 0 || hasDynamicPatterns();
|
28492 |
const hasPatterns = patternSet.inlinePatterns.length > 0 || patternSet.blockPatterns.length > 0 || hasDynamicPatterns();
|
| 27929 |
if (hasPatterns && handleEnter(editor, patternSet)) {
|
28493 |
if (hasPatterns && handleEnter(editor, patternSet)) {
|
| 27930 |
e.preventDefault();
|
28494 |
e.preventDefault();
|
| 27931 |
}
|
28495 |
}
|
| 27932 |
}
|
28496 |
}
|
| 27933 |
}, true);
|
28497 |
}, true);
|
| - |
|
28498 |
editor.on('keydown', e => {
|
| - |
|
28499 |
if (e.keyCode === 32 && editor.selection.isCollapsed() && editor.selection.isEditable()) {
|
| - |
|
28500 |
const patternSet = filterByTrigger(getPatternSet(), 'space');
|
| - |
|
28501 |
const hasPatterns = patternSet.blockPatterns.length > 0 || hasDynamicPatterns();
|
| - |
|
28502 |
if (hasPatterns && handleBlockPatternOnSpace(editor, patternSet)) {
|
| - |
|
28503 |
e.preventDefault();
|
| - |
|
28504 |
}
|
| - |
|
28505 |
}
|
| - |
|
28506 |
}, true);
|
| 27934 |
const handleInlineTrigger = () => {
|
28507 |
const handleInlineTrigger = () => {
|
| 27935 |
if (editor.selection.isCollapsed()) {
|
28508 |
if (editor.selection.isCollapsed() && editor.selection.isEditable()) {
|
| 27936 |
const patternSet = getPatternSet();
|
28509 |
const patternSet = filterByTrigger(getPatternSet(), 'space');
|
| 27937 |
const hasPatterns = patternSet.inlinePatterns.length > 0 || hasDynamicPatterns();
|
28510 |
const hasPatterns = patternSet.inlinePatterns.length > 0 || hasDynamicPatterns();
|
| 27938 |
if (hasPatterns) {
|
28511 |
if (hasPatterns) {
|
| 27939 |
handleInlineKey(editor, patternSet);
|
28512 |
handleInlineKey(editor, patternSet);
|
| 27940 |
}
|
28513 |
}
|
| 27941 |
}
|
28514 |
}
|
| Línea 27965... |
Línea 28538... |
| 27965 |
const isiOS = Env.deviceType.isiPhone() || Env.deviceType.isiPad();
|
28538 |
const isiOS = Env.deviceType.isiPhone() || Env.deviceType.isiPad();
|
| 27966 |
const isMac = Env.os.isMacOS() || Env.os.isiOS();
|
28539 |
const isMac = Env.os.isMacOS() || Env.os.isiOS();
|
| 27967 |
const setEditorCommandState = (cmd, state) => {
|
28540 |
const setEditorCommandState = (cmd, state) => {
|
| 27968 |
try {
|
28541 |
try {
|
| 27969 |
editor.getDoc().execCommand(cmd, false, String(state));
|
28542 |
editor.getDoc().execCommand(cmd, false, String(state));
|
| 27970 |
} catch (ex) {
|
28543 |
} catch (_a) {
|
| 27971 |
}
|
28544 |
}
|
| 27972 |
};
|
28545 |
};
|
| 27973 |
const isDefaultPrevented = e => {
|
28546 |
const isDefaultPrevented = e => {
|
| 27974 |
return e.isDefaultPrevented();
|
28547 |
return e.isDefaultPrevented();
|
| 27975 |
};
|
28548 |
};
|
| Línea 27990... |
Línea 28563... |
| 27990 |
editor.on('keydown', e => {
|
28563 |
editor.on('keydown', e => {
|
| 27991 |
const keyCode = e.keyCode;
|
28564 |
const keyCode = e.keyCode;
|
| 27992 |
if (!isDefaultPrevented(e) && (keyCode === DELETE || keyCode === BACKSPACE) && editor.selection.isEditable()) {
|
28565 |
if (!isDefaultPrevented(e) && (keyCode === DELETE || keyCode === BACKSPACE) && editor.selection.isEditable()) {
|
| 27993 |
const isCollapsed = editor.selection.isCollapsed();
|
28566 |
const isCollapsed = editor.selection.isCollapsed();
|
| 27994 |
const body = editor.getBody();
|
28567 |
const body = editor.getBody();
|
| 27995 |
if (isCollapsed && !isEmpty$2(SugarElement.fromDom(body))) {
|
28568 |
if (isCollapsed && !isEmptyNode(editor.schema, body)) {
|
| 27996 |
return;
|
28569 |
return;
|
| 27997 |
}
|
28570 |
}
|
| 27998 |
if (!isCollapsed && !allContentsSelected(editor.selection.getRng())) {
|
28571 |
if (!isCollapsed && !allContentsSelected(editor.selection.getRng())) {
|
| 27999 |
return;
|
28572 |
return;
|
| 28000 |
}
|
28573 |
}
|
| Línea 28301... |
Línea 28874... |
| 28301 |
setGeckoEditingOptions();
|
28874 |
setGeckoEditingOptions();
|
| 28302 |
showBrokenImageIcon();
|
28875 |
showBrokenImageIcon();
|
| 28303 |
blockCmdArrowNavigation();
|
28876 |
blockCmdArrowNavigation();
|
| 28304 |
}
|
28877 |
}
|
| 28305 |
};
|
28878 |
};
|
| 28306 |
const dropDragEndEvent = () => {
|
- |
|
| 28307 |
editor.on('drop', event => {
|
- |
|
| 28308 |
var _a;
|
- |
|
| 28309 |
const data = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/html');
|
- |
|
| 28310 |
if (isString(data) && /^<img[^>]*>$/.test(data)) {
|
- |
|
| 28311 |
editor.dispatch('dragend', new window.DragEvent('dragend', event));
|
- |
|
| 28312 |
}
|
- |
|
| 28313 |
});
|
- |
|
| 28314 |
};
|
- |
|
| 28315 |
const setup = () => {
|
28879 |
const setup = () => {
|
| 28316 |
removeBlockQuoteOnBackSpace();
|
28880 |
removeBlockQuoteOnBackSpace();
|
| 28317 |
emptyEditorWhenDeleting();
|
28881 |
emptyEditorWhenDeleting();
|
| 28318 |
if (!Env.windowsPhone) {
|
28882 |
if (!Env.windowsPhone) {
|
| 28319 |
normalizeSelection();
|
28883 |
normalizeSelection();
|
| Línea 28340... |
Línea 28904... |
| 28340 |
setGeckoEditingOptions();
|
28904 |
setGeckoEditingOptions();
|
| 28341 |
addBrAfterLastLinks();
|
28905 |
addBrAfterLastLinks();
|
| 28342 |
showBrokenImageIcon();
|
28906 |
showBrokenImageIcon();
|
| 28343 |
blockCmdArrowNavigation();
|
28907 |
blockCmdArrowNavigation();
|
| 28344 |
disableBackspaceIntoATable();
|
28908 |
disableBackspaceIntoATable();
|
| 28345 |
dropDragEndEvent();
|
- |
|
| 28346 |
}
|
28909 |
}
|
| 28347 |
};
|
28910 |
};
|
| 28348 |
if (isRtc(editor)) {
|
28911 |
if (isRtc(editor)) {
|
| 28349 |
setupRtc();
|
28912 |
setupRtc();
|
| 28350 |
} else {
|
28913 |
} else {
|
| Línea 28354... |
Línea 28917... |
| 28354 |
refreshContentEditable,
|
28917 |
refreshContentEditable,
|
| 28355 |
isHidden
|
28918 |
isHidden
|
| 28356 |
};
|
28919 |
};
|
| 28357 |
};
|
28920 |
};
|
| Línea -... |
Línea 28921... |
| - |
|
28921 |
|
| - |
|
28922 |
const isGplKey = key => key.toLowerCase() === 'gpl';
|
| - |
|
28923 |
const isValidGeneratedKey = key => key.length >= 64 && key.length <= 255;
|
| - |
|
28924 |
const validateLicenseKey = key => isGplKey(key) || isValidGeneratedKey(key) ? 'VALID' : 'INVALID';
|
| - |
|
28925 |
const validateEditorLicenseKey = editor => {
|
| - |
|
28926 |
const licenseKey = getLicenseKey(editor);
|
| - |
|
28927 |
const hasApiKey = isString(getApiKey(editor));
|
| - |
|
28928 |
if (!hasApiKey && (isUndefined(licenseKey) || validateLicenseKey(licenseKey) === 'INVALID')) {
|
| - |
|
28929 |
console.warn(`TinyMCE is running in evaluation mode. Provide a valid license key or add license_key: 'gpl' to the init config to agree to the open source license terms. Read more at https://www.tiny.cloud/license-key/`);
|
| - |
|
28930 |
}
|
| - |
|
28931 |
};
|
| 28358 |
|
28932 |
|
| 28359 |
const DOM$6 = DOMUtils.DOM;
|
28933 |
const DOM$6 = DOMUtils.DOM;
|
| 28360 |
const appendStyle = (editor, text) => {
|
28934 |
const appendStyle = (editor, text) => {
|
| 28361 |
const body = SugarElement.fromDom(editor.getBody());
|
28935 |
const body = SugarElement.fromDom(editor.getBody());
|
| 28362 |
const container = getStyleContainer(getRootNode(body));
|
28936 |
const container = getStyleContainer(getRootNode(body));
|
| 28363 |
const style = SugarElement.fromTag('style');
|
28937 |
const style = SugarElement.fromTag('style');
|
| 28364 |
set$3(style, 'type', 'text/css');
|
28938 |
set$4(style, 'type', 'text/css');
|
| 28365 |
append$1(style, SugarElement.fromText(text));
|
28939 |
append$1(style, SugarElement.fromText(text));
|
| 28366 |
append$1(container, style);
|
28940 |
append$1(container, style);
|
| 28367 |
editor.on('remove', () => {
|
28941 |
editor.on('remove', () => {
|
| 28368 |
remove$5(style);
|
28942 |
remove$4(style);
|
| 28369 |
});
|
28943 |
});
|
| 28370 |
};
|
28944 |
};
|
| 28371 |
const getRootName = editor => editor.inline ? editor.getElement().nodeName.toLowerCase() : undefined;
|
28945 |
const getRootName = editor => editor.inline ? editor.getElement().nodeName.toLowerCase() : undefined;
|
| 28372 |
const removeUndefined = obj => filter$4(obj, v => isUndefined(v) === false);
|
28946 |
const removeUndefined = obj => filter$4(obj, v => isUndefined(v) === false);
|
| Línea 28377... |
Línea 28951... |
| 28377 |
allow_conditional_comments: getOption('allow_conditional_comments'),
|
28951 |
allow_conditional_comments: getOption('allow_conditional_comments'),
|
| 28378 |
allow_html_data_urls: getOption('allow_html_data_urls'),
|
28952 |
allow_html_data_urls: getOption('allow_html_data_urls'),
|
| 28379 |
allow_svg_data_urls: getOption('allow_svg_data_urls'),
|
28953 |
allow_svg_data_urls: getOption('allow_svg_data_urls'),
|
| 28380 |
allow_html_in_named_anchor: getOption('allow_html_in_named_anchor'),
|
28954 |
allow_html_in_named_anchor: getOption('allow_html_in_named_anchor'),
|
| 28381 |
allow_script_urls: getOption('allow_script_urls'),
|
28955 |
allow_script_urls: getOption('allow_script_urls'),
|
| - |
|
28956 |
allow_mathml_annotation_encodings: getOption('allow_mathml_annotation_encodings'),
|
| 28382 |
allow_unsafe_link_target: getOption('allow_unsafe_link_target'),
|
28957 |
allow_unsafe_link_target: getOption('allow_unsafe_link_target'),
|
| 28383 |
convert_unsafe_embeds: getOption('convert_unsafe_embeds'),
|
28958 |
convert_unsafe_embeds: getOption('convert_unsafe_embeds'),
|
| 28384 |
convert_fonts_to_spans: getOption('convert_fonts_to_spans'),
|
28959 |
convert_fonts_to_spans: getOption('convert_fonts_to_spans'),
|
| 28385 |
fix_list_elements: getOption('fix_list_elements'),
|
28960 |
fix_list_elements: getOption('fix_list_elements'),
|
| 28386 |
font_size_legacy_values: getOption('font_size_legacy_values'),
|
28961 |
font_size_legacy_values: getOption('font_size_legacy_values'),
|
| Línea 28388... |
Línea 28963... |
| 28388 |
forced_root_block_attrs: getOption('forced_root_block_attrs'),
|
28963 |
forced_root_block_attrs: getOption('forced_root_block_attrs'),
|
| 28389 |
preserve_cdata: getOption('preserve_cdata'),
|
28964 |
preserve_cdata: getOption('preserve_cdata'),
|
| 28390 |
inline_styles: getOption('inline_styles'),
|
28965 |
inline_styles: getOption('inline_styles'),
|
| 28391 |
root_name: getRootName(editor),
|
28966 |
root_name: getRootName(editor),
|
| 28392 |
sandbox_iframes: getOption('sandbox_iframes'),
|
28967 |
sandbox_iframes: getOption('sandbox_iframes'),
|
| - |
|
28968 |
sandbox_iframes_exclusions: getSandboxIframesExclusions(editor),
|
| 28393 |
sanitize: getOption('xss_sanitization'),
|
28969 |
sanitize: getOption('xss_sanitization'),
|
| 28394 |
validate: true,
|
28970 |
validate: true,
|
| 28395 |
blob_cache: blobCache,
|
28971 |
blob_cache: blobCache,
|
| 28396 |
document: editor.getDoc()
|
28972 |
document: editor.getDoc()
|
| 28397 |
});
|
28973 |
});
|
| Línea 28531... |
Línea 29107... |
| 28531 |
const initInstanceCallback = getInitInstanceCallback(editor);
|
29107 |
const initInstanceCallback = getInitInstanceCallback(editor);
|
| 28532 |
if (isFunction(initInstanceCallback)) {
|
29108 |
if (isFunction(initInstanceCallback)) {
|
| 28533 |
initInstanceCallback.call(editor, editor);
|
29109 |
initInstanceCallback.call(editor, editor);
|
| 28534 |
}
|
29110 |
}
|
| 28535 |
autoFocus(editor);
|
29111 |
autoFocus(editor);
|
| - |
|
29112 |
if (isDisabled(editor)) {
|
| - |
|
29113 |
toggleDisabled(editor, true);
|
| - |
|
29114 |
}
|
| 28536 |
};
|
29115 |
};
|
| 28537 |
const getStyleSheetLoader$1 = editor => editor.inline ? editor.ui.styleSheetLoader : editor.dom.styleSheetLoader;
|
29116 |
const getStyleSheetLoader$1 = editor => editor.inline ? editor.ui.styleSheetLoader : editor.dom.styleSheetLoader;
|
| 28538 |
const makeStylesheetLoadingPromises = (editor, css, framedFonts) => {
|
29117 |
const makeStylesheetLoadingPromises = (editor, css, framedFonts) => {
|
| 28539 |
const {
|
29118 |
const {
|
| 28540 |
pass: bundledCss,
|
29119 |
pass: bundledCss,
|
| Línea 28658... |
Línea 29237... |
| 28658 |
}
|
29237 |
}
|
| 28659 |
const body = editor.getBody();
|
29238 |
const body = editor.getBody();
|
| 28660 |
body.disabled = true;
|
29239 |
body.disabled = true;
|
| 28661 |
editor.readonly = isReadOnly$1(editor);
|
29240 |
editor.readonly = isReadOnly$1(editor);
|
| 28662 |
editor._editableRoot = hasEditableRoot$1(editor);
|
29241 |
editor._editableRoot = hasEditableRoot$1(editor);
|
| 28663 |
if (!editor.readonly && editor.hasEditableRoot()) {
|
29242 |
if (!isDisabled$1(editor) && editor.hasEditableRoot()) {
|
| 28664 |
if (editor.inline && DOM$6.getStyle(body, 'position', true) === 'static') {
|
29243 |
if (editor.inline && DOM$6.getStyle(body, 'position', true) === 'static') {
|
| 28665 |
body.style.position = 'relative';
|
29244 |
body.style.position = 'relative';
|
| 28666 |
}
|
29245 |
}
|
| 28667 |
body.contentEditable = 'true';
|
29246 |
body.contentEditable = 'true';
|
| 28668 |
}
|
29247 |
}
|
| Línea 28679... |
Línea 29258... |
| 28679 |
schema: editor.schema,
|
29258 |
schema: editor.schema,
|
| 28680 |
contentCssCors: shouldUseContentCssCors(editor),
|
29259 |
contentCssCors: shouldUseContentCssCors(editor),
|
| 28681 |
referrerPolicy: getReferrerPolicy(editor),
|
29260 |
referrerPolicy: getReferrerPolicy(editor),
|
| 28682 |
onSetAttrib: e => {
|
29261 |
onSetAttrib: e => {
|
| 28683 |
editor.dispatch('SetAttrib', e);
|
29262 |
editor.dispatch('SetAttrib', e);
|
| 28684 |
},
|
29263 |
}
|
| 28685 |
force_hex_color: shouldForceHexColor(editor)
|
- |
|
| 28686 |
});
|
29264 |
});
|
| 28687 |
editor.parser = createParser(editor);
|
29265 |
editor.parser = createParser(editor);
|
| 28688 |
editor.serializer = DomSerializer(mkSerializerSettings(editor), editor);
|
29266 |
editor.serializer = DomSerializer(mkSerializerSettings(editor), editor);
|
| 28689 |
editor.selection = EditorSelection(editor.dom, editor.getWin(), editor.serializer, editor);
|
29267 |
editor.selection = EditorSelection(editor.dom, editor.getWin(), editor.serializer, editor);
|
| 28690 |
editor.annotator = Annotator(editor);
|
29268 |
editor.annotator = Annotator(editor);
|
| Línea 28704... |
Línea 29282... |
| 28704 |
setup$o(editor);
|
29282 |
setup$o(editor);
|
| 28705 |
setup$r(editor);
|
29283 |
setup$r(editor);
|
| 28706 |
setup$7(editor);
|
29284 |
setup$7(editor);
|
| 28707 |
const setupRtcThunk = setup$t(editor);
|
29285 |
const setupRtcThunk = setup$t(editor);
|
| 28708 |
preInit(editor);
|
29286 |
preInit(editor);
|
| - |
|
29287 |
validateEditorLicenseKey(editor);
|
| 28709 |
setupRtcThunk.fold(() => {
|
29288 |
setupRtcThunk.fold(() => {
|
| 28710 |
const cancelProgress = startProgress(editor);
|
29289 |
const cancelProgress = startProgress(editor);
|
| 28711 |
loadContentCss(editor).then(() => {
|
29290 |
loadContentCss(editor).then(() => {
|
| 28712 |
initEditorWithInitialContent(editor);
|
29291 |
initEditorWithInitialContent(editor);
|
| 28713 |
cancelProgress();
|
29292 |
cancelProgress();
|
| Línea 28735... |
Línea 29314... |
| 28735 |
const bind = (element, event, handler) => bind$2(element, event, filter, handler);
|
29314 |
const bind = (element, event, handler) => bind$2(element, event, filter, handler);
|
| Línea 28736... |
Línea 29315... |
| 28736 |
|
29315 |
|
| 28737 |
const DOM$5 = DOMUtils.DOM;
|
29316 |
const DOM$5 = DOMUtils.DOM;
|
| 28738 |
const createIframeElement = (id, title, customAttrs, tabindex) => {
|
29317 |
const createIframeElement = (id, title, customAttrs, tabindex) => {
|
| 28739 |
const iframe = SugarElement.fromTag('iframe');
|
29318 |
const iframe = SugarElement.fromTag('iframe');
|
| 28740 |
tabindex.each(t => set$3(iframe, 'tabindex', t));
|
29319 |
tabindex.each(t => set$4(iframe, 'tabindex', t));
|
| 28741 |
setAll$1(iframe, customAttrs);
|
29320 |
setAll$1(iframe, customAttrs);
|
| 28742 |
setAll$1(iframe, {
|
29321 |
setAll$1(iframe, {
|
| 28743 |
id: id + '_ifr',
|
29322 |
id: id + '_ifr',
|
| 28744 |
frameBorder: '0',
|
29323 |
frameBorder: '0',
|
| Línea 28762... |
Línea 29341... |
| 28762 |
}
|
29341 |
}
|
| 28763 |
iframeHTML += '</head>' + `<body id="${ bodyId }" class="mce-content-body ${ bodyClass }" data-id="${ editor.id }" aria-label="${ translatedAriaText }">` + '<br>' + '</body></html>';
|
29342 |
iframeHTML += '</head>' + `<body id="${ bodyId }" class="mce-content-body ${ bodyClass }" data-id="${ editor.id }" aria-label="${ translatedAriaText }">` + '<br>' + '</body></html>';
|
| 28764 |
return iframeHTML;
|
29343 |
return iframeHTML;
|
| 28765 |
};
|
29344 |
};
|
| 28766 |
const createIframe = (editor, boxInfo) => {
|
29345 |
const createIframe = (editor, boxInfo) => {
|
| - |
|
29346 |
const iframeTitle = Env.browser.isFirefox() ? getIframeAriaText(editor) : 'Rich Text Area';
|
| 28767 |
const iframeTitle = editor.translate('Rich Text Area');
|
29347 |
const translatedTitle = editor.translate(iframeTitle);
|
| 28768 |
const tabindex = getOpt(SugarElement.fromDom(editor.getElement()), 'tabindex').bind(toInt);
|
29348 |
const tabindex = getOpt(SugarElement.fromDom(editor.getElement()), 'tabindex').bind(toInt);
|
| 28769 |
const ifr = createIframeElement(editor.id, iframeTitle, getIframeAttrs(editor), tabindex).dom;
|
29349 |
const ifr = createIframeElement(editor.id, translatedTitle, getIframeAttrs(editor), tabindex).dom;
|
| 28770 |
ifr.onload = () => {
|
29350 |
ifr.onload = () => {
|
| 28771 |
ifr.onload = null;
|
29351 |
ifr.onload = null;
|
| 28772 |
editor.dispatch('load');
|
29352 |
editor.dispatch('load');
|
| 28773 |
};
|
29353 |
};
|
| 28774 |
editor.contentAreaContainer = boxInfo.iframeContainer;
|
29354 |
editor.contentAreaContainer = boxInfo.iframeContainer;
|
| Línea 28916... |
Línea 29496... |
| 28916 |
const uiApiFacade = {
|
29496 |
const uiApiFacade = {
|
| 28917 |
show: Optional.from(api.show).getOr(noop),
|
29497 |
show: Optional.from(api.show).getOr(noop),
|
| 28918 |
hide: Optional.from(api.hide).getOr(noop),
|
29498 |
hide: Optional.from(api.hide).getOr(noop),
|
| 28919 |
isEnabled: Optional.from(api.isEnabled).getOr(always),
|
29499 |
isEnabled: Optional.from(api.isEnabled).getOr(always),
|
| 28920 |
setEnabled: state => {
|
29500 |
setEnabled: state => {
|
| - |
|
29501 |
const shouldSkip = state && (editor.mode.get() === 'readonly' || isDisabled(editor));
|
| 28921 |
if (!editor.mode.isReadOnly()) {
|
29502 |
if (!shouldSkip) {
|
| 28922 |
Optional.from(api.setEnabled).each(f => f(state));
|
29503 |
Optional.from(api.setEnabled).each(f => f(state));
|
| 28923 |
}
|
29504 |
}
|
| 28924 |
}
|
29505 |
}
|
| 28925 |
};
|
29506 |
};
|
| 28926 |
editor.ui = {
|
29507 |
editor.ui = {
|
| Línea 29058... |
Línea 29639... |
| 29058 |
return;
|
29639 |
return;
|
| 29059 |
}
|
29640 |
}
|
| 29060 |
const element = SugarElement.fromDom(editor.getElement());
|
29641 |
const element = SugarElement.fromDom(editor.getElement());
|
| 29061 |
const snapshot = clone$4(element);
|
29642 |
const snapshot = clone$4(element);
|
| 29062 |
editor.on('remove', () => {
|
29643 |
editor.on('remove', () => {
|
| 29063 |
eachr(element.dom.attributes, attr => remove$a(element, attr.name));
|
29644 |
eachr(element.dom.attributes, attr => remove$9(element, attr.name));
|
| 29064 |
setAll$1(element, snapshot);
|
29645 |
setAll$1(element, snapshot);
|
| 29065 |
});
|
29646 |
});
|
| 29066 |
editor.ui.styleSheetLoader = getStyleSheetLoader(element, editor);
|
29647 |
editor.ui.styleSheetLoader = getStyleSheetLoader(element, editor);
|
| 29067 |
if (!isInline$1(editor)) {
|
29648 |
if (!isInline$1(editor)) {
|
| 29068 |
editor.orgVisibility = editor.getElement().style.visibility;
|
29649 |
editor.orgVisibility = editor.getElement().style.visibility;
|
| Línea 29129... |
Línea 29710... |
| 29129 |
};
|
29710 |
};
|
| Línea 29130... |
Línea 29711... |
| 29130 |
|
29711 |
|
| 29131 |
const setEditableRoot = (editor, state) => {
|
29712 |
const setEditableRoot = (editor, state) => {
|
| 29132 |
if (editor._editableRoot !== state) {
|
29713 |
if (editor._editableRoot !== state) {
|
| 29133 |
editor._editableRoot = state;
|
29714 |
editor._editableRoot = state;
|
| 29134 |
if (!editor.readonly) {
|
29715 |
if (!isDisabled(editor)) {
|
| 29135 |
editor.getBody().contentEditable = String(editor.hasEditableRoot());
|
29716 |
editor.getBody().contentEditable = String(editor.hasEditableRoot());
|
| 29136 |
editor.nodeChanged();
|
29717 |
editor.nodeChanged();
|
| 29137 |
}
|
29718 |
}
|
| 29138 |
fireEditableRootStateChange(editor, state);
|
29719 |
fireEditableRootStateChange(editor, state);
|
| Línea 29142... |
Línea 29723... |
| 29142 |
|
29723 |
|
| 29143 |
const sectionResult = (sections, settings) => ({
|
29724 |
const sectionResult = (sections, settings) => ({
|
| 29144 |
sections: constant(sections),
|
29725 |
sections: constant(sections),
|
| 29145 |
options: constant(settings)
|
29726 |
options: constant(settings)
|
| 29146 |
});
|
29727 |
});
|
| 29147 |
const deviceDetection = detect$2().deviceType;
|
29728 |
const deviceDetection = detect$1().deviceType;
|
| 29148 |
const isPhone = deviceDetection.isPhone();
|
29729 |
const isPhone = deviceDetection.isPhone();
|
| 29149 |
const isTablet = deviceDetection.isTablet();
|
29730 |
const isTablet = deviceDetection.isTablet();
|
| 29150 |
const normalizePlugins = plugins => {
|
29731 |
const normalizePlugins = plugins => {
|
| 29151 |
if (isNullable(plugins)) {
|
29732 |
if (isNullable(plugins)) {
|
| Línea 29227... |
Línea 29808... |
| 29227 |
const deviceOverrideOptions = isMobileDevice ? { mobile: getMobileOverrideOptions((_a = options.mobile) !== null && _a !== void 0 ? _a : {}, isPhone) } : {};
|
29808 |
const deviceOverrideOptions = isMobileDevice ? { mobile: getMobileOverrideOptions((_a = options.mobile) !== null && _a !== void 0 ? _a : {}, isPhone) } : {};
|
| 29228 |
const sectionResult = extractSections(['mobile'], deepMerge(deviceOverrideOptions, options));
|
29809 |
const sectionResult = extractSections(['mobile'], deepMerge(deviceOverrideOptions, options));
|
| 29229 |
const extendedOptions = Tools.extend(defaultOptions, defaultOverrideOptions, sectionResult.options(), isOnMobile(isMobileDevice, sectionResult) ? getSection(sectionResult, 'mobile') : {}, { external_plugins: getExternalPlugins(defaultOverrideOptions, sectionResult.options()) });
|
29810 |
const extendedOptions = Tools.extend(defaultOptions, defaultOverrideOptions, sectionResult.options(), isOnMobile(isMobileDevice, sectionResult) ? getSection(sectionResult, 'mobile') : {}, { external_plugins: getExternalPlugins(defaultOverrideOptions, sectionResult.options()) });
|
| 29230 |
return processPlugins(isMobileDevice, sectionResult, defaultOverrideOptions, extendedOptions);
|
29811 |
return processPlugins(isMobileDevice, sectionResult, defaultOverrideOptions, extendedOptions);
|
| 29231 |
};
|
29812 |
};
|
| - |
|
29813 |
const normalizeOptions = (defaultOverrideOptions, options) => {
|
| - |
|
29814 |
const copiedOptions = merge(options);
|
| 29232 |
const normalizeOptions = (defaultOverrideOptions, options) => combineOptions(isPhone || isTablet, isPhone, options, defaultOverrideOptions, options);
|
29815 |
return combineOptions(isPhone || isTablet, isPhone, copiedOptions, defaultOverrideOptions, copiedOptions);
|
| - |
|
29816 |
};
|
| Línea 29233... |
Línea 29817... |
| 29233 |
|
29817 |
|
| Línea 29234... |
Línea 29818... |
| 29234 |
const addVisual = (editor, elm) => addVisual$1(editor, elm);
|
29818 |
const addVisual = (editor, elm) => addVisual$1(editor, elm);
|
| 29235 |
|
29819 |
|
| 29236 |
const registerExecCommands$3 = editor => {
|
29820 |
const registerExecCommands$2 = editor => {
|
| 29237 |
const toggleFormat = (name, value) => {
|
29821 |
const toggleFormat = (name, value) => {
|
| 29238 |
editor.formatter.toggle(name, value);
|
29822 |
editor.formatter.toggle(name, value);
|
| 29239 |
editor.nodeChanged();
|
29823 |
editor.nodeChanged();
|
| Línea 29254... |
Línea 29838... |
| 29254 |
JustifyRight: toggleAlign('right'),
|
29838 |
JustifyRight: toggleAlign('right'),
|
| 29255 |
JustifyFull: toggleAlign('justify'),
|
29839 |
JustifyFull: toggleAlign('justify'),
|
| 29256 |
JustifyNone: toggleAlign('none')
|
29840 |
JustifyNone: toggleAlign('none')
|
| 29257 |
});
|
29841 |
});
|
| 29258 |
};
|
29842 |
};
|
| 29259 |
const registerQueryStateCommands$1 = editor => {
|
29843 |
const registerQueryStateCommands = editor => {
|
| 29260 |
const alignStates = name => () => {
|
29844 |
const alignStates = name => () => {
|
| 29261 |
const selection = editor.selection;
|
29845 |
const selection = editor.selection;
|
| 29262 |
const nodes = selection.isCollapsed() ? [editor.dom.getParent(selection.getNode(), editor.dom.isBlock)] : selection.getSelectedBlocks();
|
29846 |
const nodes = selection.isCollapsed() ? [editor.dom.getParent(selection.getNode(), editor.dom.isBlock)] : selection.getSelectedBlocks();
|
| 29263 |
return exists(nodes, node => isNonNullable(editor.formatter.matchNode(node, name)));
|
29847 |
return exists(nodes, node => isNonNullable(editor.formatter.matchNode(node, name)));
|
| 29264 |
};
|
29848 |
};
|
| Línea 29267... |
Línea 29851... |
| 29267 |
JustifyCenter: alignStates('aligncenter'),
|
29851 |
JustifyCenter: alignStates('aligncenter'),
|
| 29268 |
JustifyRight: alignStates('alignright'),
|
29852 |
JustifyRight: alignStates('alignright'),
|
| 29269 |
JustifyFull: alignStates('alignjustify')
|
29853 |
JustifyFull: alignStates('alignjustify')
|
| 29270 |
}, 'state');
|
29854 |
}, 'state');
|
| 29271 |
};
|
29855 |
};
|
| 29272 |
const registerCommands$b = editor => {
|
29856 |
const registerCommands$a = editor => {
|
| 29273 |
registerExecCommands$3(editor);
|
29857 |
registerExecCommands$2(editor);
|
| 29274 |
registerQueryStateCommands$1(editor);
|
29858 |
registerQueryStateCommands(editor);
|
| 29275 |
};
|
29859 |
};
|
| Línea 29276... |
Línea 29860... |
| 29276 |
|
29860 |
|
| 29277 |
const registerCommands$a = editor => {
|
29861 |
const registerCommands$9 = editor => {
|
| 29278 |
editor.editorCommands.addCommands({
|
29862 |
editor.editorCommands.addCommands({
|
| 29279 |
'Cut,Copy,Paste': command => {
|
29863 |
'Cut,Copy,Paste': command => {
|
| 29280 |
const doc = editor.getDoc();
|
29864 |
const doc = editor.getDoc();
|
| 29281 |
let failed;
|
29865 |
let failed;
|
| 29282 |
try {
|
29866 |
try {
|
| 29283 |
doc.execCommand(command);
|
29867 |
doc.execCommand(command);
|
| 29284 |
} catch (ex) {
|
29868 |
} catch (_a) {
|
| 29285 |
failed = true;
|
29869 |
failed = true;
|
| 29286 |
}
|
29870 |
}
|
| 29287 |
if (command === 'paste' && !doc.queryCommandEnabled(command)) {
|
29871 |
if (command === 'paste' && !doc.queryCommandEnabled(command)) {
|
| 29288 |
failed = true;
|
29872 |
failed = true;
|
| Línea 29356... |
Línea 29940... |
| 29356 |
editor.addVisual();
|
29940 |
editor.addVisual();
|
| 29357 |
});
|
29941 |
});
|
| 29358 |
}
|
29942 |
}
|
| 29359 |
};
|
29943 |
};
|
| Línea 29360... |
Línea 29944... |
| 29360 |
|
29944 |
|
| 29361 |
const registerCommands$9 = editor => {
|
29945 |
const registerCommands$8 = editor => {
|
| 29362 |
editor.editorCommands.addCommands({
|
29946 |
editor.editorCommands.addCommands({
|
| 29363 |
mceCleanup: () => {
|
29947 |
mceCleanup: () => {
|
| 29364 |
const bm = editor.selection.getBookmark();
|
29948 |
const bm = editor.selection.getBookmark();
|
| 29365 |
editor.setContent(editor.getContent());
|
29949 |
editor.setContent(editor.getContent());
|
| Línea 29414... |
Línea 29998... |
| 29414 |
const getFontSize = getFontProp('font-size');
|
29998 |
const getFontSize = getFontProp('font-size');
|
| 29415 |
const getFontFamily = compose(normalizeFontFamily, getFontProp('font-family'));
|
29999 |
const getFontFamily = compose(normalizeFontFamily, getFontProp('font-family'));
|
| Línea 29416... |
Línea 30000... |
| 29416 |
|
30000 |
|
| 29417 |
const findFirstCaretElement = editor => firstPositionIn(editor.getBody()).bind(caret => {
|
30001 |
const findFirstCaretElement = editor => firstPositionIn(editor.getBody()).bind(caret => {
|
| 29418 |
const container = caret.container();
|
30002 |
const container = caret.container();
|
| 29419 |
return Optional.from(isText$a(container) ? container.parentNode : container);
|
30003 |
return Optional.from(isText$b(container) ? container.parentNode : container);
|
| 29420 |
});
|
30004 |
});
|
| 29421 |
const getCaretElement = editor => Optional.from(editor.selection.getRng()).bind(rng => {
|
30005 |
const getCaretElement = editor => Optional.from(editor.selection.getRng()).bind(rng => {
|
| 29422 |
const root = editor.getBody();
|
30006 |
const root = editor.getBody();
|
| 29423 |
const atStartOfNode = rng.startContainer === root && rng.startOffset === 0;
|
30007 |
const atStartOfNode = rng.startContainer === root && rng.startOffset === 0;
|
| Línea 29479... |
Línea 30063... |
| 29479 |
const lineHeightAction = (editor, lineHeight) => {
|
30063 |
const lineHeightAction = (editor, lineHeight) => {
|
| 29480 |
editor.formatter.toggle('lineheight', { value: String(lineHeight) });
|
30064 |
editor.formatter.toggle('lineheight', { value: String(lineHeight) });
|
| 29481 |
editor.nodeChanged();
|
30065 |
editor.nodeChanged();
|
| 29482 |
};
|
30066 |
};
|
| Línea 29483... |
Línea 30067... |
| 29483 |
|
30067 |
|
| 29484 |
const registerExecCommands$2 = editor => {
|
30068 |
const registerExecCommands$1 = editor => {
|
| 29485 |
const toggleFormat = (name, value) => {
|
30069 |
const toggleFormat = (name, value) => {
|
| 29486 |
editor.formatter.toggle(name, value);
|
30070 |
editor.formatter.toggle(name, value);
|
| 29487 |
editor.nodeChanged();
|
30071 |
editor.nodeChanged();
|
| 29488 |
};
|
30072 |
};
|
| Línea 29534... |
Línea 30118... |
| 29534 |
}, 'state');
|
30118 |
}, 'state');
|
| 29535 |
editor.editorCommands.addQueryValueHandler('FontName', () => fontNameQuery(editor));
|
30119 |
editor.editorCommands.addQueryValueHandler('FontName', () => fontNameQuery(editor));
|
| 29536 |
editor.editorCommands.addQueryValueHandler('FontSize', () => fontSizeQuery(editor));
|
30120 |
editor.editorCommands.addQueryValueHandler('FontSize', () => fontSizeQuery(editor));
|
| 29537 |
editor.editorCommands.addQueryValueHandler('LineHeight', () => lineHeightQuery(editor));
|
30121 |
editor.editorCommands.addQueryValueHandler('LineHeight', () => lineHeightQuery(editor));
|
| 29538 |
};
|
30122 |
};
|
| 29539 |
const registerCommands$8 = editor => {
|
30123 |
const registerCommands$7 = editor => {
|
| 29540 |
registerExecCommands$2(editor);
|
30124 |
registerExecCommands$1(editor);
|
| 29541 |
registerQueryValueCommands(editor);
|
30125 |
registerQueryValueCommands(editor);
|
| 29542 |
};
|
30126 |
};
|
| Línea 29543... |
Línea 30127... |
| 29543 |
|
30127 |
|
| 29544 |
const registerCommands$7 = editor => {
|
30128 |
const registerCommands$6 = editor => {
|
| 29545 |
editor.editorCommands.addCommands({
|
30129 |
editor.editorCommands.addCommands({
|
| 29546 |
mceAddUndoLevel: () => {
|
30130 |
mceAddUndoLevel: () => {
|
| 29547 |
editor.undoManager.add();
|
30131 |
editor.undoManager.add();
|
| 29548 |
},
|
30132 |
},
|
| Línea 29556... |
Línea 30140... |
| 29556 |
editor.undoManager.redo();
|
30140 |
editor.undoManager.redo();
|
| 29557 |
}
|
30141 |
}
|
| 29558 |
});
|
30142 |
});
|
| 29559 |
};
|
30143 |
};
|
| Línea 29560... |
Línea 30144... |
| 29560 |
|
30144 |
|
| 29561 |
const registerCommands$6 = editor => {
|
30145 |
const registerCommands$5 = editor => {
|
| 29562 |
editor.editorCommands.addCommands({
|
30146 |
editor.editorCommands.addCommands({
|
| 29563 |
Indent: () => {
|
30147 |
Indent: () => {
|
| 29564 |
indent(editor);
|
30148 |
indent(editor);
|
| 29565 |
},
|
30149 |
},
|
| Línea 29568... |
Línea 30152... |
| 29568 |
}
|
30152 |
}
|
| 29569 |
});
|
30153 |
});
|
| 29570 |
editor.editorCommands.addCommands({ Outdent: () => canOutdent(editor) }, 'state');
|
30154 |
editor.editorCommands.addCommands({ Outdent: () => canOutdent(editor) }, 'state');
|
| 29571 |
};
|
30155 |
};
|
| Línea 29572... |
Línea 30156... |
| 29572 |
|
30156 |
|
| 29573 |
const registerCommands$5 = editor => {
|
30157 |
const registerCommands$4 = editor => {
|
| - |
|
30158 |
const applyLinkToSelection = (_command, _ui, value) => {
|
| - |
|
30159 |
if (editor.mode.isReadOnly()) {
|
| - |
|
30160 |
return;
|
| 29574 |
const applyLinkToSelection = (_command, _ui, value) => {
|
30161 |
}
|
| 29575 |
const linkDetails = isString(value) ? { href: value } : value;
|
30162 |
const linkDetails = isString(value) ? { href: value } : value;
|
| 29576 |
const anchor = editor.dom.getParent(editor.selection.getNode(), 'a');
|
30163 |
const anchor = editor.dom.getParent(editor.selection.getNode(), 'a');
|
| 29577 |
if (isObject(linkDetails) && isString(linkDetails.href)) {
|
30164 |
if (isObject(linkDetails) && isString(linkDetails.href)) {
|
| 29578 |
linkDetails.href = linkDetails.href.replace(/ /g, '%20');
|
30165 |
linkDetails.href = linkDetails.href.replace(/ /g, '%20');
|
| Línea 29600... |
Línea 30187... |
| 29600 |
mceInsertLink: applyLinkToSelection,
|
30187 |
mceInsertLink: applyLinkToSelection,
|
| 29601 |
createLink: applyLinkToSelection
|
30188 |
createLink: applyLinkToSelection
|
| 29602 |
});
|
30189 |
});
|
| 29603 |
};
|
30190 |
};
|
| Línea 29604... |
Línea -... |
| 29604 |
|
- |
|
| 29605 |
const registerExecCommands$1 = editor => {
|
- |
|
| 29606 |
editor.editorCommands.addCommands({
|
- |
|
| 29607 |
'InsertUnorderedList,InsertOrderedList': command => {
|
- |
|
| 29608 |
editor.getDoc().execCommand(command);
|
- |
|
| 29609 |
const listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');
|
- |
|
| 29610 |
if (listElm) {
|
- |
|
| 29611 |
const listParent = listElm.parentNode;
|
- |
|
| 29612 |
if (listParent && /^(H[1-6]|P|ADDRESS|PRE)$/.test(listParent.nodeName)) {
|
- |
|
| 29613 |
const bm = editor.selection.getBookmark();
|
- |
|
| 29614 |
editor.dom.split(listParent, listElm);
|
- |
|
| 29615 |
editor.selection.moveToBookmark(bm);
|
- |
|
| 29616 |
}
|
- |
|
| 29617 |
}
|
- |
|
| 29618 |
}
|
- |
|
| 29619 |
});
|
- |
|
| 29620 |
};
|
- |
|
| 29621 |
const registerQueryStateCommands = editor => {
|
- |
|
| 29622 |
editor.editorCommands.addCommands({
|
- |
|
| 29623 |
'InsertUnorderedList,InsertOrderedList': command => {
|
- |
|
| 29624 |
const list = editor.dom.getParent(editor.selection.getNode(), 'ul,ol');
|
- |
|
| 29625 |
return list && (command === 'insertunorderedlist' && list.tagName === 'UL' || command === 'insertorderedlist' && list.tagName === 'OL');
|
- |
|
| 29626 |
}
|
- |
|
| 29627 |
}, 'state');
|
- |
|
| 29628 |
};
|
- |
|
| 29629 |
const registerCommands$4 = editor => {
|
- |
|
| 29630 |
registerExecCommands$1(editor);
|
- |
|
| 29631 |
registerQueryStateCommands(editor);
|
- |
|
| 29632 |
};
|
- |
|
| 29633 |
|
30191 |
|
| 29634 |
const getTopParentBlock = (editor, node, root, container) => {
|
30192 |
const getTopParentBlock = (editor, node, root, container) => {
|
| 29635 |
const dom = editor.dom;
|
30193 |
const dom = editor.dom;
|
| 29636 |
const selector = node => dom.isBlock(node) && node.parentElement === root;
|
30194 |
const selector = node => dom.isBlock(node) && node.parentElement === root;
|
| 29637 |
const topParentBlock = selector(node) ? node : dom.getParent(container, selector, root);
|
30195 |
const topParentBlock = selector(node) ? node : dom.getParent(container, selector, root);
|
| 29638 |
return Optional.from(topParentBlock).map(SugarElement.fromDom);
|
30196 |
return Optional.from(topParentBlock).map(SugarElement.fromDom);
|
| 29639 |
};
|
30197 |
};
|
| - |
|
30198 |
const insert = (editor, before) => {
|
| - |
|
30199 |
if (editor.mode.isReadOnly()) {
|
| - |
|
30200 |
return;
|
| 29640 |
const insert = (editor, before) => {
|
30201 |
}
|
| 29641 |
const dom = editor.dom;
|
30202 |
const dom = editor.dom;
|
| 29642 |
const rng = editor.selection.getRng();
|
30203 |
const rng = editor.selection.getRng();
|
| 29643 |
const node = before ? editor.selection.getStart() : editor.selection.getEnd();
|
30204 |
const node = before ? editor.selection.getStart() : editor.selection.getEnd();
|
| 29644 |
const container = before ? rng.startContainer : rng.endContainer;
|
30205 |
const container = before ? rng.startContainer : rng.endContainer;
|
| Línea 29732... |
Línea 30293... |
| 29732 |
editor.addVisual();
|
30293 |
editor.addVisual();
|
| 29733 |
}
|
30294 |
}
|
| 29734 |
});
|
30295 |
});
|
| 29735 |
};
|
30296 |
};
|
| 29736 |
const registerCommands = editor => {
|
30297 |
const registerCommands = editor => {
|
| 29737 |
registerCommands$b(editor);
|
- |
|
| 29738 |
registerCommands$a(editor);
|
30298 |
registerCommands$a(editor);
|
| 29739 |
registerCommands$7(editor);
|
- |
|
| 29740 |
registerCommands$1(editor);
|
- |
|
| 29741 |
registerCommands$9(editor);
|
30299 |
registerCommands$9(editor);
|
| 29742 |
registerCommands$5(editor);
|
- |
|
| 29743 |
registerCommands$6(editor);
|
30300 |
registerCommands$6(editor);
|
| - |
|
30301 |
registerCommands$1(editor);
|
| - |
|
30302 |
registerCommands$8(editor);
|
| - |
|
30303 |
registerCommands$4(editor);
|
| - |
|
30304 |
registerCommands$5(editor);
|
| 29744 |
registerCommands$3(editor);
|
30305 |
registerCommands$3(editor);
|
| 29745 |
registerCommands$2(editor);
|
30306 |
registerCommands$2(editor);
|
| 29746 |
registerCommands$4(editor);
|
- |
|
| 29747 |
registerCommands$8(editor);
|
30307 |
registerCommands$7(editor);
|
| 29748 |
registerExecCommands(editor);
|
30308 |
registerExecCommands(editor);
|
| 29749 |
};
|
30309 |
};
|
| Línea 29750... |
Línea 30310... |
| 29750 |
|
30310 |
|
| 29751 |
const selectionSafeCommands = ['toggleview'];
|
30311 |
const selectionSafeCommands = ['toggleview'];
|
| Línea 29841... |
Línea 30401... |
| 29841 |
addQueryValueHandler(command, callback, scope) {
|
30401 |
addQueryValueHandler(command, callback, scope) {
|
| 29842 |
this.commands.value[command.toLowerCase()] = () => callback.call(scope !== null && scope !== void 0 ? scope : this.editor);
|
30402 |
this.commands.value[command.toLowerCase()] = () => callback.call(scope !== null && scope !== void 0 ? scope : this.editor);
|
| 29843 |
}
|
30403 |
}
|
| 29844 |
}
|
30404 |
}
|
| Línea 29845... |
Línea -... |
| 29845 |
|
- |
|
| 29846 |
const internalContentEditableAttr = 'data-mce-contenteditable';
|
- |
|
| 29847 |
const toggleClass = (elm, cls, state) => {
|
- |
|
| 29848 |
if (has(elm, cls) && !state) {
|
- |
|
| 29849 |
remove$7(elm, cls);
|
- |
|
| 29850 |
} else if (state) {
|
- |
|
| 29851 |
add$2(elm, cls);
|
- |
|
| 29852 |
}
|
- |
|
| 29853 |
};
|
- |
|
| 29854 |
const setEditorCommandState = (editor, cmd, state) => {
|
- |
|
| 29855 |
try {
|
- |
|
| 29856 |
editor.getDoc().execCommand(cmd, false, String(state));
|
- |
|
| 29857 |
} catch (ex) {
|
- |
|
| 29858 |
}
|
- |
|
| 29859 |
};
|
- |
|
| 29860 |
const setContentEditable = (elm, state) => {
|
- |
|
| 29861 |
elm.dom.contentEditable = state ? 'true' : 'false';
|
- |
|
| 29862 |
};
|
- |
|
| 29863 |
const switchOffContentEditableTrue = elm => {
|
- |
|
| 29864 |
each$e(descendants(elm, '*[contenteditable="true"]'), elm => {
|
- |
|
| 29865 |
set$3(elm, internalContentEditableAttr, 'true');
|
- |
|
| 29866 |
setContentEditable(elm, false);
|
- |
|
| 29867 |
});
|
- |
|
| 29868 |
};
|
- |
|
| 29869 |
const switchOnContentEditableTrue = elm => {
|
- |
|
| 29870 |
each$e(descendants(elm, `*[${ internalContentEditableAttr }="true"]`), elm => {
|
- |
|
| 29871 |
remove$a(elm, internalContentEditableAttr);
|
- |
|
| 29872 |
setContentEditable(elm, true);
|
- |
|
| 29873 |
});
|
- |
|
| 29874 |
};
|
- |
|
| 29875 |
const removeFakeSelection = editor => {
|
- |
|
| 29876 |
Optional.from(editor.selection.getNode()).each(elm => {
|
- |
|
| 29877 |
elm.removeAttribute('data-mce-selected');
|
- |
|
| 29878 |
});
|
- |
|
| 29879 |
};
|
- |
|
| 29880 |
const restoreFakeSelection = editor => {
|
- |
|
| 29881 |
editor.selection.setRng(editor.selection.getRng());
|
- |
|
| 29882 |
};
|
- |
|
| 29883 |
const toggleReadOnly = (editor, state) => {
|
- |
|
| 29884 |
const body = SugarElement.fromDom(editor.getBody());
|
- |
|
| 29885 |
toggleClass(body, 'mce-content-readonly', state);
|
- |
|
| 29886 |
if (state) {
|
- |
|
| 29887 |
editor.selection.controlSelection.hideResizeRect();
|
- |
|
| 29888 |
editor._selectionOverrides.hideFakeCaret();
|
- |
|
| 29889 |
removeFakeSelection(editor);
|
- |
|
| 29890 |
editor.readonly = true;
|
- |
|
| 29891 |
setContentEditable(body, false);
|
- |
|
| 29892 |
switchOffContentEditableTrue(body);
|
- |
|
| 29893 |
} else {
|
- |
|
| 29894 |
editor.readonly = false;
|
- |
|
| 29895 |
if (editor.hasEditableRoot()) {
|
- |
|
| 29896 |
setContentEditable(body, true);
|
- |
|
| 29897 |
}
|
- |
|
| 29898 |
switchOnContentEditableTrue(body);
|
- |
|
| 29899 |
setEditorCommandState(editor, 'StyleWithCSS', false);
|
- |
|
| 29900 |
setEditorCommandState(editor, 'enableInlineTableEditing', false);
|
- |
|
| 29901 |
setEditorCommandState(editor, 'enableObjectResizing', false);
|
- |
|
| 29902 |
if (hasEditorOrUiFocus(editor)) {
|
- |
|
| 29903 |
editor.focus();
|
- |
|
| 29904 |
}
|
- |
|
| 29905 |
restoreFakeSelection(editor);
|
- |
|
| 29906 |
editor.nodeChanged();
|
- |
|
| 29907 |
}
|
- |
|
| 29908 |
};
|
- |
|
| 29909 |
const isReadOnly = editor => editor.readonly;
|
- |
|
| 29910 |
const registerFilters = editor => {
|
- |
|
| 29911 |
editor.parser.addAttributeFilter('contenteditable', nodes => {
|
- |
|
| 29912 |
if (isReadOnly(editor)) {
|
- |
|
| 29913 |
each$e(nodes, node => {
|
- |
|
| 29914 |
node.attr(internalContentEditableAttr, node.attr('contenteditable'));
|
- |
|
| 29915 |
node.attr('contenteditable', 'false');
|
- |
|
| 29916 |
});
|
- |
|
| 29917 |
}
|
- |
|
| 29918 |
});
|
- |
|
| 29919 |
editor.serializer.addAttributeFilter(internalContentEditableAttr, nodes => {
|
- |
|
| 29920 |
if (isReadOnly(editor)) {
|
- |
|
| 29921 |
each$e(nodes, node => {
|
- |
|
| 29922 |
node.attr('contenteditable', node.attr(internalContentEditableAttr));
|
- |
|
| 29923 |
});
|
- |
|
| 29924 |
}
|
- |
|
| 29925 |
});
|
- |
|
| 29926 |
editor.serializer.addTempAttr(internalContentEditableAttr);
|
- |
|
| 29927 |
};
|
- |
|
| 29928 |
const registerReadOnlyContentFilters = editor => {
|
- |
|
| 29929 |
if (editor.serializer) {
|
- |
|
| 29930 |
registerFilters(editor);
|
- |
|
| 29931 |
} else {
|
- |
|
| 29932 |
editor.on('PreInit', () => {
|
- |
|
| 29933 |
registerFilters(editor);
|
- |
|
| 29934 |
});
|
- |
|
| 29935 |
}
|
- |
|
| 29936 |
};
|
- |
|
| 29937 |
const isClickEvent = e => e.type === 'click';
|
- |
|
| 29938 |
const allowedEvents = ['copy'];
|
- |
|
| 29939 |
const isReadOnlyAllowedEvent = e => contains$2(allowedEvents, e.type);
|
- |
|
| 29940 |
const getAnchorHrefOpt = (editor, elm) => {
|
- |
|
| 29941 |
const isRoot = elm => eq(elm, SugarElement.fromDom(editor.getBody()));
|
- |
|
| 29942 |
return closest$3(elm, 'a', isRoot).bind(a => getOpt(a, 'href'));
|
- |
|
| 29943 |
};
|
- |
|
| 29944 |
const processReadonlyEvents = (editor, e) => {
|
- |
|
| 29945 |
if (isClickEvent(e) && !VK.metaKeyPressed(e)) {
|
- |
|
| 29946 |
const elm = SugarElement.fromDom(e.target);
|
- |
|
| 29947 |
getAnchorHrefOpt(editor, elm).each(href => {
|
- |
|
| 29948 |
e.preventDefault();
|
- |
|
| 29949 |
if (/^#/.test(href)) {
|
- |
|
| 29950 |
const targetEl = editor.dom.select(`${ href },[name="${ removeLeading(href, '#') }"]`);
|
- |
|
| 29951 |
if (targetEl.length) {
|
- |
|
| 29952 |
editor.selection.scrollIntoView(targetEl[0], true);
|
- |
|
| 29953 |
}
|
- |
|
| 29954 |
} else {
|
- |
|
| 29955 |
window.open(href, '_blank', 'rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');
|
- |
|
| 29956 |
}
|
- |
|
| 29957 |
});
|
- |
|
| 29958 |
} else if (isReadOnlyAllowedEvent(e)) {
|
- |
|
| 29959 |
editor.dispatch(e.type, e);
|
- |
|
| 29960 |
}
|
- |
|
| 29961 |
};
|
- |
|
| 29962 |
const registerReadOnlySelectionBlockers = editor => {
|
- |
|
| 29963 |
editor.on('ShowCaret', e => {
|
- |
|
| 29964 |
if (isReadOnly(editor)) {
|
- |
|
| 29965 |
e.preventDefault();
|
- |
|
| 29966 |
}
|
- |
|
| 29967 |
});
|
- |
|
| 29968 |
editor.on('ObjectSelected', e => {
|
- |
|
| 29969 |
if (isReadOnly(editor)) {
|
- |
|
| 29970 |
e.preventDefault();
|
- |
|
| 29971 |
}
|
- |
|
| 29972 |
});
|
- |
|
| 29973 |
};
|
- |
|
| 29974 |
|
30405 |
|
| 29975 |
const nativeEvents = Tools.makeMap('focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange ' + 'mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover ' + 'draggesture dragdrop drop drag submit ' + 'compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel', ' ');
|
30406 |
const nativeEvents = Tools.makeMap('focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange ' + 'mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover ' + 'draggesture dragdrop drop drag submit ' + 'compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel', ' ');
|
| 29976 |
class EventDispatcher {
|
30407 |
class EventDispatcher {
|
| 29977 |
static isNative(name) {
|
30408 |
static isNative(name) {
|
| 29978 |
return !!nativeEvents[name.toLowerCase()];
|
30409 |
return !!nativeEvents[name.toLowerCase()];
|
| Línea 30161... |
Línea 30592... |
| 30161 |
}
|
30592 |
}
|
| 30162 |
return editor.eventRoot;
|
30593 |
return editor.eventRoot;
|
| 30163 |
}
|
30594 |
}
|
| 30164 |
return editor.getBody();
|
30595 |
return editor.getBody();
|
| 30165 |
};
|
30596 |
};
|
| 30166 |
const isListening = editor => !editor.hidden && !isReadOnly(editor);
|
30597 |
const isListening = editor => !editor.hidden && !isDisabled(editor);
|
| 30167 |
const fireEvent = (editor, eventName, e) => {
|
30598 |
const fireEvent = (editor, eventName, e) => {
|
| 30168 |
if (isListening(editor)) {
|
30599 |
if (isListening(editor)) {
|
| 30169 |
editor.dispatch(eventName, e);
|
30600 |
editor.dispatch(eventName, e);
|
| 30170 |
} else if (isReadOnly(editor)) {
|
30601 |
} else if (isDisabled(editor)) {
|
| 30171 |
processReadonlyEvents(editor, e);
|
30602 |
processDisabledEvents(editor, e);
|
| 30172 |
}
|
30603 |
}
|
| 30173 |
};
|
30604 |
};
|
| 30174 |
const bindEventDelegate = (editor, eventName) => {
|
30605 |
const bindEventDelegate = (editor, eventName) => {
|
| 30175 |
if (!editor.delegates) {
|
30606 |
if (!editor.delegates) {
|
| 30176 |
editor.delegates = {};
|
30607 |
editor.delegates = {};
|
| Línea 30344... |
Línea 30775... |
| 30344 |
console.error(getErrorMessage(`Invalid default value passed for the "${ name }" option`, result));
|
30775 |
console.error(getErrorMessage(`Invalid default value passed for the "${ name }" option`, result));
|
| 30345 |
}
|
30776 |
}
|
| 30346 |
}
|
30777 |
}
|
| 30347 |
return undefined;
|
30778 |
return undefined;
|
| 30348 |
};
|
30779 |
};
|
| 30349 |
const create$5 = (editor, initialOptions) => {
|
30780 |
const create$5 = (editor, initialOptions, rawInitialOptions = initialOptions) => {
|
| 30350 |
const registry = {};
|
30781 |
const registry = {};
|
| 30351 |
const values = {};
|
30782 |
const values = {};
|
| 30352 |
const setValue = (name, value, processor) => {
|
30783 |
const setValue = (name, value, processor) => {
|
| 30353 |
const result = processValue(value, processor);
|
30784 |
const result = processValue(value, processor);
|
| 30354 |
if (isValidResult(result)) {
|
30785 |
if (isValidResult(result)) {
|
| Línea 30392... |
Línea 30823... |
| 30392 |
delete values[name];
|
30823 |
delete values[name];
|
| 30393 |
}
|
30824 |
}
|
| 30394 |
return registered;
|
30825 |
return registered;
|
| 30395 |
};
|
30826 |
};
|
| 30396 |
const isSet = name => has$2(values, name);
|
30827 |
const isSet = name => has$2(values, name);
|
| - |
|
30828 |
const debug = () => {
|
| - |
|
30829 |
try {
|
| - |
|
30830 |
console.log(JSON.parse(JSON.stringify(rawInitialOptions, (_key, value) => {
|
| - |
|
30831 |
if (isBoolean(value) || isNumber(value) || isString(value) || isNull(value) || isArray$1(value) || isPlainObject(value)) {
|
| - |
|
30832 |
return value;
|
| - |
|
30833 |
}
|
| - |
|
30834 |
return Object.prototype.toString.call(value);
|
| - |
|
30835 |
})));
|
| - |
|
30836 |
} catch (error) {
|
| - |
|
30837 |
console.error(error);
|
| - |
|
30838 |
}
|
| - |
|
30839 |
};
|
| 30397 |
return {
|
30840 |
return {
|
| 30398 |
register,
|
30841 |
register,
|
| 30399 |
isRegistered,
|
30842 |
isRegistered,
|
| 30400 |
get,
|
30843 |
get,
|
| 30401 |
set,
|
30844 |
set,
|
| 30402 |
unset,
|
30845 |
unset,
|
| 30403 |
isSet
|
30846 |
isSet,
|
| - |
|
30847 |
debug
|
| 30404 |
};
|
30848 |
};
|
| 30405 |
};
|
30849 |
};
|
| Línea -... |
Línea 30850... |
| - |
|
30850 |
|
| - |
|
30851 |
const setContentEditable = (elm, state) => {
|
| - |
|
30852 |
elm.dom.contentEditable = state ? 'true' : 'false';
|
| - |
|
30853 |
};
|
| - |
|
30854 |
const toggleReadOnly = (editor, state) => {
|
| - |
|
30855 |
const body = SugarElement.fromDom(editor.getBody());
|
| - |
|
30856 |
if (state) {
|
| - |
|
30857 |
editor.readonly = true;
|
| - |
|
30858 |
if (editor.hasEditableRoot()) {
|
| - |
|
30859 |
setContentEditable(body, true);
|
| - |
|
30860 |
}
|
| - |
|
30861 |
disableEditor(editor);
|
| - |
|
30862 |
} else {
|
| - |
|
30863 |
editor.readonly = false;
|
| - |
|
30864 |
enableEditor(editor);
|
| - |
|
30865 |
}
|
| - |
|
30866 |
};
|
| - |
|
30867 |
const isReadOnly = editor => editor.readonly;
|
| - |
|
30868 |
const registerReadOnlyInputBlockers = editor => {
|
| - |
|
30869 |
editor.on('beforeinput paste cut dragend dragover draggesture dragdrop drop drag', e => {
|
| - |
|
30870 |
if (isReadOnly(editor)) {
|
| - |
|
30871 |
e.preventDefault();
|
| - |
|
30872 |
}
|
| - |
|
30873 |
});
|
| - |
|
30874 |
editor.on('BeforeExecCommand', e => {
|
| - |
|
30875 |
if ((e.command === 'Undo' || e.command === 'Redo') && isReadOnly(editor)) {
|
| - |
|
30876 |
e.preventDefault();
|
| - |
|
30877 |
}
|
| - |
|
30878 |
});
|
| - |
|
30879 |
editor.on('input', e => {
|
| - |
|
30880 |
if (!e.isComposing && isReadOnly(editor)) {
|
| - |
|
30881 |
const undoLevel = editor.undoManager.add();
|
| - |
|
30882 |
if (isNonNullable(undoLevel)) {
|
| - |
|
30883 |
editor.undoManager.undo();
|
| - |
|
30884 |
}
|
| - |
|
30885 |
}
|
| - |
|
30886 |
});
|
| - |
|
30887 |
editor.on('compositionend', () => {
|
| - |
|
30888 |
if (isReadOnly(editor)) {
|
| - |
|
30889 |
const undoLevel = editor.undoManager.add();
|
| - |
|
30890 |
if (isNonNullable(undoLevel)) {
|
| - |
|
30891 |
editor.undoManager.undo();
|
| - |
|
30892 |
}
|
| - |
|
30893 |
}
|
| - |
|
30894 |
});
|
| - |
|
30895 |
};
|
| 30406 |
|
30896 |
|
| 30407 |
const defaultModes = [
|
30897 |
const defaultModes = [
|
| 30408 |
'design',
|
30898 |
'design',
|
| 30409 |
'readonly'
|
30899 |
'readonly'
|
| 30410 |
];
|
30900 |
];
|
| Línea 30423... |
Línea 30913... |
| 30423 |
}
|
30913 |
}
|
| 30424 |
activeMode.set(mode);
|
30914 |
activeMode.set(mode);
|
| 30425 |
fireSwitchMode(editor, mode);
|
30915 |
fireSwitchMode(editor, mode);
|
| 30426 |
};
|
30916 |
};
|
| 30427 |
const setMode = (editor, availableModes, activeMode, mode) => {
|
30917 |
const setMode = (editor, availableModes, activeMode, mode) => {
|
| 30428 |
if (mode === activeMode.get()) {
|
30918 |
if (mode === activeMode.get() || editor.initialized && isDisabled(editor)) {
|
| 30429 |
return;
|
30919 |
return;
|
| 30430 |
} else if (!has$2(availableModes, mode)) {
|
30920 |
} else if (!has$2(availableModes, mode)) {
|
| 30431 |
throw new Error(`Editor mode '${ mode }' is invalid`);
|
30921 |
throw new Error(`Editor mode '${ mode }' is invalid`);
|
| 30432 |
}
|
30922 |
}
|
| 30433 |
if (editor.initialized) {
|
30923 |
if (editor.initialized) {
|
| Línea 30467... |
Línea 30957... |
| 30467 |
activate: noop,
|
30957 |
activate: noop,
|
| 30468 |
deactivate: noop,
|
30958 |
deactivate: noop,
|
| 30469 |
editorReadOnly: true
|
30959 |
editorReadOnly: true
|
| 30470 |
}
|
30960 |
}
|
| 30471 |
});
|
30961 |
});
|
| 30472 |
registerReadOnlyContentFilters(editor);
|
30962 |
registerReadOnlyInputBlockers(editor);
|
| 30473 |
registerReadOnlySelectionBlockers(editor);
|
30963 |
registerEventsAndFilters$1(editor);
|
| 30474 |
return {
|
30964 |
return {
|
| 30475 |
isReadOnly: () => isReadOnly(editor),
|
30965 |
isReadOnly: () => isReadOnly(editor),
|
| 30476 |
set: mode => setMode(editor, availableModes.get(), activeMode, mode),
|
30966 |
set: mode => setMode(editor, availableModes.get(), activeMode, mode),
|
| 30477 |
get: () => activeMode.get(),
|
30967 |
get: () => activeMode.get(),
|
| 30478 |
register: (mode, api) => {
|
30968 |
register: (mode, api) => {
|
| Línea 30643... |
Línea 31133... |
| 30643 |
const menuItems = {};
|
31133 |
const menuItems = {};
|
| 30644 |
const popups = {};
|
31134 |
const popups = {};
|
| 30645 |
const icons = {};
|
31135 |
const icons = {};
|
| 30646 |
const contextMenus = {};
|
31136 |
const contextMenus = {};
|
| 30647 |
const contextToolbars = {};
|
31137 |
const contextToolbars = {};
|
| - |
|
31138 |
const contexts = {};
|
| 30648 |
const sidebars = {};
|
31139 |
const sidebars = {};
|
| 30649 |
const views = {};
|
31140 |
const views = {};
|
| 30650 |
const add = (collection, type) => (name, spec) => {
|
31141 |
const add = (collection, type) => (name, spec) => {
|
| 30651 |
collection[name.toLowerCase()] = {
|
31142 |
collection[name.toLowerCase()] = {
|
| 30652 |
...spec,
|
31143 |
...spec,
|
| 30653 |
type
|
31144 |
type
|
| 30654 |
};
|
31145 |
};
|
| 30655 |
};
|
31146 |
};
|
| - |
|
31147 |
const addDefaulted = (collection, type) => (name, spec) => {
|
| - |
|
31148 |
collection[name.toLowerCase()] = {
|
| - |
|
31149 |
type,
|
| - |
|
31150 |
...spec
|
| - |
|
31151 |
};
|
| - |
|
31152 |
};
|
| 30656 |
const addIcon = (name, svgData) => icons[name.toLowerCase()] = svgData;
|
31153 |
const addIcon = (name, svgData) => icons[name.toLowerCase()] = svgData;
|
| - |
|
31154 |
const addContext = (name, pred) => contexts[name.toLowerCase()] = pred;
|
| 30657 |
return {
|
31155 |
return {
|
| 30658 |
addButton: add(buttons, 'button'),
|
31156 |
addButton: add(buttons, 'button'),
|
| 30659 |
addGroupToolbarButton: add(buttons, 'grouptoolbarbutton'),
|
31157 |
addGroupToolbarButton: add(buttons, 'grouptoolbarbutton'),
|
| 30660 |
addToggleButton: add(buttons, 'togglebutton'),
|
31158 |
addToggleButton: add(buttons, 'togglebutton'),
|
| 30661 |
addMenuButton: add(buttons, 'menubutton'),
|
31159 |
addMenuButton: add(buttons, 'menubutton'),
|
| Línea 30664... |
Línea 31162... |
| 30664 |
addNestedMenuItem: add(menuItems, 'nestedmenuitem'),
|
31162 |
addNestedMenuItem: add(menuItems, 'nestedmenuitem'),
|
| 30665 |
addToggleMenuItem: add(menuItems, 'togglemenuitem'),
|
31163 |
addToggleMenuItem: add(menuItems, 'togglemenuitem'),
|
| 30666 |
addAutocompleter: add(popups, 'autocompleter'),
|
31164 |
addAutocompleter: add(popups, 'autocompleter'),
|
| 30667 |
addContextMenu: add(contextMenus, 'contextmenu'),
|
31165 |
addContextMenu: add(contextMenus, 'contextmenu'),
|
| 30668 |
addContextToolbar: add(contextToolbars, 'contexttoolbar'),
|
31166 |
addContextToolbar: add(contextToolbars, 'contexttoolbar'),
|
| 30669 |
addContextForm: add(contextToolbars, 'contextform'),
|
31167 |
addContextForm: addDefaulted(contextToolbars, 'contextform'),
|
| 30670 |
addSidebar: add(sidebars, 'sidebar'),
|
31168 |
addSidebar: add(sidebars, 'sidebar'),
|
| 30671 |
addView: add(views, 'views'),
|
31169 |
addView: add(views, 'views'),
|
| 30672 |
addIcon,
|
31170 |
addIcon,
|
| - |
|
31171 |
addContext,
|
| 30673 |
getAll: () => ({
|
31172 |
getAll: () => ({
|
| 30674 |
buttons,
|
31173 |
buttons,
|
| 30675 |
menuItems,
|
31174 |
menuItems,
|
| 30676 |
icons,
|
31175 |
icons,
|
| 30677 |
popups,
|
31176 |
popups,
|
| 30678 |
contextMenus,
|
31177 |
contextMenus,
|
| 30679 |
contextToolbars,
|
31178 |
contextToolbars,
|
| 30680 |
sidebars,
|
31179 |
sidebars,
|
| 30681 |
views
|
31180 |
views,
|
| - |
|
31181 |
contexts
|
| 30682 |
})
|
31182 |
})
|
| 30683 |
};
|
31183 |
};
|
| 30684 |
};
|
31184 |
};
|
| Línea 30685... |
Línea 31185... |
| 30685 |
|
31185 |
|
| Línea 30699... |
Línea 31199... |
| 30699 |
addSplitButton: bridge.addSplitButton,
|
31199 |
addSplitButton: bridge.addSplitButton,
|
| 30700 |
addToggleButton: bridge.addToggleButton,
|
31200 |
addToggleButton: bridge.addToggleButton,
|
| 30701 |
addGroupToolbarButton: bridge.addGroupToolbarButton,
|
31201 |
addGroupToolbarButton: bridge.addGroupToolbarButton,
|
| 30702 |
addToggleMenuItem: bridge.addToggleMenuItem,
|
31202 |
addToggleMenuItem: bridge.addToggleMenuItem,
|
| 30703 |
addView: bridge.addView,
|
31203 |
addView: bridge.addView,
|
| - |
|
31204 |
addContext: bridge.addContext,
|
| 30704 |
getAll: bridge.getAll
|
31205 |
getAll: bridge.getAll
|
| 30705 |
};
|
31206 |
};
|
| 30706 |
};
|
31207 |
};
|
| Línea 30707... |
Línea 31208... |
| 30707 |
|
31208 |
|
| Línea 30730... |
Línea 31231... |
| 30730 |
extend(this, EditorObservable);
|
31231 |
extend(this, EditorObservable);
|
| 30731 |
const self = this;
|
31232 |
const self = this;
|
| 30732 |
this.id = id;
|
31233 |
this.id = id;
|
| 30733 |
this.hidden = false;
|
31234 |
this.hidden = false;
|
| 30734 |
const normalizedOptions = normalizeOptions(editorManager.defaultOptions, options);
|
31235 |
const normalizedOptions = normalizeOptions(editorManager.defaultOptions, options);
|
| 30735 |
this.options = create$5(self, normalizedOptions);
|
31236 |
this.options = create$5(self, normalizedOptions, options);
|
| 30736 |
register$7(self);
|
31237 |
register$7(self);
|
| 30737 |
const getOption = this.options.get;
|
31238 |
const getOption = this.options.get;
|
| 30738 |
if (getOption('deprecation_warnings')) {
|
31239 |
if (getOption('deprecation_warnings')) {
|
| 30739 |
logWarnings(options, normalizedOptions);
|
31240 |
logWarnings(options, normalizedOptions);
|
| 30740 |
}
|
31241 |
}
|
| Línea 31134... |
Línea 31635... |
| 31134 |
baseURI: null,
|
31635 |
baseURI: null,
|
| 31135 |
baseURL: null,
|
31636 |
baseURL: null,
|
| 31136 |
defaultOptions: {},
|
31637 |
defaultOptions: {},
|
| 31137 |
documentBaseURL: null,
|
31638 |
documentBaseURL: null,
|
| 31138 |
suffix: null,
|
31639 |
suffix: null,
|
| 31139 |
majorVersion: '6',
|
31640 |
majorVersion: '7',
|
| 31140 |
minorVersion: '8.3',
|
31641 |
minorVersion: '7.1',
|
| 31141 |
releaseDate: '2024-02-08',
|
31642 |
releaseDate: '2025-03-05',
|
| 31142 |
i18n: I18n,
|
31643 |
i18n: I18n,
|
| 31143 |
activeEditor: null,
|
31644 |
activeEditor: null,
|
| 31144 |
focusedEditor: null,
|
31645 |
focusedEditor: null,
|
| 31145 |
setup() {
|
31646 |
setup() {
|
| 31146 |
const self = this;
|
31647 |
const self = this;
|
| Línea 31224... |
Línea 31725... |
| 31224 |
}
|
31725 |
}
|
| 31225 |
return callback.apply(self, []);
|
31726 |
return callback.apply(self, []);
|
| 31226 |
};
|
31727 |
};
|
| 31227 |
const findTargets = options => {
|
31728 |
const findTargets = options => {
|
| 31228 |
if (Env.browser.isIE() || Env.browser.isEdge()) {
|
31729 |
if (Env.browser.isIE() || Env.browser.isEdge()) {
|
| 31229 |
initError('TinyMCE does not support the browser you are using. For a list of supported' + ' browsers please see: https://www.tiny.cloud/docs/tinymce/6/support/#supportedwebbrowsers');
|
31730 |
initError('TinyMCE does not support the browser you are using. For a list of supported' + ' browsers please see: https://www.tiny.cloud/docs/tinymce/7/support/#supportedwebbrowsers');
|
| 31230 |
return [];
|
31731 |
return [];
|
| 31231 |
} else if (isQuirksMode) {
|
31732 |
} else if (isQuirksMode) {
|
| 31232 |
initError('Failed to initialize the editor as the document is not in standards mode. ' + 'TinyMCE requires standards mode.');
|
31733 |
initError('Failed to initialize the editor as the document is not in standards mode. ' + 'TinyMCE requires standards mode.');
|
| 31233 |
return [];
|
31734 |
return [];
|
| 31234 |
} else if (isString(options.selector)) {
|
31735 |
} else if (isString(options.selector)) {
|
| Línea 31606... |
Línea 32107... |
| 31606 |
const has = id => {
|
32107 |
const has = id => {
|
| 31607 |
return id in resources;
|
32108 |
return id in resources;
|
| 31608 |
};
|
32109 |
};
|
| 31609 |
const unload = id => {
|
32110 |
const unload = id => {
|
| 31610 |
delete tasks[id];
|
32111 |
delete tasks[id];
|
| - |
|
32112 |
delete resources[id];
|
| 31611 |
};
|
32113 |
};
|
| 31612 |
const get = id => resources[id];
|
32114 |
const get = id => resources[id];
|
| 31613 |
return {
|
32115 |
return {
|
| 31614 |
load,
|
32116 |
load,
|
| 31615 |
add,
|
32117 |
add,
|
| Línea 31657... |
Línea 32159... |
| 31657 |
try {
|
32159 |
try {
|
| 31658 |
const test = '__storage_test__';
|
32160 |
const test = '__storage_test__';
|
| 31659 |
localStorage = window.localStorage;
|
32161 |
localStorage = window.localStorage;
|
| 31660 |
localStorage.setItem(test, test);
|
32162 |
localStorage.setItem(test, test);
|
| 31661 |
localStorage.removeItem(test);
|
32163 |
localStorage.removeItem(test);
|
| 31662 |
} catch (e) {
|
32164 |
} catch (_a) {
|
| 31663 |
localStorage = create();
|
32165 |
localStorage = create();
|
| 31664 |
}
|
32166 |
}
|
| 31665 |
var LocalStorage = localStorage;
|
32167 |
var LocalStorage = localStorage;
|
| Línea 31666... |
Línea 32168... |
| 31666 |
|
32168 |
|
| Línea 31740... |
Línea 32242... |
| 31740 |
|
32242 |
|
| 31741 |
const exportToModuleLoaders = tinymce => {
|
32243 |
const exportToModuleLoaders = tinymce => {
|
| 31742 |
if (typeof module === 'object') {
|
32244 |
if (typeof module === 'object') {
|
| 31743 |
try {
|
32245 |
try {
|
| 31744 |
module.exports = tinymce;
|
32246 |
module.exports = tinymce;
|
| 31745 |
} catch (_) {
|
32247 |
} catch (_a) {
|
| 31746 |
}
|
32248 |
}
|
| 31747 |
}
|
32249 |
}
|
| 31748 |
};
|
32250 |
};
|
| 31749 |
const exportToWindowGlobal = tinymce => {
|
32251 |
const exportToWindowGlobal = tinymce => {
|