@themarioga/grid-editor 9.2.6 → 9.3.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +68 -5
  3. package/dist/grideditor.bundle.min.js +2 -2
  4. package/dist/grideditor.css +267 -0
  5. package/dist/grideditor.d.ts +88 -0
  6. package/dist/grideditor.esm.js +27 -5
  7. package/dist/grideditor.js +27 -5
  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 +102 -0
  13. package/dist/locales/grideditor.es.js +102 -0
  14. package/dist/locales/grideditor.es.min.js +1 -1
  15. package/dist/locales/grideditor.es.min.js.map +2 -2
  16. package/dist/plugins/grideditor.navbar.esm.js +2084 -0
  17. package/dist/plugins/grideditor.navbar.js +2085 -0
  18. package/dist/plugins/grideditor.navbar.min.js +1 -0
  19. package/dist/plugins/grideditor.navbar.min.js.map +7 -0
  20. package/dist/plugins/grideditor.sidenav.esm.js +1978 -0
  21. package/dist/plugins/grideditor.sidenav.js +1979 -0
  22. package/dist/plugins/grideditor.sidenav.min.js +1 -0
  23. package/dist/plugins/grideditor.sidenav.min.js.map +7 -0
  24. package/docs/events.md +5 -1
  25. package/docs/locale-keys.md +103 -1
  26. package/docs/plugins.md +23 -4
  27. package/example/containers.html +59 -2
  28. package/example/index.html +1 -1
  29. package/example/playground.html +2 -0
  30. package/package.json +1 -1
  31. package/src/js/grideditor.js +36 -4
  32. package/src/js/locales/grideditor.es.js +102 -0
  33. package/src/js/nav/browse.js +51 -0
  34. package/src/js/nav/canvas.js +170 -0
  35. package/src/js/nav/convert.js +175 -0
  36. package/src/js/nav/drawers.js +258 -0
  37. package/src/js/nav/feature.js +94 -0
  38. package/src/js/nav/locale.js +128 -0
  39. package/src/js/nav/markup.js +121 -0
  40. package/src/js/nav/panels.js +443 -0
  41. package/src/js/nav/pieces.js +207 -0
  42. package/src/js/plugins/grideditor.navbar.js +454 -0
  43. package/src/js/plugins/grideditor.sidenav.js +349 -0
  44. package/src/less/grideditor.less +199 -0
  45. package/types/grideditor.d.ts +88 -0
@@ -105,7 +105,7 @@ title. `{kind}` is one of the `panel.kind_*` keys, or a container's own label.
105
105
  container.*
106
106
  -----------
107
107
 
108
- The containers: tabs, accordions, popups, offcanvases, carousels and cards, and the panes inside them.
108
+ The containers: tabs, accordions, popups, offcanvases, carousels, cards, navbars and sidebars, and the panes and pieces inside them.
109
109
 
110
110
  | Key | English | Where |
111
111
  | --- | --- | --- |
@@ -178,6 +178,108 @@ The containers: tabs, accordions, popups, offcanvases, carousels and cards, and
178
178
  | `container.add_card` | Card | Toolbar button that adds a card |
179
179
  | `container.card_title` | Card title | Title of a new card, in its header |
180
180
  | `container.card_footer` | Card footer | Text of a new card's footer, when it has one |
181
+ | `container.add_navbar` | Navbar | Toolbar button that adds a navbar |
182
+ | `container.add_sidenav` | Sidebar | Toolbar button that adds a sidebar. The container is `sidenav`: `sidebar` is the settings panel's |
183
+ | `container.navbar_brand` | Brand | Text of a new navbar's brand |
184
+ | `container.sidenav_brand` | Brand | Text of a new sidebar's brand |
185
+ | `container.nav_link` | Link | Text of a new link, and what an emptied link goes back to |
186
+ | `container.nav_dropdown` | Dropdown | Text of a new dropdown, and what an emptied one goes back to. Also its choice in the add menu of a navbar's list |
187
+ | `container.nav_submenu` | Submenu | Text of a new collapsible submenu. Also its choice in the add menu of a sidebar's list |
188
+ | `container.nav_menu_link` | Action | Text of a new link in a menu, and its choice in the add menu of a dropdown |
189
+ | `container.nav_menu_header` | Header | Text of a new header in a menu, and its choice in the add menu of a dropdown |
190
+ | `container.nav_text` | Text | Text of a new text, and its choice in the add menu of a container or a dropdown |
191
+ | `container.navbar_toggle` | Toggle navigation | `aria-label` of a navbar's toggler, written in the interface's language when the navbar is made |
192
+ | `container.navbar_offcanvas_title` | Menu | Title of the header of a navbar that folds into an offcanvas |
193
+ | `container.sidenav_trigger` | Menu | Text of the button that opens a responsive sidebar |
194
+ | `tool.add_nav_piece` | Add… | Container drawer, the tool that adds a list, a text or a free zone |
195
+ | `tool.add_nav_link` | Add link or dropdown | List drawer, the tool that adds a link or a dropdown |
196
+ | `tool.add_nav_menu_item` | Add item | Dropdown drawer, the tool that adds a link, a divider, a header or a text |
197
+ | `tool.fold_nav_menu` | Fold this menu while editing | Dropdown drawer. Editing shows a menu open, and this folds it away |
198
+ | `confirm.delete_nav_piece` | Delete this and everything in it? | Asked before a piece of a navbar or a sidebar is deleted |
199
+ | `container.navbar_section` | Navbar | Heading of a navbar's section of its settings panel |
200
+ | `container.sidenav_section` | Sidebar | Heading of a sidebar's section of its settings panel |
201
+ | `container.nav_brand_show` | Brand | Its checkbox for having a brand |
202
+ | `container.nav_brand_image` | Image | Brand's field for the image's src |
203
+ | `container.nav_brand_alt` | Alt text | Brand's field for the image's alt |
204
+ | `container.nav_brand_height` | Height (px) | Brand's field for the image's height, in pixels |
205
+ | `container.navbar_expand` | Expand | Its select for the breakpoint from which the navbar is expanded |
206
+ | `container.navbar_expand_never` | Never | Expand: never, it is always folded |
207
+ | `container.navbar_expand_always` | Always | Expand: always, it is never folded |
208
+ | `container.navbar_expand_from` | From {breakpoint} | Expand: from that breakpoint up. `{breakpoint}` is `sm`, `md`… |
209
+ | `container.navbar_collapse` | Collapse | Its select for how the navbar folds |
210
+ | `container.navbar_collapse_collapse` | Collapse | Collapse: a collapse Bootstrap opens under the brand |
211
+ | `container.navbar_collapse_offcanvas` | Offcanvas | Collapse: an offcanvas that slides in |
212
+ | `container.navbar_collapse_none` | Not collapsed | Collapse: it does not fold, and has no toggler |
213
+ | `container.navbar_offcanvas_placement` | Side | Its select for the edge the offcanvas comes from |
214
+ | `container.nav_start` | Start | Side: the left in a left to right page |
215
+ | `container.nav_end` | End | Side: the right in a left to right page |
216
+ | `container.nav_bg` | Background | Its select for the background |
217
+ | `container.nav_bg_none` | None | Background: none |
218
+ | `container.nav_bg_body_tertiary` | Light grey | Background: `bg-body-tertiary` |
219
+ | `container.nav_bg_body` | Page | Background: `bg-body` |
220
+ | `container.nav_bg_primary` | Primary | Background: `bg-primary` |
221
+ | `container.nav_bg_secondary` | Secondary | Background: `bg-secondary` |
222
+ | `container.nav_bg_success` | Success | Background: `bg-success` |
223
+ | `container.nav_bg_danger` | Danger | Background: `bg-danger` |
224
+ | `container.nav_bg_warning` | Warning | Background: `bg-warning` |
225
+ | `container.nav_bg_info` | Info | Background: `bg-info` |
226
+ | `container.nav_bg_light` | Light | Background: `bg-light` |
227
+ | `container.nav_bg_dark` | Dark | Background: `bg-dark` |
228
+ | `container.nav_theme` | Theme | Its select for `data-bs-theme` |
229
+ | `container.nav_theme_auto` | Auto | Theme: the page's |
230
+ | `container.nav_theme_light` | Light | Theme: light |
231
+ | `container.nav_theme_dark` | Dark | Theme: dark |
232
+ | `container.navbar_position` | Position | Its select for the position |
233
+ | `container.navbar_position_none` | In the flow | Position: in the flow of the page |
234
+ | `container.navbar_position_fixed_top` | Fixed top | Position: `fixed-top` |
235
+ | `container.navbar_position_fixed_bottom` | Fixed bottom | Position: `fixed-bottom` |
236
+ | `container.navbar_position_sticky_top` | Sticky top | Position: `sticky-top` |
237
+ | `container.navbar_position_sticky_bottom` | Sticky bottom | Position: `sticky-bottom` |
238
+ | `container.navbar_width` | Inner width | Its select for the width of what is inside the navbar |
239
+ | `container.navbar_width_fluid` | Full | Inner width: `container-fluid` |
240
+ | `container.navbar_width_fixed` | Fixed | Inner width: `container` |
241
+ | `container.navbar_width_from` | Full up to {breakpoint} | Inner width: `container-{bp}`. `{breakpoint}` is the key |
242
+ | `container.sidenav_width` | Width | Its field for the width, a css length |
243
+ | `container.sidenav_style` | Link style | Its select for the style of the links |
244
+ | `container.sidenav_style_pills` | Pills | Link style: `nav-pills` |
245
+ | `container.sidenav_style_plain` | Plain | Link style: plain |
246
+ | `container.sidenav_full_height` | Full height | Its checkbox for the full height of the window |
247
+ | `container.sidenav_responsive` | Responsive | Its select for the breakpoint below which the sidebar is an offcanvas |
248
+ | `container.sidenav_responsive_never` | Always visible | Responsive: always visible |
249
+ | `container.sidenav_responsive_from` | Offcanvas below {breakpoint} | Responsive: an offcanvas below that breakpoint. `{breakpoint}` is `sm`, `md`… |
250
+ | `container.sidenav_offcanvas_title` | Menu | Title of the header of a responsive sidebar |
251
+ | `container.nav_close` | Close | `aria-label` of the close button of those headers |
252
+ | `container.nav_list_section` | List | Heading of a list's section, and what the panel calls it |
253
+ | `container.nav_link_section` | Link | Heading of a link's section, and what the panel calls it |
254
+ | `container.nav_dropdown_section` | Dropdown | Heading of a dropdown's section, and what the panel calls it |
255
+ | `container.nav_menu_item_section` | Item | Heading of a menu item's section, and what the panel calls it |
256
+ | `container.nav_text_section` | Text | Heading of a text's section, and what the panel calls it |
257
+ | `container.nav_zone_section` | Free zone | Heading of a free zone's section, and what the panel calls it |
258
+ | `container.nav_brand_section` | Brand | Heading of the brand's section, and what the panel calls it |
259
+ | `container.nav_align` | Alignment | Its select for where a piece sits in the navbar |
260
+ | `container.nav_align_after` | After the previous | Alignment: right after the previous piece |
261
+ | `container.nav_align_end` | At the end | Alignment: at the end (`ms-auto`) |
262
+ | `container.nav_align_center` | Centered | Alignment: centered (`mx-auto`) |
263
+ | `container.nav_scroll` | Scroll | Its checkbox for a list that scrolls |
264
+ | `container.nav_scroll_height` | Height | Its field for the height a list scrolls at |
265
+ | `container.nav_bottom` | At the bottom | Its checkbox for a piece of the sidebar at the bottom (`mt-auto`) |
266
+ | `container.nav_href` | URL | Its field for a link's URL |
267
+ | `container.nav_active` | Active | Its checkbox for the active link |
268
+ | `container.nav_disabled` | Disabled | Its checkbox for a disabled link |
269
+ | `container.nav_new_tab` | New tab | Its checkbox for opening a link in a new tab |
270
+ | `container.nav_menu_end` | Menu on the right | Its checkbox for a menu that opens to the right |
271
+ | `container.nav_submenu_type` | Type | Its select for the kind of menu a sidebar's dropdown is |
272
+ | `container.nav_submenu_type_collapse` | Collapsible | Type: a collapsible submenu |
273
+ | `container.nav_submenu_type_dropdown` | Dropdown | Type: a dropdown |
274
+ | `container.nav_submenu_open` | Open on load | Its checkbox for a submenu open when the page loads |
275
+ | `container.nav_menu_divider` | Divider | Choice in the add menu of a dropdown: a divider |
276
+ | `container.nav_zone` | Free zone | Choice in the add menu of a container: a free zone |
277
+ | `tool.add_nav_list` | Add list | Tooltip of that choice for a list |
278
+ | `tool.add_nav_text` | Add text | Tooltip of that choice for a text |
279
+ | `tool.add_nav_zone` | Add free zone | Tooltip of that choice for a free zone |
280
+ | `tool.unfold_nav_menu` | Unfold this menu | Dropdown drawer, the same tool once the menu is folded away |
281
+ | `container.nav_browse` | Browse… | Title of the button that opens the host's file browser |
282
+ | `tool.delete_nav_piece` | Delete | Delete tool of a piece of a navbar or a sidebar |
181
283
 
182
284
 
183
285
  section.*
package/docs/plugins.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Writing a plugin
2
2
  ================
3
3
 
4
- Tabs, accordions, popups, offcanvases, carousels, cards and the element level controls are not built
4
+ Tabs, accordions, popups, offcanvases, carousels, cards, navbars, sidebars and the element level controls are not built
5
5
  into grid-editor: each is a file you load beside it, and loading the file is
6
6
  what turns the feature on. `grideditor.card.js` is the shortest of them, and
7
7
  the one to read first if you are about to write your own.
@@ -12,6 +12,8 @@ the one to read first if you are about to write your own.
12
12
  <script src="dist/plugins/grideditor.popup.min.js"></script>
13
13
  <script src="dist/plugins/grideditor.offcanvas.min.js"></script>
14
14
  <script src="dist/plugins/grideditor.card.min.js"></script>
15
+ <script src="dist/plugins/grideditor.navbar.min.js"></script>
16
+ <script src="dist/plugins/grideditor.sidenav.min.js"></script>
15
17
  <script src="dist/plugins/grideditor.elements.min.js"></script>
16
18
  ```
17
19
 
@@ -164,8 +166,8 @@ element, and where there may be several, an array.
164
166
  | `ge.detailsOf(node)` | A node's settings panel, wherever it is: in its drawer, or open in the offcanvas, popover, modal or sidebar `settings_panel` names, outside the canvas. Find a panel's fields through it, never through the drawer. Null for a node with none. Whole: the plugins' sections and *Responsive*, built only while the panel is open, are built if they were not. `ge.detailsOf(node, { build: false })` hands it back as it is, without building them - for a plugin that only refreshes what may be showing, or asks whether a node has a panel at all |
165
167
  | `ge.deleteNode(kind, node, confirmText, animate)` | Remove a node: ask, animate, announce |
166
168
  | `ge.place(node, kind, options)` | Put a created node where `appendTo` and friends say, through the add events. `options.source` is the payload's `source`, `api` by default |
167
- | `ge.createPaneControls(pane, kind, hostTools, confirmText, remove)` | The drawer a pane gets: move, the host's tools, delete. Returns the drawer, for a plugin that wants other tools in it |
168
- | `ge.makeLabelEditable(label)` | Rename in place, with the Bootstrap toggle suspended while typing |
169
+ | `ge.createPaneControls(pane, kind, hostTools, confirmText, remove, options?)` | The drawer a pane gets: move, the host's tools, delete. Returns the drawer, for a plugin that wants other tools in it. `options.presets` is the list of preset classes its settings panel offers, in place of the `pane_classes` setting: `[]` for a pane that has none |
170
+ | `ge.makeLabelEditable(label)` | Rename in place, with the Bootstrap toggle suspended while typing, and put back after only if it was this call that suspended it: a toggle already suspended - an accordion item's button, a navbar's dropdown - stays so |
169
171
  | `ge.labelIn(button)` | The label span inside a button, wrapped if it is not already |
170
172
  | `ge.unwrapLabels(scope)` | Take those wrappers off again, for `unmark` |
171
173
  | `ge.suspendToggles(scope)` / `ge.resumeToggles(scope)` | Move the attributes Bootstrap's data api acts on - `data-bs-toggle`, `data-bs-dismiss`, `data-bs-slide`, `data-bs-slide-to` and `data-bs-ride` - aside while editing, and back on the way out. They take `scope` and everything under it: a plugin whose container holds others passes the elements that are its own |
@@ -258,7 +260,18 @@ needs to put a new kind of block on the canvas:
258
260
  and containers always cut.
259
261
  - **`accepts(region, node)`** can turn a block away from a list: `false` and the
260
262
  drag will not drop it there, whoever's block and whoever's list. With none of
261
- these hooks, every block goes everywhere, as before.
263
+ these hooks, every block goes everywhere, as before. Every way of adding a
264
+ block asks it: a drag, Ctrl+V, the toolbar's buttons and `ge.place` - so
265
+ `createContainer`, `createRow`, `createText`… with `appendTo`, `prependTo`,
266
+ `insertBefore` or `insertAfter`, and the clipboard's paste tool. What the
267
+ toolbar was going to add to a region that will not have it goes to the
268
+ canvas, just after the block the region is in. `ge.place` warns, adds
269
+ nothing, fires no add event and returns `null` - at once, even from an
270
+ event handler, whose adds are queued otherwise. Its `null` is then also
271
+ for a region that would not take the block, and not only for a handler
272
+ that canceled. The buttons of a feature plugin with `inColumn`, which wrap
273
+ what they make in a row and a column, and the markup `init` and `setHtml`
274
+ are given, are not asked.
262
275
  - **`toolbar`** adds buttons beside the containers'. A click appends what
263
276
  `create()` returns to the canvas, announced as `kind`; a drop puts it where it
264
277
  was dropped, or, when that region will not have it, on the canvas just after
@@ -492,6 +505,12 @@ rather than remembering anything about it.
492
505
  when the plugin is not loaded.
493
506
  - **`kindOf(node)`** returns the `kind` an event should carry for a node the
494
507
  plugin owns, or null.
508
+ - **`kindLabel(kind)`** returns the text the settings panel titles a node of a
509
+ kind the plugin made up with, or null. It is asked where the panel would
510
+ otherwise show the kind as it is - after a container's `labelKey` and its
511
+ panes' `paneLabelKey`, and the core's own kinds - and the first plugin that
512
+ answers wins. The navbar and sidenav plugins' `nav` feature uses it for
513
+ the kinds of their pieces.
495
514
 
496
515
  The core's own lists and the plugins' are taken down together: every list made
497
516
  through `sortable()` is registered, so `deinit` unmakes exactly those and a
@@ -25,6 +25,8 @@
25
25
  <script src="../dist/plugins/grideditor.offcanvas.min.js"></script>
26
26
  <script src="../dist/plugins/grideditor.card.min.js"></script>
27
27
  <script src="../dist/plugins/grideditor.carousel.min.js"></script>
28
+ <script src="../dist/plugins/grideditor.navbar.min.js"></script>
29
+ <script src="../dist/plugins/grideditor.sidenav.min.js"></script>
28
30
 
29
31
  <script>
30
32
  document.addEventListener('DOMContentLoaded', function() {
@@ -102,7 +104,7 @@
102
104
  one: rows, columns, content areas and elements nest inside
103
105
  it exactly as they do at the top level. The five buttons in
104
106
  the toolbar add a tabs container, an accordion, a popup, an
105
- offcanvas, a carousel and a card &mdash; tabs, accordion and carousel
107
+ offcanvas, a carousel, a card, a navbar and a sidebar &mdash; tabs, accordion and carousel
106
108
  hold a pane each, the others hold one region.
107
109
  </p>
108
110
  <p class="form-text">
@@ -123,7 +125,8 @@
123
125
  one slide shows at a time, the arrows in its drawer move
124
126
  between them, and the gear has a Carousel section for
125
127
  fade, autoplay and the rest of Bootstrap's options, and a
126
- slide&rsquo;s own gear has its interval.
128
+ slide&rsquo;s own gear has its interval. The navbar and the
129
+ sidebar after it are edited piece by piece, each with a drawer.
127
130
  </p>
128
131
  <button class="btn btn-sm btn-secondary" id="output" type="button">Show the html this produces</button>
129
132
  <button class="btn btn-sm btn-primary" id="authored" type="button">Open that html as a real page</button>
@@ -370,6 +373,60 @@
370
373
  </div>
371
374
  </div>
372
375
 
376
+ <div class="row">
377
+ <div class="col-lg-12">
378
+ <div data-ge-container="navbar">
379
+ <nav class="navbar navbar-expand-lg bg-body-tertiary">
380
+ <div class="container-fluid">
381
+ <a class="navbar-brand" href="#">Example</a>
382
+ <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#example-navbar" aria-controls="example-navbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
383
+ <div class="collapse navbar-collapse" id="example-navbar">
384
+ <ul class="navbar-nav">
385
+ <li class="nav-item"><a class="nav-link active" aria-current="page" href="#">Home</a></li>
386
+ <li class="nav-item"><a class="nav-link" href="#">Pricing</a></li>
387
+ <li class="nav-item dropdown">
388
+ <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Products</a>
389
+ <ul class="dropdown-menu">
390
+ <li><a class="dropdown-item" href="#">Editor</a></li>
391
+ <li><hr class="dropdown-divider"></li>
392
+ <li><a class="dropdown-item" href="#">Plugins</a></li>
393
+ </ul>
394
+ </li>
395
+ </ul>
396
+ <span class="navbar-text ms-auto">Signed out</span>
397
+ </div>
398
+ </div>
399
+ </nav>
400
+ </div>
401
+ </div>
402
+ </div>
403
+
404
+ <div class="row">
405
+ <div class="col-lg-4">
406
+ <div data-ge-container="sidenav">
407
+ <div class="d-flex flex-column flex-shrink-0 p-3 bg-body-tertiary" style="width: 280px;">
408
+ <a class="d-flex align-items-center mb-3 link-body-emphasis text-decoration-none fs-4" href="#" data-ge-nav="brand">Docs</a>
409
+ <ul class="nav nav-pills flex-column">
410
+ <li class="nav-item"><a class="nav-link active" aria-current="page" href="#">Start</a></li>
411
+ <li class="nav-item" data-ge-nav="submenu">
412
+ <a class="nav-link dropdown-toggle" href="#example-submenu" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="example-submenu">Guides</a>
413
+ <div class="collapse" id="example-submenu">
414
+ <ul class="nav flex-column ms-3">
415
+ <li class="nav-item"><a class="nav-link" href="#">Containers</a></li>
416
+ <li class="nav-item"><a class="nav-link" href="#">Plugins</a></li>
417
+ </ul>
418
+ </div>
419
+ </li>
420
+ <li class="nav-item"><a class="nav-link" href="#">Changelog</a></li>
421
+ </ul>
422
+ </div>
423
+ </div>
424
+ </div>
425
+ <div class="col-lg-8">
426
+ <div class="ge-content" data-ge-content-type="tinymce"><p>The sidebar is a column of its own here, with content next to it.</p></div>
427
+ </div>
428
+ </div>
429
+
373
430
  </div> <!-- /#myGrid -->
374
431
  </div> <!-- /.container -->
375
432
 
@@ -72,7 +72,7 @@
72
72
  <strong>Containers</strong>
73
73
  <code class="text-body-secondary">containers.html</code>
74
74
  </div>
75
- <span class="text-body-secondary">Tabs, accordions, popups, offcanvases and cards, two levels deep, and the export opened as a real page</span>
75
+ <span class="text-body-secondary">Tabs, accordions, popups, offcanvases, cards, a navbar and a sidebar, two levels deep, and the export opened as a real page</span>
76
76
  </a>
77
77
 
78
78
  <a class="list-group-item list-group-item-action" href="elements.html">
@@ -46,6 +46,8 @@
46
46
  <script src="../dist/plugins/grideditor.offcanvas.min.js"></script>
47
47
  <script src="../dist/plugins/grideditor.carousel.min.js"></script>
48
48
  <script src="../dist/plugins/grideditor.card.min.js"></script>
49
+ <script src="../dist/plugins/grideditor.navbar.min.js"></script>
50
+ <script src="../dist/plugins/grideditor.sidenav.min.js"></script>
49
51
  <script src="../dist/plugins/grideditor.order.min.js"></script>
50
52
  <script src="../dist/plugins/grideditor.alignment.min.js"></script>
51
53
  <script src="../dist/plugins/grideditor.gutters.min.js"></script>
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "version": "9.2.6",
35
+ "version": "9.3.0",
36
36
  "main": "dist/grideditor.js",
37
37
  "module": "dist/grideditor.esm.js",
38
38
  "types": "dist/grideditor.d.ts",
@@ -2006,6 +2006,15 @@ function build(instance, baseElem, optionsOrMethod) {
2006
2006
  // a column. A row in a row brings a column too
2007
2007
  var placed = wrapFor(where.region, made);
2008
2008
 
2009
+ // What the region will not have goes to the canvas, as a feature's
2010
+ // button does: the column a container was wrapped in is one the
2011
+ // region will not take either
2012
+ var holder = placed === made ? null : made.parentElement;
2013
+ if (!acceptsBlock(where.region, placed) || (holder && !acceptsBlock(holder, made))) {
2014
+ where = canvasAfterTopOf(where.region);
2015
+ placed = wrapFor(where.region, made);
2016
+ }
2017
+
2009
2018
  return addNode(container ? type : 'row', made, function() {
2010
2019
  if (where.before) {
2011
2020
  where.before.parentNode.insertBefore(placed, where.before);
@@ -3766,11 +3775,11 @@ function build(instance, baseElem, optionsOrMethod) {
3766
3775
  * A pane drawer: small, inline, and made the same way for every
3767
3776
  * container type so a tab and an accordion item behave alike.
3768
3777
  */
3769
- function createPaneControls(pane, kind, tools, confirmText, remove) {
3778
+ function createPaneControls(pane, kind, tools, confirmText, remove, options) {
3770
3779
  var drawer = prependDrawer(pane, 'ge-tools-drawer ge-pane-drawer');
3771
3780
 
3772
3781
  createMoveTool(drawer);
3773
- addSettingsTool(drawer, pane, settings.pane_classes);
3782
+ addSettingsTool(drawer, pane, options && options.presets ? options.presets : settings.pane_classes);
3774
3783
 
3775
3784
  hostTools(drawer, tools);
3776
3785
 
@@ -3839,12 +3848,17 @@ function build(instance, baseElem, optionsOrMethod) {
3839
3848
 
3840
3849
  var toggle = dom.closest(label, '[data-bs-toggle], [data-ge-bs-toggle]');
3841
3850
 
3851
+ // A toggle already apart when the editing starts - an accordion
3852
+ // item's button - stays apart when it ends
3853
+ var keepApart = false;
3854
+
3842
3855
  editableLabels.add(label);
3843
3856
  label.setAttribute('title', t('tool.rename'));
3844
3857
  label.addEventListener('dblclick', function(e) {
3845
3858
  e.preventDefault();
3846
3859
  e.stopPropagation();
3847
3860
 
3861
+ keepApart = !!toggle && toggle.hasAttribute('data-ge-bs-toggle');
3848
3862
  suspendToggles(toggle);
3849
3863
  label.setAttribute('contenteditable', 'true');
3850
3864
  label.focus();
@@ -3860,7 +3874,7 @@ function build(instance, baseElem, optionsOrMethod) {
3860
3874
  });
3861
3875
  label.addEventListener('blur', function() {
3862
3876
  label.removeAttribute('contenteditable');
3863
- resumeToggles(toggle);
3877
+ if (!keepApart) { resumeToggles(toggle); }
3864
3878
  });
3865
3879
  }
3866
3880
 
@@ -5295,10 +5309,21 @@ function build(instance, baseElem, optionsOrMethod) {
5295
5309
  case 'section': return t('panel.kind_section');
5296
5310
  case 'tab': return t('panel.kind_tab');
5297
5311
  case 'accordion-item': return t('panel.kind_accordion_item');
5298
- default: return kind;
5312
+ default: return featureKindLabel(kind) || kind;
5299
5313
  }
5300
5314
  }
5301
5315
 
5316
+ /** What a feature plugin calls a kind it made up, or null when none does. */
5317
+ function featureKindLabel(kind) {
5318
+ var label = null;
5319
+
5320
+ pluginHooks('kindLabel').forEach(function(hook) {
5321
+ if (label === null) { label = hook(kind) || null; }
5322
+ });
5323
+
5324
+ return label;
5325
+ }
5326
+
5302
5327
  /**
5303
5328
  * Make sure every column is marked as one, and that a column with no
5304
5329
  * sizing at all gets some.
@@ -6173,6 +6198,13 @@ function build(instance, baseElem, optionsOrMethod) {
6173
6198
  ? target
6174
6199
  : target.parentElement;
6175
6200
 
6201
+ // Checked now, not when a queued add runs: a caller inside an
6202
+ // event handler gets its answer at once
6203
+ if (parent && !acceptsBlock(parent, node)) {
6204
+ warn(kind + ': ' + kindOf(parent) + ' does not take it; nothing is added');
6205
+ return null;
6206
+ }
6207
+
6176
6208
  var add = function() {
6177
6209
  return addNode(kind, node, function() {
6178
6210
  if (placement === 'appendTo') {
@@ -132,6 +132,108 @@ GridEditor.locales.es = {
132
132
  'container.add_accordion': 'Acordeón',
133
133
  'container.add_accordion_item': 'Añadir apartado',
134
134
  'container.accordion_label': 'Apartado {number}',
135
+ 'container.add_navbar': 'Barra de navegación',
136
+ 'container.add_sidenav': 'Barra lateral',
137
+ 'container.navbar_brand': 'Marca',
138
+ 'container.sidenav_brand': 'Marca',
139
+ 'container.nav_link': 'Enlace',
140
+ 'container.nav_dropdown': 'Desplegable',
141
+ 'container.nav_submenu': 'Submenú',
142
+ 'container.nav_menu_link': 'Acción',
143
+ 'container.nav_menu_header': 'Encabezado',
144
+ 'container.nav_text': 'Texto',
145
+ 'container.navbar_toggle': 'Mostrar navegación',
146
+ 'container.navbar_offcanvas_title': 'Menú',
147
+ 'container.sidenav_trigger': 'Menú',
148
+ 'tool.add_nav_piece': 'Añadir…',
149
+ 'tool.add_nav_link': 'Añadir enlace o desplegable',
150
+ 'tool.add_nav_menu_item': 'Añadir ítem',
151
+ 'tool.fold_nav_menu': 'Plegar este menú mientras editas',
152
+ 'confirm.delete_nav_piece': '¿Borrar esto y todo lo que contiene?',
153
+ 'container.navbar_section': 'Barra de navegación',
154
+ 'container.sidenav_section': 'Barra lateral',
155
+ 'container.nav_brand_show': 'Marca',
156
+ 'container.nav_brand_image': 'Imagen',
157
+ 'container.nav_brand_alt': 'Texto alternativo',
158
+ 'container.nav_brand_height': 'Alto (px)',
159
+ 'container.navbar_expand': 'Expandir',
160
+ 'container.navbar_expand_never': 'Nunca',
161
+ 'container.navbar_expand_always': 'Siempre',
162
+ 'container.navbar_expand_from': 'Desde {breakpoint}',
163
+ 'container.navbar_collapse': 'Plegado',
164
+ 'container.navbar_collapse_collapse': 'Collapse',
165
+ 'container.navbar_collapse_offcanvas': 'Offcanvas',
166
+ 'container.navbar_collapse_none': 'Sin plegar',
167
+ 'container.navbar_offcanvas_placement': 'Lado',
168
+ 'container.nav_start': 'Inicio',
169
+ 'container.nav_end': 'Fin',
170
+ 'container.nav_bg': 'Fondo',
171
+ 'container.nav_bg_none': 'Ninguno',
172
+ 'container.nav_bg_body_tertiary': 'Gris claro',
173
+ 'container.nav_bg_body': 'Página',
174
+ 'container.nav_bg_primary': 'Primario',
175
+ 'container.nav_bg_secondary': 'Secundario',
176
+ 'container.nav_bg_success': 'Éxito',
177
+ 'container.nav_bg_danger': 'Peligro',
178
+ 'container.nav_bg_warning': 'Aviso',
179
+ 'container.nav_bg_info': 'Información',
180
+ 'container.nav_bg_light': 'Claro',
181
+ 'container.nav_bg_dark': 'Oscuro',
182
+ 'container.nav_theme': 'Tema',
183
+ 'container.nav_theme_auto': 'Automático',
184
+ 'container.nav_theme_light': 'Claro',
185
+ 'container.nav_theme_dark': 'Oscuro',
186
+ 'container.navbar_position': 'Posición',
187
+ 'container.navbar_position_none': 'En su sitio',
188
+ 'container.navbar_position_fixed_top': 'Fija arriba',
189
+ 'container.navbar_position_fixed_bottom': 'Fija abajo',
190
+ 'container.navbar_position_sticky_top': 'Pegada arriba',
191
+ 'container.navbar_position_sticky_bottom': 'Pegada abajo',
192
+ 'container.navbar_width': 'Ancho interior',
193
+ 'container.navbar_width_fluid': 'Completo',
194
+ 'container.navbar_width_fixed': 'Fijo',
195
+ 'container.navbar_width_from': 'Completo hasta {breakpoint}',
196
+ 'container.sidenav_width': 'Ancho',
197
+ 'container.sidenav_style': 'Estilo de enlaces',
198
+ 'container.sidenav_style_pills': 'Pills',
199
+ 'container.sidenav_style_plain': 'Sencillo',
200
+ 'container.sidenav_full_height': 'Alto completo',
201
+ 'container.sidenav_responsive': 'Responsive',
202
+ 'container.sidenav_responsive_never': 'Siempre visible',
203
+ 'container.sidenav_responsive_from': 'Offcanvas por debajo de {breakpoint}',
204
+ 'container.sidenav_offcanvas_title': 'Menú',
205
+ 'container.nav_close': 'Cerrar',
206
+ 'container.nav_list_section': 'Lista',
207
+ 'container.nav_link_section': 'Enlace',
208
+ 'container.nav_dropdown_section': 'Desplegable',
209
+ 'container.nav_menu_item_section': 'Ítem',
210
+ 'container.nav_text_section': 'Texto',
211
+ 'container.nav_zone_section': 'Zona libre',
212
+ 'container.nav_brand_section': 'Marca',
213
+ 'container.nav_align': 'Alineación',
214
+ 'container.nav_align_after': 'Tras lo anterior',
215
+ 'container.nav_align_end': 'Al final',
216
+ 'container.nav_align_center': 'Centrada',
217
+ 'container.nav_scroll': 'Scroll',
218
+ 'container.nav_scroll_height': 'Alto',
219
+ 'container.nav_bottom': 'Al pie',
220
+ 'container.nav_href': 'URL',
221
+ 'container.nav_active': 'Activo',
222
+ 'container.nav_disabled': 'Desactivado',
223
+ 'container.nav_new_tab': 'Pestaña nueva',
224
+ 'container.nav_menu_end': 'Menú a la derecha',
225
+ 'container.nav_submenu_type': 'Tipo',
226
+ 'container.nav_submenu_type_collapse': 'Plegable',
227
+ 'container.nav_submenu_type_dropdown': 'Dropdown',
228
+ 'container.nav_submenu_open': 'Abierto al cargar',
229
+ 'container.nav_menu_divider': 'Separador',
230
+ 'container.nav_zone': 'Zona libre',
231
+ 'tool.add_nav_list': 'Añadir lista',
232
+ 'tool.add_nav_text': 'Añadir texto',
233
+ 'tool.add_nav_zone': 'Añadir zona libre',
234
+ 'tool.unfold_nav_menu': 'Desplegar este menú',
235
+ 'container.nav_browse': 'Examinar…',
236
+ 'tool.delete_nav_piece': 'Borrar',
135
237
  'container.add_popup': 'Ventana emergente',
136
238
  'container.popup_title': 'Título',
137
239
  'container.popup_trigger': 'Abrir',
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The button that opens the host's file browser: `browse(done, { node,
3
+ * property, value })` in the navbar or sidenav setting, answered by
4
+ * `done(url)` or by the promise it returns, whichever comes first.
5
+ * Nothing, an empty text or a value that is not a text leaves the field as
6
+ * it was, and so does an answer that comes when the node or the editor is
7
+ * gone. Errors are the host's: not caught.
8
+ */
9
+ import * as dom from '../dom.js';
10
+
11
+ /**
12
+ * `browse` is the host's function, `context.destroyed` says the editor is
13
+ * gone, and `current()` and `apply(url)` read and write the field. `node`
14
+ * is the node the answer is for, or a function that says which when asked.
15
+ * Nothing when the host gave no `browse`.
16
+ */
17
+ export function browseButton(ge, context, browse, node, property, current, apply) {
18
+ if (typeof browse !== 'function') { return null; }
19
+
20
+ var button = dom.element('button', {
21
+ type: 'button',
22
+ 'class': 'btn btn-outline-secondary ge-nav-browse',
23
+ title: ge.t('container.nav_browse'),
24
+ 'aria-label': ge.t('container.nav_browse'),
25
+ });
26
+ button.appendChild(dom.element('i', { 'class': 'bi bi-folder2-open', 'aria-hidden': 'true' }));
27
+
28
+ button.addEventListener('click', function() {
29
+ var answered = false; // Each press takes one answer, the first
30
+ var target = typeof node === 'function' ? node() : node;
31
+
32
+ function answer(url) {
33
+ if (answered) { return; }
34
+ answered = true;
35
+
36
+ if (url === null || url === undefined) { return; }
37
+ if (typeof url !== 'string') {
38
+ ge.warn('navbar and sidenav browse gave ' + typeof url + ', not a text: ignored');
39
+ return;
40
+ }
41
+ if (url.trim() === '' || context.destroyed || !ge.canvas.contains(target)) { return; }
42
+
43
+ apply(url.trim());
44
+ }
45
+
46
+ var result = browse(answer, { node: target, property: property, value: current() });
47
+ if (result && typeof result.then === 'function') { result.then(answer); }
48
+ });
49
+
50
+ return button;
51
+ }