@themarioga/grid-editor 9.2.6 → 9.4.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 (51) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +109 -5
  3. package/dist/grideditor.bundle.min.js +2 -2
  4. package/dist/grideditor.css +329 -0
  5. package/dist/grideditor.d.ts +125 -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 +125 -0
  13. package/dist/locales/grideditor.es.js +125 -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.dropdown.esm.js +2231 -0
  17. package/dist/plugins/grideditor.dropdown.js +2232 -0
  18. package/dist/plugins/grideditor.dropdown.min.js +1 -0
  19. package/dist/plugins/grideditor.dropdown.min.js.map +7 -0
  20. package/dist/plugins/grideditor.navbar.esm.js +2188 -0
  21. package/dist/plugins/grideditor.navbar.js +2189 -0
  22. package/dist/plugins/grideditor.navbar.min.js +1 -0
  23. package/dist/plugins/grideditor.navbar.min.js.map +7 -0
  24. package/dist/plugins/grideditor.sidenav.esm.js +2082 -0
  25. package/dist/plugins/grideditor.sidenav.js +2083 -0
  26. package/dist/plugins/grideditor.sidenav.min.js +1 -0
  27. package/dist/plugins/grideditor.sidenav.min.js.map +7 -0
  28. package/docs/events.md +5 -1
  29. package/docs/locale-keys.md +126 -1
  30. package/docs/plugins.md +24 -4
  31. package/example/containers.html +93 -2
  32. package/example/index.html +1 -1
  33. package/example/playground.html +3 -0
  34. package/package.json +1 -1
  35. package/src/js/grideditor.js +36 -4
  36. package/src/js/locales/grideditor.es.js +125 -0
  37. package/src/js/nav/browse.js +51 -0
  38. package/src/js/nav/canvas.js +170 -0
  39. package/src/js/nav/convert.js +179 -0
  40. package/src/js/nav/drawers.js +290 -0
  41. package/src/js/nav/dropdown.js +253 -0
  42. package/src/js/nav/feature.js +113 -0
  43. package/src/js/nav/locale.js +128 -0
  44. package/src/js/nav/markup.js +121 -0
  45. package/src/js/nav/panels.js +454 -0
  46. package/src/js/nav/pieces.js +253 -0
  47. package/src/js/plugins/grideditor.dropdown.js +335 -0
  48. package/src/js/plugins/grideditor.navbar.js +454 -0
  49. package/src/js/plugins/grideditor.sidenav.js +349 -0
  50. package/src/less/grideditor.less +231 -0
  51. package/types/grideditor.d.ts +125 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,63 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
 
8
+ ## [Unreleased]
9
+
10
+
11
+ ## [9.4.0] - 2026-12-02
12
+
13
+ ### Added
14
+ - **Dropdown** (`grideditor.dropdown.js`), a container plugin: a Bootstrap 5.3
15
+ dropdown on its own, in a column. Its menu is a list of items - links,
16
+ dividers, headers and texts, edited where they stand and reordered as a
17
+ navbar's dropdowns are - or free content, rows and columns, whichever the
18
+ settings panel says; changing it asks first. The button can be split, open
19
+ down, up, right or left, take the menu to the right, and have a Bootstrap
20
+ style, outlined or not, and a size. The setting `dropdown` and
21
+ `createContainer('dropdown', …)` take the same options and a `browse` for
22
+ the host's file browser. It shares `src/js/nav/` with the navbar and sidenav
23
+ plugins, which it works beside in any order of loading; load the three from
24
+ the same version.
25
+
26
+ ### Fixed
27
+ - An item dragged from one dropdown's menu to another's, in a navbar or a
28
+ sidebar, no longer gets the `dropdown-item` class twice.
29
+
30
+ ## [9.3.0] - 2026-12-01
31
+
32
+ ### Added
33
+ - **Navbar** (`grideditor.navbar.js`) and **sidebar** (`grideditor.sidenav.js`)
34
+ container plugins. A navbar is Bootstrap 5.3's, with a brand, lists of
35
+ links, dropdowns, texts and free zones of rows and columns, that folds into
36
+ a collapse or an offcanvas, or not at all. A sidebar is the _Sidebars_
37
+ example, with collapsible submenus or dropdowns, that becomes an offcanvas
38
+ below a breakpoint. Every piece has a drawer, its text is edited where it
39
+ stands, and its options - the settings `navbar` and `sidenav`, and the
40
+ panel - include a `browse(done, { node, property, value })` for the host's
41
+ file browser. The plugin is called `sidenav` and the toolbar says _Sidebar_,
42
+ because the editor's `sidebar` setting is its own settings panel.
43
+ - The plugin hook `kindLabel(kind)`, for the title the settings panel gives a
44
+ kind a feature plugin made up.
45
+ - `ge.createPaneControls(…, options)`, with `options.presets` for the preset
46
+ classes of the pane's panel.
47
+
48
+ ### Changed
49
+ - The toolbar's container and row buttons, `ge.place` - `createContainer`,
50
+ `createRow`, `createSection`… with `appendTo` and the like - and the
51
+ clipboard's paste tool now ask a feature's `accepts(region, node)`, as a
52
+ drag, Ctrl+V and the buttons of a feature plugin already did. What the
53
+ toolbar was going to add to a region that will not have it goes to the
54
+ canvas, after the block the region is in. `ge.place` warns, adds nothing
55
+ and returns `null`: `createSection({ appendTo: <a column> })`, which left
56
+ the section in the column, no longer does.
57
+
58
+ ### Fixed
59
+ - `ge.makeLabelEditable` put a Bootstrap toggle back when the editing was
60
+ done even if it had been apart before, as an accordion item's button is:
61
+ renaming an item left its collapse working in the canvas. It now puts back
62
+ only what it took.
63
+
64
+
8
65
  ## [9.2.6] - 2026-11-22
9
66
 
10
67
  ### Fixed
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Grid Editor
2
2
  ===========
3
3
 
4
- Grid Editor is a visual javascript editor for the [bootstrap 5 grid system](https://getbootstrap.com/docs/5.3/layout/grid/), in plain DOM: no jQuery needed. You can create, drag, resize and delete rows and columns — sized in units, equal (`col`) or to their content (`col-auto`), or shared out by their row (`row-cols-*`) — indent them, group them in sections (`.container`), copy and paste them, and give each of bootstrap's six breakpoints its own layout — or edit them all at once, with a mouse or with a finger. Bootstrap's responsive utilities — display, flex, order, alignment, gutters, spacing, text alignment, sticky and float — are edited per breakpoint too, and any row, column, container or element can be given inline css, with Bootstrap's classes for it offered as chips. It also edits tabs, accordions, popups, offcanvases, carousels and cards, and any markup you mark as an element, and it tells your application about every change it makes.
4
+ Grid Editor is a visual javascript editor for the [bootstrap 5 grid system](https://getbootstrap.com/docs/5.3/layout/grid/), in plain DOM: no jQuery needed. You can create, drag, resize and delete rows and columns — sized in units, equal (`col`) or to their content (`col-auto`), or shared out by their row (`row-cols-*`) — indent them, group them in sections (`.container`), copy and paste them, and give each of bootstrap's six breakpoints its own layout — or edit them all at once, with a mouse or with a finger. Bootstrap's responsive utilities — display, flex, order, alignment, gutters, spacing, text alignment, sticky and float — are edited per breakpoint too, and any row, column, container or element can be given inline css, with Bootstrap's classes for it offered as chips. It also edits tabs, accordions, popups, offcanvases, carousels, cards, navbars and sidebars, and any markup you mark as an element, and it tells your application about every change it makes.
5
5
 
6
6
  This is a fork of [Friendly-Pixel/grid-editor](https://github.com/Friendly-Pixel/grid-editor)
7
7
  by Simon Epskamp, carrying it on from 2.x. It is published as
@@ -26,7 +26,7 @@ from any web server, or from GitHub Pages, with no build step.
26
26
  | [example/basic.html](example/basic.html) | The editor with tinyMCE in the content areas | [live](https://themarioga.github.io/grid-editor/example/basic.html) |
27
27
  | [example/columns.html](example/columns.html) | The six breakpoints and the "all sizes" view, equal and auto columns, columns per row, and sections | [live](https://themarioga.github.io/grid-editor/example/columns.html) |
28
28
  | [example/custom-plugins.html](example/custom-plugins.html) | Plugins of your own: a container, and a drawer tool with a modal that saves an attribute | [live](https://themarioga.github.io/grid-editor/example/custom-plugins.html) |
29
- | [example/containers.html](example/containers.html) | Tabs, accordions, popups, offcanvases, carousels and cards, two levels deep | [live](https://themarioga.github.io/grid-editor/example/containers.html) |
29
+ | [example/containers.html](example/containers.html) | Tabs, accordions, popups, offcanvases, carousels, cards, a navbar, a sidebar and dropdowns, two levels deep | [live](https://themarioga.github.io/grid-editor/example/containers.html) |
30
30
  | [example/elements.html](example/elements.html) | Element level controls, including an element with no visual output | [live](https://themarioga.github.io/grid-editor/example/elements.html) |
31
31
  | [example/style.html](example/style.html) | Inline style with Bootstrap's classes as chips, and the responsive utilities, edited per breakpoint | [live](https://themarioga.github.io/grid-editor/example/style.html) |
32
32
  | [example/locale.html](example/locale.html) | The interface in Spanish, with a language switcher | [live](https://themarioga.github.io/grid-editor/example/locale.html) |
@@ -189,7 +189,7 @@ has, with the options it was made with, and warns once.
189
189
  | `createSection` | `options?` | `Element` | A section, with the sections plugin. `options`: `width` (`'fixed'`, `'fluid'` or a breakpoint), `rows` (layouts), and a placement |
190
190
  | `createElement` | `content`, `options?` | `Element` | Host markup wrapped as an element. `options`: `type`, `label` |
191
191
  | `createText` | `type?`, `options?` | `Element` | A content area for a text editor, the first one offered by default. `options`: `content`, and a placement. `null` if the editor is not loaded, or no text editor is |
192
- | `createContainer` | `type`, `options?` | `Element` | `'tabs'`, `'accordion'`, `'popup'`, `'offcanvas'`, `'carousel'` or `'card'` |
192
+ | `createContainer` | `type`, `options?` | `Element` | `'tabs'`, `'accordion'`, `'popup'`, `'offcanvas'`, `'carousel'`, `'card'`, `'navbar'`, `'sidenav'` or `'dropdown'` |
193
193
  | `addTab` | `container`, `options?` | `Element` | Appends a tab, returns its pane |
194
194
  | `addAccordionItem` | `container`, `options?` | `Element` | Appends an item, returns its body |
195
195
  | `addPane` | `container`, `options?` | `Element` | Appends a pane to a container of any type that has them - a tab, an item, a carousel slide, whose `options.interval` is its time in milliseconds - and returns it. `null`, and a warning, for a node that is not one |
@@ -1017,7 +1017,7 @@ The methods are there only when the plugin is loaded.
1017
1017
 
1018
1018
  ### Containers
1019
1019
 
1020
- Tabs, accordions, popups, offcanvases, carousels and cards. A tabs, accordion or
1020
+ Tabs, accordions, popups, offcanvases, carousels, cards, navbars, sidebars and dropdowns. A tabs, accordion or
1021
1021
  carousel container holds panes; a popup, an offcanvas and a card hold one region. Either way a region is an ordinary one: rows,
1022
1022
  columns, content areas and elements nest inside it exactly as they do at the
1023
1023
  top level.
@@ -1033,6 +1033,9 @@ it available:
1033
1033
  <script src="grid-editor/dist/plugins/grideditor.offcanvas.min.js"></script>
1034
1034
  <script src="grid-editor/dist/plugins/grideditor.carousel.min.js"></script>
1035
1035
  <script src="grid-editor/dist/plugins/grideditor.card.min.js"></script>
1036
+ <script src="grid-editor/dist/plugins/grideditor.navbar.min.js"></script>
1037
+ <script src="grid-editor/dist/plugins/grideditor.sidenav.min.js"></script>
1038
+ <script src="grid-editor/dist/plugins/grideditor.dropdown.min.js"></script>
1036
1039
  ```
1037
1040
 
1038
1041
  The toolbar offers a button per loaded plugin. See [docs/plugins.md](docs/plugins.md)
@@ -1114,7 +1117,108 @@ puts the attributes Bootstrap's javascript acts on aside, so an autoplay never
1114
1117
  starts over the canvas. Each slide's drawer moves it a place back or on. What
1115
1118
  `getHtml` gives starts at the first slide, whichever one the canvas was on.
1116
1119
 
1117
- See [example/containers.html](example/containers.html).
1120
+ A navbar and a sidebar are navigation, and are edited piece by piece: see
1121
+ [Navbars and sidebars](#navbars-and-sidebars) below. A dropdown on its own is
1122
+ edited the same way: see [Dropdowns](#dropdowns). See
1123
+ [example/containers.html](example/containers.html).
1124
+
1125
+ #### Navbars and sidebars
1126
+
1127
+ `grideditor.navbar.js` is a Bootstrap 5.3 navbar - a brand, lists of links,
1128
+ dropdowns, texts, and _free zones_ that hold rows and columns - and
1129
+ `grideditor.sidenav.js` is a vertical one, as in Bootstrap's _Sidebars_
1130
+ example. The sidebar's plugin is `sidenav`, and its toolbar button says
1131
+ _Sidebar_: the editor's `sidebar` setting is its settings panel. Load both
1132
+ files from the same version of grid-editor.
1133
+
1134
+ Each piece - a list, a link, a dropdown or submenu, an item of a menu, a text,
1135
+ a free zone, the brand - has a drawer, and its text is renamed where it
1136
+ stands. Its options are in its settings panel, and the container's in a
1137
+ section of its own. Nothing of Bootstrap's javascript runs on the canvas while
1138
+ editing: the part that folds and the menus are shown open, each menu has a
1139
+ tool to fold it away, and a click on a link goes nowhere. With the preview
1140
+ button pressed the toggles and dropdowns work, and links still go nowhere.
1141
+ `getHtml` gives a navbar that works on the page with Bootstrap's javascript.
1142
+
1143
+ __`navbar`:__ The options of the navbars made new, as Bootstrap has them:
1144
+ `expand` (`false`, `true`, or the breakpoint - `'sm'` to `'xxl'` - from which
1145
+ it is expanded; `'lg'`), `collapse` (`'collapse'`, `'offcanvas'` or `false` for
1146
+ a navbar that does not fold; `'collapse'`), `offcanvas_placement` (`'start'` or
1147
+ `'end'`; `'end'`), `bg` (`'body-tertiary'`, `'primary'`, `'dark'`… or `null`;
1148
+ `'body-tertiary'`), `theme` (`null`, `'light'` or `'dark'`), `position`
1149
+ (`'fixed-top'`, `'fixed-bottom'`, `'sticky-top'`, `'sticky-bottom'` or `null`)
1150
+ and `width` (`'fluid'`, `'fixed'` or a breakpoint; `'fluid'`). A value a key
1151
+ does not take is warned about and its default used. `createContainer` also takes
1152
+ `brand`, the brand's text or `false` for none.
1153
+
1154
+ __`sidenav`:__ The options of the sidebars made new: `width` (a css length the
1155
+ browser takes as a `width`; `'280px'`), `bg` and `theme` (as the navbar's),
1156
+ `style` (`'pills'` or `'plain'`), `full_height` (`false`) and `responsive` (`null`
1157
+ for always visible, or the breakpoint below which it is an offcanvas a button
1158
+ opens). `createContainer` also takes `brand` and `trigger_label`, the button's
1159
+ text.
1160
+
1161
+ __`browse`:__ In the `navbar` and in the `sidenav` setting, the host's file
1162
+ browser: with it, the field for a link's URL, and the brand's image, has a
1163
+ _Browse…_ button. It is `browse(done, { node, property, value })`, as
1164
+ `inline_style.browse` is: `property` is `'href'` or `'src'`, and the answer is
1165
+ `done(url)` or the promise the function returns, whichever comes first.
1166
+ Nothing, `null` or an empty text leaves the field as it was.
1167
+
1168
+ ```javascript
1169
+ new GridEditor('#myGrid', {
1170
+ navbar: { expand: 'md', browse: function(done, field) { openMyFileBrowser(field.value).then(done); } },
1171
+ sidenav: { width: '20rem', responsive: 'lg' },
1172
+ });
1173
+ ge.createContainer('navbar', { brand: 'ACME', collapse: 'offcanvas' });
1174
+ ge.createContainer('sidenav', { brand: false, full_height: true });
1175
+ ```
1176
+
1177
+ A link's `href` is written as it is typed, `javascript:` included: cleaning it
1178
+ is the page's, as it is for any markup the editor is given. A navbar with
1179
+ `position: 'sticky-top'` only sticks inside its parent: in a column of a row
1180
+ of its own there is no distance to travel, and a sidebar next to a column of
1181
+ content taller than it does stick. `fixed-*` and `sticky-*` are shown in their
1182
+ place while editing, so they never cover the editor.
1183
+
1184
+ #### Dropdowns
1185
+
1186
+ `grideditor.dropdown.js` is a Bootstrap 5.3 dropdown on its own: a button that
1187
+ opens a menu, in a column like any other block. The menu is one of two kinds,
1188
+ chosen in its settings panel: _Items_ - links, dividers, headers and texts,
1189
+ renamed where they stand and reordered by their drawers, as the dropdowns of a
1190
+ navbar are - or _Free content_, rows and columns. Changing the kind asks first,
1191
+ and what the menu held is dropped. The button can be split into an action,
1192
+ with a link of its own, and a caret; it opens down, up, right or left; the menu
1193
+ can open to the right; and it has a Bootstrap style, outlined or not, and a
1194
+ size.
1195
+
1196
+ Nothing of Bootstrap's javascript runs on the canvas while editing: the menu is
1197
+ shown open, below the buttons whichever the direction, with a tool to fold it
1198
+ away, and a click on a link goes nowhere. With the preview button pressed the
1199
+ toggle works. A dropdown is not put inside the free content of another, nor a
1200
+ navbar or a sidebar: Bootstrap has no menus inside menus. Load it from the same
1201
+ version of grid-editor as the navbar and sidenav plugins, in any order.
1202
+
1203
+ __`dropdown`:__ The options of the dropdowns made new: `label` (the button's
1204
+ text; the interface's `Dropdown`), `menu` (`'items'` or `'content'`), `style`
1205
+ (`'secondary'`, `'primary'`, `'success'`, `'danger'`, `'warning'`, `'info'`,
1206
+ `'light'`, `'dark'` or `'link'`), `outline` (`false`; `link` has none), `size`
1207
+ (`null`, `'sm'` or `'lg'`), `direction` (`'down'`, `'up'`, `'end'` or `'start'`),
1208
+ `menu_end` (`false`) and `split` (`false`), and `browse`, the host's file
1209
+ browser of the navbar and sidenav settings, for the links. `createContainer`
1210
+ takes the same options, which win over the setting. A value a key does not take
1211
+ is warned about and its default used.
1212
+
1213
+ ```javascript
1214
+ new GridEditor('#myGrid', { dropdown: { style: 'primary', size: 'sm' } });
1215
+ ge.createContainer('dropdown', { label: 'Actions', split: true, direction: 'end' });
1216
+ ge.createContainer('dropdown', { menu: 'content', label: 'Filters' });
1217
+ ```
1218
+
1219
+ A link's `href` is written as it is typed, as in the navbar. A button's text and
1220
+ the toggles are edited in place, and `getHtml` gives the markup of Bootstrap's
1221
+ documentation, with nothing of the editor in it.
1118
1222
 
1119
1223
  ### Localization
1120
1224