@themarioga/grid-editor 6.0.0-beta.5 → 7.0.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 +54 -0
- package/README.md +140 -89
- package/UPGRADING.md +146 -2
- 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 -170
- 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 +482 -493
- 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 +491 -471
- 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 +500 -534
- 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 +7 -4
- package/docs/plugins.md +49 -27
- package/example/adapter.html +112 -0
- package/example/attributes.html +85 -61
- package/example/autocols.html +9 -9
- package/example/autosave.html +13 -14
- package/example/basic.html +4 -5
- package/example/breakpoints.html +5 -6
- package/example/ckeditor.html +4 -5
- package/example/clipboard.html +11 -10
- package/example/codemirror.html +9 -7
- package/example/containers.html +7 -8
- package/example/custom_editor.html +53 -34
- package/example/elements.html +10 -11
- 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 +9 -9
- package/package.json +43 -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 -158
- 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 +147 -139
- package/src/js/plugins/grideditor.visibility.js +24 -25
- package/src/js/register.js +18 -0
- package/src/js/text/grideditor.text.js +81 -106
- 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,161 +7,169 @@
|
|
|
7
7
|
* factory is called with, described in docs/plugins.md.
|
|
8
8
|
*
|
|
9
9
|
* <script src="tinymce/tinymce.min.js"></script>
|
|
10
|
-
* <script src="dist/
|
|
10
|
+
* <script src="dist/grideditor.min.js"></script>
|
|
11
11
|
* <script src="dist/plugins/grideditor.tinymce.min.js"></script>
|
|
12
12
|
*
|
|
13
13
|
* 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
|
-
* page loads.
|
|
14
|
+
* loaded on its own, like every plugin. It imports what every text editor
|
|
15
|
+
* shares - text blocks, the Text button, createText, making the host's plain
|
|
16
|
+
* content a text - from src/js/text/grideditor.text.js, which the build puts
|
|
17
|
+
* in its classic script, installed once however many editors a page loads.
|
|
19
18
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
import { GridEditor } from '../grideditor.js';
|
|
20
|
+
import * as dom from '../dom.js';
|
|
21
|
+
import '../text/grideditor.text.js';
|
|
22
|
+
|
|
23
|
+
Object.assign(GridEditor.locales.en, {
|
|
24
|
+
'text.tinymce': 'tinyMCE',
|
|
25
|
+
'warning.oninit_removed': 'tinyMCE\'s oninit option was removed in 7.0 and is ignored: use init_instance_callback.',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// tinyMCE snapshots the target element's attributes when an inline editor is
|
|
29
|
+
// created and restores them on remove(), so this has to run *after* remove()
|
|
30
|
+
// to keep the grid editor's own class and tinyMCE's leftovers off the element.
|
|
31
|
+
function cleanUp(contentArea) {
|
|
32
|
+
dom.removeClass(contentArea, 'active ge-rte-active');
|
|
33
|
+
['id', 'style', 'spellcheck', 'contenteditable', 'data-mce-style'].forEach(function(name) {
|
|
34
|
+
contentArea.removeAttribute(name);
|
|
24
35
|
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var INITIAL_CONTENT = '<p>Lorem ipsum dolores</p>';
|
|
39
|
+
|
|
40
|
+
// What this file remembers about a content area: its editor, and whether a
|
|
41
|
+
// deinit came before that editor was ready
|
|
42
|
+
var editors = new WeakMap();
|
|
43
|
+
var pendingRemove = new WeakSet();
|
|
44
|
+
|
|
45
|
+
// Said once per page, however many editors are on it
|
|
46
|
+
var warnedOninit = false;
|
|
47
|
+
|
|
48
|
+
GridEditor.texts.tinymce = function(ge) {
|
|
49
|
+
return {
|
|
50
|
+
labelKey: 'text.tinymce',
|
|
51
|
+
initialContent: INITIAL_CONTENT,
|
|
52
|
+
missingKey: 'error.tinymce_missing',
|
|
53
|
+
|
|
54
|
+
available: function() { return !!window.tinymce; },
|
|
55
|
+
|
|
56
|
+
start: function(contentAreas) {
|
|
57
|
+
var settings = ge.settings;
|
|
58
|
+
var userConfig = (settings.tinymce && settings.tinymce.config) ? settings.tinymce.config : {};
|
|
59
|
+
|
|
60
|
+
// 'oninit' was the pre-6 name for init_instance_callback, honoured
|
|
61
|
+
// through 6.x and gone in 7.0
|
|
62
|
+
if (userConfig.oninit && !warnedOninit) {
|
|
63
|
+
warnedOninit = true;
|
|
64
|
+
ge.warn(ge.t('warning.oninit_removed'));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
contentAreas.forEach(function(contentArea) {
|
|
68
|
+
if (dom.hasClass(contentArea, 'active')) { return; }
|
|
69
|
+
|
|
70
|
+
if (contentArea.innerHTML == INITIAL_CONTENT) {
|
|
71
|
+
contentArea.innerHTML = '';
|
|
72
|
+
}
|
|
73
|
+
dom.addClass(contentArea, 'active');
|
|
74
|
+
|
|
75
|
+
var configuration = Object.assign({
|
|
76
|
+
// tinyMCE's own "Upgrade" badge in the menubar. Off by
|
|
77
|
+
// default because an inline editor here is a column of
|
|
78
|
+
// someone's page, not tinyMCE's own interface; a host that
|
|
79
|
+
// wants it back passes promotion: true.
|
|
80
|
+
promotion: false,
|
|
81
|
+
}, userConfig, {
|
|
82
|
+
target: contentArea,
|
|
83
|
+
inline: true,
|
|
84
|
+
init_instance_callback: function(editor) {
|
|
85
|
+
// deinit ran before this init finished, so tear it down again
|
|
86
|
+
if (pendingRemove.has(contentArea)) {
|
|
87
|
+
pendingRemove.delete(contentArea);
|
|
88
|
+
editor.remove();
|
|
89
|
+
// deinit already ran and cannot clean up after this
|
|
90
|
+
// late remove(), so do it here instead
|
|
91
|
+
cleanUp(contentArea);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
25
94
|
|
|
26
|
-
|
|
27
|
-
// created and restores them on remove(), so this has to run *after* remove()
|
|
28
|
-
// to keep the grid editor's own class and tinyMCE's leftovers off the element.
|
|
29
|
-
function cleanUp(contentArea) {
|
|
30
|
-
contentArea
|
|
31
|
-
.removeClass('active')
|
|
32
|
-
.removeClass('ge-rte-active')
|
|
33
|
-
.removeAttr('id')
|
|
34
|
-
.removeAttr('style')
|
|
35
|
-
.removeAttr('spellcheck')
|
|
36
|
-
.removeAttr('contenteditable')
|
|
37
|
-
.removeAttr('data-mce-style')
|
|
38
|
-
;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var INITIAL_CONTENT = '<p>Lorem ipsum dolores</p>';
|
|
42
|
-
|
|
43
|
-
$.fn.gridEditor.texts.tinymce = function(ge) {
|
|
44
|
-
return {
|
|
45
|
-
labelKey: 'text.tinymce',
|
|
46
|
-
initialContent: INITIAL_CONTENT,
|
|
47
|
-
missingKey: 'error.tinymce_missing',
|
|
48
|
-
|
|
49
|
-
available: function() { return !!window.tinymce; },
|
|
50
|
-
|
|
51
|
-
start: function(contentAreas) {
|
|
52
|
-
var settings = ge.settings;
|
|
53
|
-
var userConfig = (settings.tinymce && settings.tinymce.config) ? settings.tinymce.config : {};
|
|
54
|
-
|
|
55
|
-
contentAreas.each(function() {
|
|
56
|
-
var contentArea = $(this);
|
|
57
|
-
if (contentArea.hasClass('active')) { return; }
|
|
58
|
-
|
|
59
|
-
if (contentArea.html() == INITIAL_CONTENT) {
|
|
60
|
-
contentArea.html('');
|
|
61
|
-
}
|
|
62
|
-
contentArea.addClass('active');
|
|
63
|
-
|
|
64
|
-
var configuration = $.extend({
|
|
65
|
-
// tinyMCE's own "Upgrade" badge in the menubar. Off by
|
|
66
|
-
// default because an inline editor here is a column of
|
|
67
|
-
// someone's page, not tinyMCE's own interface; a host that
|
|
68
|
-
// wants it back passes promotion: true.
|
|
69
|
-
promotion: false,
|
|
70
|
-
}, userConfig, {
|
|
71
|
-
target: this,
|
|
72
|
-
inline: true,
|
|
73
|
-
init_instance_callback: function(editor) {
|
|
74
|
-
// deinit ran before this init finished, so tear it down again
|
|
75
|
-
if (contentArea.data('ge-tinymce-pending-remove')) {
|
|
76
|
-
contentArea.removeData('ge-tinymce-pending-remove');
|
|
77
|
-
editor.remove();
|
|
78
|
-
// deinit already ran and cannot clean up after this
|
|
79
|
-
// late remove(), so do it here instead
|
|
80
|
-
cleanUp(contentArea);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
contentArea.data('ge-tinymce', editor);
|
|
85
|
-
|
|
86
|
-
// The editor rewrote what is inside this content area
|
|
87
|
-
// while it took it over, so whatever the grid editor
|
|
88
|
-
// had in there is gone. Saying so lets it put its own
|
|
89
|
-
// furniture back.
|
|
90
|
-
ge.textReady(contentArea);
|
|
95
|
+
editors.set(contentArea, editor);
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
ge.textReady(contentArea);
|
|
98
|
-
});
|
|
97
|
+
// The editor rewrote what is inside this content area
|
|
98
|
+
// while it took it over, so whatever the grid editor
|
|
99
|
+
// had in there is gone. Saying so lets it put its own
|
|
100
|
+
// furniture back.
|
|
101
|
+
ge.textReady(contentArea);
|
|
99
102
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
// Undo and redo rewrite it too, from snapshots that
|
|
104
|
+
// leave out whatever is marked data-mce-bogus - an
|
|
105
|
+
// element's drawer among them - so it goes back in
|
|
106
|
+
// after each of those as well
|
|
107
|
+
editor.on('Undo Redo', function() {
|
|
108
|
+
ge.textReady(contentArea);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// The inline toolbar is laid out against the element's
|
|
112
|
+
// geometry at the moment tinyMCE draws it, and an
|
|
113
|
+
// element that has just appeared - a tab pane, an
|
|
114
|
+
// accordion body, a column whose width is still
|
|
115
|
+
// settling - may not have its own width yet. Asking
|
|
116
|
+
// for the ui again once the browser has laid the frame
|
|
117
|
+
// out measures it as it now is, instead of leaving a
|
|
118
|
+
// toolbar wrapped into a narrow column.
|
|
119
|
+
window.requestAnimationFrame(function() {
|
|
120
|
+
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
121
|
+
|
|
122
|
+
editor.ui.show();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// And again whenever the user comes back to this
|
|
126
|
+
// editor: by then the element may have been resized,
|
|
127
|
+
// hidden and shown again - a tab switched away from
|
|
128
|
+
// and back, a column made narrower - and the toolbar
|
|
129
|
+
// is only ever as right as its last measurement.
|
|
130
|
+
editor.on('focus', function() {
|
|
108
131
|
window.requestAnimationFrame(function() {
|
|
109
132
|
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
110
133
|
|
|
111
134
|
editor.ui.show();
|
|
112
135
|
});
|
|
136
|
+
});
|
|
113
137
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// hidden and shown again - a tab switched away from
|
|
117
|
-
// and back, a column made narrower - and the toolbar
|
|
118
|
-
// is only ever as right as its last measurement.
|
|
119
|
-
editor.on('focus', function() {
|
|
120
|
-
window.requestAnimationFrame(function() {
|
|
121
|
-
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
122
|
-
|
|
123
|
-
editor.ui.show();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
138
|
+
// Bring focus to text field
|
|
139
|
+
editor.focus();
|
|
126
140
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// Call the original callbacks, if any were passed in the config
|
|
131
|
-
if (userConfig.init_instance_callback) {
|
|
132
|
-
userConfig.init_instance_callback.call(this, editor);
|
|
133
|
-
}
|
|
134
|
-
// 'oninit' is the pre-6 name, honoured so existing configs keep working
|
|
135
|
-
if (userConfig.oninit) {
|
|
136
|
-
userConfig.oninit.call(this, editor);
|
|
137
|
-
}
|
|
141
|
+
// Call the original callback, if one was passed in the config
|
|
142
|
+
if (userConfig.init_instance_callback) {
|
|
143
|
+
userConfig.init_instance_callback.call(this, editor);
|
|
138
144
|
}
|
|
139
|
-
});
|
|
140
|
-
// We always edit the element we were handed, so a selector in the
|
|
141
|
-
// user config would only fight with target
|
|
142
|
-
delete configuration.selector;
|
|
143
|
-
|
|
144
|
-
window.tinymce.init(configuration);
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
stop: function(contentAreas) {
|
|
149
|
-
contentAreas.filter('.active').each(function() {
|
|
150
|
-
var contentArea = $(this);
|
|
151
|
-
var editor = contentArea.data('ge-tinymce');
|
|
152
|
-
|
|
153
|
-
if (editor) {
|
|
154
|
-
contentArea.removeData('ge-tinymce');
|
|
155
|
-
editor.remove();
|
|
156
|
-
} else {
|
|
157
|
-
// tinymce.init() is asynchronous, so the editor may not exist
|
|
158
|
-
// yet. Leave a note for init_instance_callback to remove it.
|
|
159
|
-
contentArea.data('ge-tinymce-pending-remove', true);
|
|
160
145
|
}
|
|
161
|
-
|
|
162
|
-
cleanUp(contentArea);
|
|
163
146
|
});
|
|
164
|
-
|
|
165
|
-
|
|
147
|
+
// We always edit the element we were handed, so a selector in the
|
|
148
|
+
// user config would only fight with target
|
|
149
|
+
delete configuration.selector;
|
|
150
|
+
delete configuration.oninit;
|
|
151
|
+
|
|
152
|
+
window.tinymce.init(configuration);
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
stop: function(contentAreas) {
|
|
157
|
+
contentAreas.filter(function(contentArea) {
|
|
158
|
+
return dom.hasClass(contentArea, 'active');
|
|
159
|
+
}).forEach(function(contentArea) {
|
|
160
|
+
var editor = editors.get(contentArea);
|
|
161
|
+
|
|
162
|
+
if (editor) {
|
|
163
|
+
editors.delete(contentArea);
|
|
164
|
+
editor.remove();
|
|
165
|
+
} else {
|
|
166
|
+
// tinymce.init() is asynchronous, so the editor may not exist
|
|
167
|
+
// yet. Leave a note for init_instance_callback to remove it.
|
|
168
|
+
pendingRemove.add(contentArea);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
cleanUp(contentArea);
|
|
172
|
+
});
|
|
173
|
+
},
|
|
166
174
|
};
|
|
167
|
-
}
|
|
175
|
+
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* block). What it can ask the editor for is the handle its factory is called
|
|
9
9
|
* with, described in docs/plugins.md.
|
|
10
10
|
*
|
|
11
|
-
* <script src="dist/
|
|
11
|
+
* <script src="dist/grideditor.min.js"></script>
|
|
12
12
|
* <script src="dist/plugins/grideditor.visibility.min.js"></script>
|
|
13
13
|
*
|
|
14
14
|
* A hidden node is never hidden from the editor, which would leave nothing to
|
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
* utilities.visibility.drawer: false leaves the eye out of the drawers, and
|
|
19
19
|
* the panel field is the only control.
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
import { GridEditor } from '../grideditor.js';
|
|
22
|
+
import * as dom from '../dom.js';
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Object.assign(GridEditor.locales.en, {
|
|
24
25
|
'utility.visibility': 'Visibility',
|
|
25
26
|
'utility.visibility_hidden': 'Hidden',
|
|
26
27
|
'utility.visibility_shown': 'Shown',
|
|
@@ -34,9 +35,9 @@ var CLASS_PATTERN = /(?:^|\s)d-(?:(?:sm|md|lg|xl|xxl)-)?(?:none|block|flex)(?:\s
|
|
|
34
35
|
|
|
35
36
|
var NODES = '.row, .column, .ge-content, .ge-element, [data-ge-container]';
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
GridEditor.utilities.visibility = function(ge) {
|
|
38
39
|
|
|
39
|
-
var options =
|
|
40
|
+
var options = Object.assign({ drawer: true }, ge.settings.utilities.visibility);
|
|
40
41
|
|
|
41
42
|
/** What "shown" is written as on this kind of node. */
|
|
42
43
|
function shown(kind) {
|
|
@@ -45,7 +46,7 @@ $.fn.gridEditor.utilities.visibility = function(ge) {
|
|
|
45
46
|
|
|
46
47
|
function applies(node, kind) {
|
|
47
48
|
return kind === 'row' || kind === 'column' || kind === 'element' || kind === 'text' || kind === 'plain' ||
|
|
48
|
-
|
|
49
|
+
dom.is(node, '[data-ge-container]');
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
function hiddenAt(node, view) {
|
|
@@ -103,38 +104,38 @@ $.fn.gridEditor.utilities.visibility = function(ge) {
|
|
|
103
104
|
* and data-ge-hidden-in carries the badge text for the all view.
|
|
104
105
|
*/
|
|
105
106
|
function mark(scope) {
|
|
106
|
-
|
|
107
|
-
var node = $(this);
|
|
107
|
+
dom.selfAndAll(scope, NODES).forEach(function(node) {
|
|
108
108
|
var kind = ge.kindOf(node);
|
|
109
|
-
var carries = applies(node, kind) && CLASS_PATTERN.test(node.
|
|
109
|
+
var carries = applies(node, kind) && CLASS_PATTERN.test(node.getAttribute('class') || '');
|
|
110
110
|
var tiers = carries ? hiddenTiers(node) : [];
|
|
111
111
|
var here = carries && hiddenHere(node);
|
|
112
112
|
var partly = carries && ge.view() === 'all' && tiers.length > 0 && !here;
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
dom.toggleClass(node, 'ge-visibility', carries);
|
|
115
|
+
dom.toggleClass(node, 'ge-hidden-in-view', here);
|
|
115
116
|
|
|
116
117
|
if (partly) {
|
|
117
|
-
node.
|
|
118
|
+
node.setAttribute('data-ge-hidden-in', ge.t('badge.hidden_in', { breakpoints: tiers.join(', ') }));
|
|
118
119
|
} else {
|
|
119
|
-
node.
|
|
120
|
+
node.removeAttribute('data-ge-hidden-in');
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
.
|
|
125
|
-
.
|
|
123
|
+
dom.children(node, '.ge-tools-drawer').forEach(function(drawer) {
|
|
124
|
+
dom.children(drawer, '.ge-visibility-tool').forEach(function(tool) {
|
|
125
|
+
tool.setAttribute('title', here ? ge.t('tool.show_in_view') : ge.t('tool.hide_in_view'));
|
|
126
|
+
dom.all(tool, 'i').forEach(function(icon) {
|
|
127
|
+
icon.setAttribute('class', here ? 'bi bi-eye-slash' : 'bi bi-eye');
|
|
128
|
+
});
|
|
129
|
+
});
|
|
126
130
|
});
|
|
127
131
|
});
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
function unmark() {
|
|
131
|
-
ge.canvas
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
;
|
|
136
|
-
|
|
137
|
-
if (!node.attr('class')) { node.removeAttr('class'); }
|
|
135
|
+
dom.all(ge.canvas, '.ge-visibility, .ge-hidden-in-view, [data-ge-hidden-in]').forEach(function(node) {
|
|
136
|
+
dom.removeClass(node, 'ge-visibility ge-hidden-in-view');
|
|
137
|
+
node.removeAttribute('data-ge-hidden-in');
|
|
138
|
+
dom.dropEmptyClass(node);
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
|
|
@@ -168,5 +169,3 @@ $.fn.gridEditor.utilities.visibility = function(ge) {
|
|
|
168
169
|
onDeinit: unmark,
|
|
169
170
|
};
|
|
170
171
|
};
|
|
171
|
-
|
|
172
|
-
})(jQuery);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a plugin's or a locale's classic script imports in place of the
|
|
3
|
+
* editor: the GridEditor the page already loaded.
|
|
4
|
+
*
|
|
5
|
+
* The build points `import { GridEditor } from '../grideditor.js'` here for
|
|
6
|
+
* the classic scripts, so each registers on the editor the page has rather
|
|
7
|
+
* than bringing its own. Loaded before the editor there is nothing to
|
|
8
|
+
* register on, and saying so is better than a TypeError three calls later.
|
|
9
|
+
*/
|
|
10
|
+
var GridEditor = window.GridEditor;
|
|
11
|
+
|
|
12
|
+
if (!GridEditor || typeof GridEditor.get !== 'function') {
|
|
13
|
+
throw new Error('grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, ' +
|
|
14
|
+
'its locales and grideditor.jquery.js');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { GridEditor };
|
|
18
|
+
export default GridEditor;
|