@themarioga/grid-editor 6.0.0-beta.4 → 6.0.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 +31 -0
- package/README.md +60 -6
- package/UPGRADING.md +27 -2
- package/dist/grideditor.css +46 -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 +53 -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 -2
- package/dist/locales/grideditor.es.min.js +1 -1
- package/dist/locales/grideditor.es.min.js.map +1 -1
- package/dist/plugins/grideditor.ckeditor.js +6 -52
- package/dist/plugins/grideditor.ckeditor.min.js +1 -1
- package/dist/plugins/grideditor.ckeditor.min.js.map +1 -1
- package/dist/plugins/grideditor.codemirror-inline.js +190 -0
- package/dist/plugins/grideditor.codemirror-inline.min.js +2 -0
- package/dist/plugins/grideditor.codemirror-inline.min.js.map +1 -0
- package/dist/plugins/grideditor.codemirror.js +79 -0
- package/dist/plugins/grideditor.codemirror.min.js +2 -0
- package/dist/plugins/grideditor.codemirror.min.js.map +1 -0
- package/dist/plugins/grideditor.summernote.js +6 -52
- package/dist/plugins/grideditor.summernote.min.js +1 -1
- package/dist/plugins/grideditor.summernote.min.js.map +1 -1
- package/dist/plugins/grideditor.tinymce.js +6 -52
- package/dist/plugins/grideditor.tinymce.min.js +1 -1
- package/dist/plugins/grideditor.tinymce.min.js.map +1 -1
- package/docs/events.md +6 -0
- package/docs/locale-keys.md +14 -4
- package/docs/plugins.md +20 -5
- package/example/codemirror.html +103 -0
- package/example/index.html +8 -0
- package/package.json +1 -1
- package/src/js/jquery.grideditor.js +53 -20
- package/src/js/locales/grideditor.es.js +4 -2
- package/src/js/plugins/grideditor.ckeditor.js +2 -2
- package/src/js/plugins/grideditor.codemirror-inline.js +190 -0
- package/src/js/plugins/grideditor.codemirror.js +79 -0
- package/src/js/plugins/grideditor.summernote.js +2 -2
- package/src/js/plugins/grideditor.tinymce.js +2 -2
- package/src/js/text/grideditor.text.js +4 -50
- package/src/less/grideditor.less +54 -0
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* It is a feature plugin, `text`, that the `plugins` setting does not choose
|
|
10
10
|
* (content_types does), and it is everything a text is to the editor: the
|
|
11
|
-
* text block's drawer, the Text buttons in the toolbar
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* text block's drawer, the Text buttons in the toolbar, createText, opening
|
|
12
|
+
* an editor on a click and closing it again with the host's attributes put
|
|
13
|
+
* back, and making the host's plain content a text through the core's
|
|
14
|
+
* `textTypes` hook.
|
|
15
15
|
*
|
|
16
16
|
* Each editor registers under $.fn.gridEditor.texts, which is this file's own
|
|
17
17
|
* registry and not a contract: an editor of a host's own is a feature plugin
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
if ($.fn.gridEditor.features.text) { return; }
|
|
23
23
|
|
|
24
24
|
$.extend($.fn.gridEditor.locales.en, {
|
|
25
|
-
'tool.add_text': 'Add text',
|
|
26
|
-
'tool.add_text_type': 'Add {editor} text',
|
|
27
25
|
'text.add': 'Text',
|
|
28
26
|
'text.add_type': 'Text ({editor})',
|
|
29
27
|
'panel.editor': 'Editor',
|
|
@@ -119,11 +117,6 @@
|
|
|
119
117
|
.html(content !== undefined ? content : (text && text.initialContent) || '');
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
/** A text block at the end of a column, through the add events. */
|
|
123
|
-
function addTextTo(col, type) {
|
|
124
|
-
return ge.place(makeText(type), 'text', { appendTo: col, source: 'tool' });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
120
|
/**
|
|
128
121
|
* createText(type?, options?): a content area of a text editor's,
|
|
129
122
|
* detached unless a placement is given. The type is the first one
|
|
@@ -262,44 +255,6 @@
|
|
|
262
255
|
});
|
|
263
256
|
}
|
|
264
257
|
|
|
265
|
-
/**
|
|
266
|
-
* The add text tool, in each column's drawer before its add row tool:
|
|
267
|
-
* a text of the first editor offered, or, held, of the one chosen.
|
|
268
|
-
*/
|
|
269
|
-
function addTextTools() {
|
|
270
|
-
var texts = offeredTexts();
|
|
271
|
-
if (!texts.length) { return; }
|
|
272
|
-
|
|
273
|
-
ge.canvas.find('.column').each(function() {
|
|
274
|
-
var col = $(this);
|
|
275
|
-
var drawer = col.children('.ge-tools-drawer');
|
|
276
|
-
if (!drawer.length || drawer.children('.ge-add-text').length) { return; }
|
|
277
|
-
|
|
278
|
-
ge.createTool(drawer, ge.t('tool.add_text'), 'ge-add-text', 'bi bi-type', function() {
|
|
279
|
-
if (ge.closePicker()) { return; } // The picker was open: that was the answer
|
|
280
|
-
|
|
281
|
-
addTextTo(col, texts[0]);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
var tool = drawer.children('.ge-add-text');
|
|
285
|
-
var addRow = drawer.children('.ge-add-row');
|
|
286
|
-
if (addRow.length) { tool.insertBefore(addRow); }
|
|
287
|
-
|
|
288
|
-
if (texts.length > 1) {
|
|
289
|
-
ge.attachPicker(tool, function() {
|
|
290
|
-
ge.openPicker(tool, texts.map(function(type) {
|
|
291
|
-
return {
|
|
292
|
-
label: textLabel(type),
|
|
293
|
-
title: ge.t('tool.add_text_type', { editor: textLabel(type) }),
|
|
294
|
-
attributes: { 'data-ge-content-type': type },
|
|
295
|
-
choose: function() { addTextTo(col, type); },
|
|
296
|
-
};
|
|
297
|
-
}), 'ge-text-picker');
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
258
|
var texts = offeredTexts();
|
|
304
259
|
|
|
305
260
|
return {
|
|
@@ -354,7 +309,6 @@
|
|
|
354
309
|
|
|
355
310
|
onInit: function() {
|
|
356
311
|
markTexts();
|
|
357
|
-
addTextTools();
|
|
358
312
|
|
|
359
313
|
ge.canvas.off('click.ge-text').on('click.ge-text', '.ge-content', onClick);
|
|
360
314
|
},
|
|
@@ -402,8 +356,8 @@
|
|
|
402
356
|
*
|
|
403
357
|
* Up to 5.x the main bundle carried a copy of this file; since 6.0 it is
|
|
404
358
|
* loaded on its own, like every plugin. The built file starts with what
|
|
405
|
-
* every text editor shares - text blocks, the Text button
|
|
406
|
-
*
|
|
359
|
+
* every text editor shares - text blocks, the Text button, createText,
|
|
360
|
+
* making the host's plain content a text - from
|
|
407
361
|
* src/js/text/grideditor.text.js, installed once however many editors a
|
|
408
362
|
* page loads.
|
|
409
363
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(
|
|
1
|
+
(g=>{var t,x;function v(e){var n={};return g.each(g.makeArray(e.attributes),function(e,t){n[t.name]=t.value}),n}function y(e){return(e||"").split(/\s+/).filter(function(e){return""!==e&&!t.test(e)})}function e(r){var o=r.settings,f={},n={};function a(){return o.content_types.filter(function(e){return!!f[e]})}function c(e){var t=f[e];return t&&t.labelKey?r.t(t.labelKey):e}function i(e,t){var n=f[e];return g('<div class="ge-content" />').addClass("ge-content-type-"+e).attr("data-ge-content-type",e).html(void 0!==t?t:n&&n.initialContent||"")}function t(e){return f[e.attr("data-ge-content-type")]}function s(e){var t;e.hasClass("ge-rte-active")||e.is(":visible")&&(t=f[e.attr("data-ge-content-type")])&&(t.available&&!t.available()?t.missingKey&&console.error(r.t(t.missingKey)):(e.data("ge-text-before",v(e[0])).removeData("ge-text-ready"),e.addClass("ge-rte-active"),t.start(e)))}function e(){s(g(this))}function l(e){var n,t,a,i,r,o,c,s=f[e.attr("data-ge-content-type")],l=e.data("ge-text-before"),d=l?v(e[0]):null;s&&s.stop(e),e.removeClass("ge-rte-active"),l&&(s=l,t=(n=e).data("ge-text-ready")||l,a=d,i=g.extend({},s),g.each(g.extend({},t,a),function(e){"class"===e||x.test(e)||t[e]===a[e]||(void 0===a[e]?delete i[e]:i[e]=a[e])}),r=y(t.class),o=y(a.class),c=y(s.class).filter(function(e){return-1!==o.indexOf(e)||-1===r.indexOf(e)}),o.forEach(function(e){-1===r.indexOf(e)&&-1===c.indexOf(e)&&c.push(e)}),c.length?i.class=c.join(" "):delete i.class,g.each(v(n[0]),function(e){n.removeAttr(e)}),g.each(i,function(e,t){n.attr(e,t)}),e.removeData("ge-text-before").removeData("ge-text-ready"))}function d(t){var n=t.children(".ge-content"),e=n.attr("data-ge-content-type"),a=g('<div class="ge-tools-drawer ge-text-drawer" />').prependTo(t),i=(r.createMoveTool(a),r.addSettingsTool(a,n,o.text_classes));g('<div class="ge-field ge-text-editor" />').append(g('<span class="ge-field-label" />').text(r.t("panel.editor"))).append(g('<span class="ge-field-value" />').text(c(e))).prependTo(i.children(".ge-details-general")),o.text_tools.forEach(function(e){r.createTool(a,e.title||"",e.className||"",e.iconClass||"bi bi-wrench",e.on)}),r.createTool(a,r.t("tool.delete_text"),"ge-delete-text","bi bi-trash",function(){r.deleteNode("text",n,r.t("confirm.delete_text"),function(e){l(n),t.slideUp(function(){t.remove(),e()})})})}g.each(g.fn.gridEditor.texts,function(e,t){f[e]=t(r)}),Array.isArray(o.content_types)||(o.content_types=Object.keys(f)),Array.isArray(o.text_tools)||(o.text_tools=[]),Array.isArray(o.text_classes)||(o.text_classes=[]);var u=a();return{methods:{createText:function(e,t){return e&&"object"==typeof e&&(t=e,e=void 0),t=t||{},(e=e||a()[0])&&f[e]?r.place(i(e,t.content),"text",t):(n["createText:"+e]||(n["createText:"+e]=!0,r.warn('createText: no text editor "'+e+'" is loaded; load its plugin and name it in content_types')),null)}},textTypes:function(){var n=a(),e=Object.keys(f).filter(function(e){return-1===n.indexOf(e)});return n.concat(e).map(function(e){var t=f[e];return{type:e,label:c(e),offered:-1!==n.indexOf(e),available:t.available?function(){return t.available()}:null,missingKey:t.missingKey,edit:function(e){var t=e.parent(".ge-text-block");t.length&&!t.children(".ge-tools-drawer").length&&d(t),s(e)}}})},toolbar:u.map(function(e){return{label:function(){return 1<u.length?r.t("text.add_type",{editor:c(e)}):r.t("text.add")},iconClass:f[e].iconClass,className:"ge-add-text-button",kind:"text",inColumn:!0,create:function(){return i(e)}}}),onInit:function(){r.canvas.find(".ge-text-block").each(function(){var e=g(this);e.children(".ge-tools-drawer").length||t(e.children(".ge-content"))&&d(e)}),r.canvas.off("click.ge-text").on("click.ge-text",".ge-content",e)},onBeforeDeinit:function(){r.canvas.find(".ge-content").each(function(){t(g(this))&&l(g(this))})},onDeinit:function(){r.canvas.off("click.ge-text")},onContentReady:function(e){e.data("ge-text-before")&&!e.data("ge-text-ready")&&e.data("ge-text-ready",v(e[0]))}}}g.fn.gridEditor.features.text||(g.extend(g.fn.gridEditor.locales.en,{"text.add":"Text","text.add_type":"Text ({editor})","panel.editor":"Editor","panel.kind_text":"Text"}),g.fn.gridEditor.texts=g.fn.gridEditor.texts||{},t=/^(mce-|cke|note-)|^(active|ge-rte-active)$/,x=/^(data-mce-|contenteditable$|spellcheck$)/,e.always=!0,g.fn.gridEditor.features.text=e)})(jQuery),(o=>{o.extend(o.fn.gridEditor.locales.en,{"text.ckeditor":"CKEditor"});var t="<p>Lorem initius... </p>";o.fn.gridEditor.texts.ckeditor=function(r){return{labelKey:"text.ckeditor",initialContent:t,missingKey:"error.ckeditor_missing",available:function(){return!!window.CKEDITOR},start:function(e){var i=r.settings;e.each(function(){var e,n,a=o(this);a.hasClass("active")||(a.html()==t&&a.html(" "),a.addClass("active").attr("contenteditable","true"),e=o.extend({},i.ckeditor&&i.ckeditor.config?i.ckeditor.config:{},{on:{instanceReady:function(e){var t;try{t=i.ckeditor.config.on.instanceReady}catch(e){}t&&t.call(this,e),r.textReady(a),n.focus()}}}),n=window.CKEDITOR.inline(a.get(0),e),a.data("ge-ckeditor",n))})},stop:function(e){e.filter(".active").each(function(){var n,a,e=o(this),t=window.CKEDITOR?(n=e).data("ge-ckeditor")||(a=null,o.each(window.CKEDITOR.instances,function(e,t){t.element&&t.element.$===n[0]&&(a=t)}),a):null;t&&t.destroy(),e.removeData("ge-ckeditor"),e.removeClass("active cke_focus").removeAttr("id").removeAttr("style").removeAttr("spellcheck").removeAttr("contenteditable")})}}}})(jQuery);
|
|
2
2
|
//# sourceMappingURL=grideditor.ckeditor.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grideditor.ckeditor.min.js","sources":["../../src/js/text/grideditor.text.js","../../src/js/plugins/grideditor.ckeditor.js"],"names":["$","EDITOR_CLASS","EDITOR_ATTRIBUTE","attributesOf","element","found","each","makeArray","attributes","i","attribute","name","value","classesIn","split","filter","test","textFeature","ge","settings","TEXTS","warned","offeredTexts","content_types","type","textLabel","text","labelKey","t","makeText","content","addClass","attr","html","undefined","initialContent","
|
|
1
|
+
{"version":3,"file":"grideditor.ckeditor.min.js","sources":["../../src/js/text/grideditor.text.js","../../src/js/plugins/grideditor.ckeditor.js"],"names":["$","EDITOR_CLASS","EDITOR_ATTRIBUTE","attributesOf","element","found","each","makeArray","attributes","i","attribute","name","value","classesIn","split","filter","test","textFeature","ge","settings","TEXTS","warned","offeredTexts","content_types","type","textLabel","text","labelKey","t","makeText","content","addClass","attr","html","undefined","initialContent","isOurs","block","startText","hasClass","is","available","missingKey","console","error","data","removeData","start","onClick","this","closeText","ready","open","result","readyClasses","openClasses","classes","before","stop","removeClass","extend","indexOf","forEach","push","length","join","removeAttr","createTextControls","textBlock","children","drawer","prependTo","details","createMoveTool","addSettingsTool","text_classes","append","text_tools","hostTool","createTool","title","className","iconClass","on","deleteNode","removed","slideUp","remove","fn","gridEditor","texts","factory","Array","isArray","Object","keys","methods","createText","options","place","warn","textTypes","offered","others","concat","map","label","edit","parent","toolbar","editor","kind","inColumn","create","onInit","canvas","find","off","onBeforeDeinit","onDeinit","onContentReady","area","features","locales","en","text.add","text.add_type","panel.editor","panel.kind_text","always","jQuery","text.ckeditor","INITIAL_CONTENT","ckeditor","window","CKEDITOR","contentAreas","configuration","instance","contentArea","config","instanceReady","evt","callback","err","call","textReady","focus","inline","get","instances","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OT,EAAYU,IAAI,CAAC,EAAGZ,CAAa,EACvEE,EAAY9F,KAAK,cAAe6F,CAAQ,EAC5C,CAAC,CACL,EAEAhF,KAAM,SAAS8E,GACXA,EAAazH,OAAO,SAAS,EAAET,KAAK,WAChC,IArEQqI,EAIZtI,EAiEQsI,EAAc3I,EAAEiD,IAAI,EAKpByF,EAAWJ,OAAOC,UA1EdI,EA0EoCA,GAzE7B9F,KAAK,aAAa,IAGrCxC,EAAQ,KACZL,EAAEM,KAAKgI,OAAOC,SAASe,UAAW,SAAS3I,EAAM+H,GACzCA,EAAStI,SAAWsI,EAAStI,QAAQJ,IAAM2I,EAAY,KAAMtI,EAAQqI,EAC7E,CAAC,EAEMrI,GAiE4D,KACvDqI,GAAYA,EAASa,QAAQ,EACjCZ,EAAY7F,WAAW,aAAa,EAGpC6F,EACKhF,YAAY,kBAAkB,EAC9BO,WAAW,IAAI,EACfA,WAAW,OAAO,EAClBA,WAAW,YAAY,EACvBA,WAAW,iBAAiB,CAErC,CAAC,CACL,CACJ,CACJ,CACH,GAAEgE,MAAM"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A block's html, edited in place with CodeMirror.
|
|
3
|
+
*
|
|
4
|
+
* A feature plugin: load this file after the editor, and CodeMirror 5 with
|
|
5
|
+
* its html mode after or before it, and every drawer of a row, a column, a
|
|
6
|
+
* text, the host's plain content, an element, a section or a container has a
|
|
7
|
+
* </> tool. It opens the block's html - the block itself and everything in
|
|
8
|
+
* it, as getHtml would give it - in CodeMirror where the block was, and
|
|
9
|
+
* Apply puts what was written in the block's place. What it can ask the
|
|
10
|
+
* editor for is the handle its factory is called with, described in
|
|
11
|
+
* docs/plugins.md.
|
|
12
|
+
*
|
|
13
|
+
* <link rel="stylesheet" href="codemirror/lib/codemirror.css">
|
|
14
|
+
* <script src="codemirror/lib/codemirror.js"></script>
|
|
15
|
+
* <script src="codemirror/mode/xml/xml.js"></script>
|
|
16
|
+
* <script src="codemirror/mode/javascript/javascript.js"></script>
|
|
17
|
+
* <script src="codemirror/mode/css/css.js"></script>
|
|
18
|
+
* <script src="codemirror/mode/htmlmixed/htmlmixed.js"></script>
|
|
19
|
+
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
20
|
+
* <script src="dist/plugins/grideditor.codemirror-inline.min.js"></script>
|
|
21
|
+
*
|
|
22
|
+
* Without CodeMirror on the page the html is edited in a plain textarea.
|
|
23
|
+
* CodeMirror's options are the codemirror plugin's, codemirror.config.
|
|
24
|
+
*/
|
|
25
|
+
(function($) {
|
|
26
|
+
|
|
27
|
+
$.extend($.fn.gridEditor.locales.en, {
|
|
28
|
+
'tool.edit_html': 'Edit html',
|
|
29
|
+
'codemirror.apply': 'Apply',
|
|
30
|
+
'codemirror.cancel': 'Cancel',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** What has html of its own to edit: a pane's is split between its button and its body. */
|
|
34
|
+
var KINDS = ['row', 'column', 'text', 'plain', 'element', 'section'];
|
|
35
|
+
|
|
36
|
+
$.fn.gridEditor.features['codemirror-inline'] = function(ge) {
|
|
37
|
+
|
|
38
|
+
var open = []; // The blocks being edited: { node, kind, from, wrapper, textarea, editor }
|
|
39
|
+
|
|
40
|
+
function options() {
|
|
41
|
+
var own = (ge.settings.codemirror && ge.settings.codemirror.config) || {};
|
|
42
|
+
|
|
43
|
+
return $.extend({
|
|
44
|
+
mode: 'htmlmixed',
|
|
45
|
+
lineNumbers: true,
|
|
46
|
+
lineWrapping: true,
|
|
47
|
+
tabSize: 2,
|
|
48
|
+
indentUnit: 2,
|
|
49
|
+
// As tall as what it holds, up to the css's limit
|
|
50
|
+
viewportMargin: Infinity,
|
|
51
|
+
}, own);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** What stands for the node in its column: a text's text block, or the node. */
|
|
55
|
+
function anchorOf(node) {
|
|
56
|
+
var textBlock = node.parent('.ge-text-block');
|
|
57
|
+
return textBlock.length ? textBlock : node;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function entryOf(node) {
|
|
61
|
+
return open.filter(function(entry) { return entry.node[0] === node[0]; })[0] || null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function editable(node, kind) {
|
|
65
|
+
return KINDS.indexOf(kind) !== -1 || node.is('[data-ge-container]');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The editor where the block was, the block hidden behind it. */
|
|
69
|
+
function show(entry) {
|
|
70
|
+
var anchor = anchorOf(entry.node).addClass('ge-code-hidden');
|
|
71
|
+
entry.wrapper.insertAfter(anchor);
|
|
72
|
+
if (entry.editor) { entry.editor.refresh(); }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function hide(entry) {
|
|
76
|
+
entry.wrapper.detach();
|
|
77
|
+
anchorOf(entry.node).removeClass('ge-code-hidden');
|
|
78
|
+
entry.node.removeClass('ge-code-hidden');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function close(entry) {
|
|
82
|
+
hide(entry);
|
|
83
|
+
if (entry.editor) { entry.editor.toTextArea(); }
|
|
84
|
+
entry.wrapper.remove();
|
|
85
|
+
open.splice(open.indexOf(entry), 1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function openEditor(node) {
|
|
89
|
+
if (entryOf(node)) { return; }
|
|
90
|
+
|
|
91
|
+
var entry = {
|
|
92
|
+
node: node,
|
|
93
|
+
kind: ge.kindOf(node),
|
|
94
|
+
// As getHtml gives it: no drawers, no editor open in it
|
|
95
|
+
from: ge.nodeHtml(node),
|
|
96
|
+
// A drawer, to the editor: never content, never a block to move
|
|
97
|
+
wrapper: $('<div class="ge-tools-drawer ge-code-inline" />'),
|
|
98
|
+
editor: null,
|
|
99
|
+
};
|
|
100
|
+
entry.textarea = $('<textarea class="ge-code-inline-source" />').val(entry.from).appendTo(entry.wrapper);
|
|
101
|
+
|
|
102
|
+
var bar = $('<div class="ge-code-inline-bar" />').appendTo(entry.wrapper);
|
|
103
|
+
$('<button type="button" class="btn btn-sm btn-primary ge-code-apply" />')
|
|
104
|
+
.text(ge.t('codemirror.apply'))
|
|
105
|
+
.on('click', function() { apply(entry); })
|
|
106
|
+
.appendTo(bar);
|
|
107
|
+
$('<button type="button" class="btn btn-sm btn-outline-secondary ge-code-cancel" />')
|
|
108
|
+
.text(ge.t('codemirror.cancel'))
|
|
109
|
+
.on('click', function() { close(entry); })
|
|
110
|
+
.appendTo(bar);
|
|
111
|
+
|
|
112
|
+
open.push(entry);
|
|
113
|
+
show(entry);
|
|
114
|
+
|
|
115
|
+
if (window.CodeMirror) {
|
|
116
|
+
entry.editor = window.CodeMirror.fromTextArea(entry.textarea[0], options());
|
|
117
|
+
$(entry.editor.getWrapperElement()).addClass('ge-code-editor');
|
|
118
|
+
entry.editor.focus();
|
|
119
|
+
} else {
|
|
120
|
+
entry.textarea.trigger('focus');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* What was written, in the block's place, through the edit-html events.
|
|
126
|
+
* The canvas leaves editing to take it in and comes back, as it does for
|
|
127
|
+
* getHtml, so what was written is read as the editor reads any markup.
|
|
128
|
+
*/
|
|
129
|
+
function apply(entry) {
|
|
130
|
+
var to = entry.editor ? entry.editor.getValue() : entry.textarea.val();
|
|
131
|
+
var payload = ge.payloadFor(entry.kind, entry.node, { source: 'tool', from: entry.from, to: to });
|
|
132
|
+
|
|
133
|
+
// Canceled, the editor stays open with what was written in it
|
|
134
|
+
if (!ge.emit('before-edit-html', payload)) { return; }
|
|
135
|
+
|
|
136
|
+
close(entry);
|
|
137
|
+
|
|
138
|
+
var instance = ge.canvas.data('grideditor');
|
|
139
|
+
instance.deinit();
|
|
140
|
+
|
|
141
|
+
var made = $('<div />').html(to).contents();
|
|
142
|
+
entry.node.replaceWith(made);
|
|
143
|
+
|
|
144
|
+
instance.init();
|
|
145
|
+
|
|
146
|
+
ge.emit('after-edit-html', ge.payloadFor(entry.kind, made.filter('*'), {
|
|
147
|
+
source: 'tool',
|
|
148
|
+
from: entry.from,
|
|
149
|
+
to: to,
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function tool(drawer, node) {
|
|
154
|
+
ge.createTool(drawer, ge.t('tool.edit_html'), 'ge-edit-html', 'bi bi-code-slash', function() {
|
|
155
|
+
openEditor(node);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
drawerTools: function(drawer, node, kind) {
|
|
161
|
+
if (editable(node, kind)) { tool(drawer, node); }
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
// Plain content has no gear, and so none of the drawerTools: its
|
|
165
|
+
// html is what there is to edit about it
|
|
166
|
+
plainTools: tool,
|
|
167
|
+
|
|
168
|
+
// Every deinit - getHtml's among them - takes the editors off the
|
|
169
|
+
// canvas, whatever is in them, and every init puts them back where
|
|
170
|
+
// their block is. A block that is gone takes its editor with it.
|
|
171
|
+
onBeforeDeinit: function() {
|
|
172
|
+
open.forEach(hide);
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
onInit: function() {
|
|
176
|
+
open.slice().forEach(function(entry) {
|
|
177
|
+
if (!$.contains(document.documentElement, entry.node[0])) {
|
|
178
|
+
if (entry.editor) { entry.editor.toTextArea(); }
|
|
179
|
+
entry.wrapper.remove();
|
|
180
|
+
open.splice(open.indexOf(entry), 1);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
show(entry);
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
})(jQuery);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(l=>{l.extend(l.fn.gridEditor.locales.en,{"tool.edit_html":"Edit html","codemirror.apply":"Apply","codemirror.cancel":"Cancel"});var s=["row","column","text","plain","element","section"];l.fn.gridEditor.features["codemirror-inline"]=function(i){var t=[];function r(e){var o=e.parent(".ge-text-block");return o.length?o:e}function d(e){var o=r(e.node).addClass("ge-code-hidden");e.wrapper.insertAfter(o),e.editor&&e.editor.refresh()}function o(e){e.wrapper.detach(),r(e.node).removeClass("ge-code-hidden"),e.node.removeClass("ge-code-hidden")}function a(e){o(e),e.editor&&e.editor.toTextArea(),e.wrapper.remove(),t.splice(t.indexOf(e),1)}function n(e){var o,n;o=e,t.filter(function(e){return e.node[0]===o[0]})[0]||((n={node:e,kind:i.kindOf(e),from:i.nodeHtml(e),wrapper:l('<div class="ge-tools-drawer ge-code-inline" />'),editor:null}).textarea=l('<textarea class="ge-code-inline-source" />').val(n.from).appendTo(n.wrapper),e=l('<div class="ge-code-inline-bar" />').appendTo(n.wrapper),l('<button type="button" class="btn btn-sm btn-primary ge-code-apply" />').text(i.t("codemirror.apply")).on("click",function(){var e,o,t,r;t=(e=n).editor?e.editor.getValue():e.textarea.val(),r=i.payloadFor(e.kind,e.node,{source:"tool",from:e.from,to:t}),i.emit("before-edit-html",r)&&(a(e),(r=i.canvas.data("grideditor")).deinit(),o=l("<div />").html(t).contents(),e.node.replaceWith(o),r.init(),i.emit("after-edit-html",i.payloadFor(e.kind,o.filter("*"),{source:"tool",from:e.from,to:t})))}).appendTo(e),l('<button type="button" class="btn btn-sm btn-outline-secondary ge-code-cancel" />').text(i.t("codemirror.cancel")).on("click",function(){a(n)}).appendTo(e),t.push(n),d(n),window.CodeMirror?(n.editor=window.CodeMirror.fromTextArea(n.textarea[0],(e=i.settings.codemirror&&i.settings.codemirror.config||{},l.extend({mode:"htmlmixed",lineNumbers:!0,lineWrapping:!0,tabSize:2,indentUnit:2,viewportMargin:1/0},e))),l(n.editor.getWrapperElement()).addClass("ge-code-editor"),n.editor.focus()):n.textarea.trigger("focus"))}function c(e,o){i.createTool(e,i.t("tool.edit_html"),"ge-edit-html","bi bi-code-slash",function(){n(o)})}return{drawerTools:function(e,o,t){var r;r=o,-1===s.indexOf(t)&&!r.is("[data-ge-container]")||c(e,o)},plainTools:c,onBeforeDeinit:function(){t.forEach(o)},onInit:function(){t.slice().forEach(function(e){l.contains(document.documentElement,e.node[0])?d(e):(e.editor&&e.editor.toTextArea(),e.wrapper.remove(),t.splice(t.indexOf(e),1))})}}}})(jQuery);
|
|
2
|
+
//# sourceMappingURL=grideditor.codemirror-inline.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grideditor.codemirror-inline.min.js","sources":["../../src/js/plugins/grideditor.codemirror-inline.js"],"names":["$","extend","fn","gridEditor","locales","en","tool.edit_html","codemirror.apply","codemirror.cancel","KINDS","features","ge","open","anchorOf","node","textBlock","parent","length","show","entry","anchor","addClass","wrapper","insertAfter","editor","refresh","hide","detach","removeClass","close","toTextArea","remove","splice","indexOf","openEditor","filter","kind","kindOf","from","nodeHtml","textarea","val","appendTo","bar","text","t","on","made","to","payload","getValue","payloadFor","source","emit","instance","canvas","data","deinit","html","contents","replaceWith","init","push","window","CodeMirror","fromTextArea","own","settings","codemirror","config","mode","lineNumbers","lineWrapping","tabSize","indentUnit","viewportMargin","Infinity","getWrapperElement","focus","trigger","tool","drawer","createTool","drawerTools","is","plainTools","onBeforeDeinit","forEach","onInit","slice","contains","document","documentElement","jQuery"],"mappings":"CAwBUA,IAEVA,EAAEC,OAAOD,EAAEE,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,iBAAkB,YAClBC,mBAAoB,QACpBC,oBAAqB,QACzB,CAAC,EAGD,IAAIC,EAAQ,CAAC,MAAO,SAAU,OAAQ,QAAS,UAAW,WAE1DT,EAAEE,GAAGC,WAAWO,SAAS,qBAAuB,SAASC,GAErD,IAAIC,EAAO,GAiBX,SAASC,EAASC,GACd,IAAIC,EAAYD,EAAKE,OAAO,gBAAgB,EAC5C,OAAOD,EAAUE,OAASF,EAAYD,CAC1C,CAWA,SAASI,EAAKC,GACV,IAAIC,EAASP,EAASM,EAAML,IAAI,EAAEO,SAAS,gBAAgB,EAC3DF,EAAMG,QAAQC,YAAYH,CAAM,EAC5BD,EAAMK,QA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,QAgGUG,CAhGE,GAAYtB,CAAAA,EAAKsE,GAAG,qBAAqB,GAgGlCJ,EAAKC,EAAQnE,CAAI,CACjD,EAIAuE,WAAYL,EAKZM,eAAgB,WACZ1E,EAAK2E,QAAQ7D,CAAI,CACrB,EAEA8D,OAAQ,WACJ5E,EAAK6E,MAAM,EAAEF,QAAQ,SAASpE,GACrBnB,EAAE0F,SAASC,SAASC,gBAAiBzE,EAAML,KAAK,EAAE,EAOvDI,EAAKC,CAAK,GANFA,EAAMK,QAAUL,EAAMK,OAAOM,WAAW,EAC5CX,EAAMG,QAAQS,OAAO,EACrBnB,EAAKoB,OAAOpB,EAAKqB,QAAQd,CAAK,EAAG,CAAC,EAK1C,CAAC,CACL,CACJ,CACJ,CAEC,GAAE0E,MAAM"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CodeMirror for grid-editor's source view.
|
|
3
|
+
*
|
|
4
|
+
* A feature plugin: load this file after the editor, and CodeMirror 5 with
|
|
5
|
+
* its html mode after or before it, and the toolbar's source button edits the
|
|
6
|
+
* canvas's html in CodeMirror - highlighted, with line numbers - rather than
|
|
7
|
+
* in a plain textarea. What it can ask the editor for is the handle its
|
|
8
|
+
* factory is called with, described in docs/plugins.md.
|
|
9
|
+
*
|
|
10
|
+
* <link rel="stylesheet" href="codemirror/lib/codemirror.css">
|
|
11
|
+
* <script src="codemirror/lib/codemirror.js"></script>
|
|
12
|
+
* <script src="codemirror/mode/xml/xml.js"></script>
|
|
13
|
+
* <script src="codemirror/mode/javascript/javascript.js"></script>
|
|
14
|
+
* <script src="codemirror/mode/css/css.js"></script>
|
|
15
|
+
* <script src="codemirror/mode/htmlmixed/htmlmixed.js"></script>
|
|
16
|
+
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
17
|
+
* <script src="dist/plugins/grideditor.codemirror.min.js"></script>
|
|
18
|
+
*
|
|
19
|
+
* CodeMirror 5 rather than 6: 6 comes as ES modules only, for a bundler,
|
|
20
|
+
* where 5 loads from a script tag like the rest of the page. Without
|
|
21
|
+
* CodeMirror on the page the source view is the textarea, as before, and
|
|
22
|
+
* the console says why.
|
|
23
|
+
*/
|
|
24
|
+
(function($) {
|
|
25
|
+
|
|
26
|
+
$.extend($.fn.gridEditor.locales.en, {
|
|
27
|
+
'error.codemirror_missing': 'CodeMirror not available! Make sure you loaded the CodeMirror js file; the source is edited in a plain textarea without it.',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
$.fn.gridEditor.features.codemirror = function(ge) {
|
|
31
|
+
|
|
32
|
+
var editor = null;
|
|
33
|
+
var warned = false;
|
|
34
|
+
|
|
35
|
+
function options() {
|
|
36
|
+
var own = (ge.settings.codemirror && ge.settings.codemirror.config) || {};
|
|
37
|
+
|
|
38
|
+
return $.extend({
|
|
39
|
+
mode: 'htmlmixed',
|
|
40
|
+
lineNumbers: true,
|
|
41
|
+
lineWrapping: true,
|
|
42
|
+
tabSize: 2,
|
|
43
|
+
indentUnit: 2,
|
|
44
|
+
}, own);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
// Over the textarea the editor fills with the canvas's html: it goes
|
|
49
|
+
// where the textarea was, as tall as the editor made the textarea
|
|
50
|
+
onSourceOpen: function(textarea) {
|
|
51
|
+
if (!window.CodeMirror) {
|
|
52
|
+
if (!warned) {
|
|
53
|
+
warned = true;
|
|
54
|
+
ge.warn(ge.t('error.codemirror_missing'));
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
var height = textarea.height();
|
|
60
|
+
|
|
61
|
+
editor = window.CodeMirror.fromTextArea(textarea[0], options());
|
|
62
|
+
$(editor.getWrapperElement()).addClass('ge-code-editor');
|
|
63
|
+
editor.setSize(null, height);
|
|
64
|
+
editor.focus();
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
// What it holds goes back in the textarea, which is what the canvas
|
|
68
|
+
// is made of again, and the textarea is left as it found it
|
|
69
|
+
onSourceClose: function() {
|
|
70
|
+
if (!editor) { return; }
|
|
71
|
+
|
|
72
|
+
editor.save();
|
|
73
|
+
editor.toTextArea();
|
|
74
|
+
editor = null;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
})(jQuery);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(t=>{t.extend(t.fn.gridEditor.locales.en,{"error.codemirror_missing":"CodeMirror not available! Make sure you loaded the CodeMirror js file; the source is edited in a plain textarea without it."}),t.fn.gridEditor.features.codemirror=function(o){var i=null,n=!1;return{onSourceOpen:function(e){var r;window.CodeMirror?(r=e.height(),i=window.CodeMirror.fromTextArea(e[0],(e=o.settings.codemirror&&o.settings.codemirror.config||{},t.extend({mode:"htmlmixed",lineNumbers:!0,lineWrapping:!0,tabSize:2,indentUnit:2},e))),t(i.getWrapperElement()).addClass("ge-code-editor"),i.setSize(null,r),i.focus()):n||(n=!0,o.warn(o.t("error.codemirror_missing")))},onSourceClose:function(){i&&(i.save(),i.toTextArea(),i=null)}}}})(jQuery);
|
|
2
|
+
//# sourceMappingURL=grideditor.codemirror.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grideditor.codemirror.min.js","sources":["../../src/js/plugins/grideditor.codemirror.js"],"names":["$","extend","fn","gridEditor","locales","en","error.codemirror_missing","features","codemirror","ge","editor","warned","onSourceOpen","textarea","height","window","CodeMirror","fromTextArea","own","settings","config","mode","lineNumbers","lineWrapping","tabSize","indentUnit","getWrapperElement","addClass","setSize","focus","warn","t","onSourceClose","save","toTextArea","jQuery"],"mappings":"CAuBUA,IAEVA,EAAEC,OAAOD,EAAEE,GAAGC,WAAWC,QAAQC,GAAI,CACjCC,2BAA4B,6HAChC,CAAC,EAEDN,EAAEE,GAAGC,WAAWI,SAASC,WAAa,SAASC,GAE3C,IAAIC,EAAS,KACTC,EAAS,CAAA,EAcb,MAAO,CAGHC,aAAc,SAASC,GACnB,IAQIC,EARCC,OAAOC,YAQRF,EAASD,EAASC,OAAO,EAE7BJ,EAASK,OAAOC,WAAWC,aAAaJ,EAAS,IAzBjDK,EAAOT,EAAGU,SAASX,YAAcC,EAAGU,SAASX,WAAWY,QAAW,GAEhEpB,EAAEC,OAAO,CACZoB,KAAM,YACNC,YAAa,CAAA,EACbC,aAAc,CAAA,EACdC,QAAS,EACTC,WAAY,CAChB,EAAGP,CAAG,EAiB4D,EAC9DlB,EAAEU,EAAOgB,kBAAkB,CAAC,EAAEC,SAAS,gBAAgB,EACvDjB,EAAOkB,QAAQ,KAAMd,CAAM,EAC3BJ,EAAOmB,MAAM,GAZJlB,IACDA,EAAS,CAAA,EACTF,EAAGqB,KAAKrB,EAAGsB,EAAE,0BAA0B,CAAC,EAWpD,EAIAC,cAAe,WACNtB,IAELA,EAAOuB,KAAK,EACZvB,EAAOwB,WAAW,EAClBxB,EAAS,KACb,CACJ,CACJ,CAEC,GAAEyB,MAAM"}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* It is a feature plugin, `text`, that the `plugins` setting does not choose
|
|
10
10
|
* (content_types does), and it is everything a text is to the editor: the
|
|
11
|
-
* text block's drawer, the Text buttons in the toolbar
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* text block's drawer, the Text buttons in the toolbar, createText, opening
|
|
12
|
+
* an editor on a click and closing it again with the host's attributes put
|
|
13
|
+
* back, and making the host's plain content a text through the core's
|
|
14
|
+
* `textTypes` hook.
|
|
15
15
|
*
|
|
16
16
|
* Each editor registers under $.fn.gridEditor.texts, which is this file's own
|
|
17
17
|
* registry and not a contract: an editor of a host's own is a feature plugin
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
if ($.fn.gridEditor.features.text) { return; }
|
|
23
23
|
|
|
24
24
|
$.extend($.fn.gridEditor.locales.en, {
|
|
25
|
-
'tool.add_text': 'Add text',
|
|
26
|
-
'tool.add_text_type': 'Add {editor} text',
|
|
27
25
|
'text.add': 'Text',
|
|
28
26
|
'text.add_type': 'Text ({editor})',
|
|
29
27
|
'panel.editor': 'Editor',
|
|
@@ -119,11 +117,6 @@
|
|
|
119
117
|
.html(content !== undefined ? content : (text && text.initialContent) || '');
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
/** A text block at the end of a column, through the add events. */
|
|
123
|
-
function addTextTo(col, type) {
|
|
124
|
-
return ge.place(makeText(type), 'text', { appendTo: col, source: 'tool' });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
120
|
/**
|
|
128
121
|
* createText(type?, options?): a content area of a text editor's,
|
|
129
122
|
* detached unless a placement is given. The type is the first one
|
|
@@ -262,44 +255,6 @@
|
|
|
262
255
|
});
|
|
263
256
|
}
|
|
264
257
|
|
|
265
|
-
/**
|
|
266
|
-
* The add text tool, in each column's drawer before its add row tool:
|
|
267
|
-
* a text of the first editor offered, or, held, of the one chosen.
|
|
268
|
-
*/
|
|
269
|
-
function addTextTools() {
|
|
270
|
-
var texts = offeredTexts();
|
|
271
|
-
if (!texts.length) { return; }
|
|
272
|
-
|
|
273
|
-
ge.canvas.find('.column').each(function() {
|
|
274
|
-
var col = $(this);
|
|
275
|
-
var drawer = col.children('.ge-tools-drawer');
|
|
276
|
-
if (!drawer.length || drawer.children('.ge-add-text').length) { return; }
|
|
277
|
-
|
|
278
|
-
ge.createTool(drawer, ge.t('tool.add_text'), 'ge-add-text', 'bi bi-type', function() {
|
|
279
|
-
if (ge.closePicker()) { return; } // The picker was open: that was the answer
|
|
280
|
-
|
|
281
|
-
addTextTo(col, texts[0]);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
var tool = drawer.children('.ge-add-text');
|
|
285
|
-
var addRow = drawer.children('.ge-add-row');
|
|
286
|
-
if (addRow.length) { tool.insertBefore(addRow); }
|
|
287
|
-
|
|
288
|
-
if (texts.length > 1) {
|
|
289
|
-
ge.attachPicker(tool, function() {
|
|
290
|
-
ge.openPicker(tool, texts.map(function(type) {
|
|
291
|
-
return {
|
|
292
|
-
label: textLabel(type),
|
|
293
|
-
title: ge.t('tool.add_text_type', { editor: textLabel(type) }),
|
|
294
|
-
attributes: { 'data-ge-content-type': type },
|
|
295
|
-
choose: function() { addTextTo(col, type); },
|
|
296
|
-
};
|
|
297
|
-
}), 'ge-text-picker');
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
258
|
var texts = offeredTexts();
|
|
304
259
|
|
|
305
260
|
return {
|
|
@@ -354,7 +309,6 @@
|
|
|
354
309
|
|
|
355
310
|
onInit: function() {
|
|
356
311
|
markTexts();
|
|
357
|
-
addTextTools();
|
|
358
312
|
|
|
359
313
|
ge.canvas.off('click.ge-text').on('click.ge-text', '.ge-content', onClick);
|
|
360
314
|
},
|
|
@@ -402,8 +356,8 @@
|
|
|
402
356
|
*
|
|
403
357
|
* Up to 5.x the main bundle carried a copy of this file; since 6.0 it is
|
|
404
358
|
* loaded on its own, like every plugin. The built file starts with what
|
|
405
|
-
* every text editor shares - text blocks, the Text button
|
|
406
|
-
*
|
|
359
|
+
* every text editor shares - text blocks, the Text button, createText,
|
|
360
|
+
* making the host's plain content a text - from
|
|
407
361
|
* src/js/text/grideditor.text.js, installed once however many editors a
|
|
408
362
|
* page loads.
|
|
409
363
|
*/
|