@themarioga/grid-editor 9.0.0-beta.5 → 9.0.0-beta.6

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 (63) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +23 -17
  3. package/UPGRADING.md +24 -5
  4. package/dist/grideditor.bundle.min.js +3 -3
  5. package/dist/grideditor.css +5 -4
  6. package/dist/grideditor.d.ts +6 -18
  7. package/dist/grideditor.esm.js +122 -100
  8. package/dist/grideditor.jquery.js +1 -3
  9. package/dist/grideditor.jquery.min.js +1 -1
  10. package/dist/grideditor.jquery.min.js.map +2 -2
  11. package/dist/grideditor.js +122 -100
  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/plugins/grideditor.accordion.esm.js +7 -0
  17. package/dist/plugins/grideditor.accordion.js +7 -0
  18. package/dist/plugins/grideditor.accordion.min.js +1 -1
  19. package/dist/plugins/grideditor.accordion.min.js.map +3 -3
  20. package/dist/plugins/grideditor.card.esm.js +4 -0
  21. package/dist/plugins/grideditor.card.js +4 -0
  22. package/dist/plugins/grideditor.card.min.js +1 -1
  23. package/dist/plugins/grideditor.card.min.js.map +3 -3
  24. package/dist/plugins/grideditor.carousel.esm.js +4 -0
  25. package/dist/plugins/grideditor.carousel.js +4 -0
  26. package/dist/plugins/grideditor.carousel.min.js +1 -1
  27. package/dist/plugins/grideditor.carousel.min.js.map +2 -2
  28. package/dist/plugins/grideditor.clipboard.esm.js +3 -18
  29. package/dist/plugins/grideditor.clipboard.js +3 -18
  30. package/dist/plugins/grideditor.clipboard.min.js +1 -1
  31. package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
  32. package/dist/plugins/grideditor.history.esm.js +1 -6
  33. package/dist/plugins/grideditor.history.js +1 -6
  34. package/dist/plugins/grideditor.history.min.js +1 -1
  35. package/dist/plugins/grideditor.history.min.js.map +3 -3
  36. package/dist/plugins/grideditor.offcanvas.esm.js +4 -0
  37. package/dist/plugins/grideditor.offcanvas.js +4 -0
  38. package/dist/plugins/grideditor.offcanvas.min.js +1 -1
  39. package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
  40. package/dist/plugins/grideditor.popup.esm.js +4 -0
  41. package/dist/plugins/grideditor.popup.js +4 -0
  42. package/dist/plugins/grideditor.popup.min.js +1 -1
  43. package/dist/plugins/grideditor.popup.min.js.map +3 -3
  44. package/dist/plugins/grideditor.tabs.esm.js +4 -0
  45. package/dist/plugins/grideditor.tabs.js +4 -0
  46. package/dist/plugins/grideditor.tabs.min.js +1 -1
  47. package/dist/plugins/grideditor.tabs.min.js.map +2 -2
  48. package/docs/events.md +8 -11
  49. package/docs/plugins.md +10 -8
  50. package/example/clipboard.html +13 -10
  51. package/package.json +1 -1
  52. package/src/js/grideditor.jquery.js +0 -2
  53. package/src/js/grideditor.js +177 -110
  54. package/src/js/plugins/grideditor.accordion.js +9 -0
  55. package/src/js/plugins/grideditor.card.js +5 -0
  56. package/src/js/plugins/grideditor.carousel.js +5 -0
  57. package/src/js/plugins/grideditor.clipboard.js +11 -24
  58. package/src/js/plugins/grideditor.history.js +3 -6
  59. package/src/js/plugins/grideditor.offcanvas.js +5 -0
  60. package/src/js/plugins/grideditor.popup.js +5 -0
  61. package/src/js/plugins/grideditor.tabs.js +5 -0
  62. package/src/less/grideditor.less +5 -4
  63. package/types/grideditor.d.ts +6 -18
@@ -586,13 +586,14 @@ html.ge-sidebar-open {
586
586
  outline: 2px solid var(--bs-primary, #0d6efd);
587
587
  outline-offset: 1px;
588
588
  }
589
- /* Where the toolbar's buttons add, with active_target. A node that is both
590
- shows both: this one a little further out */
591
- .ge-canvas.ge-editing .ge-active-target {
589
+ /* The target, with active_target: where the toolbar's buttons add and what
590
+ the sidebar shows. A node that also has its panel open shows both: this
591
+ one a little further out */
592
+ .ge-canvas.ge-editing .ge-selected {
592
593
  outline: 2px dashed var(--bs-success, #198754);
593
594
  outline-offset: -2px;
594
595
  }
595
- .ge-canvas.ge-editing .ge-active-target.ge-settings-target {
596
+ .ge-canvas.ge-editing .ge-selected.ge-settings-target {
596
597
  box-shadow: 0 0 0 4px var(--bs-success, #198754);
597
598
  }
598
599
  /* While editing */
@@ -190,7 +190,7 @@ export interface GridEditorOptions {
190
190
  drawer_overflow?: 'menu' | 'wrap';
191
191
  /** The add buttons in categories - rows, content, and a plugin's own - one shown at a time, chosen with tabs. Default false. */
192
192
  toolbar_groups?: boolean;
193
- /** A click in a column or a section makes it where the toolbar's buttons add. Default false, and true with settings_panel 'sidebar', which throws if it is given false. */
193
+ /** A click on any node with settings - a row, a column, a container, a text - makes it the target: where the toolbar's buttons add, and what the sidebar shows. Default false, and true with settings_panel 'sidebar', which throws if it is given false. */
194
194
  active_target?: boolean;
195
195
  /** The plugins to use, of any kind; null is every one loaded. */
196
196
  plugins?: string[] | null;
@@ -209,7 +209,7 @@ export interface GridEditorOptions {
209
209
  elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
210
210
  /** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
211
211
  autosave?: AutosaveOptions;
212
- /** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the node selected or the target; default active_target. */
212
+ /** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the active target; default active_target. */
213
213
  clipboard?: { shortcuts?: boolean };
214
214
  /** The history plugin: undo and redo. */
215
215
  history?: HistoryOptions;
@@ -230,7 +230,7 @@ export interface GridEditorOptions {
230
230
  locale_strings?: Record<string, string>;
231
231
  callbacks?: Partial<GridEditorCallbacks>;
232
232
  confirm_delete?: boolean;
233
- /** Where a node's settings open. 'sidebar' is a panel that stays on the right while editing, showing the selected node's; one editor per page has it. It turns active_target on, and the constructor throws a TypeError if active_target is false. */
233
+ /** Where a node's settings open. 'sidebar' is a panel that stays on the right while editing, showing the active target's; one editor per page has it. It turns active_target on, and the constructor throws a TypeError if active_target is false. */
234
234
  settings_panel?: 'offcanvas' | 'popover' | 'modal' | 'inline' | 'sidebar';
235
235
  /** The 'sidebar' panel. */
236
236
  sidebar?: SidebarSettings;
@@ -389,7 +389,7 @@ export interface ViewChangePayload {
389
389
  to: View;
390
390
  }
391
391
 
392
- /** The active target changed: the column or region the toolbar adds to, or null for the canvas. */
392
+ /** The active target changed: the node the toolbar adds to and the sidebar shows - any with settings - or null for the canvas. */
393
393
  export interface TargetChangePayload {
394
394
  canvas: HTMLElement;
395
395
  target: HTMLElement | null;
@@ -402,13 +402,6 @@ export interface PreviewChangePayload {
402
402
  previewing: boolean;
403
403
  }
404
404
 
405
- /** The selection changed, with settings_panel 'sidebar': the node whose settings the sidebar shows, or null. */
406
- export interface SelectionChangePayload {
407
- canvas: HTMLElement;
408
- node: HTMLElement | null;
409
- from: HTMLElement | null;
410
- }
411
-
412
405
  /** The events, by name, with their payloads. Adding fires a specific name and the generic one. */
413
406
  export interface GridEditorEventMap {
414
407
  'grideditor:before-add': Payload;
@@ -451,7 +444,6 @@ export interface GridEditorEventMap {
451
444
  'grideditor:view-change': ViewChangePayload;
452
445
  'grideditor:preview-change': PreviewChangePayload;
453
446
  'grideditor:target-change': TargetChangePayload;
454
- 'grideditor:selection-change': SelectionChangePayload;
455
447
  'grideditor:after-autosave': AutosavePayload;
456
448
  'grideditor:after-restore-draft': RestoreDraftPayload;
457
449
  'grideditor:autosave-error': AutosaveErrorPayload;
@@ -562,14 +554,10 @@ export declare class GridEditor {
562
554
  /** Take the editor off: the markup stays, everything else goes. */
563
555
  destroy(): this;
564
556
  changeView(view: View): this;
565
- /** The column or region the toolbar adds to, or null. Null without active_target, which settings_panel 'sidebar' turns on. */
557
+ /** The node the toolbar adds to, and the sidebar shows, or null: any node with settings, a row, a column, a container, a text. Null without active_target, which settings_panel 'sidebar' turns on. */
566
558
  getActiveTarget(): HTMLElement | null;
567
- /** Make a column or region, or the first a selector matches, where the toolbar adds; null for none. */
559
+ /** Make a node with settings, or the first a selector matches, the one the toolbar adds to; null for none. */
568
560
  setActiveTarget(target: HTMLElement | string | null): this;
569
- /** The node whose settings the sidebar shows, or null. Null unless settings_panel is 'sidebar'. */
570
- getSelected(): HTMLElement | null;
571
- /** Select a node with settings, or the first a selector matches, or null for none. Does nothing unless settings_panel is 'sidebar'. */
572
- setSelected(node: HTMLElement | string | null): this;
573
561
  getView(): View;
574
562
  setLocale(code: string): this;
575
563
  createRow(layout?: RowLayout, options?: Placement): HTMLElement | null;
@@ -328,9 +328,7 @@ var METHODS = {
328
328
  getUtility: { value: true },
329
329
  setUtility: { value: true },
330
330
  getActiveTarget: { value: true },
331
- setActiveTarget: {},
332
- getSelected: { value: true },
333
- setSelected: {}
331
+ setActiveTarget: {}
334
332
  };
335
333
  var PLACEMENTS = ["appendTo", "prependTo", "insertAfter", "insertBefore"];
336
334
  var REFERENCES = [
@@ -686,7 +684,6 @@ function build(instance, baseElem, optionsOrMethod) {
686
684
  var sortables = [];
687
685
  var instanceId = ++editorCounter;
688
686
  var destroyed = false;
689
- var selected = null;
690
687
  var sidebarCollapsed = null;
691
688
  var pluginHandle = null;
692
689
  if (settings.settings_panel === "sidebar") {
@@ -1129,8 +1126,7 @@ function build(instance, baseElem, optionsOrMethod) {
1129
1126
  var signal = { signal: lifetime.signal };
1130
1127
  window.addEventListener("scroll", onScroll, signal);
1131
1128
  delegate(canvas, "click", ".ge-content", onContentClick, signal);
1132
- var sidebarMode = panelMode() === "sidebar";
1133
- if (settings.active_target || sidebarMode) {
1129
+ if (settings.active_target) {
1134
1130
  var pressed = null;
1135
1131
  canvas.addEventListener("pointerdown", function(e) {
1136
1132
  pressed = { x: e.clientX, y: e.clientY };
@@ -1144,12 +1140,7 @@ function build(instance, baseElem, optionsOrMethod) {
1144
1140
  if (from && Math.abs(e.clientX - from.x) + Math.abs(e.clientY - from.y) > settings.drag.threshold) {
1145
1141
  return;
1146
1142
  }
1147
- if (settings.active_target) {
1148
- clickTarget(e);
1149
- }
1150
- if (sidebarMode && canvas.contains(e.target)) {
1151
- changeSelection(settingsNodeAt(e.target));
1152
- }
1143
+ clickTarget(e);
1153
1144
  }, signal);
1154
1145
  document.addEventListener("keydown", function(e) {
1155
1146
  if (e.key !== "Escape" || openSettingsState || dialogState) {
@@ -1162,23 +1153,28 @@ function build(instance, baseElem, optionsOrMethod) {
1162
1153
  if (focus && (is(focus, "input, textarea, select") || focus.isContentEditable)) {
1163
1154
  return;
1164
1155
  }
1165
- if (selected && isEditing()) {
1166
- changeSelection(null);
1167
- } else if (activeTarget) {
1156
+ if (activeTarget) {
1168
1157
  changeTarget(null);
1169
1158
  }
1170
1159
  }, signal);
1171
- }
1172
- if (sidebarMode) {
1173
1160
  canvas.addEventListener("focusin", function(e) {
1174
1161
  var node = isEditing() ? settingsNodeAt(e.target) : null;
1175
1162
  if (node) {
1176
- changeSelection(node);
1163
+ changeTarget(node);
1177
1164
  }
1178
1165
  }, signal);
1166
+ var pressedOn = null;
1167
+ document.addEventListener("pointerdown", function(e) {
1168
+ pressedOn = e.target;
1169
+ }, { capture: true, signal: signal.signal });
1179
1170
  document.addEventListener("click", function(e) {
1180
1171
  var target = e.target;
1181
- if (!selected || !isEditing() || !target || target.nodeType !== 1) {
1172
+ var from = pressedOn;
1173
+ pressedOn = null;
1174
+ if (!activeTarget || !isEditing() || !target || target.nodeType !== 1) {
1175
+ return;
1176
+ }
1177
+ if (from && from.nodeType === 1 && (canvas.contains(from) || closest(from, EDITOR_CONTROLS))) {
1182
1178
  return;
1183
1179
  }
1184
1180
  if (!attached(target) || canvas.contains(target)) {
@@ -1187,17 +1183,22 @@ function build(instance, baseElem, optionsOrMethod) {
1187
1183
  if (closest(target, EDITOR_CONTROLS) || canvas.querySelector(".ge-rte-active")) {
1188
1184
  return;
1189
1185
  }
1190
- changeSelection(null);
1186
+ changeTarget(null);
1191
1187
  }, signal);
1188
+ }
1189
+ if (panelMode() === "sidebar") {
1192
1190
  window.addEventListener("resize", reserveSidebarRoom, signal);
1193
1191
  }
1194
1192
  function clickTarget(e) {
1195
- var region = closest(e.target, targetSelector());
1196
- if (region && region === activeTarget && (e.target === region || e.target === child(region, ".ge-tools-drawer"))) {
1193
+ if (!canvas.contains(e.target)) {
1194
+ return;
1195
+ }
1196
+ var node = settingsNodeAt(e.target);
1197
+ if (node && node === activeTarget && (e.target === drawerOf(node) || e.target === node && !hasClass(node, "ge-content"))) {
1197
1198
  changeTarget(null);
1198
1199
  return;
1199
1200
  }
1200
- changeTarget(region && region !== canvas && canvas.contains(region) ? region : null);
1201
+ changeTarget(node);
1201
1202
  }
1202
1203
  }
1203
1204
  function textReady(block) {
@@ -1682,13 +1683,11 @@ function build(instance, baseElem, optionsOrMethod) {
1682
1683
  }
1683
1684
  var placed = made;
1684
1685
  if (item.inColumn) {
1685
- if (!is(where.region, ".column")) {
1686
- placed = inRowOfItsOwn(made);
1687
- }
1686
+ placed = wrapFor(where.region, made);
1688
1687
  } else if (!acceptsBlock(where.region, made)) {
1689
- var ancestors = where.region === canvas ? [] : parentsUntil(where.region, canvas).reverse().concat([where.region]);
1690
- var top = ancestors[0] || null;
1691
- where = { region: canvas, before: top ? top.nextElementSibling : null };
1688
+ where = canvasAfterTopOf(where.region);
1689
+ } else if (is(where.region, ".row")) {
1690
+ placed = wrapFor(where.region, made);
1692
1691
  }
1693
1692
  return addNode(item.kind, made, function() {
1694
1693
  if (where.before) {
@@ -1698,10 +1697,32 @@ function build(instance, baseElem, optionsOrMethod) {
1698
1697
  }
1699
1698
  }, { parent: where.region, source: item.source || source || "dragdrop" });
1700
1699
  }
1700
+ function canvasAfterTopOf(region) {
1701
+ var ancestors = region === canvas ? [] : parentsUntil(region, canvas).reverse().concat([region]);
1702
+ var top = ancestors[0] || null;
1703
+ return { region: canvas, before: top ? top.nextElementSibling : null };
1704
+ }
1705
+ function placeInTarget(node, kind, source) {
1706
+ if (!activeTarget) {
1707
+ return null;
1708
+ }
1709
+ var where = { region: effectiveRegion(activeTarget), before: null };
1710
+ var placed = wrapFor(where.region, node);
1711
+ var holder = placed === node ? null : node.parentElement;
1712
+ if (!acceptsBlock(where.region, placed) || holder && !acceptsBlock(holder, node)) {
1713
+ where = canvasAfterTopOf(where.region);
1714
+ placed = node;
1715
+ }
1716
+ return addNode(kind, node, function() {
1717
+ if (where.before) {
1718
+ where.before.parentNode.insertBefore(placed, where.before);
1719
+ } else {
1720
+ where.region.appendChild(placed);
1721
+ }
1722
+ }, { parent: where.region, source: source || "api" });
1723
+ }
1701
1724
  function inRowOfItsOwn(node) {
1702
- var row = createRow();
1703
- row.appendChild(createColumn(MAX_COL_SIZE)).appendChild(node);
1704
- return row;
1725
+ return rowHolding(createColumn(MAX_COL_SIZE), node);
1705
1726
  }
1706
1727
  function showDropMarker(pageX, pageY) {
1707
1728
  var where = dropPlaceAt(pageX, pageY);
@@ -1730,10 +1751,7 @@ function build(instance, baseElem, optionsOrMethod) {
1730
1751
  var container = button.getAttribute("data-ge-toolbar") === "container";
1731
1752
  var type = button.getAttribute("data-ge-container-type");
1732
1753
  var made = container ? CONTAINERS[type].create({}) : rowFromLayout(button.getAttribute("data-ge-layout"));
1733
- var placed = made;
1734
- if (container && !is(where.region, ".column")) {
1735
- placed = inRowOfItsOwn(made);
1736
- }
1754
+ var placed = wrapFor(where.region, made);
1737
1755
  return addNode(container ? type : "row", made, function() {
1738
1756
  if (where.before) {
1739
1757
  where.before.parentNode.insertBefore(placed, where.before);
@@ -1996,7 +2014,6 @@ function build(instance, baseElem, optionsOrMethod) {
1996
2014
  setPreview(false);
1997
2015
  deinit();
1998
2016
  changeTarget(null);
1999
- changeSelection(null);
2000
2017
  htmlTextArea.style.height = 0.8 * document.documentElement.clientHeight + "px";
2001
2018
  htmlTextArea.value = canvas.innerHTML;
2002
2019
  show(htmlTextArea);
@@ -2012,11 +2029,8 @@ function build(instance, baseElem, optionsOrMethod) {
2012
2029
  init();
2013
2030
  hide(htmlTextArea);
2014
2031
  }
2015
- function targetSelector() {
2016
- return [".column"].concat(pluginHooks("regions")).join(", ");
2017
- }
2018
2032
  function isTarget(node) {
2019
- return !!node && node !== canvas && canvas.contains(node) && is(node, targetSelector());
2033
+ return !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
2020
2034
  }
2021
2035
  function changeTarget(node) {
2022
2036
  if (node === activeTarget) {
@@ -2024,16 +2038,63 @@ function build(instance, baseElem, optionsOrMethod) {
2024
2038
  }
2025
2039
  var from = activeTarget;
2026
2040
  if (from) {
2027
- removeClass(from, "ge-active-target");
2041
+ removeClass(from, "ge-selected");
2028
2042
  }
2029
2043
  activeTarget = node;
2030
2044
  if (node && hasClass(canvas, "ge-editing")) {
2031
- addClass(node, "ge-active-target");
2045
+ addClass(node, "ge-selected");
2032
2046
  }
2047
+ renderSidebar();
2033
2048
  emit("target-change", { canvas, target: node, from });
2034
2049
  }
2050
+ function regionSelector() {
2051
+ return [".column"].concat(pluginHooks("regions")).join(", ");
2052
+ }
2053
+ function effectiveRegion(target) {
2054
+ if (is(target, ".row, " + regionSelector())) {
2055
+ return target;
2056
+ }
2057
+ var inside = isContainerOrPane(target) ? paneRegionOf(target) : null;
2058
+ return inside || closest(target.parentElement, regionSelector()) || canvas;
2059
+ }
2060
+ function isContainerOrPane(node) {
2061
+ if (node.getAttribute("data-ge-container")) {
2062
+ return true;
2063
+ }
2064
+ var container = closest(node.parentElement, "[data-ge-container]", canvas);
2065
+ var definition = container && CONTAINERS[containerTypeOf(container)];
2066
+ return !!definition && !!definition.paneKind && kindOf(node) === definition.paneKind;
2067
+ }
2068
+ function paneRegionOf(node) {
2069
+ var isContainer = !!node.getAttribute("data-ge-container");
2070
+ var container = isContainer ? node : closest(node.parentElement, "[data-ge-container]", canvas);
2071
+ var definition = CONTAINERS[containerTypeOf(container)];
2072
+ return definition && definition.regionOf ? definition.regionOf(container, isContainer ? null : node) || null : null;
2073
+ }
2074
+ function wrapFor(region, node) {
2075
+ if (is(node, ".column")) {
2076
+ return is(region, ".row") ? node : rowHolding(node);
2077
+ }
2078
+ if (is(region, ".row")) {
2079
+ var column = createColumn(rowColsSource(region, leadingTier()) ? null : settings.add_column.size);
2080
+ column.appendChild(node);
2081
+ return column;
2082
+ }
2083
+ if (is(region, ".column") || is(node, ".row")) {
2084
+ return node;
2085
+ }
2086
+ return rowHolding(createColumn(MAX_COL_SIZE), node);
2087
+ }
2088
+ function rowHolding(column, node) {
2089
+ var row = createRow();
2090
+ if (node) {
2091
+ column.appendChild(node);
2092
+ }
2093
+ row.appendChild(column);
2094
+ return row;
2095
+ }
2035
2096
  function addToTarget(button, source) {
2036
- var made = insertFromToolbar(button, { region: activeTarget, before: null }, source);
2097
+ var made = insertFromToolbar(button, { region: effectiveRegion(activeTarget), before: null }, source);
2037
2098
  if (made && made.scrollIntoView) {
2038
2099
  made.scrollIntoView({ behavior: "smooth" });
2039
2100
  }
@@ -2042,8 +2103,8 @@ function build(instance, baseElem, optionsOrMethod) {
2042
2103
  if (openSettingsState && !attached(openSettingsState.node)) {
2043
2104
  closeSettings();
2044
2105
  }
2045
- if (selected && !canvas.contains(selected)) {
2046
- changeSelection(null);
2106
+ if (activeTarget && !canvas.contains(activeTarget)) {
2107
+ changeTarget(null);
2047
2108
  }
2048
2109
  if (dialogState && dialogState.home && !attached(dialogState.home)) {
2049
2110
  closeDialog();
@@ -2067,7 +2128,7 @@ function build(instance, baseElem, optionsOrMethod) {
2067
2128
  if (activeTarget && !canvas.contains(activeTarget)) {
2068
2129
  changeTarget(null);
2069
2130
  } else if (activeTarget) {
2070
- addClass(activeTarget, "ge-active-target");
2131
+ addClass(activeTarget, "ge-selected");
2071
2132
  }
2072
2133
  showSidebar();
2073
2134
  }
@@ -2076,7 +2137,7 @@ function build(instance, baseElem, optionsOrMethod) {
2076
2137
  hideSidebar();
2077
2138
  removeClass(canvas, "ge-editing ge-drag-drawer ge-dropping");
2078
2139
  if (activeTarget) {
2079
- removeClass(activeTarget, "ge-active-target");
2140
+ removeClass(activeTarget, "ge-selected");
2080
2141
  }
2081
2142
  plugins("onBeforeDeinit");
2082
2143
  closeSizePicker();
@@ -2153,8 +2214,8 @@ function build(instance, baseElem, optionsOrMethod) {
2153
2214
  }
2154
2215
  var copy = copyCanvas();
2155
2216
  var root = copy.root;
2156
- [root].concat(all(root, ".ge-active-target, .ge-settings-target")).forEach(function(node) {
2157
- removeClass(node, "ge-active-target ge-settings-target");
2217
+ [root].concat(all(root, ".ge-selected, .ge-settings-target")).forEach(function(node) {
2218
+ removeClass(node, "ge-selected ge-settings-target");
2158
2219
  dropEmptyClass(node);
2159
2220
  });
2160
2221
  all(root, ".ge-drop-marker").forEach(function(marker) {
@@ -2236,7 +2297,6 @@ function build(instance, baseElem, optionsOrMethod) {
2236
2297
  setPreview(false);
2237
2298
  deinit();
2238
2299
  activeTarget = null;
2239
- selected = null;
2240
2300
  if (sidebarHolder === instance) {
2241
2301
  sidebarHolder = null;
2242
2302
  }
@@ -2317,6 +2377,9 @@ function build(instance, baseElem, optionsOrMethod) {
2317
2377
  addSettingsTool,
2318
2378
  deleteNode,
2319
2379
  place,
2380
+ // A node made, added to the active target as the toolbar adds
2381
+ // what it makes: null with no target, or when it was canceled
2382
+ placeInTarget,
2320
2383
  createPaneControls,
2321
2384
  makeLabelEditable,
2322
2385
  labelIn,
@@ -2373,22 +2436,12 @@ function build(instance, baseElem, optionsOrMethod) {
2373
2436
  toolbarItems: function(name) {
2374
2437
  return mainControls ? all(mainControls, '[data-ge-toolbar="feature"][data-ge-feature="' + name + '"]') : [];
2375
2438
  },
2376
- getSelected: function() {
2377
- return panelMode() === "sidebar" ? selected : null;
2378
- },
2379
2439
  getActiveTarget: function() {
2380
2440
  return settings.active_target ? activeTarget : null;
2381
2441
  },
2382
2442
  // True when it took: a node that cannot be, or no setting
2383
2443
  // for it, says nothing, since a plugin putting back what it
2384
2444
  // remembers cannot know the node is still one
2385
- setSelected: function(node) {
2386
- var chosen = panelMode() === "sidebar" && !!node && node !== canvas && canvas.contains(node) && detailsFor.has(node);
2387
- if (chosen) {
2388
- changeSelection(node);
2389
- }
2390
- return chosen;
2391
- },
2392
2445
  setActiveTarget: function(node) {
2393
2446
  var chosen = !!settings.active_target && isTarget(node);
2394
2447
  if (chosen) {
@@ -2396,7 +2449,7 @@ function build(instance, baseElem, optionsOrMethod) {
2396
2449
  }
2397
2450
  return chosen;
2398
2451
  },
2399
- // What keeps Escape from the selection and the target, and an
2452
+ // What keeps Escape from the target, and an
2400
2453
  // inline panel unfolded in a drawer, which Escape leaves alone
2401
2454
  panelOpen: function() {
2402
2455
  if (openSettingsState || dialogState) {
@@ -3769,7 +3822,7 @@ function build(instance, baseElem, optionsOrMethod) {
3769
3822
  delegate(panel, "click", ".ge-settings-close", function(e) {
3770
3823
  e.preventDefault();
3771
3824
  if (mode === "sidebar") {
3772
- changeSelection(null);
3825
+ changeTarget(null);
3773
3826
  } else {
3774
3827
  closeSettings();
3775
3828
  }
@@ -3890,7 +3943,7 @@ function build(instance, baseElem, optionsOrMethod) {
3890
3943
  if (!panel || !isEditing()) {
3891
3944
  return;
3892
3945
  }
3893
- var details = selected ? detailsOf(selected) : null;
3946
+ var details = activeTarget ? detailsOf(activeTarget) : null;
3894
3947
  if (details ? sidebarShown && sidebarShown.details === details : !sidebarShown && sidebarEmpty) {
3895
3948
  return;
3896
3949
  }
@@ -3904,11 +3957,10 @@ function build(instance, baseElem, optionsOrMethod) {
3904
3957
  sidebarEmpty = { body };
3905
3958
  return;
3906
3959
  }
3907
- sidebarShown = { node: selected, details, home: details.parentElement, next: details.nextElementSibling };
3908
- setSidebarTitle(t("panel.title", { kind: kindLabel(selected) }));
3960
+ sidebarShown = { node: activeTarget, details, home: details.parentElement, next: details.nextElementSibling };
3961
+ setSidebarTitle(t("panel.title", { kind: kindLabel(activeTarget) }));
3909
3962
  holder.appendChild(details);
3910
3963
  show(details);
3911
- addClass(selected, "ge-settings-target");
3912
3964
  }
3913
3965
  function emptyContent() {
3914
3966
  var fromHost = settings.sidebar.empty;
@@ -3958,15 +4010,6 @@ function build(instance, baseElem, optionsOrMethod) {
3958
4010
  }
3959
4011
  return null;
3960
4012
  }
3961
- function changeSelection(node) {
3962
- if (node === selected) {
3963
- return;
3964
- }
3965
- var from = selected;
3966
- selected = node;
3967
- renderSidebar();
3968
- emit("selection-change", { canvas, node, from });
3969
- }
3970
4013
  function placePopover(panel, gear) {
3971
4014
  if (!attached(gear)) {
3972
4015
  return;
@@ -5076,28 +5119,11 @@ function build(instance, baseElem, optionsOrMethod) {
5076
5119
  var node = nodeFrom(value);
5077
5120
  if (!isTarget(node)) {
5078
5121
  var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
5079
- warn("setActiveTarget: " + named + " is not a column or a region of the canvas");
5122
+ warn("setActiveTarget: " + named + " is not a node of the canvas with settings");
5080
5123
  return;
5081
5124
  }
5082
5125
  changeTarget(node);
5083
5126
  }
5084
- function apiSetSelected(value) {
5085
- if (panelMode() !== "sidebar") {
5086
- warnOnceHere("sidebar-api", 'setSelected needs settings_panel "sidebar": without it, it does nothing');
5087
- return;
5088
- }
5089
- if (value === null || value === void 0) {
5090
- changeSelection(null);
5091
- return;
5092
- }
5093
- var node = nodeFrom(value);
5094
- if (!node || node === canvas || !canvas.contains(node) || !detailsFor.has(node)) {
5095
- var named = typeof value === "string" ? value : node ? "<" + node.tagName.toLowerCase() + ">" : String(value);
5096
- warn("setSelected: " + named + " is not a node of the canvas with settings");
5097
- return;
5098
- }
5099
- changeSelection(node);
5100
- }
5101
5127
  var own = {
5102
5128
  getHtml,
5103
5129
  getPlainHtml,
@@ -5136,11 +5162,7 @@ function build(instance, baseElem, optionsOrMethod) {
5136
5162
  getActiveTarget: function() {
5137
5163
  return settings.active_target ? activeTarget : null;
5138
5164
  },
5139
- setActiveTarget: apiSetActiveTarget,
5140
- getSelected: function() {
5141
- return panelMode() === "sidebar" ? selected : null;
5142
- },
5143
- setSelected: apiSetSelected
5165
+ setActiveTarget: apiSetActiveTarget
5144
5166
  };
5145
5167
  Object.keys(own).forEach(function(name) {
5146
5168
  var value = !!(METHODS[name] && METHODS[name].value);
@@ -5191,7 +5213,7 @@ GridEditor.t = translate;
5191
5213
  GridEditor._plainHtml = plainHtml;
5192
5214
  GridEditor.Sortable = null;
5193
5215
  GridEditor.bootstrap = null;
5194
- GridEditor.version = false ? "dev" : "9.0.0-beta.5";
5216
+ GridEditor.version = false ? "dev" : "9.0.0-beta.6";
5195
5217
  GridEditor.locales = {
5196
5218
  en: {
5197
5219
  "tool.move": "Move",
@@ -47,9 +47,7 @@
47
47
  getUtility: { value: true },
48
48
  setUtility: { value: true },
49
49
  getActiveTarget: { value: true },
50
- setActiveTarget: {},
51
- getSelected: { value: true },
52
- setSelected: {}
50
+ setActiveTarget: {}
53
51
  };
54
52
  var TOOL_SETTINGS = [
55
53
  "row_tools",
@@ -1 +1 @@
1
- (()=>{var u=window.GridEditor;if(!u||typeof u.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");var i=window.jQuery,T=function(a,o){return u.t({locale:"en"},a,o)},m={};function b(a,o){m[a]||(m[a]=!0,window.console&&window.console.warn&&window.console.warn("grid-editor: "+o))}!i||!i.fn?b("no-jquery",T("warning.adapter_no_jquery")):x();function x(){var a={getHtml:{value:!0},getPlainHtml:{value:!0},init:{},deinit:{},reset:{},destroy:{},changeView:{},getView:{value:!0},createRow:{value:!0},createColumn:{value:!0},createElement:{value:!0},createText:{value:!0},createSection:{value:!0},createContainer:{value:!0},addTab:{value:!0},addAccordionItem:{value:!0},setLocale:{},getUtility:{value:!0},setUtility:{value:!0},getActiveTarget:{value:!0},setActiveTarget:{},getSelected:{value:!0},setSelected:{}},o=["row_tools","col_tools","element_tools","container_tools","tab_tools","accordion_tools","text_tools"];function g(r){return!!r&&r.nodeType===1}function l(r){return r instanceof i?r[0]||null:r}function h(r){if(r instanceof i)return l(r);if(r&&typeof r=="object"&&!Array.isArray(r)&&!g(r)){var t={};return Object.keys(r).forEach(function(e){t[e]=l(r[e])}),t}return r}function v(r){return g(r)?i(r):r}var s=new WeakMap;function w(r){if(!r||typeof r!="object")return r;if(s.has(r))return s.get(r);var t=Object.assign({},r);return["node","parent","canvas"].forEach(function(e){e in r&&(t[e]=i(r[e]||[]))}),r.container&&(t.container=i(r.container)),Array.isArray(r.nodes)&&(t.node=i(r.nodes)),["from","to"].forEach(function(e){var n=r[e];n&&typeof n=="object"&&"parent"in n&&(t[e]=Object.assign({},n,{parent:i(n.parent||[])}))}),s.set(r,t),t}var p=i.event.dispatch;i.event.dispatch=function(r){return arguments.length===1&&r instanceof window.CustomEvent&&typeof r.type=="string"&&r.type.indexOf("grideditor:")===0?p.call(this,r,w(r.detail)):p.apply(this,arguments)};function y(r){return function(t){return r.call(this,i.event.fix(t))}}function _(r){if(!r||!r.on)return r;var t;return typeof r.on=="function"?t=y(r.on):(t={},Object.keys(r.on).forEach(function(e){t[e]=y(r.on[e])})),Object.assign({},r,{on:t})}function j(r){return function(t,e){var n=typeof r=="string"?window[r]:r;return n(i(t),e)}}function E(r){if(r=Object.assign({},r||{}),r.callbacks){var t={};Object.keys(r.callbacks).forEach(function(n){var c=r.callbacks[n];t[n]=typeof c=="function"?function(f){return c(w(f))}:c}),r.callbacks=t}if(r.custom_filter&&r.custom_filter.length){var e=typeof r.custom_filter=="string"||typeof r.custom_filter=="function"?[r.custom_filter]:Array.prototype.slice.call(r.custom_filter);r.custom_filter=e.map(j)}return o.forEach(function(n){Array.isArray(r[n])&&(r[n]=r[n].map(_))}),r.source_textarea=l(r.source_textarea),r}function A(r){var t={canvas:i(r.canvas)};return Object.keys(a).forEach(function(e){t[e]=function(){var n=r[e].apply(r,Array.prototype.map.call(arguments,h));return n===r?void 0:v(n)}}),Object.defineProperty(t,"settings",{enumerable:!0,get:function(){return r.settings}}),t}u._created.push(function(r){i.data(r.canvas,"grideditor",A(r));var t=r.destroy;r.destroy=function(){var e=t.apply(this,arguments);return i.removeData(r.canvas,"grideditor"),e}});function O(r,t,e){var n=a[t];if(!n)return b("method:"+t,'unknown method "'+t+'"'),r;if(e=e.map(h),n.value){var c=r.first();if(!c.length)return null;var f=u.get(c[0]);return f?v(f[t].apply(f,e)):t==="getHtml"?c.html():t==="getPlainHtml"?u._plainHtml(c.html()):null}return r.each(function(){var d=u.get(this);d&&d[t].apply(d,e)}),r}i.fn.gridEditor=function(r){if(typeof r=="string")return O(this,r,Array.prototype.slice.call(arguments,1));var t=E(r);return this.each(function(){u.create(this,t)}),this},i.fn.gridEditor.locales=u.locales,i.fn.gridEditor.t=u.t}})();
1
+ (()=>{var u=window.GridEditor;if(!u||typeof u.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");var i=window.jQuery,T=function(a,o){return u.t({locale:"en"},a,o)},m={};function b(a,o){m[a]||(m[a]=!0,window.console&&window.console.warn&&window.console.warn("grid-editor: "+o))}!i||!i.fn?b("no-jquery",T("warning.adapter_no_jquery")):x();function x(){var a={getHtml:{value:!0},getPlainHtml:{value:!0},init:{},deinit:{},reset:{},destroy:{},changeView:{},getView:{value:!0},createRow:{value:!0},createColumn:{value:!0},createElement:{value:!0},createText:{value:!0},createSection:{value:!0},createContainer:{value:!0},addTab:{value:!0},addAccordionItem:{value:!0},setLocale:{},getUtility:{value:!0},setUtility:{value:!0},getActiveTarget:{value:!0},setActiveTarget:{}},o=["row_tools","col_tools","element_tools","container_tools","tab_tools","accordion_tools","text_tools"];function g(r){return!!r&&r.nodeType===1}function l(r){return r instanceof i?r[0]||null:r}function h(r){if(r instanceof i)return l(r);if(r&&typeof r=="object"&&!Array.isArray(r)&&!g(r)){var t={};return Object.keys(r).forEach(function(e){t[e]=l(r[e])}),t}return r}function w(r){return g(r)?i(r):r}var s=new WeakMap;function p(r){if(!r||typeof r!="object")return r;if(s.has(r))return s.get(r);var t=Object.assign({},r);return["node","parent","canvas"].forEach(function(e){e in r&&(t[e]=i(r[e]||[]))}),r.container&&(t.container=i(r.container)),Array.isArray(r.nodes)&&(t.node=i(r.nodes)),["from","to"].forEach(function(e){var n=r[e];n&&typeof n=="object"&&"parent"in n&&(t[e]=Object.assign({},n,{parent:i(n.parent||[])}))}),s.set(r,t),t}var v=i.event.dispatch;i.event.dispatch=function(r){return arguments.length===1&&r instanceof window.CustomEvent&&typeof r.type=="string"&&r.type.indexOf("grideditor:")===0?v.call(this,r,p(r.detail)):v.apply(this,arguments)};function y(r){return function(t){return r.call(this,i.event.fix(t))}}function _(r){if(!r||!r.on)return r;var t;return typeof r.on=="function"?t=y(r.on):(t={},Object.keys(r.on).forEach(function(e){t[e]=y(r.on[e])})),Object.assign({},r,{on:t})}function j(r){return function(t,e){var n=typeof r=="string"?window[r]:r;return n(i(t),e)}}function E(r){if(r=Object.assign({},r||{}),r.callbacks){var t={};Object.keys(r.callbacks).forEach(function(n){var c=r.callbacks[n];t[n]=typeof c=="function"?function(f){return c(p(f))}:c}),r.callbacks=t}if(r.custom_filter&&r.custom_filter.length){var e=typeof r.custom_filter=="string"||typeof r.custom_filter=="function"?[r.custom_filter]:Array.prototype.slice.call(r.custom_filter);r.custom_filter=e.map(j)}return o.forEach(function(n){Array.isArray(r[n])&&(r[n]=r[n].map(_))}),r.source_textarea=l(r.source_textarea),r}function A(r){var t={canvas:i(r.canvas)};return Object.keys(a).forEach(function(e){t[e]=function(){var n=r[e].apply(r,Array.prototype.map.call(arguments,h));return n===r?void 0:w(n)}}),Object.defineProperty(t,"settings",{enumerable:!0,get:function(){return r.settings}}),t}u._created.push(function(r){i.data(r.canvas,"grideditor",A(r));var t=r.destroy;r.destroy=function(){var e=t.apply(this,arguments);return i.removeData(r.canvas,"grideditor"),e}});function O(r,t,e){var n=a[t];if(!n)return b("method:"+t,'unknown method "'+t+'"'),r;if(e=e.map(h),n.value){var c=r.first();if(!c.length)return null;var f=u.get(c[0]);return f?w(f[t].apply(f,e)):t==="getHtml"?c.html():t==="getPlainHtml"?u._plainHtml(c.html()):null}return r.each(function(){var d=u.get(this);d&&d[t].apply(d,e)}),r}i.fn.gridEditor=function(r){if(typeof r=="string")return O(this,r,Array.prototype.slice.call(arguments,1));var t=E(r);return this.each(function(){u.create(this,t)}),this},i.fn.gridEditor.locales=u.locales,i.fn.gridEditor.t=u.t}})();