@themarioga/grid-editor 6.0.0 → 7.1.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 (147) hide show
  1. package/AUTO_SAVE.md +2 -2
  2. package/BUILDING.md +45 -29
  3. package/CHANGELOG.md +59 -0
  4. package/README.md +163 -87
  5. package/UPGRADING.md +119 -0
  6. package/dist/grideditor.bundle.min.js +14 -0
  7. package/dist/grideditor.d.ts +335 -0
  8. package/dist/grideditor.esm.js +3977 -0
  9. package/dist/grideditor.jquery.js +253 -0
  10. package/dist/grideditor.jquery.min.js +1 -0
  11. package/dist/grideditor.jquery.min.js.map +7 -0
  12. package/dist/grideditor.js +3983 -0
  13. package/dist/grideditor.min.js +6 -0
  14. package/dist/grideditor.min.js.map +7 -0
  15. package/dist/locales/grideditor.es.esm.js +158 -0
  16. package/dist/locales/grideditor.es.js +164 -168
  17. package/dist/locales/grideditor.es.min.js +6 -2
  18. package/dist/locales/grideditor.es.min.js.map +7 -1
  19. package/dist/plugins/grideditor.accordion.esm.js +294 -0
  20. package/dist/plugins/grideditor.accordion.js +286 -180
  21. package/dist/plugins/grideditor.accordion.min.js +1 -2
  22. package/dist/plugins/grideditor.accordion.min.js.map +7 -1
  23. package/dist/plugins/grideditor.alignment.esm.js +55 -0
  24. package/dist/plugins/grideditor.alignment.js +58 -77
  25. package/dist/plugins/grideditor.alignment.min.js +1 -2
  26. package/dist/plugins/grideditor.alignment.min.js.map +7 -1
  27. package/dist/plugins/grideditor.card.esm.js +73 -0
  28. package/dist/plugins/grideditor.card.js +74 -64
  29. package/dist/plugins/grideditor.card.min.js +1 -2
  30. package/dist/plugins/grideditor.card.min.js.map +7 -1
  31. package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
  32. package/dist/plugins/grideditor.ckeditor.js +484 -449
  33. package/dist/plugins/grideditor.ckeditor.min.js +1 -2
  34. package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
  35. package/dist/plugins/grideditor.clipboard.esm.js +326 -0
  36. package/dist/plugins/grideditor.clipboard.js +298 -235
  37. package/dist/plugins/grideditor.clipboard.min.js +1 -2
  38. package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
  39. package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
  40. package/dist/plugins/grideditor.codemirror-inline.js +188 -168
  41. package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
  42. package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
  43. package/dist/plugins/grideditor.codemirror.esm.js +63 -0
  44. package/dist/plugins/grideditor.codemirror.js +60 -71
  45. package/dist/plugins/grideditor.codemirror.min.js +1 -2
  46. package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
  47. package/dist/plugins/grideditor.elements.esm.js +271 -0
  48. package/dist/plugins/grideditor.elements.js +256 -149
  49. package/dist/plugins/grideditor.elements.min.js +1 -2
  50. package/dist/plugins/grideditor.elements.min.js.map +7 -1
  51. package/dist/plugins/grideditor.float.esm.js +34 -0
  52. package/dist/plugins/grideditor.float.js +37 -52
  53. package/dist/plugins/grideditor.float.min.js +1 -2
  54. package/dist/plugins/grideditor.float.min.js.map +7 -1
  55. package/dist/plugins/grideditor.gutters.esm.js +143 -0
  56. package/dist/plugins/grideditor.gutters.js +134 -131
  57. package/dist/plugins/grideditor.gutters.min.js +1 -2
  58. package/dist/plugins/grideditor.gutters.min.js.map +7 -1
  59. package/dist/plugins/grideditor.order.esm.js +189 -0
  60. package/dist/plugins/grideditor.order.js +170 -182
  61. package/dist/plugins/grideditor.order.min.js +1 -2
  62. package/dist/plugins/grideditor.order.min.js.map +7 -1
  63. package/dist/plugins/grideditor.popup.esm.js +187 -0
  64. package/dist/plugins/grideditor.popup.js +183 -134
  65. package/dist/plugins/grideditor.popup.min.js +1 -2
  66. package/dist/plugins/grideditor.popup.min.js.map +7 -1
  67. package/dist/plugins/grideditor.sections.esm.js +271 -0
  68. package/dist/plugins/grideditor.sections.js +250 -173
  69. package/dist/plugins/grideditor.sections.min.js +1 -2
  70. package/dist/plugins/grideditor.sections.min.js.map +7 -1
  71. package/dist/plugins/grideditor.spacing.esm.js +318 -0
  72. package/dist/plugins/grideditor.spacing.js +296 -272
  73. package/dist/plugins/grideditor.spacing.min.js +1 -2
  74. package/dist/plugins/grideditor.spacing.min.js.map +7 -1
  75. package/dist/plugins/grideditor.summernote.esm.js +509 -0
  76. package/dist/plugins/grideditor.summernote.js +493 -427
  77. package/dist/plugins/grideditor.summernote.min.js +1 -2
  78. package/dist/plugins/grideditor.summernote.min.js.map +7 -1
  79. package/dist/plugins/grideditor.tabs.esm.js +237 -0
  80. package/dist/plugins/grideditor.tabs.js +233 -139
  81. package/dist/plugins/grideditor.tabs.min.js +1 -2
  82. package/dist/plugins/grideditor.tabs.min.js.map +7 -1
  83. package/dist/plugins/grideditor.textalign.esm.js +40 -0
  84. package/dist/plugins/grideditor.textalign.js +43 -56
  85. package/dist/plugins/grideditor.textalign.min.js +1 -2
  86. package/dist/plugins/grideditor.textalign.min.js.map +7 -1
  87. package/dist/plugins/grideditor.tinymce.esm.js +519 -0
  88. package/dist/plugins/grideditor.tinymce.js +502 -490
  89. package/dist/plugins/grideditor.tinymce.min.js +1 -2
  90. package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
  91. package/dist/plugins/grideditor.visibility.esm.js +158 -0
  92. package/dist/plugins/grideditor.visibility.js +140 -149
  93. package/dist/plugins/grideditor.visibility.min.js +1 -2
  94. package/dist/plugins/grideditor.visibility.min.js.map +7 -1
  95. package/docs/events.md +47 -21
  96. package/docs/locale-keys.md +6 -0
  97. package/docs/plugins.md +47 -25
  98. package/example/adapter.html +112 -0
  99. package/example/attributes.html +89 -62
  100. package/example/autocols.html +9 -9
  101. package/example/autosave.html +18 -16
  102. package/example/basic.html +8 -6
  103. package/example/breakpoints.html +5 -6
  104. package/example/ckeditor.html +4 -5
  105. package/example/clipboard.html +15 -11
  106. package/example/codemirror.html +13 -8
  107. package/example/containers.html +11 -9
  108. package/example/custom_editor.html +53 -34
  109. package/example/elements.html +14 -12
  110. package/example/index.html +16 -2
  111. package/example/locale.html +6 -7
  112. package/example/plugins.html +44 -29
  113. package/example/summernote.html +6 -5
  114. package/example/utilities.html +17 -13
  115. package/example/wrap_content.html +13 -10
  116. package/package.json +44 -12
  117. package/src/js/dom.js +401 -0
  118. package/src/js/grideditor.classic.js +16 -0
  119. package/src/js/grideditor.jquery.js +325 -0
  120. package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
  121. package/src/js/locales/grideditor.es.js +163 -156
  122. package/src/js/plugins/grideditor.accordion.js +97 -77
  123. package/src/js/plugins/grideditor.alignment.js +5 -7
  124. package/src/js/plugins/grideditor.card.js +23 -23
  125. package/src/js/plugins/grideditor.ckeditor.js +107 -106
  126. package/src/js/plugins/grideditor.clipboard.js +49 -37
  127. package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
  128. package/src/js/plugins/grideditor.codemirror.js +9 -10
  129. package/src/js/plugins/grideditor.elements.js +57 -33
  130. package/src/js/plugins/grideditor.float.js +4 -6
  131. package/src/js/plugins/grideditor.gutters.js +20 -15
  132. package/src/js/plugins/grideditor.order.js +28 -25
  133. package/src/js/plugins/grideditor.popup.js +63 -51
  134. package/src/js/plugins/grideditor.sections.js +39 -32
  135. package/src/js/plugins/grideditor.spacing.js +42 -45
  136. package/src/js/plugins/grideditor.summernote.js +112 -76
  137. package/src/js/plugins/grideditor.tabs.js +65 -57
  138. package/src/js/plugins/grideditor.textalign.js +4 -6
  139. package/src/js/plugins/grideditor.tinymce.js +148 -140
  140. package/src/js/plugins/grideditor.visibility.js +24 -25
  141. package/src/js/register.js +18 -0
  142. package/src/js/text/grideditor.text.js +77 -56
  143. package/types/grideditor.d.ts +335 -0
  144. package/dist/jquery.grideditor.bundle.min.js +0 -10
  145. package/dist/jquery.grideditor.js +0 -4927
  146. package/dist/jquery.grideditor.min.js +0 -2
  147. 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/), written as a [jQuery](http://jquery.com/) plugin. 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.
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
  ![Preview](http://i.imgur.com/UF9CCzk.png)
@@ -39,13 +37,17 @@ 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) |
41
+
42
+ [example/angular](example/angular) is the editor in an Angular app, from the npm
43
+ package: an Angular CLI project, with a build step, unlike the pages above.
42
44
 
43
45
  Installation
44
46
  ------------
45
47
 
46
- * __Dependencies:__ Grid Editor depends on jQuery, [SortableJS](https://sortablejs.github.io/Sortable/), Bootstrap Icons, and Bootstrap 5, so make sure you have included those in the page.
47
- * If you want to use the tinyMCE integration, include tinyMCE 6 as well, and `dist/plugins/grideditor.tinymce.min.js` after the editor. The tinyMCE jQuery plugin is no longer needed, and no longer exists as of tinyMCE 6.
48
- * If you want to use the summernote integration, include summernote and `dist/plugins/grideditor.summernote.min.js`.
48
+ * __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.
49
+ * If you want to use the tinyMCE integration, include tinyMCE 7 (7.9.3 or later) as well, and `dist/plugins/grideditor.tinymce.min.js` after the editor.
50
+ * 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
51
  * If you want to use the CKEditor integration... you get the point: CKEditor and `dist/plugins/grideditor.ckeditor.min.js`.
50
52
  * 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
53
  * From npm:
@@ -57,10 +59,10 @@ npm install @themarioga/grid-editor
57
59
  * Or [download the latest version of Grid Editor](https://github.com/themarioga/grid-editor/archive/master.zip) and include it in your page:
58
60
 
59
61
  ```html
60
- <!-- Make sure jQuery, SortableJS, bootstrap icons, and bootstrap 5 are included. TinyMCE is optional. -->
62
+ <!-- Make sure SortableJS, bootstrap icons, and bootstrap 5 are included. TinyMCE is optional. -->
61
63
  <link rel="stylesheet" type="text/css" href="grid-editor/dist/grideditor.min.css" />
62
64
  <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
63
- <script src="grid-editor/dist/jquery.grideditor.min.js"></script>
65
+ <script src="grid-editor/dist/grideditor.min.js"></script>
64
66
  <!-- The text editor you use, as a plugin -->
65
67
  <script src="grid-editor/dist/plugins/grideditor.tinymce.min.js"></script>
66
68
  ```
@@ -70,20 +72,67 @@ inside it &mdash; one or the other, never both:
70
72
 
71
73
  ```html
72
74
  <link rel="stylesheet" type="text/css" href="grid-editor/dist/grideditor.min.css" />
73
- <script src="grid-editor/dist/jquery.grideditor.bundle.min.js"></script>
75
+ <script src="grid-editor/dist/grideditor.bundle.min.js"></script>
76
+ ```
77
+
78
+ ### As an ES module
79
+
80
+ An app built with a bundler - Angular, React, Vue, Vite - imports the editor
81
+ and the plugins it wants. A plugin registers as it is imported:
82
+
83
+ ```javascript
84
+ import GridEditor from '@themarioga/grid-editor';
85
+ import '@themarioga/grid-editor/plugins/tabs';
86
+ import '@themarioga/grid-editor/plugins/tinymce';
87
+ import '@themarioga/grid-editor/locales/es';
88
+ import '@themarioga/grid-editor/css';
89
+ import Sortable from 'sortablejs';
90
+ import * as bootstrap from 'bootstrap';
91
+
92
+ // What a module app has as imports, not as window.Sortable and window.bootstrap
93
+ GridEditor.Sortable = Sortable;
94
+ GridEditor.bootstrap = bootstrap;
95
+
96
+ const ge = new GridEditor(element, { content_types: ['tinymce'] });
97
+ ```
98
+
99
+ The module build imports nothing itself. Without `GridEditor.Sortable` or a
100
+ `window.Sortable`, dragging is off; without Bootstrap's javascript, a delete is
101
+ confirmed with the browser's `confirm()` and the modal settings panel opens
102
+ with a backdrop of the editor's own. Types for the public API come with the
103
+ package (`dist/grideditor.d.ts`).
104
+
105
+ [example/angular](example/angular) is a whole app that does this, with the
106
+ editor as an Angular component.
107
+
108
+ Load the classic script *or* the module build on a page, never both.
109
+
110
+ ### A page written for 6.x
111
+
112
+ A page that uses the jQuery API of 6.x - `$(el).gridEditor(...)`, jQuery
113
+ events, jQuery objects in the payloads - keeps it by loading jQuery 4 and the
114
+ adapter after the editor, and the 7.x plugins after that:
115
+
116
+ ```html
117
+ <script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
118
+ <script src="grid-editor/dist/grideditor.min.js"></script>
119
+ <script src="grid-editor/dist/grideditor.jquery.min.js"></script>
120
+ <script src="grid-editor/dist/plugins/grideditor.tabs.min.js"></script>
74
121
  ```
75
122
 
123
+ Plugins written for 6.x are not kept working: see [UPGRADING.md](UPGRADING.md).
124
+
76
125
  Usage
77
126
  -----
78
127
  ```javascript
79
- $('#myGrid').gridEditor({
128
+ var ge = new GridEditor('#myGrid', {
80
129
  new_row_layouts: [[12], [6,6], [9,3]],
81
130
  });
82
131
  // Call this to get the result after the user has done some editing:
83
- var html = $('#myGrid').gridEditor('getHtml');
132
+ var html = ge.getHtml();
84
133
 
85
134
  // Or, for a page that only publishes the result and never edits it again:
86
- var published = $('#myGrid').gridEditor('getPlainHtml');
135
+ var published = ge.getPlainHtml();
87
136
  ```
88
137
 
89
138
  `getHtml` keeps a little of the editor's own marking: the `column` class, the
@@ -104,9 +153,17 @@ Methods
104
153
  -------
105
154
 
106
155
  ```javascript
107
- $('#myGrid').gridEditor('method', argument);
156
+ var ge = new GridEditor('#myGrid', options); // or GridEditor.create('#myGrid', options)
157
+ ge.method(argument);
158
+
159
+ GridEditor.get('#myGrid'); // the editor on an element, or null
108
160
  ```
109
161
 
162
+ The element is an element or a selector, which takes the first element it
163
+ matches; one that matches nothing throws a `TypeError`. An element has one
164
+ editor at most: asked for a second, `new GridEditor` hands back the one it
165
+ has, with the options it was made with, and warns once.
166
+
110
167
  | Method | Arguments | Returns | What it does |
111
168
  | --- | --- | --- | --- |
112
169
  | `getHtml` | — | `String` | The clean html: no drawers, no editor classes, no inline styles |
@@ -115,62 +172,64 @@ $('#myGrid').gridEditor('method', argument);
115
172
  | `deinit` | — | `this` | Strip the editing furniture, leave the markup |
116
173
  | `reset` | — | `this` | `deinit()` then `init()` |
117
174
  | `destroy` | — | `this` | Deinit, drop the controls, unbind, forget the instance |
118
- | `remove` | — | `this` | Deprecated alias of `destroy` |
119
175
  | `changeView` | `breakpoint` | `this` | `'xs'`…`'xxl'`, or `'all'` to edit every breakpoint at once, with one class |
120
176
  | `getView` | — | `String` | The view the editor is in |
121
177
  | `setLocale` | `code` | `this` | Switch language and re-render the controls |
122
- | `createRow` | `layout?`, `options?` | `jQuery` | A row, optionally with columns: `createRow([8, 4])`, `createRow(['auto', 'equal'])`, `createRow({ row_cols: { xs: 1, md: 3 }, columns: 6 })` |
123
- | `createColumn` | `size`, `options?` | `jQuery` | 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 |
124
- | `createSection` | `options?` | `jQuery` | A section, with the sections plugin. `options`: `width` (`'fixed'`, `'fluid'` or a breakpoint), `rows` (layouts), and a placement |
125
- | `createElement` | `content`, `options?` | `jQuery` | Host markup wrapped as an element. `options`: `type`, `label` |
126
- | `createText` | `type?`, `options?` | `jQuery` | 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 |
127
- | `createContainer` | `type`, `options?` | `jQuery` | `'tabs'`, `'accordion'` or `'popup'` |
128
- | `addTab` | `container`, `options?` | `jQuery` | Appends a tab, returns its pane |
129
- | `addAccordionItem` | `container`, `options?` | `jQuery` | Appends an item, returns its body |
178
+ | `createRow` | `layout?`, `options?` | `Element` | A row, optionally with columns: `createRow([8, 4])`, `createRow(['auto', 'equal'])`, `createRow({ row_cols: { xs: 1, md: 3 }, columns: 6 })` |
179
+ | `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 |
180
+ | `createSection` | `options?` | `Element` | A section, with the sections plugin. `options`: `width` (`'fixed'`, `'fluid'` or a breakpoint), `rows` (layouts), and a placement |
181
+ | `createElement` | `content`, `options?` | `Element` | Host markup wrapped as an element. `options`: `type`, `label` |
182
+ | `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 |
183
+ | `createContainer` | `type`, `options?` | `Element` | `'tabs'`, `'accordion'` or `'popup'` |
184
+ | `addTab` | `container`, `options?` | `Element` | Appends a tab, returns its pane |
185
+ | `addAccordionItem` | `container`, `options?` | `Element` | Appends an item, returns its body |
130
186
  | `getUtility` | `node`, `family`, `view?` | `String` | A utility plugin's value on a node in a view (the current one by default), or `null` |
131
187
  | `setUtility` | `node`, `family`, `value`, `view?` | `Boolean` | Write it through the events; `null` is inherit. `false` if canceled or nothing changed |
132
188
 
133
- A method called on an element with no editor on it is a no-op that returns the
134
- set, so host code does not have to check first. `getHtml` and `getPlainHtml`
135
- are the exception: they return the element's html either way, and
136
- `getPlainHtml` cleans it.
189
+ The methods that do something hand back the editor, so they chain. After
190
+ `destroy()` every method is a no-op that says so once, but for `getHtml` and
191
+ `getPlainHtml`, which read the element as it is.
137
192
 
138
- The `create*` methods hand back the node they made rather than the jQuery set,
139
- because you need the node. It comes back **detached**: place it and call
140
- `reset()`, or pass a parent and let grid-editor do both.
193
+ The `create*` methods hand back the element they made, or `null` when a handler
194
+ canceled the add. It comes back **detached**: place it and call `reset()`, or
195
+ pass a parent - an element or a selector - and let grid-editor do both.
141
196
 
142
197
  ```javascript
143
198
  // place it yourself
144
- var row = $('#myGrid').gridEditor('createRow', [8, 4]);
145
- row.appendTo('#myGrid');
146
- $('#myGrid').gridEditor('reset');
199
+ var row = ge.createRow([8, 4]);
200
+ document.querySelector('#myGrid').appendChild(row);
201
+ ge.reset();
147
202
 
148
203
  // or say where it goes: appendTo, prependTo, insertAfter, insertBefore
149
- $('#myGrid').gridEditor('createRow', [8, 4], { appendTo: '#myGrid' });
204
+ ge.createRow([8, 4], { appendTo: '#myGrid' });
150
205
  ```
151
206
 
152
- If you are calling several methods in a row, take the instance handle instead
153
- of dispatching each one. It exposes the same methods, plus the canvas and a
154
- read-only copy of the settings:
207
+ Besides the methods, the editor has its canvas and a read-only copy of the
208
+ settings:
155
209
 
156
210
  ```javascript
157
- var ge = $('#myGrid').data('grideditor');
158
211
  ge.createRow([12], { appendTo: ge.canvas });
159
- ge.changeView('lg');
212
+ ge.settings.locale; // 'en'
160
213
  ```
161
214
 
215
+ A html string written into the canvas - through the source view,
216
+ `source_textarea`, `createElement` or a paste - is parsed as `innerHTML`
217
+ parses: a `<script>` in it is kept in the markup and does not run in the
218
+ editor. Up to 6.x it did.
219
+
162
220
  Events
163
221
  ------
164
222
 
165
- Every operation is announced before and after it happens, as a jQuery event on
166
- the canvas and as a callback. A `before-*` can be canceled.
223
+ Every operation is announced before and after it happens, as a DOM event on
224
+ the canvas - a `CustomEvent` with the payload as its `detail` - and as a
225
+ callback. A `before-*` can be canceled.
167
226
 
168
227
  ```javascript
169
- $('#myGrid').on('grideditor:before-delete', function(e, payload) {
170
- if (payload.node.hasClass('locked')) { e.preventDefault(); }
228
+ ge.canvas.addEventListener('grideditor:before-delete', function(e) {
229
+ if (e.detail.node.classList.contains('locked')) { e.preventDefault(); }
171
230
  });
172
231
 
173
- $('#myGrid').gridEditor({
232
+ new GridEditor('#myGrid', {
174
233
  callbacks: {
175
234
  after_move: function(payload) { console.log(payload.from, payload.to); },
176
235
  },
@@ -183,7 +242,7 @@ The full catalogue, the payload and what canceling each operation does is in
183
242
  Languages
184
243
  ---------
185
244
 
186
- The interface ships in English and Spanish. English is built into the plugin;
245
+ The interface ships in English and Spanish. English is built into the editor;
187
246
  every other language is a file you load after it.
188
247
 
189
248
  | Code | Language | File |
@@ -192,9 +251,9 @@ every other language is a file you load after it.
192
251
  | `es` | Spanish | `dist/locales/grideditor.es.js` |
193
252
 
194
253
  ```html
195
- <script src="grid-editor/dist/jquery.grideditor.min.js"></script>
254
+ <script src="grid-editor/dist/grideditor.min.js"></script>
196
255
  <script src="grid-editor/dist/locales/grideditor.es.js"></script>
197
- <script>$('#myGrid').gridEditor({ locale: 'es' });</script>
256
+ <script>new GridEditor('#myGrid', { locale: 'es' });</script>
198
257
  ```
199
258
 
200
259
  Override single strings without a locale file with `locale_strings`, and switch
@@ -214,7 +273,7 @@ Options
214
273
  __`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
274
 
216
275
  ```javascript
217
- $('#myGrid').gridEditor({
276
+ new GridEditor('#myGrid', {
218
277
  new_row_layouts: [[12], [6,6], [9,3], ['auto', 'equal'], { row_cols: { xs: 1, md: 3 }, columns: 6 }],
219
278
  });
220
279
  ```
@@ -260,7 +319,7 @@ buttons beside the two fields. Empty by default; the classes field covers the
260
319
  general case, and this is for the handful a host wants one click away.
261
320
 
262
321
  ```javascript
263
- $('#myGrid').gridEditor({
322
+ new GridEditor('#myGrid', {
264
323
  row_classes: [{ label: 'Dark', cssClass: 'my-app-dark' }],
265
324
  });
266
325
  ```
@@ -270,7 +329,7 @@ __`col_classes`:__ The same as `row_classes`, but for columns. `container_classe
270
329
  __`row_tools`:__ Add extra tool buttons to the row toolbar.
271
330
 
272
331
  ```javascript
273
- $('#myGrid').gridEditor({
332
+ new GridEditor('#myGrid', {
274
333
  row_tools: [{
275
334
  title: 'Set background image',
276
335
  iconClass: 'glyphicon-picture',
@@ -288,7 +347,7 @@ __`col_tools`:__ The same as row_tools, but for columns.
288
347
  __`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
348
 
290
349
  ```javascript
291
- $('#myGrid').gridEditor({
350
+ new GridEditor('#myGrid', {
292
351
  drag_handle: 'drawer',
293
352
  });
294
353
  ```
@@ -296,7 +355,7 @@ $('#myGrid').gridEditor({
296
355
  __`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
356
 
298
357
  ```javascript
299
- $('#myGrid').gridEditor({
358
+ new GridEditor('#myGrid', {
300
359
  drag_handle: 'drawer',
301
360
  toolbar_drag: 'auto',
302
361
  });
@@ -306,7 +365,7 @@ __`custom_filter`:__ Allows the execution of a custom function before initializa
306
365
  Gives the `canvas` element and `isInit` (true/false) as parameter.
307
366
 
308
367
  ```javascript
309
- $('#myGrid').gridEditor({
368
+ new GridEditor('#myGrid', {
310
369
  'custom_filter': 'functionname',
311
370
  });
312
371
 
@@ -322,7 +381,7 @@ function functionname(canvas, isInit) {
322
381
  or
323
382
 
324
383
  ```javascript
325
- $('#myGrid').gridEditor({
384
+ new GridEditor('#myGrid', {
326
385
  'custom_filter': function(canvas, isInit) {
327
386
  //...
328
387
  },
@@ -332,7 +391,7 @@ $('#myGrid').gridEditor({
332
391
  __`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
392
 
334
393
  ```javascript
335
- $('#myGrid').gridEditor({
394
+ new GridEditor('#myGrid', {
336
395
  'valid_col_sizes': [2, 5, 8, 10],
337
396
  });
338
397
  ```
@@ -342,7 +401,7 @@ __`valid_col_offsets`:__ The same, for the indent buttons. Default `[0, 1, … 1
342
401
  __`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
402
 
344
403
  ```javascript
345
- $('#myGrid').gridEditor({
404
+ new GridEditor('#myGrid', {
346
405
  add_column: {
347
406
  size: 12, // what a click adds
348
407
  picker: true, // false turns the hold gesture off
@@ -354,9 +413,9 @@ $('#myGrid').gridEditor({
354
413
  __`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
414
 
356
415
  ```javascript
357
- $('#myGrid').gridEditor({
416
+ new GridEditor('#myGrid', {
358
417
  callbacks: {
359
- before_delete: function(payload) { return !payload.node.hasClass('locked'); },
418
+ before_delete: function(payload) { return !payload.node.classList.contains('locked'); },
360
419
  after_add_row: function(payload) { console.log('row added', payload.node); },
361
420
  },
362
421
  });
@@ -374,7 +433,7 @@ __`settings_panel`:__ Where the settings a gear opens are shown - a node's id, i
374
433
  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
434
 
376
435
  ```javascript
377
- $('#myGrid').gridEditor({ settings_panel: 'popover' });
436
+ new GridEditor('#myGrid', { settings_panel: 'popover' });
378
437
  ```
379
438
 
380
439
  __`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 +441,7 @@ __`confirm_delete`:__ Whether to ask before deleting a row, column, element or c
382
441
  __`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
442
 
384
443
  ```javascript
385
- $('#myGrid').gridEditor({
444
+ new GridEditor('#myGrid', {
386
445
  drag: {
387
446
  delay: 0, // ms to hold before a drag starts
388
447
  touch_delay: 100, // the same for touch, where 0 eats the page's scrolling
@@ -398,7 +457,7 @@ $('#myGrid').gridEditor({
398
457
  __`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
458
 
400
459
  ```javascript
401
- $('#myGrid').gridEditor({
460
+ new GridEditor('#myGrid', {
402
461
  layout_modes: ['all', 'lg', 'sm', 'xs'],
403
462
  });
404
463
  ```
@@ -408,7 +467,7 @@ __`default_view`:__ The view the editor starts in. Default `'all'`, which writes
408
467
  __`resize`:__ Resizing a column by dragging its edge. Defaults:
409
468
 
410
469
  ```javascript
411
- $('#myGrid').gridEditor({
470
+ new GridEditor('#myGrid', {
412
471
  resize: {
413
472
  enabled: true,
414
473
  handles: 'e', // 'w' for a right to left page, 'e, w' for both
@@ -437,7 +496,7 @@ several (*Text (tinyMCE)*, *Text (CKEditor)*...). The button adds a row with
437
496
  the text in it, or, dragged into a column, puts the text where it is dropped.
438
497
 
439
498
  ```javascript
440
- $('#myGrid').gridEditor('createText', { content: '<p>Hello</p>', appendTo: '#myColumn' });
499
+ ge.createText({ content: '<p>Hello</p>', appendTo: '#myColumn' });
441
500
  ```
442
501
 
443
502
  A text whose editor's plugin is not loaded is still a block, to move and
@@ -487,7 +546,7 @@ beside it instead, with a warning.
487
546
  __`elements`:__ Defaults:
488
547
 
489
548
  ```javascript
490
- $('#myGrid').gridEditor({
549
+ new GridEditor('#myGrid', {
491
550
  elements: {
492
551
  enabled: 'auto', // on when the page has any; true or false to decide yourself
493
552
  selector: '[data-ge-element]', // what counts as an element
@@ -534,14 +593,14 @@ replaces what the breakpoints said. While you edit, the canvas shows what the
534
593
  classes mean in the view you are in; `getHtml` returns only the classes.
535
594
 
536
595
  ```javascript
537
- $('#myGrid').gridEditor('setUtility', column, 'visibility', 'none', 'md'); // d-md-none
538
- $('#myGrid').gridEditor('getUtility', column, 'visibility', 'lg'); // 'none', inherited
596
+ ge.setUtility(column, 'visibility', 'none', 'md'); // d-md-none
597
+ ge.getUtility(column, 'visibility', 'lg'); // 'none', inherited
539
598
  ```
540
599
 
541
600
  __`utilities`:__ Options for each plugin, under its name.
542
601
 
543
602
  ```javascript
544
- $('#myGrid').gridEditor({
603
+ new GridEditor('#myGrid', {
545
604
  utilities: {
546
605
  visibility: { drawer: false }, // no eye in the drawers, the field only
547
606
  order: { drawer: false }, // no arrows in the column drawers
@@ -573,7 +632,7 @@ breakpoint. They are called sections, not containers, because a container is
573
632
  what the tabs, accordion, popup and card plugins make.
574
633
 
575
634
  ```javascript
576
- $('#myGrid').gridEditor('createSection', { width: 'md', rows: [[6, 6]], appendTo: '#myGrid' });
635
+ ge.createSection({ width: 'md', rows: [[6, 6]], appendTo: '#myGrid' });
577
636
  ```
578
637
 
579
638
  __`sections`:__ `{ widths: ['fixed', 'sm', 'md', 'lg', 'xl', 'xxl', 'fluid'] }`, the widths the field offers.
@@ -633,7 +692,7 @@ Each type is a plugin, in a file of its own, and loading the file is what makes
633
692
  it available:
634
693
 
635
694
  ```html
636
- <script src="grid-editor/dist/jquery.grideditor.min.js"></script>
695
+ <script src="grid-editor/dist/grideditor.min.js"></script>
637
696
  <script src="grid-editor/dist/plugins/grideditor.tabs.min.js"></script>
638
697
  <script src="grid-editor/dist/plugins/grideditor.accordion.min.js"></script>
639
698
  <script src="grid-editor/dist/plugins/grideditor.popup.min.js"></script>
@@ -646,21 +705,21 @@ for the contract, and for writing one of your own.
646
705
  __`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.
647
706
 
648
707
  ```javascript
649
- $('#myGrid').gridEditor({ plugins: ['tabs', 'elements'] });
708
+ new GridEditor('#myGrid', { plugins: ['tabs', 'elements'] });
650
709
  ```
651
710
 
652
711
  __`container_tools`, `tab_tools`, `accordion_tools`:__ Extra tools on the container drawer and on each pane's drawer, same shape as `row_tools`.
653
712
 
654
713
  ```javascript
655
- var tabs = $('#myGrid').gridEditor('createContainer', 'tabs', {
714
+ var tabs = ge.createContainer('tabs', {
656
715
  tabs: 2,
657
716
  labels: ['Overview', 'Details'],
658
717
  appendTo: $('#myGrid .column').first(),
659
718
  });
660
- $('#myGrid').gridEditor('addTab', tabs, { label: 'Third', activate: true });
719
+ ge.addTab(tabs, { label: 'Third', activate: true });
661
720
 
662
- $('#myGrid').gridEditor('createContainer', 'accordion', { items: 3, stay_open: true });
663
- $('#myGrid').gridEditor('createContainer', 'popup', { title: 'Terms', trigger_label: 'Read them', size: 'lg' });
721
+ ge.createContainer('accordion', { items: 3, stay_open: true });
722
+ ge.createContainer('popup', { title: 'Terms', trigger_label: 'Read them', size: 'lg' });
664
723
  ```
665
724
 
666
725
  An accordion opens and closes from its headers while editing, and what you
@@ -684,16 +743,16 @@ __`locale`:__ The code of a locale in `$.fn.gridEditor.locales`. Default `'en'`.
684
743
  __`locale_strings`:__ Overrides for individual keys, without a locale file.
685
744
 
686
745
  ```javascript
687
- $('#myGrid').gridEditor({
746
+ new GridEditor('#myGrid', {
688
747
  locale: 'es',
689
748
  locale_strings: { 'tool.move': 'Arrastrar' },
690
749
  });
691
750
  ```
692
751
 
693
- __`source_textarea`:__ Allows to set an already existing textarea as input for grid editor.
752
+ __`source_textarea`:__ Allows to set an already existing textarea as input for grid editor: an element, or a selector.
694
753
 
695
754
  ```javascript
696
- $('#myGrid').gridEditor({
755
+ new GridEditor('#myGrid', {
697
756
  source_textarea: 'textarea.myTextarea',
698
757
  });
699
758
  ```
@@ -701,9 +760,8 @@ $('#myGrid').gridEditor({
701
760
  You will have write back the content to the textarea before saving, for example in this way:
702
761
 
703
762
  ```javascript
704
- $('form.myForm').on('submit', function() {
705
- var html = $('#myGrid').gridEditor('getHtml');
706
- $('textarea.myTextarea').val(html);
763
+ document.querySelector('form.myForm').addEventListener('submit', function() {
764
+ document.querySelector('textarea.myTextarea').value = ge.getHtml();
707
765
  });
708
766
  ```
709
767
 
@@ -715,7 +773,7 @@ hand, and back again with what was written.
715
773
  __`edit_source`:__ Whether the toolbar has that button. Default value: `true`.
716
774
 
717
775
  ```javascript
718
- $('#myGrid').gridEditor({
776
+ new GridEditor('#myGrid', {
719
777
  edit_source: false,
720
778
  });
721
779
  ```
@@ -740,7 +798,7 @@ plugin's defaults: `mode: 'htmlmixed'`, `lineNumbers`, `lineWrapping`, a tab
740
798
  of 2.
741
799
 
742
800
  ```javascript
743
- $('#myGrid').gridEditor({
801
+ new GridEditor('#myGrid', {
744
802
  codemirror: { config: { theme: 'monokai' } },
745
803
  });
746
804
  ```
@@ -765,7 +823,7 @@ same way, `codemirror.config` included, and a textarea without it.
765
823
  ### Rich text editor options
766
824
 
767
825
  Grid editor comes with support for the following rich text editors (RTEs), each a plugin of its own to load after the editor:
768
- * [TinyMCE](http://www.tinymce.com/) 6 - `dist/plugins/grideditor.tinymce.min.js` - [(example)](example/basic.html)
826
+ * [TinyMCE](http://www.tinymce.com/) 7 - `dist/plugins/grideditor.tinymce.min.js` - [(example)](example/basic.html)
769
827
  * [summernote](http://summernote.org/) 0.9 - `dist/plugins/grideditor.summernote.min.js` - [(example)](example/summernote.html)
770
828
  * [CKEditor](http://ckeditor.com/) 4 - `dist/plugins/grideditor.ckeditor.min.js` - [(example)](example/ckeditor.html)
771
829
 
@@ -779,7 +837,7 @@ it is missing. Another editor is a plugin of your own:
779
837
  __`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.
780
838
 
781
839
  ```javascript
782
- $('#myGrid').gridEditor({
840
+ new GridEditor('#myGrid', {
783
841
  content_types: ['summernote'],
784
842
  });
785
843
  ```
@@ -789,7 +847,7 @@ See the [CKEditor documentation](http://docs.ckeditor.com/).
789
847
  Also check out the [ckeditor example](example/ckeditor.html).
790
848
 
791
849
  ```javascript
792
- $('#myGrid').gridEditor({
850
+ new GridEditor('#myGrid', {
793
851
  ckeditor: {
794
852
  config: { language: 'fr' }
795
853
  }
@@ -801,7 +859,7 @@ See the [summernote documentation](http://summernote.org/deep-dive/).
801
859
  Also check out the [summernote example](example/summernote.html).
802
860
 
803
861
  ```javascript
804
- $('#myGrid').gridEditor({
862
+ new GridEditor('#myGrid', {
805
863
  summernote: {
806
864
  config: { shortcuts: false }
807
865
  }
@@ -809,11 +867,11 @@ $('#myGrid').gridEditor({
809
867
  ```
810
868
 
811
869
  __`tinymce.config`:__ Specify tinyMCE config, when using the `tinymce` `content_types`.
812
- See the [tinyMCE documentation](https://www.tiny.cloud/docs/tinymce/6/).
870
+ See the [tinyMCE documentation](https://www.tiny.cloud/docs/tinymce/7/).
813
871
  Also check out the [tinymce example](example/basic.html).
814
872
 
815
873
  ```javascript
816
- $('#myGrid').gridEditor({
874
+ new GridEditor('#myGrid', {
817
875
  tinymce: {
818
876
  config: { paste_as_text: true }
819
877
  }
@@ -824,6 +882,24 @@ Grid editor passes `promotion: false`, so tinyMCE's "Upgrade" badge does not
824
882
  appear in the menubar of an inline editor sitting in someone's page. Pass
825
883
  `promotion: true` in your own config to get it back.
826
884
 
885
+ tinyMCE 7 is licensed GPL-2.0-or-later, and asks for a `license_key`: pass
886
+ `license_key: 'gpl'` to accept the GPL, or your own key if you have a
887
+ commercial licence. Without one it runs in evaluation mode and says so in the
888
+ console. Grid editor does not pass one for you, since the licence is yours to
889
+ choose.
890
+
891
+ ```javascript
892
+ new GridEditor('#myGrid', {
893
+ tinymce: {
894
+ config: { license_key: 'gpl' }
895
+ }
896
+ });
897
+ ```
898
+
899
+ Use 7.9.3 or later: every tinyMCE 6 release, and 7.x before 7.9.3, has known
900
+ cross-site scripting vulnerabilities. The integration still works with
901
+ tinyMCE 6, but the examples and tests run on 7.9.3.
902
+
827
903
 
828
904
  Upgrading
829
905
  ---------