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