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

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 +35 -0
  2. package/README.md +30 -8
  3. package/dist/grideditor.bundle.min.js +2 -2
  4. package/dist/grideditor.css +187 -0
  5. package/dist/grideditor.d.ts +44 -0
  6. package/dist/grideditor.esm.js +35 -23
  7. package/dist/grideditor.js +35 -23
  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 +728 -0
  17. package/dist/plugins/grideditor.offcanvas.js +733 -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 +267 -37
  21. package/dist/plugins/grideditor.popup.js +267 -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 +10 -3
  25. package/docs/locale-keys.md +21 -1
  26. package/docs/plugins.md +21 -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 +41 -23
  31. package/src/js/locales/grideditor.es.js +20 -0
  32. package/src/js/plugins/grideditor.offcanvas.js +423 -0
  33. package/src/js/plugins/grideditor.popup.js +10 -70
  34. package/src/js/triggers/triggers.js +321 -0
  35. package/src/less/grideditor.less +60 -0
  36. package/types/grideditor.d.ts +44 -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;
@@ -361,6 +396,12 @@ export interface TargetChangePayload {
361
396
  from: HTMLElement | null;
362
397
  }
363
398
 
399
+ /** The preview button was pressed (true) or let go (false). */
400
+ export interface PreviewChangePayload {
401
+ canvas: HTMLElement;
402
+ previewing: boolean;
403
+ }
404
+
364
405
  /** The selection changed, with settings_panel 'sidebar': the node whose settings the sidebar shows, or null. */
365
406
  export interface SelectionChangePayload {
366
407
  canvas: HTMLElement;
@@ -406,7 +447,9 @@ export interface GridEditorEventMap {
406
447
  'grideditor:after-edit-html': EditHtmlPayload;
407
448
  'grideditor:after-copy': Payload;
408
449
  'grideditor:popup-orphan': PopupOrphanPayload;
450
+ 'grideditor:offcanvas-orphan': OffcanvasOrphanPayload;
409
451
  'grideditor:view-change': ViewChangePayload;
452
+ 'grideditor:preview-change': PreviewChangePayload;
410
453
  'grideditor:target-change': TargetChangePayload;
411
454
  'grideditor:selection-change': SelectionChangePayload;
412
455
  'grideditor:after-autosave': AutosavePayload;
@@ -537,6 +580,7 @@ export declare class GridEditor {
537
580
  createSection(options?: CreateSectionOptions): HTMLElement | null;
538
581
  createContainer(type: 'tabs', options?: CreateTabsOptions): HTMLElement | null;
539
582
  createContainer(type: 'carousel', options?: CreateCarouselOptions): HTMLElement | null;
583
+ createContainer(type: 'offcanvas', options?: CreateOffcanvasOptions): HTMLElement | null;
540
584
  createContainer(type: string, options?: Placement & Record<string, unknown>): HTMLElement | null;
541
585
  addTab(container: Target, options?: PaneOptions): HTMLElement | null;
542
586
  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 = [
@@ -673,6 +671,7 @@ function build(instance, baseElem, optionsOrMethod) {
673
671
  var confirmDialog = null;
674
672
  var sizePicker = null;
675
673
  var sourceOpen = false;
674
+ var previewing = false;
676
675
  var dropMarker = null;
677
676
  var activeTarget = null;
678
677
  var toolbarLifetime = null;
@@ -1130,11 +1129,6 @@ function build(instance, baseElem, optionsOrMethod) {
1130
1129
  var signal = { signal: lifetime.signal };
1131
1130
  window.addEventListener("scroll", onScroll, signal);
1132
1131
  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
1132
  var sidebarMode = panelMode() === "sidebar";
1139
1133
  if (settings.active_target || sidebarMode) {
1140
1134
  var pressed = null;
@@ -1327,20 +1321,19 @@ function build(instance, baseElem, optionsOrMethod) {
1327
1321
  btnGroup.appendChild(htmlButton);
1328
1322
  }
1329
1323
  var previewButton = create('<button type="button" class="btn btn-sm btn-primary gm-preview"><i class="bi bi-eye-fill"></i></button>');
1330
- var endPreview = function() {
1331
- if (!hasClass(previewButton, "active")) {
1332
- addClass(canvas, "ge-editing");
1333
- }
1334
- };
1335
1324
  previewButton.setAttribute("title", t("tool.preview"));
1325
+ toggleClass(previewButton, "active btn-danger", previewing);
1336
1326
  previewButton.addEventListener("mouseenter", function() {
1337
1327
  removeClass(canvas, "ge-editing");
1338
1328
  });
1339
1329
  previewButton.addEventListener("click", function() {
1340
- toggleClass(previewButton, "active btn-danger");
1341
- endPreview();
1330
+ setPreview(!previewing);
1331
+ });
1332
+ previewButton.addEventListener("mouseleave", function() {
1333
+ if (!previewing) {
1334
+ addClass(canvas, "ge-editing");
1335
+ }
1342
1336
  });
1343
- previewButton.addEventListener("mouseleave", endPreview);
1344
1337
  btnGroup.appendChild(previewButton);
1345
1338
  if (endItems.length) {
1346
1339
  var end = wrapper.appendChild(element("div", { "class": "pull-right ge-toolbar-end" }));
@@ -1432,12 +1425,8 @@ function build(instance, baseElem, optionsOrMethod) {
1432
1425
  if (!mainControls || destroyed) {
1433
1426
  return;
1434
1427
  }
1435
- var previewing = !!one(mainControls, ".gm-preview.active");
1436
1428
  removeMainControls();
1437
1429
  createMainControls();
1438
- if (previewing) {
1439
- addClass(one(mainControls, ".gm-preview"), "active btn-danger");
1440
- }
1441
1430
  onScroll();
1442
1431
  }
1443
1432
  function removeMainControls() {
@@ -1989,7 +1978,22 @@ function build(instance, baseElem, optionsOrMethod) {
1989
1978
  deinit();
1990
1979
  init();
1991
1980
  }
1981
+ function setPreview(on2) {
1982
+ on2 = !!on2;
1983
+ if (on2 === previewing) {
1984
+ return;
1985
+ }
1986
+ previewing = on2;
1987
+ var button = mainControls ? one(mainControls, ".gm-preview") : null;
1988
+ if (button) {
1989
+ toggleClass(button, "active btn-danger", on2);
1990
+ }
1991
+ toggleClass(canvas, "ge-editing", !on2);
1992
+ plugins("onPreviewChange", on2);
1993
+ emit("preview-change", { canvas, previewing: on2 });
1994
+ }
1992
1995
  function openSource() {
1996
+ setPreview(false);
1993
1997
  deinit();
1994
1998
  changeTarget(null);
1995
1999
  changeSelection(null);
@@ -2045,7 +2049,7 @@ function build(instance, baseElem, optionsOrMethod) {
2045
2049
  closeDialog();
2046
2050
  }
2047
2051
  runFilter(true);
2048
- addClass(canvas, "ge-editing");
2052
+ toggleClass(canvas, "ge-editing", !previewing);
2049
2053
  toggleClass(canvas, "ge-drag-drawer", settings.drag_handle === "drawer");
2050
2054
  addAllColClasses();
2051
2055
  var cutter = textCutter();
@@ -2219,6 +2223,7 @@ function build(instance, baseElem, optionsOrMethod) {
2219
2223
  });
2220
2224
  }
2221
2225
  }
2226
+ setPreview(false);
2222
2227
  deinit();
2223
2228
  setHtml(canvas, html);
2224
2229
  init();
@@ -2228,6 +2233,7 @@ function build(instance, baseElem, optionsOrMethod) {
2228
2233
  if (sourceOpen) {
2229
2234
  closeSource();
2230
2235
  }
2236
+ setPreview(false);
2231
2237
  deinit();
2232
2238
  activeTarget = null;
2233
2239
  selected = null;
@@ -2322,6 +2328,9 @@ function build(instance, baseElem, optionsOrMethod) {
2322
2328
  operate,
2323
2329
  kindOf,
2324
2330
  view: getView,
2331
+ previewing: function() {
2332
+ return previewing;
2333
+ },
2325
2334
  viewTiers: function() {
2326
2335
  return tiersFor(curView).map(function(tier) {
2327
2336
  return tier.key;
@@ -2926,8 +2935,11 @@ function build(instance, baseElem, optionsOrMethod) {
2926
2935
  if (!Object.keys(renamed).length) {
2927
2936
  return node;
2928
2937
  }
2938
+ var references = Object.keys(CONTAINERS).reduce(function(names, type) {
2939
+ return names.concat(CONTAINERS[type].references || []);
2940
+ }, REFERENCES);
2929
2941
  selfAndAll(node, "*").forEach(function(element2) {
2930
- REFERENCES.forEach(function(name) {
2942
+ references.forEach(function(name) {
2931
2943
  var value = element2.getAttribute(name);
2932
2944
  if (value === null) {
2933
2945
  return;
@@ -5179,7 +5191,7 @@ GridEditor.t = translate;
5179
5191
  GridEditor._plainHtml = plainHtml;
5180
5192
  GridEditor.Sortable = null;
5181
5193
  GridEditor.bootstrap = null;
5182
- GridEditor.version = false ? "dev" : "9.0.0-beta.3";
5194
+ GridEditor.version = false ? "dev" : "9.0.0-beta.5";
5183
5195
  GridEditor.locales = {
5184
5196
  en: {
5185
5197
  "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 = [
@@ -674,6 +672,7 @@
674
672
  var confirmDialog = null;
675
673
  var sizePicker = null;
676
674
  var sourceOpen = false;
675
+ var previewing = false;
677
676
  var dropMarker = null;
678
677
  var activeTarget = null;
679
678
  var toolbarLifetime = null;
@@ -1131,11 +1130,6 @@
1131
1130
  var signal = { signal: lifetime.signal };
1132
1131
  window.addEventListener("scroll", onScroll, signal);
1133
1132
  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
1133
  var sidebarMode = panelMode() === "sidebar";
1140
1134
  if (settings.active_target || sidebarMode) {
1141
1135
  var pressed = null;
@@ -1328,20 +1322,19 @@
1328
1322
  btnGroup.appendChild(htmlButton);
1329
1323
  }
1330
1324
  var previewButton = create('<button type="button" class="btn btn-sm btn-primary gm-preview"><i class="bi bi-eye-fill"></i></button>');
1331
- var endPreview = function() {
1332
- if (!hasClass(previewButton, "active")) {
1333
- addClass(canvas, "ge-editing");
1334
- }
1335
- };
1336
1325
  previewButton.setAttribute("title", t("tool.preview"));
1326
+ toggleClass(previewButton, "active btn-danger", previewing);
1337
1327
  previewButton.addEventListener("mouseenter", function() {
1338
1328
  removeClass(canvas, "ge-editing");
1339
1329
  });
1340
1330
  previewButton.addEventListener("click", function() {
1341
- toggleClass(previewButton, "active btn-danger");
1342
- endPreview();
1331
+ setPreview(!previewing);
1332
+ });
1333
+ previewButton.addEventListener("mouseleave", function() {
1334
+ if (!previewing) {
1335
+ addClass(canvas, "ge-editing");
1336
+ }
1343
1337
  });
1344
- previewButton.addEventListener("mouseleave", endPreview);
1345
1338
  btnGroup.appendChild(previewButton);
1346
1339
  if (endItems.length) {
1347
1340
  var end = wrapper.appendChild(element("div", { "class": "pull-right ge-toolbar-end" }));
@@ -1433,12 +1426,8 @@
1433
1426
  if (!mainControls || destroyed) {
1434
1427
  return;
1435
1428
  }
1436
- var previewing = !!one(mainControls, ".gm-preview.active");
1437
1429
  removeMainControls();
1438
1430
  createMainControls();
1439
- if (previewing) {
1440
- addClass(one(mainControls, ".gm-preview"), "active btn-danger");
1441
- }
1442
1431
  onScroll();
1443
1432
  }
1444
1433
  function removeMainControls() {
@@ -1990,7 +1979,22 @@
1990
1979
  deinit();
1991
1980
  init();
1992
1981
  }
1982
+ function setPreview(on2) {
1983
+ on2 = !!on2;
1984
+ if (on2 === previewing) {
1985
+ return;
1986
+ }
1987
+ previewing = on2;
1988
+ var button = mainControls ? one(mainControls, ".gm-preview") : null;
1989
+ if (button) {
1990
+ toggleClass(button, "active btn-danger", on2);
1991
+ }
1992
+ toggleClass(canvas, "ge-editing", !on2);
1993
+ plugins("onPreviewChange", on2);
1994
+ emit("preview-change", { canvas, previewing: on2 });
1995
+ }
1993
1996
  function openSource() {
1997
+ setPreview(false);
1994
1998
  deinit();
1995
1999
  changeTarget(null);
1996
2000
  changeSelection(null);
@@ -2046,7 +2050,7 @@
2046
2050
  closeDialog();
2047
2051
  }
2048
2052
  runFilter(true);
2049
- addClass(canvas, "ge-editing");
2053
+ toggleClass(canvas, "ge-editing", !previewing);
2050
2054
  toggleClass(canvas, "ge-drag-drawer", settings.drag_handle === "drawer");
2051
2055
  addAllColClasses();
2052
2056
  var cutter = textCutter();
@@ -2220,6 +2224,7 @@
2220
2224
  });
2221
2225
  }
2222
2226
  }
2227
+ setPreview(false);
2223
2228
  deinit();
2224
2229
  setHtml(canvas, html);
2225
2230
  init();
@@ -2229,6 +2234,7 @@
2229
2234
  if (sourceOpen) {
2230
2235
  closeSource();
2231
2236
  }
2237
+ setPreview(false);
2232
2238
  deinit();
2233
2239
  activeTarget = null;
2234
2240
  selected = null;
@@ -2323,6 +2329,9 @@
2323
2329
  operate,
2324
2330
  kindOf,
2325
2331
  view: getView,
2332
+ previewing: function() {
2333
+ return previewing;
2334
+ },
2326
2335
  viewTiers: function() {
2327
2336
  return tiersFor(curView).map(function(tier) {
2328
2337
  return tier.key;
@@ -2927,8 +2936,11 @@
2927
2936
  if (!Object.keys(renamed).length) {
2928
2937
  return node;
2929
2938
  }
2939
+ var references = Object.keys(CONTAINERS).reduce(function(names, type) {
2940
+ return names.concat(CONTAINERS[type].references || []);
2941
+ }, REFERENCES);
2930
2942
  selfAndAll(node, "*").forEach(function(element2) {
2931
- REFERENCES.forEach(function(name) {
2943
+ references.forEach(function(name) {
2932
2944
  var value = element2.getAttribute(name);
2933
2945
  if (value === null) {
2934
2946
  return;
@@ -5180,7 +5192,7 @@
5180
5192
  GridEditor._plainHtml = plainHtml;
5181
5193
  GridEditor.Sortable = null;
5182
5194
  GridEditor.bootstrap = null;
5183
- GridEditor.version = false ? "dev" : "9.0.0-beta.3";
5195
+ GridEditor.version = false ? "dev" : "9.0.0-beta.5";
5184
5196
  GridEditor.locales = {
5185
5197
  en: {
5186
5198
  "tool.move": "Move",