@themarioga/grid-editor 6.0.0-beta.5 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTO_SAVE.md +2 -2
- package/BUILDING.md +45 -29
- package/CHANGELOG.md +54 -0
- package/README.md +140 -89
- package/UPGRADING.md +146 -2
- package/dist/grideditor.bundle.min.js +14 -0
- package/dist/grideditor.d.ts +335 -0
- package/dist/grideditor.esm.js +3977 -0
- package/dist/grideditor.jquery.js +253 -0
- package/dist/grideditor.jquery.min.js +1 -0
- package/dist/grideditor.jquery.min.js.map +7 -0
- package/dist/grideditor.js +3983 -0
- package/dist/grideditor.min.js +6 -0
- package/dist/grideditor.min.js.map +7 -0
- package/dist/locales/grideditor.es.esm.js +158 -0
- package/dist/locales/grideditor.es.js +164 -170
- package/dist/locales/grideditor.es.min.js +6 -2
- package/dist/locales/grideditor.es.min.js.map +7 -1
- package/dist/plugins/grideditor.accordion.esm.js +294 -0
- package/dist/plugins/grideditor.accordion.js +286 -180
- package/dist/plugins/grideditor.accordion.min.js +1 -2
- package/dist/plugins/grideditor.accordion.min.js.map +7 -1
- package/dist/plugins/grideditor.alignment.esm.js +55 -0
- package/dist/plugins/grideditor.alignment.js +58 -77
- package/dist/plugins/grideditor.alignment.min.js +1 -2
- package/dist/plugins/grideditor.alignment.min.js.map +7 -1
- package/dist/plugins/grideditor.card.esm.js +73 -0
- package/dist/plugins/grideditor.card.js +74 -64
- package/dist/plugins/grideditor.card.min.js +1 -2
- package/dist/plugins/grideditor.card.min.js.map +7 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
- package/dist/plugins/grideditor.ckeditor.js +482 -493
- package/dist/plugins/grideditor.ckeditor.min.js +1 -2
- package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
- package/dist/plugins/grideditor.clipboard.esm.js +326 -0
- package/dist/plugins/grideditor.clipboard.js +298 -235
- package/dist/plugins/grideditor.clipboard.min.js +1 -2
- package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
- package/dist/plugins/grideditor.codemirror-inline.js +188 -168
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror.esm.js +63 -0
- package/dist/plugins/grideditor.codemirror.js +60 -71
- package/dist/plugins/grideditor.codemirror.min.js +1 -2
- package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
- package/dist/plugins/grideditor.elements.esm.js +271 -0
- package/dist/plugins/grideditor.elements.js +256 -149
- package/dist/plugins/grideditor.elements.min.js +1 -2
- package/dist/plugins/grideditor.elements.min.js.map +7 -1
- package/dist/plugins/grideditor.float.esm.js +34 -0
- package/dist/plugins/grideditor.float.js +37 -52
- package/dist/plugins/grideditor.float.min.js +1 -2
- package/dist/plugins/grideditor.float.min.js.map +7 -1
- package/dist/plugins/grideditor.gutters.esm.js +143 -0
- package/dist/plugins/grideditor.gutters.js +134 -131
- package/dist/plugins/grideditor.gutters.min.js +1 -2
- package/dist/plugins/grideditor.gutters.min.js.map +7 -1
- package/dist/plugins/grideditor.order.esm.js +189 -0
- package/dist/plugins/grideditor.order.js +170 -182
- package/dist/plugins/grideditor.order.min.js +1 -2
- package/dist/plugins/grideditor.order.min.js.map +7 -1
- package/dist/plugins/grideditor.popup.esm.js +187 -0
- package/dist/plugins/grideditor.popup.js +183 -134
- package/dist/plugins/grideditor.popup.min.js +1 -2
- package/dist/plugins/grideditor.popup.min.js.map +7 -1
- package/dist/plugins/grideditor.sections.esm.js +271 -0
- package/dist/plugins/grideditor.sections.js +250 -173
- package/dist/plugins/grideditor.sections.min.js +1 -2
- package/dist/plugins/grideditor.sections.min.js.map +7 -1
- package/dist/plugins/grideditor.spacing.esm.js +318 -0
- package/dist/plugins/grideditor.spacing.js +296 -272
- package/dist/plugins/grideditor.spacing.min.js +1 -2
- package/dist/plugins/grideditor.spacing.min.js.map +7 -1
- package/dist/plugins/grideditor.summernote.esm.js +509 -0
- package/dist/plugins/grideditor.summernote.js +491 -471
- package/dist/plugins/grideditor.summernote.min.js +1 -2
- package/dist/plugins/grideditor.summernote.min.js.map +7 -1
- package/dist/plugins/grideditor.tabs.esm.js +237 -0
- package/dist/plugins/grideditor.tabs.js +233 -139
- package/dist/plugins/grideditor.tabs.min.js +1 -2
- package/dist/plugins/grideditor.tabs.min.js.map +7 -1
- package/dist/plugins/grideditor.textalign.esm.js +40 -0
- package/dist/plugins/grideditor.textalign.js +43 -56
- package/dist/plugins/grideditor.textalign.min.js +1 -2
- package/dist/plugins/grideditor.textalign.min.js.map +7 -1
- package/dist/plugins/grideditor.tinymce.esm.js +519 -0
- package/dist/plugins/grideditor.tinymce.js +500 -534
- package/dist/plugins/grideditor.tinymce.min.js +1 -2
- package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
- package/dist/plugins/grideditor.visibility.esm.js +158 -0
- package/dist/plugins/grideditor.visibility.js +140 -149
- package/dist/plugins/grideditor.visibility.min.js +1 -2
- package/dist/plugins/grideditor.visibility.min.js.map +7 -1
- package/docs/events.md +47 -21
- package/docs/locale-keys.md +7 -4
- package/docs/plugins.md +49 -27
- package/example/adapter.html +112 -0
- package/example/attributes.html +85 -61
- package/example/autocols.html +9 -9
- package/example/autosave.html +13 -14
- package/example/basic.html +4 -5
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +11 -10
- package/example/codemirror.html +9 -7
- package/example/containers.html +7 -8
- package/example/custom_editor.html +53 -34
- package/example/elements.html +10 -11
- package/example/index.html +16 -2
- package/example/locale.html +6 -7
- package/example/plugins.html +44 -29
- package/example/summernote.html +6 -5
- package/example/utilities.html +17 -13
- package/example/wrap_content.html +9 -9
- package/package.json +43 -12
- package/src/js/dom.js +401 -0
- package/src/js/grideditor.classic.js +16 -0
- package/src/js/grideditor.jquery.js +325 -0
- package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
- package/src/js/locales/grideditor.es.js +163 -158
- package/src/js/plugins/grideditor.accordion.js +97 -77
- package/src/js/plugins/grideditor.alignment.js +5 -7
- package/src/js/plugins/grideditor.card.js +23 -23
- package/src/js/plugins/grideditor.ckeditor.js +107 -106
- package/src/js/plugins/grideditor.clipboard.js +49 -37
- package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
- package/src/js/plugins/grideditor.codemirror.js +9 -10
- package/src/js/plugins/grideditor.elements.js +57 -33
- package/src/js/plugins/grideditor.float.js +4 -6
- package/src/js/plugins/grideditor.gutters.js +20 -15
- package/src/js/plugins/grideditor.order.js +28 -25
- package/src/js/plugins/grideditor.popup.js +63 -51
- package/src/js/plugins/grideditor.sections.js +39 -32
- package/src/js/plugins/grideditor.spacing.js +42 -45
- package/src/js/plugins/grideditor.summernote.js +112 -76
- package/src/js/plugins/grideditor.tabs.js +65 -57
- package/src/js/plugins/grideditor.textalign.js +4 -6
- package/src/js/plugins/grideditor.tinymce.js +147 -139
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +81 -106
- package/types/grideditor.d.ts +335 -0
- package/dist/jquery.grideditor.bundle.min.js +0 -10
- package/dist/jquery.grideditor.js +0 -4927
- package/dist/jquery.grideditor.min.js +0 -2
- package/dist/jquery.grideditor.min.js.map +0 -1
|
@@ -1,60 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
19
|
-
'utility.text_align': 'Text alignment',
|
|
20
|
-
'utility.text_start': 'Start',
|
|
21
|
-
'utility.text_center': 'Center',
|
|
22
|
-
'utility.text_end': 'End',
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
/** Start and end are left and right: Bootstrap's css is left to right. */
|
|
26
|
-
var CSS = { start: 'left', center: 'center', end: 'right' };
|
|
27
|
-
|
|
28
|
-
$.fn.gridEditor.utilities.textalign = function(ge) {
|
|
29
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// src/js/register.js
|
|
3
|
+
var GridEditor = window.GridEditor;
|
|
4
|
+
if (!GridEditor || typeof GridEditor.get !== "function") {
|
|
5
|
+
throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/js/plugins/grideditor.textalign.js
|
|
9
|
+
Object.assign(GridEditor.locales.en, {
|
|
10
|
+
"utility.text_align": "Text alignment",
|
|
11
|
+
"utility.text_start": "Start",
|
|
12
|
+
"utility.text_center": "Center",
|
|
13
|
+
"utility.text_end": "End"
|
|
14
|
+
});
|
|
15
|
+
var CSS = { start: "left", center: "center", end: "right" };
|
|
16
|
+
GridEditor.utilities.textalign = function(ge) {
|
|
30
17
|
function label(value) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
if (value === "start") {
|
|
19
|
+
return ge.t("utility.text_start");
|
|
20
|
+
}
|
|
21
|
+
if (value === "center") {
|
|
22
|
+
return ge.t("utility.text_center");
|
|
23
|
+
}
|
|
24
|
+
return ge.t("utility.text_end");
|
|
35
25
|
}
|
|
36
|
-
|
|
37
26
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}],
|
|
27
|
+
families: [{
|
|
28
|
+
name: "text-align",
|
|
29
|
+
prefix: "text",
|
|
30
|
+
values: ["start", "center", "end"],
|
|
31
|
+
appliesTo: ["row", "column", "text", "element", "container"],
|
|
32
|
+
labelKey: "utility.text_align",
|
|
33
|
+
label,
|
|
34
|
+
/**
|
|
35
|
+
* With no class applying here, the node aligns as its parent
|
|
36
|
+
* does - or as the host's css says - which only the browser can
|
|
37
|
+
* tell, so it is asked with the classes out of the way. Parents
|
|
38
|
+
* are previewed before their children, so the parent's answer is
|
|
39
|
+
* already the view's.
|
|
40
|
+
*/
|
|
41
|
+
preview: function(value, node) {
|
|
42
|
+
return { "text-align": value === null ? ge.bareStyle(node, "text-align", "text-align") : CSS[value] };
|
|
43
|
+
}
|
|
44
|
+
}]
|
|
57
45
|
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
})(jQuery);
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.textalign.min.js.map
|
|
1
|
+
(()=>{var e=window.GridEditor;if(!e||typeof e.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");Object.assign(e.locales.en,{"utility.text_align":"Text alignment","utility.text_start":"Start","utility.text_center":"Center","utility.text_end":"End"});var l={start:"left",center:"center",end:"right"};e.utilities.textalign=function(i){function r(t){return t==="start"?i.t("utility.text_start"):t==="center"?i.t("utility.text_center"):i.t("utility.text_end")}return{families:[{name:"text-align",prefix:"text",values:["start","center","end"],appliesTo:["row","column","text","element","container"],labelKey:"utility.text_align",label:r,preview:function(t,n){return{"text-align":t===null?i.bareStyle(n,"text-align","text-align"):l[t]}}}]}};})();
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/js/register.js", "../../src/js/plugins/grideditor.textalign.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * What a plugin's or a locale's classic script imports in place of the\n * editor: the GridEditor the page already loaded.\n *\n * The build points `import { GridEditor } from '../grideditor.js'` here for\n * the classic scripts, so each registers on the editor the page has rather\n * than bringing its own. Loaded before the editor there is nothing to\n * register on, and saying so is better than a TypeError three calls later.\n */\nvar GridEditor = window.GridEditor;\n\nif (!GridEditor || typeof GridEditor.get !== 'function') {\n throw new Error('grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, ' +\n 'its locales and grideditor.jquery.js');\n}\n\nexport { GridEditor };\nexport default GridEditor;\n", "/**\n * Text alignment for grid-editor.\n *\n * A utility plugin: load this file after the editor and a row, column,\n * element or container can align its text per breakpoint, with Bootstrap's\n * text-{breakpoint}-start, -center and -end classes. What it can ask the\n * editor for is the handle its factory is called with, described in\n * docs/plugins.md.\n *\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.textalign.min.js\"></script>\n *\n * The class aligns everything inside the node that does not align itself: a\n * paragraph the rich text editor gave its own text-align keeps it.\n */\nimport { GridEditor } from '../grideditor.js';\n\nObject.assign(GridEditor.locales.en, {\n 'utility.text_align': 'Text alignment',\n 'utility.text_start': 'Start',\n 'utility.text_center': 'Center',\n 'utility.text_end': 'End',\n});\n\n/** Start and end are left and right: Bootstrap's css is left to right. */\nvar CSS = { start: 'left', center: 'center', end: 'right' };\n\nGridEditor.utilities.textalign = function(ge) {\n\n function label(value) {\n if (value === 'start') { return ge.t('utility.text_start'); }\n if (value === 'center') { return ge.t('utility.text_center'); }\n\n return ge.t('utility.text_end');\n }\n\n return {\n families: [{\n name: 'text-align',\n prefix: 'text',\n values: ['start', 'center', 'end'],\n appliesTo: ['row', 'column', 'text', 'element', 'container'],\n labelKey: 'utility.text_align',\n label: label,\n\n /**\n * With no class applying here, the node aligns as its parent\n * does - or as the host's css says - which only the browser can\n * tell, so it is asked with the classes out of the way. Parents\n * are previewed before their children, so the parent's answer is\n * already the view's.\n */\n preview: function(value, node) {\n return { 'text-align': value === null ? ge.bareStyle(node, 'text-align', 'text-align') : CSS[value] };\n },\n }],\n };\n};\n"],
|
|
5
|
+
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECI9C,OAAO,OAAOC,EAAW,QAAQ,GAAI,CACjC,qBAAsB,iBACtB,qBAAsB,QACtB,sBAAuB,SACvB,mBAAoB,KACxB,CAAC,EAGD,IAAIC,EAAM,CAAE,MAAO,OAAQ,OAAQ,SAAU,IAAK,OAAQ,EAE1DD,EAAW,UAAU,UAAY,SAASE,EAAI,CAE1C,SAASC,EAAMC,EAAO,CAClB,OAAIA,IAAU,QAAkBF,EAAG,EAAE,oBAAoB,EACrDE,IAAU,SAAmBF,EAAG,EAAE,qBAAqB,EAEpDA,EAAG,EAAE,kBAAkB,CAClC,CAEA,MAAO,CACH,SAAU,CAAC,CACP,KAAM,aACN,OAAQ,OACR,OAAQ,CAAC,QAAS,SAAU,KAAK,EACjC,UAAW,CAAC,MAAO,SAAU,OAAQ,UAAW,WAAW,EAC3D,SAAU,qBACV,MAAOC,EASP,QAAS,SAASC,EAAOC,EAAM,CAC3B,MAAO,CAAE,aAAcD,IAAU,KAAOF,EAAG,UAAUG,EAAM,aAAc,YAAY,EAAIJ,EAAIG,CAAK,CAAE,CACxG,CACJ,CAAC,CACL,CACJ",
|
|
6
|
+
"names": ["GridEditor", "GridEditor", "CSS", "ge", "label", "value", "node"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
// src/js/plugins/grideditor.tinymce.js
|
|
2
|
+
import { GridEditor as GridEditor2 } from "../grideditor.esm.js";
|
|
3
|
+
|
|
4
|
+
// src/js/dom.js
|
|
5
|
+
function all(root, selector) {
|
|
6
|
+
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
7
|
+
}
|
|
8
|
+
function children(node, selector) {
|
|
9
|
+
if (!node) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return Array.prototype.filter.call(node.children, function(each) {
|
|
13
|
+
return !selector || each.matches(selector);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function child(node, selector) {
|
|
17
|
+
return children(node, selector)[0] || null;
|
|
18
|
+
}
|
|
19
|
+
function closest(node, selector, stopAt) {
|
|
20
|
+
var found = node && node.nodeType === 1 ? node.closest(selector) : null;
|
|
21
|
+
if (found && stopAt && found !== stopAt && !stopAt.contains(found)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
function element(tag, attributes, text) {
|
|
27
|
+
var node = document.createElement(tag);
|
|
28
|
+
Object.keys(attributes || {}).forEach(function(name) {
|
|
29
|
+
var value = attributes[name];
|
|
30
|
+
if (value !== null && value !== void 0 && value !== false) {
|
|
31
|
+
node.setAttribute(name, value);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (text !== void 0 && text !== null) {
|
|
35
|
+
node.textContent = text;
|
|
36
|
+
}
|
|
37
|
+
return node;
|
|
38
|
+
}
|
|
39
|
+
function setHtml(node, html) {
|
|
40
|
+
node.innerHTML = html === void 0 || html === null ? "" : String(html);
|
|
41
|
+
return node;
|
|
42
|
+
}
|
|
43
|
+
function addClass(node, names) {
|
|
44
|
+
split(names).forEach(function(name) {
|
|
45
|
+
node.classList.add(name);
|
|
46
|
+
});
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
49
|
+
function removeClass(node, names) {
|
|
50
|
+
split(names).forEach(function(name) {
|
|
51
|
+
node.classList.remove(name);
|
|
52
|
+
});
|
|
53
|
+
return node;
|
|
54
|
+
}
|
|
55
|
+
function hasClass(node, name) {
|
|
56
|
+
return !!node && node.nodeType === 1 && node.classList.contains(name);
|
|
57
|
+
}
|
|
58
|
+
function split(names) {
|
|
59
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
60
|
+
}
|
|
61
|
+
function hide(node) {
|
|
62
|
+
node.style.display = "none";
|
|
63
|
+
return node;
|
|
64
|
+
}
|
|
65
|
+
function visible(node) {
|
|
66
|
+
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
67
|
+
}
|
|
68
|
+
function delegate(root, types, selector, handler, options) {
|
|
69
|
+
var listener = function(event) {
|
|
70
|
+
var match = closest(event.target, selector, root);
|
|
71
|
+
if (match && root.contains(match)) {
|
|
72
|
+
return handler.call(match, event);
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
};
|
|
76
|
+
split(types).forEach(function(type) {
|
|
77
|
+
root.addEventListener(type, listener, options);
|
|
78
|
+
});
|
|
79
|
+
return listener;
|
|
80
|
+
}
|
|
81
|
+
var DEFAULT_DURATION = 400;
|
|
82
|
+
function animateAway(node, frames, duration, done) {
|
|
83
|
+
duration = duration === void 0 ? DEFAULT_DURATION : duration;
|
|
84
|
+
var finish = function() {
|
|
85
|
+
hide(node);
|
|
86
|
+
if (done) {
|
|
87
|
+
done();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
if (!visible(node) || !node.animate || duration <= 0) {
|
|
91
|
+
window.setTimeout(finish, 0);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
var animation = node.animate(frames(getComputedStyle(node)), {
|
|
95
|
+
duration,
|
|
96
|
+
easing: "ease-in-out"
|
|
97
|
+
});
|
|
98
|
+
var called = false;
|
|
99
|
+
var once = function() {
|
|
100
|
+
if (called) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
called = true;
|
|
104
|
+
finish();
|
|
105
|
+
};
|
|
106
|
+
animation.onfinish = once;
|
|
107
|
+
animation.oncancel = once;
|
|
108
|
+
}
|
|
109
|
+
function slideUp(node, duration, done) {
|
|
110
|
+
if (typeof duration === "function") {
|
|
111
|
+
done = duration;
|
|
112
|
+
duration = void 0;
|
|
113
|
+
}
|
|
114
|
+
node.style.overflow = "hidden";
|
|
115
|
+
animateAway(node, function(style) {
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
height: style.height,
|
|
119
|
+
paddingTop: style.paddingTop,
|
|
120
|
+
paddingBottom: style.paddingBottom,
|
|
121
|
+
marginTop: style.marginTop,
|
|
122
|
+
marginBottom: style.marginBottom
|
|
123
|
+
},
|
|
124
|
+
{ height: "0px", paddingTop: "0px", paddingBottom: "0px", marginTop: "0px", marginBottom: "0px" }
|
|
125
|
+
];
|
|
126
|
+
}, duration, function() {
|
|
127
|
+
node.style.removeProperty("overflow");
|
|
128
|
+
if (done) {
|
|
129
|
+
done();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/js/text/grideditor.text.js
|
|
135
|
+
import { GridEditor } from "../grideditor.esm.js";
|
|
136
|
+
if (!GridEditor.features.text) {
|
|
137
|
+
let attributesOf = function(element2) {
|
|
138
|
+
var found = {};
|
|
139
|
+
Array.prototype.slice.call(element2.attributes).forEach(function(attribute) {
|
|
140
|
+
found[attribute.name] = attribute.value;
|
|
141
|
+
});
|
|
142
|
+
return found;
|
|
143
|
+
}, classesIn = function(value) {
|
|
144
|
+
return (value || "").split(/\s+/).filter(function(name) {
|
|
145
|
+
return name !== "" && !EDITOR_CLASS.test(name);
|
|
146
|
+
});
|
|
147
|
+
}, restoreAttributes = function(block, before, ready, open) {
|
|
148
|
+
var result = Object.assign({}, before);
|
|
149
|
+
Object.keys(Object.assign({}, ready, open)).forEach(function(name) {
|
|
150
|
+
if (name === "class" || EDITOR_ATTRIBUTE.test(name) || ready[name] === open[name]) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (open[name] === void 0) {
|
|
154
|
+
delete result[name];
|
|
155
|
+
} else {
|
|
156
|
+
result[name] = open[name];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
var readyClasses = classesIn(ready["class"]);
|
|
160
|
+
var openClasses = classesIn(open["class"]);
|
|
161
|
+
var classes = classesIn(before["class"]).filter(function(name) {
|
|
162
|
+
return openClasses.indexOf(name) !== -1 || readyClasses.indexOf(name) === -1;
|
|
163
|
+
});
|
|
164
|
+
openClasses.forEach(function(name) {
|
|
165
|
+
if (readyClasses.indexOf(name) === -1 && classes.indexOf(name) === -1) {
|
|
166
|
+
classes.push(name);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
if (classes.length) {
|
|
170
|
+
result["class"] = classes.join(" ");
|
|
171
|
+
} else {
|
|
172
|
+
delete result["class"];
|
|
173
|
+
}
|
|
174
|
+
Object.keys(attributesOf(block)).forEach(function(name) {
|
|
175
|
+
block.removeAttribute(name);
|
|
176
|
+
});
|
|
177
|
+
Object.keys(result).forEach(function(name) {
|
|
178
|
+
block.setAttribute(name, result[name]);
|
|
179
|
+
});
|
|
180
|
+
}, textFeature = function(ge) {
|
|
181
|
+
var settings = ge.settings;
|
|
182
|
+
var TEXTS = {};
|
|
183
|
+
var warned = {};
|
|
184
|
+
Object.keys(GridEditor.texts).forEach(function(type) {
|
|
185
|
+
TEXTS[type] = GridEditor.texts[type](ge);
|
|
186
|
+
});
|
|
187
|
+
if (!Array.isArray(settings.content_types)) {
|
|
188
|
+
settings.content_types = Object.keys(TEXTS);
|
|
189
|
+
}
|
|
190
|
+
if (!Array.isArray(settings.text_tools)) {
|
|
191
|
+
settings.text_tools = [];
|
|
192
|
+
}
|
|
193
|
+
if (!Array.isArray(settings.text_classes)) {
|
|
194
|
+
settings.text_classes = [];
|
|
195
|
+
}
|
|
196
|
+
function offeredTexts() {
|
|
197
|
+
return settings.content_types.filter(function(type) {
|
|
198
|
+
return !!TEXTS[type];
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function textLabel(type) {
|
|
202
|
+
var text = TEXTS[type];
|
|
203
|
+
return text && text.labelKey ? ge.t(text.labelKey) : type;
|
|
204
|
+
}
|
|
205
|
+
function makeText(type, content) {
|
|
206
|
+
var text = TEXTS[type];
|
|
207
|
+
var block = element("div", {
|
|
208
|
+
"class": "ge-content ge-content-type-" + type,
|
|
209
|
+
"data-ge-content-type": type
|
|
210
|
+
});
|
|
211
|
+
if (content && content.nodeType) {
|
|
212
|
+
block.appendChild(content);
|
|
213
|
+
} else {
|
|
214
|
+
setHtml(block, content !== void 0 ? content : text && text.initialContent || "");
|
|
215
|
+
}
|
|
216
|
+
return block;
|
|
217
|
+
}
|
|
218
|
+
function apiCreateText(type, options) {
|
|
219
|
+
if (type && typeof type === "object") {
|
|
220
|
+
options = type;
|
|
221
|
+
type = void 0;
|
|
222
|
+
}
|
|
223
|
+
options = options || {};
|
|
224
|
+
type = type || offeredTexts()[0];
|
|
225
|
+
if (!type || !TEXTS[type]) {
|
|
226
|
+
if (!warned["createText:" + type]) {
|
|
227
|
+
warned["createText:" + type] = true;
|
|
228
|
+
ge.warn('createText: no text editor "' + type + '" is loaded; load its plugin and name it in content_types');
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
return ge.place(makeText(type, options.content), "text", options);
|
|
233
|
+
}
|
|
234
|
+
function isOurs(block) {
|
|
235
|
+
return !!TEXTS[block.getAttribute("data-ge-content-type")];
|
|
236
|
+
}
|
|
237
|
+
function startText(block) {
|
|
238
|
+
if (hasClass(block, "ge-rte-active")) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (!visible(block)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
var text = TEXTS[block.getAttribute("data-ge-content-type")];
|
|
245
|
+
if (!text) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (text.available && !text.available()) {
|
|
249
|
+
if (text.missingKey) {
|
|
250
|
+
console.error(ge.t(text.missingKey));
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
readBefore.set(block, attributesOf(block));
|
|
255
|
+
readReady.delete(block);
|
|
256
|
+
addClass(block, "ge-rte-active");
|
|
257
|
+
text.start([block]);
|
|
258
|
+
}
|
|
259
|
+
function onClick() {
|
|
260
|
+
startText(this);
|
|
261
|
+
}
|
|
262
|
+
function closeText(block) {
|
|
263
|
+
var text = TEXTS[block.getAttribute("data-ge-content-type")];
|
|
264
|
+
var before = readBefore.get(block);
|
|
265
|
+
var open = before ? attributesOf(block) : null;
|
|
266
|
+
if (text) {
|
|
267
|
+
text.stop([block]);
|
|
268
|
+
}
|
|
269
|
+
removeClass(block, "ge-rte-active");
|
|
270
|
+
if (before) {
|
|
271
|
+
restoreAttributes(block, before, readReady.get(block) || before, open);
|
|
272
|
+
readBefore.delete(block);
|
|
273
|
+
readReady.delete(block);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function createTextControls(textBlock) {
|
|
277
|
+
var block = child(textBlock, ".ge-content");
|
|
278
|
+
var type = block.getAttribute("data-ge-content-type");
|
|
279
|
+
var drawer = element("div", { "class": "ge-tools-drawer ge-text-drawer" });
|
|
280
|
+
textBlock.insertBefore(drawer, textBlock.firstChild);
|
|
281
|
+
ge.createMoveTool(drawer);
|
|
282
|
+
var details = ge.addSettingsTool(drawer, block, settings.text_classes);
|
|
283
|
+
var general = child(details, ".ge-details-general");
|
|
284
|
+
var editor = element("div", { "class": "ge-field ge-text-editor" });
|
|
285
|
+
editor.appendChild(element("span", { "class": "ge-field-label" }, ge.t("panel.editor")));
|
|
286
|
+
editor.appendChild(element("span", { "class": "ge-field-value" }, textLabel(type)));
|
|
287
|
+
general.insertBefore(editor, general.firstChild);
|
|
288
|
+
settings.text_tools.forEach(function(hostTool) {
|
|
289
|
+
ge.createTool(
|
|
290
|
+
drawer,
|
|
291
|
+
hostTool.title || "",
|
|
292
|
+
hostTool.className || "",
|
|
293
|
+
hostTool.iconClass || "bi bi-wrench",
|
|
294
|
+
hostTool.on
|
|
295
|
+
);
|
|
296
|
+
});
|
|
297
|
+
ge.createTool(drawer, ge.t("tool.delete_text"), "ge-delete-text", "bi bi-trash", function() {
|
|
298
|
+
ge.deleteNode("text", block, ge.t("confirm.delete_text"), function(removed) {
|
|
299
|
+
closeText(block);
|
|
300
|
+
slideUp(textBlock, function() {
|
|
301
|
+
textBlock.remove();
|
|
302
|
+
removed();
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function markTexts() {
|
|
308
|
+
all(ge.canvas, ".ge-text-block").forEach(function(textBlock) {
|
|
309
|
+
if (child(textBlock, ".ge-tools-drawer")) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
var block = child(textBlock, ".ge-content");
|
|
313
|
+
if (!block || !isOurs(block)) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
createTextControls(textBlock);
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
var texts = offeredTexts();
|
|
320
|
+
var clicks = null;
|
|
321
|
+
return {
|
|
322
|
+
methods: {
|
|
323
|
+
createText: apiCreateText
|
|
324
|
+
},
|
|
325
|
+
/**
|
|
326
|
+
* The types this plugin edits, for the core: every editor loaded
|
|
327
|
+
* is the owner of its texts, and the ones offered are what the
|
|
328
|
+
* host's plain content can be made.
|
|
329
|
+
*/
|
|
330
|
+
textTypes: function() {
|
|
331
|
+
var offered = offeredTexts();
|
|
332
|
+
var others = Object.keys(TEXTS).filter(function(type) {
|
|
333
|
+
return offered.indexOf(type) === -1;
|
|
334
|
+
});
|
|
335
|
+
return offered.concat(others).map(function(type) {
|
|
336
|
+
var text = TEXTS[type];
|
|
337
|
+
return {
|
|
338
|
+
type,
|
|
339
|
+
label: textLabel(type),
|
|
340
|
+
offered: offered.indexOf(type) !== -1,
|
|
341
|
+
available: text.available ? function() {
|
|
342
|
+
return text.available();
|
|
343
|
+
} : null,
|
|
344
|
+
missingKey: text.missingKey,
|
|
345
|
+
edit: function(block) {
|
|
346
|
+
var textBlock = block.parentElement;
|
|
347
|
+
if (hasClass(textBlock, "ge-text-block") && !child(textBlock, ".ge-tools-drawer")) {
|
|
348
|
+
createTextControls(textBlock);
|
|
349
|
+
}
|
|
350
|
+
startText(block);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
});
|
|
354
|
+
},
|
|
355
|
+
// A text block of each editor offered. Like a container, it goes
|
|
356
|
+
// into a row of its own when clicked, or where it is dropped
|
|
357
|
+
toolbar: texts.map(function(type) {
|
|
358
|
+
return {
|
|
359
|
+
label: function() {
|
|
360
|
+
return texts.length > 1 ? ge.t("text.add_type", { editor: textLabel(type) }) : ge.t("text.add");
|
|
361
|
+
},
|
|
362
|
+
iconClass: TEXTS[type].iconClass,
|
|
363
|
+
className: "ge-add-text-button",
|
|
364
|
+
kind: "text",
|
|
365
|
+
inColumn: true,
|
|
366
|
+
create: function() {
|
|
367
|
+
return makeText(type);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}),
|
|
371
|
+
onInit: function() {
|
|
372
|
+
markTexts();
|
|
373
|
+
if (clicks) {
|
|
374
|
+
ge.canvas.removeEventListener("click", clicks);
|
|
375
|
+
}
|
|
376
|
+
clicks = delegate(ge.canvas, "click", ".ge-content", onClick);
|
|
377
|
+
},
|
|
378
|
+
// While the drawers and the text blocks are still there, as the
|
|
379
|
+
// editors left them
|
|
380
|
+
onBeforeDeinit: function() {
|
|
381
|
+
all(ge.canvas, ".ge-content").forEach(function(block) {
|
|
382
|
+
if (isOurs(block)) {
|
|
383
|
+
closeText(block);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
},
|
|
387
|
+
onDeinit: function() {
|
|
388
|
+
if (clicks) {
|
|
389
|
+
ge.canvas.removeEventListener("click", clicks);
|
|
390
|
+
}
|
|
391
|
+
clicks = null;
|
|
392
|
+
},
|
|
393
|
+
// The first time only: an undo says ready again, and by then the
|
|
394
|
+
// host may have changed the content area itself
|
|
395
|
+
onContentReady: function(area) {
|
|
396
|
+
if (readBefore.has(area) && !readReady.has(area)) {
|
|
397
|
+
readReady.set(area, attributesOf(area));
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
Object.assign(GridEditor.locales.en, {
|
|
403
|
+
"text.add": "Text",
|
|
404
|
+
"text.add_type": "Text ({editor})",
|
|
405
|
+
"panel.editor": "Editor",
|
|
406
|
+
"panel.kind_text": "Text"
|
|
407
|
+
});
|
|
408
|
+
readBefore = /* @__PURE__ */ new WeakMap();
|
|
409
|
+
readReady = /* @__PURE__ */ new WeakMap();
|
|
410
|
+
EDITOR_CLASS = /^(mce-|cke|note-)|^(active|ge-rte-active)$/;
|
|
411
|
+
EDITOR_ATTRIBUTE = /^(data-mce-|contenteditable$|spellcheck$)/;
|
|
412
|
+
textFeature.always = true;
|
|
413
|
+
GridEditor.features.text = textFeature;
|
|
414
|
+
}
|
|
415
|
+
var readBefore;
|
|
416
|
+
var readReady;
|
|
417
|
+
var EDITOR_CLASS;
|
|
418
|
+
var EDITOR_ATTRIBUTE;
|
|
419
|
+
|
|
420
|
+
// src/js/plugins/grideditor.tinymce.js
|
|
421
|
+
Object.assign(GridEditor2.locales.en, {
|
|
422
|
+
"text.tinymce": "tinyMCE",
|
|
423
|
+
"warning.oninit_removed": "tinyMCE's oninit option was removed in 7.0 and is ignored: use init_instance_callback."
|
|
424
|
+
});
|
|
425
|
+
function cleanUp(contentArea) {
|
|
426
|
+
removeClass(contentArea, "active ge-rte-active");
|
|
427
|
+
["id", "style", "spellcheck", "contenteditable", "data-mce-style"].forEach(function(name) {
|
|
428
|
+
contentArea.removeAttribute(name);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
var INITIAL_CONTENT = "<p>Lorem ipsum dolores</p>";
|
|
432
|
+
var editors = /* @__PURE__ */ new WeakMap();
|
|
433
|
+
var pendingRemove = /* @__PURE__ */ new WeakSet();
|
|
434
|
+
var warnedOninit = false;
|
|
435
|
+
GridEditor2.texts.tinymce = function(ge) {
|
|
436
|
+
return {
|
|
437
|
+
labelKey: "text.tinymce",
|
|
438
|
+
initialContent: INITIAL_CONTENT,
|
|
439
|
+
missingKey: "error.tinymce_missing",
|
|
440
|
+
available: function() {
|
|
441
|
+
return !!window.tinymce;
|
|
442
|
+
},
|
|
443
|
+
start: function(contentAreas) {
|
|
444
|
+
var settings = ge.settings;
|
|
445
|
+
var userConfig = settings.tinymce && settings.tinymce.config ? settings.tinymce.config : {};
|
|
446
|
+
if (userConfig.oninit && !warnedOninit) {
|
|
447
|
+
warnedOninit = true;
|
|
448
|
+
ge.warn(ge.t("warning.oninit_removed"));
|
|
449
|
+
}
|
|
450
|
+
contentAreas.forEach(function(contentArea) {
|
|
451
|
+
if (hasClass(contentArea, "active")) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (contentArea.innerHTML == INITIAL_CONTENT) {
|
|
455
|
+
contentArea.innerHTML = "";
|
|
456
|
+
}
|
|
457
|
+
addClass(contentArea, "active");
|
|
458
|
+
var configuration = Object.assign({
|
|
459
|
+
// tinyMCE's own "Upgrade" badge in the menubar. Off by
|
|
460
|
+
// default because an inline editor here is a column of
|
|
461
|
+
// someone's page, not tinyMCE's own interface; a host that
|
|
462
|
+
// wants it back passes promotion: true.
|
|
463
|
+
promotion: false
|
|
464
|
+
}, userConfig, {
|
|
465
|
+
target: contentArea,
|
|
466
|
+
inline: true,
|
|
467
|
+
init_instance_callback: function(editor) {
|
|
468
|
+
if (pendingRemove.has(contentArea)) {
|
|
469
|
+
pendingRemove.delete(contentArea);
|
|
470
|
+
editor.remove();
|
|
471
|
+
cleanUp(contentArea);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
editors.set(contentArea, editor);
|
|
475
|
+
ge.textReady(contentArea);
|
|
476
|
+
editor.on("Undo Redo", function() {
|
|
477
|
+
ge.textReady(contentArea);
|
|
478
|
+
});
|
|
479
|
+
window.requestAnimationFrame(function() {
|
|
480
|
+
if (editor.removed || !editor.ui || !editor.ui.show) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
editor.ui.show();
|
|
484
|
+
});
|
|
485
|
+
editor.on("focus", function() {
|
|
486
|
+
window.requestAnimationFrame(function() {
|
|
487
|
+
if (editor.removed || !editor.ui || !editor.ui.show) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
editor.ui.show();
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
editor.focus();
|
|
494
|
+
if (userConfig.init_instance_callback) {
|
|
495
|
+
userConfig.init_instance_callback.call(this, editor);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
delete configuration.selector;
|
|
500
|
+
delete configuration.oninit;
|
|
501
|
+
window.tinymce.init(configuration);
|
|
502
|
+
});
|
|
503
|
+
},
|
|
504
|
+
stop: function(contentAreas) {
|
|
505
|
+
contentAreas.filter(function(contentArea) {
|
|
506
|
+
return hasClass(contentArea, "active");
|
|
507
|
+
}).forEach(function(contentArea) {
|
|
508
|
+
var editor = editors.get(contentArea);
|
|
509
|
+
if (editor) {
|
|
510
|
+
editors.delete(contentArea);
|
|
511
|
+
editor.remove();
|
|
512
|
+
} else {
|
|
513
|
+
pendingRemove.add(contentArea);
|
|
514
|
+
}
|
|
515
|
+
cleanUp(contentArea);
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
};
|