@themarioga/grid-editor 8.7.1 → 8.8.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.
@@ -32,6 +32,7 @@ var METHODS = {
32
32
  createContainer: { value: true },
33
33
  addTab: { value: true },
34
34
  addAccordionItem: { value: true },
35
+ addPane: { value: true },
35
36
  setLocale: {},
36
37
  getUtility: { value: true },
37
38
  setUtility: { value: true },
@@ -985,6 +986,17 @@ function build(instance, baseElem, optionsOrMethod) {
985
986
  if (fromPlugin) { return fromPlugin; }
986
987
 
987
988
  if (node.getAttribute('data-ge-container')) { return node.getAttribute('data-ge-container'); }
989
+
990
+ // A container plugin's pane, by the class it marks its panes with
991
+ var paneKind = null;
992
+ Object.keys(CONTAINERS).forEach(function(type) {
993
+ var definition = CONTAINERS[type];
994
+ if (!paneKind && definition.paneClass && dom.hasClass(node, definition.paneClass)) {
995
+ paneKind = definition.paneKind;
996
+ }
997
+ });
998
+ if (paneKind) { return paneKind; }
999
+
988
1000
  if (dom.hasClass(node, 'ge-tab')) { return 'tab'; }
989
1001
  if (dom.hasClass(node, 'ge-accordion-item')) { return 'accordion-item'; }
990
1002
  if (dom.hasClass(node, 'row')) { return 'row'; }
@@ -3150,7 +3162,7 @@ function build(instance, baseElem, optionsOrMethod) {
3150
3162
  }
3151
3163
 
3152
3164
  /* --------------------------------------------------------------
3153
- * Containers: tabs, accordions and popups.
3165
+ * Containers: tabs, accordions, popups, carousels and cards.
3154
3166
  *
3155
3167
  * A container holds panes, and a pane is an ordinary canvas region -
3156
3168
  * rows, columns, content areas and elements nest inside one exactly
@@ -3260,6 +3272,7 @@ function build(instance, baseElem, optionsOrMethod) {
3260
3272
  if (definition.addPane) {
3261
3273
  createTool(drawer, t(definition.addPaneKey), 'ge-add-pane', 'bi bi-plus-circle', function() {
3262
3274
  var pane = definition.addPane(container, {});
3275
+ if (!pane) { return; }
3263
3276
 
3264
3277
  addNode(definition.paneKind, pane, function() {}, {
3265
3278
  parent: container,
@@ -3300,33 +3313,41 @@ function build(instance, baseElem, optionsOrMethod) {
3300
3313
  * for its selector to match, so the attribute is moved aside while
3301
3314
  * the editor needs the control not to react, and moved back on the
3302
3315
  * way out.
3316
+ *
3317
+ * The attributes are the ones Bootstrap's data api acts on: the tabs',
3318
+ * accordions' and popups' toggles and dismisses, and a carousel's
3319
+ * slide controls and autoplay.
3303
3320
  */
3321
+ var TOGGLE_ATTRIBUTES = ['toggle', 'dismiss', 'slide', 'slide-to', 'ride'];
3322
+
3304
3323
  function suspendToggles(scope) {
3305
3324
  if (!scope) { return; }
3306
3325
 
3307
- dom.selfAndAll(scope, '[data-bs-toggle], [data-bs-dismiss]').forEach(function(node) {
3308
- ['toggle', 'dismiss'].forEach(function(name) {
3309
- var value = node.getAttribute('data-bs-' + name);
3310
- if (value === null) { return; }
3326
+ dom.selfAndAll(scope, TOGGLE_ATTRIBUTES.map(function(name) { return '[data-bs-' + name + ']'; }).join(', '))
3327
+ .forEach(function(node) {
3328
+ TOGGLE_ATTRIBUTES.forEach(function(name) {
3329
+ var value = node.getAttribute('data-bs-' + name);
3330
+ if (value === null) { return; }
3311
3331
 
3312
- node.setAttribute('data-ge-bs-' + name, value);
3313
- node.removeAttribute('data-bs-' + name);
3332
+ node.setAttribute('data-ge-bs-' + name, value);
3333
+ node.removeAttribute('data-bs-' + name);
3334
+ });
3314
3335
  });
3315
- });
3316
3336
  }
3317
3337
 
3318
3338
  function resumeToggles(scope) {
3319
3339
  if (!scope) { return; }
3320
3340
 
3321
- dom.selfAndAll(scope, '[data-ge-bs-toggle], [data-ge-bs-dismiss]').forEach(function(node) {
3322
- ['toggle', 'dismiss'].forEach(function(name) {
3323
- var value = node.getAttribute('data-ge-bs-' + name);
3324
- if (value === null) { return; }
3341
+ dom.selfAndAll(scope, TOGGLE_ATTRIBUTES.map(function(name) { return '[data-ge-bs-' + name + ']'; }).join(', '))
3342
+ .forEach(function(node) {
3343
+ TOGGLE_ATTRIBUTES.forEach(function(name) {
3344
+ var value = node.getAttribute('data-ge-bs-' + name);
3345
+ if (value === null) { return; }
3325
3346
 
3326
- node.setAttribute('data-bs-' + name, value);
3327
- node.removeAttribute('data-ge-bs-' + name);
3347
+ node.setAttribute('data-bs-' + name, value);
3348
+ node.removeAttribute('data-ge-bs-' + name);
3349
+ });
3328
3350
  });
3329
- });
3330
3351
  }
3331
3352
 
3332
3353
  /**
@@ -4480,6 +4501,11 @@ function build(instance, baseElem, optionsOrMethod) {
4480
4501
 
4481
4502
  if (CONTAINERS[kind] && CONTAINERS[kind].labelKey) { return t(CONTAINERS[kind].labelKey); }
4482
4503
 
4504
+ var paneLabel = Object.keys(CONTAINERS).filter(function(type) {
4505
+ return CONTAINERS[type].paneKind === kind && CONTAINERS[type].paneLabelKey;
4506
+ })[0];
4507
+ if (paneLabel) { return t(CONTAINERS[paneLabel].paneLabelKey); }
4508
+
4483
4509
  switch (kind) {
4484
4510
  case 'row': return t('panel.kind_row');
4485
4511
  case 'column': return t('panel.kind_column');
@@ -5437,6 +5463,7 @@ function build(instance, baseElem, optionsOrMethod) {
5437
5463
  }
5438
5464
 
5439
5465
  var pane = definition.addPane(container, options);
5466
+ if (!pane) { return null; }
5440
5467
 
5441
5468
  return addNode(definition.paneKind, pane, function() {}, {
5442
5469
  parent: container,
@@ -5445,6 +5472,19 @@ function build(instance, baseElem, optionsOrMethod) {
5445
5472
  });
5446
5473
  }
5447
5474
 
5475
+ /** A pane appended to a container of any type that has panes. */
5476
+ function apiAddPane(container, options) {
5477
+ container = nodeFrom(container);
5478
+
5479
+ var type = containerTypeOf(container);
5480
+ if (!CONTAINERS[type] || !CONTAINERS[type].addPane) {
5481
+ warn('addPane: this is not a container with panes');
5482
+ return null;
5483
+ }
5484
+
5485
+ return addPaneTo(container, type, options);
5486
+ }
5487
+
5448
5488
  /**
5449
5489
  * A shallow frozen copy of the settings for the instance, so a host
5450
5490
  * can read what the editor is running with without changing it
@@ -5868,6 +5908,7 @@ function build(instance, baseElem, optionsOrMethod) {
5868
5908
  addAccordionItem: function(container, options) {
5869
5909
  return addPaneTo(container, 'accordion', options);
5870
5910
  },
5911
+ addPane: apiAddPane,
5871
5912
  setLocale: setLocale,
5872
5913
  getUtility: getUtility,
5873
5914
  setUtility: setUtility,
@@ -5930,13 +5971,13 @@ function build(instance, baseElem, optionsOrMethod) {
5930
5971
  GridEditor._created = [];
5931
5972
 
5932
5973
  /**
5933
- * Container plugins: tabs, accordions, popups, and whatever a host writes.
5974
+ * Container plugins: tabs, accordions, popups, carousels, cards, and whatever a host writes.
5934
5975
  *
5935
5976
  * A plugin is a factory registered under the type it builds, called once per
5936
5977
  * editor with the handle described in docs/plugins.md. Loading its file is
5937
5978
  * what makes the type available; the `plugins` setting narrows that list.
5938
5979
  *
5939
- * GridEditor.containers.carousel = function(ge) {
5980
+ * GridEditor.containers.gallery = function(ge) {
5940
5981
  * return { labelKey: ..., create: ..., mark: ..., unmark: ... };
5941
5982
  * };
5942
5983
  */
@@ -97,6 +97,33 @@ GridEditor.locales.es = {
97
97
  'container.tabs_layout_horizontal': 'Horizontal',
98
98
  'container.tabs_layout_vertical': 'Vertical',
99
99
  'container.tabs_layout_vertical_from': 'Vertical desde {breakpoint}',
100
+ 'container.add_carousel': 'Carrusel',
101
+ 'container.add_carousel_item': 'Añadir diapositiva',
102
+ 'confirm.delete_carousel_item': '¿Borrar esta diapositiva y todo lo que contiene?',
103
+ 'panel.kind_carousel_item': 'Diapositiva',
104
+ 'container.carousel_previous': 'Anterior',
105
+ 'container.carousel_next': 'Siguiente',
106
+ 'container.carousel_slide_label': 'Diapositiva {number}',
107
+ 'container.carousel_counter': '{current} / {total}',
108
+ 'tool.carousel_show_previous': 'Diapositiva anterior',
109
+ 'tool.carousel_show_next': 'Diapositiva siguiente',
110
+ 'tool.carousel_move_back': 'Mover atrás',
111
+ 'tool.carousel_move_forward': 'Mover adelante',
112
+ 'container.carousel_section': 'Carrusel',
113
+ 'container.carousel_controls': 'Flechas',
114
+ 'container.carousel_indicators': 'Indicadores',
115
+ 'container.carousel_fade': 'Fundido',
116
+ 'container.carousel_dark': 'Tema oscuro',
117
+ 'container.carousel_ride': 'Autoplay',
118
+ 'container.carousel_ride_no': 'No',
119
+ 'container.carousel_ride_load': 'Al cargar',
120
+ 'container.carousel_ride_interaction': 'Tras la primera interacción',
121
+ 'container.carousel_interval': 'Intervalo (s)',
122
+ 'container.carousel_pause': 'Pausa al pasar el ratón',
123
+ 'container.carousel_wrap': 'Volver al principio',
124
+ 'container.carousel_keyboard': 'Teclado',
125
+ 'container.carousel_touch': 'Táctil',
126
+ 'container.carousel_item_section': 'Diapositiva',
100
127
  'container.add_accordion': 'Acordeón',
101
128
  'container.add_accordion_item': 'Añadir apartado',
102
129
  'container.accordion_label': 'Apartado {number}',