@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.
Files changed (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/grideditor.bundle.min.js +2 -2
  3. package/dist/grideditor.esm.js +78 -10
  4. package/dist/grideditor.js +78 -10
  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 +4 -1
  16. package/dist/plugins/grideditor.inline-style.js +4 -1
  17. package/dist/plugins/grideditor.inline-style.min.js +3 -3
  18. package/dist/plugins/grideditor.inline-style.min.js.map +2 -2
  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 +85 -7
  34. package/src/js/inline-style/catalog.js +1 -1
  35. package/src/js/plugins/grideditor.carousel.js +9 -2
  36. package/src/js/plugins/grideditor.clipboard.js +1 -1
  37. package/src/js/plugins/grideditor.inline-style.js +3 -0
  38. package/src/js/plugins/grideditor.offcanvas.js +8 -1
  39. package/src/js/plugins/grideditor.sections.js +1 -1
  40. package/src/js/plugins/grideditor.tabs.js +8 -1
@@ -685,6 +685,7 @@ function build(instance, baseElem, optionsOrMethod) {
685
685
  var toolbarGroup = null;
686
686
  var warnedHere = {};
687
687
  var sortables = [];
688
+ var sortableKinds = /* @__PURE__ */ new WeakMap();
688
689
  var instanceId = ++editorCounter;
689
690
  var destroyed = false;
690
691
  var sidebarCollapsed = null;
@@ -698,6 +699,7 @@ function build(instance, baseElem, optionsOrMethod) {
698
699
  }
699
700
  }
700
701
  var detailsFor = /* @__PURE__ */ new WeakMap();
702
+ var panelBodies = /* @__PURE__ */ new WeakMap();
701
703
  var toolActions = /* @__PURE__ */ new WeakMap();
702
704
  var pendingDelete = null;
703
705
  var moves = /* @__PURE__ */ new WeakMap();
@@ -2476,8 +2478,16 @@ function build(instance, baseElem, optionsOrMethod) {
2476
2478
  attachPicker,
2477
2479
  openPicker,
2478
2480
  closePicker: closeSizePicker,
2479
- // A node's settings panel, in its drawer or open outside it
2480
- detailsOf,
2481
+ // A node's settings panel, in its drawer or open outside it,
2482
+ // whole: { build: false } for it as it is, without what is
2483
+ // built only while it is open
2484
+ detailsOf: function(node, options) {
2485
+ var details = detailsOf(node);
2486
+ if (details && !(options && options.build === false)) {
2487
+ buildPanelBody(details);
2488
+ }
2489
+ return details;
2490
+ },
2481
2491
  // A node's drawer: its first child, or for a content area the
2482
2492
  // one beside it in its text block
2483
2493
  drawerOf,
@@ -3668,14 +3678,42 @@ function build(instance, baseElem, optionsOrMethod) {
3668
3678
  });
3669
3679
  classGroup.appendChild(btn);
3670
3680
  });
3671
- pluginSections(container).forEach(function(section) {
3672
- detailsDiv.appendChild(section);
3673
- });
3674
- var utilities = createUtilitiesSection(container);
3681
+ var anchor = detailsDiv.appendChild(document.createComment(" ge-details-body "));
3682
+ panelBodies.set(detailsDiv, { node: container, anchor, nodes: null });
3683
+ return detailsDiv;
3684
+ }
3685
+ function buildPanelBody(details) {
3686
+ var body = panelBodies.get(details);
3687
+ if (!body || body.nodes) {
3688
+ return;
3689
+ }
3690
+ var nodes = pluginSections(body.node);
3691
+ var utilities = createUtilitiesSection(body.node);
3675
3692
  if (utilities) {
3676
- detailsDiv.appendChild(utilities);
3693
+ nodes.push(utilities);
3677
3694
  }
3678
- return detailsDiv;
3695
+ nodes.forEach(function(node) {
3696
+ details.insertBefore(node, body.anchor);
3697
+ });
3698
+ body.nodes = nodes;
3699
+ }
3700
+ function dropPanelBody(details) {
3701
+ var body = panelBodies.get(details);
3702
+ if (!body || !body.nodes) {
3703
+ return;
3704
+ }
3705
+ if (dialogState && dialogState.home && details.contains(dialogState.home)) {
3706
+ closeDialog();
3707
+ }
3708
+ body.nodes.forEach(function(node) {
3709
+ node.remove();
3710
+ });
3711
+ body.nodes = null;
3712
+ pluginFields.forEach(function(fieldNode, field) {
3713
+ if (!field.isConnected) {
3714
+ pluginFields.delete(field);
3715
+ }
3716
+ });
3679
3717
  }
3680
3718
  function sectionTitle(text) {
3681
3719
  return element("h6", { "class": "ge-section-title" }, text);
@@ -3743,7 +3781,13 @@ function build(instance, baseElem, optionsOrMethod) {
3743
3781
  function toggleSettings(node, details, gear) {
3744
3782
  var mode = panelMode();
3745
3783
  if (mode === "inline") {
3746
- toggle(details);
3784
+ if (visible(details)) {
3785
+ hide(details);
3786
+ dropPanelBody(details);
3787
+ } else {
3788
+ buildPanelBody(details);
3789
+ show(details);
3790
+ }
3747
3791
  return;
3748
3792
  }
3749
3793
  var same = openSettingsState && openSettingsState.details === details;
@@ -3765,6 +3809,7 @@ function build(instance, baseElem, optionsOrMethod) {
3765
3809
  listening
3766
3810
  };
3767
3811
  one(panel, ".ge-settings-title").textContent = t("panel.title", { kind: kindLabel(node) });
3812
+ buildPanelBody(details);
3768
3813
  one(panel, ".ge-settings-body").appendChild(details);
3769
3814
  show(details);
3770
3815
  addClass(node, "ge-settings-target");
@@ -3831,6 +3876,7 @@ function build(instance, baseElem, optionsOrMethod) {
3831
3876
  returnPanel(open);
3832
3877
  }
3833
3878
  function returnPanel(open) {
3879
+ dropPanelBody(open.details);
3834
3880
  removeClass(open.node, "ge-settings-target");
3835
3881
  open.details.style.removeProperty("display");
3836
3882
  dropEmptyStyle(open.details);
@@ -4016,6 +4062,7 @@ function build(instance, baseElem, optionsOrMethod) {
4016
4062
  }
4017
4063
  sidebarShown = { node: activeTarget, details, home: details.parentElement, next: details.nextElementSibling };
4018
4064
  setSidebarTitle(t("panel.title", { kind: kindLabel(activeTarget) }));
4065
+ buildPanelBody(details);
4019
4066
  holder.appendChild(details);
4020
4067
  show(details);
4021
4068
  }
@@ -4508,7 +4555,17 @@ function build(instance, baseElem, optionsOrMethod) {
4508
4555
  var wholeDrawer = settings.drag_handle === "drawer";
4509
4556
  var cancel = dragCancelSelector();
4510
4557
  var soloGroup = 0;
4558
+ var kind = options.draggable + "|" + (options.group || "");
4559
+ dropDetachedSortables();
4511
4560
  lists.forEach(function(list) {
4561
+ var kinds = sortableKinds.get(list);
4562
+ if (kinds && kinds.has(kind)) {
4563
+ return;
4564
+ }
4565
+ if (!kinds) {
4566
+ sortableKinds.set(list, kinds = /* @__PURE__ */ new Set());
4567
+ }
4568
+ kinds.add(kind);
4512
4569
  var group = options.group ? { name: groupName(options.group) } : { name: groupName(options.draggable + "-" + ++soloGroup), pull: false, put: false };
4513
4570
  if (options.group && options.accepts) {
4514
4571
  group.put = function(to, from, dragged) {
@@ -4818,6 +4875,17 @@ function build(instance, baseElem, optionsOrMethod) {
4818
4875
  sortableInstance.destroy();
4819
4876
  });
4820
4877
  sortables = [];
4878
+ sortableKinds = /* @__PURE__ */ new WeakMap();
4879
+ }
4880
+ function dropDetachedSortables() {
4881
+ sortables = sortables.filter(function(sortableInstance) {
4882
+ if (canvas.contains(sortableInstance.el)) {
4883
+ return true;
4884
+ }
4885
+ sortableInstance.destroy();
4886
+ sortableKinds.delete(sortableInstance.el);
4887
+ return false;
4888
+ });
4821
4889
  }
4822
4890
  function createRow() {
4823
4891
  return element("div", { "class": "row" });
@@ -5270,7 +5338,7 @@ GridEditor.t = translate;
5270
5338
  GridEditor._plainHtml = plainHtml;
5271
5339
  GridEditor.Sortable = null;
5272
5340
  GridEditor.bootstrap = null;
5273
- GridEditor.version = false ? "dev" : "9.0.0";
5341
+ GridEditor.version = false ? "dev" : "9.1.0";
5274
5342
  GridEditor.locales = {
5275
5343
  en: {
5276
5344
  "tool.move": "Move",
@@ -686,6 +686,7 @@
686
686
  var toolbarGroup = null;
687
687
  var warnedHere = {};
688
688
  var sortables = [];
689
+ var sortableKinds = /* @__PURE__ */ new WeakMap();
689
690
  var instanceId = ++editorCounter;
690
691
  var destroyed = false;
691
692
  var sidebarCollapsed = null;
@@ -699,6 +700,7 @@
699
700
  }
700
701
  }
701
702
  var detailsFor = /* @__PURE__ */ new WeakMap();
703
+ var panelBodies = /* @__PURE__ */ new WeakMap();
702
704
  var toolActions = /* @__PURE__ */ new WeakMap();
703
705
  var pendingDelete = null;
704
706
  var moves = /* @__PURE__ */ new WeakMap();
@@ -2477,8 +2479,16 @@
2477
2479
  attachPicker,
2478
2480
  openPicker,
2479
2481
  closePicker: closeSizePicker,
2480
- // A node's settings panel, in its drawer or open outside it
2481
- detailsOf,
2482
+ // A node's settings panel, in its drawer or open outside it,
2483
+ // whole: { build: false } for it as it is, without what is
2484
+ // built only while it is open
2485
+ detailsOf: function(node, options) {
2486
+ var details = detailsOf(node);
2487
+ if (details && !(options && options.build === false)) {
2488
+ buildPanelBody(details);
2489
+ }
2490
+ return details;
2491
+ },
2482
2492
  // A node's drawer: its first child, or for a content area the
2483
2493
  // one beside it in its text block
2484
2494
  drawerOf,
@@ -3669,14 +3679,42 @@
3669
3679
  });
3670
3680
  classGroup.appendChild(btn);
3671
3681
  });
3672
- pluginSections(container).forEach(function(section) {
3673
- detailsDiv.appendChild(section);
3674
- });
3675
- var utilities = createUtilitiesSection(container);
3682
+ var anchor = detailsDiv.appendChild(document.createComment(" ge-details-body "));
3683
+ panelBodies.set(detailsDiv, { node: container, anchor, nodes: null });
3684
+ return detailsDiv;
3685
+ }
3686
+ function buildPanelBody(details) {
3687
+ var body = panelBodies.get(details);
3688
+ if (!body || body.nodes) {
3689
+ return;
3690
+ }
3691
+ var nodes = pluginSections(body.node);
3692
+ var utilities = createUtilitiesSection(body.node);
3676
3693
  if (utilities) {
3677
- detailsDiv.appendChild(utilities);
3694
+ nodes.push(utilities);
3678
3695
  }
3679
- return detailsDiv;
3696
+ nodes.forEach(function(node) {
3697
+ details.insertBefore(node, body.anchor);
3698
+ });
3699
+ body.nodes = nodes;
3700
+ }
3701
+ function dropPanelBody(details) {
3702
+ var body = panelBodies.get(details);
3703
+ if (!body || !body.nodes) {
3704
+ return;
3705
+ }
3706
+ if (dialogState && dialogState.home && details.contains(dialogState.home)) {
3707
+ closeDialog();
3708
+ }
3709
+ body.nodes.forEach(function(node) {
3710
+ node.remove();
3711
+ });
3712
+ body.nodes = null;
3713
+ pluginFields.forEach(function(fieldNode, field) {
3714
+ if (!field.isConnected) {
3715
+ pluginFields.delete(field);
3716
+ }
3717
+ });
3680
3718
  }
3681
3719
  function sectionTitle(text) {
3682
3720
  return element("h6", { "class": "ge-section-title" }, text);
@@ -3744,7 +3782,13 @@
3744
3782
  function toggleSettings(node, details, gear) {
3745
3783
  var mode = panelMode();
3746
3784
  if (mode === "inline") {
3747
- toggle(details);
3785
+ if (visible(details)) {
3786
+ hide(details);
3787
+ dropPanelBody(details);
3788
+ } else {
3789
+ buildPanelBody(details);
3790
+ show(details);
3791
+ }
3748
3792
  return;
3749
3793
  }
3750
3794
  var same = openSettingsState && openSettingsState.details === details;
@@ -3766,6 +3810,7 @@
3766
3810
  listening
3767
3811
  };
3768
3812
  one(panel, ".ge-settings-title").textContent = t("panel.title", { kind: kindLabel(node) });
3813
+ buildPanelBody(details);
3769
3814
  one(panel, ".ge-settings-body").appendChild(details);
3770
3815
  show(details);
3771
3816
  addClass(node, "ge-settings-target");
@@ -3832,6 +3877,7 @@
3832
3877
  returnPanel(open);
3833
3878
  }
3834
3879
  function returnPanel(open) {
3880
+ dropPanelBody(open.details);
3835
3881
  removeClass(open.node, "ge-settings-target");
3836
3882
  open.details.style.removeProperty("display");
3837
3883
  dropEmptyStyle(open.details);
@@ -4017,6 +4063,7 @@
4017
4063
  }
4018
4064
  sidebarShown = { node: activeTarget, details, home: details.parentElement, next: details.nextElementSibling };
4019
4065
  setSidebarTitle(t("panel.title", { kind: kindLabel(activeTarget) }));
4066
+ buildPanelBody(details);
4020
4067
  holder.appendChild(details);
4021
4068
  show(details);
4022
4069
  }
@@ -4509,7 +4556,17 @@
4509
4556
  var wholeDrawer = settings.drag_handle === "drawer";
4510
4557
  var cancel = dragCancelSelector();
4511
4558
  var soloGroup = 0;
4559
+ var kind = options.draggable + "|" + (options.group || "");
4560
+ dropDetachedSortables();
4512
4561
  lists.forEach(function(list) {
4562
+ var kinds = sortableKinds.get(list);
4563
+ if (kinds && kinds.has(kind)) {
4564
+ return;
4565
+ }
4566
+ if (!kinds) {
4567
+ sortableKinds.set(list, kinds = /* @__PURE__ */ new Set());
4568
+ }
4569
+ kinds.add(kind);
4513
4570
  var group = options.group ? { name: groupName(options.group) } : { name: groupName(options.draggable + "-" + ++soloGroup), pull: false, put: false };
4514
4571
  if (options.group && options.accepts) {
4515
4572
  group.put = function(to, from, dragged) {
@@ -4819,6 +4876,17 @@
4819
4876
  sortableInstance.destroy();
4820
4877
  });
4821
4878
  sortables = [];
4879
+ sortableKinds = /* @__PURE__ */ new WeakMap();
4880
+ }
4881
+ function dropDetachedSortables() {
4882
+ sortables = sortables.filter(function(sortableInstance) {
4883
+ if (canvas.contains(sortableInstance.el)) {
4884
+ return true;
4885
+ }
4886
+ sortableInstance.destroy();
4887
+ sortableKinds.delete(sortableInstance.el);
4888
+ return false;
4889
+ });
4822
4890
  }
4823
4891
  function createRow() {
4824
4892
  return element("div", { "class": "row" });
@@ -5271,7 +5339,7 @@
5271
5339
  GridEditor._plainHtml = plainHtml;
5272
5340
  GridEditor.Sortable = null;
5273
5341
  GridEditor.bootstrap = null;
5274
- GridEditor.version = false ? "dev" : "9.0.0";
5342
+ GridEditor.version = false ? "dev" : "9.1.0";
5275
5343
  GridEditor.locales = {
5276
5344
  en: {
5277
5345
  "tool.move": "Move",