@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,56 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
18
|
-
(function($) {
|
|
19
|
-
|
|
20
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
21
|
-
'utility.float': 'Float',
|
|
22
|
-
'utility.float_start': 'Start',
|
|
23
|
-
'utility.float_end': 'End',
|
|
24
|
-
'utility.float_none': 'None',
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
/** Start and end are left and right: Bootstrap's css is left to right. */
|
|
28
|
-
var CSS = { start: 'left', end: 'right', none: 'none' };
|
|
29
|
-
|
|
30
|
-
$.fn.gridEditor.utilities.float = function(ge) {
|
|
31
|
-
|
|
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.float.js
|
|
9
|
+
Object.assign(GridEditor.locales.en, {
|
|
10
|
+
"utility.float": "Float",
|
|
11
|
+
"utility.float_start": "Start",
|
|
12
|
+
"utility.float_end": "End",
|
|
13
|
+
"utility.float_none": "None"
|
|
14
|
+
});
|
|
15
|
+
var CSS = { start: "left", end: "right", none: "none" };
|
|
16
|
+
GridEditor.utilities.float = function(ge) {
|
|
32
17
|
function label(value) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
if (value === "start") {
|
|
19
|
+
return ge.t("utility.float_start");
|
|
20
|
+
}
|
|
21
|
+
if (value === "end") {
|
|
22
|
+
return ge.t("utility.float_end");
|
|
23
|
+
}
|
|
24
|
+
return ge.t("utility.float_none");
|
|
37
25
|
}
|
|
38
|
-
|
|
39
26
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}],
|
|
27
|
+
families: [{
|
|
28
|
+
name: "float",
|
|
29
|
+
prefix: "float",
|
|
30
|
+
values: ["start", "end", "none"],
|
|
31
|
+
appliesTo: ["element"],
|
|
32
|
+
labelKey: "utility.float",
|
|
33
|
+
label,
|
|
34
|
+
/** With no class applying here, whatever the host's css floats it as. */
|
|
35
|
+
preview: function(value, node) {
|
|
36
|
+
return { float: value === null ? ge.bareStyle(node, "float", "float") : CSS[value] };
|
|
37
|
+
}
|
|
38
|
+
}]
|
|
53
39
|
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
})(jQuery);
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.float.min.js.map
|
|
1
|
+
(()=>{var i=window.GridEditor;if(!i||typeof i.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(i.locales.en,{"utility.float":"Float","utility.float_start":"Start","utility.float_end":"End","utility.float_none":"None"});var l={start:"left",end:"right",none:"none"};i.utilities.float=function(e){function r(t){return t==="start"?e.t("utility.float_start"):t==="end"?e.t("utility.float_end"):e.t("utility.float_none")}return{families:[{name:"float",prefix:"float",values:["start","end","none"],appliesTo:["element"],labelKey:"utility.float",label:r,preview:function(t,o){return{float:t===null?e.bareStyle(o,"float","float"):l[t]}}}]}};})();
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/js/register.js", "../../src/js/plugins/grideditor.float.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 * Floating elements for grid-editor.\n *\n * A utility plugin: load this file after the editor and after the elements\n * plugin, and an element can float to the start or the end of its content\n * area per breakpoint, with the text around it, using Bootstrap's\n * float-{breakpoint}-start, -end and -none 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.elements.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.float.min.js\"></script>\n *\n * Elements only. A floated row or column stops being part of the grid, and a\n * container sits beside the content areas rather than in their text.\n */\nimport { GridEditor } from '../grideditor.js';\n\nObject.assign(GridEditor.locales.en, {\n 'utility.float': 'Float',\n 'utility.float_start': 'Start',\n 'utility.float_end': 'End',\n 'utility.float_none': 'None',\n});\n\n/** Start and end are left and right: Bootstrap's css is left to right. */\nvar CSS = { start: 'left', end: 'right', none: 'none' };\n\nGridEditor.utilities.float = function(ge) {\n\n function label(value) {\n if (value === 'start') { return ge.t('utility.float_start'); }\n if (value === 'end') { return ge.t('utility.float_end'); }\n\n return ge.t('utility.float_none');\n }\n\n return {\n families: [{\n name: 'float',\n prefix: 'float',\n values: ['start', 'end', 'none'],\n appliesTo: ['element'],\n labelKey: 'utility.float',\n label: label,\n\n /** With no class applying here, whatever the host's css floats it as. */\n preview: function(value, node) {\n return { float: value === null ? ge.bareStyle(node, 'float', 'float') : 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,ECM9C,OAAO,OAAOC,EAAW,QAAQ,GAAI,CACjC,gBAAiB,QACjB,sBAAuB,QACvB,oBAAqB,MACrB,qBAAsB,MAC1B,CAAC,EAGD,IAAIC,EAAM,CAAE,MAAO,OAAQ,IAAK,QAAS,KAAM,MAAO,EAEtDD,EAAW,UAAU,MAAQ,SAASE,EAAI,CAEtC,SAASC,EAAMC,EAAO,CAClB,OAAIA,IAAU,QAAkBF,EAAG,EAAE,qBAAqB,EACtDE,IAAU,MAAgBF,EAAG,EAAE,mBAAmB,EAE/CA,EAAG,EAAE,oBAAoB,CACpC,CAEA,MAAO,CACH,SAAU,CAAC,CACP,KAAM,QACN,OAAQ,QACR,OAAQ,CAAC,QAAS,MAAO,MAAM,EAC/B,UAAW,CAAC,SAAS,EACrB,SAAU,gBACV,MAAOC,EAGP,QAAS,SAASC,EAAOC,EAAM,CAC3B,MAAO,CAAE,MAAOD,IAAU,KAAOF,EAAG,UAAUG,EAAM,QAAS,OAAO,EAAIJ,EAAIG,CAAK,CAAE,CACvF,CACJ,CAAC,CACL,CACJ",
|
|
6
|
+
"names": ["GridEditor", "GridEditor", "CSS", "ge", "label", "value", "node"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// src/js/plugins/grideditor.gutters.js
|
|
2
|
+
import { GridEditor } 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 selfAndAll(root, selector) {
|
|
9
|
+
if (!root) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
var found = all(root, selector);
|
|
13
|
+
if (root.nodeType === 1 && root.matches(selector)) {
|
|
14
|
+
found.unshift(root);
|
|
15
|
+
}
|
|
16
|
+
return found;
|
|
17
|
+
}
|
|
18
|
+
function removeClass(node, names) {
|
|
19
|
+
split(names).forEach(function(name) {
|
|
20
|
+
node.classList.remove(name);
|
|
21
|
+
});
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
function toggleClass(node, names, state) {
|
|
25
|
+
split(names).forEach(function(name) {
|
|
26
|
+
if (state === void 0) {
|
|
27
|
+
node.classList.toggle(name);
|
|
28
|
+
} else {
|
|
29
|
+
node.classList.toggle(name, !!state);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return node;
|
|
33
|
+
}
|
|
34
|
+
function split(names) {
|
|
35
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/js/plugins/grideditor.gutters.js
|
|
39
|
+
Object.assign(GridEditor.locales.en, {
|
|
40
|
+
"utility.gutters": "Gutters",
|
|
41
|
+
"utility.gutters_x": "Horizontal gutters",
|
|
42
|
+
"utility.gutters_y": "Vertical gutters"
|
|
43
|
+
});
|
|
44
|
+
var VALUES = ["0", "1", "2", "3", "4", "5"];
|
|
45
|
+
var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
|
|
46
|
+
var DEFAULT_X = "1.5rem";
|
|
47
|
+
var DEFAULT_Y = "0";
|
|
48
|
+
var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
|
|
49
|
+
var CLASS_PATTERN = /(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;
|
|
50
|
+
GridEditor.utilities.gutters = function(ge) {
|
|
51
|
+
var options = Object.assign({ scale: SCALE }, ge.settings.utilities.gutters);
|
|
52
|
+
var listening = null;
|
|
53
|
+
function source(row, prefix, tier) {
|
|
54
|
+
var classes = (row.getAttribute("class") || "").split(/\s+/);
|
|
55
|
+
for (var i = tier; i >= 0; i--) {
|
|
56
|
+
for (var value = VALUES.length - 1; value >= 0; value--) {
|
|
57
|
+
var name = prefix + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + value;
|
|
58
|
+
if (classes.indexOf(name) !== -1) {
|
|
59
|
+
return { tier: i, value };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function axis(row, prefix, fallback) {
|
|
66
|
+
var tier = ge.breakpoints.indexOf(ge.view());
|
|
67
|
+
var winner = [source(row, "g", tier), source(row, prefix, tier)].filter(Boolean).sort(function(a, b) {
|
|
68
|
+
return b.tier - a.tier || b.value - a.value;
|
|
69
|
+
})[0];
|
|
70
|
+
return winner ? options.scale[winner.value] : fallback;
|
|
71
|
+
}
|
|
72
|
+
function preview(axes) {
|
|
73
|
+
return function(value, row) {
|
|
74
|
+
var styles = {};
|
|
75
|
+
if (axes.indexOf("x") !== -1) {
|
|
76
|
+
styles["--bs-gutter-x"] = axis(row, "gx", DEFAULT_X);
|
|
77
|
+
}
|
|
78
|
+
if (axes.indexOf("y") !== -1) {
|
|
79
|
+
styles["--bs-gutter-y"] = axis(row, "gy", DEFAULT_Y);
|
|
80
|
+
}
|
|
81
|
+
return styles;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function afterUtility(e) {
|
|
85
|
+
var payload = e.detail;
|
|
86
|
+
if (payload.family !== "g") {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
["gx", "gy"].forEach(function(family) {
|
|
90
|
+
ge.setUtility(payload.node, family, null, { view: payload.breakpoint, source: payload.source });
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function mark(scope) {
|
|
94
|
+
selfAndAll(scope, ".row").forEach(function(row) {
|
|
95
|
+
toggleClass(row, "ge-gutters", CLASS_PATTERN.test(row.getAttribute("class") || ""));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
families: [
|
|
100
|
+
{
|
|
101
|
+
name: "g",
|
|
102
|
+
prefix: "g",
|
|
103
|
+
values: VALUES,
|
|
104
|
+
appliesTo: ["row"],
|
|
105
|
+
labelKey: "utility.gutters",
|
|
106
|
+
preview: preview(["x", "y"])
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "gx",
|
|
110
|
+
prefix: "gx",
|
|
111
|
+
values: VALUES,
|
|
112
|
+
appliesTo: ["row"],
|
|
113
|
+
labelKey: "utility.gutters_x",
|
|
114
|
+
preview: preview(["x"])
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "gy",
|
|
118
|
+
prefix: "gy",
|
|
119
|
+
values: VALUES,
|
|
120
|
+
appliesTo: ["row"],
|
|
121
|
+
labelKey: "utility.gutters_y",
|
|
122
|
+
preview: preview(["y"])
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
onInit: function() {
|
|
126
|
+
if (listening) {
|
|
127
|
+
ge.canvas.removeEventListener("grideditor:after-utility", listening);
|
|
128
|
+
}
|
|
129
|
+
listening = afterUtility;
|
|
130
|
+
ge.canvas.addEventListener("grideditor:after-utility", listening);
|
|
131
|
+
},
|
|
132
|
+
onRefresh: mark,
|
|
133
|
+
onDeinit: function() {
|
|
134
|
+
if (listening) {
|
|
135
|
+
ge.canvas.removeEventListener("grideditor:after-utility", listening);
|
|
136
|
+
}
|
|
137
|
+
listening = null;
|
|
138
|
+
all(ge.canvas, ".ge-gutters").forEach(function(row) {
|
|
139
|
+
removeClass(row, "ge-gutters");
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -1,145 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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/dom.js
|
|
9
|
+
function all(root, selector) {
|
|
10
|
+
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
11
|
+
}
|
|
12
|
+
function selfAndAll(root, selector) {
|
|
13
|
+
if (!root) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
var found = all(root, selector);
|
|
17
|
+
if (root.nodeType === 1 && root.matches(selector)) {
|
|
18
|
+
found.unshift(root);
|
|
19
|
+
}
|
|
20
|
+
return found;
|
|
21
|
+
}
|
|
22
|
+
function removeClass(node, names) {
|
|
23
|
+
split(names).forEach(function(name) {
|
|
24
|
+
node.classList.remove(name);
|
|
25
|
+
});
|
|
26
|
+
return node;
|
|
27
|
+
}
|
|
28
|
+
function toggleClass(node, names, state) {
|
|
29
|
+
split(names).forEach(function(name) {
|
|
30
|
+
if (state === void 0) {
|
|
31
|
+
node.classList.toggle(name);
|
|
32
|
+
} else {
|
|
33
|
+
node.classList.toggle(name, !!state);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
function split(names) {
|
|
39
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/js/plugins/grideditor.gutters.js
|
|
43
|
+
Object.assign(GridEditor.locales.en, {
|
|
44
|
+
"utility.gutters": "Gutters",
|
|
45
|
+
"utility.gutters_x": "Horizontal gutters",
|
|
46
|
+
"utility.gutters_y": "Vertical gutters"
|
|
47
|
+
});
|
|
48
|
+
var VALUES = ["0", "1", "2", "3", "4", "5"];
|
|
49
|
+
var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
|
|
50
|
+
var DEFAULT_X = "1.5rem";
|
|
51
|
+
var DEFAULT_Y = "0";
|
|
52
|
+
var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
|
|
53
|
+
var CLASS_PATTERN = /(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;
|
|
54
|
+
GridEditor.utilities.gutters = function(ge) {
|
|
55
|
+
var options = Object.assign({ scale: SCALE }, ge.settings.utilities.gutters);
|
|
56
|
+
var listening = null;
|
|
44
57
|
function source(row, prefix, tier) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for (var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
var classes = (row.getAttribute("class") || "").split(/\s+/);
|
|
59
|
+
for (var i = tier; i >= 0; i--) {
|
|
60
|
+
for (var value = VALUES.length - 1; value >= 0; value--) {
|
|
61
|
+
var name = prefix + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + value;
|
|
62
|
+
if (classes.indexOf(name) !== -1) {
|
|
63
|
+
return { tier: i, value };
|
|
64
|
+
}
|
|
52
65
|
}
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
55
68
|
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* One axis the way Bootstrap's css settles it. g and gx (or gy) set the
|
|
59
|
-
* same variable, every breakpoint's rules come after the smaller ones',
|
|
60
|
-
* and within a breakpoint the bigger values come later. So the class
|
|
61
|
-
* that wins is the one from the wider breakpoint, then the bigger one -
|
|
62
|
-
* not the more specific family, whatever that would suggest.
|
|
63
|
-
*/
|
|
64
69
|
function axis(row, prefix, fallback) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return winner ? options.scale[winner.value] : fallback;
|
|
70
|
+
var tier = ge.breakpoints.indexOf(ge.view());
|
|
71
|
+
var winner = [source(row, "g", tier), source(row, prefix, tier)].filter(Boolean).sort(function(a, b) {
|
|
72
|
+
return b.tier - a.tier || b.value - a.value;
|
|
73
|
+
})[0];
|
|
74
|
+
return winner ? options.scale[winner.value] : fallback;
|
|
71
75
|
}
|
|
72
|
-
|
|
73
76
|
function preview(axes) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
77
|
+
return function(value, row) {
|
|
78
|
+
var styles = {};
|
|
79
|
+
if (axes.indexOf("x") !== -1) {
|
|
80
|
+
styles["--bs-gutter-x"] = axis(row, "gx", DEFAULT_X);
|
|
81
|
+
}
|
|
82
|
+
if (axes.indexOf("y") !== -1) {
|
|
83
|
+
styles["--bs-gutter-y"] = axis(row, "gy", DEFAULT_Y);
|
|
84
|
+
}
|
|
85
|
+
return styles;
|
|
86
|
+
};
|
|
82
87
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
['gx', 'gy'].forEach(function(family) {
|
|
93
|
-
ge.setUtility(payload.node, family, null, { view: payload.breakpoint, source: payload.source });
|
|
94
|
-
});
|
|
88
|
+
function afterUtility(e) {
|
|
89
|
+
var payload = e.detail;
|
|
90
|
+
if (payload.family !== "g") {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
["gx", "gy"].forEach(function(family) {
|
|
94
|
+
ge.setUtility(payload.node, family, null, { view: payload.breakpoint, source: payload.source });
|
|
95
|
+
});
|
|
95
96
|
}
|
|
96
|
-
|
|
97
97
|
function mark(scope) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
98
|
+
selfAndAll(scope, ".row").forEach(function(row) {
|
|
99
|
+
toggleClass(row, "ge-gutters", CLASS_PATTERN.test(row.getAttribute("class") || ""));
|
|
100
|
+
});
|
|
102
101
|
}
|
|
103
|
-
|
|
104
102
|
return {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: 'gx',
|
|
116
|
-
prefix: 'gx',
|
|
117
|
-
values: VALUES,
|
|
118
|
-
appliesTo: ['row'],
|
|
119
|
-
labelKey: 'utility.gutters_x',
|
|
120
|
-
preview: preview(['x']),
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
name: 'gy',
|
|
124
|
-
prefix: 'gy',
|
|
125
|
-
values: VALUES,
|
|
126
|
-
appliesTo: ['row'],
|
|
127
|
-
labelKey: 'utility.gutters_y',
|
|
128
|
-
preview: preview(['y']),
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
|
|
132
|
-
onInit: function() {
|
|
133
|
-
ge.canvas.off('grideditor:after-utility.ge-gutters').on('grideditor:after-utility.ge-gutters', afterUtility);
|
|
103
|
+
families: [
|
|
104
|
+
{
|
|
105
|
+
name: "g",
|
|
106
|
+
prefix: "g",
|
|
107
|
+
values: VALUES,
|
|
108
|
+
appliesTo: ["row"],
|
|
109
|
+
labelKey: "utility.gutters",
|
|
110
|
+
preview: preview(["x", "y"])
|
|
134
111
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
112
|
+
{
|
|
113
|
+
name: "gx",
|
|
114
|
+
prefix: "gx",
|
|
115
|
+
values: VALUES,
|
|
116
|
+
appliesTo: ["row"],
|
|
117
|
+
labelKey: "utility.gutters_x",
|
|
118
|
+
preview: preview(["x"])
|
|
141
119
|
},
|
|
120
|
+
{
|
|
121
|
+
name: "gy",
|
|
122
|
+
prefix: "gy",
|
|
123
|
+
values: VALUES,
|
|
124
|
+
appliesTo: ["row"],
|
|
125
|
+
labelKey: "utility.gutters_y",
|
|
126
|
+
preview: preview(["y"])
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
onInit: function() {
|
|
130
|
+
if (listening) {
|
|
131
|
+
ge.canvas.removeEventListener("grideditor:after-utility", listening);
|
|
132
|
+
}
|
|
133
|
+
listening = afterUtility;
|
|
134
|
+
ge.canvas.addEventListener("grideditor:after-utility", listening);
|
|
135
|
+
},
|
|
136
|
+
onRefresh: mark,
|
|
137
|
+
onDeinit: function() {
|
|
138
|
+
if (listening) {
|
|
139
|
+
ge.canvas.removeEventListener("grideditor:after-utility", listening);
|
|
140
|
+
}
|
|
141
|
+
listening = null;
|
|
142
|
+
all(ge.canvas, ".ge-gutters").forEach(function(row) {
|
|
143
|
+
removeClass(row, "ge-gutters");
|
|
144
|
+
});
|
|
145
|
+
}
|
|
142
146
|
};
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
})(jQuery);
|
|
147
|
+
};
|
|
148
|
+
})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.gutters.min.js.map
|
|
1
|
+
(()=>{var s=window.GridEditor;if(!s||typeof s.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");function d(t,i){return t?Array.prototype.slice.call(t.querySelectorAll(i)):[]}function m(t,i){if(!t)return[];var e=d(t,i);return t.nodeType===1&&t.matches(i)&&e.unshift(t),e}function x(t,i){return h(i).forEach(function(e){t.classList.remove(e)}),t}function y(t,i,e){return h(i).forEach(function(f){e===void 0?t.classList.toggle(f):t.classList.toggle(f,!!e)}),t}function h(t){return String(t||"").split(/\s+/).filter(Boolean)}Object.assign(s.locales.en,{"utility.gutters":"Gutters","utility.gutters_x":"Horizontal gutters","utility.gutters_y":"Vertical gutters"});var p=["0","1","2","3","4","5"],T=["0",".25rem",".5rem","1rem","1.5rem","3rem"],C="1.5rem",L="0",E=["","sm","md","lg","xl","xxl"],S=/(?:^|\s)g[xy]?-(?:(?:sm|md|lg|xl|xxl)-)?[0-5](?:\s|$)/;s.utilities.gutters=function(t){var i=Object.assign({scale:T},t.settings.utilities.gutters),e=null;function f(r,n,o){for(var u=(r.getAttribute("class")||"").split(/\s+/),l=o;l>=0;l--)for(var a=p.length-1;a>=0;a--){var c=n+(E[l]?"-"+E[l]:"")+"-"+a;if(u.indexOf(c)!==-1)return{tier:l,value:a}}return null}function v(r,n,o){var u=t.breakpoints.indexOf(t.view()),l=[f(r,"g",u),f(r,n,u)].filter(Boolean).sort(function(a,c){return c.tier-a.tier||c.value-a.value})[0];return l?i.scale[l.value]:o}function g(r){return function(n,o){var u={};return r.indexOf("x")!==-1&&(u["--bs-gutter-x"]=v(o,"gx",C)),r.indexOf("y")!==-1&&(u["--bs-gutter-y"]=v(o,"gy",L)),u}}function w(r){var n=r.detail;n.family==="g"&&["gx","gy"].forEach(function(o){t.setUtility(n.node,o,null,{view:n.breakpoint,source:n.source})})}function b(r){m(r,".row").forEach(function(n){y(n,"ge-gutters",S.test(n.getAttribute("class")||""))})}return{families:[{name:"g",prefix:"g",values:p,appliesTo:["row"],labelKey:"utility.gutters",preview:g(["x","y"])},{name:"gx",prefix:"gx",values:p,appliesTo:["row"],labelKey:"utility.gutters_x",preview:g(["x"])},{name:"gy",prefix:"gy",values:p,appliesTo:["row"],labelKey:"utility.gutters_y",preview:g(["y"])}],onInit:function(){e&&t.canvas.removeEventListener("grideditor:after-utility",e),e=w,t.canvas.addEventListener("grideditor:after-utility",e)},onRefresh:b,onDeinit:function(){e&&t.canvas.removeEventListener("grideditor:after-utility",e),e=null,d(t.canvas,".ge-gutters").forEach(function(r){x(r,"ge-gutters")})}}};})();
|