@themarioga/grid-editor 7.3.0 → 8.0.0-beta.2
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/CHANGELOG.md +60 -0
- package/README.md +27 -30
- package/UPGRADING.md +55 -0
- package/dist/grideditor.bundle.min.js +3 -3
- package/dist/grideditor.css +47 -6
- package/dist/grideditor.d.ts +3 -3
- package/dist/grideditor.esm.js +7 -58
- package/dist/grideditor.jquery.js +0 -13
- package/dist/grideditor.jquery.min.js +1 -1
- package/dist/grideditor.jquery.min.js.map +3 -3
- package/dist/grideditor.js +7 -58
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +2 -2
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +13 -6
- package/dist/locales/grideditor.es.js +13 -6
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.accordion.min.js.map +2 -2
- package/dist/plugins/grideditor.alignment.esm.js +11 -38
- package/dist/plugins/grideditor.alignment.js +11 -38
- package/dist/plugins/grideditor.alignment.min.js +1 -1
- package/dist/plugins/grideditor.alignment.min.js.map +3 -3
- package/dist/plugins/grideditor.card.min.js.map +1 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +0 -5
- package/dist/plugins/grideditor.ckeditor.js +0 -5
- package/dist/plugins/grideditor.ckeditor.min.js +1 -1
- package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
- package/dist/plugins/grideditor.clipboard.min.js.map +1 -1
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +1 -1
- package/dist/plugins/grideditor.codemirror.min.js.map +1 -1
- package/dist/plugins/grideditor.elements.min.js.map +2 -2
- package/dist/plugins/grideditor.gutters.min.js.map +1 -1
- package/dist/plugins/grideditor.order.min.js.map +1 -1
- package/dist/plugins/grideditor.popup.min.js.map +1 -1
- package/dist/plugins/grideditor.sections.min.js.map +2 -2
- package/dist/plugins/grideditor.style.esm.js +393 -60
- package/dist/plugins/grideditor.style.js +387 -56
- package/dist/plugins/grideditor.style.min.js +4 -2
- package/dist/plugins/grideditor.style.min.js.map +4 -4
- package/dist/plugins/grideditor.summernote.min.js.map +2 -2
- package/dist/plugins/grideditor.tabs.min.js.map +2 -2
- package/dist/plugins/grideditor.tinymce.esm.js +1 -8
- package/dist/plugins/grideditor.tinymce.js +1 -8
- package/dist/plugins/grideditor.tinymce.min.js +1 -1
- package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
- package/docs/events.md +4 -6
- package/docs/locale-keys.md +18 -13
- package/docs/plugins.md +15 -35
- package/example/ckeditor.html +0 -5
- package/example/index.html +5 -4
- package/example/style.html +16 -4
- package/example/utilities.html +12 -11
- package/package.json +1 -1
- package/src/js/dom.js +1 -2
- package/src/js/grideditor.jquery.js +7 -28
- package/src/js/grideditor.js +12 -81
- package/src/js/locales/grideditor.es.js +13 -6
- package/src/js/plugins/grideditor.alignment.js +21 -50
- package/src/js/plugins/grideditor.ckeditor.js +10 -23
- package/src/js/plugins/grideditor.style.js +18 -12
- package/src/js/plugins/grideditor.summernote.js +4 -5
- package/src/js/plugins/grideditor.tinymce.js +4 -17
- package/src/js/style/accordion.js +14 -3
- package/src/js/style/display.js +229 -0
- package/src/js/style/drawerflow.js +118 -0
- package/src/js/style/flex.js +156 -0
- package/src/js/style/float.js +2 -4
- package/src/js/style/options.js +5 -20
- package/src/js/style/sections.js +42 -15
- package/src/js/style/spacing.js +2 -4
- package/src/js/style/sticky.js +39 -0
- package/src/js/style/textalign.js +2 -4
- package/src/js/text/grideditor.text.js +1 -1
- package/src/less/grideditor.less +40 -10
- package/types/grideditor.d.ts +3 -3
- package/dist/plugins/grideditor.float.esm.js +0 -43
- package/dist/plugins/grideditor.float.js +0 -47
- package/dist/plugins/grideditor.float.min.js +0 -1
- package/dist/plugins/grideditor.float.min.js.map +0 -7
- package/dist/plugins/grideditor.spacing.esm.js +0 -327
- package/dist/plugins/grideditor.spacing.js +0 -329
- package/dist/plugins/grideditor.spacing.min.js +0 -1
- package/dist/plugins/grideditor.spacing.min.js.map +0 -7
- package/dist/plugins/grideditor.textalign.esm.js +0 -49
- package/dist/plugins/grideditor.textalign.js +0 -53
- package/dist/plugins/grideditor.textalign.min.js +0 -1
- package/dist/plugins/grideditor.textalign.min.js.map +0 -7
- package/dist/plugins/grideditor.visibility.esm.js +0 -167
- package/dist/plugins/grideditor.visibility.js +0 -169
- package/dist/plugins/grideditor.visibility.min.js +0 -1
- package/dist/plugins/grideditor.visibility.min.js.map +0 -7
- package/src/js/plugins/grideditor.float.js +0 -29
- package/src/js/plugins/grideditor.spacing.js +0 -31
- package/src/js/plugins/grideditor.textalign.js +0 -27
- package/src/js/plugins/grideditor.visibility.js +0 -32
- package/src/js/style/visibility.js +0 -160
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
// src/js/plugins/grideditor.spacing.js
|
|
2
|
-
import { GridEditor as GridEditor2 } from "../grideditor.esm.js";
|
|
3
|
-
|
|
4
|
-
// src/js/style/spacing.js
|
|
5
|
-
import { GridEditor } from "../grideditor.esm.js";
|
|
6
|
-
|
|
7
|
-
// src/js/dom.js
|
|
8
|
-
function all(root, selector) {
|
|
9
|
-
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
10
|
-
}
|
|
11
|
-
function selfAndAll(root, selector) {
|
|
12
|
-
if (!root) {
|
|
13
|
-
return [];
|
|
14
|
-
}
|
|
15
|
-
var found = all(root, selector);
|
|
16
|
-
if (root.nodeType === 1 && root.matches(selector)) {
|
|
17
|
-
found.unshift(root);
|
|
18
|
-
}
|
|
19
|
-
return found;
|
|
20
|
-
}
|
|
21
|
-
function children(node, selector) {
|
|
22
|
-
if (!node) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
return Array.prototype.filter.call(node.children, function(each) {
|
|
26
|
-
return !selector || each.matches(selector);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
function child(node, selector) {
|
|
30
|
-
return children(node, selector)[0] || null;
|
|
31
|
-
}
|
|
32
|
-
function is(node, selector) {
|
|
33
|
-
return !!node && node.nodeType === 1 && node.matches(selector);
|
|
34
|
-
}
|
|
35
|
-
function element(tag, attributes, text) {
|
|
36
|
-
var node = document.createElement(tag);
|
|
37
|
-
Object.keys(attributes || {}).forEach(function(name) {
|
|
38
|
-
var value = attributes[name];
|
|
39
|
-
if (value !== null && value !== void 0 && value !== false) {
|
|
40
|
-
node.setAttribute(name, value);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
if (text !== void 0 && text !== null) {
|
|
44
|
-
node.textContent = text;
|
|
45
|
-
}
|
|
46
|
-
return node;
|
|
47
|
-
}
|
|
48
|
-
function hasClass(node, name) {
|
|
49
|
-
return !!node && node.nodeType === 1 && node.classList.contains(name);
|
|
50
|
-
}
|
|
51
|
-
function css(node, styles) {
|
|
52
|
-
Object.keys(styles).forEach(function(property) {
|
|
53
|
-
var value = styles[property];
|
|
54
|
-
if (typeof value === "number" && !UNITLESS[property]) {
|
|
55
|
-
value = value + "px";
|
|
56
|
-
}
|
|
57
|
-
node.style.setProperty(property, value === null || value === void 0 ? "" : String(value));
|
|
58
|
-
});
|
|
59
|
-
return node;
|
|
60
|
-
}
|
|
61
|
-
var UNITLESS = { opacity: true, "z-index": true, "flex-grow": true, "flex-shrink": true, order: true };
|
|
62
|
-
var defaultDisplays = {};
|
|
63
|
-
function defaultDisplay(node) {
|
|
64
|
-
var tag = node.nodeName;
|
|
65
|
-
if (!defaultDisplays[tag]) {
|
|
66
|
-
var probe = document.body.appendChild(document.createElement(tag));
|
|
67
|
-
defaultDisplays[tag] = getComputedStyle(probe).display;
|
|
68
|
-
probe.remove();
|
|
69
|
-
if (defaultDisplays[tag] === "none") {
|
|
70
|
-
defaultDisplays[tag] = "block";
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return defaultDisplays[tag];
|
|
74
|
-
}
|
|
75
|
-
function show(node) {
|
|
76
|
-
node.style.removeProperty("display");
|
|
77
|
-
if (getComputedStyle(node).display === "none") {
|
|
78
|
-
node.style.display = defaultDisplay(node);
|
|
79
|
-
}
|
|
80
|
-
return node;
|
|
81
|
-
}
|
|
82
|
-
function hide(node) {
|
|
83
|
-
node.style.display = "none";
|
|
84
|
-
return node;
|
|
85
|
-
}
|
|
86
|
-
function toggle(node, state) {
|
|
87
|
-
if (state === void 0) {
|
|
88
|
-
state = !visible(node);
|
|
89
|
-
}
|
|
90
|
-
return state ? show(node) : hide(node);
|
|
91
|
-
}
|
|
92
|
-
function visible(node) {
|
|
93
|
-
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// src/js/style/spacing.js
|
|
97
|
-
Object.assign(GridEditor.locales.en, {
|
|
98
|
-
"utility.padding": "Padding",
|
|
99
|
-
"utility.margin": "Margin",
|
|
100
|
-
"utility.side_all": "All sides",
|
|
101
|
-
"utility.side_x": "Left and right",
|
|
102
|
-
"utility.side_y": "Top and bottom",
|
|
103
|
-
"utility.side_t": "Top",
|
|
104
|
-
"utility.side_b": "Bottom",
|
|
105
|
-
"utility.side_s": "Start",
|
|
106
|
-
"utility.side_e": "End",
|
|
107
|
-
"utility.spacing_gutter": "A column's side padding is its gutter: changing it changes the gutter"
|
|
108
|
-
});
|
|
109
|
-
var VALUES = ["0", "1", "2", "3", "4", "5"];
|
|
110
|
-
var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
|
|
111
|
-
var SIDES = ["", "x", "y", "t", "e", "b", "s"];
|
|
112
|
-
var SET = {
|
|
113
|
-
"": ["top", "right", "bottom", "left"],
|
|
114
|
-
x: ["left", "right"],
|
|
115
|
-
y: ["top", "bottom"],
|
|
116
|
-
t: ["top"],
|
|
117
|
-
e: ["right"],
|
|
118
|
-
b: ["bottom"],
|
|
119
|
-
s: ["left"]
|
|
120
|
-
};
|
|
121
|
-
var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
|
|
122
|
-
var PROPERTIES = { p: "padding", m: "margin" };
|
|
123
|
-
function pattern(key) {
|
|
124
|
-
return new RegExp("^" + key + "[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$");
|
|
125
|
-
}
|
|
126
|
-
function spacingPart(ge, given) {
|
|
127
|
-
var options = Object.assign({ values: VALUES, scale: SCALE }, given);
|
|
128
|
-
var patterns = { p: pattern("p"), m: pattern("m") };
|
|
129
|
-
function applies(node, kind) {
|
|
130
|
-
return kind === "row" || kind === "column" || kind === "element" || is(node, "[data-ge-container]");
|
|
131
|
-
}
|
|
132
|
-
function classes(node) {
|
|
133
|
-
return (node.getAttribute("class") || "").split(/\s+/);
|
|
134
|
-
}
|
|
135
|
-
function carries(node, key) {
|
|
136
|
-
return classes(node).some(function(name) {
|
|
137
|
-
return patterns[key].test(name);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
function source(node, family, tier) {
|
|
141
|
-
var names = classes(node);
|
|
142
|
-
var values = family.charAt(0) === "m" ? VALUES.concat(["auto"]) : VALUES;
|
|
143
|
-
for (var i = tier; i >= 0; i--) {
|
|
144
|
-
for (var v = 0; v < values.length; v++) {
|
|
145
|
-
var name = family + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + values[v];
|
|
146
|
-
if (names.indexOf(name) !== -1) {
|
|
147
|
-
return { tier: i, value: values[v] };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
function without(node, key) {
|
|
154
|
-
var original = node.getAttribute("class");
|
|
155
|
-
var style;
|
|
156
|
-
var bare = {};
|
|
157
|
-
node.setAttribute("class", classes(node).filter(function(name) {
|
|
158
|
-
return !patterns[key].test(name);
|
|
159
|
-
}).join(" "));
|
|
160
|
-
style = getComputedStyle(node);
|
|
161
|
-
["top", "right", "bottom", "left"].forEach(function(side) {
|
|
162
|
-
bare[side] = style.getPropertyValue(PROPERTIES[key] + "-" + side);
|
|
163
|
-
});
|
|
164
|
-
if (original === null) {
|
|
165
|
-
node.removeAttribute("class");
|
|
166
|
-
} else {
|
|
167
|
-
node.setAttribute("class", original);
|
|
168
|
-
}
|
|
169
|
-
return bare;
|
|
170
|
-
}
|
|
171
|
-
function sides(node, key, breakpoint) {
|
|
172
|
-
var tier = ge.breakpoints.indexOf(breakpoint);
|
|
173
|
-
var winners = {};
|
|
174
|
-
var styles = {};
|
|
175
|
-
var neutral = null;
|
|
176
|
-
SIDES.forEach(function(side, order) {
|
|
177
|
-
var found = source(node, key + side, tier);
|
|
178
|
-
if (!found) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
SET[side].forEach(function(set) {
|
|
182
|
-
var current = winners[set];
|
|
183
|
-
if (!current || found.tier > current.tier || found.tier === current.tier && order > current.order) {
|
|
184
|
-
winners[set] = { tier: found.tier, order, value: found.value };
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
["top", "right", "bottom", "left"].forEach(function(set) {
|
|
189
|
-
var winner = winners[set];
|
|
190
|
-
if (!winner) {
|
|
191
|
-
neutral = neutral || without(node, key);
|
|
192
|
-
styles[PROPERTIES[key] + "-" + set] = neutral[set];
|
|
193
|
-
} else {
|
|
194
|
-
styles[PROPERTIES[key] + "-" + set] = winner.value === "auto" ? "auto" : options.scale[winner.value];
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
return styles;
|
|
198
|
-
}
|
|
199
|
-
function startingSide(node, key) {
|
|
200
|
-
var names = classes(node).filter(function(name) {
|
|
201
|
-
return patterns[key].test(name);
|
|
202
|
-
});
|
|
203
|
-
var found = SIDES.filter(function(side) {
|
|
204
|
-
return names.some(function(name) {
|
|
205
|
-
return name.indexOf(key + side + "-") === 0;
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
return found.length ? found[0] : "";
|
|
209
|
-
}
|
|
210
|
-
function sideLabel(side) {
|
|
211
|
-
switch (side) {
|
|
212
|
-
case "x":
|
|
213
|
-
return ge.t("utility.side_x");
|
|
214
|
-
case "y":
|
|
215
|
-
return ge.t("utility.side_y");
|
|
216
|
-
case "t":
|
|
217
|
-
return ge.t("utility.side_t");
|
|
218
|
-
case "b":
|
|
219
|
-
return ge.t("utility.side_b");
|
|
220
|
-
case "s":
|
|
221
|
-
return ge.t("utility.side_s");
|
|
222
|
-
case "e":
|
|
223
|
-
return ge.t("utility.side_e");
|
|
224
|
-
default:
|
|
225
|
-
return ge.t("utility.side_all");
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function group(node, key, labelText) {
|
|
229
|
-
var box = element("div", { "class": "ge-spacing-group", "data-ge-spacing": key });
|
|
230
|
-
var side = element("select", { "class": "ge-spacing-side form-select form-select-sm" });
|
|
231
|
-
box.appendChild(element("span", { "class": "ge-utility-label" }, labelText));
|
|
232
|
-
SIDES.forEach(function(value) {
|
|
233
|
-
side.appendChild(element("option", { value }, sideLabel(value)));
|
|
234
|
-
});
|
|
235
|
-
var field = ge.utilityField(node, key + startingSide(node, key));
|
|
236
|
-
side.value = field.getAttribute("data-ge-family").slice(1);
|
|
237
|
-
side.addEventListener("change", function() {
|
|
238
|
-
var next = ge.utilityField(node, key + this.value);
|
|
239
|
-
field.replaceWith(next);
|
|
240
|
-
field = next;
|
|
241
|
-
});
|
|
242
|
-
box.appendChild(side);
|
|
243
|
-
box.appendChild(field);
|
|
244
|
-
return box;
|
|
245
|
-
}
|
|
246
|
-
var NODES = ".row, .column, .ge-element, [data-ge-container]";
|
|
247
|
-
function mark(scope) {
|
|
248
|
-
selfAndAll(scope, NODES).forEach(function(node) {
|
|
249
|
-
var drawer = child(node, ".ge-tools-drawer");
|
|
250
|
-
if (!drawer || !applies(node, ge.kindOf(node))) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
if (carries(node, "p")) {
|
|
254
|
-
var style = getComputedStyle(node);
|
|
255
|
-
css(drawer, {
|
|
256
|
-
"margin-top": "-" + style.paddingTop,
|
|
257
|
-
"margin-left": "-" + style.paddingLeft,
|
|
258
|
-
"margin-right": "-" + style.paddingRight,
|
|
259
|
-
width: "calc(100% + " + style.paddingLeft + " + " + style.paddingRight + ")"
|
|
260
|
-
});
|
|
261
|
-
} else {
|
|
262
|
-
css(drawer, { "margin-top": "", "margin-left": "", "margin-right": "", width: "" });
|
|
263
|
-
}
|
|
264
|
-
if (hasClass(node, "column")) {
|
|
265
|
-
var padded = classes(node).some(function(name) {
|
|
266
|
-
return /^p[xse]?-/.test(name) && patterns.p.test(name);
|
|
267
|
-
});
|
|
268
|
-
all(drawer, ".ge-spacing-gutter").forEach(function(note) {
|
|
269
|
-
toggle(note, padded);
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
function families(key, labelKey) {
|
|
275
|
-
var values = key === "m" ? VALUES.concat(["auto"]) : VALUES;
|
|
276
|
-
var offered = options.values.concat(key === "m" ? ["auto"] : []);
|
|
277
|
-
return SIDES.map(function(side) {
|
|
278
|
-
return {
|
|
279
|
-
name: key + side,
|
|
280
|
-
prefix: key + side,
|
|
281
|
-
values,
|
|
282
|
-
appliesTo: ["row", "column", "text", "element", "container"],
|
|
283
|
-
labelKey,
|
|
284
|
-
panel: false,
|
|
285
|
-
choices: function() {
|
|
286
|
-
return values.filter(function(value) {
|
|
287
|
-
return offered.indexOf(value) !== -1;
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
return {
|
|
294
|
-
families: families("p", "utility.padding").concat(families("m", "utility.margin")),
|
|
295
|
-
panel: function(node, kind) {
|
|
296
|
-
if (!applies(node, kind)) {
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
var box = element("div", { "class": "ge-spacing" });
|
|
300
|
-
box.appendChild(group(node, "p", ge.t("utility.padding")));
|
|
301
|
-
box.appendChild(group(node, "m", ge.t("utility.margin")));
|
|
302
|
-
if (kind === "column") {
|
|
303
|
-
box.appendChild(element("small", { "class": "ge-spacing-gutter" }, ge.t("utility.spacing_gutter")));
|
|
304
|
-
}
|
|
305
|
-
return box;
|
|
306
|
-
},
|
|
307
|
-
preview: function(node, kind, breakpoint) {
|
|
308
|
-
if (!applies(node, kind)) {
|
|
309
|
-
return {};
|
|
310
|
-
}
|
|
311
|
-
var styles = {};
|
|
312
|
-
["p", "m"].forEach(function(key) {
|
|
313
|
-
if (carries(node, key)) {
|
|
314
|
-
Object.assign(styles, sides(node, key, breakpoint));
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
return styles;
|
|
318
|
-
},
|
|
319
|
-
onRefresh: mark
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// src/js/plugins/grideditor.spacing.js
|
|
324
|
-
GridEditor2.utilities.spacing = function(ge) {
|
|
325
|
-
ge.warn('the "spacing" plugin is deprecated and will be removed in 8.0: load grideditor.style.js');
|
|
326
|
-
return spacingPart(ge, ge.settings.utilities.spacing);
|
|
327
|
-
};
|
|
@@ -1,329 +0,0 @@
|
|
|
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 children(node, selector) {
|
|
23
|
-
if (!node) {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
return Array.prototype.filter.call(node.children, function(each) {
|
|
27
|
-
return !selector || each.matches(selector);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function child(node, selector) {
|
|
31
|
-
return children(node, selector)[0] || null;
|
|
32
|
-
}
|
|
33
|
-
function is(node, selector) {
|
|
34
|
-
return !!node && node.nodeType === 1 && node.matches(selector);
|
|
35
|
-
}
|
|
36
|
-
function element(tag, attributes, text) {
|
|
37
|
-
var node = document.createElement(tag);
|
|
38
|
-
Object.keys(attributes || {}).forEach(function(name) {
|
|
39
|
-
var value = attributes[name];
|
|
40
|
-
if (value !== null && value !== void 0 && value !== false) {
|
|
41
|
-
node.setAttribute(name, value);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
if (text !== void 0 && text !== null) {
|
|
45
|
-
node.textContent = text;
|
|
46
|
-
}
|
|
47
|
-
return node;
|
|
48
|
-
}
|
|
49
|
-
function hasClass(node, name) {
|
|
50
|
-
return !!node && node.nodeType === 1 && node.classList.contains(name);
|
|
51
|
-
}
|
|
52
|
-
function css(node, styles) {
|
|
53
|
-
Object.keys(styles).forEach(function(property) {
|
|
54
|
-
var value = styles[property];
|
|
55
|
-
if (typeof value === "number" && !UNITLESS[property]) {
|
|
56
|
-
value = value + "px";
|
|
57
|
-
}
|
|
58
|
-
node.style.setProperty(property, value === null || value === void 0 ? "" : String(value));
|
|
59
|
-
});
|
|
60
|
-
return node;
|
|
61
|
-
}
|
|
62
|
-
var UNITLESS = { opacity: true, "z-index": true, "flex-grow": true, "flex-shrink": true, order: true };
|
|
63
|
-
var defaultDisplays = {};
|
|
64
|
-
function defaultDisplay(node) {
|
|
65
|
-
var tag = node.nodeName;
|
|
66
|
-
if (!defaultDisplays[tag]) {
|
|
67
|
-
var probe = document.body.appendChild(document.createElement(tag));
|
|
68
|
-
defaultDisplays[tag] = getComputedStyle(probe).display;
|
|
69
|
-
probe.remove();
|
|
70
|
-
if (defaultDisplays[tag] === "none") {
|
|
71
|
-
defaultDisplays[tag] = "block";
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return defaultDisplays[tag];
|
|
75
|
-
}
|
|
76
|
-
function show(node) {
|
|
77
|
-
node.style.removeProperty("display");
|
|
78
|
-
if (getComputedStyle(node).display === "none") {
|
|
79
|
-
node.style.display = defaultDisplay(node);
|
|
80
|
-
}
|
|
81
|
-
return node;
|
|
82
|
-
}
|
|
83
|
-
function hide(node) {
|
|
84
|
-
node.style.display = "none";
|
|
85
|
-
return node;
|
|
86
|
-
}
|
|
87
|
-
function toggle(node, state) {
|
|
88
|
-
if (state === void 0) {
|
|
89
|
-
state = !visible(node);
|
|
90
|
-
}
|
|
91
|
-
return state ? show(node) : hide(node);
|
|
92
|
-
}
|
|
93
|
-
function visible(node) {
|
|
94
|
-
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/js/style/spacing.js
|
|
98
|
-
Object.assign(GridEditor.locales.en, {
|
|
99
|
-
"utility.padding": "Padding",
|
|
100
|
-
"utility.margin": "Margin",
|
|
101
|
-
"utility.side_all": "All sides",
|
|
102
|
-
"utility.side_x": "Left and right",
|
|
103
|
-
"utility.side_y": "Top and bottom",
|
|
104
|
-
"utility.side_t": "Top",
|
|
105
|
-
"utility.side_b": "Bottom",
|
|
106
|
-
"utility.side_s": "Start",
|
|
107
|
-
"utility.side_e": "End",
|
|
108
|
-
"utility.spacing_gutter": "A column's side padding is its gutter: changing it changes the gutter"
|
|
109
|
-
});
|
|
110
|
-
var VALUES = ["0", "1", "2", "3", "4", "5"];
|
|
111
|
-
var SCALE = ["0", ".25rem", ".5rem", "1rem", "1.5rem", "3rem"];
|
|
112
|
-
var SIDES = ["", "x", "y", "t", "e", "b", "s"];
|
|
113
|
-
var SET = {
|
|
114
|
-
"": ["top", "right", "bottom", "left"],
|
|
115
|
-
x: ["left", "right"],
|
|
116
|
-
y: ["top", "bottom"],
|
|
117
|
-
t: ["top"],
|
|
118
|
-
e: ["right"],
|
|
119
|
-
b: ["bottom"],
|
|
120
|
-
s: ["left"]
|
|
121
|
-
};
|
|
122
|
-
var INFIXES = ["", "sm", "md", "lg", "xl", "xxl"];
|
|
123
|
-
var PROPERTIES = { p: "padding", m: "margin" };
|
|
124
|
-
function pattern(key) {
|
|
125
|
-
return new RegExp("^" + key + "[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$");
|
|
126
|
-
}
|
|
127
|
-
function spacingPart(ge, given) {
|
|
128
|
-
var options = Object.assign({ values: VALUES, scale: SCALE }, given);
|
|
129
|
-
var patterns = { p: pattern("p"), m: pattern("m") };
|
|
130
|
-
function applies(node, kind) {
|
|
131
|
-
return kind === "row" || kind === "column" || kind === "element" || is(node, "[data-ge-container]");
|
|
132
|
-
}
|
|
133
|
-
function classes(node) {
|
|
134
|
-
return (node.getAttribute("class") || "").split(/\s+/);
|
|
135
|
-
}
|
|
136
|
-
function carries(node, key) {
|
|
137
|
-
return classes(node).some(function(name) {
|
|
138
|
-
return patterns[key].test(name);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function source(node, family, tier) {
|
|
142
|
-
var names = classes(node);
|
|
143
|
-
var values = family.charAt(0) === "m" ? VALUES.concat(["auto"]) : VALUES;
|
|
144
|
-
for (var i = tier; i >= 0; i--) {
|
|
145
|
-
for (var v = 0; v < values.length; v++) {
|
|
146
|
-
var name = family + (INFIXES[i] ? "-" + INFIXES[i] : "") + "-" + values[v];
|
|
147
|
-
if (names.indexOf(name) !== -1) {
|
|
148
|
-
return { tier: i, value: values[v] };
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
function without(node, key) {
|
|
155
|
-
var original = node.getAttribute("class");
|
|
156
|
-
var style;
|
|
157
|
-
var bare = {};
|
|
158
|
-
node.setAttribute("class", classes(node).filter(function(name) {
|
|
159
|
-
return !patterns[key].test(name);
|
|
160
|
-
}).join(" "));
|
|
161
|
-
style = getComputedStyle(node);
|
|
162
|
-
["top", "right", "bottom", "left"].forEach(function(side) {
|
|
163
|
-
bare[side] = style.getPropertyValue(PROPERTIES[key] + "-" + side);
|
|
164
|
-
});
|
|
165
|
-
if (original === null) {
|
|
166
|
-
node.removeAttribute("class");
|
|
167
|
-
} else {
|
|
168
|
-
node.setAttribute("class", original);
|
|
169
|
-
}
|
|
170
|
-
return bare;
|
|
171
|
-
}
|
|
172
|
-
function sides(node, key, breakpoint) {
|
|
173
|
-
var tier = ge.breakpoints.indexOf(breakpoint);
|
|
174
|
-
var winners = {};
|
|
175
|
-
var styles = {};
|
|
176
|
-
var neutral = null;
|
|
177
|
-
SIDES.forEach(function(side, order) {
|
|
178
|
-
var found = source(node, key + side, tier);
|
|
179
|
-
if (!found) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
SET[side].forEach(function(set) {
|
|
183
|
-
var current = winners[set];
|
|
184
|
-
if (!current || found.tier > current.tier || found.tier === current.tier && order > current.order) {
|
|
185
|
-
winners[set] = { tier: found.tier, order, value: found.value };
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
["top", "right", "bottom", "left"].forEach(function(set) {
|
|
190
|
-
var winner = winners[set];
|
|
191
|
-
if (!winner) {
|
|
192
|
-
neutral = neutral || without(node, key);
|
|
193
|
-
styles[PROPERTIES[key] + "-" + set] = neutral[set];
|
|
194
|
-
} else {
|
|
195
|
-
styles[PROPERTIES[key] + "-" + set] = winner.value === "auto" ? "auto" : options.scale[winner.value];
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
return styles;
|
|
199
|
-
}
|
|
200
|
-
function startingSide(node, key) {
|
|
201
|
-
var names = classes(node).filter(function(name) {
|
|
202
|
-
return patterns[key].test(name);
|
|
203
|
-
});
|
|
204
|
-
var found = SIDES.filter(function(side) {
|
|
205
|
-
return names.some(function(name) {
|
|
206
|
-
return name.indexOf(key + side + "-") === 0;
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
return found.length ? found[0] : "";
|
|
210
|
-
}
|
|
211
|
-
function sideLabel(side) {
|
|
212
|
-
switch (side) {
|
|
213
|
-
case "x":
|
|
214
|
-
return ge.t("utility.side_x");
|
|
215
|
-
case "y":
|
|
216
|
-
return ge.t("utility.side_y");
|
|
217
|
-
case "t":
|
|
218
|
-
return ge.t("utility.side_t");
|
|
219
|
-
case "b":
|
|
220
|
-
return ge.t("utility.side_b");
|
|
221
|
-
case "s":
|
|
222
|
-
return ge.t("utility.side_s");
|
|
223
|
-
case "e":
|
|
224
|
-
return ge.t("utility.side_e");
|
|
225
|
-
default:
|
|
226
|
-
return ge.t("utility.side_all");
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function group(node, key, labelText) {
|
|
230
|
-
var box = element("div", { "class": "ge-spacing-group", "data-ge-spacing": key });
|
|
231
|
-
var side = element("select", { "class": "ge-spacing-side form-select form-select-sm" });
|
|
232
|
-
box.appendChild(element("span", { "class": "ge-utility-label" }, labelText));
|
|
233
|
-
SIDES.forEach(function(value) {
|
|
234
|
-
side.appendChild(element("option", { value }, sideLabel(value)));
|
|
235
|
-
});
|
|
236
|
-
var field = ge.utilityField(node, key + startingSide(node, key));
|
|
237
|
-
side.value = field.getAttribute("data-ge-family").slice(1);
|
|
238
|
-
side.addEventListener("change", function() {
|
|
239
|
-
var next = ge.utilityField(node, key + this.value);
|
|
240
|
-
field.replaceWith(next);
|
|
241
|
-
field = next;
|
|
242
|
-
});
|
|
243
|
-
box.appendChild(side);
|
|
244
|
-
box.appendChild(field);
|
|
245
|
-
return box;
|
|
246
|
-
}
|
|
247
|
-
var NODES = ".row, .column, .ge-element, [data-ge-container]";
|
|
248
|
-
function mark(scope) {
|
|
249
|
-
selfAndAll(scope, NODES).forEach(function(node) {
|
|
250
|
-
var drawer = child(node, ".ge-tools-drawer");
|
|
251
|
-
if (!drawer || !applies(node, ge.kindOf(node))) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
if (carries(node, "p")) {
|
|
255
|
-
var style = getComputedStyle(node);
|
|
256
|
-
css(drawer, {
|
|
257
|
-
"margin-top": "-" + style.paddingTop,
|
|
258
|
-
"margin-left": "-" + style.paddingLeft,
|
|
259
|
-
"margin-right": "-" + style.paddingRight,
|
|
260
|
-
width: "calc(100% + " + style.paddingLeft + " + " + style.paddingRight + ")"
|
|
261
|
-
});
|
|
262
|
-
} else {
|
|
263
|
-
css(drawer, { "margin-top": "", "margin-left": "", "margin-right": "", width: "" });
|
|
264
|
-
}
|
|
265
|
-
if (hasClass(node, "column")) {
|
|
266
|
-
var padded = classes(node).some(function(name) {
|
|
267
|
-
return /^p[xse]?-/.test(name) && patterns.p.test(name);
|
|
268
|
-
});
|
|
269
|
-
all(drawer, ".ge-spacing-gutter").forEach(function(note) {
|
|
270
|
-
toggle(note, padded);
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
function families(key, labelKey) {
|
|
276
|
-
var values = key === "m" ? VALUES.concat(["auto"]) : VALUES;
|
|
277
|
-
var offered = options.values.concat(key === "m" ? ["auto"] : []);
|
|
278
|
-
return SIDES.map(function(side) {
|
|
279
|
-
return {
|
|
280
|
-
name: key + side,
|
|
281
|
-
prefix: key + side,
|
|
282
|
-
values,
|
|
283
|
-
appliesTo: ["row", "column", "text", "element", "container"],
|
|
284
|
-
labelKey,
|
|
285
|
-
panel: false,
|
|
286
|
-
choices: function() {
|
|
287
|
-
return values.filter(function(value) {
|
|
288
|
-
return offered.indexOf(value) !== -1;
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
return {
|
|
295
|
-
families: families("p", "utility.padding").concat(families("m", "utility.margin")),
|
|
296
|
-
panel: function(node, kind) {
|
|
297
|
-
if (!applies(node, kind)) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
var box = element("div", { "class": "ge-spacing" });
|
|
301
|
-
box.appendChild(group(node, "p", ge.t("utility.padding")));
|
|
302
|
-
box.appendChild(group(node, "m", ge.t("utility.margin")));
|
|
303
|
-
if (kind === "column") {
|
|
304
|
-
box.appendChild(element("small", { "class": "ge-spacing-gutter" }, ge.t("utility.spacing_gutter")));
|
|
305
|
-
}
|
|
306
|
-
return box;
|
|
307
|
-
},
|
|
308
|
-
preview: function(node, kind, breakpoint) {
|
|
309
|
-
if (!applies(node, kind)) {
|
|
310
|
-
return {};
|
|
311
|
-
}
|
|
312
|
-
var styles = {};
|
|
313
|
-
["p", "m"].forEach(function(key) {
|
|
314
|
-
if (carries(node, key)) {
|
|
315
|
-
Object.assign(styles, sides(node, key, breakpoint));
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
return styles;
|
|
319
|
-
},
|
|
320
|
-
onRefresh: mark
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// src/js/plugins/grideditor.spacing.js
|
|
325
|
-
GridEditor.utilities.spacing = function(ge) {
|
|
326
|
-
ge.warn('the "spacing" plugin is deprecated and will be removed in 8.0: load grideditor.style.js');
|
|
327
|
-
return spacingPart(ge, ge.settings.utilities.spacing);
|
|
328
|
-
};
|
|
329
|
-
})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var v=window.GridEditor;if(!v||typeof v.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 w(t,n){return t?Array.prototype.slice.call(t.querySelectorAll(n)):[]}function _(t,n){if(!t)return[];var l=w(t,n);return t.nodeType===1&&t.matches(n)&&l.unshift(t),l}function V(t,n){return t?Array.prototype.filter.call(t.children,function(l){return!n||l.matches(n)}):[]}function B(t,n){return V(t,n)[0]||null}function j(t,n){return!!t&&t.nodeType===1&&t.matches(n)}function d(t,n,l){var s=document.createElement(t);return Object.keys(n||{}).forEach(function(m){var c=n[m];c!=null&&c!==!1&&s.setAttribute(m,c)}),l!=null&&(s.textContent=l),s}function R(t,n){return!!t&&t.nodeType===1&&t.classList.contains(n)}function A(t,n){return Object.keys(n).forEach(function(l){var s=n[l];typeof s=="number"&&!X[l]&&(s=s+"px"),t.style.setProperty(l,s==null?"":String(s))}),t}var X={opacity:!0,"z-index":!0,"flex-grow":!0,"flex-shrink":!0,order:!0},x={};function z(t){var n=t.nodeName;if(!x[n]){var l=document.body.appendChild(document.createElement(n));x[n]=getComputedStyle(l).display,l.remove(),x[n]==="none"&&(x[n]="block")}return x[n]}function K(t){return t.style.removeProperty("display"),getComputedStyle(t).display==="none"&&(t.style.display=z(t)),t}function Y(t){return t.style.display="none",t}function P(t,n){return n===void 0&&(n=!$(t)),n?K(t):Y(t)}function $(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}Object.assign(v.locales.en,{"utility.padding":"Padding","utility.margin":"Margin","utility.side_all":"All sides","utility.side_x":"Left and right","utility.side_y":"Top and bottom","utility.side_t":"Top","utility.side_b":"Bottom","utility.side_s":"Start","utility.side_e":"End","utility.spacing_gutter":"A column's side padding is its gutter: changing it changes the gutter"});var y=["0","1","2","3","4","5"],Q=["0",".25rem",".5rem","1rem","1.5rem","3rem"],b=["","x","y","t","e","b","s"],Z={"":["top","right","bottom","left"],x:["left","right"],y:["top","bottom"],t:["top"],e:["right"],b:["bottom"],s:["left"]},N=["","sm","md","lg","xl","xxl"],C={p:"padding",m:"margin"};function H(t){return new RegExp("^"+t+"[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$")}function I(t,n){var l=Object.assign({values:y,scale:Q},n),s={p:H("p"),m:H("m")};function m(e,r){return r==="row"||r==="column"||r==="element"||j(e,"[data-ge-container]")}function c(e){return(e.getAttribute("class")||"").split(/\s+/)}function S(e,r){return c(e).some(function(a){return s[r].test(a)})}function D(e,r,a){for(var u=c(e),o=r.charAt(0)==="m"?y.concat(["auto"]):y,i=a;i>=0;i--)for(var f=0;f<o.length;f++){var p=r+(N[i]?"-"+N[i]:"")+"-"+o[f];if(u.indexOf(p)!==-1)return{tier:i,value:o[f]}}return null}function F(e,r){var a=e.getAttribute("class"),u,o={};return e.setAttribute("class",c(e).filter(function(i){return!s[r].test(i)}).join(" ")),u=getComputedStyle(e),["top","right","bottom","left"].forEach(function(i){o[i]=u.getPropertyValue(C[r]+"-"+i)}),a===null?e.removeAttribute("class"):e.setAttribute("class",a),o}function U(e,r,a){var u=t.breakpoints.indexOf(a),o={},i={},f=null;return b.forEach(function(p,g){var h=D(e,r+p,u);h&&Z[p].forEach(function(O){var E=o[O];(!E||h.tier>E.tier||h.tier===E.tier&&g>E.order)&&(o[O]={tier:h.tier,order:g,value:h.value})})}),["top","right","bottom","left"].forEach(function(p){var g=o[p];g?i[C[r]+"-"+p]=g.value==="auto"?"auto":l.scale[g.value]:(f=f||F(e,r),i[C[r]+"-"+p]=f[p])}),i}function G(e,r){var a=c(e).filter(function(o){return s[r].test(o)}),u=b.filter(function(o){return a.some(function(i){return i.indexOf(r+o+"-")===0})});return u.length?u[0]:""}function M(e){switch(e){case"x":return t.t("utility.side_x");case"y":return t.t("utility.side_y");case"t":return t.t("utility.side_t");case"b":return t.t("utility.side_b");case"s":return t.t("utility.side_s");case"e":return t.t("utility.side_e");default:return t.t("utility.side_all")}}function T(e,r,a){var u=d("div",{class:"ge-spacing-group","data-ge-spacing":r}),o=d("select",{class:"ge-spacing-side form-select form-select-sm"});u.appendChild(d("span",{class:"ge-utility-label"},a)),b.forEach(function(f){o.appendChild(d("option",{value:f},M(f)))});var i=t.utilityField(e,r+G(e,r));return o.value=i.getAttribute("data-ge-family").slice(1),o.addEventListener("change",function(){var f=t.utilityField(e,r+this.value);i.replaceWith(f),i=f}),u.appendChild(o),u.appendChild(i),u}var q=".row, .column, .ge-element, [data-ge-container]";function W(e){_(e,q).forEach(function(r){var a=B(r,".ge-tools-drawer");if(!(!a||!m(r,t.kindOf(r)))){if(S(r,"p")){var u=getComputedStyle(r);A(a,{"margin-top":"-"+u.paddingTop,"margin-left":"-"+u.paddingLeft,"margin-right":"-"+u.paddingRight,width:"calc(100% + "+u.paddingLeft+" + "+u.paddingRight+")"})}else A(a,{"margin-top":"","margin-left":"","margin-right":"",width:""});if(R(r,"column")){var o=c(r).some(function(i){return/^p[xse]?-/.test(i)&&s.p.test(i)});w(a,".ge-spacing-gutter").forEach(function(i){P(i,o)})}}})}function L(e,r){var a=e==="m"?y.concat(["auto"]):y,u=l.values.concat(e==="m"?["auto"]:[]);return b.map(function(o){return{name:e+o,prefix:e+o,values:a,appliesTo:["row","column","text","element","container"],labelKey:r,panel:!1,choices:function(){return a.filter(function(i){return u.indexOf(i)!==-1})}}})}return{families:L("p","utility.padding").concat(L("m","utility.margin")),panel:function(e,r){if(!m(e,r))return null;var a=d("div",{class:"ge-spacing"});return a.appendChild(T(e,"p",t.t("utility.padding"))),a.appendChild(T(e,"m",t.t("utility.margin"))),r==="column"&&a.appendChild(d("small",{class:"ge-spacing-gutter"},t.t("utility.spacing_gutter"))),a},preview:function(e,r,a){if(!m(e,r))return{};var u={};return["p","m"].forEach(function(o){S(e,o)&&Object.assign(u,U(e,o,a))}),u},onRefresh:W}}v.utilities.spacing=function(t){return t.warn('the "spacing" plugin is deprecated and will be removed in 8.0: load grideditor.style.js'),I(t,t.settings.utilities.spacing)};})();
|