@themarioga/grid-editor 5.0.0 → 5.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/CHANGELOG.md +27 -0
- package/README.md +64 -3
- package/dist/grideditor.css +5 -0
- package/dist/grideditor.min.css +1 -1
- package/dist/grideditor.min.css.map +1 -1
- package/dist/jquery.grideditor.bundle.min.js +2 -2
- package/dist/jquery.grideditor.js +110 -20
- package/dist/jquery.grideditor.min.js +1 -1
- package/dist/jquery.grideditor.min.js.map +1 -1
- package/dist/locales/grideditor.es.js +4 -0
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +1 -1
- package/dist/plugins/grideditor.clipboard.js +274 -0
- package/dist/plugins/grideditor.clipboard.min.js +2 -0
- package/dist/plugins/grideditor.clipboard.min.js.map +1 -0
- package/dist/plugins/grideditor.sections.js +4 -4
- package/dist/plugins/grideditor.sections.min.js +1 -1
- package/dist/plugins/grideditor.sections.min.js.map +1 -1
- package/docs/events.md +4 -1
- package/docs/locale-keys.md +13 -0
- package/docs/plugins.md +10 -1
- package/example/clipboard.html +99 -0
- package/example/index.html +8 -0
- package/example/wrap_content.html +66 -16
- package/package.json +1 -1
- package/src/js/jquery.grideditor.js +110 -20
- package/src/js/locales/grideditor.es.js +4 -0
- package/src/js/plugins/grideditor.clipboard.js +274 -0
- package/src/js/plugins/grideditor.sections.js +4 -4
- package/src/less/grideditor.less +6 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy and paste for grid-editor.
|
|
3
|
+
*
|
|
4
|
+
* A feature plugin: load this file after the editor and every row, column,
|
|
5
|
+
* section, container and element gets a copy tool, and every place one of
|
|
6
|
+
* them can go gets a paste tool while there is something copied that fits.
|
|
7
|
+
* What it can ask the editor for is the handle its factory is called with,
|
|
8
|
+
* described in docs/plugins.md.
|
|
9
|
+
*
|
|
10
|
+
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
11
|
+
* <script src="dist/plugins/grideditor.clipboard.min.js"></script>
|
|
12
|
+
*
|
|
13
|
+
* What is copied is kept in localStorage, so it survives a reload and can be
|
|
14
|
+
* pasted in another tab or another editor of the same site. A browser that
|
|
15
|
+
* will not give the page its storage keeps it in memory, for this page only.
|
|
16
|
+
*
|
|
17
|
+
* A paste is an add like any other - before-add-* and after-add-*, with
|
|
18
|
+
* `source: 'paste'` - so a host can turn one away.
|
|
19
|
+
*/
|
|
20
|
+
(function($) {
|
|
21
|
+
|
|
22
|
+
$.extend($.fn.gridEditor.locales.en, {
|
|
23
|
+
'tool.copy': 'Copy',
|
|
24
|
+
'tool.paste': 'Paste',
|
|
25
|
+
'clipboard.paste_row': 'Paste row',
|
|
26
|
+
'clipboard.paste_section': 'Paste section',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
var STORAGE_ITEM = 'grideditor.clipboard';
|
|
30
|
+
var CHANGE = 'grideditor-clipboard';
|
|
31
|
+
var VERSION = 1;
|
|
32
|
+
|
|
33
|
+
/** Where nothing can be stored, what was copied lives here, for this page. */
|
|
34
|
+
var memory = null;
|
|
35
|
+
var editors = 0;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* What each drawer takes when something is pasted into it, by the kind of the
|
|
39
|
+
* node the drawer belongs to. A category is what was copied: a row, a column,
|
|
40
|
+
* a section, a container of any type, an element.
|
|
41
|
+
*/
|
|
42
|
+
var TARGETS = {
|
|
43
|
+
column: ['row', 'container', 'element'],
|
|
44
|
+
row: ['column'],
|
|
45
|
+
section: ['row'],
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The attributes that point at an id, as the id itself or as a #selector.
|
|
50
|
+
* A pasted copy that has to take new ids takes them here too, so its tabs,
|
|
51
|
+
* its accordion and its popups still point at their own panes.
|
|
52
|
+
*/
|
|
53
|
+
var REFERENCES = ['data-bs-target', 'data-bs-parent', 'href', 'aria-controls', 'aria-labelledby',
|
|
54
|
+
'aria-describedby', 'for', 'data-ge-popup-id', 'data-ge-popup-target'];
|
|
55
|
+
|
|
56
|
+
/** An id grid-editor generated: ge-{type}-{counter}-{random}. */
|
|
57
|
+
var GENERATED_ID = /^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;
|
|
58
|
+
|
|
59
|
+
function read() {
|
|
60
|
+
var raw;
|
|
61
|
+
|
|
62
|
+
try {
|
|
63
|
+
raw = window.localStorage.getItem(STORAGE_ITEM);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return memory;
|
|
66
|
+
}
|
|
67
|
+
if (raw === null) { return memory; }
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
var clip = JSON.parse(raw);
|
|
71
|
+
return clip && clip.version === VERSION && clip.html ? clip : null;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function write(clip) {
|
|
78
|
+
try {
|
|
79
|
+
window.localStorage.setItem(STORAGE_ITEM, JSON.stringify(clip));
|
|
80
|
+
memory = null;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
memory = clip;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
$(document).trigger(CHANGE);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Another tab copied something: every editor here looks again
|
|
89
|
+
$(window).on('storage', function(e) {
|
|
90
|
+
if (e.originalEvent && e.originalEvent.key === STORAGE_ITEM) { $(document).trigger(CHANGE); }
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
$.fn.gridEditor.features.clipboard = function(ge) {
|
|
94
|
+
|
|
95
|
+
var namespace = '.ge-clipboard-' + (++editors);
|
|
96
|
+
var shown = null; // What the toolbar's paste buttons stand for
|
|
97
|
+
|
|
98
|
+
function used(name) {
|
|
99
|
+
return !ge.settings.plugins || ge.settings.plugins.indexOf(name) !== -1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A category this editor can take: the plugin that makes it is here. */
|
|
103
|
+
function available(clip) {
|
|
104
|
+
if (clip.category === 'container') {
|
|
105
|
+
return !!$.fn.gridEditor.containers[clip.kind] && used(clip.kind);
|
|
106
|
+
}
|
|
107
|
+
if (clip.category === 'section') { return !!$.fn.gridEditor.features.sections && used('sections'); }
|
|
108
|
+
if (clip.category === 'element') { return !!$.fn.gridEditor.features.elements && used('elements'); }
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function fits(clip, categories) {
|
|
114
|
+
return !!clip && categories.indexOf(clip.category) !== -1 && available(clip);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function categoryOf(kind) {
|
|
118
|
+
if ($.fn.gridEditor.containers[kind]) { return 'container'; }
|
|
119
|
+
|
|
120
|
+
return ['row', 'column', 'section', 'element'].indexOf(kind) !== -1 ? kind : null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function copy(node, kind) {
|
|
124
|
+
var html = ge.nodeHtml(node);
|
|
125
|
+
|
|
126
|
+
write({ version: VERSION, category: categoryOf(kind), kind: kind, html: html });
|
|
127
|
+
ge.emit('after-copy', ge.payloadFor(kind, node, { source: 'tool' }));
|
|
128
|
+
|
|
129
|
+
// The canvas came back with new drawers: the one to flash is the
|
|
130
|
+
// node's new copy tool
|
|
131
|
+
var tool = node.children('.ge-tools-drawer').find('> .ge-copy');
|
|
132
|
+
tool.addClass('ge-copied').find('i').attr('class', 'bi bi-check2');
|
|
133
|
+
setTimeout(function() {
|
|
134
|
+
tool.removeClass('ge-copied').find('i').attr('class', 'bi bi-copy');
|
|
135
|
+
}, 1200);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function paste(target, categories) {
|
|
139
|
+
var clip = read();
|
|
140
|
+
if (!fits(clip, categories)) { return; }
|
|
141
|
+
|
|
142
|
+
var node = fresh(clip.html);
|
|
143
|
+
var into = target;
|
|
144
|
+
|
|
145
|
+
// An element goes into the column's last content area. With none,
|
|
146
|
+
// the column's next init wraps it in one of its own
|
|
147
|
+
if (clip.category === 'element') {
|
|
148
|
+
var area = target.children('.ge-content').last();
|
|
149
|
+
if (area.length) { into = area; }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
ge.place(node, clip.kind, { appendTo: into, source: 'paste' });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The copied markup as a node, with new ids where the page already has
|
|
157
|
+
* them: two copies of a tab strip pointing at one set of panes is a tab
|
|
158
|
+
* strip that opens the other copy's tabs. An id the page does not have
|
|
159
|
+
* is kept, so pasting into another page changes nothing.
|
|
160
|
+
*/
|
|
161
|
+
function fresh(html) {
|
|
162
|
+
var node = $($.parseHTML(html.trim(), document, true)).first();
|
|
163
|
+
var renamed = {};
|
|
164
|
+
var taken = function(id) {
|
|
165
|
+
return !!document.getElementById(id) || Object.keys(renamed).some(function(old) {
|
|
166
|
+
return renamed[old] === id;
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
node.find('[id]').addBack('[id]').each(function() {
|
|
171
|
+
var id = this.id;
|
|
172
|
+
if (!document.getElementById(id)) { return; }
|
|
173
|
+
|
|
174
|
+
var generated = GENERATED_ID.exec(id);
|
|
175
|
+
var next;
|
|
176
|
+
|
|
177
|
+
if (generated) {
|
|
178
|
+
do { next = ge.containerId(generated[1]); } while (taken(next));
|
|
179
|
+
} else {
|
|
180
|
+
var n = 2;
|
|
181
|
+
while (taken(id + '-' + n)) { n++; }
|
|
182
|
+
next = id + '-' + n;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
renamed[id] = next;
|
|
186
|
+
this.id = next;
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
if (!Object.keys(renamed).length) { return node; }
|
|
190
|
+
|
|
191
|
+
node.find('*').addBack().each(function() {
|
|
192
|
+
var element = this;
|
|
193
|
+
|
|
194
|
+
REFERENCES.forEach(function(name) {
|
|
195
|
+
var value = element.getAttribute(name);
|
|
196
|
+
if (value === null) { return; }
|
|
197
|
+
if (name === 'href' && value.charAt(0) !== '#') { return; }
|
|
198
|
+
|
|
199
|
+
var rewritten = value.split(/(\s+)/).map(function(token) {
|
|
200
|
+
if (renamed[token]) { return renamed[token]; }
|
|
201
|
+
if (token.charAt(0) === '#' && renamed[token.slice(1)]) { return '#' + renamed[token.slice(1)]; }
|
|
202
|
+
|
|
203
|
+
return token;
|
|
204
|
+
}).join('');
|
|
205
|
+
|
|
206
|
+
if (rewritten !== value) { element.setAttribute(name, rewritten); }
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
return node;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Show the paste tools, and the toolbar's paste buttons, that fit what is copied. */
|
|
214
|
+
function refresh() {
|
|
215
|
+
var clip = read();
|
|
216
|
+
|
|
217
|
+
ge.canvas.find('.ge-paste').each(function() {
|
|
218
|
+
$(this).toggle(fits(clip, $(this).attr('data-ge-paste').split(' ')));
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
ge.toolbarItems('clipboard').each(function() {
|
|
222
|
+
var item = TOOLBAR[parseInt($(this).attr('data-ge-item'), 10)];
|
|
223
|
+
$(this).toggle(fits(clip, [item.kind]));
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
shown = clip;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
var TOOLBAR = [
|
|
230
|
+
{ kind: 'row', labelKey: 'clipboard.paste_row' },
|
|
231
|
+
{ kind: 'section', labelKey: 'clipboard.paste_section' },
|
|
232
|
+
].map(function(item) {
|
|
233
|
+
return $.extend(item, {
|
|
234
|
+
iconClass: 'bi bi-clipboard-plus',
|
|
235
|
+
source: 'paste',
|
|
236
|
+
// What the button showed, even if another tab has copied
|
|
237
|
+
// something else since
|
|
238
|
+
create: function() { return fresh(shown.html); },
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
drawerTools: function(drawer, node, kind) {
|
|
244
|
+
if (categoryOf(kind)) {
|
|
245
|
+
ge.createTool(drawer, ge.t('tool.copy'), 'ge-copy', 'bi bi-copy', function() {
|
|
246
|
+
copy(node, kind);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
var categories = TARGETS[kind];
|
|
251
|
+
if (!categories) { return; }
|
|
252
|
+
|
|
253
|
+
ge.createTool(drawer, ge.t('tool.paste'), 'ge-paste', 'bi bi-clipboard-plus', function() {
|
|
254
|
+
paste(node, categories);
|
|
255
|
+
});
|
|
256
|
+
drawer.children('.ge-paste').last()
|
|
257
|
+
.attr('data-ge-paste', categories.join(' '))
|
|
258
|
+
.toggle(fits(read(), categories));
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
toolbar: TOOLBAR,
|
|
262
|
+
|
|
263
|
+
onInit: function() {
|
|
264
|
+
refresh();
|
|
265
|
+
$(document).off(CHANGE + namespace).on(CHANGE + namespace, refresh);
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
onDeinit: function() {
|
|
269
|
+
$(document).off(CHANGE + namespace);
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
})(jQuery);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(u=>{u.extend(u.fn.gridEditor.locales.en,{"tool.copy":"Copy","tool.paste":"Paste","clipboard.paste_row":"Paste row","clipboard.paste_section":"Paste section"});var i="grideditor.clipboard",f="grideditor-clipboard",g=1,p=null,b=0,m={column:["row","container","element"],row:["column"],section:["row"]},h=["data-bs-target","data-bs-parent","href","aria-controls","aria-labelledby","aria-describedby","for","data-ge-popup-id","data-ge-popup-target"],y=/^ge-([a-z][a-z-]*?)-\d+-[a-z0-9]+$/;function v(){var t;try{t=window.localStorage.getItem(i)}catch(t){return p}if(null===t)return p;try{var e=JSON.parse(t);return e&&e.version===g&&e.html?e:null}catch(t){return null}}u(window).on("storage",function(t){t.originalEvent&&t.originalEvent.key===i&&u(document).trigger(f)}),u.fn.gridEditor.features.clipboard=function(a){var t=".ge-clipboard-"+ ++b,n=null;function o(t){return!a.settings.plugins||-1!==a.settings.plugins.indexOf(t)}function c(t,e){return!!t&&-1!==e.indexOf(t.category)&&("container"===(e=t).category?!!u.fn.gridEditor.containers[e.kind]&&o(e.kind):"section"===e.category?!!u.fn.gridEditor.features.sections&&o("sections"):"element"!==e.category||!!u.fn.gridEditor.features.elements&&o("elements"))}function l(t){return u.fn.gridEditor.containers[t]?"container":-1!==["row","column","section","element"].indexOf(t)?t:null}function s(t,e){var n=a.nodeHtml(t),n={version:g,category:l(e),kind:e,html:n};try{window.localStorage.setItem(i,JSON.stringify(n)),p=null}catch(t){p=n}u(document).trigger(f),a.emit("after-copy",a.payloadFor(e,t,{source:"tool"}));var o=t.children(".ge-tools-drawer").find("> .ge-copy");o.addClass("ge-copied").find("i").attr("class","bi bi-check2"),setTimeout(function(){o.removeClass("ge-copied").find("i").attr("class","bi bi-copy")},1200)}function d(t){function r(e){return!!document.getElementById(e)||Object.keys(i).some(function(t){return i[t]===e})}var t=u(u.parseHTML(t.trim(),document,!0)).first(),i={};return t.find("[id]").addBack("[id]").each(function(){var t=this.id;if(document.getElementById(t)){var e,n=y.exec(t);if(n)for(;e=a.containerId(n[1]),r(e););else{for(var o=2;r(t+"-"+o);)o++;e=t+"-"+o}i[t]=e,this.id=e}}),Object.keys(i).length&&t.find("*").addBack().each(function(){var o=this;h.forEach(function(t){var e,n=o.getAttribute(t);null===n||"href"===t&&"#"!==n.charAt(0)||(e=n.split(/(\s+)/).map(function(t){return i[t]||("#"===t.charAt(0)&&i[t.slice(1)]?"#"+i[t.slice(1)]:t)}).join(""))!==n&&o.setAttribute(t,e)})}),t}function e(){var e=v();a.canvas.find(".ge-paste").each(function(){u(this).toggle(c(e,u(this).attr("data-ge-paste").split(" ")))}),a.toolbarItems("clipboard").each(function(){var t=r[parseInt(u(this).attr("data-ge-item"),10)];u(this).toggle(c(e,[t.kind]))}),n=e}var r=[{kind:"row",labelKey:"clipboard.paste_row"},{kind:"section",labelKey:"clipboard.paste_section"}].map(function(t){return u.extend(t,{iconClass:"bi bi-clipboard-plus",source:"paste",create:function(){return d(n.html)}})});return{drawerTools:function(t,r,e){l(e)&&a.createTool(t,a.t("tool.copy"),"ge-copy","bi bi-copy",function(){s(r,e)});var i=m[e];i&&(a.createTool(t,a.t("tool.paste"),"ge-paste","bi bi-clipboard-plus",function(){var t,e,n,o;t=r,e=i,c(o=v(),e)&&(e=d(o.html),n=t,"element"===o.category&&(t=t.children(".ge-content").last()).length&&(n=t),a.place(e,o.kind,{appendTo:n,source:"paste"}))}),t.children(".ge-paste").last().attr("data-ge-paste",i.join(" ")).toggle(c(v(),i)))},toolbar:r,onInit:function(){e(),u(document).off(f+t).on(f+t,e)},onDeinit:function(){u(document).off(f+t)}}}})(jQuery);
|
|
2
|
+
//# sourceMappingURL=grideditor.clipboard.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grideditor.clipboard.min.js","sources":["../../src/js/plugins/grideditor.clipboard.js"],"names":["$","extend","fn","gridEditor","locales","en","tool.copy","tool.paste","clipboard.paste_row","clipboard.paste_section","STORAGE_ITEM","CHANGE","VERSION","memory","editors","TARGETS","column","row","section","REFERENCES","GENERATED_ID","read","raw","window","localStorage","getItem","error","clip","JSON","parse","version","html","on","e","originalEvent","key","document","trigger","features","clipboard","ge","namespace","shown","used","name","settings","plugins","indexOf","fits","categories","category","containers","kind","sections","elements","categoryOf","copy","node","nodeHtml","setItem","stringify","emit","payloadFor","source","tool","children","find","addClass","attr","setTimeout","removeClass","fresh","taken","id","getElementById","Object","keys","renamed","some","old","parseHTML","trim","first","addBack","each","this","next","generated","exec","containerId","n","length","element","forEach","rewritten","value","getAttribute","charAt","split","map","token","slice","join","setAttribute","refresh","canvas","toggle","toolbarItems","item","TOOLBAR","parseInt","labelKey","iconClass","create","drawerTools","drawer","createTool","t","target","into","area","last","place","appendTo","toolbar","on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SAAU4B,EAAOC,GAG9BhF,EAAGkF,MAAMjE,EAAM9B,EAAKyB,KAAM,CAAEuE,SAAUJ,EAAMxD,OAAQ,OAAQ,CAAC,EAuGzD,CAAC,EACDoD,EAAOlD,SAAS,WAAW,EAAEwD,KAAK,EAC7BrD,KAAK,gBAAiBnB,EAAWqD,KAAK,GAAG,CAAC,EAC1CI,OAAO1D,EAAK3B,EAAK,EAAG4B,CAAU,CAAC,EACxC,EAEA2E,QAASf,EAETgB,OAAQ,WACJrB,EAAQ,EACRxG,EAAEoC,QAAQ,EAAE0F,IAAInH,EAAS8B,CAAS,EAAET,GAAGrB,EAAS8B,EAAW+D,CAAO,CACtE,EAEAuB,SAAU,WACN/H,EAAEoC,QAAQ,EAAE0F,IAAInH,EAAS8B,CAAS,CACtC,CACJ,CACJ,CAEC,GAAEuF,MAAM"}
|
|
@@ -124,15 +124,15 @@ $.fn.gridEditor.features.sections = function(ge) {
|
|
|
124
124
|
ge.createMoveTool(drawer);
|
|
125
125
|
ge.addSettingsTool(drawer, section, ge.settings.section_classes || []).append(widthField(section));
|
|
126
126
|
|
|
127
|
-
ge.createTool(drawer, ge.t('tool.add_row_to_section'), 'ge-add-row', 'bi bi-plus-circle', function() {
|
|
128
|
-
ge.place(ge.rowFromLayout([12]), 'row', { appendTo: section });
|
|
129
|
-
});
|
|
130
|
-
|
|
131
127
|
ge.createTool(drawer, ge.t('tool.delete_section'), 'ge-delete-section', 'bi bi-trash', function() {
|
|
132
128
|
ge.deleteNode('section', section, ge.t('confirm.delete_section'), function(removed) {
|
|
133
129
|
section.slideUp(removed);
|
|
134
130
|
});
|
|
135
131
|
});
|
|
132
|
+
|
|
133
|
+
ge.createTool(drawer, ge.t('tool.add_row_to_section'), 'ge-add-row', 'bi bi-plus-circle', function() {
|
|
134
|
+
ge.place(ge.rowFromLayout([12]), 'row', { appendTo: section });
|
|
135
|
+
});
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
function mark() {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(c=>{c.extend(c.fn.gridEditor.locales.en,{"section.add":"Section","section.width":"Width","section.fixed":"Fixed","section.fluid":"Full width","section.from":"Fixed from {breakpoint}","tool.add_row_to_section":"Add row","tool.delete_section":"Remove section","confirm.delete_section":"Delete this section and everything in it?"});var r={fixed:"container",fluid:"container-fluid",sm:"container-sm",md:"container-md",lg:"container-lg",xl:"container-xl",xxl:"container-xxl"},l=["fixed","sm","md","lg","xl","xxl","fluid"];c.fn.gridEditor.features.sections=function(s){var o=c.extend({widths:l},s.settings.sections);function a(n){var i=null;return c.each(r,function(e,t){!i&&n.hasClass(t)&&(i=e)}),i}function e(){return s.canvas.children().filter(function(){return(e=c(this)).parent()[0]===s.canvas[0]&&null!==a(e);var e})}function n(e){var t=c("<select />"),n=a(e),i=-1===o.widths.indexOf(n)?o.widths.concat([n]):o.widths;return l.forEach(function(e){-1!==i.indexOf(e)&&c("<option />").attr("value",e).text("fixed"===(e=e)?s.t("section.fixed"):"fluid"===e?s.t("section.fluid"):s.t("section.from",{breakpoint:e})).appendTo(t)}),t.val(n).on("change",function(){var t,n,i,o;t=e,n=this.value,i="panel",(o=a(t))!==n&&r[n]&&s.operate(function(){var e=s.payloadFor("section",t,{family:"section",breakpoint:"all",tiers:[],from:o,to:n,source:i||"api"});return s.emit("before-utility",e)?(t.removeClass(r[o]).addClass(r[n]),s.emit("after-utility",e),!0):(t.find("> .ge-tools-drawer .ge-section-width select").val(o),!1)})}),c('<label class="ge-utility ge-section-width" />').append(c('<span class="ge-utility-label" />').text(s.t("section.width"))).append(t)}function t(e){e=e||{};var t=c("<div />").addClass(r[e.width]||r.fixed);return(e.rows||[[12]]).forEach(function(e){s.rowFromLayout(e).appendTo(t)}),s.place(t,"section",e)}return{methods:{createSection:t},kindOf:function(e){return e.hasClass("ge-section")?"section":null},blocks:".ge-section",regions:".ge-section",accepts:function(e,t){var n;return t.hasClass("ge-section")||!(n=t).parent().length&&null!==a(n)?e[0]===s.canvas[0]:!e.hasClass("ge-section")||t.hasClass("row")},toolbar:[{labelKey:"section.add",kind:"section",create:function(){return t()}}],onInit:function(){e().each(function(){var t,e=c(this).addClass("ge-section");e.children(".ge-tools-drawer").length||(t=e,e=c('<div class="ge-tools-drawer ge-section-drawer" />').prependTo(t),s.createMoveTool(e),s.addSettingsTool(e,t,s.settings.section_classes||[]).append(n(t)),s.createTool(e,s.t("tool.
|
|
1
|
+
(c=>{c.extend(c.fn.gridEditor.locales.en,{"section.add":"Section","section.width":"Width","section.fixed":"Fixed","section.fluid":"Full width","section.from":"Fixed from {breakpoint}","tool.add_row_to_section":"Add row","tool.delete_section":"Remove section","confirm.delete_section":"Delete this section and everything in it?"});var r={fixed:"container",fluid:"container-fluid",sm:"container-sm",md:"container-md",lg:"container-lg",xl:"container-xl",xxl:"container-xxl"},l=["fixed","sm","md","lg","xl","xxl","fluid"];c.fn.gridEditor.features.sections=function(s){var o=c.extend({widths:l},s.settings.sections);function a(n){var i=null;return c.each(r,function(e,t){!i&&n.hasClass(t)&&(i=e)}),i}function e(){return s.canvas.children().filter(function(){return(e=c(this)).parent()[0]===s.canvas[0]&&null!==a(e);var e})}function n(e){var t=c("<select />"),n=a(e),i=-1===o.widths.indexOf(n)?o.widths.concat([n]):o.widths;return l.forEach(function(e){-1!==i.indexOf(e)&&c("<option />").attr("value",e).text("fixed"===(e=e)?s.t("section.fixed"):"fluid"===e?s.t("section.fluid"):s.t("section.from",{breakpoint:e})).appendTo(t)}),t.val(n).on("change",function(){var t,n,i,o;t=e,n=this.value,i="panel",(o=a(t))!==n&&r[n]&&s.operate(function(){var e=s.payloadFor("section",t,{family:"section",breakpoint:"all",tiers:[],from:o,to:n,source:i||"api"});return s.emit("before-utility",e)?(t.removeClass(r[o]).addClass(r[n]),s.emit("after-utility",e),!0):(t.find("> .ge-tools-drawer .ge-section-width select").val(o),!1)})}),c('<label class="ge-utility ge-section-width" />').append(c('<span class="ge-utility-label" />').text(s.t("section.width"))).append(t)}function t(e){e=e||{};var t=c("<div />").addClass(r[e.width]||r.fixed);return(e.rows||[[12]]).forEach(function(e){s.rowFromLayout(e).appendTo(t)}),s.place(t,"section",e)}return{methods:{createSection:t},kindOf:function(e){return e.hasClass("ge-section")?"section":null},blocks:".ge-section",regions:".ge-section",accepts:function(e,t){var n;return t.hasClass("ge-section")||!(n=t).parent().length&&null!==a(n)?e[0]===s.canvas[0]:!e.hasClass("ge-section")||t.hasClass("row")},toolbar:[{labelKey:"section.add",kind:"section",create:function(){return t()}}],onInit:function(){e().each(function(){var t,e=c(this).addClass("ge-section");e.children(".ge-tools-drawer").length||(t=e,e=c('<div class="ge-tools-drawer ge-section-drawer" />').prependTo(t),s.createMoveTool(e),s.addSettingsTool(e,t,s.settings.section_classes||[]).append(n(t)),s.createTool(e,s.t("tool.delete_section"),"ge-delete-section","bi bi-trash",function(){s.deleteNode("section",t,s.t("confirm.delete_section"),function(e){t.slideUp(e)})}),s.createTool(e,s.t("tool.add_row_to_section"),"ge-add-row","bi bi-plus-circle",function(){s.place(s.rowFromLayout([12]),"row",{appendTo:t})}))})},onDeinit:function(){s.canvas.children(".ge-section").removeClass("ge-section")}}}})(jQuery);
|
|
2
2
|
//# sourceMappingURL=grideditor.sections.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grideditor.sections.min.js","sources":["../../src/js/plugins/grideditor.sections.js"],"names":["$","extend","fn","gridEditor","locales","en","section.add","section.width","section.fixed","section.fluid","section.from","tool.add_row_to_section","tool.delete_section","confirm.delete_section","WIDTHS","fixed","fluid","sm","md","lg","xl","xxl","ORDER","features","sections","ge","options","widths","settings","widthOf","section","found","each","width","className","hasClass","canvas","children","filter","node","this","parent","widthField","select","current","offered","indexOf","concat","forEach","attr","text","t","breakpoint","appendTo","val","on","source","from","value","operate","payload","payloadFor","family","tiers","to","emit","removeClass","addClass","find","append","createSection","rows","layout","rowFromLayout","place","methods","kindOf","blocks","regions","accepts","region","length","toolbar","labelKey","kind","create","onInit","drawer","prependTo","createMoveTool","addSettingsTool","section_classes","createTool","deleteNode","removed","slideUp","onDeinit","jQuery"],"mappings":"CAkBUA,IAEVA,EAAEC,OAAOD,EAAEE,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,cAAe,UACfC,gBAAiB,QACjBC,gBAAiB,QACjBC,gBAAiB,aACjBC,eAAgB,0BAChBC,0BAA2B,UAC3BC,sBAAuB,iBACvBC,yBAA0B,2CAC9B,CAAC,EAGD,IAAIC,EAAS,CACTC,MAAO,YACPC,MAAO,kBACPC,GAAI,eACJC,GAAI,eACJC,GAAI,eACJC,GAAI,eACJC,IAAK,eACT,EAEIC,EAAQ,CAAC,QAAS,KAAM,KAAM,KAAM,KAAM,MAAO,SAErDtB,EAAEE,GAAGC,WAAWoB,SAASC,SAAW,SAASC,GAEzC,IAAIC,EAAU1B,EAAEC,OAAO,CAAE0B,OAAQL,CAAM,EAAGG,EAAGG,SAASJ,QAAQ,EAE9D,SAASK,EAAQC,GACb,IAAIC,EAAQ,KAMZ,OAJA/B,EAAEgC,KAAKlB,EAAQ,SAASmB,EAAOC,GACvB,CAACH,GAASD,EAAQK,SAASD,CAAS,IAAKH,EAAQE,EACzD,CAAC,EAEMF,CACX,CAMA,SAASP,IACL,OAAOC,EAAGW,OAAOC,SAAS,EAAEC,OAAO,WAAa,OALjCC,EAKkDvC,EAAEwC,IAAI,GAJ3DC,OAAO,EAAE,KAAOhB,EAAGW,OAAO,IAAwB,OAAlBP,EAAQU,CAAI,EAD5D,IAAmBA,CAK4D,CAAC,CAChF,CAuCA,SAASG,EAAWZ,GAChB,IAAIa,EAAS3C,EAAE,YAAY,EACvB4C,EAAUf,EAAQC,CAAO,EACzBe,EAA8C,CAAC,IAArCnB,EAAQC,OAAOmB,QAAQF,CAAO,EAAWlB,EAAQC,OAAOoB,OAAO,CAACH,EAAQ,EAAIlB,EAAQC,OASlG,OAPAL,EAAM0B,QAAQ,SAASf,GACY,CAAC,IAA5BY,EAAQC,QAAQb,CAAK,GACzBjC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M,EAAEnB,SAASvB,CAAO,CAC7C,CAAC,EAEML,EAAGiD,MAAM5C,EAAS,UAAWF,CAAQ,CAChD,CAEA,MAAO,CACH+C,QAAS,CACLL,cAAeA,CACnB,EAEAM,OAAQ,SAASrC,GACb,OAAOA,EAAKJ,SAAS,YAAY,EAAI,UAAY,IACrD,EAGA0C,OAAQ,cACRC,QAAS,cAGTC,QAAS,SAASC,EAAQzC,GACtB,IAiBeA,EAjBf,OAAIA,EAAKJ,SAAS,YAAY,GAkB3B,EADYI,EAjBkCA,GAkBxCE,OAAO,EAAEwC,QAA4B,OAAlBpD,EAAQU,CAAI,EAlByByC,EAAO,KAAOvD,EAAGW,OAAO,GACrF4C,CAAAA,EAAO7C,SAAS,YAAY,GAAYI,EAAKJ,SAAS,KAAK,CAGnE,EAEA+C,QAAS,CAAC,CACNC,SAAU,cACVC,KAAM,UACNC,OAAQ,WAAa,OAAOf,EAAc,CAAG,CACjD,GAEAgB,OAnDJ,WACI9D,EAAS,EAAEQ,KAAK,WACZ,IAnBgBF,EAmBZA,EAAU9B,EAAEwC,IAAI,EAAE2B,SAAS,YAAY,EACtCrC,EAAQO,SAAS,kBAAkB,EAAE4C,SApB1BnD,EAoBmDA,EAnBnEyD,EAASvF,EAAE,mDAAmD,EAAEwF,UAAU1D,CAAO,EAErFL,EAAGgE,eAAeF,CAAM,EACxB9D,EAAGiE,gBAAgBH,EAAQzD,EAASL,EAAGG,SAAS+D,iBAAmB,EAAE,EAAEtB,OAAO3B,EAAWZ,CAAO,CAAC,EAEjGL,EAAGmE,WAAWL,EAAQ9D,EAAG0B,EAAE,
|
|
1
|
+
{"version":3,"file":"grideditor.sections.min.js","sources":["../../src/js/plugins/grideditor.sections.js"],"names":["$","extend","fn","gridEditor","locales","en","section.add","section.width","section.fixed","section.fluid","section.from","tool.add_row_to_section","tool.delete_section","confirm.delete_section","WIDTHS","fixed","fluid","sm","md","lg","xl","xxl","ORDER","features","sections","ge","options","widths","settings","widthOf","section","found","each","width","className","hasClass","canvas","children","filter","node","this","parent","widthField","select","current","offered","indexOf","concat","forEach","attr","text","t","breakpoint","appendTo","val","on","source","from","value","operate","payload","payloadFor","family","tiers","to","emit","removeClass","addClass","find","append","createSection","rows","layout","rowFromLayout","place","methods","kindOf","blocks","regions","accepts","region","length","toolbar","labelKey","kind","create","onInit","drawer","prependTo","createMoveTool","addSettingsTool","section_classes","createTool","deleteNode","removed","slideUp","onDeinit","jQuery"],"mappings":"CAkBUA,IAEVA,EAAEC,OAAOD,EAAEE,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,cAAe,UACfC,gBAAiB,QACjBC,gBAAiB,QACjBC,gBAAiB,aACjBC,eAAgB,0BAChBC,0BAA2B,UAC3BC,sBAAuB,iBACvBC,yBAA0B,2CAC9B,CAAC,EAGD,IAAIC,EAAS,CACTC,MAAO,YACPC,MAAO,kBACPC,GAAI,eACJC,GAAI,eACJC,GAAI,eACJC,GAAI,eACJC,IAAK,eACT,EAEIC,EAAQ,CAAC,QAAS,KAAM,KAAM,KAAM,KAAM,MAAO,SAErDtB,EAAEE,GAAGC,WAAWoB,SAASC,SAAW,SAASC,GAEzC,IAAIC,EAAU1B,EAAEC,OAAO,CAAE0B,OAAQL,CAAM,EAAGG,EAAGG,SAASJ,QAAQ,EAE9D,SAASK,EAAQC,GACb,IAAIC,EAAQ,KAMZ,OAJA/B,EAAEgC,KAAKlB,EAAQ,SAASmB,EAAOC,GACvB,CAACH,GAASD,EAAQK,SAASD,CAAS,IAAKH,EAAQE,EACzD,CAAC,EAEMF,CACX,CAMA,SAASP,IACL,OAAOC,EAAGW,OAAOC,SAAS,EAAEC,OAAO,WAAa,OALjCC,EAKkDvC,EAAEwC,IAAI,GAJ3DC,OAAO,EAAE,KAAOhB,EAAGW,OAAO,IAAwB,OAAlBP,EAAQU,CAAI,EAD5D,IAAmBA,CAK4D,CAAC,CAChF,CAuCA,SAASG,EAAWZ,GAChB,IAAIa,EAAS3C,EAAE,YAAY,EACvB4C,EAAUf,E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WACnF1B,EAAGoE,WAAW,UAAW/D,EAASL,EAAG0B,EAAE,wBAAwB,EAAG,SAAS2C,GACvEhE,EAAQiE,QAAQD,CAAO,CAC3B,CAAC,CACL,CAAC,EAEDrE,EAAGmE,WAAWL,EAAQ9D,EAAG0B,EAAE,yBAAyB,EAAG,aAAc,oBAAqB,WACtF1B,EAAGiD,MAAMjD,EAAGgD,cAAc,CAAC,GAAG,EAAG,MAAO,CAAEpB,SAAUvB,CAAQ,CAAC,CACjE,CAAC,EAOD,CAAC,CACL,EA+CIkE,SA7CJ,WACIvE,EAAGW,OAAOC,SAAS,aAAa,EAAE6B,YAAY,YAAY,CAC9D,CA4CA,CAMJ,CAEC,GAAE+B,MAAM"}
|
package/docs/events.md
CHANGED
|
@@ -59,6 +59,7 @@ about every insertion can bind `grideditor:before-add` and switch on
|
|
|
59
59
|
| `grideditor:before-utility` | — | yes | before a utility class is written, from the panel, a plugin's tool or `setUtility` |
|
|
60
60
|
| `grideditor:after-utility` | — | no | after the class is written and the preview redrawn, only if something changed |
|
|
61
61
|
| `grideditor:view-change` | — | no | after the view changes, only if it actually changed |
|
|
62
|
+
| `grideditor:after-copy` | — | no | with the clipboard plugin, after a node is copied |
|
|
62
63
|
|
|
63
64
|
Two things here are not in the 3.0 specification's catalogue. The indent pair,
|
|
64
65
|
because the indent tools are an operation like any other and announce
|
|
@@ -122,7 +123,9 @@ screen, and its `source` is `panel`, `tool` or `api`.
|
|
|
122
123
|
|
|
123
124
|
`source` matters to a host that both drives the editor from its own palette and
|
|
124
125
|
listens for what the user does: `api` is your own call coming back to you,
|
|
125
|
-
`tool` is a click in the editor, `dragdrop` is a gesture
|
|
126
|
+
`tool` is a click in the editor, `dragdrop` is a gesture, and `paste` is a node
|
|
127
|
+
the clipboard plugin put in, from a paste tool or the toolbar. A paste is an add
|
|
128
|
+
like any other, so canceling its `before-add-*` turns it away.
|
|
126
129
|
|
|
127
130
|
`kind: 'content'` appears when a content area itself is dragged between
|
|
128
131
|
columns. The kinds for containers are the container's own type, so a listener
|
package/docs/locale-keys.md
CHANGED
|
@@ -100,6 +100,19 @@ The sections plugin: Bootstrap's `.container` and its kin, on the canvas.
|
|
|
100
100
|
| `confirm.delete_section` | Delete this section and everything in it? | Asked before a section is deleted |
|
|
101
101
|
|
|
102
102
|
|
|
103
|
+
clipboard.*
|
|
104
|
+
-----------
|
|
105
|
+
|
|
106
|
+
The clipboard plugin: copy and paste.
|
|
107
|
+
|
|
108
|
+
| Key | English | Where |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| `tool.copy` | Copy | Row, column, section, container and element drawers |
|
|
111
|
+
| `tool.paste` | Paste | Column, row and section drawers, while something that fits there is copied |
|
|
112
|
+
| `clipboard.paste_row` | Paste row | Toolbar button, while a row is copied |
|
|
113
|
+
| `clipboard.paste_section` | Paste section | Toolbar button, while a section is copied |
|
|
114
|
+
|
|
115
|
+
|
|
103
116
|
confirm.*
|
|
104
117
|
---------
|
|
105
118
|
|
package/docs/plugins.md
CHANGED
|
@@ -107,7 +107,7 @@ not change without a major version.
|
|
|
107
107
|
| `ge.createMoveTool(drawer)` | The drag handle, unless `drag_handle` says the whole drawer is one |
|
|
108
108
|
| `ge.addSettingsTool(drawer, node, presets)` | The gear, and the id and class panel it opens |
|
|
109
109
|
| `ge.deleteNode(kind, node, confirmText, animate)` | Remove a node: ask, animate, announce |
|
|
110
|
-
| `ge.place(node, kind, options)` | Put a created node where `appendTo` and friends say, through the add events |
|
|
110
|
+
| `ge.place(node, kind, options)` | Put a created node where `appendTo` and friends say, through the add events. `options.source` is the payload's `source`, `api` by default |
|
|
111
111
|
| `ge.createPaneControls(pane, kind, hostTools, confirmText, remove)` | The drawer a pane gets: move, the host's tools, delete |
|
|
112
112
|
| `ge.makeLabelEditable(label)` | Rename in place, with the Bootstrap toggle suspended while typing |
|
|
113
113
|
| `ge.labelIn(button)` | The label span inside a button, wrapped if it is not already |
|
|
@@ -124,6 +124,8 @@ not change without a major version.
|
|
|
124
124
|
| `ge.setUtility(node, family, value, options?)` | Write one through the events. `options` is a view key or `{ view, source }` |
|
|
125
125
|
| `ge.utilityField(node, family)` | A panel field for one family, for a plugin that builds its own panel |
|
|
126
126
|
| `ge.rowFromLayout(layout)` | A detached row from a layout: `[8, 4]`, `['auto', 'equal']` or `{ row_cols, columns }` |
|
|
127
|
+
| `ge.nodeHtml(node)` | One node's markup as `getHtml` would give it. The canvas leaves editing to read it and comes back, as it does for `getHtml` |
|
|
128
|
+
| `ge.toolbarItems(name)` | The toolbar buttons the feature plugin `name` declared, for showing and hiding them |
|
|
127
129
|
| `ge.bareStyle(node, family, property)` | A css property's value on the node with none of the family's classes: what a preview shows when no class applies and that is not a constant |
|
|
128
130
|
|
|
129
131
|
The add, delete and move events for a container and its panes are fired by the
|
|
@@ -149,6 +151,7 @@ $.fn.gridEditor.features.elements = function(ge) {
|
|
|
149
151
|
regions: '.ge-section', // more lists those blocks move in
|
|
150
152
|
accepts: function(region, node) { … }, // false turns a block away from a region
|
|
151
153
|
toolbar: [{ labelKey: …, kind: …, create: function() { … } }], // buttons beside the containers'
|
|
154
|
+
drawerTools: function(drawer, node, kind) { … }, // tools beside the gear, in every drawer
|
|
152
155
|
};
|
|
153
156
|
};
|
|
154
157
|
```
|
|
@@ -168,6 +171,12 @@ needs to put a new kind of block on the canvas:
|
|
|
168
171
|
was dropped, or, when that region will not have it, on the canvas just after
|
|
169
172
|
the block it was dropped in.
|
|
170
173
|
|
|
174
|
+
- **`drawerTools(drawer, node, kind)`** runs for every drawer that has a gear,
|
|
175
|
+
as a utility plugin's does, so a tool can go on any node. The clipboard
|
|
176
|
+
plugin puts its copy and paste tools in with it.
|
|
177
|
+
- A **`toolbar`** item can also have an `iconClass`, `bi bi-plus` otherwise,
|
|
178
|
+
and a `source` for the add events, `tool` or `dragdrop` otherwise.
|
|
179
|
+
|
|
171
180
|
- **`onSortable(sortable)`** is handed the function the editor makes all of its
|
|
172
181
|
own lists with. A plugin describes a list; it never touches the drag toolkit
|
|
173
182
|
itself, which is what keeps `drag_handle`, the cancel selector and the move
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
5
|
+
|
|
6
|
+
<!-- CSS dependencies -->
|
|
7
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
|
8
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.13.1/font/bootstrap-icons.css">
|
|
9
|
+
|
|
10
|
+
<!-- Javascript dependencies -->
|
|
11
|
+
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
|
|
12
|
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
|
|
13
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/6.8.6/tinymce.min.js"></script>
|
|
14
|
+
|
|
15
|
+
<!-- Grid editor CSS -->
|
|
16
|
+
<link rel="stylesheet" type="text/css" href="../dist/grideditor.css" />
|
|
17
|
+
<!-- Grid editor javascript -->
|
|
18
|
+
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.6/Sortable.min.js"></script>
|
|
19
|
+
<script src="../dist/jquery.grideditor.min.js"></script>
|
|
20
|
+
<!-- Copy and paste is a plugin of its own. The others are here so there
|
|
21
|
+
is a bit of everything to copy. -->
|
|
22
|
+
<script src="../dist/plugins/grideditor.clipboard.min.js"></script>
|
|
23
|
+
<script src="../dist/plugins/grideditor.sections.min.js"></script>
|
|
24
|
+
<script src="../dist/plugins/grideditor.tabs.min.js"></script>
|
|
25
|
+
<script src="../dist/plugins/grideditor.accordion.min.js"></script>
|
|
26
|
+
<script src="../dist/plugins/grideditor.elements.min.js"></script>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
$(function() {
|
|
30
|
+
var settings = {
|
|
31
|
+
new_row_layouts: [[12], [6, 6], [4, 4, 4]],
|
|
32
|
+
content_types: ['tinymce'],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
$('#myGrid').gridEditor(settings);
|
|
36
|
+
$('#otherGrid').gridEditor(settings);
|
|
37
|
+
|
|
38
|
+
// A paste is an add like any other, with source 'paste'
|
|
39
|
+
$('#myGrid, #otherGrid').on('grideditor:after-add', function(e, payload) {
|
|
40
|
+
if (payload.source === 'paste') {
|
|
41
|
+
$('#log').text('Pasted a ' + payload.kind + ' into ' + e.currentTarget.id);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<title>Grid Editor example - copy and paste</title>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<!-- Back to the demo index -->
|
|
51
|
+
<div class="container pt-3">
|
|
52
|
+
<a class="link-secondary" href="index.html"><i class="bi bi-arrow-left"></i> All demos</a>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div class="container py-3">
|
|
56
|
+
<h2>Copy and paste</h2>
|
|
57
|
+
<p class="text-body-secondary">
|
|
58
|
+
Every row, column, section, container and element has a
|
|
59
|
+
<i class="bi bi-copy"></i> copy tool in its drawer. Once something
|
|
60
|
+
is copied, a <i class="bi bi-clipboard-plus"></i> paste tool shows
|
|
61
|
+
wherever it can go: a row into a column or a section, a column into
|
|
62
|
+
a row, a container or an element into a column. Rows and sections
|
|
63
|
+
also get a <em>Paste</em> button in the toolbar, which can be
|
|
64
|
+
clicked or dragged to where the copy should land.
|
|
65
|
+
</p>
|
|
66
|
+
<p class="text-body-secondary">
|
|
67
|
+
What is copied is kept in the browser, so it can be pasted in the
|
|
68
|
+
other editor, after a reload, or in this page open in another tab.
|
|
69
|
+
<span id="log" class="fw-semibold"></span>
|
|
70
|
+
</p>
|
|
71
|
+
|
|
72
|
+
<h5 class="mt-4">One editor</h5>
|
|
73
|
+
<div id="myGrid">
|
|
74
|
+
<div class="row" id="intro">
|
|
75
|
+
<div class="col-lg-6">
|
|
76
|
+
<h3>Copy this row</h3>
|
|
77
|
+
<p>Then paste it into a column below, or into the other editor. Its id is renamed in the copy, so <a href="#intro">links to it</a> keep working.</p>
|
|
78
|
+
</div>
|
|
79
|
+
<div class="col-lg-6">
|
|
80
|
+
<blockquote data-ge-element="quote">An element: copy it into another column.</blockquote>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="row">
|
|
84
|
+
<div class="col-lg-4"><p>A column to paste into.</p></div>
|
|
85
|
+
<div class="col-lg-4"><p>Another one.</p></div>
|
|
86
|
+
<div class="col-lg-4"><p>And a third.</p></div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<h5 class="mt-4">Another editor</h5>
|
|
91
|
+
<div id="otherGrid">
|
|
92
|
+
<div class="row">
|
|
93
|
+
<div class="col-lg-12"><p>Paste here what you copied above.</p></div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
</body>
|
|
99
|
+
</html>
|
package/example/index.html
CHANGED
|
@@ -125,6 +125,14 @@
|
|
|
125
125
|
<span class="text-body-secondary">The same, with summernote</span>
|
|
126
126
|
</a>
|
|
127
127
|
|
|
128
|
+
<a class="list-group-item list-group-item-action" href="clipboard.html">
|
|
129
|
+
<div class="d-flex justify-content-between">
|
|
130
|
+
<strong>Copy and paste</strong>
|
|
131
|
+
<code class="text-body-secondary">clipboard.html</code>
|
|
132
|
+
</div>
|
|
133
|
+
<span class="text-body-secondary">Copying a row, a column or a container and pasting it somewhere else, in this editor or another</span>
|
|
134
|
+
</a>
|
|
135
|
+
|
|
128
136
|
<a class="list-group-item list-group-item-action" href="wrap_content.html">
|
|
129
137
|
<div class="d-flex justify-content-between">
|
|
130
138
|
<strong>Wrapped content</strong>
|