@themarioga/grid-editor 9.0.0-beta.2 → 9.0.0-beta.4
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.
- package/CHANGELOG.md +34 -0
- package/README.md +76 -8
- package/dist/grideditor.bundle.min.js +2 -2
- package/dist/grideditor.css +187 -0
- package/dist/grideditor.d.ts +75 -0
- package/dist/grideditor.esm.js +38 -11
- package/dist/grideditor.js +38 -11
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/grideditor.min.js +1 -1
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +22 -0
- package/dist/locales/grideditor.es.js +22 -0
- package/dist/locales/grideditor.es.min.js +2 -2
- package/dist/locales/grideditor.es.min.js.map +2 -2
- package/dist/plugins/grideditor.history.esm.js +360 -0
- package/dist/plugins/grideditor.history.js +365 -0
- package/dist/plugins/grideditor.history.min.js +1 -0
- package/dist/plugins/grideditor.history.min.js.map +7 -0
- package/dist/plugins/grideditor.offcanvas.esm.js +551 -0
- package/dist/plugins/grideditor.offcanvas.js +556 -0
- package/dist/plugins/grideditor.offcanvas.min.js +1 -0
- package/dist/plugins/grideditor.offcanvas.min.js.map +7 -0
- package/dist/plugins/grideditor.popup.esm.js +90 -37
- package/dist/plugins/grideditor.popup.js +90 -37
- package/dist/plugins/grideditor.popup.min.js +1 -1
- package/dist/plugins/grideditor.popup.min.js.map +4 -4
- package/docs/events.md +7 -3
- package/docs/locale-keys.md +32 -1
- package/docs/plugins.md +19 -5
- package/example/clipboard.html +22 -0
- package/example/containers.html +22 -4
- package/example/history.html +94 -0
- package/example/index.html +9 -1
- package/package.json +1 -1
- package/src/js/grideditor.js +37 -9
- package/src/js/locales/grideditor.es.js +22 -0
- package/src/js/plugins/grideditor.history.js +367 -0
- package/src/js/plugins/grideditor.offcanvas.js +420 -0
- package/src/js/plugins/grideditor.popup.js +8 -70
- package/src/js/triggers/triggers.js +121 -0
- package/src/less/grideditor.less +60 -0
- package/types/grideditor.d.ts +75 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ 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
|
+
## [9.0.0-beta.4] - 2026-10-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- offcanvas: a container plugin for Bootstrap's offcanvas, with its trigger.
|
|
12
|
+
While editing the panel is unfolded in place and its body is a region, as a
|
|
13
|
+
popup's is. `createContainer('offcanvas', { title, trigger, trigger_label,
|
|
14
|
+
placement, backdrop, scroll, keyboard, responsive, dark })`, the `offcanvas`
|
|
15
|
+
setting for the ones made new, and an *Offcanvas* section in its settings
|
|
16
|
+
panel. With `responsive` the panel's own trigger gets `d-<breakpoint>-none`.
|
|
17
|
+
The event `offcanvas-orphan`, for a trigger whose offcanvas is missing.
|
|
18
|
+
- A container plugin's definition can have `references`: the attributes of its
|
|
19
|
+
own that hold an id, which `freshNode` renames along with the id when a copy
|
|
20
|
+
is made.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- The core no longer names the popup: its ids are followed through the popup
|
|
24
|
+
plugin's `references`, and the trigger handling the popup and the offcanvas
|
|
25
|
+
share moved out of the core with it. Nothing changes in the markup, the
|
|
26
|
+
events or the behaviour of a popup.
|
|
27
|
+
|
|
28
|
+
## [9.0.0-beta.3] - 2026-10-20
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- history: a plugin for undo and redo. Ctrl+Z goes back a step and Ctrl+Y or
|
|
32
|
+
Ctrl+Shift+Z comes forward (⌘ on a Mac), and two buttons on the right of the
|
|
33
|
+
toolbar do the same. A step is the canvas `delay` ms after the last change,
|
|
34
|
+
and the node selected and the target are chosen again by where they were.
|
|
35
|
+
`history: { shortcuts, buttons, max, delay }`; `undo()`, `redo()`,
|
|
36
|
+
`canUndo()`, `canRedo()` and `clearHistory()`; the events `after-undo`,
|
|
37
|
+
`after-redo` and `history-change`.
|
|
38
|
+
- A feature plugin's `toolbar` item can have an `action` in place of `create`:
|
|
39
|
+
a button that does something instead of adding a block, and `disabled`.
|
|
40
|
+
- The plugin handle has `setSelected(node)` and `setActiveTarget(node)`.
|
|
41
|
+
|
|
8
42
|
## [9.0.0-beta.2] - 2026-10-20
|
|
9
43
|
|
|
10
44
|
### Added
|
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, 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 and cards, 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
|
|
@@ -27,7 +27,7 @@ from any web server, or from GitHub Pages, with no build step.
|
|
|
27
27
|
| [example/breakpoints.html](example/breakpoints.html) | The six breakpoints and the "all sizes" view | [live](https://themarioga.github.io/grid-editor/example/breakpoints.html) |
|
|
28
28
|
| [example/plugins.html](example/plugins.html) | The plugin model, with one written in the page itself | [live](https://themarioga.github.io/grid-editor/example/plugins.html) |
|
|
29
29
|
| [example/attributes.html](example/attributes.html) | A plugin of your own: a drawer tool, a modal, and its settings saved as an attribute | [live](https://themarioga.github.io/grid-editor/example/attributes.html) |
|
|
30
|
-
| [example/containers.html](example/containers.html) | Tabs, accordions, popups, carousels and cards, two levels deep | [live](https://themarioga.github.io/grid-editor/example/containers.html) |
|
|
30
|
+
| [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) |
|
|
31
31
|
| [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) |
|
|
32
32
|
| [example/autocols.html](example/autocols.html) | Equal and auto columns, columns per row, and sections | [live](https://themarioga.github.io/grid-editor/example/autocols.html) |
|
|
33
33
|
| [example/utilities.html](example/utilities.html) | Bootstrap's responsive utilities, edited per breakpoint | [live](https://themarioga.github.io/grid-editor/example/utilities.html) |
|
|
@@ -36,6 +36,7 @@ from any web server, or from GitHub Pages, with no build step.
|
|
|
36
36
|
| [example/summernote.html](example/summernote.html) | Summernote instead of tinyMCE | [live](https://themarioga.github.io/grid-editor/example/summernote.html) |
|
|
37
37
|
| [example/clipboard.html](example/clipboard.html) | Copy and paste, within an editor, between two, and between tabs | [live](https://themarioga.github.io/grid-editor/example/clipboard.html) |
|
|
38
38
|
| [example/wrap_content.html](example/wrap_content.html) | Non-bootstrap markup wrapped into the grid | [live](https://themarioga.github.io/grid-editor/example/wrap_content.html) |
|
|
39
|
+
| [example/history.html](example/history.html) | The history plugin: undo and redo, with the keyboard and the toolbar | [live](https://themarioga.github.io/grid-editor/example/history.html) |
|
|
39
40
|
| [example/autosave.html](example/autosave.html) | The autosave plugin: drafts kept as the user edits, offered back after a reload; import and export | [live](https://themarioga.github.io/grid-editor/example/autosave.html) |
|
|
40
41
|
| [example/adapter.html](example/adapter.html) | A page written for 6.x, with jQuery, running unchanged through the adapter | [live](https://themarioga.github.io/grid-editor/example/adapter.html) |
|
|
41
42
|
|
|
@@ -192,7 +193,7 @@ has, with the options it was made with, and warns once.
|
|
|
192
193
|
| `createSection` | `options?` | `Element` | A section, with the sections plugin. `options`: `width` (`'fixed'`, `'fluid'` or a breakpoint), `rows` (layouts), and a placement |
|
|
193
194
|
| `createElement` | `content`, `options?` | `Element` | Host markup wrapped as an element. `options`: `type`, `label` |
|
|
194
195
|
| `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 |
|
|
195
|
-
| `createContainer` | `type`, `options?` | `Element` | `'tabs'`, `'accordion'`, `'popup'`, `'carousel'` or `'card'` |
|
|
196
|
+
| `createContainer` | `type`, `options?` | `Element` | `'tabs'`, `'accordion'`, `'popup'`, `'offcanvas'`, `'carousel'` or `'card'` |
|
|
196
197
|
| `addTab` | `container`, `options?` | `Element` | Appends a tab, returns its pane |
|
|
197
198
|
| `addAccordionItem` | `container`, `options?` | `Element` | Appends an item, returns its body |
|
|
198
199
|
| `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 |
|
|
@@ -792,7 +793,7 @@ row and delete. The toolbar gets a *Section* button. Rows drag in and out of
|
|
|
792
793
|
sections, and sections drag along the canvas but not into a column. In a
|
|
793
794
|
breakpoint view each section is as wide as its container would be at that
|
|
794
795
|
breakpoint. They are called sections, not containers, because a container is
|
|
795
|
-
what the tabs, accordion, popup and card plugins make.
|
|
796
|
+
what the tabs, accordion, popup, offcanvas and card plugins make.
|
|
796
797
|
|
|
797
798
|
```javascript
|
|
798
799
|
ge.createSection({ width: 'md', rows: [[6, 6]], appendTo: '#myGrid' });
|
|
@@ -817,7 +818,7 @@ nowhere else:
|
|
|
817
818
|
| a row | a column, a section, or the canvas from the toolbar's paste button |
|
|
818
819
|
| a column | a row |
|
|
819
820
|
| a section | the canvas, from the toolbar's paste button |
|
|
820
|
-
| a container (tabs, accordion, popup, card) | a column |
|
|
821
|
+
| a container (tabs, accordion, popup, offcanvas, card) | a column |
|
|
821
822
|
| a text | a column |
|
|
822
823
|
| an element | a column |
|
|
823
824
|
|
|
@@ -837,7 +838,7 @@ The copy is what `getHtml` would give for that node. When it is pasted, any id
|
|
|
837
838
|
it carries that the page already has is renamed - `ge-tab-…` ids get new
|
|
838
839
|
generated ones, the host's own get a suffix, `hero` becoming `hero-2` - and
|
|
839
840
|
whatever inside the copy pointed at the old id (`data-bs-target`,
|
|
840
|
-
`data-bs-parent`, `href="#…"`, `aria-*`, a popup's trigger) points at the new
|
|
841
|
+
`data-bs-parent`, `href="#…"`, `aria-*`, a popup's or an offcanvas's trigger) points at the new
|
|
841
842
|
one. So the tabs of a copy open the copy's panes, not the original's.
|
|
842
843
|
|
|
843
844
|
A paste is an add like any other: `before-add-*` and `after-add-*` with
|
|
@@ -928,10 +929,61 @@ version of grid-editor reads it*, so one saved before an upgrade that changes
|
|
|
928
929
|
what `getHtml` gives is not offered after it. Drafts are a safety net, not a
|
|
929
930
|
place to keep work.
|
|
930
931
|
|
|
932
|
+
### Undo and redo
|
|
933
|
+
|
|
934
|
+
A plugin:
|
|
935
|
+
|
|
936
|
+
```html
|
|
937
|
+
<script src="grid-editor/dist/plugins/grideditor.history.min.js"></script>
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
What is edited is kept, step by step, in memory. <kbd>Ctrl</kbd>+<kbd>Z</kbd>
|
|
941
|
+
(<kbd>⌘</kbd>+<kbd>Z</kbd> on a Mac) goes back one step, and
|
|
942
|
+
<kbd>Ctrl</kbd>+<kbd>Y</kbd> or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Z</kbd>
|
|
943
|
+
comes forward again; two buttons on the right of the toolbar do the same. A
|
|
944
|
+
step is what the canvas is `delay` milliseconds after the last change, so a
|
|
945
|
+
drag, a resize or a burst of typing is one. A change made after going back ends
|
|
946
|
+
what could be redone. The steps go with the page: they are not kept in the
|
|
947
|
+
storage, and a draft restored by the autosave plugin is one more step.
|
|
948
|
+
|
|
949
|
+
```javascript
|
|
950
|
+
new GridEditor('#myGrid', {
|
|
951
|
+
history: {
|
|
952
|
+
shortcuts: true, // the keys; false leaves them to the browser
|
|
953
|
+
buttons: true, // the toolbar's buttons
|
|
954
|
+
max: 50, // the steps that can be undone
|
|
955
|
+
delay: 500, // milliseconds after the last change that make a step
|
|
956
|
+
},
|
|
957
|
+
});
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
The keys stay the browser's, or the text editor's, while a field or a text is
|
|
961
|
+
edited, while a panel or a dialog is open, and while the canvas is in preview or
|
|
962
|
+
showing its source; what was typed becomes a step when it is done. They go to
|
|
963
|
+
the editor used last. Going to a step makes the canvas again, so an open text
|
|
964
|
+
closes, and the node selected in the sidebar and the target are chosen again by
|
|
965
|
+
where they were: nothing is selected if there is no node there any more.
|
|
966
|
+
|
|
967
|
+
| Method | Returns | What it does |
|
|
968
|
+
| --- | --- | --- |
|
|
969
|
+
| `undo()` | `Boolean` | Goes back a step; `false` when there is none, or the canvas is not being edited or a drag is going on |
|
|
970
|
+
| `redo()` | `Boolean` | Comes forward a step |
|
|
971
|
+
| `canUndo()` | `Boolean` | Whether there is a step to go back to. A change not yet a step counts |
|
|
972
|
+
| `canRedo()` | `Boolean` | Whether there is one to come forward to |
|
|
973
|
+
| `clearHistory()` | `Boolean` | What there is now is the first step, with nothing before it or after it: for a page that loads another document |
|
|
974
|
+
|
|
975
|
+
The methods are there only when the plugin is loaded.
|
|
976
|
+
|
|
977
|
+
| Event | Payload | Fires |
|
|
978
|
+
| --- | --- | --- |
|
|
979
|
+
| `grideditor:after-undo` | `canvas`, `html`, `source` (`shortcut`, `tool` or `api`) | after the canvas went back a step |
|
|
980
|
+
| `grideditor:after-redo` | `canvas`, `html`, `source` | after it came forward |
|
|
981
|
+
| `grideditor:history-change` | `canvas`, `canUndo`, `canRedo` | when either changed: for a page with buttons of its own, which `buttons: false` leaves to it |
|
|
982
|
+
|
|
931
983
|
### Containers
|
|
932
984
|
|
|
933
|
-
Tabs, accordions, popups, carousels and cards. A tabs, accordion
|
|
934
|
-
carousel container holds panes; a card
|
|
985
|
+
Tabs, accordions, popups, offcanvases, carousels and cards. A tabs, accordion or
|
|
986
|
+
carousel container holds panes; a popup, an offcanvas and a card hold one region. Either way a region is an ordinary one: rows,
|
|
935
987
|
columns, content areas and elements nest inside it exactly as they do at the
|
|
936
988
|
top level.
|
|
937
989
|
|
|
@@ -943,6 +995,7 @@ it available:
|
|
|
943
995
|
<script src="grid-editor/dist/plugins/grideditor.tabs.min.js"></script>
|
|
944
996
|
<script src="grid-editor/dist/plugins/grideditor.accordion.min.js"></script>
|
|
945
997
|
<script src="grid-editor/dist/plugins/grideditor.popup.min.js"></script>
|
|
998
|
+
<script src="grid-editor/dist/plugins/grideditor.offcanvas.min.js"></script>
|
|
946
999
|
<script src="grid-editor/dist/plugins/grideditor.carousel.min.js"></script>
|
|
947
1000
|
<script src="grid-editor/dist/plugins/grideditor.card.min.js"></script>
|
|
948
1001
|
```
|
|
@@ -971,6 +1024,13 @@ ge.createContainer('carousel', { slides: 3, controls: false }); // an option g
|
|
|
971
1024
|
ge.addPane(carousel, { interval: 8000 }); // a slide that stays for 8 seconds
|
|
972
1025
|
```
|
|
973
1026
|
|
|
1027
|
+
__`offcanvas`:__ The options of the offcanvases made new, from the toolbar or with `createContainer`, as Bootstrap has them: `placement` (`'start'`, `'end'`, `'top'` or `'bottom'`; `'start'`), `backdrop` (`true`, `false` or `'static'`; `true`), `scroll` (the page scrolls behind it; `false`), `keyboard` (Esc closes it; `true`), `responsive` (`null`, or the breakpoint - `'sm'` to `'xxl'` - from which it is content in the page and not a panel) and `dark` (`data-bs-theme="dark"`). A value a key does not take is warned about and its default used. Every offcanvas also has an *Offcanvas* section in its settings panel, which changes its own. It is all Bootstrap's classes and attributes, so a page's markup says it too.
|
|
1028
|
+
|
|
1029
|
+
```javascript
|
|
1030
|
+
new GridEditor('#myGrid', { offcanvas: { placement: 'end', backdrop: 'static' } });
|
|
1031
|
+
ge.createContainer('offcanvas', { title: 'Menu', trigger_label: 'Menu', responsive: 'lg' }); // an option given wins
|
|
1032
|
+
```
|
|
1033
|
+
|
|
974
1034
|
__`container_tools`, `tab_tools`, `accordion_tools`, `carousel_tools`:__ Extra tools on the container drawer and on each pane's drawer, same shape as `row_tools`.
|
|
975
1035
|
|
|
976
1036
|
```javascript
|
|
@@ -983,6 +1043,7 @@ ge.addTab(tabs, { label: 'Third', activate: true });
|
|
|
983
1043
|
|
|
984
1044
|
ge.createContainer('accordion', { items: 3, stay_open: true });
|
|
985
1045
|
ge.createContainer('popup', { title: 'Terms', trigger_label: 'Read them', size: 'lg' });
|
|
1046
|
+
ge.createContainer('offcanvas', { title: 'Filters', placement: 'end', trigger: false });
|
|
986
1047
|
```
|
|
987
1048
|
|
|
988
1049
|
An accordion opens and closes from its headers while editing, and what you
|
|
@@ -997,6 +1058,13 @@ the trigger. Any node in the canvas carrying
|
|
|
997
1058
|
`data-ge-popup-target="<popup id>"` is a trigger too — grid-editor leaves your
|
|
998
1059
|
markup alone and writes Bootstrap's attributes onto it in the output.
|
|
999
1060
|
|
|
1061
|
+
An offcanvas is the same with Bootstrap's offcanvas in place of its modal: it is
|
|
1062
|
+
rendered unfolded in place while editing, its body is a region, and the trigger
|
|
1063
|
+
is the button it makes, or any node carrying
|
|
1064
|
+
`data-ge-offcanvas-target="<offcanvas id>"`. With `responsive` the panel is
|
|
1065
|
+
content in the page from that breakpoint up, so its own trigger gets
|
|
1066
|
+
`d-<breakpoint>-none`; a trigger of yours elsewhere is not touched.
|
|
1067
|
+
|
|
1000
1068
|
A carousel shows one slide at a time while editing, as it does on the page.
|
|
1001
1069
|
The container's drawer has the arrows and says which slide it is on, and
|
|
1002
1070
|
Bootstrap's own arrows are kept in the markup but not drawn, so they never sit
|