@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,268 +1,331 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 one(root, selector) {
|
|
13
|
+
return root ? root.querySelector(selector) : null;
|
|
14
|
+
}
|
|
15
|
+
function selfAndAll(root, selector) {
|
|
16
|
+
if (!root) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
var found = all(root, selector);
|
|
20
|
+
if (root.nodeType === 1 && root.matches(selector)) {
|
|
21
|
+
found.unshift(root);
|
|
22
|
+
}
|
|
23
|
+
return found;
|
|
24
|
+
}
|
|
25
|
+
function children(node, selector) {
|
|
26
|
+
if (!node) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return Array.prototype.filter.call(node.children, function(each) {
|
|
30
|
+
return !selector || each.matches(selector);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function child(node, selector) {
|
|
34
|
+
return children(node, selector)[0] || null;
|
|
35
|
+
}
|
|
36
|
+
function parse(html) {
|
|
37
|
+
var template = document.createElement("template");
|
|
38
|
+
template.innerHTML = html;
|
|
39
|
+
return Array.prototype.slice.call(template.content.childNodes);
|
|
40
|
+
}
|
|
41
|
+
function create(html) {
|
|
42
|
+
var nodes = parse(html.trim());
|
|
43
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
44
|
+
if (nodes[i].nodeType === 1) {
|
|
45
|
+
return nodes[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
function addClass(node, names) {
|
|
51
|
+
split(names).forEach(function(name) {
|
|
52
|
+
node.classList.add(name);
|
|
53
|
+
});
|
|
54
|
+
return node;
|
|
55
|
+
}
|
|
56
|
+
function removeClass(node, names) {
|
|
57
|
+
split(names).forEach(function(name) {
|
|
58
|
+
node.classList.remove(name);
|
|
59
|
+
});
|
|
60
|
+
return node;
|
|
61
|
+
}
|
|
62
|
+
function split(names) {
|
|
63
|
+
return String(names || "").split(/\s+/).filter(Boolean);
|
|
64
|
+
}
|
|
65
|
+
var defaultDisplays = {};
|
|
66
|
+
function defaultDisplay(node) {
|
|
67
|
+
var tag = node.nodeName;
|
|
68
|
+
if (!defaultDisplays[tag]) {
|
|
69
|
+
var probe = document.body.appendChild(document.createElement(tag));
|
|
70
|
+
defaultDisplays[tag] = getComputedStyle(probe).display;
|
|
71
|
+
probe.remove();
|
|
72
|
+
if (defaultDisplays[tag] === "none") {
|
|
73
|
+
defaultDisplays[tag] = "block";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return defaultDisplays[tag];
|
|
77
|
+
}
|
|
78
|
+
function show(node) {
|
|
79
|
+
node.style.removeProperty("display");
|
|
80
|
+
if (getComputedStyle(node).display === "none") {
|
|
81
|
+
node.style.display = defaultDisplay(node);
|
|
82
|
+
}
|
|
83
|
+
return node;
|
|
84
|
+
}
|
|
85
|
+
function hide(node) {
|
|
86
|
+
node.style.display = "none";
|
|
87
|
+
return node;
|
|
88
|
+
}
|
|
89
|
+
function toggle(node, state) {
|
|
90
|
+
if (state === void 0) {
|
|
91
|
+
state = !visible(node);
|
|
92
|
+
}
|
|
93
|
+
return state ? show(node) : hide(node);
|
|
94
|
+
}
|
|
95
|
+
function visible(node) {
|
|
96
|
+
return !!(node.offsetWidth || node.offsetHeight || node.getClientRects().length);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/js/plugins/grideditor.clipboard.js
|
|
100
|
+
Object.assign(GridEditor.locales.en, {
|
|
101
|
+
"tool.copy": "Copy",
|
|
102
|
+
"tool.paste": "Paste",
|
|
103
|
+
"clipboard.paste_row": "Paste row",
|
|
104
|
+
"clipboard.paste_section": "Paste section"
|
|
105
|
+
});
|
|
106
|
+
var STORAGE_ITEM = "grideditor.clipboard";
|
|
107
|
+
var CHANGE = "grideditor-clipboard";
|
|
108
|
+
var VERSION = 1;
|
|
109
|
+
var memory = null;
|
|
110
|
+
var TARGETS = {
|
|
111
|
+
column: ["row", "text", "container", "element"],
|
|
112
|
+
row: ["column"],
|
|
113
|
+
section: ["row"]
|
|
114
|
+
};
|
|
115
|
+
var REFERENCES = [
|
|
116
|
+
"data-bs-target",
|
|
117
|
+
"data-bs-parent",
|
|
118
|
+
"href",
|
|
119
|
+
"aria-controls",
|
|
120
|
+
"aria-labelledby",
|
|
121
|
+
"aria-describedby",
|
|
122
|
+
"for",
|
|
123
|
+
"data-ge-popup-id",
|
|
124
|
+
"data-ge-popup-target"
|
|
125
|
+
];
|
|
126
|
+
var GENERATED_ID = /^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;
|
|
127
|
+
function read() {
|
|
61
128
|
var raw;
|
|
62
|
-
|
|
63
129
|
try {
|
|
64
|
-
|
|
130
|
+
raw = window.localStorage.getItem(STORAGE_ITEM);
|
|
65
131
|
} catch (error) {
|
|
66
|
-
|
|
132
|
+
return memory;
|
|
133
|
+
}
|
|
134
|
+
if (raw === null) {
|
|
135
|
+
return memory;
|
|
67
136
|
}
|
|
68
|
-
if (raw === null) { return memory; }
|
|
69
|
-
|
|
70
137
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
138
|
+
var clip = JSON.parse(raw);
|
|
139
|
+
return clip && clip.version === VERSION && clip.html ? clip : null;
|
|
73
140
|
} catch (error) {
|
|
74
|
-
|
|
141
|
+
return null;
|
|
75
142
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function write(clip) {
|
|
143
|
+
}
|
|
144
|
+
function write(clip) {
|
|
79
145
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
146
|
+
window.localStorage.setItem(STORAGE_ITEM, JSON.stringify(clip));
|
|
147
|
+
memory = null;
|
|
82
148
|
} catch (error) {
|
|
83
|
-
|
|
149
|
+
memory = clip;
|
|
84
150
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (e.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
|
|
151
|
+
announce();
|
|
152
|
+
}
|
|
153
|
+
function announce() {
|
|
154
|
+
document.dispatchEvent(new CustomEvent(CHANGE));
|
|
155
|
+
}
|
|
156
|
+
window.addEventListener("storage", function(e) {
|
|
157
|
+
if (e.key === STORAGE_ITEM) {
|
|
158
|
+
announce();
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
GridEditor.features.clipboard = function(ge) {
|
|
162
|
+
var shown = null;
|
|
163
|
+
var listening = false;
|
|
99
164
|
function used(name) {
|
|
100
|
-
|
|
165
|
+
return !ge.settings.plugins || ge.settings.plugins.indexOf(name) !== -1;
|
|
101
166
|
}
|
|
102
|
-
|
|
103
|
-
/** A category this editor can take: the plugin that makes it is here. */
|
|
104
167
|
function available(clip) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
168
|
+
if (clip.category === "container") {
|
|
169
|
+
return !!GridEditor.containers[clip.kind] && used(clip.kind);
|
|
170
|
+
}
|
|
171
|
+
if (clip.category === "section") {
|
|
172
|
+
return !!GridEditor.features.sections && used("sections");
|
|
173
|
+
}
|
|
174
|
+
if (clip.category === "element") {
|
|
175
|
+
return !!GridEditor.features.elements && used("elements");
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
112
178
|
}
|
|
113
|
-
|
|
114
179
|
function fits(clip, categories) {
|
|
115
|
-
|
|
180
|
+
return !!clip && categories.indexOf(clip.category) !== -1 && available(clip);
|
|
116
181
|
}
|
|
117
|
-
|
|
118
182
|
function categoryOf(kind) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
183
|
+
if (GridEditor.containers[kind]) {
|
|
184
|
+
return "container";
|
|
185
|
+
}
|
|
186
|
+
return ["row", "column", "section", "text", "element"].indexOf(kind) !== -1 ? kind : null;
|
|
122
187
|
}
|
|
123
|
-
|
|
124
188
|
function copy(node, kind) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
189
|
+
var html = ge.nodeHtml(node);
|
|
190
|
+
write({ version: VERSION, category: categoryOf(kind), kind, html });
|
|
191
|
+
ge.emit("after-copy", ge.payloadFor(kind, node, { source: "tool" }));
|
|
192
|
+
var tool = child(ge.drawerOf(node), ".ge-copy");
|
|
193
|
+
if (!tool) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var icon = one(tool, "i");
|
|
197
|
+
addClass(tool, "ge-copied");
|
|
198
|
+
if (icon) {
|
|
199
|
+
icon.setAttribute("class", "bi bi-check2");
|
|
200
|
+
}
|
|
201
|
+
setTimeout(function() {
|
|
202
|
+
removeClass(tool, "ge-copied");
|
|
203
|
+
if (icon) {
|
|
204
|
+
icon.setAttribute("class", "bi bi-copy");
|
|
205
|
+
}
|
|
206
|
+
}, 1200);
|
|
137
207
|
}
|
|
138
|
-
|
|
139
208
|
function paste(target, categories) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
209
|
+
var clip = read();
|
|
210
|
+
if (!fits(clip, categories)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
ge.place(fresh(clip.html), clip.kind, { appendTo: target, source: "paste" });
|
|
144
214
|
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* The copied markup as a node, with new ids where the page already has
|
|
148
|
-
* them: two copies of a tab strip pointing at one set of panes is a tab
|
|
149
|
-
* strip that opens the other copy's tabs. An id the page does not have
|
|
150
|
-
* is kept, so pasting into another page changes nothing.
|
|
151
|
-
*/
|
|
152
215
|
function fresh(html) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
node.find('[id]').addBack('[id]').each(function() {
|
|
162
|
-
var id = this.id;
|
|
163
|
-
if (!document.getElementById(id)) { return; }
|
|
164
|
-
|
|
165
|
-
var generated = GENERATED_ID.exec(id);
|
|
166
|
-
var next;
|
|
167
|
-
|
|
168
|
-
if (generated) {
|
|
169
|
-
do { next = ge.containerId(generated[1]); } while (taken(next));
|
|
170
|
-
} else {
|
|
171
|
-
var n = 2;
|
|
172
|
-
while (taken(id + '-' + n)) { n++; }
|
|
173
|
-
next = id + '-' + n;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
renamed[id] = next;
|
|
177
|
-
this.id = next;
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
if (!Object.keys(renamed).length) { return node; }
|
|
181
|
-
|
|
182
|
-
node.find('*').addBack().each(function() {
|
|
183
|
-
var element = this;
|
|
184
|
-
|
|
185
|
-
REFERENCES.forEach(function(name) {
|
|
186
|
-
var value = element.getAttribute(name);
|
|
187
|
-
if (value === null) { return; }
|
|
188
|
-
if (name === 'href' && value.charAt(0) !== '#') { return; }
|
|
189
|
-
|
|
190
|
-
var rewritten = value.split(/(\s+)/).map(function(token) {
|
|
191
|
-
if (renamed[token]) { return renamed[token]; }
|
|
192
|
-
if (token.charAt(0) === '#' && renamed[token.slice(1)]) { return '#' + renamed[token.slice(1)]; }
|
|
193
|
-
|
|
194
|
-
return token;
|
|
195
|
-
}).join('');
|
|
196
|
-
|
|
197
|
-
if (rewritten !== value) { element.setAttribute(name, rewritten); }
|
|
198
|
-
});
|
|
216
|
+
var node = create(html);
|
|
217
|
+
var renamed = {};
|
|
218
|
+
var taken = function(id) {
|
|
219
|
+
return !!document.getElementById(id) || Object.keys(renamed).some(function(old) {
|
|
220
|
+
return renamed[old] === id;
|
|
199
221
|
});
|
|
200
|
-
|
|
222
|
+
};
|
|
223
|
+
selfAndAll(node, "[id]").forEach(function(element) {
|
|
224
|
+
var id = element.id;
|
|
225
|
+
if (!document.getElementById(id)) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
var generated = GENERATED_ID.exec(id);
|
|
229
|
+
var next;
|
|
230
|
+
if (generated) {
|
|
231
|
+
do {
|
|
232
|
+
next = ge.containerId(generated[1]);
|
|
233
|
+
} while (taken(next));
|
|
234
|
+
} else {
|
|
235
|
+
var n = 2;
|
|
236
|
+
while (taken(id + "-" + n)) {
|
|
237
|
+
n++;
|
|
238
|
+
}
|
|
239
|
+
next = id + "-" + n;
|
|
240
|
+
}
|
|
241
|
+
renamed[id] = next;
|
|
242
|
+
element.id = next;
|
|
243
|
+
});
|
|
244
|
+
if (!Object.keys(renamed).length) {
|
|
201
245
|
return node;
|
|
246
|
+
}
|
|
247
|
+
selfAndAll(node, "*").forEach(function(element) {
|
|
248
|
+
REFERENCES.forEach(function(name) {
|
|
249
|
+
var value = element.getAttribute(name);
|
|
250
|
+
if (value === null) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (name === "href" && value.charAt(0) !== "#") {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
var rewritten = value.split(/(\s+)/).map(function(token) {
|
|
257
|
+
if (renamed[token]) {
|
|
258
|
+
return renamed[token];
|
|
259
|
+
}
|
|
260
|
+
if (token.charAt(0) === "#" && renamed[token.slice(1)]) {
|
|
261
|
+
return "#" + renamed[token.slice(1)];
|
|
262
|
+
}
|
|
263
|
+
return token;
|
|
264
|
+
}).join("");
|
|
265
|
+
if (rewritten !== value) {
|
|
266
|
+
element.setAttribute(name, rewritten);
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
return node;
|
|
202
271
|
}
|
|
203
|
-
|
|
204
|
-
/** Show the paste tools, and the toolbar's paste buttons, that fit what is copied. */
|
|
205
272
|
function refresh() {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
shown = clip;
|
|
273
|
+
var clip = read();
|
|
274
|
+
all(ge.canvas, ".ge-paste").forEach(function(tool) {
|
|
275
|
+
toggle(tool, fits(clip, tool.getAttribute("data-ge-paste").split(" ")));
|
|
276
|
+
});
|
|
277
|
+
ge.toolbarItems("clipboard").forEach(function(button) {
|
|
278
|
+
var item = TOOLBAR[parseInt(button.getAttribute("data-ge-item"), 10)];
|
|
279
|
+
toggle(button, fits(clip, [item.kind]));
|
|
280
|
+
});
|
|
281
|
+
shown = clip;
|
|
218
282
|
}
|
|
219
|
-
|
|
220
283
|
var TOOLBAR = [
|
|
221
|
-
|
|
222
|
-
|
|
284
|
+
{ kind: "row", labelKey: "clipboard.paste_row" },
|
|
285
|
+
{ kind: "section", labelKey: "clipboard.paste_section" }
|
|
223
286
|
].map(function(item) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
287
|
+
return Object.assign(item, {
|
|
288
|
+
iconClass: "bi bi-clipboard-plus",
|
|
289
|
+
// On the right, as an icon: pasting is not one of the things
|
|
290
|
+
// the add buttons make
|
|
291
|
+
align: "end",
|
|
292
|
+
source: "paste",
|
|
293
|
+
// What the button showed, even if another tab has copied
|
|
294
|
+
// something else since
|
|
295
|
+
create: function() {
|
|
296
|
+
return fresh(shown.html);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
234
299
|
});
|
|
235
|
-
|
|
236
300
|
return {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
301
|
+
drawerTools: function(drawer, node, kind) {
|
|
302
|
+
if (categoryOf(kind)) {
|
|
303
|
+
ge.createTool(drawer, ge.t("tool.copy"), "ge-copy", "bi bi-copy", function() {
|
|
304
|
+
copy(node, kind);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
var categories = TARGETS[kind];
|
|
308
|
+
if (!categories) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
var tool = ge.createTool(drawer, ge.t("tool.paste"), "ge-paste", "bi bi-clipboard-plus", function() {
|
|
312
|
+
paste(node, categories);
|
|
313
|
+
});
|
|
314
|
+
tool.setAttribute("data-ge-paste", categories.join(" "));
|
|
315
|
+
toggle(tool, fits(read(), categories));
|
|
316
|
+
},
|
|
317
|
+
toolbar: TOOLBAR,
|
|
318
|
+
onInit: function() {
|
|
319
|
+
refresh();
|
|
320
|
+
if (!listening) {
|
|
321
|
+
document.addEventListener(CHANGE, refresh);
|
|
322
|
+
listening = true;
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
onDeinit: function() {
|
|
326
|
+
document.removeEventListener(CHANGE, refresh);
|
|
327
|
+
listening = false;
|
|
328
|
+
}
|
|
265
329
|
};
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
})(jQuery);
|
|
330
|
+
};
|
|
331
|
+
})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
(
|
|
2
|
-
//# sourceMappingURL=grideditor.clipboard.min.js.map
|
|
1
|
+
(()=>{var l=window.GridEditor;if(!l||typeof l.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 x(t,e){return t?Array.prototype.slice.call(t.querySelectorAll(e)):[]}function S(t,e){return t?t.querySelector(e):null}function b(t,e){if(!t)return[];var n=x(t,e);return t.nodeType===1&&t.matches(e)&&n.unshift(t),n}function P(t,e){return t?Array.prototype.filter.call(t.children,function(n){return!e||n.matches(e)}):[]}function B(t,e){return P(t,e)[0]||null}function _(t){var e=document.createElement("template");return e.innerHTML=t,Array.prototype.slice.call(e.content.childNodes)}function L(t){for(var e=_(t.trim()),n=0;n<e.length;n++)if(e[n].nodeType===1)return e[n];return null}function I(t,e){return N(e).forEach(function(n){t.classList.add(n)}),t}function j(t,e){return N(e).forEach(function(n){t.classList.remove(n)}),t}function N(t){return String(t||"").split(/\s+/).filter(Boolean)}var d={};function F(t){var e=t.nodeName;if(!d[e]){var n=document.body.appendChild(document.createElement(e));d[e]=getComputedStyle(n).display,n.remove(),d[e]==="none"&&(d[e]="block")}return d[e]}function U(t){return t.style.removeProperty("display"),getComputedStyle(t).display==="none"&&(t.style.display=F(t)),t}function z(t){return t.style.display="none",t}function g(t,e){return e===void 0&&(e=!M(t)),e?U(t):z(t)}function M(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}Object.assign(l.locales.en,{"tool.copy":"Copy","tool.paste":"Paste","clipboard.paste_row":"Paste row","clipboard.paste_section":"Paste section"});var A="grideditor.clipboard",w="grideditor-clipboard",R=1,v=null,J={column:["row","text","container","element"],row:["column"],section:["row"]},K=["data-bs-target","data-bs-parent","href","aria-controls","aria-labelledby","aria-describedby","for","data-ge-popup-id","data-ge-popup-target"],W=/^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;function E(){var t;try{t=window.localStorage.getItem(A)}catch(n){return v}if(t===null)return v;try{var e=JSON.parse(t);return e&&e.version===R&&e.html?e:null}catch(n){return null}}function V(t){try{window.localStorage.setItem(A,JSON.stringify(t)),v=null}catch(e){v=t}H()}function H(){document.dispatchEvent(new CustomEvent(w))}window.addEventListener("storage",function(t){t.key===A&&H()});l.features.clipboard=function(t){var e=null,n=!1;function h(r){return!t.settings.plugins||t.settings.plugins.indexOf(r)!==-1}function k(r){return r.category==="container"?!!l.containers[r.kind]&&h(r.kind):r.category==="section"?!!l.features.sections&&h("sections"):r.category==="element"?!!l.features.elements&&h("elements"):!0}function m(r,i){return!!r&&i.indexOf(r.category)!==-1&&k(r)}function T(r){return l.containers[r]?"container":["row","column","section","text","element"].indexOf(r)!==-1?r:null}function D(r,i){var o=t.nodeHtml(r);V({version:R,category:T(i),kind:i,html:o}),t.emit("after-copy",t.payloadFor(i,r,{source:"tool"}));var u=B(t.drawerOf(r),".ge-copy");if(u){var a=S(u,"i");I(u,"ge-copied"),a&&a.setAttribute("class","bi bi-check2"),setTimeout(function(){j(u,"ge-copied"),a&&a.setAttribute("class","bi bi-copy")},1200)}}function G(r,i){var o=E();m(o,i)&&t.place(C(o.html),o.kind,{appendTo:r,source:"paste"})}function C(r){var i=L(r),o={},u=function(a){return!!document.getElementById(a)||Object.keys(o).some(function(c){return o[c]===a})};return b(i,"[id]").forEach(function(a){var c=a.id;if(document.getElementById(c)){var p=W.exec(c),s;if(p)do s=t.containerId(p[1]);while(u(s));else{for(var f=2;u(c+"-"+f);)f++;s=c+"-"+f}o[c]=s,a.id=s}}),Object.keys(o).length&&b(i,"*").forEach(function(a){K.forEach(function(c){var p=a.getAttribute(c);if(p!==null&&!(c==="href"&&p.charAt(0)!=="#")){var s=p.split(/(\s+)/).map(function(f){return o[f]?o[f]:f.charAt(0)==="#"&&o[f.slice(1)]?"#"+o[f.slice(1)]:f}).join("");s!==p&&a.setAttribute(c,s)}})}),i}function y(){var r=E();x(t.canvas,".ge-paste").forEach(function(i){g(i,m(r,i.getAttribute("data-ge-paste").split(" ")))}),t.toolbarItems("clipboard").forEach(function(i){var o=O[parseInt(i.getAttribute("data-ge-item"),10)];g(i,m(r,[o.kind]))}),e=r}var O=[{kind:"row",labelKey:"clipboard.paste_row"},{kind:"section",labelKey:"clipboard.paste_section"}].map(function(r){return Object.assign(r,{iconClass:"bi bi-clipboard-plus",align:"end",source:"paste",create:function(){return C(e.html)}})});return{drawerTools:function(r,i,o){T(o)&&t.createTool(r,t.t("tool.copy"),"ge-copy","bi bi-copy",function(){D(i,o)});var u=J[o];if(u){var a=t.createTool(r,t.t("tool.paste"),"ge-paste","bi bi-clipboard-plus",function(){G(i,u)});a.setAttribute("data-ge-paste",u.join(" ")),g(a,m(E(),u))}},toolbar:O,onInit:function(){y(),n||(document.addEventListener(w,y),n=!0)},onDeinit:function(){document.removeEventListener(w,y),n=!1}}};})();
|