@themarioga/grid-editor 9.0.0-beta.6 → 9.0.0-beta.8

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 (103) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +54 -27
  3. package/UPGRADING.md +1 -1
  4. package/dist/grideditor.bundle.min.js +2 -2
  5. package/dist/grideditor.css +24 -3
  6. package/dist/grideditor.d.ts +27 -2
  7. package/dist/grideditor.esm.js +64 -7
  8. package/dist/grideditor.js +64 -7
  9. package/dist/grideditor.min.css +1 -1
  10. package/dist/grideditor.min.css.map +1 -1
  11. package/dist/grideditor.min.js +1 -1
  12. package/dist/grideditor.min.js.map +3 -3
  13. package/dist/locales/grideditor.es.esm.js +2 -0
  14. package/dist/locales/grideditor.es.js +2 -0
  15. package/dist/locales/grideditor.es.min.js +1 -1
  16. package/dist/locales/grideditor.es.min.js.map +2 -2
  17. package/dist/plugins/grideditor.accordion.esm.js +9 -0
  18. package/dist/plugins/grideditor.accordion.js +9 -0
  19. package/dist/plugins/grideditor.accordion.min.js +1 -1
  20. package/dist/plugins/grideditor.accordion.min.js.map +3 -3
  21. package/dist/plugins/grideditor.card.min.js +1 -1
  22. package/dist/plugins/grideditor.card.min.js.map +1 -1
  23. package/dist/plugins/grideditor.carousel.esm.js +3 -0
  24. package/dist/plugins/grideditor.carousel.js +3 -0
  25. package/dist/plugins/grideditor.carousel.min.js +1 -1
  26. package/dist/plugins/grideditor.carousel.min.js.map +3 -3
  27. package/dist/plugins/grideditor.ckeditor.esm.js +9 -0
  28. package/dist/plugins/grideditor.ckeditor.js +9 -0
  29. package/dist/plugins/grideditor.ckeditor.min.js +1 -1
  30. package/dist/plugins/grideditor.ckeditor.min.js.map +3 -3
  31. package/dist/plugins/grideditor.clipboard.esm.js +44 -7
  32. package/dist/plugins/grideditor.clipboard.js +44 -7
  33. package/dist/plugins/grideditor.clipboard.min.js +1 -1
  34. package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
  35. package/dist/plugins/grideditor.codemirror-inline.min.js.map +1 -1
  36. package/dist/plugins/grideditor.codemirror.min.js.map +1 -1
  37. package/dist/plugins/grideditor.elements.esm.js +3 -0
  38. package/dist/plugins/grideditor.elements.js +3 -0
  39. package/dist/plugins/grideditor.elements.min.js +1 -1
  40. package/dist/plugins/grideditor.elements.min.js.map +3 -3
  41. package/dist/plugins/grideditor.gutters.min.js.map +1 -1
  42. package/dist/plugins/grideditor.history.esm.js +1 -1
  43. package/dist/plugins/grideditor.history.js +1 -1
  44. package/dist/plugins/grideditor.history.min.js +1 -1
  45. package/dist/plugins/grideditor.history.min.js.map +2 -2
  46. package/dist/plugins/grideditor.inline-style.esm.js +66 -3
  47. package/dist/plugins/grideditor.inline-style.js +66 -3
  48. package/dist/plugins/grideditor.inline-style.min.js +4 -4
  49. package/dist/plugins/grideditor.inline-style.min.js.map +3 -3
  50. package/dist/plugins/grideditor.offcanvas.min.js.map +1 -1
  51. package/dist/plugins/grideditor.order.min.js +1 -1
  52. package/dist/plugins/grideditor.order.min.js.map +1 -1
  53. package/dist/plugins/grideditor.popup.min.js.map +1 -1
  54. package/dist/plugins/grideditor.sections.esm.js +9 -0
  55. package/dist/plugins/grideditor.sections.js +9 -0
  56. package/dist/plugins/grideditor.sections.min.js +1 -1
  57. package/dist/plugins/grideditor.sections.min.js.map +3 -3
  58. package/dist/plugins/grideditor.summernote.esm.js +9 -0
  59. package/dist/plugins/grideditor.summernote.js +9 -0
  60. package/dist/plugins/grideditor.summernote.min.js +1 -1
  61. package/dist/plugins/grideditor.summernote.min.js.map +3 -3
  62. package/dist/plugins/grideditor.tabs.esm.js +3 -0
  63. package/dist/plugins/grideditor.tabs.js +3 -0
  64. package/dist/plugins/grideditor.tabs.min.js +1 -1
  65. package/dist/plugins/grideditor.tabs.min.js.map +3 -3
  66. package/dist/plugins/grideditor.tinymce.esm.js +9 -0
  67. package/dist/plugins/grideditor.tinymce.js +9 -0
  68. package/dist/plugins/grideditor.tinymce.min.js +1 -1
  69. package/dist/plugins/grideditor.tinymce.min.js.map +3 -3
  70. package/docs/events.md +6 -1
  71. package/docs/locale-keys.md +2 -0
  72. package/docs/plugins.md +9 -7
  73. package/example/adapter.html +11 -1
  74. package/example/clipboard.html +7 -4
  75. package/example/{autocols.html → columns.html} +61 -20
  76. package/example/containers.html +13 -2
  77. package/example/{attributes.html → custom-plugins.html} +130 -12
  78. package/example/elements.html +13 -2
  79. package/example/history.html +6 -3
  80. package/example/index.html +30 -81
  81. package/example/playground.html +840 -0
  82. package/example/style.html +291 -0
  83. package/example/text-editors.html +320 -0
  84. package/package.json +1 -1
  85. package/src/js/dom.js +6 -0
  86. package/src/js/grideditor.js +69 -7
  87. package/src/js/inline-style/accordion.js +4 -3
  88. package/src/js/inline-style/fields.js +56 -3
  89. package/src/js/inline-style/options.js +12 -0
  90. package/src/js/locales/grideditor.es.js +2 -0
  91. package/src/js/plugins/grideditor.clipboard.js +61 -11
  92. package/src/js/plugins/grideditor.history.js +3 -3
  93. package/src/js/plugins/grideditor.inline-style.js +10 -0
  94. package/src/js/text/grideditor.text.js +1 -1
  95. package/src/less/grideditor.less +26 -3
  96. package/types/grideditor.d.ts +27 -2
  97. package/example/breakpoints.html +0 -100
  98. package/example/ckeditor.html +0 -110
  99. package/example/custom_editor.html +0 -212
  100. package/example/inline-style.html +0 -163
  101. package/example/plugins.html +0 -251
  102. package/example/summernote.html +0 -114
  103. package/example/utilities.html +0 -200
@@ -0,0 +1,291 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+
6
+ <!-- CSS dependencies -->
7
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
8
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
9
+
10
+ <!-- Javascript dependencies -->
11
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
12
+
13
+ <!-- Grid editor CSS -->
14
+ <link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
15
+
16
+ <!-- The editor and the plugins that style a node. Each is a file of its
17
+ own, and loading it is what puts its fields in the settings panels.
18
+ The grid's utilities - order, a column's align-self and gutters -
19
+ are in the Responsive section; the inline-style plugin edits inline
20
+ css, and display, flex, spacing, text alignment, sticky and float,
21
+ in its Style accordion. Tabs and elements are here so there is one
22
+ of each kind of node. -->
23
+ <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
24
+ <script src="../dist/grideditor.min.js"></script>
25
+ <script src="../dist/plugins/grideditor.order.min.js"></script>
26
+ <script src="../dist/plugins/grideditor.alignment.min.js"></script>
27
+ <script src="../dist/plugins/grideditor.gutters.min.js"></script>
28
+ <script src="../dist/plugins/grideditor.tabs.min.js"></script>
29
+ <!-- Float works on elements, so the elements plugin comes first -->
30
+ <script src="../dist/plugins/grideditor.elements.min.js"></script>
31
+ <script src="../dist/plugins/grideditor.inline-style.min.js"></script>
32
+
33
+ <script>
34
+ document.addEventListener('DOMContentLoaded', function() {
35
+ var grid = document.getElementById('myGrid');
36
+ var panel = document.getElementById('panel');
37
+ var narrow = document.getElementById('narrow');
38
+ var browser = document.getElementById('browser');
39
+ var editor;
40
+
41
+ // A file browser of the page's own: a Bootstrap modal with some
42
+ // pictures. Closing it without choosing is a cancel
43
+ var pictures = document.getElementById('pictures');
44
+ var picturesModal = new bootstrap.Modal(pictures);
45
+ var onPicked = null;
46
+ pictures.addEventListener('click', function(e) {
47
+ var picture = e.target.closest('[data-url]');
48
+ if (!picture || !onPicked) { return; }
49
+ var done = onPicked;
50
+ onPicked = null;
51
+ picturesModal.hide();
52
+ done(picture.getAttribute('data-url'));
53
+ });
54
+ pictures.addEventListener('hidden.bs.modal', function() { onPicked = null; });
55
+
56
+ function browse(done) {
57
+ onPicked = done;
58
+ picturesModal.show();
59
+ }
60
+
61
+ function start() {
62
+ editor = new GridEditor(grid, {
63
+ new_row_layouts: [[12], [6,6], [4,4,4], [8,4]],
64
+ content_types: [],
65
+
66
+ // Where a node's settings open: 'offcanvas', the default,
67
+ // 'popover', 'modal', 'inline' in its drawer, or 'sidebar',
68
+ // a panel that stays and shows what is clicked. In a
69
+ // popover, or inline, the Style accordion opens in a dialog
70
+ settings_panel: panel.value,
71
+
72
+ // Every section, unless the host says otherwise: this
73
+ // leaves out position and keeps the border section to
74
+ // three fields with no chips
75
+ inline_style: Object.assign(narrow.checked ? {
76
+ sections: {
77
+ position: false,
78
+ border: { properties: ['border-width', 'border-style', 'border-color'], catalog: false },
79
+ },
80
+ } : {}, browser.checked ? { browse: browse } : {}),
81
+ });
82
+ }
83
+ start();
84
+
85
+ // The same canvas, started again with the other settings
86
+ function restart() {
87
+ var html = editor.getHtml();
88
+ editor.destroy();
89
+ grid.innerHTML = html;
90
+ start();
91
+ }
92
+ panel.addEventListener('change', restart);
93
+ narrow.addEventListener('change', restart);
94
+ browser.addEventListener('change', restart);
95
+
96
+ // Every change to a utility is announced, like any other operation
97
+ grid.addEventListener('grideditor:after-utility', function(e) {
98
+ var payload = e.detail;
99
+ document.getElementById('last').textContent = payload.family + ' at ' + payload.breakpoint + ': ' +
100
+ (payload.from === null ? 'default' : payload.from) + ' → ' +
101
+ (payload.to === null ? 'inherit' : payload.to);
102
+ });
103
+
104
+ // The button shows the html in place of the editor, and pressed again,
105
+ // the editor
106
+ var output = document.getElementById('output');
107
+ var outputLabel = output.textContent;
108
+ output.addEventListener('click', function() {
109
+ var showing = document.body.classList.toggle('showing-html');
110
+ if (showing) { document.getElementById('html').textContent = editor.getHtml(); }
111
+ output.textContent = showing ? 'Back to the editor' : outputLabel;
112
+ });
113
+ });
114
+ </script>
115
+
116
+ <title>Grid Editor style and utilities example</title>
117
+ <style>
118
+ /* The html, shown in place of the editor and its toolbar */
119
+ body:not(.showing-html) #html { display: none; }
120
+ .showing-html #myGrid, .showing-html .ge-mainControls { display: none; }
121
+ </style>
122
+ </head>
123
+ <body>
124
+ <!-- Back to the demo index -->
125
+ <div class="container pt-3">
126
+ <a class="link-secondary" href="index.html"><i class="bi bi-arrow-left"></i> All demos</a>
127
+ </div>
128
+
129
+ <!-- The page's own file browser, given to the editor as inline_style.browse -->
130
+ <div class="modal fade" id="pictures" tabindex="-1" aria-labelledby="pictures-title" aria-hidden="true">
131
+ <div class="modal-dialog modal-sm">
132
+ <div class="modal-content">
133
+ <div class="modal-header">
134
+ <h2 class="modal-title h6" id="pictures-title">Pictures</h2>
135
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
136
+ </div>
137
+ <div class="modal-body d-flex gap-2">
138
+ <button type="button" class="btn p-4" style="background: #f4a261" data-url="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23f4a261'/%3E%3C/svg%3E" title="sand"></button>
139
+ <button type="button" class="btn p-4" style="background: #2a9d8f" data-url="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='8' height='8' fill='%232a9d8f'/%3E%3C/svg%3E" title="sea"></button>
140
+ <button type="button" class="btn p-4" style="background: #264653" data-url="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='8' height='8' fill='%23264653'/%3E%3C/svg%3E" title="night"></button>
141
+ </div>
142
+ </div>
143
+ </div>
144
+ </div>
145
+
146
+ <div class="container">
147
+
148
+ <div class="row my-3">
149
+ <div class="col-lg-8">
150
+ <h1 class="h4">Style and responsive utilities</h1>
151
+ <p class="form-text">
152
+ <strong>Inline style.</strong> The gear of a row, a column,
153
+ a container, a tab, an element or a section has a
154
+ <strong>Style</strong> accordion: size, spacing, border,
155
+ background, text, typography, display, flex, position and
156
+ free css. What you type is written to the node's own
157
+ <code>style</code>; a value the browser does not take is
158
+ marked and not written. The inline style is the same at
159
+ every size.
160
+ </p>
161
+ <p class="form-text">
162
+ <strong>Bootstrap's classes.</strong> Each section also
163
+ offers Bootstrap's classes for what it styles, as chips:
164
+ one puts its class in the classes field, and pressing it
165
+ again takes it off. Bootstrap's utilities are
166
+ <code>!important</code>, so a field whose property a class
167
+ on the node also sets says the class wins.
168
+ </p>
169
+ <p class="form-text">
170
+ <strong>Per breakpoint.</strong> Padding and margin, text
171
+ alignment, display, flex, sticky and float, in the Style
172
+ accordion, and order, a column's alignment and gutters, in
173
+ the <strong>Responsive</strong> section, are Bootstrap's
174
+ responsive classes. Pick a breakpoint in the toolbar's
175
+ dropdown and a change is written for that breakpoint alone;
176
+ in <strong>All sizes</strong> it is written once, for
177
+ every size. Every field says what the breakpoint inherits
178
+ and from where.
179
+ </p>
180
+ <ul class="form-text ps-3">
181
+ <li><strong>Display:</strong> the eye in a drawer hides the
182
+ node in the view being edited, faded so you can show it
183
+ again. The sidebar of the third row is hidden on phones
184
+ and tablets.</li>
185
+ <li><strong>Order:</strong> the arrows in a column's drawer
186
+ move it without moving the markup. In the fourth row,
187
+ "Second" comes first on phones only.</li>
188
+ <li><strong>Gutters:</strong> the fourth row has none on
189
+ phones and wide ones from small desktop up.</li>
190
+ <li><strong>Alignment and spacing:</strong> the fifth row
191
+ centres its column from small desktop up, which gets
192
+ more padding and centred text there too.</li>
193
+ <li><strong>Float:</strong> the quote in the last row floats
194
+ to the end from tablet up, with the text flowing round it.</li>
195
+ <li><strong>Flex:</strong> a node that is flex has its drawer
196
+ on top, out of the flow, so its content is laid out as
197
+ on the page.</li>
198
+ </ul>
199
+ <div class="d-flex flex-wrap align-items-center gap-3 mb-3">
200
+ <div class="d-flex align-items-center gap-2">
201
+ <label class="form-label mb-0" for="panel">A gear opens its settings in</label>
202
+ <select class="form-select form-select-sm w-auto" id="panel">
203
+ <option value="offcanvas">a side panel (offcanvas)</option>
204
+ <option value="popover">a popover</option>
205
+ <option value="modal">a modal</option>
206
+ <option value="inline">the drawer itself (inline)</option>
207
+ <option value="sidebar">a sidebar that stays (click a node)</option>
208
+ </select>
209
+ </div>
210
+ <div class="form-check mb-0">
211
+ <input class="form-check-input" type="checkbox" id="narrow">
212
+ <label class="form-check-label" for="narrow">Fewer sections: no position, a shorter border</label>
213
+ </div>
214
+ <div class="form-check mb-0">
215
+ <input class="form-check-input" type="checkbox" id="browser">
216
+ <label class="form-check-label" for="browser">A file browser for the background image</label>
217
+ </div>
218
+ </div>
219
+ <p class="form-text">Last utility change: <span id="last">none yet</span></p>
220
+ <button class="btn btn-sm btn-secondary" id="output" type="button">Show the html this produces</button>
221
+ <pre id="html" class="form-text"></pre>
222
+ </div>
223
+ </div>
224
+
225
+ <div id="myGrid">
226
+
227
+ <div class="row" style="background-color: #f0f4ff; border-radius: 12px;">
228
+ <div class="col-12 col-md-8" style="padding-top: 1rem; padding-bottom: 1rem;">
229
+ <h2 class="h5">Styled inline</h2>
230
+ <p>This row has a background and a radius in its <code>style</code>; open its gear and look in Background and Border.</p>
231
+ </div>
232
+ <div class="col-12 col-md-4 shadow-sm rounded-3" style="box-shadow: 0 4px 12px rgba(0, 0, 0, .15)">
233
+ <h2 class="h5">A class and a style</h2>
234
+ <p>It has <code>shadow-sm</code> and an inline shadow: the class wins, and the Border section says so.</p>
235
+ </div>
236
+ </div>
237
+
238
+ <div class="row my-3">
239
+ <div class="col-12 col-md-6 d-flex flex-column flex-md-row align-items-md-center gap-3 bg-primary-subtle">
240
+ <p class="mb-0">A column made flex: its texts are stacked on phones and side by side from tablet up, with a gap between them.</p>
241
+ <p class="mb-0">Open its gear, and look in Display and Flex.</p>
242
+ </div>
243
+ <div class="col-12 col-md-6 text-bg-dark">
244
+ <p>This column has <code>text-bg-dark</code>, one of Bootstrap 5.3's colors in the Background section, with the subtle ones and the opacities.</p>
245
+ </div>
246
+ </div>
247
+
248
+ <div class="row">
249
+ <div class="col-12 col-md-8">
250
+ <h2 class="h5">Main content</h2>
251
+ <p>Full width on phones and tablets, two thirds from small desktop up. Try Size on this column: it offers only the min- and max- widths and heights, since its width is the grid's.</p>
252
+ </div>
253
+ <div class="col-12 col-md-4 d-none d-md-block">
254
+ <h2 class="h5">Sidebar</h2>
255
+ <p>Only from small desktop up: <code>d-none d-md-block</code>.</p>
256
+ </div>
257
+ </div>
258
+
259
+ <div class="row g-0 g-md-5">
260
+ <div class="col-6">
261
+ <h2 class="h5">First</h2>
262
+ <p>Change the views and the utilities of these two.</p>
263
+ </div>
264
+ <div class="col-6 order-first order-sm-0">
265
+ <h2 class="h5">Second</h2>
266
+ <p>First on phones, with <code>order-first order-sm-0</code>.</p>
267
+ </div>
268
+ </div>
269
+
270
+ <div class="row justify-content-md-center">
271
+ <div class="col-12 col-md-6 py-2 py-md-4 text-md-center">
272
+ <h2 class="h5">Centred</h2>
273
+ <p>Its row has <code>justify-content-md-center</code>, and it has <code>py-2 py-md-4</code>.</p>
274
+ </div>
275
+ </div>
276
+
277
+ <div class="row">
278
+ <div class="col-12">
279
+ <blockquote data-ge-element="quote" data-ge-label="Pull quote" class="float-sm-end ms-sm-3 p-3 border-start border-4 bg-body-tertiary" style="font-style: italic; letter-spacing: .02em">
280
+ An element, floated with <code>float-sm-end</code>, with a few classes from the catalog and some typography of its own.
281
+ </blockquote>
282
+ <p>The text after it flows round the quote from tablet up, and runs under it on phones, where it does not float. Switch between Phone and Tablet in the dropdown to see it move, or choose another float in the element's Position section.</p>
283
+ <p>A second paragraph, so there is enough text to flow.</p>
284
+ </div>
285
+ </div>
286
+
287
+ </div> <!-- /#myGrid -->
288
+ </div> <!-- /.container -->
289
+
290
+ </body>
291
+ </html>
@@ -0,0 +1,320 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+
7
+ <!-- CSS dependencies -->
8
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
9
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
10
+
11
+ <!-- Javascript dependencies. jQuery is summernote's: the editor itself
12
+ does not need it, and this page loads no jQuery adapter -->
13
+ <script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
14
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
15
+
16
+ <!-- TinyMCE 7 -->
17
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/7.9.3/tinymce.min.js"></script>
18
+ <!-- CKEditor 5: its browser build, and its stylesheet -->
19
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ckeditor5@48.5.2/dist/browser/ckeditor5.css">
20
+ <script src="https://cdn.jsdelivr.net/npm/ckeditor5@48.5.2/dist/browser/ckeditor5.umd.js"></script>
21
+ <!-- Summernote, the Bootstrap 5 build -->
22
+ <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.9.1/summernote-bs5.min.css" />
23
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.9.1/summernote-bs5.min.js"></script>
24
+
25
+ <!-- Grid editor CSS -->
26
+ <link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
27
+ <!-- Grid editor javascript -->
28
+ <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
29
+ <script src="../dist/grideditor.min.js"></script>
30
+ <!-- Each text editor is a plugin of its own, loaded after the editor.
31
+ content_types chooses which of the loaded ones an editor offers -->
32
+ <script src="../dist/plugins/grideditor.tinymce.min.js"></script>
33
+ <script src="../dist/plugins/grideditor.ckeditor.min.js"></script>
34
+ <script src="../dist/plugins/grideditor.summernote.min.js"></script>
35
+
36
+ <!-- A text editor of the page's own. It is a feature plugin like any
37
+ other: the core knows nothing of text, and asks the plugins through
38
+ textTypes which types there are. This one edits with the browser's
39
+ own contenteditable. -->
40
+ <script id="simpletext-plugin">
41
+ (function() {
42
+
43
+ Object.assign(GridEditor.locales.en, {
44
+ 'simpletext.label': 'Simple text',
45
+ 'simpletext.add': 'Simple text',
46
+ });
47
+
48
+ var TYPE = 'simpletext';
49
+
50
+ GridEditor.features.simpletext = function(ge) {
51
+
52
+ /** A content area of this plugin's: its type is on it. */
53
+ function isOurs(area) {
54
+ return !!area && area.getAttribute('data-ge-content-type') === TYPE;
55
+ }
56
+
57
+ function start(area) {
58
+ if (area.classList.contains('ge-rte-active')) { return; }
59
+
60
+ area.classList.add('ge-rte-active');
61
+ area.setAttribute('contenteditable', 'true');
62
+ area.focus();
63
+ }
64
+
65
+ // Whatever start put on the content area comes off: what is
66
+ // left is what getHtml saves
67
+ function stop(area) {
68
+ area.classList.remove('ge-rte-active');
69
+ area.removeAttribute('contenteditable');
70
+ }
71
+
72
+ /** The content area a text block holds. */
73
+ function areaOf(textBlock) {
74
+ return textBlock.querySelector(':scope > .ge-content');
75
+ }
76
+
77
+ /**
78
+ * A text's drawer. The editor wraps each content area of a
79
+ * column in a .ge-text-block while editing, and leaves the
80
+ * drawer of a type a plugin declares to that plugin.
81
+ */
82
+ function createDrawer(textBlock) {
83
+ var area = areaOf(textBlock);
84
+ var drawer = document.createElement('div');
85
+ drawer.className = 'ge-tools-drawer ge-text-drawer';
86
+ textBlock.insertBefore(drawer, textBlock.firstChild);
87
+
88
+ ge.createMoveTool(drawer);
89
+ ge.createTool(drawer, ge.t('tool.delete_text'), 'ge-delete-text', 'bi bi-trash', function() {
90
+ ge.deleteNode('text', area, ge.t('confirm.delete_text'), function(removed) {
91
+ stop(area);
92
+ // Folded away, then gone
93
+ var fold = textBlock.animate(
94
+ [{ height: textBlock.offsetHeight + 'px', opacity: 1 }, { height: '0px', opacity: 0 }],
95
+ { duration: 400, easing: 'ease-in-out' }
96
+ );
97
+ textBlock.style.overflow = 'hidden';
98
+ fold.onfinish = function() {
99
+ textBlock.remove();
100
+ removed();
101
+ };
102
+ });
103
+ });
104
+ }
105
+
106
+ function onClick(e) {
107
+ var area = e.target.closest('.ge-content');
108
+ if (area && ge.canvas.contains(area) && isOurs(area)) { start(area); }
109
+ }
110
+
111
+ return {
112
+ // The types this plugin edits. The core uses them to know
113
+ // whose a content area is, and to offer them when the
114
+ // host's plain content is clicked: edit() is handed the
115
+ // content area once the core has written the type on it
116
+ textTypes: function() {
117
+ return [{
118
+ type: TYPE,
119
+ label: ge.t('simpletext.label'),
120
+ edit: function(area) {
121
+ var textBlock = area.parentElement;
122
+ if (textBlock.classList.contains('ge-text-block') &&
123
+ !textBlock.querySelector(':scope > .ge-tools-drawer')) {
124
+ createDrawer(textBlock);
125
+ }
126
+
127
+ start(area);
128
+ },
129
+ }];
130
+ },
131
+
132
+ // A button to make a new text, in a row of its own or
133
+ // where it is dropped in a column
134
+ toolbar: [{
135
+ labelKey: 'simpletext.add',
136
+ iconClass: 'bi bi-fonts',
137
+ kind: 'text',
138
+ inColumn: true,
139
+ create: function() {
140
+ var area = document.createElement('div');
141
+ area.className = 'ge-content ge-content-type-' + TYPE;
142
+ area.setAttribute('data-ge-content-type', TYPE);
143
+ area.innerHTML = '<p>Write here</p>';
144
+ return area;
145
+ },
146
+ }],
147
+
148
+ onInit: function() {
149
+ ge.canvas.querySelectorAll('.ge-text-block').forEach(function(textBlock) {
150
+ if (textBlock.querySelector(':scope > .ge-tools-drawer')) { return; }
151
+ if (isOurs(areaOf(textBlock))) { createDrawer(textBlock); }
152
+ });
153
+
154
+ // One listener, however many times the canvas is initialized
155
+ ge.canvas.removeEventListener('click', onClick);
156
+ ge.canvas.addEventListener('click', onClick);
157
+ },
158
+
159
+ // Before the drawers and the text blocks come off
160
+ onBeforeDeinit: function() {
161
+ ge.canvas.querySelectorAll('.ge-content').forEach(function(area) {
162
+ if (isOurs(area)) { stop(area); }
163
+ });
164
+ },
165
+
166
+ onDeinit: function() {
167
+ ge.canvas.removeEventListener('click', onClick);
168
+ },
169
+ };
170
+ };
171
+
172
+ })();
173
+ </script>
174
+
175
+ <script>
176
+ document.addEventListener('DOMContentLoaded', function() {
177
+ var MODES = ['tinymce', 'ckeditor', 'summernote', 'simpletext', 'all'];
178
+ var mode = new URLSearchParams(location.search).get('editor');
179
+ if (MODES.indexOf(mode) === -1) { mode = 'tinymce'; }
180
+
181
+ document.querySelectorAll('[data-mode]').forEach(function(node) {
182
+ var on = node.getAttribute('data-mode') === mode;
183
+ if (node.classList.contains('nav-link')) {
184
+ node.classList.toggle('active', on);
185
+ } else {
186
+ node.hidden = !on;
187
+ }
188
+ });
189
+
190
+ // A text saved with each editor this mode uses, after one block
191
+ // of the host's plain content that a click makes a text
192
+ var shipped = ['tinymce', 'ckeditor', 'summernote'];
193
+ var types = mode === 'all' ? shipped.concat('simpletext') : [mode];
194
+ var grid = document.getElementById('myGrid');
195
+ var columns = types.map(function(type) {
196
+ return '<div class="col-md">' +
197
+ '<div class="ge-content ge-content-type-' + type + '" data-ge-content-type="' + type + '">' +
198
+ '<h3>' + document.querySelector('.nav-link[data-mode="' + type + '"]').textContent + '</h3>' +
199
+ '<p>A text saved with this editor: a click edits it.</p></div></div>';
200
+ });
201
+ grid.innerHTML =
202
+ '<div class="row"><div class="col-12">' +
203
+ '<h1>Plain content</h1>' +
204
+ '<p>Loose markup of the page\'s own, with no text editor\'s type on it. ' +
205
+ 'Click it and it becomes a text' + (types.length > 1 ? ' of the editor you choose.' : '.') + '</p>' +
206
+ '</div></div>' +
207
+ '<div class="row">' + columns.join('') + '</div>';
208
+
209
+ var editor = new GridEditor(grid, {
210
+ new_row_layouts: [[12], [6, 6], [4, 4, 4]],
211
+
212
+ // The shipped editors this mode offers, in this order. The
213
+ // page's own editor is not one of them: it is a plugin, which
214
+ // the plugins setting chooses
215
+ content_types: types.filter(function(type) { return shipped.indexOf(type) !== -1; }),
216
+ plugins: types.indexOf('simpletext') !== -1 ? ['simpletext'] : [],
217
+
218
+ // tinyMCE 7 and CKEditor 5 are GPL-2.0-or-later: 'gpl' and
219
+ // 'GPL' accept that licence. A commercial licence passes its
220
+ // own key here instead
221
+ tinymce: { config: { license_key: 'gpl' } },
222
+ ckeditor: {
223
+ // Anything InlineEditor.create takes, over the plugin's
224
+ // own defaults: its plugins, toolbar and headings
225
+ config: { licenseKey: 'GPL' },
226
+ },
227
+ // Anything summernote takes, over the plugin's own defaults
228
+ summernote: {
229
+ config: {
230
+ callbacks: {
231
+ onInit: function() { console.log('summernote is open'); },
232
+ },
233
+ },
234
+ },
235
+ });
236
+
237
+ // The button shows the html in place of the editor, and pressed again,
238
+ // the editor
239
+ var output = document.getElementById('output');
240
+ var outputLabel = output.textContent;
241
+ output.addEventListener('click', function() {
242
+ var showing = document.body.classList.toggle('showing-html');
243
+ if (showing) { document.getElementById('html').textContent = editor.getHtml(); }
244
+ output.textContent = showing ? 'Back to the editor' : outputLabel;
245
+ });
246
+ });
247
+ </script>
248
+
249
+ <title>Grid Editor example - text editors</title>
250
+ <style>
251
+ /* The html, shown in place of the editor and its toolbar */
252
+ body:not(.showing-html) #html { display: none; }
253
+ .showing-html #myGrid, .showing-html .ge-mainControls { display: none; }
254
+ </style>
255
+ </head>
256
+ <body>
257
+ <!-- Back to the demo index -->
258
+ <div class="container pt-3">
259
+ <a class="link-secondary" href="index.html"><i class="bi bi-arrow-left"></i> All demos</a>
260
+ </div>
261
+
262
+ <div class="container py-3">
263
+ <h2>Text editors</h2>
264
+ <p class="text-body-secondary">
265
+ What edits the text in a column is a plugin: TinyMCE, CKEditor and
266
+ summernote ship with grid-editor, and any other is a plugin of
267
+ your own. This page loads all four; <code>content_types</code>
268
+ chooses the shipped ones an editor offers, and the
269
+ <code>plugins</code> setting the page's own.
270
+ </p>
271
+
272
+ <ul class="nav nav-pills mb-3">
273
+ <li class="nav-item"><a class="nav-link" data-mode="tinymce" href="?editor=tinymce">TinyMCE</a></li>
274
+ <li class="nav-item"><a class="nav-link" data-mode="ckeditor" href="?editor=ckeditor">CKEditor 5</a></li>
275
+ <li class="nav-item"><a class="nav-link" data-mode="summernote" href="?editor=summernote">Summernote</a></li>
276
+ <li class="nav-item"><a class="nav-link" data-mode="simpletext" href="?editor=simpletext">Simple text</a></li>
277
+ <li class="nav-item"><a class="nav-link" data-mode="all" href="?editor=all">All together</a></li>
278
+ </ul>
279
+
280
+ <p class="text-body-secondary" data-mode="tinymce" hidden>
281
+ <a href="https://www.tiny.cloud/">TinyMCE</a> 7, inline:
282
+ <code>content_types: ['tinymce']</code>, and its config in
283
+ <code>tinymce.config</code>.
284
+ </p>
285
+ <p class="text-body-secondary" data-mode="ckeditor" hidden>
286
+ <a href="https://ckeditor.com/ckeditor-5/">CKEditor 5</a>, its
287
+ browser build: <code>content_types: ['ckeditor']</code>, and
288
+ anything <code>InlineEditor.create</code> takes in
289
+ <code>ckeditor.config</code>. It does not start without a
290
+ <code>licenseKey</code>, and the console says why.
291
+ </p>
292
+ <p class="text-body-secondary" data-mode="summernote" hidden>
293
+ <a href="https://summernote.org/">Summernote</a> 0.9, the
294
+ Bootstrap 5 build: <code>content_types: ['summernote']</code>, and
295
+ its options in <code>summernote.config</code>. Summernote needs
296
+ jQuery; grid-editor does not, and drives it without the jQuery
297
+ adapter.
298
+ </p>
299
+ <p class="text-body-secondary" data-mode="simpletext" hidden>
300
+ No shipped editor offered: <code>content_types: []</code>. The text
301
+ editor is the plugin in this page's source, a few dozen lines on
302
+ the browser's <code>contenteditable</code>, declaring its type
303
+ with the <code>textTypes</code> hook. See
304
+ <a href="../docs/plugins.md#text">docs/plugins.md</a>.
305
+ </p>
306
+ <p class="text-body-secondary" data-mode="all" hidden>
307
+ Every editor at once. The toolbar has a <em>Text</em> button per
308
+ editor, a click on the plain content asks which one to make it,
309
+ and each text opens with the editor it was saved with.
310
+ </p>
311
+
312
+ <div id="myGrid"></div>
313
+
314
+ <p class="mt-4">
315
+ <button type="button" class="btn btn-outline-primary btn-sm" id="output">Show getHtml</button>
316
+ </p>
317
+ <pre class="bg-body-tertiary border rounded p-3 small" id="html"></pre>
318
+ </div>
319
+ </body>
320
+ </html>
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "version": "9.0.0-beta.6",
35
+ "version": "9.0.0-beta.8",
36
36
  "main": "dist/grideditor.js",
37
37
  "module": "dist/grideditor.esm.js",
38
38
  "types": "dist/grideditor.d.ts",
package/src/js/dom.js CHANGED
@@ -324,7 +324,13 @@ var DEFAULT_DURATION = 400;
324
324
  function animateAway(node, frames, duration, done) {
325
325
  duration = duration === undefined ? DEFAULT_DURATION : duration;
326
326
 
327
+ // Marked while it goes: the history plugin waits for it, rather than
328
+ // keep the canvas halfway through as a step of its own
329
+ addClass(node, 'ge-leaving');
330
+
327
331
  var finish = function() {
332
+ removeClass(node, 'ge-leaving');
333
+ dropEmptyClass(node);
328
334
  hide(node);
329
335
  if (done) { done(); }
330
336
  };