@themarioga/grid-editor 7.2.0 → 7.3.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 (61) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +83 -14
  3. package/UPGRADING.md +31 -0
  4. package/dist/grideditor.bundle.min.js +2 -2
  5. package/dist/grideditor.css +102 -0
  6. package/dist/grideditor.d.ts +18 -0
  7. package/dist/grideditor.esm.js +291 -31
  8. package/dist/grideditor.js +291 -31
  9. package/dist/grideditor.min.css +1 -1
  10. package/dist/grideditor.min.css.map +1 -1
  11. package/dist/grideditor.min.js +1 -1
  12. package/dist/grideditor.min.js.map +3 -3
  13. package/dist/locales/grideditor.es.esm.js +67 -0
  14. package/dist/locales/grideditor.es.js +67 -0
  15. package/dist/locales/grideditor.es.min.js +1 -1
  16. package/dist/locales/grideditor.es.min.js.map +2 -2
  17. package/dist/plugins/grideditor.float.esm.js +10 -1
  18. package/dist/plugins/grideditor.float.js +8 -2
  19. package/dist/plugins/grideditor.float.min.js +1 -1
  20. package/dist/plugins/grideditor.float.min.js.map +4 -4
  21. package/dist/plugins/grideditor.spacing.esm.js +12 -3
  22. package/dist/plugins/grideditor.spacing.js +9 -3
  23. package/dist/plugins/grideditor.spacing.min.js +1 -1
  24. package/dist/plugins/grideditor.spacing.min.js.map +4 -4
  25. package/dist/plugins/grideditor.style.esm.js +1593 -0
  26. package/dist/plugins/grideditor.style.js +1592 -0
  27. package/dist/plugins/grideditor.style.min.js +2 -0
  28. package/dist/plugins/grideditor.style.min.js.map +7 -0
  29. package/dist/plugins/grideditor.textalign.esm.js +10 -1
  30. package/dist/plugins/grideditor.textalign.js +8 -2
  31. package/dist/plugins/grideditor.textalign.min.js +1 -1
  32. package/dist/plugins/grideditor.textalign.min.js.map +4 -4
  33. package/dist/plugins/grideditor.visibility.esm.js +12 -3
  34. package/dist/plugins/grideditor.visibility.js +9 -3
  35. package/dist/plugins/grideditor.visibility.min.js +1 -1
  36. package/dist/plugins/grideditor.visibility.min.js.map +4 -4
  37. package/docs/locale-keys.md +86 -7
  38. package/docs/plugins.md +49 -5
  39. package/example/index.html +14 -0
  40. package/example/style.html +151 -0
  41. package/example/utilities.html +15 -11
  42. package/package.json +1 -1
  43. package/src/js/grideditor.js +365 -27
  44. package/src/js/locales/grideditor.es.js +67 -0
  45. package/src/js/plugins/grideditor.float.js +8 -33
  46. package/src/js/plugins/grideditor.spacing.js +8 -273
  47. package/src/js/plugins/grideditor.style.js +179 -0
  48. package/src/js/plugins/grideditor.textalign.js +8 -39
  49. package/src/js/plugins/grideditor.visibility.js +8 -147
  50. package/src/js/style/accordion.js +157 -0
  51. package/src/js/style/catalog.js +76 -0
  52. package/src/js/style/custom.js +84 -0
  53. package/src/js/style/fields.js +382 -0
  54. package/src/js/style/float.js +46 -0
  55. package/src/js/style/options.js +75 -0
  56. package/src/js/style/sections.js +271 -0
  57. package/src/js/style/spacing.js +286 -0
  58. package/src/js/style/textalign.js +52 -0
  59. package/src/js/style/visibility.js +160 -0
  60. package/src/less/grideditor.less +111 -0
  61. package/types/grideditor.d.ts +18 -0
@@ -160,6 +160,73 @@ GridEditor.locales.es = {
160
160
  'utility.float_end': 'Fin',
161
161
  'utility.float_none': 'Ninguno',
162
162
  'utility.spacing_gutter': 'El relleno lateral de una columna es su espaciado: cambiarlo cambia el espacio entre columnas',
163
+ 'style.section_title': 'Estilo',
164
+ 'style.dialog_title': 'Estilo: {kind}',
165
+ 'style.section_size': 'Tamaño',
166
+ 'style.section_spacing': 'Espaciado',
167
+ 'style.section_border': 'Borde',
168
+ 'style.section_background': 'Fondo',
169
+ 'style.section_text': 'Texto',
170
+ 'style.section_typography': 'Tipografía',
171
+ 'style.section_display': 'Visualización',
172
+ 'style.section_position': 'Posición',
173
+ 'style.section_custom': 'CSS libre',
174
+ 'style.all_sizes': 'Se aplica a todos los tamaños',
175
+ 'style.overridden': 'La clase {class} tiene prioridad sobre este valor',
176
+ 'style.invalid': 'Esta propiedad no acepta ese valor',
177
+ 'style.catalog': 'Clases de Bootstrap',
178
+ 'style.shadow_x': 'X',
179
+ 'style.shadow_y': 'Y',
180
+ 'style.shadow_blur': 'Desenfoque',
181
+ 'style.shadow_spread': 'Extensión',
182
+ 'style.shadow_color': 'Color',
183
+ 'style.shadow_inset': 'Interior',
184
+ 'style.shadow_text_mode': 'Editar como texto',
185
+ 'style.prop_width': 'Ancho',
186
+ 'style.prop_height': 'Alto',
187
+ 'style.prop_min_width': 'Ancho mínimo',
188
+ 'style.prop_min_height': 'Alto mínimo',
189
+ 'style.prop_max_width': 'Ancho máximo',
190
+ 'style.prop_max_height': 'Alto máximo',
191
+ 'style.prop_margin_top': 'Margen superior',
192
+ 'style.prop_margin_right': 'Margen derecho',
193
+ 'style.prop_margin_bottom': 'Margen inferior',
194
+ 'style.prop_margin_left': 'Margen izquierdo',
195
+ 'style.prop_padding_top': 'Relleno superior',
196
+ 'style.prop_padding_right': 'Relleno derecho',
197
+ 'style.prop_padding_bottom': 'Relleno inferior',
198
+ 'style.prop_padding_left': 'Relleno izquierdo',
199
+ 'style.prop_border_width': 'Grosor del borde',
200
+ 'style.prop_border_style': 'Estilo del borde',
201
+ 'style.prop_border_color': 'Color del borde',
202
+ 'style.prop_border_radius': 'Radio del borde',
203
+ 'style.prop_box_shadow': 'Sombra',
204
+ 'style.prop_background_color': 'Color de fondo',
205
+ 'style.prop_background_image': 'Imagen de fondo',
206
+ 'style.prop_background_size': 'Tamaño del fondo',
207
+ 'style.prop_background_position': 'Posición del fondo',
208
+ 'style.prop_background_repeat': 'Repetición del fondo',
209
+ 'style.prop_color': 'Color',
210
+ 'style.prop_font_size': 'Tamaño de letra',
211
+ 'style.prop_text_align': 'Alineación',
212
+ 'style.prop_text_shadow': 'Sombra del texto',
213
+ 'style.prop_font_family': 'Fuente',
214
+ 'style.prop_font_weight': 'Grosor de letra',
215
+ 'style.prop_font_style': 'Estilo de letra',
216
+ 'style.prop_line_height': 'Interlineado',
217
+ 'style.prop_letter_spacing': 'Espaciado entre letras',
218
+ 'style.prop_text_transform': 'Mayúsculas',
219
+ 'style.prop_text_decoration': 'Decoración',
220
+ 'style.prop_display': 'Display',
221
+ 'style.prop_opacity': 'Opacidad',
222
+ 'style.prop_overflow': 'Desbordamiento',
223
+ 'style.prop_visibility': 'Visibilidad',
224
+ 'style.prop_position': 'Posición',
225
+ 'style.prop_top': 'Arriba',
226
+ 'style.prop_right': 'Derecha',
227
+ 'style.prop_bottom': 'Abajo',
228
+ 'style.prop_left': 'Izquierda',
229
+ 'style.prop_z_index': 'Z-index',
163
230
  'error.sortable_missing': '¡SortableJS no está disponible! Asegúrate de haber cargado el archivo js de Sortable; sin él no se puede arrastrar.',
164
231
  'warning.setting_removed': 'El ajuste {setting} se eliminó en la 4.0. Usa {replacement} en su lugar.',
165
232
  'warning.already_editing': 'Este elemento ya tiene un editor: se devuelve ese, con las opciones con las que se creó.',
@@ -14,41 +14,16 @@
14
14
  *
15
15
  * Elements only. A floated row or column stops being part of the grid, and a
16
16
  * container sits beside the content areas rather than in their text.
17
+ *
18
+ * Deprecated since 7.3, and gone in 8.0: grideditor.style.js carries this
19
+ * plugin's families, and edits them in its own sections. This file is that
20
+ * part on its own, as it was, and says so once per editor. Loaded beside
21
+ * the style plugin, it stands down.
17
22
  */
18
23
  import { GridEditor } from '../grideditor.js';
19
-
20
- Object.assign(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' };
24
+ import { floatPart } from '../style/float.js';
29
25
 
30
26
  GridEditor.utilities.float = function(ge) {
31
-
32
- function label(value) {
33
- if (value === 'start') { return ge.t('utility.float_start'); }
34
- if (value === 'end') { return ge.t('utility.float_end'); }
35
-
36
- return ge.t('utility.float_none');
37
- }
38
-
39
- return {
40
- families: [{
41
- name: 'float',
42
- prefix: 'float',
43
- values: ['start', 'end', 'none'],
44
- appliesTo: ['element'],
45
- labelKey: 'utility.float',
46
- label: label,
47
-
48
- /** With no class applying here, whatever the host's css floats it as. */
49
- preview: function(value, node) {
50
- return { float: value === null ? ge.bareStyle(node, 'float', 'float') : CSS[value] };
51
- },
52
- }],
53
- };
27
+ ge.warn('the "float" plugin is deprecated and will be removed in 8.0: load grideditor.style.js');
28
+ return floatPart(ge);
54
29
  };
@@ -16,281 +16,16 @@
16
16
  * utilities.spacing.values narrows the values offered, and
17
17
  * utilities.spacing.scale is what 0 to 5 come to, for a page that changed
18
18
  * Bootstrap's $spacers.
19
+ *
20
+ * Deprecated since 7.3, and gone in 8.0: grideditor.style.js carries this
21
+ * plugin's families, and edits them in its own sections. This file is that
22
+ * part on its own, as it was, and says so once per editor. Loaded beside
23
+ * the style plugin, it stands down.
19
24
  */
20
25
  import { GridEditor } from '../grideditor.js';
21
- import * as dom from '../dom.js';
22
-
23
- Object.assign(GridEditor.locales.en, {
24
- 'utility.padding': 'Padding',
25
- 'utility.margin': 'Margin',
26
- 'utility.side_all': 'All sides',
27
- 'utility.side_x': 'Left and right',
28
- 'utility.side_y': 'Top and bottom',
29
- 'utility.side_t': 'Top',
30
- 'utility.side_b': 'Bottom',
31
- 'utility.side_s': 'Start',
32
- 'utility.side_e': 'End',
33
- 'utility.spacing_gutter': 'A column\'s side padding is its gutter: changing it changes the gutter',
34
- });
35
-
36
- var VALUES = ['0', '1', '2', '3', '4', '5'];
37
-
38
- /** Bootstrap's $spacers. */
39
- var SCALE = ['0', '.25rem', '.5rem', '1rem', '1.5rem', '3rem'];
40
-
41
- /**
42
- * The sides, in the order Bootstrap's css writes their rules: within one
43
- * breakpoint a later rule wins, so p-3 pt-1 has a top of .25rem.
44
- */
45
- var SIDES = ['', 'x', 'y', 't', 'e', 'b', 's'];
46
-
47
- /** What each side sets. Start and end are left and right: Bootstrap's css is left to right. */
48
- var SET = {
49
- '': ['top', 'right', 'bottom', 'left'],
50
- x: ['left', 'right'],
51
- y: ['top', 'bottom'],
52
- t: ['top'],
53
- e: ['right'],
54
- b: ['bottom'],
55
- s: ['left'],
56
- };
57
-
58
- var INFIXES = ['', 'sm', 'md', 'lg', 'xl', 'xxl'];
59
-
60
- var PROPERTIES = { p: 'padding', m: 'margin' };
61
-
62
- /** Every class of the plugin's, padding or margin. */
63
- function pattern(key) {
64
- return new RegExp('^' + key + '[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$');
65
- }
26
+ import { spacingPart } from '../style/spacing.js';
66
27
 
67
28
  GridEditor.utilities.spacing = function(ge) {
68
-
69
- var options = Object.assign({ values: VALUES, scale: SCALE }, ge.settings.utilities.spacing);
70
- var patterns = { p: pattern('p'), m: pattern('m') };
71
-
72
- function applies(node, kind) {
73
- return kind === 'row' || kind === 'column' || kind === 'element' ||
74
- dom.is(node, '[data-ge-container]');
75
- }
76
-
77
- function classes(node) {
78
- return (node.getAttribute('class') || '').split(/\s+/);
79
- }
80
-
81
- function carries(node, key) {
82
- return classes(node).some(function(name) { return patterns[key].test(name); });
83
- }
84
-
85
- /**
86
- * The class of one family that decides a side at a breakpoint: the
87
- * widest breakpoint up to it that has one, as { tier, value }.
88
- */
89
- function source(node, family, tier) {
90
- var names = classes(node);
91
- var values = family.charAt(0) === 'm' ? VALUES.concat(['auto']) : VALUES;
92
-
93
- for (var i = tier; i >= 0; i--) {
94
- for (var v = 0; v < values.length; v++) {
95
- var name = family + (INFIXES[i] ? '-' + INFIXES[i] : '') + '-' + values[v];
96
- if (names.indexOf(name) !== -1) { return { tier: i, value: values[v] }; }
97
- }
98
- }
99
-
100
- return null;
101
- }
102
-
103
- /**
104
- * What padding or margin is on each side with none of the plugin's
105
- * classes: the editor's frame for a row or a column, the host's css
106
- * for anything else. Read by taking the classes off for a moment,
107
- * since that is the only way to ask the browser.
108
- */
109
- function without(node, key) {
110
- var original = node.getAttribute('class');
111
- var style;
112
- var bare = {};
113
-
114
- node.setAttribute('class', classes(node).filter(function(name) { return !patterns[key].test(name); }).join(' '));
115
- style = getComputedStyle(node);
116
- ['top', 'right', 'bottom', 'left'].forEach(function(side) {
117
- bare[side] = style.getPropertyValue(PROPERTIES[key] + '-' + side);
118
- });
119
- if (original === null) { node.removeAttribute('class'); } else { node.setAttribute('class', original); }
120
-
121
- return bare;
122
- }
123
-
124
- /**
125
- * Each side the way Bootstrap's css settles it: the class from the
126
- * widest breakpoint wins, and within one breakpoint the side written
127
- * later in the css. A side no class reaches shows what it is without
128
- * any, over a wider breakpoint's class that is live in a wide window.
129
- */
130
- function sides(node, key, breakpoint) {
131
- var tier = ge.breakpoints.indexOf(breakpoint);
132
- var winners = {};
133
- var styles = {};
134
- var neutral = null;
135
-
136
- SIDES.forEach(function(side, order) {
137
- var found = source(node, key + side, tier);
138
- if (!found) { return; }
139
-
140
- SET[side].forEach(function(set) {
141
- var current = winners[set];
142
- if (!current || found.tier > current.tier || (found.tier === current.tier && order > current.order)) {
143
- winners[set] = { tier: found.tier, order: order, value: found.value };
144
- }
145
- });
146
- });
147
-
148
- ['top', 'right', 'bottom', 'left'].forEach(function(set) {
149
- var winner = winners[set];
150
-
151
- if (!winner) {
152
- neutral = neutral || without(node, key);
153
- styles[PROPERTIES[key] + '-' + set] = neutral[set];
154
- } else {
155
- styles[PROPERTIES[key] + '-' + set] = winner.value === 'auto' ? 'auto' : options.scale[winner.value];
156
- }
157
- });
158
-
159
- return styles;
160
- }
161
-
162
- /** The side a group's select starts on: the first that has a class, or all. */
163
- function startingSide(node, key) {
164
- var names = classes(node).filter(function(name) { return patterns[key].test(name); });
165
- var found = SIDES.filter(function(side) {
166
- return names.some(function(name) { return name.indexOf(key + side + '-') === 0; });
167
- });
168
-
169
- return found.length ? found[0] : '';
170
- }
171
-
172
- function sideLabel(side) {
173
- switch (side) {
174
- case 'x': return ge.t('utility.side_x');
175
- case 'y': return ge.t('utility.side_y');
176
- case 't': return ge.t('utility.side_t');
177
- case 'b': return ge.t('utility.side_b');
178
- case 's': return ge.t('utility.side_s');
179
- case 'e': return ge.t('utility.side_e');
180
- default: return ge.t('utility.side_all');
181
- }
182
- }
183
-
184
- /** A padding or margin group: its name, the side, and the field of that side's family. */
185
- function group(node, key, labelText) {
186
- var box = dom.element('div', { 'class': 'ge-spacing-group', 'data-ge-spacing': key });
187
- var side = dom.element('select', { 'class': 'ge-spacing-side form-select form-select-sm' });
188
-
189
- box.appendChild(dom.element('span', { 'class': 'ge-utility-label' }, labelText));
190
-
191
- SIDES.forEach(function(value) {
192
- side.appendChild(dom.element('option', { value: value }, sideLabel(value)));
193
- });
194
-
195
- var field = ge.utilityField(node, key + startingSide(node, key));
196
-
197
- side.value = field.getAttribute('data-ge-family').slice(1);
198
- side.addEventListener('change', function() {
199
- var next = ge.utilityField(node, key + this.value);
200
- field.replaceWith(next);
201
- field = next;
202
- });
203
- box.appendChild(side);
204
- box.appendChild(field);
205
-
206
- return box;
207
- }
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
- */
218
- function mark(scope) {
219
- dom.selfAndAll(scope, NODES).forEach(function(node) {
220
- var drawer = dom.child(node, '.ge-tools-drawer');
221
-
222
- if (!drawer || !applies(node, ge.kindOf(node))) { return; }
223
-
224
- if (carries(node, 'p')) {
225
- var style = getComputedStyle(node);
226
-
227
- dom.css(drawer, {
228
- 'margin-top': '-' + style.paddingTop,
229
- 'margin-left': '-' + style.paddingLeft,
230
- 'margin-right': '-' + style.paddingRight,
231
- width: 'calc(100% + ' + style.paddingLeft + ' + ' + style.paddingRight + ')',
232
- });
233
- } else {
234
- dom.css(drawer, { 'margin-top': '', 'margin-left': '', 'margin-right': '', width: '' });
235
- }
236
-
237
- if (dom.hasClass(node, 'column')) {
238
- var padded = classes(node).some(function(name) {
239
- return /^p[xse]?-/.test(name) && patterns.p.test(name);
240
- });
241
- dom.all(drawer, '.ge-spacing-gutter').forEach(function(note) { dom.toggle(note, padded); });
242
- }
243
- });
244
- }
245
-
246
- 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
- });
263
- }
264
-
265
- 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 = dom.element('div', { 'class': 'ge-spacing' });
272
- box.appendChild(group(node, 'p', ge.t('utility.padding')));
273
- box.appendChild(group(node, 'm', ge.t('utility.margin')));
274
-
275
- if (kind === 'column') {
276
- box.appendChild(dom.element('small', { 'class': 'ge-spacing-gutter' }, ge.t('utility.spacing_gutter')));
277
- }
278
-
279
- return box;
280
- },
281
-
282
- preview: function(node, kind, breakpoint) {
283
- if (!applies(node, kind)) { return {}; }
284
-
285
- var styles = {};
286
-
287
- ['p', 'm'].forEach(function(key) {
288
- if (carries(node, key)) { Object.assign(styles, sides(node, key, breakpoint)); }
289
- });
290
-
291
- return styles;
292
- },
293
-
294
- onRefresh: mark,
295
- };
29
+ ge.warn('the "spacing" plugin is deprecated and will be removed in 8.0: load grideditor.style.js');
30
+ return spacingPart(ge, ge.settings.utilities.spacing);
296
31
  };
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Style for grid-editor.
3
+ *
4
+ * A utility plugin: load this file after the editor and every row, column,
5
+ * container, pane, element and section gets a Style accordion in its
6
+ * settings panel - size, spacing, border, background, text, typography,
7
+ * display, position and free css - written to the node's own style
8
+ * attribute, with Bootstrap's classes for each section as chips that put
9
+ * them in the classes field. What it can ask the editor for is the handle
10
+ * its factory is called with, described in docs/plugins.md.
11
+ *
12
+ * <script src="dist/grideditor.min.js"></script>
13
+ * <script src="dist/plugins/grideditor.style.min.js"></script>
14
+ *
15
+ * It carries what the spacing, textalign, visibility and float plugins
16
+ * were up to 7.2: their per breakpoint fields are in its sections rather
17
+ * than in Responsive, and those four files are deprecated. Loaded beside
18
+ * it they stand down, and their names in the plugins setting ask for it.
19
+ *
20
+ * Where the settings panel has no room for it - a popover, inline in the
21
+ * drawer - the accordion opens in a dialog, from a Style button.
22
+ *
23
+ * style.sections chooses the sections, and in each the properties and
24
+ * whether it has a catalog; style.spacing and style.visibility are what
25
+ * utilities.spacing and utilities.visibility were.
26
+ */
27
+ import { GridEditor } from '../grideditor.js';
28
+ import { spacingPart } from '../style/spacing.js';
29
+ import { textalignPart } from '../style/textalign.js';
30
+ import { visibilityPart } from '../style/visibility.js';
31
+ import { floatPart } from '../style/float.js';
32
+ import { resolveOptions } from '../style/options.js';
33
+ import { createAccordion } from '../style/accordion.js';
34
+
35
+ Object.assign(GridEditor.locales.en, {
36
+ 'style.section_title': 'Style',
37
+ 'style.dialog_title': 'Style: {kind}',
38
+ 'style.section_size': 'Size',
39
+ 'style.section_spacing': 'Spacing',
40
+ 'style.section_border': 'Border',
41
+ 'style.section_background': 'Background',
42
+ 'style.section_text': 'Text',
43
+ 'style.section_typography': 'Typography',
44
+ 'style.section_display': 'Display',
45
+ 'style.section_position': 'Position',
46
+ 'style.section_custom': 'Custom css',
47
+ 'style.all_sizes': 'Applies to every size',
48
+ 'style.overridden': 'The class {class} takes priority over this value',
49
+ 'style.invalid': 'Not a value this property takes',
50
+ 'style.catalog': 'Bootstrap classes',
51
+ 'style.shadow_x': 'X',
52
+ 'style.shadow_y': 'Y',
53
+ 'style.shadow_blur': 'Blur',
54
+ 'style.shadow_spread': 'Spread',
55
+ 'style.shadow_color': 'Color',
56
+ 'style.shadow_inset': 'Inset',
57
+ 'style.shadow_text_mode': 'Edit as text',
58
+ 'style.prop_width': 'Width',
59
+ 'style.prop_height': 'Height',
60
+ 'style.prop_min_width': 'Min width',
61
+ 'style.prop_min_height': 'Min height',
62
+ 'style.prop_max_width': 'Max width',
63
+ 'style.prop_max_height': 'Max height',
64
+ 'style.prop_margin_top': 'Margin top',
65
+ 'style.prop_margin_right': 'Margin right',
66
+ 'style.prop_margin_bottom': 'Margin bottom',
67
+ 'style.prop_margin_left': 'Margin left',
68
+ 'style.prop_padding_top': 'Padding top',
69
+ 'style.prop_padding_right': 'Padding right',
70
+ 'style.prop_padding_bottom': 'Padding bottom',
71
+ 'style.prop_padding_left': 'Padding left',
72
+ 'style.prop_border_width': 'Border width',
73
+ 'style.prop_border_style': 'Border style',
74
+ 'style.prop_border_color': 'Border color',
75
+ 'style.prop_border_radius': 'Border radius',
76
+ 'style.prop_box_shadow': 'Shadow',
77
+ 'style.prop_background_color': 'Background color',
78
+ 'style.prop_background_image': 'Background image',
79
+ 'style.prop_background_size': 'Background size',
80
+ 'style.prop_background_position': 'Background position',
81
+ 'style.prop_background_repeat': 'Background repeat',
82
+ 'style.prop_color': 'Color',
83
+ 'style.prop_font_size': 'Font size',
84
+ 'style.prop_text_align': 'Text align',
85
+ 'style.prop_text_shadow': 'Text shadow',
86
+ 'style.prop_font_family': 'Font family',
87
+ 'style.prop_font_weight': 'Font weight',
88
+ 'style.prop_font_style': 'Font style',
89
+ 'style.prop_line_height': 'Line height',
90
+ 'style.prop_letter_spacing': 'Letter spacing',
91
+ 'style.prop_text_transform': 'Text transform',
92
+ 'style.prop_text_decoration': 'Text decoration',
93
+ 'style.prop_display': 'Display',
94
+ 'style.prop_opacity': 'Opacity',
95
+ 'style.prop_overflow': 'Overflow',
96
+ 'style.prop_visibility': 'Visibility',
97
+ 'style.prop_position': 'Position',
98
+ 'style.prop_top': 'Top',
99
+ 'style.prop_right': 'Right',
100
+ 'style.prop_bottom': 'Bottom',
101
+ 'style.prop_left': 'Left',
102
+ 'style.prop_z_index': 'Z-index',
103
+ });
104
+
105
+ var PARTS = ['spacing', 'textalign', 'visibility', 'float'];
106
+
107
+ GridEditor.utilities.style = function(ge) {
108
+
109
+ var options = resolveOptions(ge);
110
+ var parts = {
111
+ spacing: spacingPart(ge, options.spacing),
112
+ textalign: textalignPart(ge),
113
+ visibility: visibilityPart(ge, options.visibility),
114
+ float: floatPart(ge),
115
+ };
116
+ var accordions = []; // { node, accordion } for every panel built since the last init
117
+ var context = {
118
+ sections: options.sections,
119
+ parts: parts,
120
+ state: { open: null },
121
+ opened: function(key) {
122
+ accordions.forEach(function(entry) { entry.accordion.open(key); });
123
+ },
124
+ };
125
+
126
+ /** Every part's hook, called in turn. */
127
+ function each(hook) {
128
+ return function() {
129
+ var args = arguments;
130
+ PARTS.forEach(function(name) {
131
+ if (parts[name][hook]) { parts[name][hook].apply(null, args); }
132
+ });
133
+ };
134
+ }
135
+
136
+ var partsRefresh = each('onRefresh');
137
+
138
+ return {
139
+ // The parts' families, edited in the sections rather than in Responsive
140
+ families: PARTS.reduce(function(all, name) {
141
+ return all.concat(parts[name].families.map(function(family) {
142
+ return Object.assign({}, family, { panel: false });
143
+ }));
144
+ }, []),
145
+
146
+ panelSection: function(node, kind) {
147
+ var accordion = createAccordion(ge, node, kind, context);
148
+ if (!accordion) { return null; }
149
+
150
+ accordions.push({ node: node, accordion: accordion });
151
+
152
+ return { labelKey: 'style.section_title', titleKey: 'style.dialog_title', body: accordion.element };
153
+ },
154
+
155
+ preview: function(node, kind, breakpoint) {
156
+ return parts.spacing.preview(node, kind, breakpoint);
157
+ },
158
+
159
+ // After a write, a change of classes or of view: the accordions of
160
+ // the nodes it touched follow
161
+ onRefresh: function(scope) {
162
+ partsRefresh(scope);
163
+
164
+ accordions = accordions.filter(function(entry) { return entry.accordion.element.isConnected; });
165
+ accordions.forEach(function(entry) {
166
+ if (entry.node === scope || scope.contains(entry.node)) { entry.accordion.render(); }
167
+ });
168
+ },
169
+
170
+ drawerTools: each('drawerTools'),
171
+
172
+ onDeinit: function() {
173
+ each('onDeinit')();
174
+ accordions = [];
175
+ },
176
+ };
177
+ };
178
+
179
+ GridEditor.utilities.style.replaces = PARTS;
@@ -12,47 +12,16 @@
12
12
  *
13
13
  * The class aligns everything inside the node that does not align itself: a
14
14
  * paragraph the rich text editor gave its own text-align keeps it.
15
+ *
16
+ * Deprecated since 7.3, and gone in 8.0: grideditor.style.js carries this
17
+ * plugin's families, and edits them in its own sections. This file is that
18
+ * part on its own, as it was, and says so once per editor. Loaded beside
19
+ * the style plugin, it stands down.
15
20
  */
16
21
  import { GridEditor } from '../grideditor.js';
17
-
18
- Object.assign(GridEditor.locales.en, {
19
- 'utility.text_align': 'Text alignment',
20
- 'utility.text_start': 'Start',
21
- 'utility.text_center': 'Center',
22
- 'utility.text_end': 'End',
23
- });
24
-
25
- /** Start and end are left and right: Bootstrap's css is left to right. */
26
- var CSS = { start: 'left', center: 'center', end: 'right' };
22
+ import { textalignPart } from '../style/textalign.js';
27
23
 
28
24
  GridEditor.utilities.textalign = function(ge) {
29
-
30
- function label(value) {
31
- if (value === 'start') { return ge.t('utility.text_start'); }
32
- if (value === 'center') { return ge.t('utility.text_center'); }
33
-
34
- return ge.t('utility.text_end');
35
- }
36
-
37
- return {
38
- families: [{
39
- name: 'text-align',
40
- prefix: 'text',
41
- values: ['start', 'center', 'end'],
42
- appliesTo: ['row', 'column', 'text', 'element', 'container'],
43
- labelKey: 'utility.text_align',
44
- label: label,
45
-
46
- /**
47
- * With no class applying here, the node aligns as its parent
48
- * does - or as the host's css says - which only the browser can
49
- * tell, so it is asked with the classes out of the way. Parents
50
- * are previewed before their children, so the parent's answer is
51
- * already the view's.
52
- */
53
- preview: function(value, node) {
54
- return { 'text-align': value === null ? ge.bareStyle(node, 'text-align', 'text-align') : CSS[value] };
55
- },
56
- }],
57
- };
25
+ ge.warn('the "textalign" plugin is deprecated and will be removed in 8.0: load grideditor.style.js');
26
+ return textalignPart(ge);
58
27
  };