@themarioga/grid-editor 6.0.0 → 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 +47 -0
- package/README.md +137 -85
- 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 +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 -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 +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 +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
|
@@ -1,511 +1,523 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* of its own, as example/custom_editor.html shows.
|
|
19
|
-
*/
|
|
20
|
-
(function($) {
|
|
21
|
-
|
|
22
|
-
if ($.fn.gridEditor.features.text) { return; }
|
|
23
|
-
|
|
24
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
25
|
-
'text.add': 'Text',
|
|
26
|
-
'text.add_type': 'Text ({editor})',
|
|
27
|
-
'panel.editor': 'Editor',
|
|
28
|
-
'panel.kind_text': 'Text',
|
|
1
|
+
(() => {
|
|
2
|
+
// src/js/register.js
|
|
3
|
+
var GridEditor = window.GridEditor;
|
|
4
|
+
if (!GridEditor || typeof GridEditor.get !== "function") {
|
|
5
|
+
throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/js/dom.js
|
|
9
|
+
function all(root, selector) {
|
|
10
|
+
return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];
|
|
11
|
+
}
|
|
12
|
+
function children(node, selector) {
|
|
13
|
+
if (!node) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return Array.prototype.filter.call(node.children, function(each) {
|
|
17
|
+
return !selector || each.matches(selector);
|
|
29
18
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
function attributesOf(element) {
|
|
39
|
-
var found = {};
|
|
40
|
-
$.each($.makeArray(element.attributes), function(i, attribute) {
|
|
41
|
-
found[attribute.name] = attribute.value;
|
|
42
|
-
});
|
|
43
|
-
return found;
|
|
19
|
+
}
|
|
20
|
+
function child(node, selector) {
|
|
21
|
+
return children(node, selector)[0] || null;
|
|
22
|
+
}
|
|
23
|
+
function closest(node, selector, stopAt) {
|
|
24
|
+
var found = node && node.nodeType === 1 ? node.closest(selector) : null;
|
|
25
|
+
if (found && stopAt && found !== stopAt && !stopAt.contains(found)) {
|
|
26
|
+
return null;
|
|
44
27
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
return found;
|
|
29
|
+
}
|
|
30
|
+
function element(tag, attributes, text) {
|
|
31
|
+
var node = document.createElement(tag);
|
|
32
|
+
Object.keys(attributes || {}).forEach(function(name) {
|
|
33
|
+
var value = attributes[name];
|
|
34
|
+
if (value !== null && value !== void 0 && value !== false) {
|
|
35
|
+
node.setAttribute(name, value);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (text !== void 0 && text !== null) {
|
|
39
|
+
node.textContent = text;
|
|
50
40
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
41
|
+
return node;
|
|
42
|
+
}
|
|
43
|
+
function setHtml(node, html) {
|
|
44
|
+
node.innerHTML = html === void 0 || html === null ? "" : String(html);
|
|
45
|
+
return node;
|
|
46
|
+
}
|
|
47
|
+
function addClass(node, names) {
|
|
48
|
+
split(names).forEach(function(name) {
|
|
49
|
+
node.classList.add(name);
|
|
50
|
+
});
|
|
51
|
+
return node;
|
|
52
|
+
}
|
|
53
|
+
function removeClass(node, names) {
|
|
54
|
+
split(names).forEach(function(name) {
|
|
55
|
+
node.classList.remove(name);
|
|
56
|
+
});
|
|
57
|
+
return node;
|
|
58
|
+
}
|
|
59
|
+
function hasClass(node, name) {
|
|
60
|
+
return !!node && node.nodeType === 1 && node.classList.contains(name);
|
|
61
|
+
}
|
|
62
|
+
function split(names) {
|
|
63
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
64
|
+
}
|
|
65
|
+
function hide(node) {
|
|
66
|
+
node.style.display = "none";
|
|
67
|
+
return node;
|
|
68
|
+
}
|
|
69
|
+
function visible(node) {
|
|
70
|
+
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
71
|
+
}
|
|
72
|
+
function delegate(root, types, selector, handler, options) {
|
|
73
|
+
var listener = function(event) {
|
|
74
|
+
var match = closest(event.target, selector, root);
|
|
75
|
+
if (match && root.contains(match)) {
|
|
76
|
+
return handler.call(match, event);
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
};
|
|
80
|
+
split(types).forEach(function(type) {
|
|
81
|
+
root.addEventListener(type, listener, options);
|
|
82
|
+
});
|
|
83
|
+
return listener;
|
|
84
|
+
}
|
|
85
|
+
var DEFAULT_DURATION = 400;
|
|
86
|
+
function animateAway(node, frames, duration, done) {
|
|
87
|
+
duration = duration === void 0 ? DEFAULT_DURATION : duration;
|
|
88
|
+
var finish = function() {
|
|
89
|
+
hide(node);
|
|
90
|
+
if (done) {
|
|
91
|
+
done();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (!visible(node) || !node.animate || duration <= 0) {
|
|
95
|
+
window.setTimeout(finish, 0);
|
|
96
|
+
return;
|
|
81
97
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
var animation = node.animate(frames(getComputedStyle(node)), {
|
|
99
|
+
duration,
|
|
100
|
+
easing: "ease-in-out"
|
|
101
|
+
});
|
|
102
|
+
var called = false;
|
|
103
|
+
var once = function() {
|
|
104
|
+
if (called) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
called = true;
|
|
108
|
+
finish();
|
|
109
|
+
};
|
|
110
|
+
animation.onfinish = once;
|
|
111
|
+
animation.oncancel = once;
|
|
112
|
+
}
|
|
113
|
+
function slideUp(node, duration, done) {
|
|
114
|
+
if (typeof duration === "function") {
|
|
115
|
+
done = duration;
|
|
116
|
+
duration = void 0;
|
|
117
|
+
}
|
|
118
|
+
node.style.overflow = "hidden";
|
|
119
|
+
animateAway(node, function(style) {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
height: style.height,
|
|
123
|
+
paddingTop: style.paddingTop,
|
|
124
|
+
paddingBottom: style.paddingBottom,
|
|
125
|
+
marginTop: style.marginTop,
|
|
126
|
+
marginBottom: style.marginBottom
|
|
127
|
+
},
|
|
128
|
+
{ height: "0px", paddingTop: "0px", paddingBottom: "0px", marginTop: "0px", marginBottom: "0px" }
|
|
129
|
+
];
|
|
130
|
+
}, duration, function() {
|
|
131
|
+
node.style.removeProperty("overflow");
|
|
132
|
+
if (done) {
|
|
133
|
+
done();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/js/text/grideditor.text.js
|
|
139
|
+
if (!GridEditor.features.text) {
|
|
140
|
+
let attributesOf = function(element2) {
|
|
141
|
+
var found = {};
|
|
142
|
+
Array.prototype.slice.call(element2.attributes).forEach(function(attribute) {
|
|
143
|
+
found[attribute.name] = attribute.value;
|
|
144
|
+
});
|
|
145
|
+
return found;
|
|
146
|
+
}, classesIn = function(value) {
|
|
147
|
+
return (value || "").split(/\s+/).filter(function(name) {
|
|
148
|
+
return name !== "" && !EDITOR_CLASS.test(name);
|
|
149
|
+
});
|
|
150
|
+
}, restoreAttributes = function(block, before, ready, open) {
|
|
151
|
+
var result = Object.assign({}, before);
|
|
152
|
+
Object.keys(Object.assign({}, ready, open)).forEach(function(name) {
|
|
153
|
+
if (name === "class" || EDITOR_ATTRIBUTE.test(name) || ready[name] === open[name]) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (open[name] === void 0) {
|
|
157
|
+
delete result[name];
|
|
158
|
+
} else {
|
|
159
|
+
result[name] = open[name];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
var readyClasses = classesIn(ready["class"]);
|
|
163
|
+
var openClasses = classesIn(open["class"]);
|
|
164
|
+
var classes = classesIn(before["class"]).filter(function(name) {
|
|
165
|
+
return openClasses.indexOf(name) !== -1 || readyClasses.indexOf(name) === -1;
|
|
166
|
+
});
|
|
167
|
+
openClasses.forEach(function(name) {
|
|
168
|
+
if (readyClasses.indexOf(name) === -1 && classes.indexOf(name) === -1) {
|
|
169
|
+
classes.push(name);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
if (classes.length) {
|
|
173
|
+
result["class"] = classes.join(" ");
|
|
174
|
+
} else {
|
|
175
|
+
delete result["class"];
|
|
176
|
+
}
|
|
177
|
+
Object.keys(attributesOf(block)).forEach(function(name) {
|
|
178
|
+
block.removeAttribute(name);
|
|
179
|
+
});
|
|
180
|
+
Object.keys(result).forEach(function(name) {
|
|
181
|
+
block.setAttribute(name, result[name]);
|
|
182
|
+
});
|
|
183
|
+
}, textFeature = function(ge) {
|
|
184
|
+
var settings = ge.settings;
|
|
185
|
+
var TEXTS = {};
|
|
186
|
+
var warned = {};
|
|
187
|
+
Object.keys(GridEditor.texts).forEach(function(type) {
|
|
188
|
+
TEXTS[type] = GridEditor.texts[type](ge);
|
|
189
|
+
});
|
|
190
|
+
if (!Array.isArray(settings.content_types)) {
|
|
191
|
+
settings.content_types = Object.keys(TEXTS);
|
|
192
|
+
}
|
|
193
|
+
if (!Array.isArray(settings.text_tools)) {
|
|
194
|
+
settings.text_tools = [];
|
|
195
|
+
}
|
|
196
|
+
if (!Array.isArray(settings.text_classes)) {
|
|
197
|
+
settings.text_classes = [];
|
|
198
|
+
}
|
|
199
|
+
function offeredTexts() {
|
|
200
|
+
return settings.content_types.filter(function(type) {
|
|
201
|
+
return !!TEXTS[type];
|
|
91
202
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
203
|
+
}
|
|
204
|
+
function textLabel(type) {
|
|
205
|
+
var text = TEXTS[type];
|
|
206
|
+
return text && text.labelKey ? ge.t(text.labelKey) : type;
|
|
207
|
+
}
|
|
208
|
+
function makeText(type, content) {
|
|
209
|
+
var text = TEXTS[type];
|
|
210
|
+
var block = element("div", {
|
|
211
|
+
"class": "ge-content ge-content-type-" + type,
|
|
212
|
+
"data-ge-content-type": type
|
|
213
|
+
});
|
|
214
|
+
if (content && content.nodeType) {
|
|
215
|
+
block.appendChild(content);
|
|
216
|
+
} else {
|
|
217
|
+
setHtml(block, content !== void 0 ? content : text && text.initialContent || "");
|
|
102
218
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
219
|
+
return block;
|
|
220
|
+
}
|
|
221
|
+
function apiCreateText(type, options) {
|
|
222
|
+
if (type && typeof type === "object") {
|
|
223
|
+
options = type;
|
|
224
|
+
type = void 0;
|
|
108
225
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
.html(content !== undefined ? content : (text && text.initialContent) || '');
|
|
226
|
+
options = options || {};
|
|
227
|
+
type = type || offeredTexts()[0];
|
|
228
|
+
if (!type || !TEXTS[type]) {
|
|
229
|
+
if (!warned["createText:" + type]) {
|
|
230
|
+
warned["createText:" + type] = true;
|
|
231
|
+
ge.warn('createText: no text editor "' + type + '" is loaded; load its plugin and name it in content_types');
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
118
234
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
options = type;
|
|
128
|
-
type = undefined;
|
|
129
|
-
}
|
|
130
|
-
options = options || {};
|
|
131
|
-
type = type || offeredTexts()[0];
|
|
132
|
-
|
|
133
|
-
if (!type || !TEXTS[type]) {
|
|
134
|
-
if (!warned['createText:' + type]) {
|
|
135
|
-
warned['createText:' + type] = true;
|
|
136
|
-
ge.warn('createText: no text editor "' + type + '" is loaded; ' +
|
|
137
|
-
'load its plugin and name it in content_types');
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return ge.place(makeText(type, options.content), 'text', options);
|
|
235
|
+
return ge.place(makeText(type, options.content), "text", options);
|
|
236
|
+
}
|
|
237
|
+
function isOurs(block) {
|
|
238
|
+
return !!TEXTS[block.getAttribute("data-ge-content-type")];
|
|
239
|
+
}
|
|
240
|
+
function startText(block) {
|
|
241
|
+
if (hasClass(block, "ge-rte-active")) {
|
|
242
|
+
return;
|
|
143
243
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
function isOurs(block) {
|
|
147
|
-
return !!TEXTS[block.attr('data-ge-content-type')];
|
|
244
|
+
if (!visible(block)) {
|
|
245
|
+
return;
|
|
148
246
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (block.hasClass('ge-rte-active')) { return; }
|
|
153
|
-
|
|
154
|
-
// A content area nobody can see - a tab that is not the open one,
|
|
155
|
-
// a closed accordion item - has no geometry for an editor to lay
|
|
156
|
-
// its toolbar out against, and nothing anyone can type into
|
|
157
|
-
if (!block.is(':visible')) { return; }
|
|
158
|
-
|
|
159
|
-
// The attribute, not jQuery's cached copy of it: it is markup, and
|
|
160
|
-
// the drawer reads it the same way
|
|
161
|
-
var text = TEXTS[block.attr('data-ge-content-type')];
|
|
162
|
-
if (!text) { return; }
|
|
163
|
-
|
|
164
|
-
// Not marked active, so the next click tries again: the library
|
|
165
|
-
// may be loaded by then
|
|
166
|
-
if (text.available && !text.available()) {
|
|
167
|
-
if (text.missingKey) { console.error(ge.t(text.missingKey)); }
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
block.data('ge-text-before', attributesOf(block[0])).removeData('ge-text-ready');
|
|
172
|
-
block.addClass('ge-rte-active');
|
|
173
|
-
text.start(block);
|
|
247
|
+
var text = TEXTS[block.getAttribute("data-ge-content-type")];
|
|
248
|
+
if (!text) {
|
|
249
|
+
return;
|
|
174
250
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
251
|
+
if (text.available && !text.available()) {
|
|
252
|
+
if (text.missingKey) {
|
|
253
|
+
console.error(ge.t(text.missingKey));
|
|
254
|
+
}
|
|
255
|
+
return;
|
|
178
256
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*/
|
|
194
|
-
function closeText(block) {
|
|
195
|
-
var text = TEXTS[block.attr('data-ge-content-type')];
|
|
196
|
-
var before = block.data('ge-text-before');
|
|
197
|
-
var open = before ? attributesOf(block[0]) : null;
|
|
198
|
-
|
|
199
|
-
// Every content area is told, as in 5.x: one whose editor never
|
|
200
|
-
// started is the plugin's to ignore
|
|
201
|
-
if (text) { text.stop(block); }
|
|
202
|
-
|
|
203
|
-
// After stop, not before: an editor that restores the class
|
|
204
|
-
// attribute it snapshotted would put ge-rte-active back
|
|
205
|
-
block.removeClass('ge-rte-active');
|
|
206
|
-
|
|
207
|
-
if (before) {
|
|
208
|
-
restoreAttributes(block, before, block.data('ge-text-ready') || before, open);
|
|
209
|
-
block.removeData('ge-text-before').removeData('ge-text-ready');
|
|
210
|
-
}
|
|
257
|
+
readBefore.set(block, attributesOf(block));
|
|
258
|
+
readReady.delete(block);
|
|
259
|
+
addClass(block, "ge-rte-active");
|
|
260
|
+
text.start([block]);
|
|
261
|
+
}
|
|
262
|
+
function onClick() {
|
|
263
|
+
startText(this);
|
|
264
|
+
}
|
|
265
|
+
function closeText(block) {
|
|
266
|
+
var text = TEXTS[block.getAttribute("data-ge-content-type")];
|
|
267
|
+
var before = readBefore.get(block);
|
|
268
|
+
var open = before ? attributesOf(block) : null;
|
|
269
|
+
if (text) {
|
|
270
|
+
text.stop([block]);
|
|
211
271
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
ge.createMoveTool(drawer);
|
|
219
|
-
|
|
220
|
-
var details = ge.addSettingsTool(drawer, block, settings.text_classes);
|
|
221
|
-
|
|
222
|
-
// Which editor edits it, first in its settings: something to
|
|
223
|
-
// know about it, not something to do with it
|
|
224
|
-
$('<div class="ge-field ge-text-editor" />')
|
|
225
|
-
.append($('<span class="ge-field-label" />').text(ge.t('panel.editor')))
|
|
226
|
-
.append($('<span class="ge-field-value" />').text(textLabel(type)))
|
|
227
|
-
.prependTo(details.children('.ge-details-general'));
|
|
228
|
-
|
|
229
|
-
settings.text_tools.forEach(function(hostTool) {
|
|
230
|
-
ge.createTool(drawer, hostTool.title || '', hostTool.className || '',
|
|
231
|
-
hostTool.iconClass || 'bi bi-wrench', hostTool.on);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
ge.createTool(drawer, ge.t('tool.delete_text'), 'ge-delete-text', 'bi bi-trash', function() {
|
|
235
|
-
ge.deleteNode('text', block, ge.t('confirm.delete_text'), function(removed) {
|
|
236
|
-
// Its editor lets go first: removed while open, it would
|
|
237
|
-
// be left behind, attached to nothing
|
|
238
|
-
closeText(block);
|
|
239
|
-
textBlock.slideUp(function() {
|
|
240
|
-
textBlock.remove();
|
|
241
|
-
removed();
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
});
|
|
272
|
+
removeClass(block, "ge-rte-active");
|
|
273
|
+
if (before) {
|
|
274
|
+
restoreAttributes(block, before, readReady.get(block) || before, open);
|
|
275
|
+
readBefore.delete(block);
|
|
276
|
+
readReady.delete(block);
|
|
245
277
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
278
|
+
}
|
|
279
|
+
function createTextControls(textBlock) {
|
|
280
|
+
var block = child(textBlock, ".ge-content");
|
|
281
|
+
var type = block.getAttribute("data-ge-content-type");
|
|
282
|
+
var drawer = element("div", { "class": "ge-tools-drawer ge-text-drawer" });
|
|
283
|
+
textBlock.insertBefore(drawer, textBlock.firstChild);
|
|
284
|
+
ge.createMoveTool(drawer);
|
|
285
|
+
var details = ge.addSettingsTool(drawer, block, settings.text_classes);
|
|
286
|
+
var general = child(details, ".ge-details-general");
|
|
287
|
+
var editor = element("div", { "class": "ge-field ge-text-editor" });
|
|
288
|
+
editor.appendChild(element("span", { "class": "ge-field-label" }, ge.t("panel.editor")));
|
|
289
|
+
editor.appendChild(element("span", { "class": "ge-field-value" }, textLabel(type)));
|
|
290
|
+
general.insertBefore(editor, general.firstChild);
|
|
291
|
+
settings.text_tools.forEach(function(hostTool) {
|
|
292
|
+
ge.createTool(
|
|
293
|
+
drawer,
|
|
294
|
+
hostTool.title || "",
|
|
295
|
+
hostTool.className || "",
|
|
296
|
+
hostTool.iconClass || "bi bi-wrench",
|
|
297
|
+
hostTool.on
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
ge.createTool(drawer, ge.t("tool.delete_text"), "ge-delete-text", "bi bi-trash", function() {
|
|
301
|
+
ge.deleteNode("text", block, ge.t("confirm.delete_text"), function(removed) {
|
|
302
|
+
closeText(block);
|
|
303
|
+
slideUp(textBlock, function() {
|
|
304
|
+
textBlock.remove();
|
|
305
|
+
removed();
|
|
255
306
|
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
},
|
|
302
|
-
iconClass: TEXTS[type].iconClass,
|
|
303
|
-
className: 'ge-add-text-button',
|
|
304
|
-
kind: 'text',
|
|
305
|
-
inColumn: true,
|
|
306
|
-
create: function() { return makeText(type); },
|
|
307
|
-
};
|
|
308
|
-
}),
|
|
309
|
-
|
|
310
|
-
onInit: function() {
|
|
311
|
-
markTexts();
|
|
312
|
-
|
|
313
|
-
ge.canvas.off('click.ge-text').on('click.ge-text', '.ge-content', onClick);
|
|
314
|
-
},
|
|
315
|
-
|
|
316
|
-
// While the drawers and the text blocks are still there, as the
|
|
317
|
-
// editors left them
|
|
318
|
-
onBeforeDeinit: function() {
|
|
319
|
-
ge.canvas.find('.ge-content').each(function() {
|
|
320
|
-
if (isOurs($(this))) { closeText($(this)); }
|
|
321
|
-
});
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
onDeinit: function() {
|
|
325
|
-
ge.canvas.off('click.ge-text');
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
// The first time only: an undo says ready again, and by then the
|
|
329
|
-
// host may have changed the content area itself
|
|
330
|
-
onContentReady: function(area) {
|
|
331
|
-
if (area.data('ge-text-before') && !area.data('ge-text-ready')) {
|
|
332
|
-
area.data('ge-text-ready', attributesOf(area[0]));
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function markTexts() {
|
|
311
|
+
all(ge.canvas, ".ge-text-block").forEach(function(textBlock) {
|
|
312
|
+
if (child(textBlock, ".ge-tools-drawer")) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
var block = child(textBlock, ".ge-content");
|
|
316
|
+
if (!block || !isOurs(block)) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
createTextControls(textBlock);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
var texts = offeredTexts();
|
|
323
|
+
var clicks = null;
|
|
324
|
+
return {
|
|
325
|
+
methods: {
|
|
326
|
+
createText: apiCreateText
|
|
327
|
+
},
|
|
328
|
+
/**
|
|
329
|
+
* The types this plugin edits, for the core: every editor loaded
|
|
330
|
+
* is the owner of its texts, and the ones offered are what the
|
|
331
|
+
* host's plain content can be made.
|
|
332
|
+
*/
|
|
333
|
+
textTypes: function() {
|
|
334
|
+
var offered = offeredTexts();
|
|
335
|
+
var others = Object.keys(TEXTS).filter(function(type) {
|
|
336
|
+
return offered.indexOf(type) === -1;
|
|
337
|
+
});
|
|
338
|
+
return offered.concat(others).map(function(type) {
|
|
339
|
+
var text = TEXTS[type];
|
|
340
|
+
return {
|
|
341
|
+
type,
|
|
342
|
+
label: textLabel(type),
|
|
343
|
+
offered: offered.indexOf(type) !== -1,
|
|
344
|
+
available: text.available ? function() {
|
|
345
|
+
return text.available();
|
|
346
|
+
} : null,
|
|
347
|
+
missingKey: text.missingKey,
|
|
348
|
+
edit: function(block) {
|
|
349
|
+
var textBlock = block.parentElement;
|
|
350
|
+
if (hasClass(textBlock, "ge-text-block") && !child(textBlock, ".ge-tools-drawer")) {
|
|
351
|
+
createTextControls(textBlock);
|
|
333
352
|
}
|
|
353
|
+
startText(block);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
// A text block of each editor offered. Like a container, it goes
|
|
359
|
+
// into a row of its own when clicked, or where it is dropped
|
|
360
|
+
toolbar: texts.map(function(type) {
|
|
361
|
+
return {
|
|
362
|
+
label: function() {
|
|
363
|
+
return texts.length > 1 ? ge.t("text.add_type", { editor: textLabel(type) }) : ge.t("text.add");
|
|
334
364
|
},
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
365
|
+
iconClass: TEXTS[type].iconClass,
|
|
366
|
+
className: "ge-add-text-button",
|
|
367
|
+
kind: "text",
|
|
368
|
+
inColumn: true,
|
|
369
|
+
create: function() {
|
|
370
|
+
return makeText(type);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
}),
|
|
374
|
+
onInit: function() {
|
|
375
|
+
markTexts();
|
|
376
|
+
if (clicks) {
|
|
377
|
+
ge.canvas.removeEventListener("click", clicks);
|
|
378
|
+
}
|
|
379
|
+
clicks = delegate(ge.canvas, "click", ".ge-content", onClick);
|
|
380
|
+
},
|
|
381
|
+
// While the drawers and the text blocks are still there, as the
|
|
382
|
+
// editors left them
|
|
383
|
+
onBeforeDeinit: function() {
|
|
384
|
+
all(ge.canvas, ".ge-content").forEach(function(block) {
|
|
385
|
+
if (isOurs(block)) {
|
|
386
|
+
closeText(block);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
},
|
|
390
|
+
onDeinit: function() {
|
|
391
|
+
if (clicks) {
|
|
392
|
+
ge.canvas.removeEventListener("click", clicks);
|
|
393
|
+
}
|
|
394
|
+
clicks = null;
|
|
395
|
+
},
|
|
396
|
+
// The first time only: an undo says ready again, and by then the
|
|
397
|
+
// host may have changed the content area itself
|
|
398
|
+
onContentReady: function(area) {
|
|
399
|
+
if (readBefore.has(area) && !readReady.has(area)) {
|
|
400
|
+
readReady.set(area, attributesOf(area));
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
};
|
|
405
|
+
Object.assign(GridEditor.locales.en, {
|
|
406
|
+
"text.add": "Text",
|
|
407
|
+
"text.add_type": "Text ({editor})",
|
|
408
|
+
"panel.editor": "Editor",
|
|
409
|
+
"panel.kind_text": "Text"
|
|
410
|
+
});
|
|
411
|
+
readBefore = /* @__PURE__ */ new WeakMap();
|
|
412
|
+
readReady = /* @__PURE__ */ new WeakMap();
|
|
413
|
+
EDITOR_CLASS = /^(mce-|cke|note-)|^(active|ge-rte-active)$/;
|
|
414
|
+
EDITOR_ATTRIBUTE = /^(data-mce-|contenteditable$|spellcheck$)/;
|
|
339
415
|
textFeature.always = true;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
*
|
|
357
|
-
* Up to 5.x the main bundle carried a copy of this file; since 6.0 it is
|
|
358
|
-
* loaded on its own, like every plugin. The built file starts with what
|
|
359
|
-
* every text editor shares - text blocks, the Text button, createText,
|
|
360
|
-
* making the host's plain content a text - from
|
|
361
|
-
* src/js/text/grideditor.text.js, installed once however many editors a
|
|
362
|
-
* page loads.
|
|
363
|
-
*/
|
|
364
|
-
(function($) {
|
|
365
|
-
|
|
366
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
367
|
-
'text.tinymce': 'tinyMCE',
|
|
416
|
+
GridEditor.features.text = textFeature;
|
|
417
|
+
}
|
|
418
|
+
var readBefore;
|
|
419
|
+
var readReady;
|
|
420
|
+
var EDITOR_CLASS;
|
|
421
|
+
var EDITOR_ATTRIBUTE;
|
|
422
|
+
|
|
423
|
+
// src/js/plugins/grideditor.tinymce.js
|
|
424
|
+
Object.assign(GridEditor.locales.en, {
|
|
425
|
+
"text.tinymce": "tinyMCE",
|
|
426
|
+
"warning.oninit_removed": "tinyMCE's oninit option was removed in 7.0 and is ignored: use init_instance_callback."
|
|
427
|
+
});
|
|
428
|
+
function cleanUp(contentArea) {
|
|
429
|
+
removeClass(contentArea, "active ge-rte-active");
|
|
430
|
+
["id", "style", "spellcheck", "contenteditable", "data-mce-style"].forEach(function(name) {
|
|
431
|
+
contentArea.removeAttribute(name);
|
|
368
432
|
});
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
// The editor rewrote what is inside this content area
|
|
431
|
-
// while it took it over, so whatever the grid editor
|
|
432
|
-
// had in there is gone. Saying so lets it put its own
|
|
433
|
-
// furniture back.
|
|
434
|
-
ge.textReady(contentArea);
|
|
435
|
-
|
|
436
|
-
// Undo and redo rewrite it too, from snapshots that
|
|
437
|
-
// leave out whatever is marked data-mce-bogus - an
|
|
438
|
-
// element's drawer among them - so it goes back in
|
|
439
|
-
// after each of those as well
|
|
440
|
-
editor.on('Undo Redo', function() {
|
|
441
|
-
ge.textReady(contentArea);
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
// The inline toolbar is laid out against the element's
|
|
445
|
-
// geometry at the moment tinyMCE draws it, and an
|
|
446
|
-
// element that has just appeared - a tab pane, an
|
|
447
|
-
// accordion body, a column whose width is still
|
|
448
|
-
// settling - may not have its own width yet. Asking
|
|
449
|
-
// for the ui again once the browser has laid the frame
|
|
450
|
-
// out measures it as it now is, instead of leaving a
|
|
451
|
-
// toolbar wrapped into a narrow column.
|
|
452
|
-
window.requestAnimationFrame(function() {
|
|
453
|
-
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
454
|
-
|
|
455
|
-
editor.ui.show();
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
// And again whenever the user comes back to this
|
|
459
|
-
// editor: by then the element may have been resized,
|
|
460
|
-
// hidden and shown again - a tab switched away from
|
|
461
|
-
// and back, a column made narrower - and the toolbar
|
|
462
|
-
// is only ever as right as its last measurement.
|
|
463
|
-
editor.on('focus', function() {
|
|
464
|
-
window.requestAnimationFrame(function() {
|
|
465
|
-
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
466
|
-
|
|
467
|
-
editor.ui.show();
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
// Bring focus to text field
|
|
472
|
-
editor.focus();
|
|
473
|
-
|
|
474
|
-
// Call the original callbacks, if any were passed in the config
|
|
475
|
-
if (userConfig.init_instance_callback) {
|
|
476
|
-
userConfig.init_instance_callback.call(this, editor);
|
|
477
|
-
}
|
|
478
|
-
// 'oninit' is the pre-6 name, honoured so existing configs keep working
|
|
479
|
-
if (userConfig.oninit) {
|
|
480
|
-
userConfig.oninit.call(this, editor);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
// We always edit the element we were handed, so a selector in the
|
|
485
|
-
// user config would only fight with target
|
|
486
|
-
delete configuration.selector;
|
|
487
|
-
|
|
488
|
-
window.tinymce.init(configuration);
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
|
-
|
|
492
|
-
stop: function(contentAreas) {
|
|
493
|
-
contentAreas.filter('.active').each(function() {
|
|
494
|
-
var contentArea = $(this);
|
|
495
|
-
var editor = contentArea.data('ge-tinymce');
|
|
496
|
-
|
|
497
|
-
if (editor) {
|
|
498
|
-
contentArea.removeData('ge-tinymce');
|
|
499
|
-
editor.remove();
|
|
500
|
-
} else {
|
|
501
|
-
// tinymce.init() is asynchronous, so the editor may not exist
|
|
502
|
-
// yet. Leave a note for init_instance_callback to remove it.
|
|
503
|
-
contentArea.data('ge-tinymce-pending-remove', true);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
cleanUp(contentArea);
|
|
433
|
+
}
|
|
434
|
+
var INITIAL_CONTENT = "<p>Lorem ipsum dolores</p>";
|
|
435
|
+
var editors = /* @__PURE__ */ new WeakMap();
|
|
436
|
+
var pendingRemove = /* @__PURE__ */ new WeakSet();
|
|
437
|
+
var warnedOninit = false;
|
|
438
|
+
GridEditor.texts.tinymce = function(ge) {
|
|
439
|
+
return {
|
|
440
|
+
labelKey: "text.tinymce",
|
|
441
|
+
initialContent: INITIAL_CONTENT,
|
|
442
|
+
missingKey: "error.tinymce_missing",
|
|
443
|
+
available: function() {
|
|
444
|
+
return !!window.tinymce;
|
|
445
|
+
},
|
|
446
|
+
start: function(contentAreas) {
|
|
447
|
+
var settings = ge.settings;
|
|
448
|
+
var userConfig = settings.tinymce && settings.tinymce.config ? settings.tinymce.config : {};
|
|
449
|
+
if (userConfig.oninit && !warnedOninit) {
|
|
450
|
+
warnedOninit = true;
|
|
451
|
+
ge.warn(ge.t("warning.oninit_removed"));
|
|
452
|
+
}
|
|
453
|
+
contentAreas.forEach(function(contentArea) {
|
|
454
|
+
if (hasClass(contentArea, "active")) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (contentArea.innerHTML == INITIAL_CONTENT) {
|
|
458
|
+
contentArea.innerHTML = "";
|
|
459
|
+
}
|
|
460
|
+
addClass(contentArea, "active");
|
|
461
|
+
var configuration = Object.assign({
|
|
462
|
+
// tinyMCE's own "Upgrade" badge in the menubar. Off by
|
|
463
|
+
// default because an inline editor here is a column of
|
|
464
|
+
// someone's page, not tinyMCE's own interface; a host that
|
|
465
|
+
// wants it back passes promotion: true.
|
|
466
|
+
promotion: false
|
|
467
|
+
}, userConfig, {
|
|
468
|
+
target: contentArea,
|
|
469
|
+
inline: true,
|
|
470
|
+
init_instance_callback: function(editor) {
|
|
471
|
+
if (pendingRemove.has(contentArea)) {
|
|
472
|
+
pendingRemove.delete(contentArea);
|
|
473
|
+
editor.remove();
|
|
474
|
+
cleanUp(contentArea);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
editors.set(contentArea, editor);
|
|
478
|
+
ge.textReady(contentArea);
|
|
479
|
+
editor.on("Undo Redo", function() {
|
|
480
|
+
ge.textReady(contentArea);
|
|
481
|
+
});
|
|
482
|
+
window.requestAnimationFrame(function() {
|
|
483
|
+
if (editor.removed || !editor.ui || !editor.ui.show) {
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
editor.ui.show();
|
|
487
|
+
});
|
|
488
|
+
editor.on("focus", function() {
|
|
489
|
+
window.requestAnimationFrame(function() {
|
|
490
|
+
if (editor.removed || !editor.ui || !editor.ui.show) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
editor.ui.show();
|
|
507
494
|
});
|
|
508
|
-
|
|
509
|
-
|
|
495
|
+
});
|
|
496
|
+
editor.focus();
|
|
497
|
+
if (userConfig.init_instance_callback) {
|
|
498
|
+
userConfig.init_instance_callback.call(this, editor);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
delete configuration.selector;
|
|
503
|
+
delete configuration.oninit;
|
|
504
|
+
window.tinymce.init(configuration);
|
|
505
|
+
});
|
|
506
|
+
},
|
|
507
|
+
stop: function(contentAreas) {
|
|
508
|
+
contentAreas.filter(function(contentArea) {
|
|
509
|
+
return hasClass(contentArea, "active");
|
|
510
|
+
}).forEach(function(contentArea) {
|
|
511
|
+
var editor = editors.get(contentArea);
|
|
512
|
+
if (editor) {
|
|
513
|
+
editors.delete(contentArea);
|
|
514
|
+
editor.remove();
|
|
515
|
+
} else {
|
|
516
|
+
pendingRemove.add(contentArea);
|
|
517
|
+
}
|
|
518
|
+
cleanUp(contentArea);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
510
521
|
};
|
|
511
|
-
}
|
|
522
|
+
};
|
|
523
|
+
})();
|