@themarioga/grid-editor 8.9.0 → 8.10.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/CHANGELOG.md +8 -0
- package/dist/grideditor.bundle.min.js +2 -2
- package/dist/grideditor.esm.js +71 -1
- package/dist/grideditor.js +71 -1
- package/dist/grideditor.min.js +1 -1
- package/dist/grideditor.min.js.map +3 -3
- package/dist/plugins/grideditor.clipboard.esm.js +2 -95
- package/dist/plugins/grideditor.clipboard.js +2 -95
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +3 -3
- package/docs/plugins.md +1 -0
- package/package.json +1 -1
- package/src/js/grideditor.js +72 -0
- package/src/js/plugins/grideditor.clipboard.js +2 -72
|
@@ -46,17 +46,6 @@ var TARGETS = {
|
|
|
46
46
|
section: ['row'],
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
/**
|
|
50
|
-
* The attributes that point at an id, as the id itself or as a #selector.
|
|
51
|
-
* A pasted copy that has to take new ids takes them here too, so its tabs,
|
|
52
|
-
* its accordion and its popups still point at their own panes.
|
|
53
|
-
*/
|
|
54
|
-
var REFERENCES = ['data-bs-target', 'data-bs-parent', 'href', 'aria-controls', 'aria-labelledby',
|
|
55
|
-
'aria-describedby', 'for', 'data-ge-popup-id', 'data-ge-popup-target'];
|
|
56
|
-
|
|
57
|
-
/** An id grid-editor generated: ge-{type}-{counter}-{random}. */
|
|
58
|
-
var GENERATED_ID = /^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;
|
|
59
|
-
|
|
60
49
|
function read() {
|
|
61
50
|
var raw;
|
|
62
51
|
|
|
@@ -150,66 +139,7 @@ GridEditor.features.clipboard = function(ge) {
|
|
|
150
139
|
var clip = read();
|
|
151
140
|
if (!fits(clip, categories)) { return; }
|
|
152
141
|
|
|
153
|
-
ge.place(
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* The copied markup as a node, with new ids where the page already has
|
|
158
|
-
* them: two copies of a tab strip pointing at one set of panes is a tab
|
|
159
|
-
* strip that opens the other copy's tabs. An id the page does not have
|
|
160
|
-
* is kept, so pasting into another page changes nothing.
|
|
161
|
-
*
|
|
162
|
-
* Parsed the way innerHTML parses, so a <script> in what was copied is
|
|
163
|
-
* markup, pasted like the rest, and does not run in the editor.
|
|
164
|
-
*/
|
|
165
|
-
function fresh(html) {
|
|
166
|
-
var node = dom.create(html);
|
|
167
|
-
var renamed = {};
|
|
168
|
-
var taken = function(id) {
|
|
169
|
-
return !!document.getElementById(id) || Object.keys(renamed).some(function(old) {
|
|
170
|
-
return renamed[old] === id;
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
dom.selfAndAll(node, '[id]').forEach(function(element) {
|
|
175
|
-
var id = element.id;
|
|
176
|
-
if (!document.getElementById(id)) { return; }
|
|
177
|
-
|
|
178
|
-
var generated = GENERATED_ID.exec(id);
|
|
179
|
-
var next;
|
|
180
|
-
|
|
181
|
-
if (generated) {
|
|
182
|
-
do { next = ge.containerId(generated[1]); } while (taken(next));
|
|
183
|
-
} else {
|
|
184
|
-
var n = 2;
|
|
185
|
-
while (taken(id + '-' + n)) { n++; }
|
|
186
|
-
next = id + '-' + n;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
renamed[id] = next;
|
|
190
|
-
element.id = next;
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
if (!Object.keys(renamed).length) { return node; }
|
|
194
|
-
|
|
195
|
-
dom.selfAndAll(node, '*').forEach(function(element) {
|
|
196
|
-
REFERENCES.forEach(function(name) {
|
|
197
|
-
var value = element.getAttribute(name);
|
|
198
|
-
if (value === null) { return; }
|
|
199
|
-
if (name === 'href' && value.charAt(0) !== '#') { return; }
|
|
200
|
-
|
|
201
|
-
var rewritten = value.split(/(\s+)/).map(function(token) {
|
|
202
|
-
if (renamed[token]) { return renamed[token]; }
|
|
203
|
-
if (token.charAt(0) === '#' && renamed[token.slice(1)]) { return '#' + renamed[token.slice(1)]; }
|
|
204
|
-
|
|
205
|
-
return token;
|
|
206
|
-
}).join('');
|
|
207
|
-
|
|
208
|
-
if (rewritten !== value) { element.setAttribute(name, rewritten); }
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
return node;
|
|
142
|
+
ge.place(ge.freshNode(clip.html), clip.kind, { appendTo: target, source: 'paste' });
|
|
213
143
|
}
|
|
214
144
|
|
|
215
145
|
/** Show the paste tools, and the toolbar's paste buttons, that fit what is copied. */
|
|
@@ -240,7 +170,7 @@ GridEditor.features.clipboard = function(ge) {
|
|
|
240
170
|
source: 'paste',
|
|
241
171
|
// What the button showed, even if another tab has copied
|
|
242
172
|
// something else since
|
|
243
|
-
create: function() { return
|
|
173
|
+
create: function() { return ge.freshNode(shown.html); },
|
|
244
174
|
});
|
|
245
175
|
});
|
|
246
176
|
|