Add theme assets;
This commit is contained in:
7
public/assets/vendors/tinymce/plugins/quickbars/index.js
vendored
Normal file
7
public/assets/vendors/tinymce/plugins/quickbars/index.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Exports the "quickbars" plugin for usage with module loaders
|
||||
// Usage:
|
||||
// CommonJS:
|
||||
// require('tinymce/plugins/quickbars')
|
||||
// ES2015:
|
||||
// import 'tinymce/plugins/quickbars'
|
||||
require('./plugin.js');
|
||||
421
public/assets/vendors/tinymce/plugins/quickbars/plugin.js
vendored
Normal file
421
public/assets/vendors/tinymce/plugins/quickbars/plugin.js
vendored
Normal file
@@ -0,0 +1,421 @@
|
||||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
*/
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
||||
|
||||
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 = type => value => typeOf(value) === type;
|
||||
const isSimpleType = type => value => typeof value === type;
|
||||
const isString = isType('string');
|
||||
const isBoolean = isSimpleType('boolean');
|
||||
const isNullable = a => a === null || a === undefined;
|
||||
const isNonNullable = a => !isNullable(a);
|
||||
const isFunction = isSimpleType('function');
|
||||
|
||||
const option = name => editor => editor.options.get(name);
|
||||
const register = editor => {
|
||||
const registerOption = editor.options.register;
|
||||
const toolbarProcessor = defaultValue => value => {
|
||||
const valid = isBoolean(value) || isString(value);
|
||||
if (valid) {
|
||||
if (isBoolean(value)) {
|
||||
return {
|
||||
value: value ? defaultValue : '',
|
||||
valid
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
value: value.trim(),
|
||||
valid
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
valid: false,
|
||||
message: 'Must be a boolean or string.'
|
||||
};
|
||||
}
|
||||
};
|
||||
const defaultSelectionToolbar = 'bold italic | quicklink h2 h3 blockquote';
|
||||
registerOption('quickbars_selection_toolbar', {
|
||||
processor: toolbarProcessor(defaultSelectionToolbar),
|
||||
default: defaultSelectionToolbar
|
||||
});
|
||||
const defaultInsertToolbar = 'quickimage quicktable';
|
||||
registerOption('quickbars_insert_toolbar', {
|
||||
processor: toolbarProcessor(defaultInsertToolbar),
|
||||
default: defaultInsertToolbar
|
||||
});
|
||||
const defaultImageToolbar = 'alignleft aligncenter alignright';
|
||||
registerOption('quickbars_image_toolbar', {
|
||||
processor: toolbarProcessor(defaultImageToolbar),
|
||||
default: defaultImageToolbar
|
||||
});
|
||||
};
|
||||
const getTextSelectionToolbarItems = option('quickbars_selection_toolbar');
|
||||
const getInsertToolbarItems = option('quickbars_insert_toolbar');
|
||||
const getImageToolbarItems = option('quickbars_image_toolbar');
|
||||
|
||||
let unique = 0;
|
||||
const generate = prefix => {
|
||||
const date = new Date();
|
||||
const time = date.getTime();
|
||||
const random = Math.floor(Math.random() * 1000000000);
|
||||
unique++;
|
||||
return prefix + '_' + random + unique + String(time);
|
||||
};
|
||||
|
||||
const insertTable = (editor, columns, rows) => {
|
||||
editor.execCommand('mceInsertTable', false, {
|
||||
rows,
|
||||
columns
|
||||
});
|
||||
};
|
||||
const insertBlob = (editor, base64, blob) => {
|
||||
const blobCache = editor.editorUpload.blobCache;
|
||||
const blobInfo = blobCache.create(generate('mceu'), blob, base64);
|
||||
blobCache.add(blobInfo);
|
||||
editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() }));
|
||||
};
|
||||
|
||||
const blobToBase64 = blob => {
|
||||
return new Promise(resolve => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => {
|
||||
resolve(reader.result.split(',')[1]);
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
};
|
||||
|
||||
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
||||
|
||||
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
||||
|
||||
const pickFile = editor => new Promise(resolve => {
|
||||
const fileInput = document.createElement('input');
|
||||
fileInput.type = 'file';
|
||||
fileInput.accept = 'image/*';
|
||||
fileInput.style.position = 'fixed';
|
||||
fileInput.style.left = '0';
|
||||
fileInput.style.top = '0';
|
||||
fileInput.style.opacity = '0.001';
|
||||
document.body.appendChild(fileInput);
|
||||
const changeHandler = e => {
|
||||
resolve(Array.prototype.slice.call(e.target.files));
|
||||
};
|
||||
fileInput.addEventListener('change', changeHandler);
|
||||
const cancelHandler = e => {
|
||||
const cleanup = () => {
|
||||
resolve([]);
|
||||
fileInput.parentNode.removeChild(fileInput);
|
||||
};
|
||||
if (global$1.os.isAndroid() && e.type !== 'remove') {
|
||||
global.setEditorTimeout(editor, cleanup, 0);
|
||||
} else {
|
||||
cleanup();
|
||||
}
|
||||
editor.off('focusin remove', cancelHandler);
|
||||
};
|
||||
editor.on('focusin remove', cancelHandler);
|
||||
fileInput.click();
|
||||
});
|
||||
|
||||
const setupButtons = editor => {
|
||||
editor.ui.registry.addButton('quickimage', {
|
||||
icon: 'image',
|
||||
tooltip: 'Insert image',
|
||||
onAction: () => {
|
||||
pickFile(editor).then(files => {
|
||||
if (files.length > 0) {
|
||||
const blob = files[0];
|
||||
blobToBase64(blob).then(base64 => {
|
||||
insertBlob(editor, base64, blob);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
editor.ui.registry.addButton('quicktable', {
|
||||
icon: 'table',
|
||||
tooltip: 'Insert table',
|
||||
onAction: () => {
|
||||
insertTable(editor, 2, 2);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const constant = value => {
|
||||
return () => {
|
||||
return value;
|
||||
};
|
||||
};
|
||||
const never = constant(false);
|
||||
|
||||
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);
|
||||
|
||||
var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
|
||||
if (is(scope, a)) {
|
||||
return Optional.some(scope);
|
||||
} else if (isFunction(isRoot) && isRoot(scope)) {
|
||||
return Optional.none();
|
||||
} else {
|
||||
return ancestor(scope, a, isRoot);
|
||||
}
|
||||
};
|
||||
|
||||
const ELEMENT = 1;
|
||||
|
||||
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 is = (element, selector) => {
|
||||
const dom = element.dom;
|
||||
if (dom.nodeType !== ELEMENT) {
|
||||
return false;
|
||||
} else {
|
||||
const elem = dom;
|
||||
if (elem.matches !== undefined) {
|
||||
return elem.matches(selector);
|
||||
} else if (elem.msMatchesSelector !== undefined) {
|
||||
return elem.msMatchesSelector(selector);
|
||||
} else if (elem.webkitMatchesSelector !== undefined) {
|
||||
return elem.webkitMatchesSelector(selector);
|
||||
} else if (elem.mozMatchesSelector !== undefined) {
|
||||
return elem.mozMatchesSelector(selector);
|
||||
} else {
|
||||
throw new Error('Browser lacks native selectors');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
typeof window !== 'undefined' ? window : Function('return this;')();
|
||||
|
||||
const name = element => {
|
||||
const r = element.dom.nodeName;
|
||||
return r.toLowerCase();
|
||||
};
|
||||
|
||||
const ancestor$1 = (scope, predicate, isRoot) => {
|
||||
let element = scope.dom;
|
||||
const stop = isFunction(isRoot) ? isRoot : never;
|
||||
while (element.parentNode) {
|
||||
element = element.parentNode;
|
||||
const el = SugarElement.fromDom(element);
|
||||
if (predicate(el)) {
|
||||
return Optional.some(el);
|
||||
} else if (stop(el)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Optional.none();
|
||||
};
|
||||
const closest$1 = (scope, predicate, isRoot) => {
|
||||
const is = (s, test) => test(s);
|
||||
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
|
||||
};
|
||||
|
||||
const ancestor = (scope, selector, isRoot) => ancestor$1(scope, e => is(e, selector), isRoot);
|
||||
const closest = (scope, selector, isRoot) => {
|
||||
const is$1 = (element, selector) => is(element, selector);
|
||||
return ClosestOrAncestor(is$1, ancestor, scope, selector, isRoot);
|
||||
};
|
||||
|
||||
const addToEditor$1 = editor => {
|
||||
const insertToolbarItems = getInsertToolbarItems(editor);
|
||||
if (insertToolbarItems.length > 0) {
|
||||
editor.ui.registry.addContextToolbar('quickblock', {
|
||||
predicate: node => {
|
||||
const sugarNode = SugarElement.fromDom(node);
|
||||
const textBlockElementsMap = editor.schema.getTextBlockElements();
|
||||
const isRoot = elem => elem.dom === editor.getBody();
|
||||
return closest(sugarNode, 'table', isRoot).fold(() => closest$1(sugarNode, elem => name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom), isRoot).isSome(), never);
|
||||
},
|
||||
items: insertToolbarItems,
|
||||
position: 'line',
|
||||
scope: 'editor'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const addToEditor = editor => {
|
||||
const isEditable = node => editor.dom.getContentEditableParent(node) !== 'false';
|
||||
const isImage = node => node.nodeName === 'IMG' || node.nodeName === 'FIGURE' && /image/i.test(node.className);
|
||||
const imageToolbarItems = getImageToolbarItems(editor);
|
||||
if (imageToolbarItems.length > 0) {
|
||||
editor.ui.registry.addContextToolbar('imageselection', {
|
||||
predicate: isImage,
|
||||
items: imageToolbarItems,
|
||||
position: 'node'
|
||||
});
|
||||
}
|
||||
const textToolbarItems = getTextSelectionToolbarItems(editor);
|
||||
if (textToolbarItems.length > 0) {
|
||||
editor.ui.registry.addContextToolbar('textselection', {
|
||||
predicate: node => !isImage(node) && !editor.selection.isCollapsed() && isEditable(node),
|
||||
items: textToolbarItems,
|
||||
position: 'selection',
|
||||
scope: 'editor'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var Plugin = () => {
|
||||
global$2.add('quickbars', editor => {
|
||||
register(editor);
|
||||
setupButtons(editor);
|
||||
addToEditor$1(editor);
|
||||
addToEditor(editor);
|
||||
});
|
||||
};
|
||||
|
||||
Plugin();
|
||||
|
||||
})();
|
||||
4
public/assets/vendors/tinymce/plugins/quickbars/plugin.min.js
vendored
Normal file
4
public/assets/vendors/tinymce/plugins/quickbars/plugin.min.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* TinyMCE version 6.1.2 (2022-07-29)
|
||||
*/
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>typeof t===e,o=("string",e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=n=e,(r=String).prototype.isPrototypeOf(o)||(null===(i=n.constructor)||void 0===i?void 0:i.name)===r.name)?"string":t;var o,n,r,i})(e));const n=t("boolean"),r=t("function"),i=e=>t=>t.options.get(e),s=i("quickbars_selection_toolbar"),a=i("quickbars_insert_toolbar"),l=i("quickbars_image_toolbar");let c=0;var u=tinymce.util.Tools.resolve("tinymce.Env"),d=tinymce.util.Tools.resolve("tinymce.util.Delay");const m=e=>{e.ui.registry.addButton("quickimage",{icon:"image",tooltip:"Insert image",onAction:()=>{(e=>new Promise((t=>{const o=document.createElement("input");o.type="file",o.accept="image/*",o.style.position="fixed",o.style.left="0",o.style.top="0",o.style.opacity="0.001",document.body.appendChild(o),o.addEventListener("change",(e=>{t(Array.prototype.slice.call(e.target.files))}));const n=r=>{const i=()=>{t([]),o.parentNode.removeChild(o)};u.os.isAndroid()&&"remove"!==r.type?d.setEditorTimeout(e,i,0):i(),e.off("focusin remove",n)};e.on("focusin remove",n),o.click()})))(e).then((t=>{if(t.length>0){const o=t[0];(e=>new Promise((t=>{const o=new FileReader;o.onloadend=()=>{t(o.result.split(",")[1])},o.readAsDataURL(e)})))(o).then((t=>{((e,t,o)=>{const n=e.editorUpload.blobCache,r=n.create((e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return c++,"mceu_"+o+c+String(t)})(),o,t);n.add(r),e.insertContent(e.dom.createHTML("img",{src:r.blobUri()}))})(e,t,o)}))}}))}}),e.ui.registry.addButton("quicktable",{icon:"table",tooltip:"Insert table",onAction:()=>{((e,t,o)=>{e.execCommand("mceInsertTable",!1,{rows:2,columns:2})})(e)}})},g=(!1,()=>false);class h{constructor(e,t){this.tag=e,this.value=t}static some(e){return new h(!0,e)}static none(){return h.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?h.some(e(this.value)):h.none()}bind(e){return this.tag?e(this.value):h.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:h.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return null==e?h.none():h.some(e)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}h.singletonNone=new h(!1);var b=(e,t,o,n,i)=>e(o,n)?h.some(o):r(i)&&i(o)?h.none():t(o,n,i);const p=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},f=p,v=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}};"undefined"!=typeof window?window:Function("return this;")();const y=(e,t,o)=>{let n=e.dom;const i=r(o)?o:g;for(;n.parentNode;){n=n.parentNode;const e=f(n);if(t(e))return h.some(e);if(i(e))break}return h.none()},k=(e,t,o)=>y(e,(e=>v(e,t)),o),w=e=>{const t=a(e);t.length>0&&e.ui.registry.addContextToolbar("quickblock",{predicate:t=>{const o=f(t),n=e.schema.getTextBlockElements(),r=t=>t.dom===e.getBody();return((e,t,o)=>b(((e,t)=>v(e,t)),k,e,"table",o))(o,0,r).fold((()=>((t,o,r)=>b(((e,t)=>t(e)),y,t,(t=>t.dom.nodeName.toLowerCase()in n&&e.dom.isEmpty(t.dom)),r))(o,0,r).isSome()),g)},items:t,position:"line",scope:"editor"})};e.add("quickbars",(e=>{(e=>{const t=e.options.register,r=e=>t=>{const r=n(t)||o(t);return r?n(t)?{value:t?e:"",valid:r}:{value:t.trim(),valid:r}:{valid:!1,message:"Must be a boolean or string."}},i="bold italic | quicklink h2 h3 blockquote";t("quickbars_selection_toolbar",{processor:r(i),default:i});const s="quickimage quicktable";t("quickbars_insert_toolbar",{processor:r(s),default:s});const a="alignleft aligncenter alignright";t("quickbars_image_toolbar",{processor:r(a),default:a})})(e),m(e),w(e),(e=>{const t=e=>"IMG"===e.nodeName||"FIGURE"===e.nodeName&&/image/i.test(e.className),o=l(e);o.length>0&&e.ui.registry.addContextToolbar("imageselection",{predicate:t,items:o,position:"node"});const n=s(e);n.length>0&&e.ui.registry.addContextToolbar("textselection",{predicate:o=>!t(o)&&!e.selection.isCollapsed()&&(t=>"false"!==e.dom.getContentEditableParent(t))(o),items:n,position:"selection",scope:"editor"})})(e)}))}();
|
||||
Reference in New Issue
Block a user