@themarioga/grid-editor 8.10.1 → 9.0.0-beta.2

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.
@@ -161,7 +161,7 @@ export interface GridEditorOptions {
161
161
  drawer_overflow?: 'menu' | 'wrap';
162
162
  /** The add buttons in categories - rows, content, and a plugin's own - one shown at a time, chosen with tabs. Default false. */
163
163
  toolbar_groups?: boolean;
164
- /** A click in a column or a section makes it where the toolbar's buttons add. Default false. */
164
+ /** 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. */
165
165
  active_target?: boolean;
166
166
  /** The plugins to use, of any kind; null is every one loaded. */
167
167
  plugins?: string[] | null;
@@ -178,6 +178,8 @@ export interface GridEditorOptions {
178
178
  elements?: { enabled?: boolean | 'auto'; selector?: string; auto?: boolean; types?: ElementType[] };
179
179
  /** The autosave plugin: what is edited, kept in the browser's storage as it changes. */
180
180
  autosave?: AutosaveOptions;
181
+ /** The clipboard plugin. `shortcuts`: Ctrl+C and Ctrl+V on the node selected or the target; default active_target. */
182
+ clipboard?: { shortcuts?: boolean };
181
183
  custom_filter?: CustomFilter | CustomFilter[] | '';
182
184
  valid_col_sizes?: ColumnSize[];
183
185
  valid_col_offsets?: number[];
@@ -195,7 +197,7 @@ export interface GridEditorOptions {
195
197
  locale_strings?: Record<string, string>;
196
198
  callbacks?: Partial<GridEditorCallbacks>;
197
199
  confirm_delete?: boolean;
198
- /** 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. */
200
+ /** 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. */
199
201
  settings_panel?: 'offcanvas' | 'popover' | 'modal' | 'inline' | 'sidebar';
200
202
  /** The 'sidebar' panel. */
201
203
  sidebar?: SidebarSettings;
@@ -271,7 +273,7 @@ export interface Payload {
271
273
  parent: HTMLElement | null;
272
274
  canvas: HTMLElement;
273
275
  breakpoint: View;
274
- source: 'api' | 'tool' | 'dragdrop' | 'paste' | 'panel' | string;
276
+ source: 'api' | 'tool' | 'dragdrop' | 'paste' | 'panel' | 'shortcut' | string;
275
277
  /** A pane inside a container. */
276
278
  container?: HTMLElement;
277
279
  }
@@ -487,7 +489,7 @@ export declare class GridEditor {
487
489
  /** Take the editor off: the markup stays, everything else goes. */
488
490
  destroy(): this;
489
491
  changeView(view: View): this;
490
- /** The column or region the toolbar adds to, or null. Null without active_target. */
492
+ /** The column or region the toolbar adds to, or null. Null without active_target, which settings_panel 'sidebar' turns on. */
491
493
  getActiveTarget(): HTMLElement | null;
492
494
  /** Make a column or region, or the first a selector matches, where the toolbar adds; null for none. */
493
495
  setActiveTarget(target: HTMLElement | string | null): this;
@@ -604,7 +604,7 @@ function build(instance, baseElem, optionsOrMethod) {
604
604
  "toolbar_groups": false,
605
605
  // The add buttons in categories, one shown at a time, picked with tabs
606
606
  "active_target": false,
607
- // A click in a column makes it where the toolbar's buttons add
607
+ // A click in a column makes it where the toolbar's buttons add. The 'sidebar' panel turns it on
608
608
  "element_tools": [],
609
609
  // Host tools on element drawers, same shape as row_tools
610
610
  "element_classes": [],
@@ -662,6 +662,12 @@ function build(instance, baseElem, optionsOrMethod) {
662
662
  Object.keys(NESTED_SETTINGS).forEach(function(name) {
663
663
  settings[name] = Object.assign({}, NESTED_SETTINGS[name], settings[name]);
664
664
  });
665
+ if (settings.settings_panel === "sidebar") {
666
+ if (optionsOrMethod && optionsOrMethod.active_target === false) {
667
+ throw new TypeError('grid-editor: settings_panel "sidebar" needs active_target; leave it out or set it to true');
668
+ }
669
+ settings.active_target = true;
670
+ }
665
671
  var canvas, mainControls, wrapper, addRowGroup, addContainerGroup, layoutDropdown, htmlTextArea;
666
672
  var curView = settings.default_view;
667
673
  var confirmDialog = null;
@@ -2343,6 +2349,41 @@ function build(instance, baseElem, optionsOrMethod) {
2343
2349
  refreshToolbar,
2344
2350
  toolbarItems: function(name) {
2345
2351
  return mainControls ? all(mainControls, '[data-ge-toolbar="feature"][data-ge-feature="' + name + '"]') : [];
2352
+ },
2353
+ getSelected: function() {
2354
+ return panelMode() === "sidebar" ? selected : null;
2355
+ },
2356
+ getActiveTarget: function() {
2357
+ return settings.active_target ? activeTarget : null;
2358
+ },
2359
+ // What keeps Escape from the selection and the target, and an
2360
+ // inline panel unfolded in a drawer, which Escape leaves alone
2361
+ panelOpen: function() {
2362
+ if (openSettingsState || dialogState) {
2363
+ return true;
2364
+ }
2365
+ if (confirmDialog && hasClass(confirmDialog, "show")) {
2366
+ return true;
2367
+ }
2368
+ return panelMode() === "inline" && all(canvas, ".ge-tools-drawer > .ge-details").some(visible);
2369
+ },
2370
+ // The toolbar and the settings panels are outside the canvas
2371
+ contains: function(node) {
2372
+ if (!node || node.nodeType !== 1) {
2373
+ return false;
2374
+ }
2375
+ if (canvas.contains(node) || mainControls && mainControls.contains(node)) {
2376
+ return true;
2377
+ }
2378
+ if (dialogPanel && dialogPanel.contains(node)) {
2379
+ return true;
2380
+ }
2381
+ if (confirmDialog && confirmDialog.contains(node)) {
2382
+ return true;
2383
+ }
2384
+ return Object.keys(settingsPanels).some(function(mode) {
2385
+ return settingsPanels[mode].contains(node);
2386
+ });
2346
2387
  }
2347
2388
  };
2348
2389
  }
@@ -5107,7 +5148,7 @@ GridEditor.t = translate;
5107
5148
  GridEditor._plainHtml = plainHtml;
5108
5149
  GridEditor.Sortable = null;
5109
5150
  GridEditor.bootstrap = null;
5110
- GridEditor.version = false ? "dev" : "8.10.1";
5151
+ GridEditor.version = false ? "dev" : "9.0.0-beta.2";
5111
5152
  GridEditor.locales = {
5112
5153
  en: {
5113
5154
  "tool.move": "Move",
@@ -605,7 +605,7 @@
605
605
  "toolbar_groups": false,
606
606
  // The add buttons in categories, one shown at a time, picked with tabs
607
607
  "active_target": false,
608
- // A click in a column makes it where the toolbar's buttons add
608
+ // A click in a column makes it where the toolbar's buttons add. The 'sidebar' panel turns it on
609
609
  "element_tools": [],
610
610
  // Host tools on element drawers, same shape as row_tools
611
611
  "element_classes": [],
@@ -663,6 +663,12 @@
663
663
  Object.keys(NESTED_SETTINGS).forEach(function(name) {
664
664
  settings[name] = Object.assign({}, NESTED_SETTINGS[name], settings[name]);
665
665
  });
666
+ if (settings.settings_panel === "sidebar") {
667
+ if (optionsOrMethod && optionsOrMethod.active_target === false) {
668
+ throw new TypeError('grid-editor: settings_panel "sidebar" needs active_target; leave it out or set it to true');
669
+ }
670
+ settings.active_target = true;
671
+ }
666
672
  var canvas, mainControls, wrapper, addRowGroup, addContainerGroup, layoutDropdown, htmlTextArea;
667
673
  var curView = settings.default_view;
668
674
  var confirmDialog = null;
@@ -2344,6 +2350,41 @@
2344
2350
  refreshToolbar,
2345
2351
  toolbarItems: function(name) {
2346
2352
  return mainControls ? all(mainControls, '[data-ge-toolbar="feature"][data-ge-feature="' + name + '"]') : [];
2353
+ },
2354
+ getSelected: function() {
2355
+ return panelMode() === "sidebar" ? selected : null;
2356
+ },
2357
+ getActiveTarget: function() {
2358
+ return settings.active_target ? activeTarget : null;
2359
+ },
2360
+ // What keeps Escape from the selection and the target, and an
2361
+ // inline panel unfolded in a drawer, which Escape leaves alone
2362
+ panelOpen: function() {
2363
+ if (openSettingsState || dialogState) {
2364
+ return true;
2365
+ }
2366
+ if (confirmDialog && hasClass(confirmDialog, "show")) {
2367
+ return true;
2368
+ }
2369
+ return panelMode() === "inline" && all(canvas, ".ge-tools-drawer > .ge-details").some(visible);
2370
+ },
2371
+ // The toolbar and the settings panels are outside the canvas
2372
+ contains: function(node) {
2373
+ if (!node || node.nodeType !== 1) {
2374
+ return false;
2375
+ }
2376
+ if (canvas.contains(node) || mainControls && mainControls.contains(node)) {
2377
+ return true;
2378
+ }
2379
+ if (dialogPanel && dialogPanel.contains(node)) {
2380
+ return true;
2381
+ }
2382
+ if (confirmDialog && confirmDialog.contains(node)) {
2383
+ return true;
2384
+ }
2385
+ return Object.keys(settingsPanels).some(function(mode) {
2386
+ return settingsPanels[mode].contains(node);
2387
+ });
2347
2388
  }
2348
2389
  };
2349
2390
  }
@@ -5108,7 +5149,7 @@
5108
5149
  GridEditor._plainHtml = plainHtml;
5109
5150
  GridEditor.Sortable = null;
5110
5151
  GridEditor.bootstrap = null;
5111
- GridEditor.version = false ? "dev" : "8.10.1";
5152
+ GridEditor.version = false ? "dev" : "9.0.0-beta.2";
5112
5153
  GridEditor.locales = {
5113
5154
  en: {
5114
5155
  "tool.move": "Move",