@themarioga/grid-editor 8.8.1 → 8.9.0

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.
@@ -585,6 +585,65 @@
585
585
  --bs-offcanvas-height: 60vh;
586
586
  }
587
587
 
588
+ /* The sidebar: always there while editing, with the page making room for it
589
+ (html.ge-sidebar-open) where the window is wide enough. Narrower than
590
+ Bootstrap's sm it covers the page instead. */
591
+ .ge-settings-sidebar {
592
+ --bs-offcanvas-width: 340px;
593
+
594
+ .ge-sidebar-empty {
595
+ margin: 0;
596
+ color: var(--bs-secondary-color, #6c757d);
597
+ }
598
+ }
599
+
600
+ html.ge-sidebar-open {
601
+ padding-right: 340px;
602
+ }
603
+
604
+ /* On the panel's left edge, centred; folded away, on the window's right edge.
605
+ Its own element, so the panel can slide out from under it. */
606
+ .ge-sidebar-toggle {
607
+ position: fixed;
608
+ top: 50%;
609
+ right: 340px;
610
+ z-index: 1045;
611
+ display: flex;
612
+ align-items: center;
613
+ justify-content: center;
614
+ width: 1.5rem;
615
+ height: 3rem;
616
+ padding: 0;
617
+ transform: translateY(-50%);
618
+ border: 1px solid var(--bs-border-color, #dee2e6);
619
+ border-right: 0;
620
+ border-radius: 0.375rem 0 0 0.375rem;
621
+ background: var(--bs-body-bg, #fff);
622
+ color: var(--bs-body-color, #212529);
623
+ transition: right 0.3s ease-in-out;
624
+
625
+ &[aria-expanded="false"] {
626
+ right: 0;
627
+ }
628
+ }
629
+
630
+ .ge-sidebar-toggle.ge-under-dialog {
631
+ z-index: 1040;
632
+ }
633
+
634
+ @media (max-width: 575.98px) {
635
+ .ge-settings-sidebar {
636
+ --bs-offcanvas-width: 100vw;
637
+ }
638
+
639
+ .ge-sidebar-toggle[aria-expanded="true"] {
640
+ right: calc(100vw - 1.5rem);
641
+ border: 1px solid var(--bs-border-color, #dee2e6);
642
+ border-left: 0;
643
+ border-radius: 0 0.375rem 0.375rem 0;
644
+ }
645
+ }
646
+
588
647
  .ge-settings-popover {
589
648
  /* Popper would position it; without Popper that is the editor's job */
590
649
  position: absolute;
@@ -909,10 +968,11 @@
909
968
  }
910
969
 
911
970
  /* A carousel shows one slide, the one Bootstrap's .active says, and the
912
- container's drawer moves between them. Bootstrap's arrows and
913
- indicators are drawn but the editor's javascript answers, not theirs:
914
- a click goes through them to what is under, and a slide is changed
915
- with no transition */
971
+ container's drawer moves between them. Bootstrap's arrows are kept in
972
+ the markup but not drawn: they would sit over the slide's content and
973
+ the drawer's already do their work. Its indicators are drawn but the
974
+ editor's javascript answers, not theirs: a click goes through them to
975
+ what is under, and a slide is changed with no transition */
916
976
  .ge-container-carousel {
917
977
  .carousel-inner {
918
978
  overflow: visible;
@@ -921,7 +981,9 @@
921
981
  transition: none;
922
982
  }
923
983
  .carousel-control-prev,
924
- .carousel-control-next,
984
+ .carousel-control-next {
985
+ display: none;
986
+ }
925
987
  .carousel-indicators {
926
988
  pointer-events: none;
927
989
  }
@@ -121,6 +121,18 @@ export interface InlineStyleOptions {
121
121
  visibility?: { drawer?: boolean };
122
122
  }
123
123
 
124
+ /** What the sidebar shows while nothing is selected, instead of its message. */
125
+ export interface SidebarContent {
126
+ /** Text, not html. Default the sidebar's own title. */
127
+ title?: string;
128
+ body: Element;
129
+ }
130
+
131
+ export interface SidebarSettings {
132
+ /** Called whenever the sidebar is left with nothing selected. Null gives the message. */
133
+ empty?: ((ge: GridEditor) => SidebarContent | null) | null;
134
+ }
135
+
124
136
  export type CustomFilter = ((canvas: HTMLElement, isInit: boolean) => void) | string;
125
137
 
126
138
  /** The settings. Every one is optional. */
@@ -183,7 +195,10 @@ export interface GridEditorOptions {
183
195
  locale_strings?: Record<string, string>;
184
196
  callbacks?: Partial<GridEditorCallbacks>;
185
197
  confirm_delete?: boolean;
186
- settings_panel?: 'offcanvas' | 'popover' | 'modal' | 'inline';
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. */
199
+ settings_panel?: 'offcanvas' | 'popover' | 'modal' | 'inline' | 'sidebar';
200
+ /** The 'sidebar' panel. */
201
+ sidebar?: SidebarSettings;
187
202
  drag?: { delay?: number; touch_delay?: number; threshold?: number; animation?: number; scroll?: boolean };
188
203
  tinymce?: { config?: Record<string, unknown> };
189
204
  ckeditor?: { config?: Record<string, unknown> };
@@ -317,6 +332,13 @@ export interface TargetChangePayload {
317
332
  from: HTMLElement | null;
318
333
  }
319
334
 
335
+ /** The selection changed, with settings_panel 'sidebar': the node whose settings the sidebar shows, or null. */
336
+ export interface SelectionChangePayload {
337
+ canvas: HTMLElement;
338
+ node: HTMLElement | null;
339
+ from: HTMLElement | null;
340
+ }
341
+
320
342
  /** The events, by name, with their payloads. Adding fires a specific name and the generic one. */
321
343
  export interface GridEditorEventMap {
322
344
  'grideditor:before-add': Payload;
@@ -357,6 +379,7 @@ export interface GridEditorEventMap {
357
379
  'grideditor:popup-orphan': PopupOrphanPayload;
358
380
  'grideditor:view-change': ViewChangePayload;
359
381
  'grideditor:target-change': TargetChangePayload;
382
+ 'grideditor:selection-change': SelectionChangePayload;
360
383
  'grideditor:after-autosave': AutosavePayload;
361
384
  'grideditor:after-restore-draft': RestoreDraftPayload;
362
385
  'grideditor:autosave-error': AutosaveErrorPayload;
@@ -468,6 +491,10 @@ export declare class GridEditor {
468
491
  getActiveTarget(): HTMLElement | null;
469
492
  /** Make a column or region, or the first a selector matches, where the toolbar adds; null for none. */
470
493
  setActiveTarget(target: HTMLElement | string | null): this;
494
+ /** The node whose settings the sidebar shows, or null. Null unless settings_panel is 'sidebar'. */
495
+ getSelected(): HTMLElement | null;
496
+ /** Select a node with settings, or the first a selector matches, or null for none. Does nothing unless settings_panel is 'sidebar'. */
497
+ setSelected(node: HTMLElement | string | null): this;
471
498
  getView(): View;
472
499
  setLocale(code: string): this;
473
500
  createRow(layout?: RowLayout, options?: Placement): HTMLElement | null;