@themarioga/grid-editor 9.0.0-beta.2 → 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 (43) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +76 -8
  3. package/dist/grideditor.bundle.min.js +2 -2
  4. package/dist/grideditor.css +187 -0
  5. package/dist/grideditor.d.ts +75 -0
  6. package/dist/grideditor.esm.js +38 -11
  7. package/dist/grideditor.js +38 -11
  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 +22 -0
  13. package/dist/locales/grideditor.es.js +22 -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.history.esm.js +360 -0
  17. package/dist/plugins/grideditor.history.js +365 -0
  18. package/dist/plugins/grideditor.history.min.js +1 -0
  19. package/dist/plugins/grideditor.history.min.js.map +7 -0
  20. package/dist/plugins/grideditor.offcanvas.esm.js +551 -0
  21. package/dist/plugins/grideditor.offcanvas.js +556 -0
  22. package/dist/plugins/grideditor.offcanvas.min.js +1 -0
  23. package/dist/plugins/grideditor.offcanvas.min.js.map +7 -0
  24. package/dist/plugins/grideditor.popup.esm.js +90 -37
  25. package/dist/plugins/grideditor.popup.js +90 -37
  26. package/dist/plugins/grideditor.popup.min.js +1 -1
  27. package/dist/plugins/grideditor.popup.min.js.map +4 -4
  28. package/docs/events.md +7 -3
  29. package/docs/locale-keys.md +32 -1
  30. package/docs/plugins.md +19 -5
  31. package/example/clipboard.html +22 -0
  32. package/example/containers.html +22 -4
  33. package/example/history.html +94 -0
  34. package/example/index.html +9 -1
  35. package/package.json +1 -1
  36. package/src/js/grideditor.js +37 -9
  37. package/src/js/locales/grideditor.es.js +22 -0
  38. package/src/js/plugins/grideditor.history.js +367 -0
  39. package/src/js/plugins/grideditor.offcanvas.js +420 -0
  40. package/src/js/plugins/grideditor.popup.js +8 -70
  41. package/src/js/triggers/triggers.js +121 -0
  42. package/src/less/grideditor.less +60 -0
  43. package/types/grideditor.d.ts +75 -0
@@ -1040,6 +1040,66 @@ html.ge-sidebar-open {
1040
1040
  }
1041
1041
  }
1042
1042
 
1043
+ /* An offcanvas is rendered unfolded and in place too: a plain block with
1044
+ its body as an ordinary region, whichever edge it comes from on the
1045
+ page. Bootstrap fixes it to the window, hides it and shifts it out
1046
+ until its own JS adds .show, which the editor never asks for, so what
1047
+ it sets is undone here. The responsive classes hide the header and
1048
+ the body's padding from their breakpoint up, where the panel is
1049
+ content: the title still has to be there to edit */
1050
+ @ge-offcanvases: offcanvas, offcanvas-sm, offcanvas-md, offcanvas-lg, offcanvas-xl, offcanvas-xxl;
1051
+
1052
+ .ge-container-offcanvas {
1053
+ each(@ge-offcanvases, {
1054
+ .@{value} {
1055
+ position: static;
1056
+ z-index: auto;
1057
+ visibility: visible;
1058
+ width: auto;
1059
+ height: auto;
1060
+ max-width: none;
1061
+ max-height: none;
1062
+ margin: @editGutter 0;
1063
+ transform: none;
1064
+ transition: none;
1065
+ display: flex;
1066
+ flex-direction: column;
1067
+ background-color: var(--bs-offcanvas-bg) !important;
1068
+ border: var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);
1069
+
1070
+ .offcanvas-header {
1071
+ display: flex;
1072
+ }
1073
+ .offcanvas-body {
1074
+ display: block;
1075
+ flex-grow: 1;
1076
+ padding: var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);
1077
+ overflow: visible;
1078
+ }
1079
+ }
1080
+ });
1081
+
1082
+ /* d-*-none on the trigger is for the page: the editor needs it to select the container */
1083
+ > .ge-offcanvas-trigger {
1084
+ display: inline-block !important;
1085
+ margin-bottom: @editGutter;
1086
+ }
1087
+
1088
+ /* Folded away, for a page with several offcanvases on it */
1089
+ &.ge-offcanvas-collapsed {
1090
+ each(@ge-offcanvases, {
1091
+ .@{value} {
1092
+ display: none;
1093
+ }
1094
+ });
1095
+ }
1096
+ }
1097
+
1098
+ /* A trigger pointing at an offcanvas that is not there any more */
1099
+ .ge-offcanvas-orphan {
1100
+ outline: 2px dashed #d9534f;
1101
+ }
1102
+
1043
1103
  /* A trigger pointing at a popup that is not there any more */
1044
1104
  .ge-popup-orphan {
1045
1105
  outline: 2px dashed #d9534f;
@@ -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,11 +204,15 @@ 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;
181
212
  /** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the node selected or the target; default active_target. */
182
213
  clipboard?: { shortcuts?: boolean };
214
+ /** The history plugin: undo and redo. */
215
+ history?: HistoryOptions;
183
216
  custom_filter?: CustomFilter | CustomFilter[] | '';
184
217
  valid_col_sizes?: ColumnSize[];
185
218
  valid_col_offsets?: number[];
@@ -222,6 +255,18 @@ export interface AutosaveOptions {
222
255
  maxAge?: number | null;
223
256
  }
224
257
 
258
+ /** The history plugin's options. */
259
+ export interface HistoryOptions {
260
+ /** Ctrl+Z, and Ctrl+Y or Ctrl+Shift+Z (⌘ on a Mac). Default true. */
261
+ shortcuts?: boolean;
262
+ /** The undo and redo buttons on the right of the toolbar. Default true. */
263
+ buttons?: boolean;
264
+ /** The steps that can be undone. Default 50. */
265
+ max?: number;
266
+ /** Milliseconds after the last change that make a step. Default 500. */
267
+ delay?: number;
268
+ }
269
+
225
270
  /** A draft the autosave plugin kept. */
226
271
  export interface AutosaveDraft {
227
272
  html: string;
@@ -252,6 +297,19 @@ export interface AutosaveErrorPayload {
252
297
  error: unknown;
253
298
  }
254
299
 
300
+ export interface HistoryPayload {
301
+ canvas: HTMLElement;
302
+ /** The markup the canvas went to. */
303
+ html: string;
304
+ source: 'shortcut' | 'tool' | 'api';
305
+ }
306
+
307
+ export interface HistoryChangePayload {
308
+ canvas: HTMLElement;
309
+ canUndo: boolean;
310
+ canRedo: boolean;
311
+ }
312
+
255
313
  /** Where a node was, or went: its parent and its index among the blocks there. */
256
314
  export interface Position {
257
315
  parent: HTMLElement;
@@ -320,6 +378,10 @@ export interface PopupOrphanPayload extends Payload {
320
378
  missing: string;
321
379
  }
322
380
 
381
+ export interface OffcanvasOrphanPayload extends Payload {
382
+ missing: string;
383
+ }
384
+
323
385
  export interface ViewChangePayload {
324
386
  canvas: HTMLElement;
325
387
  breakpoint: View;
@@ -379,12 +441,16 @@ export interface GridEditorEventMap {
379
441
  'grideditor:after-edit-html': EditHtmlPayload;
380
442
  'grideditor:after-copy': Payload;
381
443
  'grideditor:popup-orphan': PopupOrphanPayload;
444
+ 'grideditor:offcanvas-orphan': OffcanvasOrphanPayload;
382
445
  'grideditor:view-change': ViewChangePayload;
383
446
  'grideditor:target-change': TargetChangePayload;
384
447
  'grideditor:selection-change': SelectionChangePayload;
385
448
  'grideditor:after-autosave': AutosavePayload;
386
449
  'grideditor:after-restore-draft': RestoreDraftPayload;
387
450
  'grideditor:autosave-error': AutosaveErrorPayload;
451
+ 'grideditor:after-undo': HistoryPayload;
452
+ 'grideditor:after-redo': HistoryPayload;
453
+ 'grideditor:history-change': HistoryChangePayload;
388
454
  }
389
455
 
390
456
  /** An event the editor dispatches on its canvas: a CustomEvent whose detail is the payload. */
@@ -507,6 +573,7 @@ export declare class GridEditor {
507
573
  createSection(options?: CreateSectionOptions): HTMLElement | null;
508
574
  createContainer(type: 'tabs', options?: CreateTabsOptions): HTMLElement | null;
509
575
  createContainer(type: 'carousel', options?: CreateCarouselOptions): HTMLElement | null;
576
+ createContainer(type: 'offcanvas', options?: CreateOffcanvasOptions): HTMLElement | null;
510
577
  createContainer(type: string, options?: Placement & Record<string, unknown>): HTMLElement | null;
511
578
  addTab(container: Target, options?: PaneOptions): HTMLElement | null;
512
579
  addAccordionItem(container: Target, options?: PaneOptions): HTMLElement | null;
@@ -523,6 +590,14 @@ export declare class GridEditor {
523
590
  saveDraft?(): boolean;
524
591
  getDraft?(): AutosaveDraft | null;
525
592
  clearDraft?(): boolean;
593
+ /** The history plugin's, when it is loaded: true when it went to another step. */
594
+ undo?(): boolean;
595
+ redo?(): boolean;
596
+ /** Whether there is a step to go back to, a change not yet a step counting. */
597
+ canUndo?(): boolean;
598
+ canRedo?(): boolean;
599
+ /** What there is now becomes the first step, with nothing before or after it. */
600
+ clearHistory?(): boolean;
526
601
  }
527
602
 
528
603
  export default GridEditor;