@themarioga/grid-editor 6.0.0-beta.5 → 7.0.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.
- package/AUTO_SAVE.md +2 -2
- package/BUILDING.md +45 -29
- package/CHANGELOG.md +54 -0
- package/README.md +140 -89
- package/UPGRADING.md +146 -2
- package/dist/grideditor.bundle.min.js +14 -0
- package/dist/grideditor.d.ts +335 -0
- package/dist/grideditor.esm.js +3977 -0
- package/dist/grideditor.jquery.js +253 -0
- package/dist/grideditor.jquery.min.js +1 -0
- package/dist/grideditor.jquery.min.js.map +7 -0
- package/dist/grideditor.js +3983 -0
- package/dist/grideditor.min.js +6 -0
- package/dist/grideditor.min.js.map +7 -0
- package/dist/locales/grideditor.es.esm.js +158 -0
- package/dist/locales/grideditor.es.js +164 -170
- package/dist/locales/grideditor.es.min.js +6 -2
- package/dist/locales/grideditor.es.min.js.map +7 -1
- package/dist/plugins/grideditor.accordion.esm.js +294 -0
- package/dist/plugins/grideditor.accordion.js +286 -180
- package/dist/plugins/grideditor.accordion.min.js +1 -2
- package/dist/plugins/grideditor.accordion.min.js.map +7 -1
- package/dist/plugins/grideditor.alignment.esm.js +55 -0
- package/dist/plugins/grideditor.alignment.js +58 -77
- package/dist/plugins/grideditor.alignment.min.js +1 -2
- package/dist/plugins/grideditor.alignment.min.js.map +7 -1
- package/dist/plugins/grideditor.card.esm.js +73 -0
- package/dist/plugins/grideditor.card.js +74 -64
- package/dist/plugins/grideditor.card.min.js +1 -2
- package/dist/plugins/grideditor.card.min.js.map +7 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
- package/dist/plugins/grideditor.ckeditor.js +482 -493
- package/dist/plugins/grideditor.ckeditor.min.js +1 -2
- package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
- package/dist/plugins/grideditor.clipboard.esm.js +326 -0
- package/dist/plugins/grideditor.clipboard.js +298 -235
- package/dist/plugins/grideditor.clipboard.min.js +1 -2
- package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
- package/dist/plugins/grideditor.codemirror-inline.js +188 -168
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror.esm.js +63 -0
- package/dist/plugins/grideditor.codemirror.js +60 -71
- package/dist/plugins/grideditor.codemirror.min.js +1 -2
- package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
- package/dist/plugins/grideditor.elements.esm.js +271 -0
- package/dist/plugins/grideditor.elements.js +256 -149
- package/dist/plugins/grideditor.elements.min.js +1 -2
- package/dist/plugins/grideditor.elements.min.js.map +7 -1
- package/dist/plugins/grideditor.float.esm.js +34 -0
- package/dist/plugins/grideditor.float.js +37 -52
- package/dist/plugins/grideditor.float.min.js +1 -2
- package/dist/plugins/grideditor.float.min.js.map +7 -1
- package/dist/plugins/grideditor.gutters.esm.js +143 -0
- package/dist/plugins/grideditor.gutters.js +134 -131
- package/dist/plugins/grideditor.gutters.min.js +1 -2
- package/dist/plugins/grideditor.gutters.min.js.map +7 -1
- package/dist/plugins/grideditor.order.esm.js +189 -0
- package/dist/plugins/grideditor.order.js +170 -182
- package/dist/plugins/grideditor.order.min.js +1 -2
- package/dist/plugins/grideditor.order.min.js.map +7 -1
- package/dist/plugins/grideditor.popup.esm.js +187 -0
- package/dist/plugins/grideditor.popup.js +183 -134
- package/dist/plugins/grideditor.popup.min.js +1 -2
- package/dist/plugins/grideditor.popup.min.js.map +7 -1
- package/dist/plugins/grideditor.sections.esm.js +271 -0
- package/dist/plugins/grideditor.sections.js +250 -173
- package/dist/plugins/grideditor.sections.min.js +1 -2
- package/dist/plugins/grideditor.sections.min.js.map +7 -1
- package/dist/plugins/grideditor.spacing.esm.js +318 -0
- package/dist/plugins/grideditor.spacing.js +296 -272
- package/dist/plugins/grideditor.spacing.min.js +1 -2
- package/dist/plugins/grideditor.spacing.min.js.map +7 -1
- package/dist/plugins/grideditor.summernote.esm.js +509 -0
- package/dist/plugins/grideditor.summernote.js +491 -471
- package/dist/plugins/grideditor.summernote.min.js +1 -2
- package/dist/plugins/grideditor.summernote.min.js.map +7 -1
- package/dist/plugins/grideditor.tabs.esm.js +237 -0
- package/dist/plugins/grideditor.tabs.js +233 -139
- package/dist/plugins/grideditor.tabs.min.js +1 -2
- package/dist/plugins/grideditor.tabs.min.js.map +7 -1
- package/dist/plugins/grideditor.textalign.esm.js +40 -0
- package/dist/plugins/grideditor.textalign.js +43 -56
- package/dist/plugins/grideditor.textalign.min.js +1 -2
- package/dist/plugins/grideditor.textalign.min.js.map +7 -1
- package/dist/plugins/grideditor.tinymce.esm.js +519 -0
- package/dist/plugins/grideditor.tinymce.js +500 -534
- package/dist/plugins/grideditor.tinymce.min.js +1 -2
- package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
- package/dist/plugins/grideditor.visibility.esm.js +158 -0
- package/dist/plugins/grideditor.visibility.js +140 -149
- package/dist/plugins/grideditor.visibility.min.js +1 -2
- package/dist/plugins/grideditor.visibility.min.js.map +7 -1
- package/docs/events.md +47 -21
- package/docs/locale-keys.md +7 -4
- package/docs/plugins.md +49 -27
- package/example/adapter.html +112 -0
- package/example/attributes.html +85 -61
- package/example/autocols.html +9 -9
- package/example/autosave.html +13 -14
- package/example/basic.html +4 -5
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +11 -10
- package/example/codemirror.html +9 -7
- package/example/containers.html +7 -8
- package/example/custom_editor.html +53 -34
- package/example/elements.html +10 -11
- package/example/index.html +16 -2
- package/example/locale.html +6 -7
- package/example/plugins.html +44 -29
- package/example/summernote.html +6 -5
- package/example/utilities.html +17 -13
- package/example/wrap_content.html +9 -9
- package/package.json +43 -12
- package/src/js/dom.js +401 -0
- package/src/js/grideditor.classic.js +16 -0
- package/src/js/grideditor.jquery.js +325 -0
- package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
- package/src/js/locales/grideditor.es.js +163 -158
- package/src/js/plugins/grideditor.accordion.js +97 -77
- package/src/js/plugins/grideditor.alignment.js +5 -7
- package/src/js/plugins/grideditor.card.js +23 -23
- package/src/js/plugins/grideditor.ckeditor.js +107 -106
- package/src/js/plugins/grideditor.clipboard.js +49 -37
- package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
- package/src/js/plugins/grideditor.codemirror.js +9 -10
- package/src/js/plugins/grideditor.elements.js +57 -33
- package/src/js/plugins/grideditor.float.js +4 -6
- package/src/js/plugins/grideditor.gutters.js +20 -15
- package/src/js/plugins/grideditor.order.js +28 -25
- package/src/js/plugins/grideditor.popup.js +63 -51
- package/src/js/plugins/grideditor.sections.js +39 -32
- package/src/js/plugins/grideditor.spacing.js +42 -45
- package/src/js/plugins/grideditor.summernote.js +112 -76
- package/src/js/plugins/grideditor.tabs.js +65 -57
- package/src/js/plugins/grideditor.textalign.js +4 -6
- package/src/js/plugins/grideditor.tinymce.js +147 -139
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +81 -106
- package/types/grideditor.d.ts +335 -0
- package/dist/jquery.grideditor.bundle.min.js +0 -10
- package/dist/jquery.grideditor.js +0 -4927
- package/dist/jquery.grideditor.min.js +0 -2
- package/dist/jquery.grideditor.min.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
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/),
|
|
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 — visibility, order, alignment, gutters, spacing, text alignment and float — are edited per breakpoint too. It also edits tabs, accordions, popups 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
|
|
8
8
|
`@themarioga/grid-editor`.
|
|
9
9
|
|
|
10
|
-
(Looking for the __bootstrap 3 support__? Use version 0 in the [bootstrap_3 branch](https://github.com/Friendly-Pixel/grid-editor/tree/bootstrap_3))
|
|
11
|
-
|
|
12
10
|
It provides integration plugins for the following rich text editors to edit column content: TinyMCE, summernote and CKEditor.
|
|
13
11
|
|
|
14
12
|

|
|
@@ -39,13 +37,14 @@ from any web server, or from GitHub Pages, with no build step.
|
|
|
39
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) |
|
|
40
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) |
|
|
41
39
|
| [example/autosave.html](example/autosave.html) | Saving the html as the user edits | [live](https://themarioga.github.io/grid-editor/example/autosave.html) |
|
|
40
|
+
| [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) |
|
|
42
41
|
|
|
43
42
|
Installation
|
|
44
43
|
------------
|
|
45
44
|
|
|
46
|
-
* __Dependencies:__ Grid Editor depends on
|
|
47
|
-
* If you want to use the tinyMCE integration, include tinyMCE 6 as well, and `dist/plugins/grideditor.tinymce.min.js` after the editor.
|
|
48
|
-
* If you want to use the summernote integration, include summernote and `dist/plugins/grideditor.summernote.min.js`.
|
|
45
|
+
* __Dependencies:__ Grid Editor depends on [SortableJS](https://sortablejs.github.io/Sortable/), Bootstrap Icons, and Bootstrap 5, so make sure you have included those in the page. It does not need jQuery since 7.0.
|
|
46
|
+
* If you want to use the tinyMCE integration, include tinyMCE 6 as well, and `dist/plugins/grideditor.tinymce.min.js` after the editor.
|
|
47
|
+
* If you want to use the summernote integration, include summernote and `dist/plugins/grideditor.summernote.min.js`. Summernote needs jQuery itself, so that page loads jQuery too; nothing else does.
|
|
49
48
|
* If you want to use the CKEditor integration... you get the point: CKEditor and `dist/plugins/grideditor.ckeditor.min.js`.
|
|
50
49
|
* Up to 5.x the main bundle carried a copy of the three; since 6.0 the plugin of the editor you use has to be loaded, as above. See [UPGRADING.md](UPGRADING.md).
|
|
51
50
|
* From npm:
|
|
@@ -57,10 +56,10 @@ npm install @themarioga/grid-editor
|
|
|
57
56
|
* Or [download the latest version of Grid Editor](https://github.com/themarioga/grid-editor/archive/master.zip) and include it in your page:
|
|
58
57
|
|
|
59
58
|
```html
|
|
60
|
-
<!-- Make sure
|
|
59
|
+
<!-- Make sure SortableJS, bootstrap icons, and bootstrap 5 are included. TinyMCE is optional. -->
|
|
61
60
|
<link rel="stylesheet" type="text/css" href="grid-editor/dist/grideditor.min.css" />
|
|
62
61
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
63
|
-
<script src="grid-editor/dist/
|
|
62
|
+
<script src="grid-editor/dist/grideditor.min.js"></script>
|
|
64
63
|
<!-- The text editor you use, as a plugin -->
|
|
65
64
|
<script src="grid-editor/dist/plugins/grideditor.tinymce.min.js"></script>
|
|
66
65
|
```
|
|
@@ -70,20 +69,64 @@ inside it — one or the other, never both:
|
|
|
70
69
|
|
|
71
70
|
```html
|
|
72
71
|
<link rel="stylesheet" type="text/css" href="grid-editor/dist/grideditor.min.css" />
|
|
73
|
-
<script src="grid-editor/dist/
|
|
72
|
+
<script src="grid-editor/dist/grideditor.bundle.min.js"></script>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### As an ES module
|
|
76
|
+
|
|
77
|
+
An app built with a bundler - Angular, React, Vue, Vite - imports the editor
|
|
78
|
+
and the plugins it wants. A plugin registers as it is imported:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import GridEditor from '@themarioga/grid-editor';
|
|
82
|
+
import '@themarioga/grid-editor/plugins/tabs';
|
|
83
|
+
import '@themarioga/grid-editor/plugins/tinymce';
|
|
84
|
+
import '@themarioga/grid-editor/locales/es';
|
|
85
|
+
import '@themarioga/grid-editor/css';
|
|
86
|
+
import Sortable from 'sortablejs';
|
|
87
|
+
import * as bootstrap from 'bootstrap';
|
|
88
|
+
|
|
89
|
+
// What a module app has as imports, not as window.Sortable and window.bootstrap
|
|
90
|
+
GridEditor.Sortable = Sortable;
|
|
91
|
+
GridEditor.bootstrap = bootstrap;
|
|
92
|
+
|
|
93
|
+
const ge = new GridEditor(element, { content_types: ['tinymce'] });
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The module build imports nothing itself. Without `GridEditor.Sortable` or a
|
|
97
|
+
`window.Sortable`, dragging is off; without Bootstrap's javascript, a delete is
|
|
98
|
+
confirmed with the browser's `confirm()` and the modal settings panel opens
|
|
99
|
+
with a backdrop of the editor's own. Types for the public API come with the
|
|
100
|
+
package (`dist/grideditor.d.ts`).
|
|
101
|
+
|
|
102
|
+
Load the classic script *or* the module build on a page, never both.
|
|
103
|
+
|
|
104
|
+
### A page written for 6.x
|
|
105
|
+
|
|
106
|
+
A page that uses the jQuery API of 6.x - `$(el).gridEditor(...)`, jQuery
|
|
107
|
+
events, jQuery objects in the payloads - keeps it by loading jQuery 4 and the
|
|
108
|
+
adapter after the editor, and the 7.x plugins after that:
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
112
|
+
<script src="grid-editor/dist/grideditor.min.js"></script>
|
|
113
|
+
<script src="grid-editor/dist/grideditor.jquery.min.js"></script>
|
|
114
|
+
<script src="grid-editor/dist/plugins/grideditor.tabs.min.js"></script>
|
|
74
115
|
```
|
|
75
116
|
|
|
117
|
+
Plugins written for 6.x are not kept working: see [UPGRADING.md](UPGRADING.md).
|
|
118
|
+
|
|
76
119
|
Usage
|
|
77
120
|
-----
|
|
78
121
|
```javascript
|
|
79
|
-
|
|
122
|
+
var ge = new GridEditor('#myGrid', {
|
|
80
123
|
new_row_layouts: [[12], [6,6], [9,3]],
|
|
81
124
|
});
|
|
82
125
|
// Call this to get the result after the user has done some editing:
|
|
83
|
-
var html =
|
|
126
|
+
var html = ge.getHtml();
|
|
84
127
|
|
|
85
128
|
// Or, for a page that only publishes the result and never edits it again:
|
|
86
|
-
var published =
|
|
129
|
+
var published = ge.getPlainHtml();
|
|
87
130
|
```
|
|
88
131
|
|
|
89
132
|
`getHtml` keeps a little of the editor's own marking: the `column` class, the
|
|
@@ -104,9 +147,17 @@ Methods
|
|
|
104
147
|
-------
|
|
105
148
|
|
|
106
149
|
```javascript
|
|
107
|
-
|
|
150
|
+
var ge = new GridEditor('#myGrid', options); // or GridEditor.create('#myGrid', options)
|
|
151
|
+
ge.method(argument);
|
|
152
|
+
|
|
153
|
+
GridEditor.get('#myGrid'); // the editor on an element, or null
|
|
108
154
|
```
|
|
109
155
|
|
|
156
|
+
The element is an element or a selector, which takes the first element it
|
|
157
|
+
matches; one that matches nothing throws a `TypeError`. An element has one
|
|
158
|
+
editor at most: asked for a second, `new GridEditor` hands back the one it
|
|
159
|
+
has, with the options it was made with, and warns once.
|
|
160
|
+
|
|
110
161
|
| Method | Arguments | Returns | What it does |
|
|
111
162
|
| --- | --- | --- | --- |
|
|
112
163
|
| `getHtml` | — | `String` | The clean html: no drawers, no editor classes, no inline styles |
|
|
@@ -115,62 +166,64 @@ $('#myGrid').gridEditor('method', argument);
|
|
|
115
166
|
| `deinit` | — | `this` | Strip the editing furniture, leave the markup |
|
|
116
167
|
| `reset` | — | `this` | `deinit()` then `init()` |
|
|
117
168
|
| `destroy` | — | `this` | Deinit, drop the controls, unbind, forget the instance |
|
|
118
|
-
| `remove` | — | `this` | Deprecated alias of `destroy` |
|
|
119
169
|
| `changeView` | `breakpoint` | `this` | `'xs'`…`'xxl'`, or `'all'` to edit every breakpoint at once, with one class |
|
|
120
170
|
| `getView` | — | `String` | The view the editor is in |
|
|
121
171
|
| `setLocale` | `code` | `this` | Switch language and re-render the controls |
|
|
122
|
-
| `createRow` | `layout?`, `options?` | `
|
|
123
|
-
| `createColumn` | `size`, `options?` | `
|
|
124
|
-
| `createSection` | `options?` | `
|
|
125
|
-
| `createElement` | `content`, `options?` | `
|
|
126
|
-
| `createText` | `type?`, `options?` | `
|
|
127
|
-
| `createContainer` | `type`, `options?` | `
|
|
128
|
-
| `addTab` | `container`, `options?` | `
|
|
129
|
-
| `addAccordionItem` | `container`, `options?` | `
|
|
172
|
+
| `createRow` | `layout?`, `options?` | `Element` | A row, optionally with columns: `createRow([8, 4])`, `createRow(['auto', 'equal'])`, `createRow({ row_cols: { xs: 1, md: 3 }, columns: 6 })` |
|
|
173
|
+
| `createColumn` | `size`, `options?` | `Element` | An empty column: units, `'equal'` or `'auto'`; no size into a row with row-cols takes the row's share. `options`: `offset`, `content` - a text of the first editor offered, or plain content with none |
|
|
174
|
+
| `createSection` | `options?` | `Element` | A section, with the sections plugin. `options`: `width` (`'fixed'`, `'fluid'` or a breakpoint), `rows` (layouts), and a placement |
|
|
175
|
+
| `createElement` | `content`, `options?` | `Element` | Host markup wrapped as an element. `options`: `type`, `label` |
|
|
176
|
+
| `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 |
|
|
177
|
+
| `createContainer` | `type`, `options?` | `Element` | `'tabs'`, `'accordion'` or `'popup'` |
|
|
178
|
+
| `addTab` | `container`, `options?` | `Element` | Appends a tab, returns its pane |
|
|
179
|
+
| `addAccordionItem` | `container`, `options?` | `Element` | Appends an item, returns its body |
|
|
130
180
|
| `getUtility` | `node`, `family`, `view?` | `String` | A utility plugin's value on a node in a view (the current one by default), or `null` |
|
|
131
181
|
| `setUtility` | `node`, `family`, `value`, `view?` | `Boolean` | Write it through the events; `null` is inherit. `false` if canceled or nothing changed |
|
|
132
182
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
`getPlainHtml` cleans it.
|
|
183
|
+
The methods that do something hand back the editor, so they chain. After
|
|
184
|
+
`destroy()` every method is a no-op that says so once, but for `getHtml` and
|
|
185
|
+
`getPlainHtml`, which read the element as it is.
|
|
137
186
|
|
|
138
|
-
The `create*` methods hand back the
|
|
139
|
-
|
|
140
|
-
|
|
187
|
+
The `create*` methods hand back the element they made, or `null` when a handler
|
|
188
|
+
canceled the add. It comes back **detached**: place it and call `reset()`, or
|
|
189
|
+
pass a parent - an element or a selector - and let grid-editor do both.
|
|
141
190
|
|
|
142
191
|
```javascript
|
|
143
192
|
// place it yourself
|
|
144
|
-
var row =
|
|
145
|
-
|
|
146
|
-
|
|
193
|
+
var row = ge.createRow([8, 4]);
|
|
194
|
+
document.querySelector('#myGrid').appendChild(row);
|
|
195
|
+
ge.reset();
|
|
147
196
|
|
|
148
197
|
// or say where it goes: appendTo, prependTo, insertAfter, insertBefore
|
|
149
|
-
|
|
198
|
+
ge.createRow([8, 4], { appendTo: '#myGrid' });
|
|
150
199
|
```
|
|
151
200
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
read-only copy of the settings:
|
|
201
|
+
Besides the methods, the editor has its canvas and a read-only copy of the
|
|
202
|
+
settings:
|
|
155
203
|
|
|
156
204
|
```javascript
|
|
157
|
-
var ge = $('#myGrid').data('grideditor');
|
|
158
205
|
ge.createRow([12], { appendTo: ge.canvas });
|
|
159
|
-
ge.
|
|
206
|
+
ge.settings.locale; // 'en'
|
|
160
207
|
```
|
|
161
208
|
|
|
209
|
+
A html string written into the canvas - through the source view,
|
|
210
|
+
`source_textarea`, `createElement` or a paste - is parsed as `innerHTML`
|
|
211
|
+
parses: a `<script>` in it is kept in the markup and does not run in the
|
|
212
|
+
editor. Up to 6.x it did.
|
|
213
|
+
|
|
162
214
|
Events
|
|
163
215
|
------
|
|
164
216
|
|
|
165
|
-
Every operation is announced before and after it happens, as a
|
|
166
|
-
the canvas
|
|
217
|
+
Every operation is announced before and after it happens, as a DOM event on
|
|
218
|
+
the canvas - a `CustomEvent` with the payload as its `detail` - and as a
|
|
219
|
+
callback. A `before-*` can be canceled.
|
|
167
220
|
|
|
168
221
|
```javascript
|
|
169
|
-
|
|
170
|
-
if (
|
|
222
|
+
ge.canvas.addEventListener('grideditor:before-delete', function(e) {
|
|
223
|
+
if (e.detail.node.classList.contains('locked')) { e.preventDefault(); }
|
|
171
224
|
});
|
|
172
225
|
|
|
173
|
-
|
|
226
|
+
new GridEditor('#myGrid', {
|
|
174
227
|
callbacks: {
|
|
175
228
|
after_move: function(payload) { console.log(payload.from, payload.to); },
|
|
176
229
|
},
|
|
@@ -183,7 +236,7 @@ The full catalogue, the payload and what canceling each operation does is in
|
|
|
183
236
|
Languages
|
|
184
237
|
---------
|
|
185
238
|
|
|
186
|
-
The interface ships in English and Spanish. English is built into the
|
|
239
|
+
The interface ships in English and Spanish. English is built into the editor;
|
|
187
240
|
every other language is a file you load after it.
|
|
188
241
|
|
|
189
242
|
| Code | Language | File |
|
|
@@ -192,9 +245,9 @@ every other language is a file you load after it.
|
|
|
192
245
|
| `es` | Spanish | `dist/locales/grideditor.es.js` |
|
|
193
246
|
|
|
194
247
|
```html
|
|
195
|
-
<script src="grid-editor/dist/
|
|
248
|
+
<script src="grid-editor/dist/grideditor.min.js"></script>
|
|
196
249
|
<script src="grid-editor/dist/locales/grideditor.es.js"></script>
|
|
197
|
-
<script
|
|
250
|
+
<script>new GridEditor('#myGrid', { locale: 'es' });</script>
|
|
198
251
|
```
|
|
199
252
|
|
|
200
253
|
Override single strings without a locale file with `locale_strings`, and switch
|
|
@@ -214,7 +267,7 @@ Options
|
|
|
214
267
|
__`new_row_layouts`:__ Set the column layouts that appear in the "new row" buttons at the top of the editor. A size is a number of units, `'equal'` (Bootstrap's `col`, sharing what the row has left) or `'auto'` (`col-auto`, as wide as its content).
|
|
215
268
|
|
|
216
269
|
```javascript
|
|
217
|
-
|
|
270
|
+
new GridEditor('#myGrid', {
|
|
218
271
|
new_row_layouts: [[12], [6,6], [9,3], ['auto', 'equal'], { row_cols: { xs: 1, md: 3 }, columns: 6 }],
|
|
219
272
|
});
|
|
220
273
|
```
|
|
@@ -260,7 +313,7 @@ buttons beside the two fields. Empty by default; the classes field covers the
|
|
|
260
313
|
general case, and this is for the handful a host wants one click away.
|
|
261
314
|
|
|
262
315
|
```javascript
|
|
263
|
-
|
|
316
|
+
new GridEditor('#myGrid', {
|
|
264
317
|
row_classes: [{ label: 'Dark', cssClass: 'my-app-dark' }],
|
|
265
318
|
});
|
|
266
319
|
```
|
|
@@ -270,7 +323,7 @@ __`col_classes`:__ The same as `row_classes`, but for columns. `container_classe
|
|
|
270
323
|
__`row_tools`:__ Add extra tool buttons to the row toolbar.
|
|
271
324
|
|
|
272
325
|
```javascript
|
|
273
|
-
|
|
326
|
+
new GridEditor('#myGrid', {
|
|
274
327
|
row_tools: [{
|
|
275
328
|
title: 'Set background image',
|
|
276
329
|
iconClass: 'glyphicon-picture',
|
|
@@ -288,7 +341,7 @@ __`col_tools`:__ The same as row_tools, but for columns.
|
|
|
288
341
|
__`drag_handle`:__ What a drag starts from. `'tool'`, the default, gives every drawer a move tool and only that tool drags. `'drawer'` makes the whole drawer the handle and drops the move tool, since it would then only say "drag from here". The tools inside a draggable drawer still answer to a click, and dragging from one starts no move.
|
|
289
342
|
|
|
290
343
|
```javascript
|
|
291
|
-
|
|
344
|
+
new GridEditor('#myGrid', {
|
|
292
345
|
drag_handle: 'drawer',
|
|
293
346
|
});
|
|
294
347
|
```
|
|
@@ -296,7 +349,7 @@ $('#myGrid').gridEditor({
|
|
|
296
349
|
__`toolbar_drag`:__ Whether the toolbar's buttons are a palette: drag one onto the canvas and the row or container it stands for is created where you drop it, with a line showing where that is. `'auto'`, the default, turns it on when `drag_handle` is `'drawer'`, since that is the same idea applied to the toolbar; `true` and `false` decide it outright. Clicking a button still adds at the end either way.
|
|
297
350
|
|
|
298
351
|
```javascript
|
|
299
|
-
|
|
352
|
+
new GridEditor('#myGrid', {
|
|
300
353
|
drag_handle: 'drawer',
|
|
301
354
|
toolbar_drag: 'auto',
|
|
302
355
|
});
|
|
@@ -306,7 +359,7 @@ __`custom_filter`:__ Allows the execution of a custom function before initializa
|
|
|
306
359
|
Gives the `canvas` element and `isInit` (true/false) as parameter.
|
|
307
360
|
|
|
308
361
|
```javascript
|
|
309
|
-
|
|
362
|
+
new GridEditor('#myGrid', {
|
|
310
363
|
'custom_filter': 'functionname',
|
|
311
364
|
});
|
|
312
365
|
|
|
@@ -322,7 +375,7 @@ function functionname(canvas, isInit) {
|
|
|
322
375
|
or
|
|
323
376
|
|
|
324
377
|
```javascript
|
|
325
|
-
|
|
378
|
+
new GridEditor('#myGrid', {
|
|
326
379
|
'custom_filter': function(canvas, isInit) {
|
|
327
380
|
//...
|
|
328
381
|
},
|
|
@@ -332,7 +385,7 @@ $('#myGrid').gridEditor({
|
|
|
332
385
|
__`valid_col_sizes`:__ The column sizes the +/- buttons step through, and that the add column picker and the width field offer. Default `[1, 2, … 12, 'equal', 'auto']`; leave `'equal'` and `'auto'` out and they are not offered, though a column that has one still shows it.
|
|
333
386
|
|
|
334
387
|
```javascript
|
|
335
|
-
|
|
388
|
+
new GridEditor('#myGrid', {
|
|
336
389
|
'valid_col_sizes': [2, 5, 8, 10],
|
|
337
390
|
});
|
|
338
391
|
```
|
|
@@ -342,7 +395,7 @@ __`valid_col_offsets`:__ The same, for the indent buttons. Default `[0, 1, … 1
|
|
|
342
395
|
__`add_column`:__ What the add column tool in a row's drawer does. A click adds a column of `size`; holding the tool for `delay` milliseconds — with the pointer or with a finger — offers the widths in `valid_col_sizes` instead, marking the ones that no longer fit the row. Defaults:
|
|
343
396
|
|
|
344
397
|
```javascript
|
|
345
|
-
|
|
398
|
+
new GridEditor('#myGrid', {
|
|
346
399
|
add_column: {
|
|
347
400
|
size: 12, // what a click adds
|
|
348
401
|
picker: true, // false turns the hold gesture off
|
|
@@ -354,9 +407,9 @@ $('#myGrid').gridEditor({
|
|
|
354
407
|
__`callbacks`:__ A `before_*`/`after_*` function per operation, the same notifications as the events. Returning `false` from a `before_*` cancels it. See [docs/events.md](docs/events.md).
|
|
355
408
|
|
|
356
409
|
```javascript
|
|
357
|
-
|
|
410
|
+
new GridEditor('#myGrid', {
|
|
358
411
|
callbacks: {
|
|
359
|
-
before_delete: function(payload) { return !payload.node.
|
|
412
|
+
before_delete: function(payload) { return !payload.node.classList.contains('locked'); },
|
|
360
413
|
after_add_row: function(payload) { console.log('row added', payload.node); },
|
|
361
414
|
},
|
|
362
415
|
});
|
|
@@ -374,7 +427,7 @@ __`settings_panel`:__ Where the settings a gear opens are shown - a node's id, i
|
|
|
374
427
|
Each is titled after its node ("Column settings"), the node is outlined while its settings are open, and Escape closes them. The editor opens and places them itself, with Bootstrap's markup and css: a page needs neither Popper nor Bootstrap's javascript, and the modal is Bootstrap's own when Bootstrap is there. [example/utilities.html](example/utilities.html) switches between the four.
|
|
375
428
|
|
|
376
429
|
```javascript
|
|
377
|
-
|
|
430
|
+
new GridEditor('#myGrid', { settings_panel: 'popover' });
|
|
378
431
|
```
|
|
379
432
|
|
|
380
433
|
__`confirm_delete`:__ Whether to ask before deleting a row, column, element or container. Default `true`. The question is asked in a Bootstrap modal the editor builds outside your canvas, in the interface language; a page that loaded Bootstrap's css but not its javascript gets the browser's own confirm instead. Set it to `false` if you cancel `before-delete` and ask in your own way.
|
|
@@ -382,7 +435,7 @@ __`confirm_delete`:__ Whether to ask before deleting a row, column, element or c
|
|
|
382
435
|
__`drag`:__ How a drag behaves, wherever the editor drags something. Named for the gesture rather than for the library underneath, so it survives a change of library. Every gesture works from a touchscreen, which is what `touch_delay` is for: a touch drag that started instantly would take the page's scrolling with it, so a finger has to rest for a moment before it moves anything. Setting `delay` makes both gestures wait that long.
|
|
383
436
|
|
|
384
437
|
```javascript
|
|
385
|
-
|
|
438
|
+
new GridEditor('#myGrid', {
|
|
386
439
|
drag: {
|
|
387
440
|
delay: 0, // ms to hold before a drag starts
|
|
388
441
|
touch_delay: 100, // the same for touch, where 0 eats the page's scrolling
|
|
@@ -398,7 +451,7 @@ $('#myGrid').gridEditor({
|
|
|
398
451
|
__`layout_modes`:__ Which views the toolbar dropdown offers. Default `['all', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl']`. Offer fewer to keep the feel of 2.x:
|
|
399
452
|
|
|
400
453
|
```javascript
|
|
401
|
-
|
|
454
|
+
new GridEditor('#myGrid', {
|
|
402
455
|
layout_modes: ['all', 'lg', 'sm', 'xs'],
|
|
403
456
|
});
|
|
404
457
|
```
|
|
@@ -408,7 +461,7 @@ __`default_view`:__ The view the editor starts in. Default `'all'`, which writes
|
|
|
408
461
|
__`resize`:__ Resizing a column by dragging its edge. Defaults:
|
|
409
462
|
|
|
410
463
|
```javascript
|
|
411
|
-
|
|
464
|
+
new GridEditor('#myGrid', {
|
|
412
465
|
resize: {
|
|
413
466
|
enabled: true,
|
|
414
467
|
handles: 'e', // 'w' for a right to left page, 'e, w' for both
|
|
@@ -432,13 +485,12 @@ holds the focus, and while its settings are open. While the text is being
|
|
|
432
485
|
edited it stays faint, not to hide the end of the line being typed, until the
|
|
433
486
|
pointer is on the drawer itself.
|
|
434
487
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
row with the text in it, or, dragged, puts the text where it is dropped.
|
|
488
|
+
The toolbar has a *Text* button, one per editor when `content_types` offers
|
|
489
|
+
several (*Text (tinyMCE)*, *Text (CKEditor)*...). The button adds a row with
|
|
490
|
+
the text in it, or, dragged into a column, puts the text where it is dropped.
|
|
439
491
|
|
|
440
492
|
```javascript
|
|
441
|
-
|
|
493
|
+
ge.createText({ content: '<p>Hello</p>', appendTo: '#myColumn' });
|
|
442
494
|
```
|
|
443
495
|
|
|
444
496
|
A text whose editor's plugin is not loaded is still a block, to move and
|
|
@@ -488,7 +540,7 @@ beside it instead, with a warning.
|
|
|
488
540
|
__`elements`:__ Defaults:
|
|
489
541
|
|
|
490
542
|
```javascript
|
|
491
|
-
|
|
543
|
+
new GridEditor('#myGrid', {
|
|
492
544
|
elements: {
|
|
493
545
|
enabled: 'auto', // on when the page has any; true or false to decide yourself
|
|
494
546
|
selector: '[data-ge-element]', // what counts as an element
|
|
@@ -535,14 +587,14 @@ replaces what the breakpoints said. While you edit, the canvas shows what the
|
|
|
535
587
|
classes mean in the view you are in; `getHtml` returns only the classes.
|
|
536
588
|
|
|
537
589
|
```javascript
|
|
538
|
-
|
|
539
|
-
|
|
590
|
+
ge.setUtility(column, 'visibility', 'none', 'md'); // d-md-none
|
|
591
|
+
ge.getUtility(column, 'visibility', 'lg'); // 'none', inherited
|
|
540
592
|
```
|
|
541
593
|
|
|
542
594
|
__`utilities`:__ Options for each plugin, under its name.
|
|
543
595
|
|
|
544
596
|
```javascript
|
|
545
|
-
|
|
597
|
+
new GridEditor('#myGrid', {
|
|
546
598
|
utilities: {
|
|
547
599
|
visibility: { drawer: false }, // no eye in the drawers, the field only
|
|
548
600
|
order: { drawer: false }, // no arrows in the column drawers
|
|
@@ -574,7 +626,7 @@ breakpoint. They are called sections, not containers, because a container is
|
|
|
574
626
|
what the tabs, accordion, popup and card plugins make.
|
|
575
627
|
|
|
576
628
|
```javascript
|
|
577
|
-
|
|
629
|
+
ge.createSection({ width: 'md', rows: [[6, 6]], appendTo: '#myGrid' });
|
|
578
630
|
```
|
|
579
631
|
|
|
580
632
|
__`sections`:__ `{ widths: ['fixed', 'sm', 'md', 'lg', 'xl', 'xxl', 'fluid'] }`, the widths the field offers.
|
|
@@ -634,7 +686,7 @@ Each type is a plugin, in a file of its own, and loading the file is what makes
|
|
|
634
686
|
it available:
|
|
635
687
|
|
|
636
688
|
```html
|
|
637
|
-
<script src="grid-editor/dist/
|
|
689
|
+
<script src="grid-editor/dist/grideditor.min.js"></script>
|
|
638
690
|
<script src="grid-editor/dist/plugins/grideditor.tabs.min.js"></script>
|
|
639
691
|
<script src="grid-editor/dist/plugins/grideditor.accordion.min.js"></script>
|
|
640
692
|
<script src="grid-editor/dist/plugins/grideditor.popup.min.js"></script>
|
|
@@ -647,21 +699,21 @@ for the contract, and for writing one of your own.
|
|
|
647
699
|
__`plugins`:__ Which of the loaded plugins to use, containers, features and utilities alike. Every one by default; name them to use fewer than the page loaded.
|
|
648
700
|
|
|
649
701
|
```javascript
|
|
650
|
-
|
|
702
|
+
new GridEditor('#myGrid', { plugins: ['tabs', 'elements'] });
|
|
651
703
|
```
|
|
652
704
|
|
|
653
705
|
__`container_tools`, `tab_tools`, `accordion_tools`:__ Extra tools on the container drawer and on each pane's drawer, same shape as `row_tools`.
|
|
654
706
|
|
|
655
707
|
```javascript
|
|
656
|
-
var tabs =
|
|
708
|
+
var tabs = ge.createContainer('tabs', {
|
|
657
709
|
tabs: 2,
|
|
658
710
|
labels: ['Overview', 'Details'],
|
|
659
711
|
appendTo: $('#myGrid .column').first(),
|
|
660
712
|
});
|
|
661
|
-
|
|
713
|
+
ge.addTab(tabs, { label: 'Third', activate: true });
|
|
662
714
|
|
|
663
|
-
|
|
664
|
-
|
|
715
|
+
ge.createContainer('accordion', { items: 3, stay_open: true });
|
|
716
|
+
ge.createContainer('popup', { title: 'Terms', trigger_label: 'Read them', size: 'lg' });
|
|
665
717
|
```
|
|
666
718
|
|
|
667
719
|
An accordion opens and closes from its headers while editing, and what you
|
|
@@ -685,16 +737,16 @@ __`locale`:__ The code of a locale in `$.fn.gridEditor.locales`. Default `'en'`.
|
|
|
685
737
|
__`locale_strings`:__ Overrides for individual keys, without a locale file.
|
|
686
738
|
|
|
687
739
|
```javascript
|
|
688
|
-
|
|
740
|
+
new GridEditor('#myGrid', {
|
|
689
741
|
locale: 'es',
|
|
690
742
|
locale_strings: { 'tool.move': 'Arrastrar' },
|
|
691
743
|
});
|
|
692
744
|
```
|
|
693
745
|
|
|
694
|
-
__`source_textarea`:__ Allows to set an already existing textarea as input for grid editor.
|
|
746
|
+
__`source_textarea`:__ Allows to set an already existing textarea as input for grid editor: an element, or a selector.
|
|
695
747
|
|
|
696
748
|
```javascript
|
|
697
|
-
|
|
749
|
+
new GridEditor('#myGrid', {
|
|
698
750
|
source_textarea: 'textarea.myTextarea',
|
|
699
751
|
});
|
|
700
752
|
```
|
|
@@ -702,9 +754,8 @@ $('#myGrid').gridEditor({
|
|
|
702
754
|
You will have write back the content to the textarea before saving, for example in this way:
|
|
703
755
|
|
|
704
756
|
```javascript
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
$('textarea.myTextarea').val(html);
|
|
757
|
+
document.querySelector('form.myForm').addEventListener('submit', function() {
|
|
758
|
+
document.querySelector('textarea.myTextarea').value = ge.getHtml();
|
|
708
759
|
});
|
|
709
760
|
```
|
|
710
761
|
|
|
@@ -716,7 +767,7 @@ hand, and back again with what was written.
|
|
|
716
767
|
__`edit_source`:__ Whether the toolbar has that button. Default value: `true`.
|
|
717
768
|
|
|
718
769
|
```javascript
|
|
719
|
-
|
|
770
|
+
new GridEditor('#myGrid', {
|
|
720
771
|
edit_source: false,
|
|
721
772
|
});
|
|
722
773
|
```
|
|
@@ -741,7 +792,7 @@ plugin's defaults: `mode: 'htmlmixed'`, `lineNumbers`, `lineWrapping`, a tab
|
|
|
741
792
|
of 2.
|
|
742
793
|
|
|
743
794
|
```javascript
|
|
744
|
-
|
|
795
|
+
new GridEditor('#myGrid', {
|
|
745
796
|
codemirror: { config: { theme: 'monokai' } },
|
|
746
797
|
});
|
|
747
798
|
```
|
|
@@ -780,7 +831,7 @@ it is missing. Another editor is a plugin of your own:
|
|
|
780
831
|
__`content_types`:__ Specify the RTEs to offer, in order. Valid values: any of `'tinymce'`, `'summernote'`, `'ckeditor'` whose plugin is loaded. Default value: every text editor loaded, in the order the page loaded them.
|
|
781
832
|
|
|
782
833
|
```javascript
|
|
783
|
-
|
|
834
|
+
new GridEditor('#myGrid', {
|
|
784
835
|
content_types: ['summernote'],
|
|
785
836
|
});
|
|
786
837
|
```
|
|
@@ -790,7 +841,7 @@ See the [CKEditor documentation](http://docs.ckeditor.com/).
|
|
|
790
841
|
Also check out the [ckeditor example](example/ckeditor.html).
|
|
791
842
|
|
|
792
843
|
```javascript
|
|
793
|
-
|
|
844
|
+
new GridEditor('#myGrid', {
|
|
794
845
|
ckeditor: {
|
|
795
846
|
config: { language: 'fr' }
|
|
796
847
|
}
|
|
@@ -802,7 +853,7 @@ See the [summernote documentation](http://summernote.org/deep-dive/).
|
|
|
802
853
|
Also check out the [summernote example](example/summernote.html).
|
|
803
854
|
|
|
804
855
|
```javascript
|
|
805
|
-
|
|
856
|
+
new GridEditor('#myGrid', {
|
|
806
857
|
summernote: {
|
|
807
858
|
config: { shortcuts: false }
|
|
808
859
|
}
|
|
@@ -814,7 +865,7 @@ See the [tinyMCE documentation](https://www.tiny.cloud/docs/tinymce/6/).
|
|
|
814
865
|
Also check out the [tinymce example](example/basic.html).
|
|
815
866
|
|
|
816
867
|
```javascript
|
|
817
|
-
|
|
868
|
+
new GridEditor('#myGrid', {
|
|
818
869
|
tinymce: {
|
|
819
870
|
config: { paste_as_text: true }
|
|
820
871
|
}
|