@themarioga/grid-editor 9.0.0-beta.3 → 9.0.0-beta.4

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 (36) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +24 -8
  3. package/dist/grideditor.bundle.min.js +2 -2
  4. package/dist/grideditor.css +187 -0
  5. package/dist/grideditor.d.ts +37 -0
  6. package/dist/grideditor.esm.js +6 -10
  7. package/dist/grideditor.js +6 -10
  8. package/dist/grideditor.min.css +1 -1
  9. package/dist/grideditor.min.css.map +1 -1
  10. package/dist/grideditor.min.js +1 -1
  11. package/dist/grideditor.min.js.map +3 -3
  12. package/dist/locales/grideditor.es.esm.js +20 -0
  13. package/dist/locales/grideditor.es.js +20 -0
  14. package/dist/locales/grideditor.es.min.js +2 -2
  15. package/dist/locales/grideditor.es.min.js.map +2 -2
  16. package/dist/plugins/grideditor.offcanvas.esm.js +551 -0
  17. package/dist/plugins/grideditor.offcanvas.js +556 -0
  18. package/dist/plugins/grideditor.offcanvas.min.js +1 -0
  19. package/dist/plugins/grideditor.offcanvas.min.js.map +7 -0
  20. package/dist/plugins/grideditor.popup.esm.js +90 -37
  21. package/dist/plugins/grideditor.popup.js +90 -37
  22. package/dist/plugins/grideditor.popup.min.js +1 -1
  23. package/dist/plugins/grideditor.popup.min.js.map +4 -4
  24. package/docs/events.md +4 -3
  25. package/docs/locale-keys.md +21 -1
  26. package/docs/plugins.md +11 -4
  27. package/example/containers.html +22 -4
  28. package/example/index.html +1 -1
  29. package/package.json +1 -1
  30. package/src/js/grideditor.js +7 -8
  31. package/src/js/locales/grideditor.es.js +20 -0
  32. package/src/js/plugins/grideditor.offcanvas.js +420 -0
  33. package/src/js/plugins/grideditor.popup.js +8 -70
  34. package/src/js/triggers/triggers.js +121 -0
  35. package/src/less/grideditor.less +60 -0
  36. package/types/grideditor.d.ts +37 -0
@@ -626,6 +626,14 @@ html.ge-sidebar-open {
626
626
  /* A popup is rendered unfolded and in place: a plain block with its
627
627
  body as an ordinary region. Bootstrap's modal JS is never asked to
628
628
  open it, so there is no backdrop, no focus trap and no scroll lock */
629
+ /* An offcanvas is rendered unfolded and in place too: a plain block with
630
+ its body as an ordinary region, whichever edge it comes from on the
631
+ page. Bootstrap fixes it to the window, hides it and shifts it out
632
+ until its own JS adds .show, which the editor never asks for, so what
633
+ it sets is undone here. The responsive classes hide the header and
634
+ the body's padding from their breakpoint up, where the panel is
635
+ content: the title still has to be there to edit */
636
+ /* A trigger pointing at an offcanvas that is not there any more */
629
637
  /* A trigger pointing at a popup that is not there any more */
630
638
  /* Elements: the level below a column, inside a content area. Dashed
631
639
  rather than solid, so a page full of them still reads as content */
@@ -925,6 +933,185 @@ html.ge-sidebar-open {
925
933
  .ge-canvas.ge-editing .ge-container-popup.ge-popup-collapsed .modal {
926
934
  display: none;
927
935
  }
936
+ .ge-canvas.ge-editing .ge-container-offcanvas {
937
+ /* d-*-none on the trigger is for the page: the editor needs it to select the container */
938
+ /* Folded away, for a page with several offcanvases on it */
939
+ }
940
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas {
941
+ position: static;
942
+ z-index: auto;
943
+ visibility: visible;
944
+ width: auto;
945
+ height: auto;
946
+ max-width: none;
947
+ max-height: none;
948
+ margin: 5px 0;
949
+ transform: none;
950
+ transition: none;
951
+ display: flex;
952
+ flex-direction: column;
953
+ background-color: var(--bs-offcanvas-bg) !important;
954
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
955
+ }
956
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas .offcanvas-header {
957
+ display: flex;
958
+ }
959
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas .offcanvas-body {
960
+ display: block;
961
+ flex-grow: 1;
962
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
963
+ overflow: visible;
964
+ }
965
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-sm {
966
+ position: static;
967
+ z-index: auto;
968
+ visibility: visible;
969
+ width: auto;
970
+ height: auto;
971
+ max-width: none;
972
+ max-height: none;
973
+ margin: 5px 0;
974
+ transform: none;
975
+ transition: none;
976
+ display: flex;
977
+ flex-direction: column;
978
+ background-color: var(--bs-offcanvas-bg) !important;
979
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
980
+ }
981
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-sm .offcanvas-header {
982
+ display: flex;
983
+ }
984
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-sm .offcanvas-body {
985
+ display: block;
986
+ flex-grow: 1;
987
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
988
+ overflow: visible;
989
+ }
990
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-md {
991
+ position: static;
992
+ z-index: auto;
993
+ visibility: visible;
994
+ width: auto;
995
+ height: auto;
996
+ max-width: none;
997
+ max-height: none;
998
+ margin: 5px 0;
999
+ transform: none;
1000
+ transition: none;
1001
+ display: flex;
1002
+ flex-direction: column;
1003
+ background-color: var(--bs-offcanvas-bg) !important;
1004
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
1005
+ }
1006
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-md .offcanvas-header {
1007
+ display: flex;
1008
+ }
1009
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-md .offcanvas-body {
1010
+ display: block;
1011
+ flex-grow: 1;
1012
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
1013
+ overflow: visible;
1014
+ }
1015
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-lg {
1016
+ position: static;
1017
+ z-index: auto;
1018
+ visibility: visible;
1019
+ width: auto;
1020
+ height: auto;
1021
+ max-width: none;
1022
+ max-height: none;
1023
+ margin: 5px 0;
1024
+ transform: none;
1025
+ transition: none;
1026
+ display: flex;
1027
+ flex-direction: column;
1028
+ background-color: var(--bs-offcanvas-bg) !important;
1029
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
1030
+ }
1031
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-lg .offcanvas-header {
1032
+ display: flex;
1033
+ }
1034
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-lg .offcanvas-body {
1035
+ display: block;
1036
+ flex-grow: 1;
1037
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
1038
+ overflow: visible;
1039
+ }
1040
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-xl {
1041
+ position: static;
1042
+ z-index: auto;
1043
+ visibility: visible;
1044
+ width: auto;
1045
+ height: auto;
1046
+ max-width: none;
1047
+ max-height: none;
1048
+ margin: 5px 0;
1049
+ transform: none;
1050
+ transition: none;
1051
+ display: flex;
1052
+ flex-direction: column;
1053
+ background-color: var(--bs-offcanvas-bg) !important;
1054
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
1055
+ }
1056
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-xl .offcanvas-header {
1057
+ display: flex;
1058
+ }
1059
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-xl .offcanvas-body {
1060
+ display: block;
1061
+ flex-grow: 1;
1062
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
1063
+ overflow: visible;
1064
+ }
1065
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-xxl {
1066
+ position: static;
1067
+ z-index: auto;
1068
+ visibility: visible;
1069
+ width: auto;
1070
+ height: auto;
1071
+ max-width: none;
1072
+ max-height: none;
1073
+ margin: 5px 0;
1074
+ transform: none;
1075
+ transition: none;
1076
+ display: flex;
1077
+ flex-direction: column;
1078
+ background-color: var(--bs-offcanvas-bg) !important;
1079
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
1080
+ }
1081
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-xxl .offcanvas-header {
1082
+ display: flex;
1083
+ }
1084
+ .ge-canvas.ge-editing .ge-container-offcanvas .offcanvas-xxl .offcanvas-body {
1085
+ display: block;
1086
+ flex-grow: 1;
1087
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
1088
+ overflow: visible;
1089
+ }
1090
+ .ge-canvas.ge-editing .ge-container-offcanvas > .ge-offcanvas-trigger {
1091
+ display: inline-block !important;
1092
+ margin-bottom: 5px;
1093
+ }
1094
+ .ge-canvas.ge-editing .ge-container-offcanvas.ge-offcanvas-collapsed .offcanvas {
1095
+ display: none;
1096
+ }
1097
+ .ge-canvas.ge-editing .ge-container-offcanvas.ge-offcanvas-collapsed .offcanvas-sm {
1098
+ display: none;
1099
+ }
1100
+ .ge-canvas.ge-editing .ge-container-offcanvas.ge-offcanvas-collapsed .offcanvas-md {
1101
+ display: none;
1102
+ }
1103
+ .ge-canvas.ge-editing .ge-container-offcanvas.ge-offcanvas-collapsed .offcanvas-lg {
1104
+ display: none;
1105
+ }
1106
+ .ge-canvas.ge-editing .ge-container-offcanvas.ge-offcanvas-collapsed .offcanvas-xl {
1107
+ display: none;
1108
+ }
1109
+ .ge-canvas.ge-editing .ge-container-offcanvas.ge-offcanvas-collapsed .offcanvas-xxl {
1110
+ display: none;
1111
+ }
1112
+ .ge-canvas.ge-editing .ge-offcanvas-orphan {
1113
+ outline: 2px dashed #d9534f;
1114
+ }
928
1115
  .ge-canvas.ge-editing .ge-popup-orphan {
929
1116
  outline: 2px dashed #d9534f;
930
1117
  }
@@ -111,6 +111,35 @@ export interface CarouselOptions {
111
111
  /** createContainer('carousel', …): the options, and how many slides. */
112
112
  export interface CreateCarouselOptions extends Placement, CarouselOptions {}
113
113
 
114
+ /**
115
+ * The offcanvas plugin's options, the ones an offcanvas made new has, as the
116
+ * offcanvas setting gives them and createContainer overrides them: where it
117
+ * comes from, its backdrop, whether the page scrolls behind it, Esc, the
118
+ * breakpoint from which it is content and not a panel, and the dark theme.
119
+ */
120
+ export interface OffcanvasOptions {
121
+ /** The edge it slides in from. Default `'start'`. */
122
+ placement?: 'start' | 'end' | 'top' | 'bottom';
123
+ /** A backdrop behind it: `true`, `false`, or `'static'`, which does not close it on a click. Default true. */
124
+ backdrop?: boolean | 'static';
125
+ /** The page can scroll while it is open. Default false. */
126
+ scroll?: boolean;
127
+ /** Esc closes it. Default true. */
128
+ keyboard?: boolean;
129
+ /** From this breakpoint up it is content in the page, and its trigger is hidden; null is a panel at every size. Default null. */
130
+ responsive?: 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | null;
131
+ /** `data-bs-theme="dark"`. Default false. */
132
+ dark?: boolean;
133
+ }
134
+
135
+ /** createContainer('offcanvas', …): the options, its title and its trigger. */
136
+ export interface CreateOffcanvasOptions extends Placement, OffcanvasOptions {
137
+ title?: string;
138
+ /** false makes none, for a trigger the page writes itself. Default true. */
139
+ trigger?: boolean;
140
+ trigger_label?: string;
141
+ }
142
+
114
143
  /** The inline-style plugin's settings. */
115
144
  export interface InlineStyleOptions {
116
145
  /** Every section is on unless it is turned off here. */
@@ -175,6 +204,8 @@ export interface GridEditorOptions {
175
204
  tabs?: TabsOptions;
176
205
  /** The carousel plugin: the options of the carousels made new. */
177
206
  carousel?: CarouselOptions;
207
+ /** The offcanvas plugin: the options of the offcanvases made new. */
208
+ offcanvas?: OffcanvasOptions;
178
209
  elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
179
210
  /** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
180
211
  autosave?: AutosaveOptions;
@@ -347,6 +378,10 @@ export interface PopupOrphanPayload extends Payload {
347
378
  missing: string;
348
379
  }
349
380
 
381
+ export interface OffcanvasOrphanPayload extends Payload {
382
+ missing: string;
383
+ }
384
+
350
385
  export interface ViewChangePayload {
351
386
  canvas: HTMLElement;
352
387
  breakpoint: View;
@@ -406,6 +441,7 @@ export interface GridEditorEventMap {
406
441
  'grideditor:after-edit-html': EditHtmlPayload;
407
442
  'grideditor:after-copy': Payload;
408
443
  'grideditor:popup-orphan': PopupOrphanPayload;
444
+ 'grideditor:offcanvas-orphan': OffcanvasOrphanPayload;
409
445
  'grideditor:view-change': ViewChangePayload;
410
446
  'grideditor:target-change': TargetChangePayload;
411
447
  'grideditor:selection-change': SelectionChangePayload;
@@ -537,6 +573,7 @@ export declare class GridEditor {
537
573
  createSection(options?: CreateSectionOptions): HTMLElement | null;
538
574
  createContainer(type: 'tabs', options?: CreateTabsOptions): HTMLElement | null;
539
575
  createContainer(type: 'carousel', options?: CreateCarouselOptions): HTMLElement | null;
576
+ createContainer(type: 'offcanvas', options?: CreateOffcanvasOptions): HTMLElement | null;
540
577
  createContainer(type: string, options?: Placement & Record<string, unknown>): HTMLElement | null;
541
578
  addTab(container: Target, options?: PaneOptions): HTMLElement | null;
542
579
  addAccordionItem(container: Target, options?: PaneOptions): HTMLElement | null;
@@ -340,9 +340,7 @@ var REFERENCES = [
340
340
  "aria-controls",
341
341
  "aria-labelledby",
342
342
  "aria-describedby",
343
- "for",
344
- "data-ge-popup-id",
345
- "data-ge-popup-target"
343
+ "for"
346
344
  ];
347
345
  var GENERATED_ID = /^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;
348
346
  var BREAKPOINTS = [
@@ -1130,11 +1128,6 @@ function build(instance, baseElem, optionsOrMethod) {
1130
1128
  var signal = { signal: lifetime.signal };
1131
1129
  window.addEventListener("scroll", onScroll, signal);
1132
1130
  delegate(canvas, "click", ".ge-content", onContentClick, signal);
1133
- delegate(canvas, "click", ".ge-popup-trigger, [data-ge-popup-target]", function(e) {
1134
- if (hasClass(canvas, "ge-editing")) {
1135
- e.preventDefault();
1136
- }
1137
- }, signal);
1138
1131
  var sidebarMode = panelMode() === "sidebar";
1139
1132
  if (settings.active_target || sidebarMode) {
1140
1133
  var pressed = null;
@@ -2926,8 +2919,11 @@ function build(instance, baseElem, optionsOrMethod) {
2926
2919
  if (!Object.keys(renamed).length) {
2927
2920
  return node;
2928
2921
  }
2922
+ var references = Object.keys(CONTAINERS).reduce(function(names, type) {
2923
+ return names.concat(CONTAINERS[type].references || []);
2924
+ }, REFERENCES);
2929
2925
  selfAndAll(node, "*").forEach(function(element2) {
2930
- REFERENCES.forEach(function(name) {
2926
+ references.forEach(function(name) {
2931
2927
  var value = element2.getAttribute(name);
2932
2928
  if (value === null) {
2933
2929
  return;
@@ -5179,7 +5175,7 @@ GridEditor.t = translate;
5179
5175
  GridEditor._plainHtml = plainHtml;
5180
5176
  GridEditor.Sortable = null;
5181
5177
  GridEditor.bootstrap = null;
5182
- GridEditor.version = false ? "dev" : "9.0.0-beta.3";
5178
+ GridEditor.version = false ? "dev" : "9.0.0-beta.4";
5183
5179
  GridEditor.locales = {
5184
5180
  en: {
5185
5181
  "tool.move": "Move",
@@ -341,9 +341,7 @@
341
341
  "aria-controls",
342
342
  "aria-labelledby",
343
343
  "aria-describedby",
344
- "for",
345
- "data-ge-popup-id",
346
- "data-ge-popup-target"
344
+ "for"
347
345
  ];
348
346
  var GENERATED_ID = /^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;
349
347
  var BREAKPOINTS = [
@@ -1131,11 +1129,6 @@
1131
1129
  var signal = { signal: lifetime.signal };
1132
1130
  window.addEventListener("scroll", onScroll, signal);
1133
1131
  delegate(canvas, "click", ".ge-content", onContentClick, signal);
1134
- delegate(canvas, "click", ".ge-popup-trigger, [data-ge-popup-target]", function(e) {
1135
- if (hasClass(canvas, "ge-editing")) {
1136
- e.preventDefault();
1137
- }
1138
- }, signal);
1139
1132
  var sidebarMode = panelMode() === "sidebar";
1140
1133
  if (settings.active_target || sidebarMode) {
1141
1134
  var pressed = null;
@@ -2927,8 +2920,11 @@
2927
2920
  if (!Object.keys(renamed).length) {
2928
2921
  return node;
2929
2922
  }
2923
+ var references = Object.keys(CONTAINERS).reduce(function(names, type) {
2924
+ return names.concat(CONTAINERS[type].references || []);
2925
+ }, REFERENCES);
2930
2926
  selfAndAll(node, "*").forEach(function(element2) {
2931
- REFERENCES.forEach(function(name) {
2927
+ references.forEach(function(name) {
2932
2928
  var value = element2.getAttribute(name);
2933
2929
  if (value === null) {
2934
2930
  return;
@@ -5180,7 +5176,7 @@
5180
5176
  GridEditor._plainHtml = plainHtml;
5181
5177
  GridEditor.Sortable = null;
5182
5178
  GridEditor.bootstrap = null;
5183
- GridEditor.version = false ? "dev" : "9.0.0-beta.3";
5179
+ GridEditor.version = false ? "dev" : "9.0.0-beta.4";
5184
5180
  GridEditor.locales = {
5185
5181
  en: {
5186
5182
  "tool.move": "Move",