@themarioga/grid-editor 9.0.0 → 9.1.1

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 (41) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/grideditor.bundle.min.js +2 -2
  3. package/dist/grideditor.esm.js +168 -54
  4. package/dist/grideditor.js +168 -54
  5. package/dist/grideditor.min.js +1 -1
  6. package/dist/grideditor.min.js.map +3 -3
  7. package/dist/plugins/grideditor.carousel.esm.js +8 -2
  8. package/dist/plugins/grideditor.carousel.js +8 -2
  9. package/dist/plugins/grideditor.carousel.min.js +1 -1
  10. package/dist/plugins/grideditor.carousel.min.js.map +3 -3
  11. package/dist/plugins/grideditor.clipboard.esm.js +1 -1
  12. package/dist/plugins/grideditor.clipboard.js +1 -1
  13. package/dist/plugins/grideditor.clipboard.min.js +1 -1
  14. package/dist/plugins/grideditor.clipboard.min.js.map +2 -2
  15. package/dist/plugins/grideditor.inline-style.esm.js +32 -16
  16. package/dist/plugins/grideditor.inline-style.js +32 -16
  17. package/dist/plugins/grideditor.inline-style.min.js +4 -4
  18. package/dist/plugins/grideditor.inline-style.min.js.map +3 -3
  19. package/dist/plugins/grideditor.offcanvas.esm.js +7 -1
  20. package/dist/plugins/grideditor.offcanvas.js +7 -1
  21. package/dist/plugins/grideditor.offcanvas.min.js +1 -1
  22. package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
  23. package/dist/plugins/grideditor.sections.esm.js +1 -1
  24. package/dist/plugins/grideditor.sections.js +1 -1
  25. package/dist/plugins/grideditor.sections.min.js +1 -1
  26. package/dist/plugins/grideditor.sections.min.js.map +2 -2
  27. package/dist/plugins/grideditor.tabs.esm.js +7 -1
  28. package/dist/plugins/grideditor.tabs.js +7 -1
  29. package/dist/plugins/grideditor.tabs.min.js +1 -1
  30. package/dist/plugins/grideditor.tabs.min.js.map +3 -3
  31. package/docs/plugins.md +10 -2
  32. package/package.json +1 -1
  33. package/src/js/grideditor.js +187 -56
  34. package/src/js/inline-style/catalog.js +1 -1
  35. package/src/js/inline-style/drawerflow.js +35 -14
  36. package/src/js/plugins/grideditor.carousel.js +9 -2
  37. package/src/js/plugins/grideditor.clipboard.js +1 -1
  38. package/src/js/plugins/grideditor.inline-style.js +3 -0
  39. package/src/js/plugins/grideditor.offcanvas.js +8 -1
  40. package/src/js/plugins/grideditor.sections.js +1 -1
  41. package/src/js/plugins/grideditor.tabs.js +8 -1
@@ -476,6 +476,7 @@ function build(instance, baseElem, optionsOrMethod) {
476
476
  var toolbarGroup = null; // The category shown, with toolbar_groups. Kept when the toolbar is rebuilt
477
477
  var warnedHere = {}; // Some warnings are worth saying once per instance, not once per call
478
478
  var sortables = []; // Every list made sortable, so deinit destroys exactly those
479
+ var sortableKinds = new WeakMap(); // What each of those lists sorts already, so init does not make it twice
479
480
  var instanceId = ++editorCounter; // Scopes the sortable groups to this editor
480
481
  var destroyed = false;
481
482
  var sidebarCollapsed = null; // Folded away, once the sidebar has been shown: the window's width decides the first time
@@ -495,6 +496,7 @@ function build(instance, baseElem, optionsOrMethod) {
495
496
  // be jQuery data: a node's settings panel, a drag or a resize in
496
497
  // progress. Kept off the markup, and gone with the node.
497
498
  var detailsFor = new WeakMap(); // node -> its settings panel
499
+ var panelBodies = new WeakMap(); // A panel -> { node, anchor, nodes }: the part built only while it is open
498
500
  var toolActions = new WeakMap(); // A tool -> what its click does, to do it without one
499
501
  var pendingDelete = null; // What removeNode asks of the delete the tool it runs makes, for that call only
500
502
  var moves = new WeakMap(); // dragged node -> { from, canceled }
@@ -1136,8 +1138,21 @@ function build(instance, baseElem, optionsOrMethod) {
1136
1138
 
1137
1139
  var signal = { signal: lifetime.signal };
1138
1140
 
1139
- // Make controls fixed on scroll
1140
- window.addEventListener('scroll', onScroll, signal);
1141
+ // Make controls fixed on scroll. Once a frame, after the
1142
+ // layout: a scroll also comes when the page changes height - a
1143
+ // getHtml takes every drawer off and puts it back - and read
1144
+ // there and then, the toolbar's position laid the page out again
1145
+ var scrollFrame = null;
1146
+ window.addEventListener('scroll', function() {
1147
+ if (scrollFrame !== null) { return; }
1148
+ scrollFrame = window.requestAnimationFrame(function() {
1149
+ scrollFrame = null;
1150
+ if (!destroyed && mainControls) { onScroll(); }
1151
+ });
1152
+ }, signal);
1153
+ lifetime.signal.addEventListener('abort', function() {
1154
+ if (scrollFrame !== null) { window.cancelAnimationFrame(scrollFrame); }
1155
+ });
1141
1156
 
1142
1157
  /* A click on the host's plain content offers to make it a text */
1143
1158
  dom.delegate(canvas, 'click', '.ge-content', onContentClick, signal);
@@ -2503,26 +2518,35 @@ function build(instance, baseElem, optionsOrMethod) {
2503
2518
  }
2504
2519
 
2505
2520
  /**
2506
- * A copy of the canvas, and the way from each of its elements back to
2507
- * the one it was copied from. The two trees are walked side by side,
2508
- * which works because a deep clone has the same shape.
2521
+ * A copy of the canvas without its drawers, and the way from each of
2522
+ * its elements back to the one it was copied from.
2523
+ *
2524
+ * Copied node by node rather than cloned whole: the drawers are most
2525
+ * of the canvas while it is edited, and a snapshot only took them off
2526
+ * again. A template is the one node a shallow clone leaves empty, so
2527
+ * it goes whole.
2509
2528
  */
2510
2529
  function copyCanvas() {
2511
- var copy = canvas.cloneNode(true);
2512
2530
  var toLive = new Map();
2513
2531
  var toCopy = new Map();
2514
- var live = document.createTreeWalker(canvas, NodeFilter.SHOW_ELEMENT);
2515
- var copied = document.createTreeWalker(copy, NodeFilter.SHOW_ELEMENT);
2516
- var a = live.currentNode;
2517
- var b = copied.currentNode;
2518
-
2519
- while (a && b) {
2520
- toLive.set(b, a);
2521
- toCopy.set(a, b);
2522
- a = live.nextNode();
2523
- b = copied.nextNode();
2532
+
2533
+ function copyNode(live) {
2534
+ var copied = live.cloneNode(live.nodeName === 'TEMPLATE');
2535
+ if (live.nodeType !== 1) { return copied; }
2536
+
2537
+ toLive.set(copied, live);
2538
+ toCopy.set(live, copied);
2539
+ if (live.nodeName === 'TEMPLATE') { return copied; }
2540
+
2541
+ for (var child = live.firstChild; child; child = child.nextSibling) {
2542
+ if (child.nodeType === 1 && dom.hasClass(child, 'ge-tools-drawer')) { continue; }
2543
+ copied.appendChild(copyNode(child));
2544
+ }
2545
+ return copied;
2524
2546
  }
2525
2547
 
2548
+ var copy = copyNode(canvas);
2549
+
2526
2550
  return {
2527
2551
  root: copy,
2528
2552
  liveOf: function(node) { return toLive.get(node) || null; },
@@ -2801,8 +2825,14 @@ function build(instance, baseElem, optionsOrMethod) {
2801
2825
  attachPicker: attachPicker,
2802
2826
  openPicker: openPicker,
2803
2827
  closePicker: closeSizePicker,
2804
- // A node's settings panel, in its drawer or open outside it
2805
- detailsOf: detailsOf,
2828
+ // A node's settings panel, in its drawer or open outside it,
2829
+ // whole: { build: false } for it as it is, without what is
2830
+ // built only while it is open
2831
+ detailsOf: function(node, options) {
2832
+ var details = detailsOf(node);
2833
+ if (details && !(options && options.build === false)) { buildPanelBody(details); }
2834
+ return details;
2835
+ },
2806
2836
  // A node's drawer: its first child, or for a content area the
2807
2837
  // one beside it in its text block
2808
2838
  drawerOf: drawerOf,
@@ -4119,15 +4149,13 @@ function build(instance, baseElem, optionsOrMethod) {
4119
4149
 
4120
4150
  function flush() {
4121
4151
  frame = null;
4122
- var drawers = Array.from(due);
4123
- due.clear();
4124
- drawers.forEach(function(drawer) {
4125
- if (!drawer.isConnected) {
4126
- drawerResizes.unobserve(drawer);
4127
- return;
4128
- }
4129
- fitDrawer(drawer);
4152
+ var drawers = Array.from(due).filter(function(drawer) {
4153
+ if (drawer.isConnected) { return true; }
4154
+ drawerResizes.unobserve(drawer);
4155
+ return false;
4130
4156
  });
4157
+ due.clear();
4158
+ fitDrawers(drawers);
4131
4159
  }
4132
4160
 
4133
4161
  var drawerResizes = new window.ResizeObserver(function(entries) {
@@ -4170,40 +4198,73 @@ function build(instance, baseElem, optionsOrMethod) {
4170
4198
  });
4171
4199
  }
4172
4200
 
4173
- /** Hide the tools that don't fit on the drawer's line, from the end, behind its more tool. */
4174
- function fitDrawer(drawer) {
4175
- var tools = dom.children(drawer, 'a').filter(function(tool) { return !dom.hasClass(tool, 'ge-drawer-more'); });
4176
- var expanded = dom.hasClass(drawer, 'ge-drawer-expanded');
4177
-
4178
- // Measured on one line, with every tool back on it
4179
- dom.removeClass(drawer, 'ge-drawer-overflow ge-drawer-expanded');
4180
- tools.forEach(function(tool) { dom.removeClass(tool, 'ge-tool-overflow'); });
4181
-
4182
- if (!drawerOverflows(drawer, tools)) { return; }
4201
+ /**
4202
+ * Hide the tools that don't fit on each drawer's line, from the end,
4203
+ * behind its more tool.
4204
+ *
4205
+ * All the drawers at once, in phases - every write, then every read -
4206
+ * so the page is laid out three times however many drawers there
4207
+ * are: a drawer at a time, each measure laid out the whole page
4208
+ * again, and a canvas of a few hundred drawers took seconds. One
4209
+ * measure of a drawer is enough: its tools are on one line, aligned
4210
+ * left, so hiding the last ones or making room for the more tool at
4211
+ * the end moves none of the others.
4212
+ */
4213
+ function fitDrawers(drawers) {
4214
+ // Every tool back on the one line
4215
+ var fits = drawers.map(function(drawer) {
4216
+ var fit = {
4217
+ drawer: drawer,
4218
+ tools: dom.children(drawer, 'a').filter(function(tool) { return !dom.hasClass(tool, 'ge-drawer-more'); }),
4219
+ expanded: dom.hasClass(drawer, 'ge-drawer-expanded'),
4220
+ };
4221
+ dom.removeClass(drawer, 'ge-drawer-overflow ge-drawer-expanded');
4222
+ fit.tools.forEach(function(tool) { dom.removeClass(tool, 'ge-tool-overflow'); });
4223
+ return fit;
4224
+ });
4183
4225
 
4184
- dom.addClass(drawer, 'ge-drawer-overflow');
4185
- if (!dom.child(drawer, '.ge-drawer-more')) {
4186
- createTool(drawer, t('tool.more'), 'ge-drawer-more', 'bi bi-three-dots', function() {
4187
- dom.toggleClass(drawer, 'ge-drawer-expanded');
4226
+ // Where each tool ends, and whether any ends past the drawer's room
4227
+ var over = fits.filter(function(fit) {
4228
+ fit.rights = fit.tools.map(function(tool) {
4229
+ var rects = tool.getClientRects();
4230
+ return rects.length ? rects[0].right : null;
4188
4231
  });
4189
- }
4232
+ return overflows(fit, roomOf(fit.drawer));
4233
+ });
4190
4234
 
4191
- for (var i = tools.length - 1; i >= 0 && drawerOverflows(drawer, tools); i--) {
4192
- dom.addClass(tools[i], 'ge-tool-overflow');
4193
- }
4235
+ // The more tool takes its room at the end, and the tools that
4236
+ // still end past it are hidden, from the last
4237
+ over.forEach(function(fit) { dom.addClass(fit.drawer, 'ge-drawer-overflow'); });
4238
+ over.forEach(function(fit) { fit.room = roomOf(fit.drawer); });
4239
+ over.forEach(function(fit) {
4240
+ for (var i = fit.tools.length - 1; i >= 0 && overflows(fit, fit.room, i); i--) {
4241
+ dom.addClass(fit.tools[i], 'ge-tool-overflow');
4242
+ }
4243
+ if (!dom.child(fit.drawer, '.ge-drawer-more')) {
4244
+ createTool(fit.drawer, t('tool.more'), 'ge-drawer-more', 'bi bi-three-dots', function() {
4245
+ dom.toggleClass(fit.drawer, 'ge-drawer-expanded');
4246
+ });
4247
+ }
4194
4248
 
4195
- dom.toggleClass(drawer, 'ge-drawer-expanded', expanded);
4249
+ // Unfolded it stays, while there is something to unfold
4250
+ dom.toggleClass(fit.drawer, 'ge-drawer-expanded', fit.expanded);
4251
+ });
4196
4252
  }
4197
4253
 
4198
- function drawerOverflows(drawer, tools) {
4254
+ /** Where a drawer's tools have to end: its right edge, inside its border and padding. */
4255
+ function roomOf(drawer) {
4199
4256
  var style = window.getComputedStyle(drawer);
4200
- var limit = drawer.getBoundingClientRect().right -
4257
+ return drawer.getBoundingClientRect().right -
4201
4258
  parseFloat(style.borderRightWidth) - parseFloat(style.paddingRight);
4259
+ }
4202
4260
 
4203
- return tools.some(function(tool) {
4204
- var rects = tool.getClientRects();
4205
- return rects.length > 0 && rects[0].right > limit + 0.5;
4206
- });
4261
+ /** Whether any of a drawer's tools up to `last` ends past `room`. */
4262
+ function overflows(fit, room, last) {
4263
+ last = last === undefined ? fit.rights.length - 1 : last;
4264
+ for (var i = 0; i <= last; i++) {
4265
+ if (fit.rights[i] !== null && fit.rights[i] > room + 0.5) { return true; }
4266
+ }
4267
+ return false;
4207
4268
  }
4208
4269
 
4209
4270
  /**
@@ -4356,14 +4417,51 @@ function build(instance, baseElem, optionsOrMethod) {
4356
4417
  classGroup.appendChild(btn);
4357
4418
  });
4358
4419
 
4359
- pluginSections(container).forEach(function(section) { detailsDiv.appendChild(section); });
4360
-
4361
- var utilities = createUtilitiesSection(container);
4362
- if (utilities) { detailsDiv.appendChild(utilities); }
4420
+ // What plugins add and the Responsive section are most of a
4421
+ // panel - hundreds of fields with inline-style - and a panel is
4422
+ // seldom opened: they are built when it opens, here, and taken
4423
+ // away when it closes. Fields a plugin adds to the panel itself go
4424
+ // after them, as ever.
4425
+ var anchor = detailsDiv.appendChild(document.createComment(' ge-details-body '));
4426
+ panelBodies.set(detailsDiv, { node: container, anchor: anchor, nodes: null });
4363
4427
 
4364
4428
  return detailsDiv;
4365
4429
  }
4366
4430
 
4431
+ /**
4432
+ * The part of a panel built only while it is open: the plugins'
4433
+ * sections and the Responsive section, made from the node as it is
4434
+ * now, so nothing has to keep them up to date while nobody sees them.
4435
+ */
4436
+ function buildPanelBody(details) {
4437
+ var body = panelBodies.get(details);
4438
+ if (!body || body.nodes) { return; }
4439
+
4440
+ var nodes = pluginSections(body.node);
4441
+ var utilities = createUtilitiesSection(body.node);
4442
+ if (utilities) { nodes.push(utilities); }
4443
+
4444
+ nodes.forEach(function(node) { details.insertBefore(node, body.anchor); });
4445
+ body.nodes = nodes;
4446
+ }
4447
+
4448
+ /** And taken away again, with its listeners, when the panel closes. */
4449
+ function dropPanelBody(details) {
4450
+ var body = panelBodies.get(details);
4451
+ if (!body || !body.nodes) { return; }
4452
+
4453
+ // A dialog showing one of its sections goes first, or it would
4454
+ // put the section back into what is being taken away
4455
+ if (dialogState && dialogState.home && details.contains(dialogState.home)) { closeDialog(); }
4456
+
4457
+ body.nodes.forEach(function(node) { node.remove(); });
4458
+ body.nodes = null;
4459
+
4460
+ pluginFields.forEach(function(fieldNode, field) {
4461
+ if (!field.isConnected) { pluginFields.delete(field); }
4462
+ });
4463
+ }
4464
+
4367
4465
  /** The heading of one of a panel's sections. */
4368
4466
  function sectionTitle(text) {
4369
4467
  return dom.element('h6', { 'class': 'ge-section-title' }, text);
@@ -4463,7 +4561,13 @@ function build(instance, baseElem, optionsOrMethod) {
4463
4561
  var mode = panelMode();
4464
4562
 
4465
4563
  if (mode === 'inline') {
4466
- dom.toggle(details);
4564
+ if (dom.visible(details)) {
4565
+ dom.hide(details);
4566
+ dropPanelBody(details);
4567
+ } else {
4568
+ buildPanelBody(details);
4569
+ dom.show(details);
4570
+ }
4467
4571
  return;
4468
4572
  }
4469
4573
 
@@ -4487,6 +4591,7 @@ function build(instance, baseElem, optionsOrMethod) {
4487
4591
  };
4488
4592
 
4489
4593
  dom.one(panel, '.ge-settings-title').textContent = t('panel.title', { kind: kindLabel(node) });
4594
+ buildPanelBody(details);
4490
4595
  dom.one(panel, '.ge-settings-body').appendChild(details);
4491
4596
  dom.show(details);
4492
4597
  dom.addClass(node, 'ge-settings-target');
@@ -4554,6 +4659,7 @@ function build(instance, baseElem, optionsOrMethod) {
4554
4659
 
4555
4660
  /** A node's panel back where it was in its drawer, and the node no longer marked. */
4556
4661
  function returnPanel(open) {
4662
+ dropPanelBody(open.details);
4557
4663
  dom.removeClass(open.node, 'ge-settings-target');
4558
4664
  open.details.style.removeProperty('display');
4559
4665
  dom.dropEmptyStyle(open.details);
@@ -4784,6 +4890,7 @@ function build(instance, baseElem, optionsOrMethod) {
4784
4890
 
4785
4891
  sidebarShown = { node: activeTarget, details: details, home: details.parentElement, next: details.nextElementSibling };
4786
4892
  setSidebarTitle(t('panel.title', { kind: kindLabel(activeTarget) }));
4893
+ buildPanelBody(details);
4787
4894
  holder.appendChild(details);
4788
4895
  dom.show(details);
4789
4896
  }
@@ -5507,8 +5614,20 @@ function build(instance, baseElem, optionsOrMethod) {
5507
5614
  var wholeDrawer = settings.drag_handle === 'drawer';
5508
5615
  var cancel = dragCancelSelector();
5509
5616
  var soloGroup = 0;
5617
+ var kind = options.draggable + '|' + (options.group || '');
5618
+
5619
+ // init() runs after every add, and makes the canvas sortable
5620
+ // again: the lists it already made keep their instance, and the
5621
+ // ones taken off the canvas since lose theirs. Without this every
5622
+ // list gathered one more instance, and its listeners, per change.
5623
+ dropDetachedSortables();
5510
5624
 
5511
5625
  lists.forEach(function(list) {
5626
+ var kinds = sortableKinds.get(list);
5627
+ if (kinds && kinds.has(kind)) { return; }
5628
+ if (!kinds) { sortableKinds.set(list, kinds = new Set()); }
5629
+ kinds.add(kind);
5630
+
5512
5631
  // A list with no group sorts only within itself, which is what
5513
5632
  // a tab strip wants: a name of its own, closed both ways
5514
5633
  var group = options.group
@@ -5939,6 +6058,18 @@ function build(instance, baseElem, optionsOrMethod) {
5939
6058
  sortables.forEach(function(sortableInstance) { sortableInstance.destroy(); });
5940
6059
 
5941
6060
  sortables = [];
6061
+ sortableKinds = new WeakMap();
6062
+ }
6063
+
6064
+ /** Destroy the instances of the lists no longer in the canvas. */
6065
+ function dropDetachedSortables() {
6066
+ sortables = sortables.filter(function(sortableInstance) {
6067
+ if (canvas.contains(sortableInstance.el)) { return true; }
6068
+
6069
+ sortableInstance.destroy();
6070
+ sortableKinds.delete(sortableInstance.el);
6071
+ return false;
6072
+ });
5942
6073
  }
5943
6074
 
5944
6075
  function createRow() {
@@ -17,7 +17,7 @@ function classesOf(node) {
17
17
 
18
18
  /** Put a class on or off through the node's classes field. */
19
19
  function choose(ge, node, group, name) {
20
- var details = ge.detailsOf(node);
20
+ var details = ge.detailsOf(node, { build: false });
21
21
  var input = details ? dom.one(details, '.ge-classes') : null;
22
22
  if (!input) { return; }
23
23
 
@@ -55,13 +55,20 @@ export function drawerflowPart(ge) {
55
55
  return !(dom.hasClass(node, 'row') && style.flexDirection === 'row' && style.flexWrap === 'wrap');
56
56
  }
57
57
 
58
- function measure(node, drawer) {
59
- var room = Math.ceil(drawer.offsetHeight) + GAP;
58
+ /** The room a drawer takes above its node's content. */
59
+ function roomOf(drawer) {
60
+ return Math.ceil(drawer.offsetHeight) + GAP;
61
+ }
60
62
 
63
+ function place(node, room) {
61
64
  rule(room);
62
65
  node.setAttribute(OUT_ATTR, String(room));
63
66
  }
64
67
 
68
+ function measure(node, drawer) {
69
+ place(node, roomOf(drawer));
70
+ }
71
+
65
72
  /** A drawer that grows - its tools wrap, its settings unfold - takes more room. */
66
73
  function watch(drawer) {
67
74
  if (typeof ResizeObserver === 'undefined') { return; }
@@ -77,22 +84,36 @@ export function drawerflowPart(ge) {
77
84
  observer.observe(drawer);
78
85
  }
79
86
 
87
+ /**
88
+ * Every read, then every write: a node at a time, each read laid out the
89
+ * whole page again after the last node's write, which on a large canvas
90
+ * took longer than everything else a refresh does.
91
+ */
80
92
  function mark(scope) {
81
- dom.selfAndAll(scope, NODES).forEach(function(node) {
93
+ var nodes = dom.selfAndAll(scope, NODES).map(function(node) {
82
94
  var drawer = dom.child(node, '.ge-tools-drawer');
83
- if (!drawer) { return; }
84
-
85
- if (laysOut(node)) {
86
- dom.addClass(node, OUT_CLASS);
87
- measure(node, drawer);
88
- watch(drawer);
89
- } else if (dom.hasClass(node, OUT_CLASS)) {
90
- dom.removeClass(node, OUT_CLASS);
91
- node.removeAttribute(OUT_ATTR);
92
- dom.dropEmptyClass(node);
93
- if (observer) { observer.unobserve(drawer); }
95
+ return drawer ? { node: node, drawer: drawer, out: laysOut(node) } : null;
96
+ }).filter(Boolean);
97
+
98
+ var out = nodes.filter(function(entry) { return entry.out; });
99
+
100
+ nodes.forEach(function(entry) {
101
+ if (entry.out) {
102
+ dom.addClass(entry.node, OUT_CLASS);
103
+ } else if (dom.hasClass(entry.node, OUT_CLASS)) {
104
+ dom.removeClass(entry.node, OUT_CLASS);
105
+ entry.node.removeAttribute(OUT_ATTR);
106
+ dom.dropEmptyClass(entry.node);
107
+ if (observer) { observer.unobserve(entry.drawer); }
94
108
  }
95
109
  });
110
+
111
+ // Out of the flow its drawer is as wide as the node, and may wrap
112
+ out.forEach(function(entry) { entry.room = roomOf(entry.drawer); });
113
+ out.forEach(function(entry) {
114
+ place(entry.node, entry.room);
115
+ watch(entry.drawer);
116
+ });
96
117
  }
97
118
 
98
119
  function unmarkNodes(root) {
@@ -120,6 +120,13 @@ GridEditor.containers.carousel = function(ge) {
120
120
  var shown = new WeakMap(); // The slide each carousel shows, whatever its markup says
121
121
  var sections = []; // { node, element, render } for every panel section built
122
122
 
123
+ // A panel's sections are built when it opens and taken away when it
124
+ // closes: the ones gone are forgotten here as well as on a refresh
125
+ function rememberSection(entry) {
126
+ sections = sections.filter(function(each) { return each.element.isConnected; });
127
+ sections.push(entry);
128
+ }
129
+
123
130
  function carouselOf(container) {
124
131
  return dom.child(container, '.carousel');
125
132
  }
@@ -644,7 +651,7 @@ GridEditor.containers.carousel = function(ge) {
644
651
  }
645
652
 
646
653
  render();
647
- sections.push({ node: container, element: body, render: render });
654
+ rememberSection({ node: container, element: body, render: render });
648
655
 
649
656
  return body;
650
657
  }
@@ -656,7 +663,7 @@ GridEditor.containers.carousel = function(ge) {
656
663
 
657
664
  body.appendChild(field(INTERVAL_LABEL.labelKey, interval.input, interval.id));
658
665
  interval.render();
659
- sections.push({ node: item, element: body, render: interval.render });
666
+ rememberSection({ node: item, element: body, render: interval.render });
660
667
 
661
668
  return body;
662
669
  }
@@ -216,7 +216,7 @@ GridEditor.features.clipboard = function(ge) {
216
216
  if (source !== 'tool' && !(target && node.contains(target))) { return; }
217
217
 
218
218
  var parent = node.parentElement;
219
- while (parent && parent !== ge.canvas && !ge.detailsOf(parent)) { parent = parent.parentElement; }
219
+ while (parent && parent !== ge.canvas && !ge.detailsOf(parent, { build: false })) { parent = parent.parentElement; }
220
220
  ge.setActiveTarget(parent && parent !== ge.canvas ? parent : null);
221
221
  },
222
222
  });
@@ -161,6 +161,9 @@ GridEditor.utilities['inline-style'] = function(ge) {
161
161
  var accordion = createAccordion(ge, node, kind, context);
162
162
  if (!accordion) { return null; }
163
163
 
164
+ // Built when the panel opens and taken away when it closes: the
165
+ // ones gone are forgotten here as well as on a refresh
166
+ accordions = accordions.filter(function(entry) { return entry.accordion.element.isConnected; });
164
167
  accordions.push({ node: node, accordion: accordion });
165
168
 
166
169
  return { labelKey: 'inline_style.section_title', titleKey: 'inline_style.dialog_title', body: accordion.element };
@@ -86,6 +86,13 @@ GridEditor.containers.offcanvas = function(ge) {
86
86
  var RESPONSIVE = ge.breakpoints.filter(function(key) { return key !== 'xs'; });
87
87
  var sections = []; // { node, element, render } for every panel section built
88
88
 
89
+ // A panel's sections are built when it opens and taken away when it
90
+ // closes: the ones gone are forgotten here as well as on a refresh
91
+ function rememberSection(entry) {
92
+ sections = sections.filter(function(each) { return each.element.isConnected; });
93
+ sections.push(entry);
94
+ }
95
+
89
96
  var triggers = triggersFor(ge, 'offcanvas', 'data-ge-offcanvas-id', 'data-ge-offcanvas-target', 'offcanvas');
90
97
 
91
98
  var CHECKS = {
@@ -308,7 +315,7 @@ GridEditor.containers.offcanvas = function(ge) {
308
315
  }
309
316
 
310
317
  render();
311
- sections.push({ node: container, element: body, render: render });
318
+ rememberSection({ node: container, element: body, render: render });
312
319
 
313
320
  return body;
314
321
  }
@@ -91,7 +91,7 @@ GridEditor.features.sections = function(ge) {
91
91
  });
92
92
 
93
93
  if (!ge.emit('before-utility', payload)) {
94
- var select = dom.one(ge.detailsOf(section), '.ge-section-width select');
94
+ var select = dom.one(ge.detailsOf(section, { build: false }), '.ge-section-width select');
95
95
  if (select) { select.value = from; }
96
96
  return false;
97
97
  }
@@ -80,6 +80,13 @@ GridEditor.containers.tabs = function(ge) {
80
80
 
81
81
  var sections = []; // { container, render } for every panel section built
82
82
 
83
+ // A panel's sections are built when it opens and taken away when it
84
+ // closes: the ones gone are forgotten here as well as on a refresh
85
+ function rememberSection(entry) {
86
+ sections = sections.filter(function(each) { return each.element.isConnected; });
87
+ sections.push(entry);
88
+ }
89
+
83
90
  /** The strip: the container's first .nav, whatever its style. */
84
91
  function stripOf(container) {
85
92
  return dom.child(container, '.nav');
@@ -294,7 +301,7 @@ GridEditor.containers.tabs = function(ge) {
294
301
  }
295
302
 
296
303
  render();
297
- sections.push({ container: container, element: body, render: render });
304
+ rememberSection({ container: container, element: body, render: render });
298
305
 
299
306
  return body;
300
307
  }