@themarioga/grid-editor 5.3.0 → 6.0.0-beta.1
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/BUILDING.md +2 -4
- package/CHANGELOG.md +38 -0
- package/README.md +21 -8
- package/UPGRADING.md +57 -12
- package/dist/grideditor.css +46 -1
- 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 +104 -416
- package/dist/jquery.grideditor.min.js +1 -1
- package/dist/jquery.grideditor.min.js.map +1 -1
- package/dist/plugins/grideditor.ckeditor.js +2 -1
- package/dist/plugins/grideditor.ckeditor.min.js.map +1 -1
- package/dist/plugins/grideditor.clipboard.js +1 -11
- package/dist/plugins/grideditor.clipboard.min.js +1 -1
- package/dist/plugins/grideditor.clipboard.min.js.map +1 -1
- package/dist/plugins/grideditor.elements.js +66 -38
- package/dist/plugins/grideditor.elements.min.js +1 -1
- package/dist/plugins/grideditor.elements.min.js.map +1 -1
- package/dist/plugins/grideditor.summernote.js +2 -1
- package/dist/plugins/grideditor.summernote.min.js.map +1 -1
- package/dist/plugins/grideditor.tinymce.js +2 -1
- package/dist/plugins/grideditor.tinymce.min.js.map +1 -1
- package/docs/events.md +4 -3
- package/docs/plugins.md +16 -19
- package/example/attributes.html +21 -37
- package/example/elements.html +25 -20
- package/example/plugins.html +5 -5
- package/example/utilities.html +1 -1
- package/package.json +1 -1
- package/src/js/jquery.grideditor.js +103 -18
- package/src/js/plugins/grideditor.ckeditor.js +2 -1
- package/src/js/plugins/grideditor.clipboard.js +1 -11
- package/src/js/plugins/grideditor.elements.js +66 -38
- package/src/js/plugins/grideditor.summernote.js +2 -1
- package/src/js/plugins/grideditor.tinymce.js +2 -1
- package/src/less/grideditor.less +54 -1
- package/src/js/compat/bundled-texts.js +0 -14
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
* Element level controls for grid-editor.
|
|
3
3
|
*
|
|
4
4
|
* A feature plugin: load this file after the editor and the nodes a host
|
|
5
|
-
* marked
|
|
6
|
-
*
|
|
7
|
-
* factory is called with, described in docs/plugins.md.
|
|
5
|
+
* marked become elements - one movable, deletable block each, in the column
|
|
6
|
+
* beside the texts, instead of rich text. What it can ask the editor for is
|
|
7
|
+
* the handle its factory is called with, described in docs/plugins.md.
|
|
8
8
|
*
|
|
9
9
|
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
10
10
|
* <script src="dist/plugins/grideditor.elements.min.js"></script>
|
|
11
|
+
*
|
|
12
|
+
* Up to 5.x an element lived inside a content area, among the text. Markup
|
|
13
|
+
* saved that way still loads: the editor takes each element out of the text
|
|
14
|
+
* it sits in, which is what `cuts` is for.
|
|
11
15
|
*/
|
|
12
16
|
(function($) {
|
|
13
17
|
|
|
@@ -17,37 +21,41 @@ $.extend($.fn.gridEditor.locales.en, {
|
|
|
17
21
|
'confirm.delete_element': 'Delete element?',
|
|
18
22
|
});
|
|
19
23
|
|
|
24
|
+
/** A column's children that are something else than an element, whatever elements.auto says. */
|
|
25
|
+
var NOT_ELEMENTS = '.row, .ge-content, .ge-text-block, [data-ge-container], .ge-tools-drawer, .ge-resize-handle';
|
|
26
|
+
|
|
20
27
|
$.fn.gridEditor.features.elements = function(ge) {
|
|
21
28
|
|
|
29
|
+
var warnedIntoText = false;
|
|
30
|
+
|
|
22
31
|
function elementsEnabled() {
|
|
23
32
|
if (ge.settings.elements.enabled !== 'auto') { return !!ge.settings.elements.enabled; }
|
|
24
33
|
|
|
25
34
|
return ge.settings.elements.auto || ge.canvas.find(ge.settings.elements.selector).length > 0;
|
|
26
35
|
}
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
/** Whether a child of a column is an element. */
|
|
38
|
+
function isElement(node) {
|
|
29
39
|
return ge.settings.elements.auto
|
|
30
|
-
?
|
|
31
|
-
:
|
|
40
|
+
? !node.is(NOT_ELEMENTS)
|
|
41
|
+
: node.is(ge.settings.elements.selector);
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
function markElements() {
|
|
35
45
|
if (!elementsEnabled()) { return; }
|
|
36
46
|
|
|
37
|
-
ge.canvas.find('.
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
ge.canvas.find('.column').children().each(function() {
|
|
48
|
+
var element = $(this);
|
|
49
|
+
if (!element.hasClass('ge-element') && !isElement(element)) { return; }
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
createElementControls(element);
|
|
44
|
-
});
|
|
51
|
+
element.addClass('ge-element');
|
|
52
|
+
if (!element.find('> .ge-tools-drawer').length) { createElementControls(element); }
|
|
45
53
|
});
|
|
46
54
|
}
|
|
47
55
|
|
|
48
56
|
function unmarkElements() {
|
|
49
57
|
ge.canvas.find('.ge-element').each(function() {
|
|
50
|
-
var element = $(this).removeClass('ge-element')
|
|
58
|
+
var element = $(this).removeClass('ge-element');
|
|
51
59
|
|
|
52
60
|
// A host element that had no class of its own should not come
|
|
53
61
|
// back from getHtml carrying an empty one
|
|
@@ -56,16 +64,7 @@ $.fn.gridEditor.features.elements = function(ge) {
|
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
function createElementControls(element) {
|
|
59
|
-
|
|
60
|
-
// editor's furniture rather than content: it leaves the subtree
|
|
61
|
-
// alone and keeps it out of what it serializes. Without it the
|
|
62
|
-
// drawer's tools are inline elements with no text, which is
|
|
63
|
-
// exactly what its cleanup removes, so an element inside an open
|
|
64
|
-
// editor would lose its move and delete tools.
|
|
65
|
-
var drawer = $('<div class="ge-tools-drawer ge-element-drawer" />')
|
|
66
|
-
.attr('data-mce-bogus', 'all')
|
|
67
|
-
.prependTo(element)
|
|
68
|
-
;
|
|
67
|
+
var drawer = $('<div class="ge-tools-drawer ge-element-drawer" />').prependTo(element);
|
|
69
68
|
|
|
70
69
|
ge.createMoveTool(drawer);
|
|
71
70
|
ge.createTool(drawer, ge.t('tool.element_info', { name: elementName(element) }),
|
|
@@ -93,6 +92,32 @@ $.fn.gridEditor.features.elements = function(ge) {
|
|
|
93
92
|
return label || type || element[0].tagName.toLowerCase();
|
|
94
93
|
}
|
|
95
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
|
+
function placementBesideText(options) {
|
|
102
|
+
var placed = $.extend({}, options);
|
|
103
|
+
|
|
104
|
+
[['appendTo', 'insertAfter'], ['prependTo', 'insertBefore']].forEach(function(pair) {
|
|
105
|
+
var target = options[pair[0]] !== undefined ? $(options[pair[0]]) : null;
|
|
106
|
+
if (!target || !target.is('.ge-content')) { return; }
|
|
107
|
+
|
|
108
|
+
if (!warnedIntoText) {
|
|
109
|
+
warnedIntoText = true;
|
|
110
|
+
ge.warn('createElement: an element is a block of the column since 6.0, not part of a ' +
|
|
111
|
+
'content area\'s text; it goes beside the content area. Place it in a column instead.');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
delete placed[pair[0]];
|
|
115
|
+
placed[pair[1]] = target.parent('.ge-text-block').length ? target.parent() : target;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return placed;
|
|
119
|
+
}
|
|
120
|
+
|
|
96
121
|
function apiCreateElement(content, options) {
|
|
97
122
|
options = options || {};
|
|
98
123
|
|
|
@@ -104,7 +129,7 @@ $.fn.gridEditor.features.elements = function(ge) {
|
|
|
104
129
|
element.attr('data-ge-label', options.label);
|
|
105
130
|
}
|
|
106
131
|
|
|
107
|
-
return ge.place(element, 'element', options);
|
|
132
|
+
return ge.place(element, 'element', placementBesideText(options));
|
|
108
133
|
}
|
|
109
134
|
|
|
110
135
|
return {
|
|
@@ -117,24 +142,27 @@ $.fn.gridEditor.features.elements = function(ge) {
|
|
|
117
142
|
return node.hasClass('ge-element') ? 'element' : null;
|
|
118
143
|
},
|
|
119
144
|
|
|
120
|
-
onInit: markElements,
|
|
121
|
-
onDeinit: unmarkElements,
|
|
122
|
-
|
|
123
145
|
/**
|
|
124
|
-
* An
|
|
125
|
-
*
|
|
146
|
+
* An element cuts the text it sits in: 5.x's markup, or markup a host
|
|
147
|
+
* wrote the same way, has it inside a content area, and it comes out.
|
|
126
148
|
*/
|
|
127
|
-
|
|
149
|
+
cuts: function() {
|
|
150
|
+
if (!elementsEnabled()) { return null; }
|
|
128
151
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (!elementsEnabled()) { return; }
|
|
152
|
+
return ge.settings.elements.auto ? '*' : ge.settings.elements.selector;
|
|
153
|
+
},
|
|
132
154
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
// A block the columns move, beside the texts, the rows and the
|
|
156
|
+
// containers - and only the columns
|
|
157
|
+
blocks: '.ge-element',
|
|
158
|
+
accepts: function(region, node) {
|
|
159
|
+
if (node.hasClass('ge-element')) { return region.is('.column'); }
|
|
160
|
+
|
|
161
|
+
return true;
|
|
137
162
|
},
|
|
163
|
+
|
|
164
|
+
onInit: markElements,
|
|
165
|
+
onDeinit: unmarkElements,
|
|
138
166
|
};
|
|
139
167
|
};
|
|
140
168
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(
|
|
1
|
+
(s=>{s.extend(s.fn.gridEditor.locales.en,{"tool.delete_element":"Remove element","tool.element_info":"Element: {name}","confirm.delete_element":"Delete element?"}),s.fn.gridEditor.features.elements=function(a){var o=!1;function e(){return"auto"!==a.settings.elements.enabled?a.settings.elements.enabled:a.settings.elements.auto||0<a.canvas.find(a.settings.elements.selector).length}return{methods:{createElement:function(e,t){t=t||{};var n,l,e=s('<div class="ge-element" />').attr("data-ge-element",t.type||"element").append(e);return void 0!==t.label&&e.attr("data-ge-label",t.label),a.place(e,"element",(n=t,l=s.extend({},n),[["appendTo","insertAfter"],["prependTo","insertBefore"]].forEach(function(e){var t=void 0!==n[e[0]]?s(n[e[0]]):null;t&&t.is(".ge-content")&&(o||(o=!0,a.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 l[e[0]],l[e[1]]=t.parent(".ge-text-block").length?t.parent():t)}),l))}},kindOf:function(e){return e.hasClass("ge-element")?"element":null},cuts:function(){return e()?a.settings.elements.auto?"*":a.settings.elements.selector:null},blocks:".ge-element",accepts:function(e,t){return!t.hasClass("ge-element")||e.is(".column")},onInit:function(){e()&&a.canvas.find(".column").children().each(function(){var e,t,n,l=s(this);!l.hasClass("ge-element")&&(e=l,a.settings.elements.auto?e.is(".row, .ge-content, .ge-text-block, [data-ge-container], .ge-tools-drawer, .ge-resize-handle"):!e.is(a.settings.elements.selector))||(l.addClass("ge-element"),l.find("> .ge-tools-drawer").length)||(t=l,n=s('<div class="ge-tools-drawer ge-element-drawer" />').prependTo(t),a.createMoveTool(n),a.createTool(n,a.t("tool.element_info",{name:(e=>{var t=e.attr("data-ge-element"),n=e.attr("data-ge-label");return n&&t?n+" ("+t+")":n||t||e[0].tagName.toLowerCase()})(t)}),"ge-element-info","bi bi-info-circle"),a.addSettingsTool(n,t,a.settings.element_classes),a.settings.element_tools.forEach(function(e){a.createTool(n,e.title||"",e.className||"",e.iconClass||"bi bi-wrench",e.on)}),a.createTool(n,a.t("tool.delete_element"),"ge-delete-element","bi bi-trash",function(){a.deleteNode("element",t,a.t("confirm.delete_element"),function(e){t.animate({opacity:"hide",height:"hide"},300,e)})}))})},onDeinit:function(){a.canvas.find(".ge-element").each(function(){var e=s(this).removeClass("ge-element");e.attr("class")||e.removeAttr("class")})}}}})(jQuery);
|
|
2
2
|
//# sourceMappingURL=grideditor.elements.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grideditor.elements.min.js","sources":["../../src/js/plugins/grideditor.elements.js"],"names":["$","extend","fn","gridEditor","locales","en","tool.delete_element","tool.element_info","confirm.delete_element","features","elements","ge","elementsEnabled","settings","enabled","auto","canvas","find","selector","length","
|
|
1
|
+
{"version":3,"file":"grideditor.elements.min.js","sources":["../../src/js/plugins/grideditor.elements.js"],"names":["$","extend","fn","gridEditor","locales","en","tool.delete_element","tool.element_info","confirm.delete_element","features","elements","ge","warnedIntoText","elementsEnabled","settings","enabled","auto","canvas","find","selector","length","methods","createElement","content","options","placed","element","attr","type","append","undefined","label","place","forEach","pair","target","is","warn","parent","kindOf","node","hasClass","cuts","blocks","accepts","region","onInit","children","each","drawer","this","addClass","prependTo","createMoveTool","createTool","t","name","tagName","toLowerCase","addSettingsTool","element_classes","element_tools","hostTool","title","className","iconClass","on","deleteNode","removed","animate","opacity","height","onDeinit","removeClass","removeAttr","jQuery"],"mappings":"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"}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
11
11
|
* <script src="dist/plugins/grideditor.summernote.min.js"></script>
|
|
12
12
|
*
|
|
13
|
-
* Up to
|
|
13
|
+
* Up to 5.x the main bundle carried a copy of this file; since 6.0 it is
|
|
14
|
+
* loaded on its own, like every plugin.
|
|
14
15
|
*/
|
|
15
16
|
(function($) {
|
|
16
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grideditor.summernote.min.js","sources":["../../src/js/plugins/grideditor.summernote.js"],"names":["$","extend","fn","gridEditor","locales","en","text.summernote","INITIAL_CONTENT","texts","summernote","ge","labelKey","initialContent","missingKey","available","start","contentAreas","settings","now","Date","each","configuration","contentArea","this","hasClass","html","addClass","config","tabsize","airMode","callbacks","onInit","callback","err","call","textReady","stop","filter","removeClass","removeAttr","jQuery"],"mappings":"
|
|
1
|
+
{"version":3,"file":"grideditor.summernote.min.js","sources":["../../src/js/plugins/grideditor.summernote.js"],"names":["$","extend","fn","gridEditor","locales","en","text.summernote","INITIAL_CONTENT","texts","summernote","ge","labelKey","initialContent","missingKey","available","start","contentAreas","settings","now","Date","each","configuration","contentArea","this","hasClass","html","addClass","config","tabsize","airMode","callbacks","onInit","callback","err","call","textReady","stop","filter","removeClass","removeAttr","jQuery"],"mappings":"CAeUA,IAENA,EAAEC,OAAOD,EAAEE,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,kBAAmB,YACvB,CAAC,EAED,IAAIC,EAAkB,6BAEtBP,EAAEE,GAAGC,WAAWK,MAAMC,WAAa,SAASC,GACxC,MAAO,CACHC,SAAU,kBACVC,eAAgBL,EAChBM,WAAY,2BAEZC,UAAW,WAAa,MAAO,CAAC,CAACd,EAAEE,GAAGO,UAAY,EAElDM,MAAO,SAASC,GACZ,IAAIC,EAAWP,EAAGO,SAKbjB,EAAEkB,MAAOlB,EAAEkB,IAAMC,KAAKD,KAE3BF,EAAaI,KAAK,WACd,IAQIC,EARAC,EAActB,EAAEuB,IAAI,EACpBD,EAAYE,SAAS,QAAQ,IAE7BF,EAAYG,KAAK,GAAKlB,GACtBe,EAAYG,KAAK,EAAE,EAEvBH,EAAYI,SAAS,QAAQ,EAEzBL,EAAgBrB,EAAEC,OAClB,CAAA,EACA,GACCgB,EAASR,YAAcQ,EAASR,WAAWkB,OAASV,EAASR,WAAWkB,OAAS,GAClF,CACIC,QAAS,EACTC,QAAS,CAAA,EAETC,UAAW,CACPC,OAAQ,WAGJ,IAAIC,EACJ,IACIA,EAAWf,EAASR,WAAWkB,OAAOG,UAAUC,MAGpD,CAFE,MAAOE,IAGLD,GACAA,EAASE,KAAKX,IAAI,EAMtBb,EAAGyB,UAAUb,CAAW,EAExBA,EAAYb,WAAW,OAAO,CAClC,CACJ,CACJ,CACJ,EACAa,EAAYb,WAAWY,CAAa,EACxC,CAAC,CACL,EAEAe,KAAM,SAASpB,GACXA,EAAaqB,OAAO,SAAS,EAAEjB,KAAK,WAChC,IAAIE,EAActB,EAAEuB,IAAI,EACxBD,EAAYb,WAAW,SAAS,EAChCa,EACKgB,YAAY,QAAQ,EACpBC,WAAW,IAAI,EACfA,WAAW,OAAO,EAClBA,WAAW,YAAY,CAEhC,CAAC,CACL,CACJ,CACJ,CACH,GAAEC,MAAM"}
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
11
11
|
* <script src="dist/plugins/grideditor.tinymce.min.js"></script>
|
|
12
12
|
*
|
|
13
|
-
* Up to
|
|
13
|
+
* Up to 5.x the main bundle carried a copy of this file; since 6.0 it is
|
|
14
|
+
* loaded on its own, like every plugin.
|
|
14
15
|
*/
|
|
15
16
|
(function($) {
|
|
16
17
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grideditor.tinymce.min.js","sources":["../../src/js/plugins/grideditor.tinymce.js"],"names":["$","cleanUp","contentArea","removeClass","removeAttr","extend","fn","gridEditor","locales","en","text.tinymce","INITIAL_CONTENT","texts","tinymce","ge","labelKey","initialContent","missingKey","available","window","start","contentAreas","settings","userConfig","config","each","configuration","this","hasClass","html","addClass","promotion","target","inline","init_instance_callback","editor","data","removeData","remove","textReady","on","requestAnimationFrame","removed","ui","show","focus","call","oninit","selector","init","stop","filter","jQuery"],"mappings":"
|
|
1
|
+
{"version":3,"file":"grideditor.tinymce.min.js","sources":["../../src/js/plugins/grideditor.tinymce.js"],"names":["$","cleanUp","contentArea","removeClass","removeAttr","extend","fn","gridEditor","locales","en","text.tinymce","INITIAL_CONTENT","texts","tinymce","ge","labelKey","initialContent","missingKey","available","window","start","contentAreas","settings","userConfig","config","each","configuration","this","hasClass","html","addClass","promotion","target","inline","init_instance_callback","editor","data","removeData","remove","textReady","on","requestAnimationFrame","removed","ui","show","focus","call","oninit","selector","init","stop","filter","jQuery"],"mappings":"CAeUA,IASN,SAASC,EAAQC,GACbA,EACKC,YAAY,QAAQ,EACpBA,YAAY,eAAe,EAC3BC,WAAW,IAAI,EACfA,WAAW,OAAO,EAClBA,WAAW,YAAY,EACvBA,WAAW,iBAAiB,EAC5BA,WAAW,gBAAgB,CAEpC,CAjBAJ,EAAEK,OAAOL,EAAEM,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,eAAgB,SACpB,CAAC,EAiBD,IAAIC,EAAkB,6BAEtBX,EAAEM,GAAGC,WAAWK,MAAMC,QAAU,SAASC,GACrC,MAAO,CACHC,SAAU,eACVC,eAAgBL,EAChBM,WAAY,wBAEZC,UAAW,WAAa,MAAO,CAAC,CAACC,OAAON,OAAS,EAEjDO,MAAO,SAASC,GACZ,IAAIC,EAAWR,EAAGQ,SACdC,EAAcD,EAAST,SAAWS,EAAST,QAAQW,OAAUF,EAAST,QAAQW,OAAS,GAE3FH,EAAaI,KAAK,WACd,IAQIC,EARAxB,EAAcF,EAAE2B,IAAI,EACpBzB,EAAY0B,SAAS,QAAQ,IAE7B1B,EAAY2B,KAAK,GAAKlB,GACtBT,EAAY2B,KAAK,EAAE,EAEvB3B,EAAY4B,SAAS,QAAQ,EAgF7B,OA9EIJ,EAAgB1B,EAAEK,OAAO,CAKzB0B,UAAW,CAAA,CACf,EAAGR,EAAY,CACXS,OAAQL,KACRM,OAAQ,CAAA,EACRC,uBAAwB,SAASC,GAEzBjC,EAAYkC,KAAK,2BAA2B,GAC5ClC,EAAYmC,WAAW,2BAA2B,EAClDF,EAAOG,OAAO,EAGdrC,EAAQC,CAAW,IAIvBA,EAAYkC,KAAK,aAAcD,CAAM,EAMrCrB,EAAGyB,UAAUrC,CAAW,EAMxBiC,EAAOK,GAAG,YAAa,WACnB1B,EAAGyB,UAAUrC,CAAW,CAC5B,CAAC,EAUDiB,OAAOsB,sBAAsB,WACrBN,CAAAA,EAAOO,SAAYP,EAAOQ,IAAOR,EAAOQ,GAAGC,MAE/CT,EAAOQ,GAAGC,KAAK,CACnB,CAAC,EAODT,EAAOK,GAAG,QAAS,WACfrB,OAAOsB,sBAAsB,WACrBN,CAAAA,EAAOO,SAAYP,EAAOQ,IAAOR,EAAOQ,GAAGC,MAE/CT,EAAOQ,GAAGC,KAAK,CACnB,CAAC,CACL,CAAC,EAGDT,EAAOU,MAAM,EAGTtB,EAAWW,wBACXX,EAAWW,uBAAuBY,KAAKnB,KAAMQ,CAAM,EAGnDZ,EAAWwB,QACXxB,EAAWwB,OAAOD,KAAKnB,KAAMQ,CAAM,EAE3C,CACJ,CAAC,GAGoBa,SAErB7B,OAAON,QAAQoC,KAAKvB,CAAa,EACrC,CAAC,CACL,EAEAwB,KAAM,SAAS7B,GACXA,EAAa8B,OAAO,SAAS,EAAE1B,KAAK,WAChC,IAAIvB,EAAcF,EAAE2B,IAAI,EACpBQ,EAASjC,EAAYkC,KAAK,YAAY,EAEtCD,GACAjC,EAAYmC,WAAW,YAAY,EACnCF,EAAOG,OAAO,GAIdpC,EAAYkC,KAAK,4BAA6B,CAAA,CAAI,EAGtDnC,EAAQC,CAAW,CACvB,CAAC,CACL,CACJ,CACJ,CACH,GAAEkD,MAAM"}
|
package/docs/events.md
CHANGED
|
@@ -130,9 +130,10 @@ the clipboard plugin put in, from a paste tool or the toolbar. A paste is an add
|
|
|
130
130
|
like any other, so canceling its `before-add-*` turns it away.
|
|
131
131
|
|
|
132
132
|
A text block is `kind: 'text'`, with its content area as the node, when it is
|
|
133
|
-
added or
|
|
134
|
-
`kind: 'content'
|
|
135
|
-
can tell a tabs container from an
|
|
133
|
+
added, deleted or moved, and in `drawerTools`. Up to 5.x a content area
|
|
134
|
+
dragged between columns was `kind: 'content'`. The kinds for containers are
|
|
135
|
+
the container's own type, so a listener can tell a tabs container from an
|
|
136
|
+
accordion without reading the markup.
|
|
136
137
|
|
|
137
138
|
|
|
138
139
|
Canceling, and what it can honestly do
|
package/docs/plugins.md
CHANGED
|
@@ -149,7 +149,8 @@ $.fn.gridEditor.features.elements = function(ge) {
|
|
|
149
149
|
kindOf: function(node) { … }, // what an event calls this node
|
|
150
150
|
onInit: function() { … }, // every init: put the furniture in
|
|
151
151
|
onDeinit: function() { … }, // every deinit: take it out again
|
|
152
|
-
onContentReady: function(area) { … }, // a rich text editor just took over
|
|
152
|
+
onContentReady: function(area) { … }, // a rich text editor just took over, or rewrote a text
|
|
153
|
+
cuts: '[data-my-block]', // what cuts a text: a block of the column, never part of a text
|
|
153
154
|
onSortable: function(sortable) { … }, // declare your own sortable lists
|
|
154
155
|
blocks: '.ge-section', // more blocks the canvas and the columns move
|
|
155
156
|
regions: '.ge-section', // more lists those blocks move in
|
|
@@ -167,6 +168,12 @@ needs to put a new kind of block on the canvas:
|
|
|
167
168
|
rows, content areas and containers, the editor's own blocks.
|
|
168
169
|
- **`regions`** is a selector for more lists those blocks move in, in the same
|
|
169
170
|
group, so a row dragged from the canvas can land in one.
|
|
171
|
+
- **`cuts`** is a selector, or a function returning one, for nodes that are
|
|
172
|
+
never part of a text: blocks of the column. The editor cuts a content area
|
|
173
|
+
at each of its own children that matches - the text before it stays, the
|
|
174
|
+
node goes into the column, the text after goes into a new content area -
|
|
175
|
+
which is how the elements plugin takes 5.x's elements out of their text. Rows
|
|
176
|
+
and containers always cut.
|
|
170
177
|
- **`accepts(region, node)`** can turn a block away from a list: `false` and the
|
|
171
178
|
drag will not drop it there, whoever's block and whoever's list. With none of
|
|
172
179
|
these hooks, every block goes everywhere, as before.
|
|
@@ -194,21 +201,12 @@ animation for rows, columns, containers and elements, kept in a
|
|
|
194
201
|
takes off. `getHtml` keeps every attribute that is not the editor's.
|
|
195
202
|
- **The dialog lives outside the canvas**, appended to `body`, so it is never
|
|
196
203
|
part of the markup.
|
|
197
|
-
- **
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var area = node.closest('.ge-content')[0];
|
|
204
|
-
var editor = window.tinymce && tinymce.get().filter(function(e) { return e.getBody() === area; })[0];
|
|
205
|
-
var apply = function() { node.attr('data-animation', JSON.stringify(value)); };
|
|
206
|
-
|
|
207
|
-
if (editor) { editor.undoManager.transact(apply); } else { apply(); }
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
Rows, columns, sections and containers are outside any content area, and a
|
|
211
|
-
plain `attr()` is all they need.
|
|
204
|
+
- **Nothing else.** A plain `attr()` on any node. An element is never inside a
|
|
205
|
+
text editor since 6.0, and a text's own attributes, given while its editor
|
|
206
|
+
is open, are kept by grid-editor when the editor closes - tinyMCE would put
|
|
207
|
+
back the ones it found when it opened. Up to 5.x an element sat inside the
|
|
208
|
+
text, and an attribute written behind the editor's back was lost to its
|
|
209
|
+
undo.
|
|
212
210
|
|
|
213
211
|
A node's drawer is built again on every `init`, so a tool reads the node
|
|
214
212
|
rather than remembering anything about it.
|
|
@@ -298,9 +296,8 @@ $.fn.gridEditor.texts.mytext = function(ge) {
|
|
|
298
296
|
A text editor is chosen by `content_types`, never by the `plugins` setting: a
|
|
299
297
|
page that names its containers there has named no editor.
|
|
300
298
|
|
|
301
|
-
Up to
|
|
302
|
-
|
|
303
|
-
own file, loaded after, registers itself again and is the one used.
|
|
299
|
+
Up to 5.x the main bundle carried a copy of the three shipped ones; since 6.0
|
|
300
|
+
a page loads the plugin of the editor it uses, as it loads any other.
|
|
304
301
|
|
|
305
302
|
5.x's `$.fn.gridEditor.RTEs.mytext = { init, deinit, initialContent }` still
|
|
306
303
|
works: `init(settings, contentAreas)` and `deinit(settings, contentAreas)` are
|
package/example/attributes.html
CHANGED
|
@@ -69,40 +69,19 @@
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
* text editor
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* Made through tinyMCE's undo manager, it is a step of its
|
|
77
|
-
* own, which undo and redo treat like any other.
|
|
72
|
+
* A plain attr() on any node: an element is never inside a
|
|
73
|
+
* text editor since 6.0, and a text's own attributes, given
|
|
74
|
+
* while its editor is open, are kept by grid-editor when the
|
|
75
|
+
* editor closes.
|
|
78
76
|
*/
|
|
79
77
|
function write(node, value) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
node.attr(ATTRIBUTE, JSON.stringify(value));
|
|
83
|
-
} else {
|
|
84
|
-
node.removeAttr(ATTRIBUTE);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var editor = editorAround(node);
|
|
88
|
-
|
|
89
|
-
if (editor) {
|
|
90
|
-
editor.undoManager.transact(apply);
|
|
78
|
+
if (value) {
|
|
79
|
+
node.attr(ATTRIBUTE, JSON.stringify(value));
|
|
91
80
|
} else {
|
|
92
|
-
|
|
81
|
+
node.removeAttr(ATTRIBUTE);
|
|
93
82
|
}
|
|
94
83
|
}
|
|
95
84
|
|
|
96
|
-
/** The tinyMCE editor open on the content area around node, if there is one. */
|
|
97
|
-
function editorAround(node) {
|
|
98
|
-
var area = node.closest('.ge-content');
|
|
99
|
-
if (!area.length || !window.tinymce) { return null; }
|
|
100
|
-
|
|
101
|
-
return window.tinymce.get().filter(function(editor) {
|
|
102
|
-
return editor.getBody && editor.getBody() === area[0];
|
|
103
|
-
})[0] || null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
85
|
/** Built once, outside the canvas, so it is never part of getHtml. */
|
|
107
86
|
function dialog() {
|
|
108
87
|
if (modal) { return modal; }
|
|
@@ -297,12 +276,13 @@
|
|
|
297
276
|
an animation has its tool highlighted.
|
|
298
277
|
</p>
|
|
299
278
|
<p class="form-text">
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
279
|
+
Open tinyMCE on a text and set an animation on that same
|
|
280
|
+
text, from its drawer, while you are typing: the attribute
|
|
281
|
+
is kept when the editor closes, although tinyMCE puts back
|
|
282
|
+
the attributes it found when it opened. The plugin does
|
|
283
|
+
nothing special for that - a plain <code>attr()</code> -
|
|
284
|
+
and nothing special for the quote either, which is an
|
|
285
|
+
element: a block beside the texts, never inside one.
|
|
306
286
|
</p>
|
|
307
287
|
<p class="form-text">
|
|
308
288
|
<em>Open as a published page</em> puts the plain html in a
|
|
@@ -325,11 +305,15 @@
|
|
|
325
305
|
</div>
|
|
326
306
|
<div class="row">
|
|
327
307
|
<div class="col-lg-6">
|
|
328
|
-
<
|
|
308
|
+
<div class="ge-content" data-ge-content-type="tinymce">
|
|
309
|
+
<p>Ordinary text, edited by tinyMCE.</p>
|
|
310
|
+
</div>
|
|
329
311
|
<blockquote class="blockquote" data-ge-element="quote" data-ge-label="Quote">
|
|
330
|
-
<p>An element: give it an animation
|
|
312
|
+
<p>An element, beside the texts: give it an animation.</p>
|
|
331
313
|
</blockquote>
|
|
332
|
-
<
|
|
314
|
+
<div class="ge-content" data-ge-content-type="tinymce">
|
|
315
|
+
<p>More text, after the element.</p>
|
|
316
|
+
</div>
|
|
333
317
|
</div>
|
|
334
318
|
<div class="col-lg-6">
|
|
335
319
|
<div data-ge-container="card">
|
package/example/elements.html
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
selector: '[data-ge-element]',
|
|
50
50
|
|
|
51
51
|
// Turn this on for a page that configures no rich text
|
|
52
|
-
// editor and injects its own markup: every
|
|
53
|
-
//
|
|
52
|
+
// editor and injects its own markup: every loose node of
|
|
53
|
+
// a column is then an element.
|
|
54
54
|
auto: false,
|
|
55
55
|
},
|
|
56
56
|
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
// own save step. Grid editor needs no feature for this - the
|
|
75
75
|
// element level controls already apply (spec 4.4).
|
|
76
76
|
$('#addTag').on('click', function() {
|
|
77
|
-
var
|
|
77
|
+
var column = $('#myGrid .column').first();
|
|
78
78
|
|
|
79
79
|
$('#myGrid').gridEditor('createElement',
|
|
80
80
|
'<span class="my-app-tag-placeholder">Analytics tag</span>',
|
|
81
|
-
{ type: 'analytics-tag', label: 'Analytics', appendTo:
|
|
81
|
+
{ type: 'analytics-tag', label: 'Analytics', appendTo: column }
|
|
82
82
|
);
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -103,17 +103,20 @@
|
|
|
103
103
|
<div class="col-lg-8">
|
|
104
104
|
<h1 class="h4">Element level controls</h1>
|
|
105
105
|
<p class="form-text">
|
|
106
|
-
An element is a node
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
<code>data-ge-element</code>,
|
|
110
|
-
<code>data-ge-label</code>.
|
|
111
|
-
own: move, an info tool, the
|
|
112
|
-
|
|
106
|
+
An element is a node the editor treats as one movable,
|
|
107
|
+
deletable block instead of as rich text: a block of the
|
|
108
|
+
column, beside its texts, its rows and its containers. The
|
|
109
|
+
host marks them with <code>data-ge-element</code>,
|
|
110
|
+
optionally naming them with <code>data-ge-label</code>.
|
|
111
|
+
Each one gets a drawer of its own: move, an info tool, the
|
|
112
|
+
host's own tools, and delete. They drag within a column and
|
|
113
|
+
between columns.
|
|
113
114
|
</p>
|
|
114
115
|
<p class="form-text">
|
|
115
|
-
Click
|
|
116
|
-
|
|
116
|
+
Click a text to edit it; an element is never part of the
|
|
117
|
+
text an editor edits. Markup that 5.x saved, with elements
|
|
118
|
+
inside a content area's text, still loads: they come out of
|
|
119
|
+
it, into the column.
|
|
117
120
|
</p>
|
|
118
121
|
<button class="btn btn-sm btn-secondary" id="addTag" type="button">Add an analytics tag</button>
|
|
119
122
|
<button class="btn btn-sm btn-secondary" id="output" type="button">Show the html this produces</button>
|
|
@@ -127,22 +130,24 @@
|
|
|
127
130
|
<div class="col-lg-6">
|
|
128
131
|
<div class="ge-content" data-ge-content-type="tinymce">
|
|
129
132
|
<p>Ordinary text, edited in place by tinyMCE.</p>
|
|
133
|
+
</div>
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
<blockquote class="my-app-quote" data-ge-element="quote" data-ge-label="Pull quote">
|
|
136
|
+
<p>An element the host owns and styles.</p>
|
|
137
|
+
</blockquote>
|
|
134
138
|
|
|
139
|
+
<div class="ge-content" data-ge-content-type="tinymce">
|
|
135
140
|
<p>More ordinary text, after the element.</p>
|
|
136
141
|
</div>
|
|
137
142
|
</div>
|
|
138
143
|
<div class="col-lg-6">
|
|
139
144
|
<div class="ge-content" data-ge-content-type="tinymce">
|
|
140
|
-
<p>A second
|
|
145
|
+
<p>A second column. Drag an element's drawer from
|
|
141
146
|
the left column into this one.</p>
|
|
147
|
+
</div>
|
|
142
148
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</div>
|
|
149
|
+
<div data-ge-element="figure" data-ge-label="Figure">
|
|
150
|
+
<p><strong>Figure 1.</strong> Another element, of a different type.</p>
|
|
146
151
|
</div>
|
|
147
152
|
</div>
|
|
148
153
|
</div>
|
package/example/plugins.html
CHANGED
|
@@ -180,12 +180,12 @@
|
|
|
180
180
|
<div class="col-lg-12">
|
|
181
181
|
<div class="ge-content">
|
|
182
182
|
<p>Ordinary text in a content area.</p>
|
|
183
|
-
|
|
184
|
-
<blockquote data-ge-element="quote" data-ge-label="Pull quote">
|
|
185
|
-
<p>A node the host marked: an element when the elements plugin is on,
|
|
186
|
-
ordinary markup when it is off.</p>
|
|
187
|
-
</blockquote>
|
|
188
183
|
</div>
|
|
184
|
+
|
|
185
|
+
<blockquote data-ge-element="quote" data-ge-label="Pull quote">
|
|
186
|
+
<p>A node the host marked: an element when the elements plugin is on,
|
|
187
|
+
ordinary markup - text - when it is off.</p>
|
|
188
|
+
</blockquote>
|
|
189
189
|
</div>
|
|
190
190
|
</div>
|
|
191
191
|
|
package/example/utilities.html
CHANGED
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
<blockquote data-ge-element="quote" data-ge-label="Pull quote" class="float-sm-end ms-sm-3 p-3 border-start border-4">
|
|
155
155
|
A floated element, <code>float-sm-end</code>.
|
|
156
156
|
</blockquote>
|
|
157
|
-
<p>The text
|
|
157
|
+
<p>The text after it flows round the quote from tablet up, and runs under it on phones, where it does not float. Switch between Phone and Tablet in the dropdown to see it move, or choose another float in the element's panel.</p>
|
|
158
158
|
<p>A second paragraph, so there is enough text to flow.</p>
|
|
159
159
|
</div>
|
|
160
160
|
</div>
|