Add theme assets;

This commit is contained in:
kagir committed 2024-01-21 17:18:37 +01:00
1 parent fcc061aeba
commit aa45b6a645
1425 files changed
+430771 -1

No files matched your search

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