@themarioga/grid-editor 6.0.0 → 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.
Files changed (147) hide show
  1. package/AUTO_SAVE.md +2 -2
  2. package/BUILDING.md +45 -29
  3. package/CHANGELOG.md +47 -0
  4. package/README.md +137 -85
  5. package/UPGRADING.md +119 -0
  6. package/dist/grideditor.bundle.min.js +14 -0
  7. package/dist/grideditor.d.ts +335 -0
  8. package/dist/grideditor.esm.js +3977 -0
  9. package/dist/grideditor.jquery.js +253 -0
  10. package/dist/grideditor.jquery.min.js +1 -0
  11. package/dist/grideditor.jquery.min.js.map +7 -0
  12. package/dist/grideditor.js +3983 -0
  13. package/dist/grideditor.min.js +6 -0
  14. package/dist/grideditor.min.js.map +7 -0
  15. package/dist/locales/grideditor.es.esm.js +158 -0
  16. package/dist/locales/grideditor.es.js +164 -168
  17. package/dist/locales/grideditor.es.min.js +6 -2
  18. package/dist/locales/grideditor.es.min.js.map +7 -1
  19. package/dist/plugins/grideditor.accordion.esm.js +294 -0
  20. package/dist/plugins/grideditor.accordion.js +286 -180
  21. package/dist/plugins/grideditor.accordion.min.js +1 -2
  22. package/dist/plugins/grideditor.accordion.min.js.map +7 -1
  23. package/dist/plugins/grideditor.alignment.esm.js +55 -0
  24. package/dist/plugins/grideditor.alignment.js +58 -77
  25. package/dist/plugins/grideditor.alignment.min.js +1 -2
  26. package/dist/plugins/grideditor.alignment.min.js.map +7 -1
  27. package/dist/plugins/grideditor.card.esm.js +73 -0
  28. package/dist/plugins/grideditor.card.js +74 -64
  29. package/dist/plugins/grideditor.card.min.js +1 -2
  30. package/dist/plugins/grideditor.card.min.js.map +7 -1
  31. package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
  32. package/dist/plugins/grideditor.ckeditor.js +484 -449
  33. package/dist/plugins/grideditor.ckeditor.min.js +1 -2
  34. package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
  35. package/dist/plugins/grideditor.clipboard.esm.js +326 -0
  36. package/dist/plugins/grideditor.clipboard.js +298 -235
  37. package/dist/plugins/grideditor.clipboard.min.js +1 -2
  38. package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
  39. package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
  40. package/dist/plugins/grideditor.codemirror-inline.js +188 -168
  41. package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
  42. package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
  43. package/dist/plugins/grideditor.codemirror.esm.js +63 -0
  44. package/dist/plugins/grideditor.codemirror.js +60 -71
  45. package/dist/plugins/grideditor.codemirror.min.js +1 -2
  46. package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
  47. package/dist/plugins/grideditor.elements.esm.js +271 -0
  48. package/dist/plugins/grideditor.elements.js +256 -149
  49. package/dist/plugins/grideditor.elements.min.js +1 -2
  50. package/dist/plugins/grideditor.elements.min.js.map +7 -1
  51. package/dist/plugins/grideditor.float.esm.js +34 -0
  52. package/dist/plugins/grideditor.float.js +37 -52
  53. package/dist/plugins/grideditor.float.min.js +1 -2
  54. package/dist/plugins/grideditor.float.min.js.map +7 -1
  55. package/dist/plugins/grideditor.gutters.esm.js +143 -0
  56. package/dist/plugins/grideditor.gutters.js +134 -131
  57. package/dist/plugins/grideditor.gutters.min.js +1 -2
  58. package/dist/plugins/grideditor.gutters.min.js.map +7 -1
  59. package/dist/plugins/grideditor.order.esm.js +189 -0
  60. package/dist/plugins/grideditor.order.js +170 -182
  61. package/dist/plugins/grideditor.order.min.js +1 -2
  62. package/dist/plugins/grideditor.order.min.js.map +7 -1
  63. package/dist/plugins/grideditor.popup.esm.js +187 -0
  64. package/dist/plugins/grideditor.popup.js +183 -134
  65. package/dist/plugins/grideditor.popup.min.js +1 -2
  66. package/dist/plugins/grideditor.popup.min.js.map +7 -1
  67. package/dist/plugins/grideditor.sections.esm.js +271 -0
  68. package/dist/plugins/grideditor.sections.js +250 -173
  69. package/dist/plugins/grideditor.sections.min.js +1 -2
  70. package/dist/plugins/grideditor.sections.min.js.map +7 -1
  71. package/dist/plugins/grideditor.spacing.esm.js +318 -0
  72. package/dist/plugins/grideditor.spacing.js +296 -272
  73. package/dist/plugins/grideditor.spacing.min.js +1 -2
  74. package/dist/plugins/grideditor.spacing.min.js.map +7 -1
  75. package/dist/plugins/grideditor.summernote.esm.js +509 -0
  76. package/dist/plugins/grideditor.summernote.js +493 -427
  77. package/dist/plugins/grideditor.summernote.min.js +1 -2
  78. package/dist/plugins/grideditor.summernote.min.js.map +7 -1
  79. package/dist/plugins/grideditor.tabs.esm.js +237 -0
  80. package/dist/plugins/grideditor.tabs.js +233 -139
  81. package/dist/plugins/grideditor.tabs.min.js +1 -2
  82. package/dist/plugins/grideditor.tabs.min.js.map +7 -1
  83. package/dist/plugins/grideditor.textalign.esm.js +40 -0
  84. package/dist/plugins/grideditor.textalign.js +43 -56
  85. package/dist/plugins/grideditor.textalign.min.js +1 -2
  86. package/dist/plugins/grideditor.textalign.min.js.map +7 -1
  87. package/dist/plugins/grideditor.tinymce.esm.js +519 -0
  88. package/dist/plugins/grideditor.tinymce.js +502 -490
  89. package/dist/plugins/grideditor.tinymce.min.js +1 -2
  90. package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
  91. package/dist/plugins/grideditor.visibility.esm.js +158 -0
  92. package/dist/plugins/grideditor.visibility.js +140 -149
  93. package/dist/plugins/grideditor.visibility.min.js +1 -2
  94. package/dist/plugins/grideditor.visibility.min.js.map +7 -1
  95. package/docs/events.md +47 -21
  96. package/docs/locale-keys.md +6 -0
  97. package/docs/plugins.md +47 -25
  98. package/example/adapter.html +112 -0
  99. package/example/attributes.html +85 -61
  100. package/example/autocols.html +9 -9
  101. package/example/autosave.html +13 -14
  102. package/example/basic.html +4 -5
  103. package/example/breakpoints.html +5 -6
  104. package/example/ckeditor.html +4 -5
  105. package/example/clipboard.html +11 -10
  106. package/example/codemirror.html +9 -7
  107. package/example/containers.html +7 -8
  108. package/example/custom_editor.html +53 -34
  109. package/example/elements.html +10 -11
  110. package/example/index.html +16 -2
  111. package/example/locale.html +6 -7
  112. package/example/plugins.html +44 -29
  113. package/example/summernote.html +6 -5
  114. package/example/utilities.html +17 -13
  115. package/example/wrap_content.html +9 -9
  116. package/package.json +43 -12
  117. package/src/js/dom.js +401 -0
  118. package/src/js/grideditor.classic.js +16 -0
  119. package/src/js/grideditor.jquery.js +325 -0
  120. package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
  121. package/src/js/locales/grideditor.es.js +163 -156
  122. package/src/js/plugins/grideditor.accordion.js +97 -77
  123. package/src/js/plugins/grideditor.alignment.js +5 -7
  124. package/src/js/plugins/grideditor.card.js +23 -23
  125. package/src/js/plugins/grideditor.ckeditor.js +107 -106
  126. package/src/js/plugins/grideditor.clipboard.js +49 -37
  127. package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
  128. package/src/js/plugins/grideditor.codemirror.js +9 -10
  129. package/src/js/plugins/grideditor.elements.js +57 -33
  130. package/src/js/plugins/grideditor.float.js +4 -6
  131. package/src/js/plugins/grideditor.gutters.js +20 -15
  132. package/src/js/plugins/grideditor.order.js +28 -25
  133. package/src/js/plugins/grideditor.popup.js +63 -51
  134. package/src/js/plugins/grideditor.sections.js +39 -32
  135. package/src/js/plugins/grideditor.spacing.js +42 -45
  136. package/src/js/plugins/grideditor.summernote.js +112 -76
  137. package/src/js/plugins/grideditor.tabs.js +65 -57
  138. package/src/js/plugins/grideditor.textalign.js +4 -6
  139. package/src/js/plugins/grideditor.tinymce.js +147 -139
  140. package/src/js/plugins/grideditor.visibility.js +24 -25
  141. package/src/js/register.js +18 -0
  142. package/src/js/text/grideditor.text.js +77 -56
  143. package/types/grideditor.d.ts +335 -0
  144. package/dist/jquery.grideditor.bundle.min.js +0 -10
  145. package/dist/jquery.grideditor.js +0 -4927
  146. package/dist/jquery.grideditor.min.js +0 -2
  147. package/dist/jquery.grideditor.min.js.map +0 -1
@@ -1,299 +1,323 @@
1
- /**
2
- * Spacing for grid-editor.
3
- *
4
- * A utility plugin: load this file after the editor and every row, column,
5
- * element and container can have its padding and margin set per breakpoint,
6
- * with Bootstrap's p-{breakpoint}-*, pt-, px- … and m-{breakpoint}-*, mt-, mx-
7
- * … classes. What it can ask the editor for is the handle its factory is
8
- * called with, described in docs/plugins.md.
9
- *
10
- * <script src="dist/jquery.grideditor.min.js"></script>
11
- * <script src="dist/plugins/grideditor.spacing.min.js"></script>
12
- *
13
- * Fourteen families would be fourteen fields, so the panel has two, padding
14
- * and margin, each a choice of side and a value for that side.
15
- *
16
- * utilities.spacing.values narrows the values offered, and
17
- * utilities.spacing.scale is what 0 to 5 come to, for a page that changed
18
- * Bootstrap's $spacers.
19
- */
20
- (function($) {
21
-
22
- $.extend($.fn.gridEditor.locales.en, {
23
- 'utility.padding': 'Padding',
24
- 'utility.margin': 'Margin',
25
- 'utility.side_all': 'All sides',
26
- 'utility.side_x': 'Left and right',
27
- 'utility.side_y': 'Top and bottom',
28
- 'utility.side_t': 'Top',
29
- 'utility.side_b': 'Bottom',
30
- 'utility.side_s': 'Start',
31
- 'utility.side_e': 'End',
32
- 'utility.spacing_gutter': 'A column\'s side padding is its gutter: changing it changes the gutter',
33
- });
34
-
35
- var VALUES = ['0', '1', '2', '3', '4', '5'];
36
-
37
- /** Bootstrap's $spacers. */
38
- var SCALE = ['0', '.25rem', '.5rem', '1rem', '1.5rem', '3rem'];
39
-
40
- /**
41
- * The sides, in the order Bootstrap's css writes their rules: within one
42
- * breakpoint a later rule wins, so p-3 pt-1 has a top of .25rem.
43
- */
44
- var SIDES = ['', 'x', 'y', 't', 'e', 'b', 's'];
45
-
46
- /** What each side sets. Start and end are left and right: Bootstrap's css is left to right. */
47
- var SET = {
48
- '': ['top', 'right', 'bottom', 'left'],
49
- x: ['left', 'right'],
50
- y: ['top', 'bottom'],
51
- t: ['top'],
52
- e: ['right'],
53
- b: ['bottom'],
54
- s: ['left'],
55
- };
56
-
57
- var INFIXES = ['', 'sm', 'md', 'lg', 'xl', 'xxl'];
58
-
59
- var PROPERTIES = { p: 'padding', m: 'margin' };
60
-
61
- /** Every class of the plugin's, padding or margin. */
62
- function pattern(key) {
63
- return new RegExp('^' + key + '[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$');
64
- }
65
-
66
- $.fn.gridEditor.utilities.spacing = function(ge) {
67
-
68
- var options = $.extend({ values: VALUES, scale: SCALE }, ge.settings.utilities.spacing);
69
- var patterns = { p: pattern('p'), m: pattern('m') };
70
-
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/plugins/grideditor.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
+ GridEditor.utilities.spacing = function(ge) {
128
+ var options = Object.assign({ values: VALUES, scale: SCALE }, ge.settings.utilities.spacing);
129
+ var patterns = { p: pattern("p"), m: pattern("m") };
71
130
  function applies(node, kind) {
72
- return kind === 'row' || kind === 'column' || kind === 'element' ||
73
- node.is('[data-ge-container]');
131
+ return kind === "row" || kind === "column" || kind === "element" || is(node, "[data-ge-container]");
74
132
  }
75
-
76
133
  function classes(node) {
77
- return (node.attr('class') || '').split(/\s+/);
134
+ return (node.getAttribute("class") || "").split(/\s+/);
78
135
  }
79
-
80
136
  function carries(node, key) {
81
- return classes(node).some(function(name) { return patterns[key].test(name); });
137
+ return classes(node).some(function(name) {
138
+ return patterns[key].test(name);
139
+ });
82
140
  }
83
-
84
- /**
85
- * The class of one family that decides a side at a breakpoint: the
86
- * widest breakpoint up to it that has one, as { tier, value }.
87
- */
88
141
  function source(node, family, tier) {
89
- var names = classes(node);
90
- var values = family.charAt(0) === 'm' ? VALUES.concat(['auto']) : VALUES;
91
-
92
- for (var i = tier; i >= 0; i--) {
93
- for (var v = 0; v < values.length; v++) {
94
- var name = family + (INFIXES[i] ? '-' + INFIXES[i] : '') + '-' + values[v];
95
- if (names.indexOf(name) !== -1) { return { tier: i, value: values[v] }; }
96
- }
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
+ }
97
150
  }
98
-
99
- return null;
151
+ }
152
+ return null;
100
153
  }
101
-
102
- /**
103
- * What padding or margin is on each side with none of the plugin's
104
- * classes: the editor's frame for a row or a column, the host's css
105
- * for anything else. Read by taking the classes off for a moment,
106
- * since that is the only way to ask the browser.
107
- */
108
154
  function without(node, key) {
109
- var original = node.attr('class');
110
- var style;
111
- var bare = {};
112
-
113
- node.attr('class', classes(node).filter(function(name) { return !patterns[key].test(name); }).join(' '));
114
- style = getComputedStyle(node[0]);
115
- ['top', 'right', 'bottom', 'left'].forEach(function(side) {
116
- bare[side] = style.getPropertyValue(PROPERTIES[key] + '-' + side);
117
- });
118
- node.attr('class', original);
119
-
120
- return bare;
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;
121
171
  }
122
-
123
- /**
124
- * Each side the way Bootstrap's css settles it: the class from the
125
- * widest breakpoint wins, and within one breakpoint the side written
126
- * later in the css. A side no class reaches shows what it is without
127
- * any, over a wider breakpoint's class that is live in a wide window.
128
- */
129
172
  function sides(node, key, breakpoint) {
130
- var tier = ge.breakpoints.indexOf(breakpoint);
131
- var winners = {};
132
- var styles = {};
133
- var neutral = null;
134
-
135
- SIDES.forEach(function(side, order) {
136
- var found = source(node, key + side, tier);
137
- if (!found) { return; }
138
-
139
- SET[side].forEach(function(set) {
140
- var current = winners[set];
141
- if (!current || found.tier > current.tier || (found.tier === current.tier && order > current.order)) {
142
- winners[set] = { tier: found.tier, order: order, value: found.value };
143
- }
144
- });
145
- });
146
-
147
- ['top', 'right', 'bottom', 'left'].forEach(function(set) {
148
- var winner = winners[set];
149
-
150
- if (!winner) {
151
- neutral = neutral || without(node, key);
152
- styles[PROPERTIES[key] + '-' + set] = neutral[set];
153
- } else {
154
- styles[PROPERTIES[key] + '-' + set] = winner.value === 'auto' ? 'auto' : options.scale[winner.value];
155
- }
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
+ }
156
187
  });
157
-
158
- return styles;
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;
159
199
  }
160
-
161
- /** The side a group's select starts on: the first that has a class, or all. */
162
200
  function startingSide(node, key) {
163
- var names = classes(node).filter(function(name) { return patterns[key].test(name); });
164
- var found = SIDES.filter(function(side) {
165
- return names.some(function(name) { return name.indexOf(key + side + '-') === 0; });
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;
166
207
  });
167
-
168
- return found.length ? found[0] : '';
208
+ });
209
+ return found.length ? found[0] : "";
169
210
  }
170
-
171
211
  function sideLabel(side) {
172
- switch (side) {
173
- case 'x': return ge.t('utility.side_x');
174
- case 'y': return ge.t('utility.side_y');
175
- case 't': return ge.t('utility.side_t');
176
- case 'b': return ge.t('utility.side_b');
177
- case 's': return ge.t('utility.side_s');
178
- case 'e': return ge.t('utility.side_e');
179
- default: return ge.t('utility.side_all');
180
- }
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
+ }
181
228
  }
182
-
183
- /** A padding or margin group: its name, the side, and the field of that side's family. */
184
229
  function group(node, key, labelText) {
185
- var box = $('<div class="ge-spacing-group" />').attr('data-ge-spacing', key);
186
- var side = $('<select class="ge-spacing-side form-select form-select-sm" />');
187
-
188
- $('<span class="ge-utility-label" />').text(labelText).appendTo(box);
189
-
190
- SIDES.forEach(function(value) {
191
- $('<option />').attr('value', value).text(sideLabel(value)).appendTo(side);
192
- });
193
-
194
- var field = ge.utilityField(node, key + startingSide(node, key));
195
-
196
- side.val(field.attr('data-ge-family').slice(1))
197
- .on('change', function() {
198
- var next = ge.utilityField(node, key + this.value);
199
- field.replaceWith(next);
200
- field = next;
201
- })
202
- .appendTo(box)
203
- ;
204
- field.appendTo(box);
205
-
206
- return box;
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;
207
246
  }
208
-
209
- var NODES = '.row, .column, .ge-element, [data-ge-container]';
210
-
211
- /**
212
- * Keep each drawer on its node's edges. A drawer is pulled out over the
213
- * editor's frame by as much as the frame pads the node, and a padding
214
- * class replaces the frame, so a padded node's drawer is pulled out by
215
- * its real padding instead. And a column padded at the sides gets a word
216
- * about what that does to its gutter.
217
- */
247
+ var NODES = ".row, .column, .ge-element, [data-ge-container]";
218
248
  function mark(scope) {
219
- scope.find(NODES).addBack(NODES).each(function() {
220
- var node = $(this);
221
- var drawer = node.children('.ge-tools-drawer');
222
-
223
- if (!drawer.length || !applies(node, ge.kindOf(node))) { return; }
224
-
225
- if (carries(node, 'p')) {
226
- var style = getComputedStyle(node[0]);
227
-
228
- drawer.css({
229
- marginTop: '-' + style.paddingTop,
230
- marginLeft: '-' + style.paddingLeft,
231
- marginRight: '-' + style.paddingRight,
232
- width: 'calc(100% + ' + style.paddingLeft + ' + ' + style.paddingRight + ')',
233
- });
234
- } else {
235
- drawer.css({ marginTop: '', marginLeft: '', marginRight: '', width: '' });
236
- }
237
-
238
- if (node.hasClass('column')) {
239
- drawer.find('.ge-spacing-gutter').toggle(classes(node).some(function(name) {
240
- return /^p[xse]?-/.test(name) && patterns.p.test(name);
241
- }));
242
- }
243
- });
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
+ });
244
274
  }
245
-
246
275
  function families(key, labelKey) {
247
- var values = key === 'm' ? VALUES.concat(['auto']) : VALUES;
248
- var offered = options.values.concat(key === 'm' ? ['auto'] : []);
249
-
250
- return SIDES.map(function(side) {
251
- return {
252
- name: key + side,
253
- prefix: key + side,
254
- values: values,
255
- appliesTo: ['row', 'column', 'text', 'element', 'container'],
256
- labelKey: labelKey,
257
- panel: false,
258
- choices: function() {
259
- return values.filter(function(value) { return offered.indexOf(value) !== -1; });
260
- },
261
- };
262
- });
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
+ });
263
293
  }
264
-
265
294
  return {
266
- families: families('p', 'utility.padding').concat(families('m', 'utility.margin')),
267
-
268
- panel: function(node, kind) {
269
- if (!applies(node, kind)) { return null; }
270
-
271
- var box = $('<div class="ge-spacing" />')
272
- .append(group(node, 'p', ge.t('utility.padding')))
273
- .append(group(node, 'm', ge.t('utility.margin')))
274
- ;
275
-
276
- if (kind === 'column') {
277
- $('<small class="ge-spacing-gutter" />').text(ge.t('utility.spacing_gutter')).appendTo(box);
278
- }
279
-
280
- return box;
281
- },
282
-
283
- preview: function(node, kind, breakpoint) {
284
- if (!applies(node, kind)) { return {}; }
285
-
286
- var styles = {};
287
-
288
- ['p', 'm'].forEach(function(key) {
289
- if (carries(node, key)) { $.extend(styles, sides(node, key, breakpoint)); }
290
- });
291
-
292
- return styles;
293
- },
294
-
295
- onRefresh: mark,
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
296
321
  };
297
- };
298
-
299
- })(jQuery);
322
+ };
323
+ })();