@themarioga/grid-editor 9.0.0-beta.7 → 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 (52) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +29 -15
  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 +20 -0
  7. package/dist/grideditor.esm.js +10 -1
  8. package/dist/grideditor.js +10 -1
  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 +1 -0
  14. package/dist/locales/grideditor.es.js +1 -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.ckeditor.min.js.map +1 -1
  18. package/dist/plugins/grideditor.inline-style.esm.js +66 -3
  19. package/dist/plugins/grideditor.inline-style.js +66 -3
  20. package/dist/plugins/grideditor.inline-style.min.js +4 -4
  21. package/dist/plugins/grideditor.inline-style.min.js.map +3 -3
  22. package/dist/plugins/grideditor.summernote.min.js.map +1 -1
  23. package/dist/plugins/grideditor.tinymce.min.js.map +1 -1
  24. package/docs/locale-keys.md +1 -0
  25. package/docs/plugins.md +7 -6
  26. package/example/adapter.html +11 -1
  27. package/example/{autocols.html → columns.html} +61 -20
  28. package/example/containers.html +13 -2
  29. package/example/{attributes.html → custom-plugins.html} +130 -12
  30. package/example/elements.html +13 -2
  31. package/example/history.html +6 -3
  32. package/example/index.html +30 -81
  33. package/example/playground.html +840 -0
  34. package/example/style.html +291 -0
  35. package/example/text-editors.html +320 -0
  36. package/package.json +1 -1
  37. package/src/js/grideditor.js +11 -1
  38. package/src/js/inline-style/accordion.js +4 -3
  39. package/src/js/inline-style/fields.js +56 -3
  40. package/src/js/inline-style/options.js +12 -0
  41. package/src/js/locales/grideditor.es.js +1 -0
  42. package/src/js/plugins/grideditor.inline-style.js +10 -0
  43. package/src/js/text/grideditor.text.js +1 -1
  44. package/src/less/grideditor.less +26 -3
  45. package/types/grideditor.d.ts +20 -0
  46. package/example/breakpoints.html +0 -100
  47. package/example/ckeditor.html +0 -110
  48. package/example/custom_editor.html +0 -212
  49. package/example/inline-style.html +0 -163
  50. package/example/plugins.html +0 -251
  51. package/example/summernote.html +0 -114
  52. package/example/utilities.html +0 -200
@@ -1,212 +0,0 @@
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 no text editor of the shipped ones: the one this page
17
- edits text with is written below -->
18
- <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
19
- <script src="../dist/grideditor.min.js"></script>
20
-
21
- <!-- A text editor of the page's own. It is a feature plugin like any
22
- other: the core knows nothing of text, and asks the plugins through
23
- textTypes which types there are. This one edits with the browser's
24
- own contenteditable. -->
25
- <script id="simpletext-plugin">
26
- (function() {
27
-
28
- Object.assign(GridEditor.locales.en, {
29
- 'simpletext.label': 'Simple text',
30
- 'simpletext.add': 'Simple text',
31
- });
32
-
33
- var TYPE = 'simpletext';
34
-
35
- GridEditor.features.simpletext = function(ge) {
36
-
37
- /** A content area of this plugin's: its type is on it. */
38
- function isOurs(area) {
39
- return !!area && area.getAttribute('data-ge-content-type') === TYPE;
40
- }
41
-
42
- function start(area) {
43
- if (area.classList.contains('ge-rte-active')) { return; }
44
-
45
- area.classList.add('ge-rte-active');
46
- area.setAttribute('contenteditable', 'true');
47
- area.focus();
48
- }
49
-
50
- // Whatever start put on the content area comes off: what is
51
- // left is what getHtml saves
52
- function stop(area) {
53
- area.classList.remove('ge-rte-active');
54
- area.removeAttribute('contenteditable');
55
- }
56
-
57
- /** The content area a text block holds. */
58
- function areaOf(textBlock) {
59
- return textBlock.querySelector(':scope > .ge-content');
60
- }
61
-
62
- /**
63
- * A text's drawer. The editor wraps each content area of a
64
- * column in a .ge-text-block while editing, and leaves the
65
- * drawer of a type a plugin declares to that plugin.
66
- */
67
- function createDrawer(textBlock) {
68
- var area = areaOf(textBlock);
69
- var drawer = document.createElement('div');
70
- drawer.className = 'ge-tools-drawer ge-text-drawer';
71
- textBlock.insertBefore(drawer, textBlock.firstChild);
72
-
73
- ge.createMoveTool(drawer);
74
- ge.createTool(drawer, ge.t('tool.delete_text'), 'ge-delete-text', 'bi bi-trash', function() {
75
- ge.deleteNode('text', area, ge.t('confirm.delete_text'), function(removed) {
76
- stop(area);
77
- // Folded away, then gone
78
- var fold = textBlock.animate(
79
- [{ height: textBlock.offsetHeight + 'px', opacity: 1 }, { height: '0px', opacity: 0 }],
80
- { duration: 400, easing: 'ease-in-out' }
81
- );
82
- textBlock.style.overflow = 'hidden';
83
- fold.onfinish = function() {
84
- textBlock.remove();
85
- removed();
86
- };
87
- });
88
- });
89
- }
90
-
91
- function onClick(e) {
92
- var area = e.target.closest('.ge-content');
93
- if (area && ge.canvas.contains(area) && isOurs(area)) { start(area); }
94
- }
95
-
96
- return {
97
- // The types this plugin edits. The core uses them to know
98
- // whose a content area is, and to offer them when the
99
- // host's plain content is clicked: edit() is handed the
100
- // content area once the core has written the type on it
101
- textTypes: function() {
102
- return [{
103
- type: TYPE,
104
- label: ge.t('simpletext.label'),
105
- edit: function(area) {
106
- var textBlock = area.parentElement;
107
- if (textBlock.classList.contains('ge-text-block') &&
108
- !textBlock.querySelector(':scope > .ge-tools-drawer')) {
109
- createDrawer(textBlock);
110
- }
111
-
112
- start(area);
113
- },
114
- }];
115
- },
116
-
117
- // A button to make a new text, in a row of its own or
118
- // where it is dropped in a column
119
- toolbar: [{
120
- labelKey: 'simpletext.add',
121
- iconClass: 'bi bi-fonts',
122
- kind: 'text',
123
- inColumn: true,
124
- create: function() {
125
- var area = document.createElement('div');
126
- area.className = 'ge-content ge-content-type-' + TYPE;
127
- area.setAttribute('data-ge-content-type', TYPE);
128
- area.innerHTML = '<p>Write here</p>';
129
- return area;
130
- },
131
- }],
132
-
133
- onInit: function() {
134
- ge.canvas.querySelectorAll('.ge-text-block').forEach(function(textBlock) {
135
- if (textBlock.querySelector(':scope > .ge-tools-drawer')) { return; }
136
- if (isOurs(areaOf(textBlock))) { createDrawer(textBlock); }
137
- });
138
-
139
- // One listener, however many times the canvas is initialized
140
- ge.canvas.removeEventListener('click', onClick);
141
- ge.canvas.addEventListener('click', onClick);
142
- },
143
-
144
- // Before the drawers and the text blocks come off
145
- onBeforeDeinit: function() {
146
- ge.canvas.querySelectorAll('.ge-content').forEach(function(area) {
147
- if (isOurs(area)) { stop(area); }
148
- });
149
- },
150
-
151
- onDeinit: function() {
152
- ge.canvas.removeEventListener('click', onClick);
153
- },
154
- };
155
- };
156
-
157
- })();
158
- </script>
159
-
160
- <script>
161
- document.addEventListener('DOMContentLoaded', function() {
162
- var editor = new GridEditor('#myGrid', {
163
- new_row_layouts: [[12], [6, 6], [4, 4, 4]],
164
- });
165
-
166
- document.getElementById('output').addEventListener('click', function() {
167
- document.getElementById('html').textContent = editor.getHtml();
168
- });
169
- });
170
- </script>
171
-
172
- <title>Grid Editor example - a text editor of your own</title>
173
- </head>
174
- <body>
175
- <!-- Back to the demo index -->
176
- <div class="container pt-3">
177
- <a class="link-secondary" href="index.html"><i class="bi bi-arrow-left"></i> All demos</a>
178
- </div>
179
-
180
- <div class="container py-3">
181
- <h2>A text editor of your own</h2>
182
- <p class="text-body-secondary">
183
- No tinyMCE, CKEditor or summernote on this page: its text editor is
184
- the plugin in the page's source, a few dozen lines on the browser's
185
- <code>contenteditable</code>. The markup below had no text editor's
186
- type on it, so the editor took it for the host's <em>plain
187
- content</em>: it can be moved and deleted, and a click makes it a
188
- text of this editor. The second column was saved as one already.
189
- See <a href="../docs/plugins.md">docs/plugins.md</a>.
190
- </p>
191
-
192
- <div id="myGrid">
193
- <div class="row">
194
- <div class="col-lg-6">
195
- <h3>Plain content</h3>
196
- <p>Loose markup of the page's own. Click it and it is a simple text.</p>
197
- </div>
198
- <div class="col-lg-6">
199
- <div class="ge-content ge-content-type-simpletext" data-ge-content-type="simpletext">
200
- <p>A simple text, saved as one: a click edits it.</p>
201
- </div>
202
- </div>
203
- </div>
204
- </div>
205
-
206
- <p class="mt-4">
207
- <button type="button" class="btn btn-outline-primary btn-sm" id="output">Show getHtml</button>
208
- </p>
209
- <pre class="bg-body-tertiary border rounded p-3 small"><code id="html"></code></pre>
210
- </div>
211
- </body>
212
- </html>
@@ -1,163 +0,0 @@
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, the elements and tabs plugins so there is one of each
17
- kind of node, and the inline-style plugin. -->
18
- <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
19
- <script src="../dist/grideditor.min.js"></script>
20
- <script src="../dist/plugins/grideditor.elements.min.js"></script>
21
- <script src="../dist/plugins/grideditor.tabs.min.js"></script>
22
- <script src="../dist/plugins/grideditor.inline-style.min.js"></script>
23
-
24
- <script>
25
- document.addEventListener('DOMContentLoaded', function() {
26
- var grid = document.getElementById('myGrid');
27
- var panel = document.getElementById('panel');
28
- var narrow = document.getElementById('narrow');
29
- var editor;
30
-
31
- function start() {
32
- editor = new GridEditor(grid, {
33
- new_row_layouts: [[12], [6,6], [4,4,4], [8,4]],
34
- content_types: [],
35
-
36
- // Where a node's settings open. In a popover, or inline
37
- // in the drawer, the Style accordion opens in a dialog
38
- settings_panel: panel.value,
39
-
40
- // Every section, unless the host says otherwise: this
41
- // leaves out position and keeps the border section to
42
- // three fields with no chips
43
- inline_style: narrow.checked ? {
44
- sections: {
45
- position: false,
46
- border: { properties: ['border-width', 'border-style', 'border-color'], catalog: false },
47
- },
48
- } : {},
49
- });
50
- }
51
- start();
52
-
53
- // The same canvas, started again with the other settings
54
- function restart() {
55
- var html = editor.getHtml();
56
- editor.destroy();
57
- grid.innerHTML = html;
58
- start();
59
- }
60
- panel.addEventListener('change', restart);
61
- narrow.addEventListener('change', restart);
62
-
63
- document.getElementById('output').addEventListener('click', function() {
64
- document.getElementById('html').textContent = editor.getHtml();
65
- });
66
- });
67
- </script>
68
-
69
- <title>Grid Editor inline style example</title>
70
- </head>
71
- <body>
72
- <!-- Back to the demo index -->
73
- <div class="container pt-3">
74
- <a class="link-secondary" href="index.html"><i class="bi bi-arrow-left"></i> All demos</a>
75
- </div>
76
-
77
- <div class="container">
78
-
79
- <div class="row my-3">
80
- <div class="col-lg-8">
81
- <h1 class="h4">Inline style</h1>
82
- <p class="form-text">
83
- The gear of a row, a column, a container, a tab, an element
84
- or a section has a <strong>Style</strong> accordion: size,
85
- spacing, border, background, text, typography, display,
86
- flex, position and free css. What you type is written to the
87
- node's own <code>style</code>; a value the browser does
88
- not take is marked and not written.
89
- </p>
90
- <p class="form-text">
91
- Each section also offers Bootstrap's classes for what it
92
- styles, as chips: one puts its class in the classes field,
93
- and pressing it again takes it off. Bootstrap's utilities
94
- are <code>!important</code>, so a field whose property a
95
- class on the node also sets says the class wins.
96
- </p>
97
- <p class="form-text">
98
- The inline style is the same at every size. Padding and
99
- margin, text alignment, display, flex, sticky and float
100
- are Bootstrap's responsive classes, edited per breakpoint
101
- in their sections: pick a breakpoint in the dropdown. A
102
- node that is flex or grid has its drawer on top, out of
103
- the flow, so its content is laid out as on the page.
104
- </p>
105
- <div class="d-flex flex-wrap align-items-center gap-3 mb-3">
106
- <div class="d-flex align-items-center gap-2">
107
- <label class="form-label mb-0" for="panel">A gear opens its settings in</label>
108
- <select class="form-select form-select-sm w-auto" id="panel">
109
- <option value="offcanvas">a side panel (offcanvas)</option>
110
- <option value="popover">a popover</option>
111
- <option value="modal">a modal</option>
112
- <option value="inline">the drawer itself (inline)</option>
113
- </select>
114
- </div>
115
- <div class="form-check mb-0">
116
- <input class="form-check-input" type="checkbox" id="narrow">
117
- <label class="form-check-label" for="narrow">Fewer sections: no position, a shorter border</label>
118
- </div>
119
- </div>
120
- <button class="btn btn-sm btn-secondary" id="output" type="button">Show the html this produces</button>
121
- <pre id="html" class="form-text"></pre>
122
- </div>
123
- </div>
124
-
125
- <div id="myGrid">
126
-
127
- <div class="row" style="background-color: #f0f4ff; border-radius: 12px;">
128
- <div class="col-12 col-md-8" style="padding-top: 1rem; padding-bottom: 1rem;">
129
- <h2 class="h5">Styled inline</h2>
130
- <p>This row has a background and a radius in its <code>style</code>; open its gear and look in Background and Border.</p>
131
- </div>
132
- <div class="col-12 col-md-4 shadow-sm rounded-3" style="box-shadow: 0 4px 12px rgba(0, 0, 0, .15)">
133
- <h2 class="h5">A class and a style</h2>
134
- <p>It has <code>shadow-sm</code> and an inline shadow: the class wins, and the Border section says so.</p>
135
- </div>
136
- </div>
137
-
138
- <div class="row my-3">
139
- <div class="col-6">
140
- <div data-ge-element="callout" data-ge-label="Callout" class="p-3 border-start border-4 bg-body-tertiary" style="font-style: italic; letter-spacing: .02em">
141
- An element, with a few classes from the catalog and some typography of its own.
142
- </div>
143
- </div>
144
- <div class="col-6">
145
- <p>Try Size on this column: it offers only the min- and max- widths and heights, since its width is the grid's.</p>
146
- </div>
147
- </div>
148
-
149
- <div class="row my-3">
150
- <div class="col-12 col-md-6 d-flex flex-column flex-md-row align-items-md-center gap-3 bg-primary-subtle">
151
- <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>
152
- <p class="mb-0">Open its gear, and look in Display and Flex.</p>
153
- </div>
154
- <div class="col-12 col-md-6 text-bg-dark">
155
- <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>
156
- </div>
157
- </div>
158
-
159
- </div> <!-- /#myGrid -->
160
- </div> <!-- /.container -->
161
-
162
- </body>
163
- </html>
@@ -1,251 +0,0 @@
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 this page offers. Loading a file is what
17
- makes its feature available; nothing here is in the main bundle. -->
18
- <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
19
- <script src="../dist/grideditor.min.js"></script>
20
- <script src="../dist/plugins/grideditor.tabs.min.js"></script>
21
- <script src="../dist/plugins/grideditor.accordion.min.js"></script>
22
- <script src="../dist/plugins/grideditor.popup.min.js"></script>
23
- <script src="../dist/plugins/grideditor.card.min.js"></script>
24
- <script src="../dist/plugins/grideditor.elements.min.js"></script>
25
-
26
- <!-- And one written here, to show what a plugin of your own takes. It is
27
- a container type: a bootstrap alert whose body is an editable region. -->
28
- <script id="callout-plugin">
29
- (function() {
30
-
31
- // A plugin brings its own strings
32
- Object.assign(GridEditor.locales.en, {
33
- 'container.add_callout': 'Callout',
34
- 'container.callout_title': 'Heads up',
35
- });
36
-
37
- // Registered under the type it builds, and called once per editor
38
- // with the handle it works through. The handle hands out elements.
39
- GridEditor.containers.callout = function(ge) {
40
-
41
- return {
42
- // The toolbar button's label
43
- labelKey: 'container.add_callout',
44
-
45
- // A detached container. data-ge-container is what the
46
- // editor recognises: never a class, so restyling is free.
47
- create: function(options) {
48
- var label = document.createElement('span');
49
- label.className = 'ge-pane-label';
50
- label.textContent = options.title || ge.t('container.callout_title');
51
-
52
- var heading = document.createElement('h4');
53
- heading.className = 'alert-heading';
54
- heading.appendChild(label);
55
-
56
- var callout = document.createElement('div');
57
- callout.className = 'alert alert-primary';
58
- callout.setAttribute('role', 'alert');
59
- callout.appendChild(heading);
60
- callout.appendChild(ge.defaultRegion());
61
-
62
- var container = document.createElement('div');
63
- container.setAttribute('data-ge-container', 'callout');
64
- container.appendChild(callout);
65
- return container;
66
- },
67
-
68
- // Editing furniture on, and off again. Anything mark()
69
- // adds, unmark() has to take away: what is left is what
70
- // getHtml hands back.
71
- mark: function(container) {
72
- ge.makeLabelEditable(ge.labelIn(container.querySelector('.alert-heading')));
73
- },
74
-
75
- unmark: function(container) {
76
- ge.unwrapLabels(container);
77
- },
78
-
79
- // The same, on a copy of the canvas, for
80
- // getHtml({ keepEditing: true }): unmark only touches
81
- // markup, so it does for each callout on the copy
82
- cleanMarkup: function(root) {
83
- var definition = this;
84
- root.querySelectorAll('[data-ge-container="callout"]').forEach(function(container) {
85
- definition.unmark(container);
86
- });
87
- },
88
- };
89
- };
90
-
91
- })();
92
- </script>
93
-
94
- <script>
95
- document.addEventListener('DOMContentLoaded', function() {
96
- // Show the plugin written above as the page's own source
97
- document.getElementById('callout-source').textContent =
98
- document.getElementById('callout-plugin').textContent.trim().replace(/^ {8}/gm, '');
99
-
100
- function activePlugins() {
101
- return Array.prototype.map.call(document.querySelectorAll('.plugin-choice:checked'), function(box) {
102
- return box.value;
103
- });
104
- }
105
-
106
- function start() {
107
- var running = GridEditor.get('#myGrid');
108
- if (running) { running.destroy(); }
109
-
110
- new GridEditor('#myGrid', {
111
- new_row_layouts: [[12], [6, 6]],
112
- content_types: [],
113
-
114
- // Which of the loaded plugins to use. Leave it out and
115
- // every one the page loaded is used.
116
- plugins: activePlugins(),
117
- });
118
-
119
- document.getElementById('in-use').textContent = activePlugins().join(', ') || 'none';
120
- document.getElementById('registered').textContent =
121
- Object.keys(GridEditor.containers).concat(
122
- Object.keys(GridEditor.features)).sort().join(', ');
123
- }
124
-
125
- document.querySelectorAll('.plugin-choice').forEach(function(box) {
126
- box.addEventListener('change', start);
127
- });
128
- document.getElementById('output').addEventListener('click', function() {
129
- document.getElementById('html').textContent = GridEditor.get('#myGrid').getHtml();
130
- });
131
-
132
- start();
133
- });
134
- </script>
135
-
136
- <title>Grid Editor plugins example</title>
137
- </head>
138
- <body>
139
- <!-- Back to the demo index -->
140
- <div class="container pt-3">
141
- <a class="link-secondary" href="index.html"><i class="bi bi-arrow-left"></i> All demos</a>
142
- </div>
143
-
144
-
145
- <div class="container">
146
-
147
- <div class="row my-3">
148
- <div class="col-lg-8">
149
- <h1 class="h4">Plugins</h1>
150
- <p class="form-text">
151
- Tabs, accordions, popups, cards and the element level
152
- controls are not in the main bundle: each is a file loaded
153
- beside the editor, and loading it is what turns the feature
154
- on. This page loads all five, plus a sixth written in its
155
- own <code>&lt;script&gt;</code> below.
156
- </p>
157
- <p class="form-text">
158
- Tick and untick to change the <code>plugins</code> setting
159
- and re-initialize the editor. A container plugin puts a
160
- button in the toolbar; <strong>elements</strong> has no
161
- button &mdash; its effect is that the marked markup in the
162
- first row becomes a movable element.
163
- </p>
164
-
165
- <div class="mb-2">
166
- <div class="form-check form-check-inline">
167
- <input class="form-check-input plugin-choice" type="checkbox" value="tabs" id="p-tabs" checked>
168
- <label class="form-check-label" for="p-tabs">tabs</label>
169
- </div>
170
- <div class="form-check form-check-inline">
171
- <input class="form-check-input plugin-choice" type="checkbox" value="accordion" id="p-accordion" checked>
172
- <label class="form-check-label" for="p-accordion">accordion</label>
173
- </div>
174
- <div class="form-check form-check-inline">
175
- <input class="form-check-input plugin-choice" type="checkbox" value="popup" id="p-popup" checked>
176
- <label class="form-check-label" for="p-popup">popup</label>
177
- </div>
178
- <div class="form-check form-check-inline">
179
- <input class="form-check-input plugin-choice" type="checkbox" value="elements" id="p-elements" checked>
180
- <label class="form-check-label" for="p-elements">elements</label>
181
- </div>
182
- <div class="form-check form-check-inline">
183
- <input class="form-check-input plugin-choice" type="checkbox" value="card" id="p-card" checked>
184
- <label class="form-check-label" for="p-card">card</label>
185
- </div>
186
- <div class="form-check form-check-inline">
187
- <input class="form-check-input plugin-choice" type="checkbox" value="callout" id="p-callout" checked>
188
- <label class="form-check-label" for="p-callout">callout (written on this page)</label>
189
- </div>
190
- </div>
191
-
192
- <p class="form-text">
193
- Loaded: <code id="registered"></code><br>
194
- In use: <code id="in-use"></code>
195
- </p>
196
-
197
- <button class="btn btn-sm btn-secondary" id="output" type="button">Show the html this produces</button>
198
- <pre id="html" class="form-text"></pre>
199
- </div>
200
- </div>
201
-
202
- <div id="myGrid">
203
-
204
- <div class="row">
205
- <div class="col-lg-12">
206
- <div class="ge-content">
207
- <p>Ordinary text in a content area.</p>
208
- </div>
209
-
210
- <blockquote data-ge-element="quote" data-ge-label="Pull quote">
211
- <p>A node the host marked: an element when the elements plugin is on,
212
- ordinary markup - text - when it is off.</p>
213
- </blockquote>
214
- </div>
215
- </div>
216
-
217
- <div class="row">
218
- <div class="col-lg-12">
219
- <div data-ge-container="card">
220
- <div class="card">
221
- <div class="card-header">A card, from the card plugin</div>
222
- <div class="card-body">
223
- <div class="row"><div class="col-lg-12">
224
- <div class="ge-content"><p>Its body is an ordinary region: rows, columns and elements nest in it.</p></div>
225
- </div></div>
226
- </div>
227
- </div>
228
- </div>
229
- </div>
230
- </div>
231
-
232
- </div> <!-- /#myGrid -->
233
-
234
- <div class="row my-4">
235
- <div class="col-lg-10">
236
- <h2 class="h5">The callout plugin, in full</h2>
237
- <p class="form-text">
238
- Thirty lines, and it moves, deletes, nests, takes an id and
239
- classes, and round-trips through <code>getHtml</code> like
240
- anything else &mdash; the shipped <code>card</code> plugin is
241
- barely longer. See <a href="../docs/plugins.md">docs/plugins.md</a>
242
- for the whole contract.
243
- </p>
244
- <pre class="border rounded p-3 bg-light"><code id="callout-source"></code></pre>
245
- </div>
246
- </div>
247
-
248
- </div> <!-- /.container -->
249
-
250
- </body>
251
- </html>