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

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 (63) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +23 -17
  3. package/UPGRADING.md +24 -5
  4. package/dist/grideditor.bundle.min.js +3 -3
  5. package/dist/grideditor.css +5 -4
  6. package/dist/grideditor.d.ts +6 -18
  7. package/dist/grideditor.esm.js +122 -100
  8. package/dist/grideditor.jquery.js +1 -3
  9. package/dist/grideditor.jquery.min.js +1 -1
  10. package/dist/grideditor.jquery.min.js.map +2 -2
  11. package/dist/grideditor.js +122 -100
  12. package/dist/grideditor.min.css +1 -1
  13. package/dist/grideditor.min.css.map +1 -1
  14. package/dist/grideditor.min.js +2 -2
  15. package/dist/grideditor.min.js.map +3 -3
  16. package/dist/plugins/grideditor.accordion.esm.js +7 -0
  17. package/dist/plugins/grideditor.accordion.js +7 -0
  18. package/dist/plugins/grideditor.accordion.min.js +1 -1
  19. package/dist/plugins/grideditor.accordion.min.js.map +3 -3
  20. package/dist/plugins/grideditor.card.esm.js +4 -0
  21. package/dist/plugins/grideditor.card.js +4 -0
  22. package/dist/plugins/grideditor.card.min.js +1 -1
  23. package/dist/plugins/grideditor.card.min.js.map +3 -3
  24. package/dist/plugins/grideditor.carousel.esm.js +4 -0
  25. package/dist/plugins/grideditor.carousel.js +4 -0
  26. package/dist/plugins/grideditor.carousel.min.js +1 -1
  27. package/dist/plugins/grideditor.carousel.min.js.map +2 -2
  28. package/dist/plugins/grideditor.clipboard.esm.js +3 -18
  29. package/dist/plugins/grideditor.clipboard.js +3 -18
  30. package/dist/plugins/grideditor.clipboard.min.js +1 -1
  31. package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
  32. package/dist/plugins/grideditor.history.esm.js +1 -6
  33. package/dist/plugins/grideditor.history.js +1 -6
  34. package/dist/plugins/grideditor.history.min.js +1 -1
  35. package/dist/plugins/grideditor.history.min.js.map +3 -3
  36. package/dist/plugins/grideditor.offcanvas.esm.js +4 -0
  37. package/dist/plugins/grideditor.offcanvas.js +4 -0
  38. package/dist/plugins/grideditor.offcanvas.min.js +1 -1
  39. package/dist/plugins/grideditor.offcanvas.min.js.map +3 -3
  40. package/dist/plugins/grideditor.popup.esm.js +4 -0
  41. package/dist/plugins/grideditor.popup.js +4 -0
  42. package/dist/plugins/grideditor.popup.min.js +1 -1
  43. package/dist/plugins/grideditor.popup.min.js.map +3 -3
  44. package/dist/plugins/grideditor.tabs.esm.js +4 -0
  45. package/dist/plugins/grideditor.tabs.js +4 -0
  46. package/dist/plugins/grideditor.tabs.min.js +1 -1
  47. package/dist/plugins/grideditor.tabs.min.js.map +2 -2
  48. package/docs/events.md +8 -11
  49. package/docs/plugins.md +10 -8
  50. package/example/clipboard.html +13 -10
  51. package/package.json +1 -1
  52. package/src/js/grideditor.jquery.js +0 -2
  53. package/src/js/grideditor.js +177 -110
  54. package/src/js/plugins/grideditor.accordion.js +9 -0
  55. package/src/js/plugins/grideditor.card.js +5 -0
  56. package/src/js/plugins/grideditor.carousel.js +5 -0
  57. package/src/js/plugins/grideditor.clipboard.js +11 -24
  58. package/src/js/plugins/grideditor.history.js +3 -6
  59. package/src/js/plugins/grideditor.offcanvas.js +5 -0
  60. package/src/js/plugins/grideditor.popup.js +5 -0
  61. package/src/js/plugins/grideditor.tabs.js +5 -0
  62. package/src/less/grideditor.less +5 -4
  63. package/types/grideditor.d.ts +6 -18
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * A step is the canvas's markup as ge.snapshotHtml() gives it, kept `delay`
14
14
  * ms after the last change: a drag or a burst of typing is one step. Going
15
- * to one puts its markup back with ge.setHtml(), and the node that was
16
- * selected, and the target, are chosen again by where they were.
15
+ * to one puts its markup back with ge.setHtml(), and the target is chosen
16
+ * again by where it was.
17
17
  *
18
18
  * Typing in a text is the text editor's own to undo while it has the focus:
19
19
  * the keys are left alone then, and what was typed becomes a step when it
@@ -227,7 +227,6 @@ GridEditor.features.history = function(ge) {
227
227
  var to = index + step;
228
228
  if (to < 0 || to >= stack.length) { return false; }
229
229
 
230
- var selected = pathOf(ge.getSelected());
231
230
  var target = pathOf(ge.getActiveTarget());
232
231
 
233
232
  stopObserving();
@@ -236,9 +235,7 @@ GridEditor.features.history = function(ge) {
236
235
  // The step as the canvas reads it back, so that is what is compared with
237
236
  stack[index] = ge.snapshotHtml();
238
237
 
239
- var node = resolve(selected);
240
- if (node) { ge.setSelected(node); }
241
- node = resolve(target);
238
+ var node = resolve(target);
242
239
  if (node) { ge.setActiveTarget(node); }
243
240
 
244
241
  observe();
@@ -317,6 +317,11 @@ GridEditor.containers.offcanvas = function(ge) {
317
317
  labelKey: 'container.add_offcanvas',
318
318
  paneKind: 'offcanvas',
319
319
 
320
+ // Where rows go: the offcanvas's body
321
+ regionOf: function(container) {
322
+ return dom.one(container, '.offcanvas-body');
323
+ },
324
+
320
325
  // The ids a copy of an offcanvas has to rename together
321
326
  references: ['data-ge-offcanvas-id', 'data-ge-offcanvas-target'],
322
327
 
@@ -27,6 +27,11 @@ GridEditor.containers.popup = function(ge) {
27
27
  labelKey: 'container.add_popup',
28
28
  paneKind: 'popup',
29
29
 
30
+ // Where rows go: the popup's body
31
+ regionOf: function(container) {
32
+ return dom.one(container, '.modal-body');
33
+ },
34
+
30
35
  // The ids a copy of a popup has to rename together
31
36
  references: ['data-ge-popup-id', 'data-ge-popup-target'],
32
37
 
@@ -368,6 +368,11 @@ GridEditor.containers.tabs = function(ge) {
368
368
  addPaneKey: 'container.add_tab',
369
369
  paneKind: 'tab',
370
370
 
371
+ // Where rows go: the pane showing, or the pane of the tab
372
+ regionOf: function(container, tab) {
373
+ return tab ? paneOf(container, tab) : dom.one(container, ':scope > .tab-content > .tab-pane.active');
374
+ },
375
+
371
376
  create: function(options) {
372
377
  var container = dom.element('div', { 'data-ge-container': 'tabs' });
373
378
  var labels = options.labels || [];
@@ -680,13 +680,14 @@ html.ge-sidebar-open {
680
680
  outline-offset: 1px;
681
681
  }
682
682
 
683
- /* Where the toolbar's buttons add, with active_target. A node that is both
684
- shows both: this one a little further out */
685
- .ge-canvas.ge-editing .ge-active-target {
683
+ /* The target, with active_target: where the toolbar's buttons add and what
684
+ the sidebar shows. A node that also has its panel open shows both: this
685
+ one a little further out */
686
+ .ge-canvas.ge-editing .ge-selected {
686
687
  outline: 2px dashed var(--bs-success, #198754);
687
688
  outline-offset: -2px;
688
689
  }
689
- .ge-canvas.ge-editing .ge-active-target.ge-settings-target {
690
+ .ge-canvas.ge-editing .ge-selected.ge-settings-target {
690
691
  box-shadow: 0 0 0 4px var(--bs-success, #198754);
691
692
  }
692
693
 
@@ -190,7 +190,7 @@ export interface GridEditorOptions {
190
190
  drawer_overflow?: 'menu' | 'wrap';
191
191
  /** The add buttons in categories - rows, content, and a plugin's own - one shown at a time, chosen with tabs. Default false. */
192
192
  toolbar_groups?: boolean;
193
- /** A click in a column or a section makes it where the toolbar's buttons add. Default false, and true with settings_panel 'sidebar', which throws if it is given false. */
193
+ /** A click on any node with settings - a row, a column, a container, a text - makes it the target: where the toolbar's buttons add, and what the sidebar shows. Default false, and true with settings_panel 'sidebar', which throws if it is given false. */
194
194
  active_target?: boolean;
195
195
  /** The plugins to use, of any kind; null is every one loaded. */
196
196
  plugins?: string[] | null;
@@ -209,7 +209,7 @@ export interface GridEditorOptions {
209
209
  elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
210
210
  /** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
211
211
  autosave?: AutosaveOptions;
212
- /** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the node selected or the target; default active_target. */
212
+ /** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the active target; default active_target. */
213
213
  clipboard?: { shortcuts?: boolean };
214
214
  /** The history plugin: undo and redo. */
215
215
  history?: HistoryOptions;
@@ -230,7 +230,7 @@ export interface GridEditorOptions {
230
230
  locale_strings?: Record<string, string>;
231
231
  callbacks?: Partial<GridEditorCallbacks>;
232
232
  confirm_delete?: boolean;
233
- /** Where a node's settings open. 'sidebar' is a panel that stays on the right while editing, showing the selected node's; one editor per page has it. It turns active_target on, and the constructor throws a TypeError if active_target is false. */
233
+ /** Where a node's settings open. 'sidebar' is a panel that stays on the right while editing, showing the active target's; one editor per page has it. It turns active_target on, and the constructor throws a TypeError if active_target is false. */
234
234
  settings_panel?: 'offcanvas' | 'popover' | 'modal' | 'inline' | 'sidebar';
235
235
  /** The 'sidebar' panel. */
236
236
  sidebar?: SidebarSettings;
@@ -389,7 +389,7 @@ export interface ViewChangePayload {
389
389
  to: View;
390
390
  }
391
391
 
392
- /** The active target changed: the column or region the toolbar adds to, or null for the canvas. */
392
+ /** The active target changed: the node the toolbar adds to and the sidebar shows - any with settings - or null for the canvas. */
393
393
  export interface TargetChangePayload {
394
394
  canvas: HTMLElement;
395
395
  target: HTMLElement | null;
@@ -402,13 +402,6 @@ export interface PreviewChangePayload {
402
402
  previewing: boolean;
403
403
  }
404
404
 
405
- /** The selection changed, with settings_panel 'sidebar': the node whose settings the sidebar shows, or null. */
406
- export interface SelectionChangePayload {
407
- canvas: HTMLElement;
408
- node: HTMLElement | null;
409
- from: HTMLElement | null;
410
- }
411
-
412
405
  /** The events, by name, with their payloads. Adding fires a specific name and the generic one. */
413
406
  export interface GridEditorEventMap {
414
407
  'grideditor:before-add': Payload;
@@ -451,7 +444,6 @@ export interface GridEditorEventMap {
451
444
  'grideditor:view-change': ViewChangePayload;
452
445
  'grideditor:preview-change': PreviewChangePayload;
453
446
  'grideditor:target-change': TargetChangePayload;
454
- 'grideditor:selection-change': SelectionChangePayload;
455
447
  'grideditor:after-autosave': AutosavePayload;
456
448
  'grideditor:after-restore-draft': RestoreDraftPayload;
457
449
  'grideditor:autosave-error': AutosaveErrorPayload;
@@ -562,14 +554,10 @@ export declare class GridEditor {
562
554
  /** Take the editor off: the markup stays, everything else goes. */
563
555
  destroy(): this;
564
556
  changeView(view: View): this;
565
- /** The column or region the toolbar adds to, or null. Null without active_target, which settings_panel 'sidebar' turns on. */
557
+ /** The node the toolbar adds to, and the sidebar shows, or null: any node with settings, a row, a column, a container, a text. Null without active_target, which settings_panel 'sidebar' turns on. */
566
558
  getActiveTarget(): HTMLElement | null;
567
- /** Make a column or region, or the first a selector matches, where the toolbar adds; null for none. */
559
+ /** Make a node with settings, or the first a selector matches, the one the toolbar adds to; null for none. */
568
560
  setActiveTarget(target: HTMLElement | string | null): this;
569
- /** The node whose settings the sidebar shows, or null. Null unless settings_panel is 'sidebar'. */
570
- getSelected(): HTMLElement | null;
571
- /** Select a node with settings, or the first a selector matches, or null for none. Does nothing unless settings_panel is 'sidebar'. */
572
- setSelected(node: HTMLElement | string | null): this;
573
561
  getView(): View;
574
562
  setLocale(code: string): this;
575
563
  createRow(layout?: RowLayout, options?: Placement): HTMLElement | null;