@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
|
@@ -1,169 +1,276 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
(function(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function child(node, selector) {
|
|
21
|
+
return children(node, selector)[0] || null;
|
|
22
|
+
}
|
|
23
|
+
function is(node, selector) {
|
|
24
|
+
return !!node && node.nodeType === 1 && node.matches(selector);
|
|
25
|
+
}
|
|
26
|
+
function parse(html) {
|
|
27
|
+
var template = document.createElement("template");
|
|
28
|
+
template.innerHTML = html;
|
|
29
|
+
return Array.prototype.slice.call(template.content.childNodes);
|
|
30
|
+
}
|
|
31
|
+
function element(tag, attributes, text) {
|
|
32
|
+
var node = document.createElement(tag);
|
|
33
|
+
Object.keys(attributes || {}).forEach(function(name) {
|
|
34
|
+
var value = attributes[name];
|
|
35
|
+
if (value !== null && value !== void 0 && value !== false) {
|
|
36
|
+
node.setAttribute(name, value);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
if (text !== void 0 && text !== null) {
|
|
40
|
+
node.textContent = text;
|
|
41
|
+
}
|
|
42
|
+
return node;
|
|
43
|
+
}
|
|
44
|
+
function addClass(node, names) {
|
|
45
|
+
split(names).forEach(function(name) {
|
|
46
|
+
node.classList.add(name);
|
|
47
|
+
});
|
|
48
|
+
return node;
|
|
49
|
+
}
|
|
50
|
+
function removeClass(node, names) {
|
|
51
|
+
split(names).forEach(function(name) {
|
|
52
|
+
node.classList.remove(name);
|
|
53
|
+
});
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
function hasClass(node, name) {
|
|
57
|
+
return !!node && node.nodeType === 1 && node.classList.contains(name);
|
|
58
|
+
}
|
|
59
|
+
function split(names) {
|
|
60
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
61
|
+
}
|
|
62
|
+
function dropEmptyClass(node) {
|
|
63
|
+
if (!node.getAttribute("class")) {
|
|
64
|
+
node.removeAttribute("class");
|
|
65
|
+
}
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
function hide(node) {
|
|
69
|
+
node.style.display = "none";
|
|
70
|
+
return node;
|
|
71
|
+
}
|
|
72
|
+
function visible(node) {
|
|
73
|
+
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
74
|
+
}
|
|
75
|
+
var DEFAULT_DURATION = 400;
|
|
76
|
+
function animateAway(node, frames, duration, done) {
|
|
77
|
+
duration = duration === void 0 ? DEFAULT_DURATION : duration;
|
|
78
|
+
var finish = function() {
|
|
79
|
+
hide(node);
|
|
80
|
+
if (done) {
|
|
81
|
+
done();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (!visible(node) || !node.animate || duration <= 0) {
|
|
85
|
+
window.setTimeout(finish, 0);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
var animation = node.animate(frames(getComputedStyle(node)), {
|
|
89
|
+
duration,
|
|
90
|
+
easing: "ease-in-out"
|
|
91
|
+
});
|
|
92
|
+
var called = false;
|
|
93
|
+
var once = function() {
|
|
94
|
+
if (called) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
called = true;
|
|
98
|
+
finish();
|
|
99
|
+
};
|
|
100
|
+
animation.onfinish = once;
|
|
101
|
+
animation.oncancel = once;
|
|
102
|
+
}
|
|
103
|
+
function shrinkAway(node, duration, done, width) {
|
|
104
|
+
node.style.overflow = "hidden";
|
|
105
|
+
animateAway(node, function(style) {
|
|
106
|
+
var from = { opacity: style.opacity, height: style.height };
|
|
107
|
+
var to = { opacity: 0, height: "0px" };
|
|
108
|
+
if (width) {
|
|
109
|
+
from.width = style.width;
|
|
110
|
+
to.width = "0px";
|
|
111
|
+
}
|
|
112
|
+
return [from, to];
|
|
113
|
+
}, duration, function() {
|
|
114
|
+
node.style.removeProperty("overflow");
|
|
115
|
+
if (done) {
|
|
116
|
+
done();
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/js/plugins/grideditor.elements.js
|
|
122
|
+
Object.assign(GridEditor.locales.en, {
|
|
123
|
+
"tool.delete_element": "Remove element",
|
|
124
|
+
"tool.element_info": "Element: {name}",
|
|
125
|
+
"confirm.delete_element": "Delete element?"
|
|
126
|
+
});
|
|
127
|
+
var NOT_ELEMENTS = ".row, .ge-content, .ge-text-block, [data-ge-container], .ge-tools-drawer, .ge-resize-handle";
|
|
128
|
+
GridEditor.features.elements = function(ge) {
|
|
29
129
|
var warnedIntoText = false;
|
|
30
|
-
|
|
31
130
|
function elementsEnabled() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
131
|
+
if (ge.settings.elements.enabled !== "auto") {
|
|
132
|
+
return !!ge.settings.elements.enabled;
|
|
133
|
+
}
|
|
134
|
+
return ge.settings.elements.auto || !!ge.canvas.querySelector(ge.settings.elements.selector);
|
|
35
135
|
}
|
|
36
|
-
|
|
37
|
-
/** Whether a child of a column is an element. */
|
|
38
136
|
function isElement(node) {
|
|
39
|
-
|
|
40
|
-
? !node.is(NOT_ELEMENTS)
|
|
41
|
-
: node.is(ge.settings.elements.selector);
|
|
137
|
+
return ge.settings.elements.auto ? !node.matches(NOT_ELEMENTS) : node.matches(ge.settings.elements.selector);
|
|
42
138
|
}
|
|
43
|
-
|
|
44
139
|
function markElements() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
140
|
+
if (!elementsEnabled()) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
all(ge.canvas, ".column").forEach(function(column) {
|
|
144
|
+
children(column).forEach(function(element2) {
|
|
145
|
+
if (!hasClass(element2, "ge-element") && !isElement(element2)) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
addClass(element2, "ge-element");
|
|
149
|
+
if (!child(element2, ".ge-tools-drawer")) {
|
|
150
|
+
createElementControls(element2);
|
|
151
|
+
}
|
|
53
152
|
});
|
|
153
|
+
});
|
|
54
154
|
}
|
|
55
|
-
|
|
56
155
|
function unmarkElements() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// back from getHtml carrying an empty one
|
|
62
|
-
if (!element.attr('class')) { element.removeAttr('class'); }
|
|
63
|
-
});
|
|
156
|
+
all(ge.canvas, ".ge-element").forEach(function(element2) {
|
|
157
|
+
removeClass(element2, "ge-element");
|
|
158
|
+
dropEmptyClass(element2);
|
|
159
|
+
});
|
|
64
160
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
ge
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
161
|
+
function createElementControls(element2) {
|
|
162
|
+
var drawer = element("div", { "class": "ge-tools-drawer ge-element-drawer" });
|
|
163
|
+
element2.insertBefore(drawer, element2.firstChild);
|
|
164
|
+
ge.createMoveTool(drawer);
|
|
165
|
+
ge.createTool(
|
|
166
|
+
drawer,
|
|
167
|
+
ge.t("tool.element_info", { name: elementName(element2) }),
|
|
168
|
+
"ge-element-info",
|
|
169
|
+
"bi bi-info-circle"
|
|
170
|
+
);
|
|
171
|
+
ge.addSettingsTool(drawer, element2, ge.settings.element_classes);
|
|
172
|
+
ge.settings.element_tools.forEach(function(hostTool) {
|
|
173
|
+
ge.createTool(
|
|
174
|
+
drawer,
|
|
175
|
+
hostTool.title || "",
|
|
176
|
+
hostTool.className || "",
|
|
177
|
+
hostTool.iconClass || "bi bi-wrench",
|
|
178
|
+
hostTool.on
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
ge.createTool(drawer, ge.t("tool.delete_element"), "ge-delete-element", "bi bi-trash", function() {
|
|
182
|
+
ge.deleteNode("element", element2, ge.t("confirm.delete_element"), function(removed) {
|
|
183
|
+
shrinkAway(element2, 300, removed);
|
|
83
184
|
});
|
|
185
|
+
});
|
|
84
186
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return label || type || element[0].tagName.toLowerCase();
|
|
187
|
+
function elementName(element2) {
|
|
188
|
+
var type = element2.getAttribute("data-ge-element");
|
|
189
|
+
var label = element2.getAttribute("data-ge-label");
|
|
190
|
+
if (label && type) {
|
|
191
|
+
return label + " (" + type + ")";
|
|
192
|
+
}
|
|
193
|
+
return label || type || element2.tagName.toLowerCase();
|
|
93
194
|
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Placed into a content area, as 5.x did, an element would be text
|
|
97
|
-
* again, and the next init would cut it out. So it goes beside that
|
|
98
|
-
* content area instead - after it for appendTo, before it for
|
|
99
|
-
* prependTo - with a word to the host.
|
|
100
|
-
*/
|
|
101
195
|
function placementBesideText(options) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
[[
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
196
|
+
var placed = Object.assign({}, options);
|
|
197
|
+
[["appendTo", "insertAfter"], ["prependTo", "insertBefore"]].forEach(function(pair) {
|
|
198
|
+
var target = options[pair[0]] !== void 0 ? nodeFrom(options[pair[0]]) : null;
|
|
199
|
+
if (!target || !target.matches(".ge-content")) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (!warnedIntoText) {
|
|
203
|
+
warnedIntoText = true;
|
|
204
|
+
ge.warn("createElement: an element is a block of the column since 6.0, not part of a content area's text; it goes beside the content area. Place it in a column instead.");
|
|
205
|
+
}
|
|
206
|
+
delete placed[pair[0]];
|
|
207
|
+
placed[pair[1]] = hasClass(target.parentElement, "ge-text-block") ? target.parentElement : target;
|
|
208
|
+
});
|
|
209
|
+
return placed;
|
|
210
|
+
}
|
|
211
|
+
function nodeFrom(node) {
|
|
212
|
+
if (typeof node === "string") {
|
|
213
|
+
return document.querySelector(node);
|
|
214
|
+
}
|
|
215
|
+
return node && node.nodeType === 1 ? node : null;
|
|
216
|
+
}
|
|
217
|
+
function fill(element2, content) {
|
|
218
|
+
if (content === void 0 || content === null) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (typeof content === "string") {
|
|
222
|
+
parse(content).forEach(function(node) {
|
|
223
|
+
element2.appendChild(node);
|
|
116
224
|
});
|
|
117
|
-
|
|
118
|
-
|
|
225
|
+
} else if (content.nodeType) {
|
|
226
|
+
element2.appendChild(content);
|
|
227
|
+
} else if (typeof content.length === "number") {
|
|
228
|
+
Array.prototype.slice.call(content).forEach(function(node) {
|
|
229
|
+
element2.appendChild(node);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
119
232
|
}
|
|
120
|
-
|
|
121
233
|
function apiCreateElement(content, options) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return ge.place(element, 'element', placementBesideText(options));
|
|
234
|
+
options = options || {};
|
|
235
|
+
var element2 = element("div", {
|
|
236
|
+
"class": "ge-element",
|
|
237
|
+
"data-ge-element": options.type || "element"
|
|
238
|
+
});
|
|
239
|
+
fill(element2, content);
|
|
240
|
+
if (options.label !== void 0) {
|
|
241
|
+
element2.setAttribute("data-ge-label", options.label);
|
|
242
|
+
}
|
|
243
|
+
return ge.place(element2, "element", placementBesideText(options));
|
|
133
244
|
}
|
|
134
|
-
|
|
135
245
|
return {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
onInit: markElements,
|
|
165
|
-
onDeinit: unmarkElements,
|
|
246
|
+
methods: {
|
|
247
|
+
createElement: apiCreateElement
|
|
248
|
+
},
|
|
249
|
+
/** A node this plugin marked is an element, whatever else it is. */
|
|
250
|
+
kindOf: function(node) {
|
|
251
|
+
return hasClass(node, "ge-element") ? "element" : null;
|
|
252
|
+
},
|
|
253
|
+
/**
|
|
254
|
+
* An element cuts the text it sits in: 5.x's markup, or markup a host
|
|
255
|
+
* wrote the same way, has it inside a content area, and it comes out.
|
|
256
|
+
*/
|
|
257
|
+
cuts: function() {
|
|
258
|
+
if (!elementsEnabled()) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
return ge.settings.elements.auto ? "*" : ge.settings.elements.selector;
|
|
262
|
+
},
|
|
263
|
+
// A block the columns move, beside the texts, the rows and the
|
|
264
|
+
// containers - and only the columns
|
|
265
|
+
blocks: ".ge-element",
|
|
266
|
+
accepts: function(region, node) {
|
|
267
|
+
if (hasClass(node, "ge-element")) {
|
|
268
|
+
return is(region, ".column");
|
|
269
|
+
}
|
|
270
|
+
return true;
|
|
271
|
+
},
|
|
272
|
+
onInit: markElements,
|
|
273
|
+
onDeinit: unmarkElements
|
|
166
274
|
};
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
})(jQuery);
|
|
275
|
+
};
|
|
276
|
+
})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.elements.min.js.map
|
|
1
|
+
(()=>{var s=window.GridEditor;if(!s||typeof s.get!="function")throw new Error("grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, its locales and grideditor.jquery.js");function p(e,r){return e?Array.prototype.slice.call(e.querySelectorAll(r)):[]}function g(e,r){return e?Array.prototype.filter.call(e.children,function(o){return!r||o.matches(r)}):[]}function v(e,r){return g(e,r)[0]||null}function x(e,r){return!!e&&e.nodeType===1&&e.matches(r)}function y(e){var r=document.createElement("template");return r.innerHTML=e,Array.prototype.slice.call(r.content.childNodes)}function h(e,r,o){var u=document.createElement(e);return Object.keys(r||{}).forEach(function(a){var l=r[a];l!=null&&l!==!1&&u.setAttribute(a,l)}),o!=null&&(u.textContent=o),u}function E(e,r){return w(r).forEach(function(o){e.classList.add(o)}),e}function b(e,r){return w(r).forEach(function(o){e.classList.remove(o)}),e}function d(e,r){return!!e&&e.nodeType===1&&e.classList.contains(r)}function w(e){return String(e||"").split(/\s+/).filter(Boolean)}function C(e){return e.getAttribute("class")||e.removeAttribute("class"),e}function L(e){return e.style.display="none",e}function N(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}var O=400;function _(e,r,o,u){o=o===void 0?O:o;var a=function(){L(e),u&&u()};if(!N(e)||!e.animate||o<=0){window.setTimeout(a,0);return}var l=e.animate(r(getComputedStyle(e)),{duration:o,easing:"ease-in-out"}),f=!1,m=function(){f||(f=!0,a())};l.onfinish=m,l.oncancel=m}function T(e,r,o,u){e.style.overflow="hidden",_(e,function(a){var l={opacity:a.opacity,height:a.height},f={opacity:0,height:"0px"};return u&&(l.width=a.width,f.width="0px"),[l,f]},r,function(){e.style.removeProperty("overflow"),o&&o()})}Object.assign(s.locales.en,{"tool.delete_element":"Remove element","tool.element_info":"Element: {name}","confirm.delete_element":"Delete element?"});var H=".row, .ge-content, .ge-text-block, [data-ge-container], .ge-tools-drawer, .ge-resize-handle";s.features.elements=function(e){var r=!1;function o(){return e.settings.elements.enabled!=="auto"?!!e.settings.elements.enabled:e.settings.elements.auto||!!e.canvas.querySelector(e.settings.elements.selector)}function u(t){return e.settings.elements.auto?!t.matches(H):t.matches(e.settings.elements.selector)}function a(){o()&&p(e.canvas,".column").forEach(function(t){g(t).forEach(function(n){!d(n,"ge-element")&&!u(n)||(E(n,"ge-element"),v(n,".ge-tools-drawer")||f(n))})})}function l(){p(e.canvas,".ge-element").forEach(function(t){b(t,"ge-element"),C(t)})}function f(t){var n=h("div",{class:"ge-tools-drawer ge-element-drawer"});t.insertBefore(n,t.firstChild),e.createMoveTool(n),e.createTool(n,e.t("tool.element_info",{name:m(t)}),"ge-element-info","bi bi-info-circle"),e.addSettingsTool(n,t,e.settings.element_classes),e.settings.element_tools.forEach(function(i){e.createTool(n,i.title||"",i.className||"",i.iconClass||"bi bi-wrench",i.on)}),e.createTool(n,e.t("tool.delete_element"),"ge-delete-element","bi bi-trash",function(){e.deleteNode("element",t,e.t("confirm.delete_element"),function(i){T(t,300,i)})})}function m(t){var n=t.getAttribute("data-ge-element"),i=t.getAttribute("data-ge-label");return i&&n?i+" ("+n+")":i||n||t.tagName.toLowerCase()}function A(t){var n=Object.assign({},t);return[["appendTo","insertAfter"],["prependTo","insertBefore"]].forEach(function(i){var c=t[i[0]]!==void 0?S(t[i[0]]):null;!c||!c.matches(".ge-content")||(r||(r=!0,e.warn("createElement: an element is a block of the column since 6.0, not part of a content area's text; it goes beside the content area. Place it in a column instead.")),delete n[i[0]],n[i[1]]=d(c.parentElement,"ge-text-block")?c.parentElement:c)}),n}function S(t){return typeof t=="string"?document.querySelector(t):t&&t.nodeType===1?t:null}function B(t,n){n!=null&&(typeof n=="string"?y(n).forEach(function(i){t.appendChild(i)}):n.nodeType?t.appendChild(n):typeof n.length=="number"&&Array.prototype.slice.call(n).forEach(function(i){t.appendChild(i)}))}function k(t,n){n=n||{};var i=h("div",{class:"ge-element","data-ge-element":n.type||"element"});return B(i,t),n.label!==void 0&&i.setAttribute("data-ge-label",n.label),e.place(i,"element",A(n))}return{methods:{createElement:k},kindOf:function(t){return d(t,"ge-element")?"element":null},cuts:function(){return o()?e.settings.elements.auto?"*":e.settings.elements.selector:null},blocks:".ge-element",accepts:function(t,n){return d(n,"ge-element")?x(t,".column"):!0},onInit:a,onDeinit:l}};})();
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/js/register.js", "../../src/js/dom.js", "../../src/js/plugins/grideditor.elements.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * What a plugin's or a locale's classic script imports in place of the\n * editor: the GridEditor the page already loaded.\n *\n * The build points `import { GridEditor } from '../grideditor.js'` here for\n * the classic scripts, so each registers on the editor the page has rather\n * than bringing its own. Loaded before the editor there is nothing to\n * register on, and saying so is better than a TypeError three calls later.\n */\nvar GridEditor = window.GridEditor;\n\nif (!GridEditor || typeof GridEditor.get !== 'function') {\n throw new Error('grid-editor: load grideditor.js (or grideditor.bundle.min.js) before its plugins, ' +\n 'its locales and grideditor.jquery.js');\n}\n\nexport { GridEditor };\nexport default GridEditor;\n", "/**\n * The DOM, the way grid-editor uses it.\n *\n * Small helpers over the browser's own API, for the core and the shipped\n * plugins. Not a public API: a plugin of a host's own is free to write its\n * DOM code however it likes, and this file makes no promise to it.\n *\n * Stateless on purpose. The build puts a copy of this file in each plugin's\n * classic script, so anything kept here would be kept once per copy; a\n * module that needs to remember something about a node keeps its own\n * WeakMap.\n */\n\n/** Every element under `root` matching `selector`, as an array. */\nexport function all(root, selector) {\n return root ? Array.prototype.slice.call(root.querySelectorAll(selector)) : [];\n}\n\n/** The first element under `root` matching `selector`, or null. */\nexport function one(root, selector) {\n return root ? root.querySelector(selector) : null;\n}\n\n/** `root` itself when it matches, then every element under it that does. */\nexport function selfAndAll(root, selector) {\n if (!root) { return []; }\n\n var found = all(root, selector);\n if (root.nodeType === 1 && root.matches(selector)) { found.unshift(root); }\n return found;\n}\n\n/** The element children of `node`, those matching `selector` if one is given. */\nexport function children(node, selector) {\n if (!node) { return []; }\n\n return Array.prototype.filter.call(node.children, function(each) {\n return !selector || each.matches(selector);\n });\n}\n\n/** The first element child matching `selector`, or null. */\nexport function child(node, selector) {\n return children(node, selector)[0] || null;\n}\n\n/** The nearest ancestor-or-self matching `selector` below `stopAt`, or null. */\nexport function closest(node, selector, stopAt) {\n var found = node && node.nodeType === 1 ? node.closest(selector) : null;\n\n if (found && stopAt && found !== stopAt && !stopAt.contains(found)) { return null; }\n return found;\n}\n\n/** Whether `node` is an element matching `selector`. */\nexport function is(node, selector) {\n return !!node && node.nodeType === 1 && node.matches(selector);\n}\n\n/** Whether `node` is in the document. */\nexport function attached(node) {\n return !!node && document.documentElement.contains(node);\n}\n\n/** The element siblings after `node` that match `selector`. */\nexport function nextAll(node, selector) {\n var found = [];\n\n for (var next = node.nextElementSibling; next; next = next.nextElementSibling) {\n if (!selector || next.matches(selector)) { found.push(next); }\n }\n return found;\n}\n\n/** The ancestors of `node` up to, and not including, `stop`, nearest first. */\nexport function parentsUntil(node, stop) {\n var found = [];\n\n for (var parent = node.parentElement; parent && parent !== stop; parent = parent.parentElement) {\n found.push(parent);\n }\n return found;\n}\n\n/**\n * The nodes the html parses into, detached. Parsed the way innerHTML parses,\n * so a <script> in it never runs, here or once it is in the page.\n */\nexport function parse(html) {\n var template = document.createElement('template');\n template.innerHTML = html;\n return Array.prototype.slice.call(template.content.childNodes);\n}\n\n/** The one element the html is, detached. */\nexport function create(html) {\n var nodes = parse(html.trim());\n\n for (var i = 0; i < nodes.length; i++) {\n if (nodes[i].nodeType === 1) { return nodes[i]; }\n }\n return null;\n}\n\n/** An element of `tag`, with `attributes` and `text`. */\nexport function element(tag, attributes, text) {\n var node = document.createElement(tag);\n\n Object.keys(attributes || {}).forEach(function(name) {\n var value = attributes[name];\n if (value !== null && value !== undefined && value !== false) { node.setAttribute(name, value); }\n });\n if (text !== undefined && text !== null) { node.textContent = text; }\n\n return node;\n}\n\n/** Replace what `node` holds with `html`. A <script> in it does not run. */\nexport function setHtml(node, html) {\n node.innerHTML = html === undefined || html === null ? '' : String(html);\n return node;\n}\n\n/** Add one or several space separated classes. */\nexport function addClass(node, names) {\n split(names).forEach(function(name) { node.classList.add(name); });\n return node;\n}\n\nexport function removeClass(node, names) {\n split(names).forEach(function(name) { node.classList.remove(name); });\n return node;\n}\n\n/** Each class on, or off, or flipped when `on` is not given. */\nexport function toggleClass(node, names, state) {\n split(names).forEach(function(name) {\n if (state === undefined) {\n node.classList.toggle(name);\n } else {\n node.classList.toggle(name, !!state);\n }\n });\n return node;\n}\n\nexport function hasClass(node, name) {\n return !!node && node.nodeType === 1 && node.classList.contains(name);\n}\n\nfunction split(names) {\n return String(names || '').split(/\\s+/).filter(Boolean);\n}\n\n/** Take the class attribute off when there is nothing left in it. */\nexport function dropEmptyClass(node) {\n if (!node.getAttribute('class')) { node.removeAttribute('class'); }\n return node;\n}\n\n/** Take the style attribute off when there is nothing left in it. */\nexport function dropEmptyStyle(node) {\n if (!node.getAttribute('style')) { node.removeAttribute('style'); }\n return node;\n}\n\n/** Set attributes; a null or undefined value takes the attribute off. */\nexport function attr(node, attributes) {\n Object.keys(attributes).forEach(function(name) {\n var value = attributes[name];\n\n if (value === null || value === undefined) {\n node.removeAttribute(name);\n } else {\n node.setAttribute(name, value);\n }\n });\n return node;\n}\n\n/**\n * Inline styles, by css property name. A number is pixels for the properties\n * that take a length, as jQuery had it; an empty string takes one off.\n */\nexport function css(node, styles) {\n Object.keys(styles).forEach(function(property) {\n var value = styles[property];\n\n if (typeof value === 'number' && !UNITLESS[property]) { value = value + 'px'; }\n node.style.setProperty(property, value === null || value === undefined ? '' : String(value));\n });\n return node;\n}\n\nvar UNITLESS = { opacity: true, 'z-index': true, 'flex-grow': true, 'flex-shrink': true, order: true };\n\n/** What an element of this tag shows as when nothing hides it. */\nvar defaultDisplays = {};\n\nfunction defaultDisplay(node) {\n var tag = node.nodeName;\n\n if (!defaultDisplays[tag]) {\n var probe = document.body.appendChild(document.createElement(tag));\n defaultDisplays[tag] = getComputedStyle(probe).display;\n probe.remove();\n if (defaultDisplays[tag] === 'none') { defaultDisplays[tag] = 'block'; }\n }\n return defaultDisplays[tag];\n}\n\n/** Show a node: its inline display:none off, and a display of its own if a stylesheet hides it. */\nexport function show(node) {\n node.style.removeProperty('display');\n if (getComputedStyle(node).display === 'none') { node.style.display = defaultDisplay(node); }\n return node;\n}\n\nexport function hide(node) {\n node.style.display = 'none';\n return node;\n}\n\n/** Show or hide; flip when `on` is not given. */\nexport function toggle(node, state) {\n if (state === undefined) { state = !visible(node); }\n return state ? show(node) : hide(node);\n}\n\n/** Whether a node takes up room: what jQuery's :visible meant. */\nexport function visible(node) {\n return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);\n}\n\n/** The border box's width, fractions included. */\nexport function outerWidth(node) {\n return node.getBoundingClientRect().width;\n}\n\nexport function outerHeight(node) {\n return node.getBoundingClientRect().height;\n}\n\n/** The content box's height, which is what jQuery's height() gave. */\nexport function contentHeight(node) {\n var style = getComputedStyle(node);\n return node.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);\n}\n\n/** Where a node is on the page, not in the window. */\nexport function offset(node) {\n var box = node.getBoundingClientRect();\n return { top: box.top + window.pageYOffset, left: box.left + window.pageXOffset };\n}\n\n/** Its index among its parent's element children, those matching `selector` if given. */\nexport function indexIn(node, selector) {\n return children(node.parentElement, selector).indexOf(node);\n}\n\n/** Put `node` right after `reference`. */\nexport function insertAfter(node, reference) {\n reference.parentNode.insertBefore(node, reference.nextSibling);\n return node;\n}\n\n/** Replace `node` with what it holds. */\nexport function unwrap(node) {\n var parent = node.parentNode;\n\n while (node.firstChild) { parent.insertBefore(node.firstChild, node); }\n node.remove();\n}\n\n/** Put `node` inside `wrapper`, where `node` was. */\nexport function wrap(node, wrapper) {\n node.parentNode.insertBefore(wrapper, node);\n wrapper.appendChild(node);\n return wrapper;\n}\n\n/**\n * Listen on `root` for `types` (space separated) on descendants that match\n * `selector`, with `this` the matched element, as jQuery's delegated\n * handlers had it. Hands back the listener, for removeEventListener; a\n * signal in `options` removes it too.\n */\nexport function delegate(root, types, selector, handler, options) {\n var listener = function(event) {\n var match = closest(event.target, selector, root);\n if (match && root.contains(match)) { return handler.call(match, event); }\n return undefined;\n };\n\n split(types).forEach(function(type) { root.addEventListener(type, listener, options); });\n return listener;\n}\n\n/** Listen for several space separated event types with one handler. */\nexport function on(target, types, handler, options) {\n split(types).forEach(function(type) { target.addEventListener(type, handler, options); });\n return handler;\n}\n\nexport function off(target, types, handler, options) {\n split(types).forEach(function(type) { target.removeEventListener(type, handler, options); });\n}\n\n/** A mouse event of `type` sent to `node`, the way a pointer would. */\nexport function fire(node, type) {\n node.dispatchEvent(new MouseEvent(type, { bubbles: type !== 'mouseenter' && type !== 'mouseleave' }));\n}\n\n/* ------------------------------------------------------------------\n * Taking a node away, visibly.\n *\n * The durations are the ones 6.x had through jQuery: 400 ms unless the\n * caller says otherwise. `done` runs once the node is out of sight, which is\n * when the caller removes it; a node that is already out of sight is done at\n * once, on the next task, as jQuery had it.\n * ------------------------------------------------------------------ */\n\nvar DEFAULT_DURATION = 400;\n\nfunction animateAway(node, frames, duration, done) {\n duration = duration === undefined ? DEFAULT_DURATION : duration;\n\n var finish = function() {\n hide(node);\n if (done) { done(); }\n };\n\n if (!visible(node) || !node.animate || duration <= 0) {\n window.setTimeout(finish, 0);\n return;\n }\n\n var animation = node.animate(frames(getComputedStyle(node)), {\n duration: duration,\n easing: 'ease-in-out',\n });\n var called = false;\n var once = function() {\n if (called) { return; }\n called = true;\n finish();\n };\n\n animation.onfinish = once;\n animation.oncancel = once;\n}\n\n/** Fold a node up to nothing, then hide it. */\nexport function slideUp(node, duration, done) {\n if (typeof duration === 'function') {\n done = duration;\n duration = undefined;\n }\n\n node.style.overflow = 'hidden';\n animateAway(node, function(style) {\n return [\n {\n height: style.height,\n paddingTop: style.paddingTop,\n paddingBottom: style.paddingBottom,\n marginTop: style.marginTop,\n marginBottom: style.marginBottom,\n },\n { height: '0px', paddingTop: '0px', paddingBottom: '0px', marginTop: '0px', marginBottom: '0px' },\n ];\n }, duration, function() {\n node.style.removeProperty('overflow');\n if (done) { done(); }\n });\n}\n\n/** Fade a node out, then hide it. */\nexport function fadeOut(node, duration, done) {\n animateAway(node, function(style) {\n return [{ opacity: style.opacity }, { opacity: 0 }];\n }, duration, done);\n}\n\n/** Fade and fold a node, in height and, with `width`, sideways too, then hide it. */\nexport function shrinkAway(node, duration, done, width) {\n node.style.overflow = 'hidden';\n animateAway(node, function(style) {\n var from = { opacity: style.opacity, height: style.height };\n var to = { opacity: 0, height: '0px' };\n\n if (width) {\n from.width = style.width;\n to.width = '0px';\n }\n return [from, to];\n }, duration, function() {\n node.style.removeProperty('overflow');\n if (done) { done(); }\n });\n}\n", "/**\n * Element level controls for grid-editor.\n *\n * A feature plugin: load this file after the editor and the nodes a host\n * marked become elements - one movable, deletable block each, in the column\n * beside the texts, instead of rich text. What it can ask the editor for is\n * the handle its factory is called with, described in docs/plugins.md.\n *\n * <script src=\"dist/grideditor.min.js\"></script>\n * <script src=\"dist/plugins/grideditor.elements.min.js\"></script>\n *\n * Up to 5.x an element lived inside a content area, among the text. Markup\n * saved that way still loads: the editor takes each element out of the text\n * it sits in, which is what `cuts` is for.\n */\nimport { GridEditor } from '../grideditor.js';\nimport * as dom from '../dom.js';\n\nObject.assign(GridEditor.locales.en, {\n 'tool.delete_element': 'Remove element',\n 'tool.element_info': 'Element: {name}',\n 'confirm.delete_element': 'Delete element?',\n});\n\n/** A column's children that are something else than an element, whatever elements.auto says. */\nvar NOT_ELEMENTS = '.row, .ge-content, .ge-text-block, [data-ge-container], .ge-tools-drawer, .ge-resize-handle';\n\nGridEditor.features.elements = function(ge) {\n\n var warnedIntoText = false;\n\n function elementsEnabled() {\n if (ge.settings.elements.enabled !== 'auto') { return !!ge.settings.elements.enabled; }\n\n return ge.settings.elements.auto || !!ge.canvas.querySelector(ge.settings.elements.selector);\n }\n\n /** Whether a child of a column is an element. */\n function isElement(node) {\n return ge.settings.elements.auto\n ? !node.matches(NOT_ELEMENTS)\n : node.matches(ge.settings.elements.selector);\n }\n\n function markElements() {\n if (!elementsEnabled()) { return; }\n\n dom.all(ge.canvas, '.column').forEach(function(column) {\n dom.children(column).forEach(function(element) {\n if (!dom.hasClass(element, 'ge-element') && !isElement(element)) { return; }\n\n dom.addClass(element, 'ge-element');\n if (!dom.child(element, '.ge-tools-drawer')) { createElementControls(element); }\n });\n });\n }\n\n function unmarkElements() {\n dom.all(ge.canvas, '.ge-element').forEach(function(element) {\n dom.removeClass(element, 'ge-element');\n\n // A host element that had no class of its own should not come\n // back from getHtml carrying an empty one\n dom.dropEmptyClass(element);\n });\n }\n\n function createElementControls(element) {\n var drawer = dom.element('div', { 'class': 'ge-tools-drawer ge-element-drawer' });\n element.insertBefore(drawer, element.firstChild);\n\n ge.createMoveTool(drawer);\n ge.createTool(drawer, ge.t('tool.element_info', { name: elementName(element) }),\n 'ge-element-info', 'bi bi-info-circle');\n ge.addSettingsTool(drawer, element, ge.settings.element_classes);\n\n ge.settings.element_tools.forEach(function(hostTool) {\n ge.createTool(drawer, hostTool.title || '', hostTool.className || '',\n hostTool.iconClass || 'bi bi-wrench', hostTool.on);\n });\n\n ge.createTool(drawer, ge.t('tool.delete_element'), 'ge-delete-element', 'bi bi-trash', function() {\n ge.deleteNode('element', element, ge.t('confirm.delete_element'), function(removed) {\n dom.shrinkAway(element, 300, removed);\n });\n });\n }\n\n function elementName(element) {\n var type = element.getAttribute('data-ge-element');\n var label = element.getAttribute('data-ge-label');\n\n if (label && type) { return label + ' (' + type + ')'; }\n\n return label || type || element.tagName.toLowerCase();\n }\n\n /**\n * Placed into a content area, as 5.x did, an element would be text\n * again, and the next init would cut it out. So it goes beside that\n * content area instead - after it for appendTo, before it for\n * prependTo - with a word to the host.\n */\n function placementBesideText(options) {\n var placed = Object.assign({}, options);\n\n [['appendTo', 'insertAfter'], ['prependTo', 'insertBefore']].forEach(function(pair) {\n var target = options[pair[0]] !== undefined ? nodeFrom(options[pair[0]]) : null;\n if (!target || !target.matches('.ge-content')) { return; }\n\n if (!warnedIntoText) {\n warnedIntoText = true;\n ge.warn('createElement: an element is a block of the column since 6.0, not part of a ' +\n 'content area\\'s text; it goes beside the content area. Place it in a column instead.');\n }\n\n delete placed[pair[0]];\n placed[pair[1]] = dom.hasClass(target.parentElement, 'ge-text-block') ? target.parentElement : target;\n });\n\n return placed;\n }\n\n /** A place a caller named: an element, or the first one a selector matches. */\n function nodeFrom(node) {\n if (typeof node === 'string') { return document.querySelector(node); }\n return node && node.nodeType === 1 ? node : null;\n }\n\n /**\n * What the element holds: html, which is parsed as innerHTML parses so\n * no <script> in it runs, or a node, or a list of nodes.\n */\n function fill(element, content) {\n if (content === undefined || content === null) { return; }\n\n if (typeof content === 'string') {\n dom.parse(content).forEach(function(node) { element.appendChild(node); });\n } else if (content.nodeType) {\n element.appendChild(content);\n } else if (typeof content.length === 'number') {\n Array.prototype.slice.call(content).forEach(function(node) { element.appendChild(node); });\n }\n }\n\n function apiCreateElement(content, options) {\n options = options || {};\n\n var element = dom.element('div', {\n 'class': 'ge-element',\n 'data-ge-element': options.type || 'element',\n });\n fill(element, content);\n if (options.label !== undefined) {\n element.setAttribute('data-ge-label', options.label);\n }\n\n return ge.place(element, 'element', placementBesideText(options));\n }\n\n return {\n methods: {\n createElement: apiCreateElement,\n },\n\n /** A node this plugin marked is an element, whatever else it is. */\n kindOf: function(node) {\n return dom.hasClass(node, 'ge-element') ? 'element' : null;\n },\n\n /**\n * An element cuts the text it sits in: 5.x's markup, or markup a host\n * wrote the same way, has it inside a content area, and it comes out.\n */\n cuts: function() {\n if (!elementsEnabled()) { return null; }\n\n return ge.settings.elements.auto ? '*' : ge.settings.elements.selector;\n },\n\n // A block the columns move, beside the texts, the rows and the\n // containers - and only the columns\n blocks: '.ge-element',\n accepts: function(region, node) {\n if (dom.hasClass(node, 'ge-element')) { return dom.is(region, '.column'); }\n\n return true;\n },\n\n onInit: markElements,\n onDeinit: unmarkElements,\n };\n};\n"],
|
|
5
|
+
"mappings": "MASA,IAAIA,EAAa,OAAO,WAExB,GAAI,CAACA,GAAc,OAAOA,EAAW,KAAQ,WACzC,MAAM,IAAI,MAAM,wHAC0B,ECCvC,SAASC,EAAIC,EAAMC,EAAU,CAChC,OAAOD,EAAO,MAAM,UAAU,MAAM,KAAKA,EAAK,iBAAiBC,CAAQ,CAAC,EAAI,CAAC,CACjF,CAiBO,SAASC,EAASC,EAAMC,EAAU,CACrC,OAAKD,EAEE,MAAM,UAAU,OAAO,KAAKA,EAAK,SAAU,SAASE,EAAM,CAC7D,MAAO,CAACD,GAAYC,EAAK,QAAQD,CAAQ,CAC7C,CAAC,EAJmB,CAAC,CAKzB,CAGO,SAASE,EAAMH,EAAMC,EAAU,CAClC,OAAOF,EAASC,EAAMC,CAAQ,EAAE,CAAC,GAAK,IAC1C,CAWO,SAASG,EAAGC,EAAMC,EAAU,CAC/B,MAAO,CAAC,CAACD,GAAQA,EAAK,WAAa,GAAKA,EAAK,QAAQC,CAAQ,CACjE,CA+BO,SAASC,EAAMC,EAAM,CACxB,IAAIC,EAAW,SAAS,cAAc,UAAU,EAChD,OAAAA,EAAS,UAAYD,EACd,MAAM,UAAU,MAAM,KAAKC,EAAS,QAAQ,UAAU,CACjE,CAaO,SAASC,EAAQC,EAAKC,EAAYC,EAAM,CAC3C,IAAIC,EAAO,SAAS,cAAcH,CAAG,EAErC,cAAO,KAAKC,GAAc,CAAC,CAAC,EAAE,QAAQ,SAASG,EA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B,EAAG,MAAMS,EAAS,UAAWe,EAAoBC,CAAO,CAAC,CACpE,CAEA,MAAO,CACH,QAAS,CACL,cAAeQ,CACnB,EAGA,OAAQ,SAAS7B,EAAM,CACnB,OAAWM,EAASN,EAAM,YAAY,EAAI,UAAY,IAC1D,EAMA,KAAM,UAAW,CACb,OAAKF,EAAgB,EAEdF,EAAG,SAAS,SAAS,KAAO,IAAMA,EAAG,SAAS,SAAS,SAF7B,IAGrC,EAIA,OAAQ,cACR,QAAS,SAASkC,EAAQ9B,EAAM,CAC5B,OAAQM,EAASN,EAAM,YAAY,EAAgB+B,EAAGD,EAAQ,SAAS,EAEhE,EACX,EAEA,OAAQ7B,EACR,SAAUS,CACd,CACJ",
|
|
6
|
+
"names": ["GridEditor", "all", "root", "selector", "children", "node", "selector", "each", "child", "is", "node", "selector", "parse", "html", "template", "element", "tag", "attributes", "text", "node", "name", "value", "addClass", "node", "names", "split", "name", "removeClass", "hasClass", "node", "name", "split", "names", "dropEmptyClass", "hide", "node", "visible", "node", "DEFAULT_DURATION", "animateAway", "node", "frames", "duration", "done", "finish", "hide", "visible", "animation", "called", "once", "shrinkAway", "node", "duration", "done", "width", "animateAway", "style", "from", "to", "GridEditor", "NOT_ELEMENTS", "ge", "warnedIntoText", "elementsEnabled", "isElement", "node", "markElements", "all", "column", "children", "element", "hasClass", "addClass", "child", "createElementControls", "unmarkElements", "removeClass", "dropEmptyClass", "drawer", "elementName", "hostTool", "removed", "shrinkAway", "type", "label", "placementBesideText", "options", "placed", "pair", "target", "nodeFrom", "fill", "content", "parse", "apiCreateElement", "region", "is"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/js/plugins/grideditor.float.js
|
|
2
|
+
import { GridEditor } from "../grideditor.esm.js";
|
|
3
|
+
Object.assign(GridEditor.locales.en, {
|
|
4
|
+
"utility.float": "Float",
|
|
5
|
+
"utility.float_start": "Start",
|
|
6
|
+
"utility.float_end": "End",
|
|
7
|
+
"utility.float_none": "None"
|
|
8
|
+
});
|
|
9
|
+
var CSS = { start: "left", end: "right", none: "none" };
|
|
10
|
+
GridEditor.utilities.float = function(ge) {
|
|
11
|
+
function label(value) {
|
|
12
|
+
if (value === "start") {
|
|
13
|
+
return ge.t("utility.float_start");
|
|
14
|
+
}
|
|
15
|
+
if (value === "end") {
|
|
16
|
+
return ge.t("utility.float_end");
|
|
17
|
+
}
|
|
18
|
+
return ge.t("utility.float_none");
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
families: [{
|
|
22
|
+
name: "float",
|
|
23
|
+
prefix: "float",
|
|
24
|
+
values: ["start", "end", "none"],
|
|
25
|
+
appliesTo: ["element"],
|
|
26
|
+
labelKey: "utility.float",
|
|
27
|
+
label,
|
|
28
|
+
/** With no class applying here, whatever the host's css floats it as. */
|
|
29
|
+
preview: function(value, node) {
|
|
30
|
+
return { float: value === null ? ge.bareStyle(node, "float", "float") : CSS[value] };
|
|
31
|
+
}
|
|
32
|
+
}]
|
|
33
|
+
};
|
|
34
|
+
};
|