@themarioga/grid-editor 9.0.0-beta.1 → 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 CHANGED
@@ -5,6 +5,34 @@ 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
+
22
+ ## [9.0.0-beta.2] - 2026-10-20
23
+
24
+ ### Added
25
+ - clipboard: Ctrl+C and Ctrl+V (⌘C and ⌘V) with `active_target`, and so with
26
+ the sidebar. Ctrl+C copies the node selected or the target; Ctrl+V pastes
27
+ into the target, or the node selected, by the paste rules the toolbar and
28
+ the tools already have. The keys stay the browser's while a field or a
29
+ text is edited, while text is selected, or while a panel or a dialog is
30
+ open. They use the plugin's own store, never the system clipboard, and go
31
+ to the editor used last. `clipboard: { shortcuts: false }` turns them off;
32
+ `after-copy` says `source: 'shortcut'` for them.
33
+ - The plugin handle has `getSelected()`, `getActiveTarget()`, `panelOpen()`
34
+ and `contains(node)`.
35
+
8
36
  ## [9.0.0-beta.1] - 2026-10-20
9
37
 
10
38
  ### Changed
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
 
@@ -844,6 +845,24 @@ A paste is an add like any other: `before-add-*` and `after-add-*` with
844
845
  `source: 'paste'`, and canceling the first turns it away. A copy fires
845
846
  `grideditor:after-copy`.
846
847
 
848
+ With `active_target` - which `settings_panel: 'sidebar'` turns on - there are
849
+ shortcuts too, Ctrl+C and Ctrl+V (⌘C and ⌘V on a Mac). Ctrl+C copies the node
850
+ selected in the sidebar or, with none, the target, as its *Copy* tool would.
851
+ Ctrl+V pastes into the target as the toolbar's paste button would - a row at
852
+ its end, a section after the block it is in - and a text, a container or an
853
+ element at the end of a target column, as its *Paste* tool would; with no
854
+ target, into the node selected, as its *Paste* tool would. What does not fit
855
+ there is not pasted anywhere else. They go to the editor used last, and leave
856
+ the keys to the browser while a field or a text is being edited, while text
857
+ is selected (for Ctrl+C), while a settings panel, a dialog or the delete
858
+ confirmation is open, and outside editing. They use the same store as the
859
+ tools: the system clipboard is not read or written. `after-copy` says
860
+ `source: 'shortcut'` for a copy made with them.
861
+
862
+ __`clipboard`:__ `{ shortcuts }`, the plugin's settings. `shortcuts` defaults to
863
+ `active_target`; `false` turns them off, and `true` without `active_target`
864
+ warns and does nothing.
865
+
847
866
  ### Autosave
848
867
 
849
868
  A plugin:
@@ -910,6 +929,57 @@ version of grid-editor reads it*, so one saved before an upgrade that changes
910
929
  what `getHtml` gives is not offered after it. Drafts are a safety net, not a
911
930
  place to keep work.
912
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
+
913
983
  ### Containers
914
984
 
915
985
  Tabs, accordions, popups, carousels and cards. A tabs, accordion, popup or
package/UPGRADING.md CHANGED
@@ -7,6 +7,11 @@ Upgrading from grid-editor `8.x` to `9.0`
7
7
  setting to have the sidebar without it. Clicking the canvas's background, or
8
8
  pressing Escape, clears the target and the toolbar adds at the end of the
9
9
  canvas again, as before.
10
+ * __With the clipboard plugin and `active_target`, Ctrl+C and Ctrl+V copy
11
+ and paste nodes.__ They act on the node selected or the target, and leave
12
+ the keys alone while a field or a text has the focus or text is selected.
13
+ `clipboard: { shortcuts: false }` turns them off. This came in
14
+ `9.0.0-beta.2`.
10
15
  * __`settings_panel: 'sidebar'` with `active_target: false` throws.__ The
11
16
  constructor raises a `TypeError` and builds nothing. Leave `active_target`
12
17
  out, or give it `true`.