@themarioga/grid-editor 9.0.0 → 9.1.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.
- package/CHANGELOG.md +20 -0
- package/dist/grideditor.bundle.min.js +2 -2
- package/dist/grideditor.esm.js +78 -10
- package/dist/grideditor.js +78 -10
- package/dist/grideditor.min.js +1 -1
- package/dist/grideditor.min.js.map +3 -3
- package/dist/plugins/grideditor.carousel.esm.js +8 -2
- package/dist/plugins/grideditor.carousel.js +8 -2
- package/dist/plugins/grideditor.carousel.min.js +1 -1
- package/dist/plugins/grideditor.carousel.min.js.map +3 -3
- package/dist/plugins/grideditor.clipboard.esm.js +1 -1
- package/dist/plugins/grideditor.clipboard.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +2 -2
- package/dist/plugins/grideditor.inline-style.esm.js +4 -1
- package/dist/plugins/grideditor.inline-style.js +4 -1
- package/dist/plugins/grideditor.inline-style.min.js +3 -3
- package/dist/plugins/grideditor.inline-style.min.js.map +2 -2
- package/dist/plugins/grideditor.offcanvas.esm.js +7 -1
- package/dist/plugins/grideditor.offcanvas.js +7 -1
- package/dist/plugins/grideditor.offcanvas.min.js +1 -1
- package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
- package/dist/plugins/grideditor.sections.esm.js +1 -1
- package/dist/plugins/grideditor.sections.js +1 -1
- package/dist/plugins/grideditor.sections.min.js +1 -1
- package/dist/plugins/grideditor.sections.min.js.map +2 -2
- package/dist/plugins/grideditor.tabs.esm.js +7 -1
- package/dist/plugins/grideditor.tabs.js +7 -1
- package/dist/plugins/grideditor.tabs.min.js +1 -1
- package/dist/plugins/grideditor.tabs.min.js.map +3 -3
- package/docs/plugins.md +10 -2
- package/package.json +1 -1
- package/src/js/grideditor.js +85 -7
- package/src/js/inline-style/catalog.js +1 -1
- package/src/js/plugins/grideditor.carousel.js +9 -2
- package/src/js/plugins/grideditor.clipboard.js +1 -1
- package/src/js/plugins/grideditor.inline-style.js +3 -0
- package/src/js/plugins/grideditor.offcanvas.js +8 -1
- package/src/js/plugins/grideditor.sections.js +1 -1
- package/src/js/plugins/grideditor.tabs.js +8 -1
package/src/js/grideditor.js
CHANGED
|
@@ -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 }
|
|
@@ -2801,8 +2803,14 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
2801
2803
|
attachPicker: attachPicker,
|
|
2802
2804
|
openPicker: openPicker,
|
|
2803
2805
|
closePicker: closeSizePicker,
|
|
2804
|
-
// A node's settings panel, in its drawer or open outside it
|
|
2805
|
-
|
|
2806
|
+
// A node's settings panel, in its drawer or open outside it,
|
|
2807
|
+
// whole: { build: false } for it as it is, without what is
|
|
2808
|
+
// built only while it is open
|
|
2809
|
+
detailsOf: function(node, options) {
|
|
2810
|
+
var details = detailsOf(node);
|
|
2811
|
+
if (details && !(options && options.build === false)) { buildPanelBody(details); }
|
|
2812
|
+
return details;
|
|
2813
|
+
},
|
|
2806
2814
|
// A node's drawer: its first child, or for a content area the
|
|
2807
2815
|
// one beside it in its text block
|
|
2808
2816
|
drawerOf: drawerOf,
|
|
@@ -4356,14 +4364,51 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4356
4364
|
classGroup.appendChild(btn);
|
|
4357
4365
|
});
|
|
4358
4366
|
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4367
|
+
// What plugins add and the Responsive section are most of a
|
|
4368
|
+
// panel - hundreds of fields with inline-style - and a panel is
|
|
4369
|
+
// seldom opened: they are built when it opens, here, and taken
|
|
4370
|
+
// away when it closes. Fields a plugin adds to the panel itself go
|
|
4371
|
+
// after them, as ever.
|
|
4372
|
+
var anchor = detailsDiv.appendChild(document.createComment(' ge-details-body '));
|
|
4373
|
+
panelBodies.set(detailsDiv, { node: container, anchor: anchor, nodes: null });
|
|
4363
4374
|
|
|
4364
4375
|
return detailsDiv;
|
|
4365
4376
|
}
|
|
4366
4377
|
|
|
4378
|
+
/**
|
|
4379
|
+
* The part of a panel built only while it is open: the plugins'
|
|
4380
|
+
* sections and the Responsive section, made from the node as it is
|
|
4381
|
+
* now, so nothing has to keep them up to date while nobody sees them.
|
|
4382
|
+
*/
|
|
4383
|
+
function buildPanelBody(details) {
|
|
4384
|
+
var body = panelBodies.get(details);
|
|
4385
|
+
if (!body || body.nodes) { return; }
|
|
4386
|
+
|
|
4387
|
+
var nodes = pluginSections(body.node);
|
|
4388
|
+
var utilities = createUtilitiesSection(body.node);
|
|
4389
|
+
if (utilities) { nodes.push(utilities); }
|
|
4390
|
+
|
|
4391
|
+
nodes.forEach(function(node) { details.insertBefore(node, body.anchor); });
|
|
4392
|
+
body.nodes = nodes;
|
|
4393
|
+
}
|
|
4394
|
+
|
|
4395
|
+
/** And taken away again, with its listeners, when the panel closes. */
|
|
4396
|
+
function dropPanelBody(details) {
|
|
4397
|
+
var body = panelBodies.get(details);
|
|
4398
|
+
if (!body || !body.nodes) { return; }
|
|
4399
|
+
|
|
4400
|
+
// A dialog showing one of its sections goes first, or it would
|
|
4401
|
+
// put the section back into what is being taken away
|
|
4402
|
+
if (dialogState && dialogState.home && details.contains(dialogState.home)) { closeDialog(); }
|
|
4403
|
+
|
|
4404
|
+
body.nodes.forEach(function(node) { node.remove(); });
|
|
4405
|
+
body.nodes = null;
|
|
4406
|
+
|
|
4407
|
+
pluginFields.forEach(function(fieldNode, field) {
|
|
4408
|
+
if (!field.isConnected) { pluginFields.delete(field); }
|
|
4409
|
+
});
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4367
4412
|
/** The heading of one of a panel's sections. */
|
|
4368
4413
|
function sectionTitle(text) {
|
|
4369
4414
|
return dom.element('h6', { 'class': 'ge-section-title' }, text);
|
|
@@ -4463,7 +4508,13 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4463
4508
|
var mode = panelMode();
|
|
4464
4509
|
|
|
4465
4510
|
if (mode === 'inline') {
|
|
4466
|
-
dom.
|
|
4511
|
+
if (dom.visible(details)) {
|
|
4512
|
+
dom.hide(details);
|
|
4513
|
+
dropPanelBody(details);
|
|
4514
|
+
} else {
|
|
4515
|
+
buildPanelBody(details);
|
|
4516
|
+
dom.show(details);
|
|
4517
|
+
}
|
|
4467
4518
|
return;
|
|
4468
4519
|
}
|
|
4469
4520
|
|
|
@@ -4487,6 +4538,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4487
4538
|
};
|
|
4488
4539
|
|
|
4489
4540
|
dom.one(panel, '.ge-settings-title').textContent = t('panel.title', { kind: kindLabel(node) });
|
|
4541
|
+
buildPanelBody(details);
|
|
4490
4542
|
dom.one(panel, '.ge-settings-body').appendChild(details);
|
|
4491
4543
|
dom.show(details);
|
|
4492
4544
|
dom.addClass(node, 'ge-settings-target');
|
|
@@ -4554,6 +4606,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4554
4606
|
|
|
4555
4607
|
/** A node's panel back where it was in its drawer, and the node no longer marked. */
|
|
4556
4608
|
function returnPanel(open) {
|
|
4609
|
+
dropPanelBody(open.details);
|
|
4557
4610
|
dom.removeClass(open.node, 'ge-settings-target');
|
|
4558
4611
|
open.details.style.removeProperty('display');
|
|
4559
4612
|
dom.dropEmptyStyle(open.details);
|
|
@@ -4784,6 +4837,7 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
4784
4837
|
|
|
4785
4838
|
sidebarShown = { node: activeTarget, details: details, home: details.parentElement, next: details.nextElementSibling };
|
|
4786
4839
|
setSidebarTitle(t('panel.title', { kind: kindLabel(activeTarget) }));
|
|
4840
|
+
buildPanelBody(details);
|
|
4787
4841
|
holder.appendChild(details);
|
|
4788
4842
|
dom.show(details);
|
|
4789
4843
|
}
|
|
@@ -5507,8 +5561,20 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
5507
5561
|
var wholeDrawer = settings.drag_handle === 'drawer';
|
|
5508
5562
|
var cancel = dragCancelSelector();
|
|
5509
5563
|
var soloGroup = 0;
|
|
5564
|
+
var kind = options.draggable + '|' + (options.group || '');
|
|
5565
|
+
|
|
5566
|
+
// init() runs after every add, and makes the canvas sortable
|
|
5567
|
+
// again: the lists it already made keep their instance, and the
|
|
5568
|
+
// ones taken off the canvas since lose theirs. Without this every
|
|
5569
|
+
// list gathered one more instance, and its listeners, per change.
|
|
5570
|
+
dropDetachedSortables();
|
|
5510
5571
|
|
|
5511
5572
|
lists.forEach(function(list) {
|
|
5573
|
+
var kinds = sortableKinds.get(list);
|
|
5574
|
+
if (kinds && kinds.has(kind)) { return; }
|
|
5575
|
+
if (!kinds) { sortableKinds.set(list, kinds = new Set()); }
|
|
5576
|
+
kinds.add(kind);
|
|
5577
|
+
|
|
5512
5578
|
// A list with no group sorts only within itself, which is what
|
|
5513
5579
|
// a tab strip wants: a name of its own, closed both ways
|
|
5514
5580
|
var group = options.group
|
|
@@ -5939,6 +6005,18 @@ function build(instance, baseElem, optionsOrMethod) {
|
|
|
5939
6005
|
sortables.forEach(function(sortableInstance) { sortableInstance.destroy(); });
|
|
5940
6006
|
|
|
5941
6007
|
sortables = [];
|
|
6008
|
+
sortableKinds = new WeakMap();
|
|
6009
|
+
}
|
|
6010
|
+
|
|
6011
|
+
/** Destroy the instances of the lists no longer in the canvas. */
|
|
6012
|
+
function dropDetachedSortables() {
|
|
6013
|
+
sortables = sortables.filter(function(sortableInstance) {
|
|
6014
|
+
if (canvas.contains(sortableInstance.el)) { return true; }
|
|
6015
|
+
|
|
6016
|
+
sortableInstance.destroy();
|
|
6017
|
+
sortableKinds.delete(sortableInstance.el);
|
|
6018
|
+
return false;
|
|
6019
|
+
});
|
|
5942
6020
|
}
|
|
5943
6021
|
|
|
5944
6022
|
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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
304
|
+
rememberSection({ container: container, element: body, render: render });
|
|
298
305
|
|
|
299
306
|
return body;
|
|
300
307
|
}
|