@themarioga/grid-editor 3.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 (52) hide show
  1. package/AUTO_SAVE.md +30 -0
  2. package/BUILDING.md +68 -0
  3. package/CHANGELOG.md +362 -0
  4. package/LICENSE +23 -0
  5. package/README.md +521 -0
  6. package/UPGRADING.md +88 -0
  7. package/dist/grideditor.css +3875 -0
  8. package/dist/grideditor.min.css +2 -0
  9. package/dist/grideditor.min.css.map +1 -0
  10. package/dist/jquery.grideditor.js +2996 -0
  11. package/dist/jquery.grideditor.min.js +2 -0
  12. package/dist/jquery.grideditor.min.js.map +1 -0
  13. package/dist/locales/grideditor.es.js +74 -0
  14. package/dist/locales/grideditor.es.min.js +2 -0
  15. package/dist/locales/grideditor.es.min.js.map +1 -0
  16. package/dist/plugins/grideditor.accordion.js +185 -0
  17. package/dist/plugins/grideditor.accordion.min.js +2 -0
  18. package/dist/plugins/grideditor.accordion.min.js.map +1 -0
  19. package/dist/plugins/grideditor.elements.js +141 -0
  20. package/dist/plugins/grideditor.elements.min.js +2 -0
  21. package/dist/plugins/grideditor.elements.min.js.map +1 -0
  22. package/dist/plugins/grideditor.popup.js +143 -0
  23. package/dist/plugins/grideditor.popup.min.js +2 -0
  24. package/dist/plugins/grideditor.popup.min.js.map +1 -0
  25. package/dist/plugins/grideditor.tabs.js +140 -0
  26. package/dist/plugins/grideditor.tabs.min.js +2 -0
  27. package/dist/plugins/grideditor.tabs.min.js.map +1 -0
  28. package/docs/events.md +158 -0
  29. package/docs/locale-keys.md +140 -0
  30. package/docs/plugins.md +163 -0
  31. package/example/autosave.html +89 -0
  32. package/example/basic.html +93 -0
  33. package/example/breakpoints.html +94 -0
  34. package/example/ckeditor.html +104 -0
  35. package/example/containers.html +214 -0
  36. package/example/elements.html +147 -0
  37. package/example/index.html +119 -0
  38. package/example/locale.html +84 -0
  39. package/example/plugins.html +217 -0
  40. package/example/summernote.html +106 -0
  41. package/example/wrap_content.html +44 -0
  42. package/package.json +66 -0
  43. package/src/js/jquery.grideditor.ckeditor.js +77 -0
  44. package/src/js/jquery.grideditor.js +2711 -0
  45. package/src/js/jquery.grideditor.summernote.js +72 -0
  46. package/src/js/jquery.grideditor.tinymce.js +135 -0
  47. package/src/js/locales/grideditor.es.js +74 -0
  48. package/src/js/plugins/grideditor.accordion.js +185 -0
  49. package/src/js/plugins/grideditor.elements.js +141 -0
  50. package/src/js/plugins/grideditor.popup.js +143 -0
  51. package/src/js/plugins/grideditor.tabs.js +140 -0
  52. package/src/less/grideditor.less +594 -0
@@ -0,0 +1,84 @@
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://code.jquery.com/jquery-4.0.0.min.js"></script>
12
+ <script src="https://code.jquery.com/ui/1.14.2/jquery-ui.min.js"></script>
13
+ <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>
14
+
15
+ <!-- Grid editor CSS -->
16
+ <link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
17
+ <!-- Grid editor javascript, then the locales the page offers. English is
18
+ built into the plugin; every other language is a file of its own. -->
19
+ <script src="../dist/jquery.grideditor.min.js"></script>
20
+ <script src="../dist/locales/grideditor.es.js"></script>
21
+
22
+ <script>
23
+ $(function() {
24
+ $('#myGrid').gridEditor({
25
+ new_row_layouts: [[12], [6,6], [9,3]],
26
+ content_types: [],
27
+ locale: 'es',
28
+
29
+ // Individual keys can be overridden without a locale file,
30
+ // which is how a host uses its own word for something
31
+ locale_strings: {},
32
+ });
33
+
34
+ // Switching language at runtime re-renders the controls
35
+ $('#language').on('change', function() {
36
+ $('#myGrid').gridEditor('setLocale', this.value);
37
+ });
38
+ });
39
+ </script>
40
+
41
+ <title>Grid Editor locale example</title>
42
+ </head>
43
+ <body>
44
+
45
+ <div class="container">
46
+
47
+ <div class="row my-3">
48
+ <div class="col-lg-6">
49
+ <label class="form-label" for="language">Idioma / Language</label>
50
+ <select class="form-select" id="language">
51
+ <option value="es" selected>Español</option>
52
+ <option value="en">English</option>
53
+ </select>
54
+ <p class="form-text">
55
+ The tool tooltips, the layout mode dropdown, the add row
56
+ buttons, the settings panel and the delete confirms all
57
+ follow this dropdown. Hover a tool to read its tooltip.
58
+ </p>
59
+ </div>
60
+ </div>
61
+
62
+ <div id="myGrid">
63
+
64
+ <div class="row">
65
+ <div class="col-lg-12">
66
+ <h1>Editor de rejilla</h1>
67
+ <p>Pasa el ratón por encima de las herramientas para ver los textos traducidos.</p>
68
+ </div>
69
+ </div>
70
+
71
+ <div class="row">
72
+ <div class="col-lg-8">
73
+ <p>Una columna de ocho unidades.</p>
74
+ </div>
75
+ <div class="col-lg-4">
76
+ <p>Una columna de cuatro unidades.</p>
77
+ </div>
78
+ </div>
79
+
80
+ </div> <!-- /#myGrid -->
81
+ </div> <!-- /.container -->
82
+
83
+ </body>
84
+ </html>
@@ -0,0 +1,217 @@
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://code.jquery.com/jquery-4.0.0.min.js"></script>
12
+ <script src="https://code.jquery.com/ui/1.14.2/jquery-ui.min.js"></script>
13
+ <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>
14
+
15
+ <!-- Grid editor CSS -->
16
+ <link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
17
+
18
+ <!-- The editor, and the plugins this page offers. Loading a file is what
19
+ makes its feature available; nothing here is in the main bundle. -->
20
+ <script src="../dist/jquery.grideditor.min.js"></script>
21
+ <script src="../dist/plugins/grideditor.tabs.min.js"></script>
22
+ <script src="../dist/plugins/grideditor.accordion.min.js"></script>
23
+ <script src="../dist/plugins/grideditor.popup.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 card whose body is an editable region. -->
28
+ <script id="card-plugin">
29
+ (function($) {
30
+
31
+ // A plugin brings its own strings
32
+ $.extend($.fn.gridEditor.locales.en, {
33
+ 'container.add_card': 'Card',
34
+ 'container.card_title': 'Card title',
35
+ });
36
+
37
+ // Registered under the type it builds, and called once per editor
38
+ // with the handle it works through
39
+ $.fn.gridEditor.containers.card = function(ge) {
40
+
41
+ return {
42
+ // The toolbar button's label
43
+ labelKey: 'container.add_card',
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 container = $('<div />').attr('data-ge-container', 'card');
49
+
50
+ $('<div class="card" />')
51
+ .append($('<div class="card-header" />')
52
+ .text(options.title || ge.t('container.card_title')))
53
+ .append($('<div class="card-body" />').append(ge.defaultRegion()))
54
+ .appendTo(container)
55
+ ;
56
+
57
+ return container;
58
+ },
59
+
60
+ // Editing furniture on, and off again. Anything mark()
61
+ // adds, unmark() has to take away: what is left is what
62
+ // getHtml hands back.
63
+ mark: function(container) {
64
+ ge.makeLabelEditable(ge.labelIn(container.find('.card-header')));
65
+ },
66
+
67
+ unmark: function(container) {
68
+ ge.unwrapLabels(container);
69
+ },
70
+ };
71
+ };
72
+
73
+ })(jQuery);
74
+ </script>
75
+
76
+ <script>
77
+ $(function() {
78
+ // Show the plugin written above as the page's own source
79
+ $('#card-source').text($('#card-plugin').text().trim().replace(/^ {8}/gm, ''));
80
+
81
+ function activePlugins() {
82
+ return $('.plugin-choice:checked').map(function() { return this.value; }).get();
83
+ }
84
+
85
+ function start() {
86
+ $('#myGrid').gridEditor('destroy');
87
+ $('#myGrid').gridEditor({
88
+ new_row_layouts: [[12], [6, 6]],
89
+ content_types: [],
90
+
91
+ // Which of the loaded plugins to use. Leave it out and
92
+ // every one the page loaded is used.
93
+ plugins: activePlugins(),
94
+ });
95
+
96
+ $('#in-use').text(activePlugins().join(', ') || 'none');
97
+ $('#registered').text(
98
+ Object.keys($.fn.gridEditor.containers).concat(
99
+ Object.keys($.fn.gridEditor.features)).sort().join(', ')
100
+ );
101
+ }
102
+
103
+ $('.plugin-choice').on('change', start);
104
+ $('#output').on('click', function() {
105
+ $('#html').text($('#myGrid').gridEditor('getHtml'));
106
+ });
107
+
108
+ start();
109
+ });
110
+ </script>
111
+
112
+ <title>Grid Editor plugins example</title>
113
+ </head>
114
+ <body>
115
+
116
+ <div class="container">
117
+
118
+ <div class="row my-3">
119
+ <div class="col-lg-8">
120
+ <h1 class="h4">Plugins</h1>
121
+ <p class="form-text">
122
+ Tabs, accordions, popups and the element level controls are
123
+ not in the main bundle: each is a file loaded beside the
124
+ editor, and loading it is what turns the feature on. This
125
+ page loads all four, plus a fifth written in its own
126
+ <code>&lt;script&gt;</code> below.
127
+ </p>
128
+ <p class="form-text">
129
+ Tick and untick to change the <code>plugins</code> setting
130
+ and re-initialize the editor. A container plugin puts a
131
+ button in the toolbar; <strong>elements</strong> has no
132
+ button &mdash; its effect is that the marked markup in the
133
+ first row becomes a movable element.
134
+ </p>
135
+
136
+ <div class="mb-2">
137
+ <div class="form-check form-check-inline">
138
+ <input class="form-check-input plugin-choice" type="checkbox" value="tabs" id="p-tabs" checked>
139
+ <label class="form-check-label" for="p-tabs">tabs</label>
140
+ </div>
141
+ <div class="form-check form-check-inline">
142
+ <input class="form-check-input plugin-choice" type="checkbox" value="accordion" id="p-accordion" checked>
143
+ <label class="form-check-label" for="p-accordion">accordion</label>
144
+ </div>
145
+ <div class="form-check form-check-inline">
146
+ <input class="form-check-input plugin-choice" type="checkbox" value="popup" id="p-popup" checked>
147
+ <label class="form-check-label" for="p-popup">popup</label>
148
+ </div>
149
+ <div class="form-check form-check-inline">
150
+ <input class="form-check-input plugin-choice" type="checkbox" value="elements" id="p-elements" checked>
151
+ <label class="form-check-label" for="p-elements">elements</label>
152
+ </div>
153
+ <div class="form-check form-check-inline">
154
+ <input class="form-check-input plugin-choice" type="checkbox" value="card" id="p-card" checked>
155
+ <label class="form-check-label" for="p-card">card (written on this page)</label>
156
+ </div>
157
+ </div>
158
+
159
+ <p class="form-text">
160
+ Loaded: <code id="registered"></code><br>
161
+ In use: <code id="in-use"></code>
162
+ </p>
163
+
164
+ <button class="btn btn-sm btn-secondary" id="output" type="button">Show the html this produces</button>
165
+ <pre id="html" class="form-text"></pre>
166
+ </div>
167
+ </div>
168
+
169
+ <div id="myGrid">
170
+
171
+ <div class="row">
172
+ <div class="col-lg-12">
173
+ <div class="ge-content">
174
+ <p>Ordinary text in a content area.</p>
175
+
176
+ <blockquote data-ge-element="quote" data-ge-label="Pull quote">
177
+ <p>A node the host marked: an element when the elements plugin is on,
178
+ ordinary markup when it is off.</p>
179
+ </blockquote>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+ <div class="row">
185
+ <div class="col-lg-12">
186
+ <div data-ge-container="card">
187
+ <div class="card">
188
+ <div class="card-header">A card, from the plugin written on this page</div>
189
+ <div class="card-body">
190
+ <div class="row"><div class="col-lg-12">
191
+ <div class="ge-content"><p>Its body is an ordinary region: rows, columns and elements nest in it.</p></div>
192
+ </div></div>
193
+ </div>
194
+ </div>
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+ </div> <!-- /#myGrid -->
200
+
201
+ <div class="row my-4">
202
+ <div class="col-lg-10">
203
+ <h2 class="h5">The card plugin, in full</h2>
204
+ <p class="form-text">
205
+ Thirty lines, and it moves, deletes, nests, takes an id and
206
+ classes, and round-trips through <code>getHtml</code> like
207
+ anything else. See <a href="../docs/plugins.md">docs/plugins.md</a>
208
+ for the whole contract.
209
+ </p>
210
+ <pre class="border rounded p-3 bg-light"><code id="card-source"></code></pre>
211
+ </div>
212
+ </div>
213
+
214
+ </div> <!-- /.container -->
215
+
216
+ </body>
217
+ </html>
@@ -0,0 +1,106 @@
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://code.jquery.com/jquery-4.0.0.min.js"></script>
12
+ <script src="https://code.jquery.com/ui/1.14.2/jquery-ui.min.js"></script>
13
+ <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>
14
+
15
+ <!-- Summernote CSS -->
16
+ <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.9.1/summernote-bs5.min.css" />
17
+ <!-- Summernote js -->
18
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.9.1/summernote-bs5.min.js"></script>
19
+
20
+ <!-- Grid editor CSS -->
21
+ <link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
22
+ <!-- Grid editor javascript -->
23
+ <script src="../dist/jquery.grideditor.min.js"></script>
24
+
25
+ <script>
26
+ $(function() {
27
+ // Initialize grid editor
28
+ $('#myGrid').gridEditor({
29
+ new_row_layouts: [[12], [6, 6], [9, 3], [3, 9]],
30
+ content_types: ['summernote'],
31
+ summernote: {
32
+ config: {
33
+ callbacks: {
34
+ onInit: function() {
35
+ var element = this;
36
+ console.log('init done', element);
37
+ }
38
+ }
39
+ }
40
+ }
41
+ });
42
+
43
+ // Get resulting html
44
+ var html = $('#myGrid').gridEditor('getHtml');
45
+ console.log(html);
46
+ });
47
+ </script>
48
+
49
+ <title>Grid Editor example</title>
50
+ </head>
51
+ <body>
52
+
53
+ <div class="container">
54
+ <div id="myGrid">
55
+
56
+ <div class="row">
57
+ <div class="col-md-12">
58
+ <h1>Lorem ipsum dolor sit amet, consectetur</h1>
59
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Velit exercitationem eaque aperiam rem quia quibusdam dolor ducimus quo similique eos pariatur nostrum aliquam nam eius, doloremque quis voluptatum unde. Porro voluptates aspernatur voluptate ipsam, magni vero. Accusamus, iusto tempore id!</p>
60
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae laboriosam, excepturi quas.</p>
61
+ </div>
62
+ </div>
63
+
64
+ <div class="row">
65
+ <div class="col-md-4">
66
+ <h2>Lorem ipsum dolor</h2>
67
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea facilis vel aliquam aspernatur dolor placeat totam saepe perferendis. Odio quia vel sed eveniet cupiditate, illum doloremque sint veniam eum? Corporis?</p>
68
+ </div>
69
+ <div class="col-md-4">
70
+ <h2>Pariatur reprehenderit</h2>
71
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo adipisci ipsa, consequuntur cum, sunt dolores veniam. Enim inventore in dolore deserunt vitae sequi nemo!</p>
72
+ </div>
73
+ <div class="col-md-4">
74
+ <h2>Pariatur reprehenderit</h2>
75
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ea excepturi ducimus numquam aut error corporis aspernatur ipsum quos eius culpa!</p>
76
+ </div>
77
+ </div>
78
+
79
+ <div class="row">
80
+ <div class="col-md-8">
81
+ <h2>Lorem ipsum dolor.</h2>
82
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro distinctio atque molestiae optio, consequuntur? Iusto ratione cumque dolor aut dolore!</p>
83
+
84
+ <div class="row">
85
+ <div class="col-md-6">
86
+ <hr>
87
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Debitis facilis molestias voluptatum laudantium fuga ratione tempora rem dolor dicta rerum vero ut, suscipit ex qui amet quam vel cupiditate quaerat minus assumenda reiciendis, similique omnis delectus! Autem, repudiandae cumque eaque?</p>
88
+ </div>
89
+ <div class="col-md-6">
90
+ <hr>
91
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet molestiae quaerat illum, consequuntur iusto aspernatur quam provident? Possimus!</p>
92
+ </div>
93
+ </div>
94
+ </div>
95
+
96
+ <div class="col-md-4">
97
+ <h2>Lusto ratione</h2>
98
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis fugit quasi officiis id laudantium error aut ut aperiam dicta saepe non vel, cupiditate illum ipsam velit deleniti natus incidunt impedit molestias dolore quos dolores enim. Aliquid ipsam eaque consequuntur quaerat, suscipit a in. Praesentium repudiandae quibusdam recusandae sequi eligendi quos, dignissimos, officiis officia minima necessitatibus eaque consequatur in id adipisci qui minus voluptatum quae debitis, quas maxime iure. Tempore vero unde quia reiciendis ad beatae voluptate omnis, ipsa expedita ab, quasi, neque. Doloribus, pariatur. Aut hic voluptate.</p>
99
+ </div>
100
+ </div>
101
+
102
+ </div> <!-- /#myGrid -->
103
+ </div> <!-- /.container -->
104
+
105
+ </body>
106
+ </html>
@@ -0,0 +1,44 @@
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://code.jquery.com/jquery-4.0.0.min.js"></script>
12
+ <script src="https://code.jquery.com/ui/1.14.2/jquery-ui.min.js"></script>
13
+ <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>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
15
+
16
+ <!-- Grid editor CSS -->
17
+ <link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
18
+ <!-- Grid editor javascript -->
19
+ <script src="../dist/jquery.grideditor.min.js"></script>
20
+
21
+ <script>
22
+ $(function() {
23
+ // Initialize grid editor
24
+ $('#myGrid').gridEditor({
25
+ new_row_layouts: [[12], [6, 6], [9, 3], [3, 9]],
26
+ content_types: ['tinymce'],
27
+ });
28
+
29
+ // Get resulting html
30
+ var html = $('#myGrid').gridEditor('getHtml');
31
+ console.log(html);
32
+ });
33
+ </script>
34
+
35
+ <title>Grid Editor example</title>
36
+ </head>
37
+ <body>
38
+ <div id="myGrid">
39
+ <h1>Hello!</h1>
40
+ <p>Test</p>
41
+ </div>
42
+
43
+ </body>
44
+ </html>
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "scripts": {
3
+ "build": "grunt",
4
+ "lint": "eslint .",
5
+ "start": "npm run watch",
6
+ "test": "node test/run.js",
7
+ "test:vendor": "node test/vendor/update.js",
8
+ "watch": "grunt watch"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/themarioga/grid-editor.git"
13
+ },
14
+ "devDependencies": {
15
+ "eslint": "^9.39.5",
16
+ "grunt": "^1.6.3",
17
+ "grunt-cli": "^1.5.0",
18
+ "grunt-contrib-clean": "^2.0.1",
19
+ "grunt-contrib-concat": "^2.1.0",
20
+ "grunt-contrib-copy": "^1.0.0",
21
+ "grunt-contrib-cssmin": "^5.0.0",
22
+ "grunt-contrib-less": "^3.0.0",
23
+ "grunt-contrib-uglify": "^5.2.2",
24
+ "grunt-contrib-watch": "^1.1.0"
25
+ },
26
+ "name": "@themarioga/grid-editor",
27
+ "description": "Visual javascript editor for the bootstrap grid system, written as a jQuery plugin.",
28
+ "bugs": {
29
+ "url": "https://github.com/themarioga/grid-editor/issues"
30
+ },
31
+ "homepage": "https://github.com/themarioga/grid-editor#readme",
32
+ "publishConfig": {
33
+ "comment": "A scoped package publishes restricted unless it is told otherwise.",
34
+ "access": "public"
35
+ },
36
+ "version": "3.1.0",
37
+ "main": "dist/jquery.grideditor.js",
38
+ "files": [
39
+ "dist",
40
+ "src",
41
+ "docs",
42
+ "example",
43
+ "AUTO_SAVE.md",
44
+ "BUILDING.md",
45
+ "CHANGELOG.md",
46
+ "UPGRADING.md"
47
+ ],
48
+ "directories": {
49
+ "example": "example"
50
+ },
51
+ "keywords": [
52
+ "jquery-plugin",
53
+ "ecosystem:jquery",
54
+ "bootstrap5",
55
+ "grid",
56
+ "bootstrap-grid",
57
+ "css grid",
58
+ "editor",
59
+ "wysiwyg"
60
+ ],
61
+ "author": "Mario Gonzalez",
62
+ "contributors": [
63
+ "Simon Epskamp (https://github.com/Friendly-Pixel)"
64
+ ],
65
+ "license": "MIT"
66
+ }
@@ -0,0 +1,77 @@
1
+ (function($) {
2
+ $.fn.gridEditor.RTEs.ckeditor = {
3
+
4
+ init: function(settings, contentAreas) {
5
+
6
+ if (!window.CKEDITOR) {
7
+ console.error($.fn.gridEditor.t(settings, 'error.ckeditor_missing'));
8
+ }
9
+
10
+ var self = this;
11
+ contentAreas.each(function() {
12
+ var contentArea = $(this);
13
+ if (!contentArea.hasClass('active')) {
14
+ if (contentArea.html() == self.initialContent) {
15
+ // CKEditor kills this '&nbsp' creating a non usable box :/
16
+ contentArea.html('&nbsp;');
17
+ }
18
+
19
+ // Add the .attr('contenteditable',''true') or CKEditor loads readonly
20
+ contentArea.addClass('active').attr('contenteditable', 'true');
21
+
22
+ var configuration = $.extend(
23
+ {},
24
+ (settings.ckeditor && settings.ckeditor.config ? settings.ckeditor.config : {}),
25
+ {
26
+ // Focus editor on creation
27
+ on: {
28
+ instanceReady: function( evt ) {
29
+ // Call original instanceReady function, if one was passed in the config
30
+ var callback;
31
+ try {
32
+ callback = settings.ckeditor.config.on.instanceReady;
33
+ } catch (err) {
34
+ // No callback passed
35
+ }
36
+ if (callback) {
37
+ callback.call(this, evt);
38
+ }
39
+
40
+ // The editor owns what is inside the
41
+ // content area now, so the grid editor is
42
+ // told to put its own furniture back
43
+ contentArea.trigger('ge-rte-ready');
44
+
45
+ instance.focus();
46
+ }
47
+ }
48
+ }
49
+ );
50
+ var instance = CKEDITOR.inline(contentArea.get(0), configuration);
51
+ }
52
+ });
53
+ },
54
+
55
+ deinit: function(settings, contentAreas) {
56
+ contentAreas.filter('.active').each(function() {
57
+ var contentArea = $(this);
58
+
59
+ // Destroy all CKEditor instances
60
+ $.each(CKEDITOR.instances, function(_, instance) {
61
+ instance.destroy();
62
+ });
63
+
64
+ // Cleanup
65
+ contentArea
66
+ .removeClass('active cke_focus')
67
+ .removeAttr('id')
68
+ .removeAttr('style')
69
+ .removeAttr('spellcheck')
70
+ .removeAttr('contenteditable')
71
+ ;
72
+ });
73
+ },
74
+
75
+ initialContent: '<p>Lorem initius... </p>',
76
+ };
77
+ })(jQuery);