@themarioga/grid-editor 9.0.0-beta.2 → 9.0.0-beta.3
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 +14 -0
- package/README.md +52 -0
- package/dist/grideditor.bundle.min.js +2 -2
- package/dist/grideditor.d.ts +38 -0
- package/dist/grideditor.esm.js +33 -2
- package/dist/grideditor.js +33 -2
- package/dist/grideditor.min.js +1 -1
- package/dist/grideditor.min.js.map +3 -3
- package/dist/locales/grideditor.es.esm.js +2 -0
- package/dist/locales/grideditor.es.js +2 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- 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/docs/events.md +3 -0
- package/docs/locale-keys.md +11 -0
- package/docs/plugins.md +8 -1
- package/example/clipboard.html +22 -0
- package/example/history.html +94 -0
- package/example/index.html +8 -0
- package/package.json +1 -1
- package/src/js/grideditor.js +30 -1
- package/src/js/locales/grideditor.es.js +2 -0
- package/src/js/plugins/grideditor.history.js +367 -0
- package/types/grideditor.d.ts +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,20 @@ 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.3] - 2026-10-20
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- history: a plugin for undo and redo. Ctrl+Z goes back a step and Ctrl+Y or
|
|
12
|
+
Ctrl+Shift+Z comes forward (⌘ on a Mac), and two buttons on the right of the
|
|
13
|
+
toolbar do the same. A step is the canvas `delay` ms after the last change,
|
|
14
|
+
and the node selected and the target are chosen again by where they were.
|
|
15
|
+
`history: { shortcuts, buttons, max, delay }`; `undo()`, `redo()`,
|
|
16
|
+
`canUndo()`, `canRedo()` and `clearHistory()`; the events `after-undo`,
|
|
17
|
+
`after-redo` and `history-change`.
|
|
18
|
+
- A feature plugin's `toolbar` item can have an `action` in place of `create`:
|
|
19
|
+
a button that does something instead of adding a block, and `disabled`.
|
|
20
|
+
- The plugin handle has `setSelected(node)` and `setActiveTarget(node)`.
|
|
21
|
+
|
|
8
22
|
## [9.0.0-beta.2] - 2026-10-20
|
|
9
23
|
|
|
10
24
|
### Added
|
package/README.md
CHANGED
|
@@ -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
|
|
|
@@ -928,6 +929,57 @@ 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
985
|
Tabs, accordions, popups, carousels and cards. A tabs, accordion, popup or
|