@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.
- package/AUTO_SAVE.md +2 -2
- package/BUILDING.md +45 -29
- package/CHANGELOG.md +59 -0
- package/README.md +163 -87
- package/UPGRADING.md +119 -0
- package/dist/grideditor.bundle.min.js +14 -0
- package/dist/grideditor.d.ts +335 -0
- package/dist/grideditor.esm.js +3977 -0
- package/dist/grideditor.jquery.js +253 -0
- package/dist/grideditor.jquery.min.js +1 -0
- package/dist/grideditor.jquery.min.js.map +7 -0
- package/dist/grideditor.js +3983 -0
- package/dist/grideditor.min.js +6 -0
- package/dist/grideditor.min.js.map +7 -0
- package/dist/locales/grideditor.es.esm.js +158 -0
- package/dist/locales/grideditor.es.js +164 -168
- package/dist/locales/grideditor.es.min.js +6 -2
- package/dist/locales/grideditor.es.min.js.map +7 -1
- package/dist/plugins/grideditor.accordion.esm.js +294 -0
- package/dist/plugins/grideditor.accordion.js +286 -180
- package/dist/plugins/grideditor.accordion.min.js +1 -2
- package/dist/plugins/grideditor.accordion.min.js.map +7 -1
- package/dist/plugins/grideditor.alignment.esm.js +55 -0
- package/dist/plugins/grideditor.alignment.js +58 -77
- package/dist/plugins/grideditor.alignment.min.js +1 -2
- package/dist/plugins/grideditor.alignment.min.js.map +7 -1
- package/dist/plugins/grideditor.card.esm.js +73 -0
- package/dist/plugins/grideditor.card.js +74 -64
- package/dist/plugins/grideditor.card.min.js +1 -2
- package/dist/plugins/grideditor.card.min.js.map +7 -1
- package/dist/plugins/grideditor.ckeditor.esm.js +500 -0
- package/dist/plugins/grideditor.ckeditor.js +484 -449
- package/dist/plugins/grideditor.ckeditor.min.js +1 -2
- package/dist/plugins/grideditor.ckeditor.min.js.map +7 -1
- package/dist/plugins/grideditor.clipboard.esm.js +326 -0
- package/dist/plugins/grideditor.clipboard.js +298 -235
- package/dist/plugins/grideditor.clipboard.min.js +1 -2
- package/dist/plugins/grideditor.clipboard.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror-inline.esm.js +205 -0
- package/dist/plugins/grideditor.codemirror-inline.js +188 -168
- package/dist/plugins/grideditor.codemirror-inline.min.js +1 -2
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +7 -1
- package/dist/plugins/grideditor.codemirror.esm.js +63 -0
- package/dist/plugins/grideditor.codemirror.js +60 -71
- package/dist/plugins/grideditor.codemirror.min.js +1 -2
- package/dist/plugins/grideditor.codemirror.min.js.map +7 -1
- package/dist/plugins/grideditor.elements.esm.js +271 -0
- package/dist/plugins/grideditor.elements.js +256 -149
- package/dist/plugins/grideditor.elements.min.js +1 -2
- package/dist/plugins/grideditor.elements.min.js.map +7 -1
- package/dist/plugins/grideditor.float.esm.js +34 -0
- package/dist/plugins/grideditor.float.js +37 -52
- package/dist/plugins/grideditor.float.min.js +1 -2
- package/dist/plugins/grideditor.float.min.js.map +7 -1
- package/dist/plugins/grideditor.gutters.esm.js +143 -0
- package/dist/plugins/grideditor.gutters.js +134 -131
- package/dist/plugins/grideditor.gutters.min.js +1 -2
- package/dist/plugins/grideditor.gutters.min.js.map +7 -1
- package/dist/plugins/grideditor.order.esm.js +189 -0
- package/dist/plugins/grideditor.order.js +170 -182
- package/dist/plugins/grideditor.order.min.js +1 -2
- package/dist/plugins/grideditor.order.min.js.map +7 -1
- package/dist/plugins/grideditor.popup.esm.js +187 -0
- package/dist/plugins/grideditor.popup.js +183 -134
- package/dist/plugins/grideditor.popup.min.js +1 -2
- package/dist/plugins/grideditor.popup.min.js.map +7 -1
- package/dist/plugins/grideditor.sections.esm.js +271 -0
- package/dist/plugins/grideditor.sections.js +250 -173
- package/dist/plugins/grideditor.sections.min.js +1 -2
- package/dist/plugins/grideditor.sections.min.js.map +7 -1
- package/dist/plugins/grideditor.spacing.esm.js +318 -0
- package/dist/plugins/grideditor.spacing.js +296 -272
- package/dist/plugins/grideditor.spacing.min.js +1 -2
- package/dist/plugins/grideditor.spacing.min.js.map +7 -1
- package/dist/plugins/grideditor.summernote.esm.js +509 -0
- package/dist/plugins/grideditor.summernote.js +493 -427
- package/dist/plugins/grideditor.summernote.min.js +1 -2
- package/dist/plugins/grideditor.summernote.min.js.map +7 -1
- package/dist/plugins/grideditor.tabs.esm.js +237 -0
- package/dist/plugins/grideditor.tabs.js +233 -139
- package/dist/plugins/grideditor.tabs.min.js +1 -2
- package/dist/plugins/grideditor.tabs.min.js.map +7 -1
- package/dist/plugins/grideditor.textalign.esm.js +40 -0
- package/dist/plugins/grideditor.textalign.js +43 -56
- package/dist/plugins/grideditor.textalign.min.js +1 -2
- package/dist/plugins/grideditor.textalign.min.js.map +7 -1
- package/dist/plugins/grideditor.tinymce.esm.js +519 -0
- package/dist/plugins/grideditor.tinymce.js +502 -490
- package/dist/plugins/grideditor.tinymce.min.js +1 -2
- package/dist/plugins/grideditor.tinymce.min.js.map +7 -1
- package/dist/plugins/grideditor.visibility.esm.js +158 -0
- package/dist/plugins/grideditor.visibility.js +140 -149
- package/dist/plugins/grideditor.visibility.min.js +1 -2
- package/dist/plugins/grideditor.visibility.min.js.map +7 -1
- package/docs/events.md +47 -21
- package/docs/locale-keys.md +6 -0
- package/docs/plugins.md +47 -25
- package/example/adapter.html +112 -0
- package/example/attributes.html +89 -62
- package/example/autocols.html +9 -9
- package/example/autosave.html +18 -16
- package/example/basic.html +8 -6
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +15 -11
- package/example/codemirror.html +13 -8
- package/example/containers.html +11 -9
- package/example/custom_editor.html +53 -34
- package/example/elements.html +14 -12
- package/example/index.html +16 -2
- package/example/locale.html +6 -7
- package/example/plugins.html +44 -29
- package/example/summernote.html +6 -5
- package/example/utilities.html +17 -13
- package/example/wrap_content.html +13 -10
- package/package.json +44 -12
- package/src/js/dom.js +401 -0
- package/src/js/grideditor.classic.js +16 -0
- package/src/js/grideditor.jquery.js +325 -0
- package/src/js/{jquery.grideditor.js → grideditor.js} +1284 -1124
- package/src/js/locales/grideditor.es.js +163 -156
- package/src/js/plugins/grideditor.accordion.js +97 -77
- package/src/js/plugins/grideditor.alignment.js +5 -7
- package/src/js/plugins/grideditor.card.js +23 -23
- package/src/js/plugins/grideditor.ckeditor.js +107 -106
- package/src/js/plugins/grideditor.clipboard.js +49 -37
- package/src/js/plugins/grideditor.codemirror-inline.js +50 -37
- package/src/js/plugins/grideditor.codemirror.js +9 -10
- package/src/js/plugins/grideditor.elements.js +57 -33
- package/src/js/plugins/grideditor.float.js +4 -6
- package/src/js/plugins/grideditor.gutters.js +20 -15
- package/src/js/plugins/grideditor.order.js +28 -25
- package/src/js/plugins/grideditor.popup.js +63 -51
- package/src/js/plugins/grideditor.sections.js +39 -32
- package/src/js/plugins/grideditor.spacing.js +42 -45
- package/src/js/plugins/grideditor.summernote.js +112 -76
- package/src/js/plugins/grideditor.tabs.js +65 -57
- package/src/js/plugins/grideditor.textalign.js +4 -6
- package/src/js/plugins/grideditor.tinymce.js +148 -140
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +77 -56
- package/types/grideditor.d.ts +335 -0
- package/dist/jquery.grideditor.bundle.min.js +0 -10
- package/dist/jquery.grideditor.js +0 -4927
- package/dist/jquery.grideditor.min.js +0 -2
- package/dist/jquery.grideditor.min.js.map +0 -1
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* … classes. What it can ask the editor for is the handle its factory is
|
|
8
8
|
* called with, described in docs/plugins.md.
|
|
9
9
|
*
|
|
10
|
-
* <script src="dist/
|
|
10
|
+
* <script src="dist/grideditor.min.js"></script>
|
|
11
11
|
* <script src="dist/plugins/grideditor.spacing.min.js"></script>
|
|
12
12
|
*
|
|
13
13
|
* Fourteen families would be fourteen fields, so the panel has two, padding
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* utilities.spacing.scale is what 0 to 5 come to, for a page that changed
|
|
18
18
|
* Bootstrap's $spacers.
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
import { GridEditor } from '../grideditor.js';
|
|
21
|
+
import * as dom from '../dom.js';
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Object.assign(GridEditor.locales.en, {
|
|
23
24
|
'utility.padding': 'Padding',
|
|
24
25
|
'utility.margin': 'Margin',
|
|
25
26
|
'utility.side_all': 'All sides',
|
|
@@ -63,18 +64,18 @@ function pattern(key) {
|
|
|
63
64
|
return new RegExp('^' + key + '[xytbse]?-(?:(?:sm|md|lg|xl|xxl)-)?(?:[0-5]|auto)$');
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
GridEditor.utilities.spacing = function(ge) {
|
|
67
68
|
|
|
68
|
-
var options =
|
|
69
|
+
var options = Object.assign({ values: VALUES, scale: SCALE }, ge.settings.utilities.spacing);
|
|
69
70
|
var patterns = { p: pattern('p'), m: pattern('m') };
|
|
70
71
|
|
|
71
72
|
function applies(node, kind) {
|
|
72
73
|
return kind === 'row' || kind === 'column' || kind === 'element' ||
|
|
73
|
-
|
|
74
|
+
dom.is(node, '[data-ge-container]');
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
function classes(node) {
|
|
77
|
-
return (node.
|
|
78
|
+
return (node.getAttribute('class') || '').split(/\s+/);
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
function carries(node, key) {
|
|
@@ -106,16 +107,16 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
|
|
|
106
107
|
* since that is the only way to ask the browser.
|
|
107
108
|
*/
|
|
108
109
|
function without(node, key) {
|
|
109
|
-
var original = node.
|
|
110
|
+
var original = node.getAttribute('class');
|
|
110
111
|
var style;
|
|
111
112
|
var bare = {};
|
|
112
113
|
|
|
113
|
-
node.
|
|
114
|
-
style = getComputedStyle(node
|
|
114
|
+
node.setAttribute('class', classes(node).filter(function(name) { return !patterns[key].test(name); }).join(' '));
|
|
115
|
+
style = getComputedStyle(node);
|
|
115
116
|
['top', 'right', 'bottom', 'left'].forEach(function(side) {
|
|
116
117
|
bare[side] = style.getPropertyValue(PROPERTIES[key] + '-' + side);
|
|
117
118
|
});
|
|
118
|
-
node.
|
|
119
|
+
if (original === null) { node.removeAttribute('class'); } else { node.setAttribute('class', original); }
|
|
119
120
|
|
|
120
121
|
return bare;
|
|
121
122
|
}
|
|
@@ -182,26 +183,25 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
|
|
|
182
183
|
|
|
183
184
|
/** A padding or margin group: its name, the side, and the field of that side's family. */
|
|
184
185
|
function group(node, key, labelText) {
|
|
185
|
-
var box =
|
|
186
|
-
var side =
|
|
186
|
+
var box = dom.element('div', { 'class': 'ge-spacing-group', 'data-ge-spacing': key });
|
|
187
|
+
var side = dom.element('select', { 'class': 'ge-spacing-side form-select form-select-sm' });
|
|
187
188
|
|
|
188
|
-
|
|
189
|
+
box.appendChild(dom.element('span', { 'class': 'ge-utility-label' }, labelText));
|
|
189
190
|
|
|
190
191
|
SIDES.forEach(function(value) {
|
|
191
|
-
|
|
192
|
+
side.appendChild(dom.element('option', { value: value }, sideLabel(value)));
|
|
192
193
|
});
|
|
193
194
|
|
|
194
195
|
var field = ge.utilityField(node, key + startingSide(node, key));
|
|
195
196
|
|
|
196
|
-
side.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
;
|
|
204
|
-
field.appendTo(box);
|
|
197
|
+
side.value = field.getAttribute('data-ge-family').slice(1);
|
|
198
|
+
side.addEventListener('change', function() {
|
|
199
|
+
var next = ge.utilityField(node, key + this.value);
|
|
200
|
+
field.replaceWith(next);
|
|
201
|
+
field = next;
|
|
202
|
+
});
|
|
203
|
+
box.appendChild(side);
|
|
204
|
+
box.appendChild(field);
|
|
205
205
|
|
|
206
206
|
return box;
|
|
207
207
|
}
|
|
@@ -216,29 +216,29 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
|
|
|
216
216
|
* about what that does to its gutter.
|
|
217
217
|
*/
|
|
218
218
|
function mark(scope) {
|
|
219
|
-
|
|
220
|
-
var
|
|
221
|
-
var drawer = node.children('.ge-tools-drawer');
|
|
219
|
+
dom.selfAndAll(scope, NODES).forEach(function(node) {
|
|
220
|
+
var drawer = dom.child(node, '.ge-tools-drawer');
|
|
222
221
|
|
|
223
|
-
if (!drawer
|
|
222
|
+
if (!drawer || !applies(node, ge.kindOf(node))) { return; }
|
|
224
223
|
|
|
225
224
|
if (carries(node, 'p')) {
|
|
226
|
-
var style = getComputedStyle(node
|
|
225
|
+
var style = getComputedStyle(node);
|
|
227
226
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
dom.css(drawer, {
|
|
228
|
+
'margin-top': '-' + style.paddingTop,
|
|
229
|
+
'margin-left': '-' + style.paddingLeft,
|
|
230
|
+
'margin-right': '-' + style.paddingRight,
|
|
232
231
|
width: 'calc(100% + ' + style.paddingLeft + ' + ' + style.paddingRight + ')',
|
|
233
232
|
});
|
|
234
233
|
} else {
|
|
235
|
-
|
|
234
|
+
dom.css(drawer, { 'margin-top': '', 'margin-left': '', 'margin-right': '', width: '' });
|
|
236
235
|
}
|
|
237
236
|
|
|
238
|
-
if (
|
|
239
|
-
|
|
237
|
+
if (dom.hasClass(node, 'column')) {
|
|
238
|
+
var padded = classes(node).some(function(name) {
|
|
240
239
|
return /^p[xse]?-/.test(name) && patterns.p.test(name);
|
|
241
|
-
})
|
|
240
|
+
});
|
|
241
|
+
dom.all(drawer, '.ge-spacing-gutter').forEach(function(note) { dom.toggle(note, padded); });
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
244
|
}
|
|
@@ -268,13 +268,12 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
|
|
|
268
268
|
panel: function(node, kind) {
|
|
269
269
|
if (!applies(node, kind)) { return null; }
|
|
270
270
|
|
|
271
|
-
var box =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
;
|
|
271
|
+
var box = dom.element('div', { 'class': 'ge-spacing' });
|
|
272
|
+
box.appendChild(group(node, 'p', ge.t('utility.padding')));
|
|
273
|
+
box.appendChild(group(node, 'm', ge.t('utility.margin')));
|
|
275
274
|
|
|
276
275
|
if (kind === 'column') {
|
|
277
|
-
|
|
276
|
+
box.appendChild(dom.element('small', { 'class': 'ge-spacing-gutter' }, ge.t('utility.spacing_gutter')));
|
|
278
277
|
}
|
|
279
278
|
|
|
280
279
|
return box;
|
|
@@ -286,7 +285,7 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
|
|
|
286
285
|
var styles = {};
|
|
287
286
|
|
|
288
287
|
['p', 'm'].forEach(function(key) {
|
|
289
|
-
if (carries(node, key)) {
|
|
288
|
+
if (carries(node, key)) { Object.assign(styles, sides(node, key, breakpoint)); }
|
|
290
289
|
});
|
|
291
290
|
|
|
292
291
|
return styles;
|
|
@@ -295,5 +294,3 @@ $.fn.gridEditor.utilities.spacing = function(ge) {
|
|
|
295
294
|
onRefresh: mark,
|
|
296
295
|
};
|
|
297
296
|
};
|
|
298
|
-
|
|
299
|
-
})(jQuery);
|
|
@@ -6,98 +6,134 @@
|
|
|
6
6
|
* summernote in air mode. What it can ask the editor for is the
|
|
7
7
|
* handle its factory is called with, described in docs/plugins.md.
|
|
8
8
|
*
|
|
9
|
+
* <script src="jquery/jquery.min.js"></script>
|
|
9
10
|
* <script src="summernote/summernote-bs5.min.js"></script>
|
|
10
|
-
* <script src="dist/
|
|
11
|
+
* <script src="dist/grideditor.min.js"></script>
|
|
11
12
|
* <script src="dist/plugins/grideditor.summernote.min.js"></script>
|
|
12
13
|
*
|
|
14
|
+
* Summernote is a jQuery plugin, so this is the one plugin that needs jQuery
|
|
15
|
+
* on the page: it calls summernote on a content area through it, and
|
|
16
|
+
* nothing else. Towards the editor it is plain DOM, like every plugin, and
|
|
17
|
+
* it needs no jQuery adapter.
|
|
18
|
+
*
|
|
13
19
|
* Up to 5.x the main bundle carried a copy of this file; since 6.0 it is
|
|
14
|
-
* loaded on its own, like every plugin.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
|
|
20
|
+
* loaded on its own, like every plugin. It imports what every text editor
|
|
21
|
+
* shares - text blocks, the Text button, createText, making the host's plain
|
|
22
|
+
* content a text - from src/js/text/grideditor.text.js, which the build puts
|
|
23
|
+
* in its classic script, installed once however many editors a page loads.
|
|
24
|
+
*/
|
|
25
|
+
import { GridEditor } from '../grideditor.js';
|
|
26
|
+
import * as dom from '../dom.js';
|
|
27
|
+
import '../text/grideditor.text.js';
|
|
28
|
+
|
|
29
|
+
Object.assign(GridEditor.locales.en, {
|
|
30
|
+
'text.summernote': 'Summernote',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var INITIAL_CONTENT = '<p>Lorem ipsum dolores</p>';
|
|
34
|
+
|
|
35
|
+
function isPlainObject(value) {
|
|
36
|
+
return !!value && Object.prototype.toString.call(value) === '[object Object]';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* `sources` merged into `target`, objects and arrays copied all the way
|
|
41
|
+
* down rather than shared: what jQuery's deep extend did for summernote's
|
|
42
|
+
* options, whose callbacks the host's config and this file both fill in.
|
|
19
43
|
*/
|
|
20
|
-
|
|
44
|
+
function deepMerge(target) {
|
|
45
|
+
Array.prototype.slice.call(arguments, 1).forEach(function(source) {
|
|
46
|
+
Object.keys(source || {}).forEach(function(key) {
|
|
47
|
+
var value = source[key];
|
|
48
|
+
|
|
49
|
+
if (value === undefined || value === target) { return; }
|
|
21
50
|
|
|
22
|
-
|
|
23
|
-
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
target[key] = deepMerge(Array.isArray(target[key]) ? target[key] : [], value);
|
|
53
|
+
} else if (isPlainObject(value)) {
|
|
54
|
+
target[key] = deepMerge(isPlainObject(target[key]) ? target[key] : {}, value);
|
|
55
|
+
} else {
|
|
56
|
+
target[key] = value;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
24
59
|
});
|
|
25
60
|
|
|
26
|
-
|
|
61
|
+
return target;
|
|
62
|
+
}
|
|
27
63
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
64
|
+
GridEditor.texts.summernote = function(ge) {
|
|
65
|
+
return {
|
|
66
|
+
labelKey: 'text.summernote',
|
|
67
|
+
initialContent: INITIAL_CONTENT,
|
|
68
|
+
missingKey: 'error.summernote_missing',
|
|
33
69
|
|
|
34
|
-
|
|
70
|
+
available: function() { return !!(window.jQuery && window.jQuery.fn && window.jQuery.fn.summernote); },
|
|
35
71
|
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
start: function(contentAreas) {
|
|
73
|
+
var settings = ge.settings;
|
|
74
|
+
var $ = window.jQuery;
|
|
38
75
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
76
|
+
// Summernote 0.9.1 calls $.now(), which jQuery 4 removed, and
|
|
77
|
+
// cannot open without it. Given back only where it is missing,
|
|
78
|
+
// and only once summernote is actually used.
|
|
79
|
+
if (!$.now) { $.now = Date.now; }
|
|
43
80
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (contentArea.hasClass('active')) { return; }
|
|
81
|
+
contentAreas.forEach(function(contentArea) {
|
|
82
|
+
if (dom.hasClass(contentArea, 'active')) { return; }
|
|
47
83
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
callback.call(this);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// The editor owns what is inside the
|
|
76
|
-
// content area now, so the grid editor is
|
|
77
|
-
// told to put its own furniture back
|
|
78
|
-
ge.textReady(contentArea);
|
|
79
|
-
|
|
80
|
-
contentArea.summernote('focus');
|
|
84
|
+
if (contentArea.innerHTML == INITIAL_CONTENT) {
|
|
85
|
+
contentArea.innerHTML = '';
|
|
86
|
+
}
|
|
87
|
+
dom.addClass(contentArea, 'active');
|
|
88
|
+
|
|
89
|
+
var configuration = deepMerge(
|
|
90
|
+
{},
|
|
91
|
+
(settings.summernote && settings.summernote.config ? settings.summernote.config : {}),
|
|
92
|
+
{
|
|
93
|
+
tabsize: 2,
|
|
94
|
+
airMode: true,
|
|
95
|
+
// Focus editor on creation
|
|
96
|
+
callbacks: {
|
|
97
|
+
onInit: function() {
|
|
98
|
+
|
|
99
|
+
// Call original oninit function, if one was passed in the config
|
|
100
|
+
var callback;
|
|
101
|
+
try {
|
|
102
|
+
callback = settings.summernote.config.callbacks.onInit;
|
|
103
|
+
} catch (err) {
|
|
104
|
+
// No callback passed
|
|
105
|
+
}
|
|
106
|
+
if (callback) {
|
|
107
|
+
callback.call(this);
|
|
81
108
|
}
|
|
109
|
+
|
|
110
|
+
// The editor owns what is inside the
|
|
111
|
+
// content area now, so the grid editor is
|
|
112
|
+
// told to put its own furniture back
|
|
113
|
+
ge.textReady(contentArea);
|
|
114
|
+
|
|
115
|
+
$(contentArea).summernote('focus');
|
|
82
116
|
}
|
|
83
117
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
$(contentArea).summernote(configuration);
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
stop: function(contentAreas) {
|
|
125
|
+
var $ = window.jQuery;
|
|
126
|
+
|
|
127
|
+
contentAreas.filter(function(contentArea) {
|
|
128
|
+
return dom.hasClass(contentArea, 'active');
|
|
129
|
+
}).forEach(function(contentArea) {
|
|
130
|
+
if ($ && $.fn.summernote) { $(contentArea).summernote('destroy'); }
|
|
131
|
+
|
|
132
|
+
dom.removeClass(contentArea, 'active');
|
|
133
|
+
['id', 'style', 'spellcheck'].forEach(function(name) {
|
|
134
|
+
contentArea.removeAttribute(name);
|
|
99
135
|
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
136
|
+
});
|
|
137
|
+
},
|
|
102
138
|
};
|
|
103
|
-
}
|
|
139
|
+
};
|
|
@@ -5,43 +5,48 @@
|
|
|
5
5
|
* a tabs container. What it can ask the editor for is the handle its factory is
|
|
6
6
|
* called with, described in docs/plugins.md.
|
|
7
7
|
*
|
|
8
|
-
* <script src="dist/
|
|
8
|
+
* <script src="dist/grideditor.min.js"></script>
|
|
9
9
|
* <script src="dist/plugins/grideditor.tabs.min.js"></script>
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
import { GridEditor } from '../grideditor.js';
|
|
12
|
+
import * as dom from '../dom.js';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
Object.assign(GridEditor.locales.en, {
|
|
14
15
|
'container.add_tabs': 'Tabs',
|
|
15
16
|
'container.add_tab': 'Add tab',
|
|
16
17
|
'container.tab_label': 'Tab {number}',
|
|
17
18
|
'confirm.delete_tab': 'Delete this tab and everything in it?',
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
GridEditor.containers.tabs = function(ge) {
|
|
21
22
|
|
|
22
23
|
function addTabTo(container, options) {
|
|
23
24
|
options = options || {};
|
|
24
25
|
|
|
25
|
-
var strip =
|
|
26
|
-
var content =
|
|
26
|
+
var strip = dom.one(container, ':scope > .nav-tabs');
|
|
27
|
+
var content = dom.one(container, ':scope > .tab-content');
|
|
27
28
|
var id = ge.containerId('tab');
|
|
28
|
-
var number =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
var number = dom.children(strip, '.nav-item').length + 1;
|
|
30
|
+
|
|
31
|
+
var tab = strip.appendChild(dom.element('li', { 'class': 'nav-item ge-tab', role: 'presentation' }));
|
|
32
|
+
var button = tab.appendChild(dom.element('button', {
|
|
33
|
+
'class': 'nav-link',
|
|
34
|
+
type: 'button',
|
|
35
|
+
role: 'tab',
|
|
36
|
+
'data-bs-toggle': 'tab',
|
|
37
|
+
'data-bs-target': '#' + id,
|
|
38
|
+
'aria-controls': id,
|
|
39
|
+
}));
|
|
40
|
+
button.appendChild(dom.element('span', { 'class': 'ge-pane-label' },
|
|
41
|
+
options.label || ge.t('container.tab_label', { number: number })));
|
|
42
|
+
|
|
43
|
+
var pane = content.appendChild(dom.element('div', {
|
|
44
|
+
'class': 'tab-pane fade',
|
|
45
|
+
role: 'tabpanel',
|
|
46
|
+
tabindex: '0',
|
|
47
|
+
id: id,
|
|
48
|
+
}));
|
|
49
|
+
pane.appendChild(ge.defaultRegion());
|
|
45
50
|
|
|
46
51
|
if (options.activate || number === 1) { activatePane(container, pane); }
|
|
47
52
|
|
|
@@ -49,26 +54,26 @@ $.fn.gridEditor.containers.tabs = function(ge) {
|
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
function activatePane(container, pane) {
|
|
52
|
-
var id = pane.
|
|
57
|
+
var id = pane.getAttribute('id');
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
dom.all(container, ':scope > .tab-content > .tab-pane').forEach(function(each) {
|
|
60
|
+
dom.removeClass(each, 'show active');
|
|
61
|
+
});
|
|
62
|
+
dom.addClass(pane, 'show active');
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
var active = button.attr('data-bs-target') === '#' + id;
|
|
64
|
+
dom.all(container, ':scope > .nav-tabs .nav-link').forEach(function(button) {
|
|
65
|
+
var active = button.getAttribute('data-bs-target') === '#' + id;
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
dom.toggleClass(button, 'active', active);
|
|
68
|
+
button.setAttribute('aria-selected', active ? 'true' : 'false');
|
|
62
69
|
});
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
function tabOf(container, pane) {
|
|
66
|
-
return container.find('> .nav-tabs .nav-link[data-bs-target="#' + pane.attr('id') + '"]')
|
|
67
|
-
.closest('.nav-item');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
72
|
function paneOf(container, tab) {
|
|
71
|
-
|
|
73
|
+
var link = dom.one(tab, '.nav-link');
|
|
74
|
+
var target = link ? link.getAttribute('data-bs-target') : null;
|
|
75
|
+
|
|
76
|
+
return target ? dom.one(container, target) : null;
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
return {
|
|
@@ -77,7 +82,7 @@ $.fn.gridEditor.containers.tabs = function(ge) {
|
|
|
77
82
|
// A tab strip sorts its own tabs, and the panes follow them. No
|
|
78
83
|
// group: a tab belongs to the strip it was made in.
|
|
79
84
|
onSortable: function(sortable) {
|
|
80
|
-
sortable(ge.canvas
|
|
85
|
+
sortable(dom.all(ge.canvas, '.ge-container-tabs > .nav-tabs'), {
|
|
81
86
|
draggable: '.ge-tab',
|
|
82
87
|
});
|
|
83
88
|
},
|
|
@@ -85,12 +90,12 @@ $.fn.gridEditor.containers.tabs = function(ge) {
|
|
|
85
90
|
paneKind: 'tab',
|
|
86
91
|
|
|
87
92
|
create: function(options) {
|
|
88
|
-
var container =
|
|
93
|
+
var container = dom.element('div', { 'data-ge-container': 'tabs' });
|
|
89
94
|
var labels = options.labels || [];
|
|
90
95
|
var count = options.tabs || labels.length || 2;
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
container.appendChild(dom.element('ul', { 'class': 'nav nav-tabs', role: 'tablist' }));
|
|
98
|
+
container.appendChild(dom.element('div', { 'class': 'tab-content' }));
|
|
94
99
|
|
|
95
100
|
for (var i = 0; i < count; i++) {
|
|
96
101
|
addTabTo(container, { label: labels[i] });
|
|
@@ -102,27 +107,29 @@ $.fn.gridEditor.containers.tabs = function(ge) {
|
|
|
102
107
|
addPane: addTabTo,
|
|
103
108
|
|
|
104
109
|
mark: function(container) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var tab = $(this).addClass('ge-tab');
|
|
110
|
+
dom.all(container, ':scope > .tab-content > .tab-pane').forEach(function(pane) {
|
|
111
|
+
dom.addClass(pane, 'ge-tab-pane');
|
|
112
|
+
});
|
|
109
113
|
|
|
114
|
+
dom.all(container, ':scope > .nav-tabs > .nav-item').forEach(function(tab) {
|
|
115
|
+
dom.addClass(tab, 'ge-tab');
|
|
110
116
|
|
|
111
|
-
|
|
117
|
+
var link = dom.one(tab, '.nav-link');
|
|
118
|
+
if (link) { ge.makeLabelEditable(ge.labelIn(link)); }
|
|
112
119
|
|
|
113
|
-
if (
|
|
120
|
+
if (dom.child(tab, '.ge-tools-drawer')) { return; }
|
|
114
121
|
|
|
115
122
|
ge.createPaneControls(tab, 'tab', ge.settings.tab_tools, ge.t('confirm.delete_tab'),
|
|
116
123
|
function(removed) {
|
|
117
124
|
var pane = paneOf(container, tab);
|
|
118
|
-
var wasActive =
|
|
125
|
+
var wasActive = dom.hasClass(pane, 'active');
|
|
119
126
|
|
|
120
|
-
|
|
121
|
-
pane.remove();
|
|
127
|
+
dom.fadeOut(tab, 200, function() {
|
|
128
|
+
if (pane) { pane.remove(); }
|
|
122
129
|
removed();
|
|
123
130
|
|
|
124
|
-
var first =
|
|
125
|
-
if (wasActive && first
|
|
131
|
+
var first = dom.one(container, ':scope > .tab-content > .tab-pane');
|
|
132
|
+
if (wasActive && first) { activatePane(container, first); }
|
|
126
133
|
});
|
|
127
134
|
});
|
|
128
135
|
});
|
|
@@ -130,19 +137,20 @@ $.fn.gridEditor.containers.tabs = function(ge) {
|
|
|
130
137
|
|
|
131
138
|
unmark: function(container) {
|
|
132
139
|
ge.resumeToggles(container);
|
|
133
|
-
|
|
140
|
+
dom.all(container, '.ge-tab-pane').forEach(function(pane) {
|
|
141
|
+
dom.removeClass(pane, 'ge-tab-pane');
|
|
142
|
+
});
|
|
134
143
|
ge.unwrapLabels(container);
|
|
135
144
|
},
|
|
136
145
|
|
|
137
146
|
/** Panes read in tab order, whatever order they were dropped in. */
|
|
138
147
|
afterPaneMove: function(container) {
|
|
139
|
-
var content =
|
|
148
|
+
var content = dom.one(container, ':scope > .tab-content');
|
|
140
149
|
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
dom.all(container, ':scope > .nav-tabs > .nav-item').forEach(function(tab) {
|
|
151
|
+
var pane = paneOf(container, tab);
|
|
152
|
+
if (pane) { content.appendChild(pane); }
|
|
143
153
|
});
|
|
144
154
|
},
|
|
145
155
|
};
|
|
146
156
|
};
|
|
147
|
-
|
|
148
|
-
})(jQuery);
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
* editor for is the handle its factory is called with, described in
|
|
8
8
|
* docs/plugins.md.
|
|
9
9
|
*
|
|
10
|
-
* <script src="dist/
|
|
10
|
+
* <script src="dist/grideditor.min.js"></script>
|
|
11
11
|
* <script src="dist/plugins/grideditor.textalign.min.js"></script>
|
|
12
12
|
*
|
|
13
13
|
* The class aligns everything inside the node that does not align itself: a
|
|
14
14
|
* paragraph the rich text editor gave its own text-align keeps it.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
import { GridEditor } from '../grideditor.js';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Object.assign(GridEditor.locales.en, {
|
|
19
19
|
'utility.text_align': 'Text alignment',
|
|
20
20
|
'utility.text_start': 'Start',
|
|
21
21
|
'utility.text_center': 'Center',
|
|
@@ -25,7 +25,7 @@ $.extend($.fn.gridEditor.locales.en, {
|
|
|
25
25
|
/** Start and end are left and right: Bootstrap's css is left to right. */
|
|
26
26
|
var CSS = { start: 'left', center: 'center', end: 'right' };
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
GridEditor.utilities.textalign = function(ge) {
|
|
29
29
|
|
|
30
30
|
function label(value) {
|
|
31
31
|
if (value === 'start') { return ge.t('utility.text_start'); }
|
|
@@ -56,5 +56,3 @@ $.fn.gridEditor.utilities.textalign = function(ge) {
|
|
|
56
56
|
}],
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
|
-
|
|
60
|
-
})(jQuery);
|