@themarioga/grid-editor 5.3.1 → 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 +30 -0
- package/README.md +19 -8
- package/UPGRADING.md +57 -12
- package/dist/grideditor.css +13 -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 +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 +17 -0
- package/src/js/compat/bundled-texts.js +0 -14
|
@@ -1480,12 +1480,6 @@ $.fn.gridEditor = function( optionsOrMethod ) {
|
|
|
1480
1480
|
return;
|
|
1481
1481
|
}
|
|
1482
1482
|
|
|
1483
|
-
if (text.bundled) {
|
|
1484
|
-
warnOnceHere('text-bundled:' + type, 'the ' + type + ' text editor is the copy in the ' +
|
|
1485
|
-
'main bundle, which 6.0 will not include: load dist/plugins/grideditor.' + type +
|
|
1486
|
-
'.js after the editor');
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
1483
|
$(this).data('ge-text-before', attributesOf(this)).removeData('ge-text-ready');
|
|
1490
1484
|
$(this).addClass('ge-rte-active');
|
|
1491
1485
|
text.start($(this));
|
|
@@ -1501,7 +1495,9 @@ $.fn.gridEditor = function( optionsOrMethod ) {
|
|
|
1501
1495
|
canvas.addClass('ge-editing');
|
|
1502
1496
|
canvas.toggleClass('ge-drag-drawer', settings.drag_handle === 'drawer');
|
|
1503
1497
|
addAllColClasses();
|
|
1504
|
-
|
|
1498
|
+
var cutter = textCutter();
|
|
1499
|
+
splitTexts(cutter);
|
|
1500
|
+
wrapContent(cutter);
|
|
1505
1501
|
wrapTexts();
|
|
1506
1502
|
createRowControls();
|
|
1507
1503
|
createColControls();
|
|
@@ -1632,7 +1628,7 @@ $.fn.gridEditor = function( optionsOrMethod ) {
|
|
|
1632
1628
|
// plugins setting: a page that names its containers there has
|
|
1633
1629
|
// named no editor, and still wants the one it uses
|
|
1634
1630
|
$.each($.fn.gridEditor.texts, function(type, factory) {
|
|
1635
|
-
TEXTS[type] =
|
|
1631
|
+
TEXTS[type] = factory(api);
|
|
1636
1632
|
});
|
|
1637
1633
|
|
|
1638
1634
|
// 5.x's registry, for an integration a host wrote itself. One the
|
|
@@ -3475,15 +3471,12 @@ $.fn.gridEditor = function( optionsOrMethod ) {
|
|
|
3475
3471
|
|
|
3476
3472
|
/**
|
|
3477
3473
|
* What a drag reports as moving. A text block is the editor's own
|
|
3478
|
-
* wrapper, so what moved is the content area inside it
|
|
3479
|
-
* a content area moves as kind 'content', as it did in 5.x - adding
|
|
3480
|
-
* and deleting one, which 5.x never announced, already say 'text'.
|
|
3474
|
+
* wrapper, so what moved is the content area inside it.
|
|
3481
3475
|
*/
|
|
3482
3476
|
function moveSubject(item) {
|
|
3483
3477
|
var node = item.hasClass('ge-text-block') ? item.children('.ge-content') : item;
|
|
3484
|
-
var kind = kindOf(node);
|
|
3485
3478
|
|
|
3486
|
-
return { kind:
|
|
3479
|
+
return { kind: kindOf(node), node: node };
|
|
3487
3480
|
}
|
|
3488
3481
|
|
|
3489
3482
|
/** Put a node back where a refused drag found it. */
|
|
@@ -3949,10 +3942,102 @@ $.fn.gridEditor = function( optionsOrMethod ) {
|
|
|
3949
3942
|
}
|
|
3950
3943
|
}
|
|
3951
3944
|
|
|
3945
|
+
/**
|
|
3946
|
+
* What a text is never made of: rows, containers, and whatever a
|
|
3947
|
+
* feature plugin says - the elements plugin's elements. Each is a
|
|
3948
|
+
* block of the column's, beside the texts.
|
|
3949
|
+
*/
|
|
3950
|
+
function textCutter() {
|
|
3951
|
+
var cuts = ['.row', '[data-ge-container]'];
|
|
3952
|
+
|
|
3953
|
+
$.each(FEATURES, function(name, feature) {
|
|
3954
|
+
var cut = typeof feature.cuts === 'function' ? feature.cuts() : feature.cuts;
|
|
3955
|
+
if (cut) { cuts.push(cut); }
|
|
3956
|
+
});
|
|
3957
|
+
|
|
3958
|
+
return cuts.join(', ');
|
|
3959
|
+
}
|
|
3960
|
+
|
|
3961
|
+
/**
|
|
3962
|
+
* Take the blocks out of the text.
|
|
3963
|
+
*
|
|
3964
|
+
* Up to 5.x an element lived inside a content area, among the text
|
|
3965
|
+
* a rich text editor edited. From 6.0 it is a block of its own, so a
|
|
3966
|
+
* content area with one inside - markup 5.x saved - is cut there: the
|
|
3967
|
+
* text before stays in the content area, the element goes into the
|
|
3968
|
+
* column after it, and the text after goes into a new content area of
|
|
3969
|
+
* the same type. Only a content area's own children cut it, which is
|
|
3970
|
+
* where 5.x recognized elements; one inside a paragraph is text, as
|
|
3971
|
+
* it was. A part with nothing but whitespace is dropped, and the first
|
|
3972
|
+
* part that has something keeps the content area, id and classes and
|
|
3973
|
+
* all.
|
|
3974
|
+
*
|
|
3975
|
+
* On every init, and a no-op on markup 6.0 made: nothing to cut. A
|
|
3976
|
+
* content area its editor is open on is left for the next init.
|
|
3977
|
+
*/
|
|
3978
|
+
function splitTexts(cutter) {
|
|
3979
|
+
canvas.find('.column > .ge-content, .column > .ge-text-block > .ge-content').each(function() {
|
|
3980
|
+
var area = $(this);
|
|
3981
|
+
if (area.hasClass('ge-rte-active') || !area.children().filter(cutter).length) { return; }
|
|
3982
|
+
|
|
3983
|
+
var type = area.attr('data-ge-content-type');
|
|
3984
|
+
var anchor = area.parent('.ge-text-block').length ? area.parent() : area;
|
|
3985
|
+
var pieces = [];
|
|
3986
|
+
var run = [];
|
|
3987
|
+
|
|
3988
|
+
$.each($.makeArray(area[0].childNodes), function(i, node) {
|
|
3989
|
+
if (node.nodeType === 1 && $(node).is(cutter)) {
|
|
3990
|
+
pieces.push({ text: run }, { block: node });
|
|
3991
|
+
run = [];
|
|
3992
|
+
} else {
|
|
3993
|
+
run.push(node);
|
|
3994
|
+
}
|
|
3995
|
+
});
|
|
3996
|
+
pieces.push({ text: run });
|
|
3997
|
+
|
|
3998
|
+
$(area[0].childNodes).detach();
|
|
3999
|
+
|
|
4000
|
+
var kept = false;
|
|
4001
|
+
var last = anchor;
|
|
4002
|
+
|
|
4003
|
+
pieces.forEach(function(piece) {
|
|
4004
|
+
var placed;
|
|
4005
|
+
|
|
4006
|
+
if (piece.block) {
|
|
4007
|
+
placed = $(piece.block);
|
|
4008
|
+
} else if (!hasContent(piece.text)) {
|
|
4009
|
+
return;
|
|
4010
|
+
} else if (kept) {
|
|
4011
|
+
// Of the same type, or of none if it had none
|
|
4012
|
+
placed = (type ? createDefaultContentWrapper(type) : $('<div class="ge-content" />'))
|
|
4013
|
+
.append(piece.text);
|
|
4014
|
+
} else {
|
|
4015
|
+
// The content area itself, moved along if an
|
|
4016
|
+
// element came before the first text
|
|
4017
|
+
area.append(piece.text);
|
|
4018
|
+
placed = anchor;
|
|
4019
|
+
kept = true;
|
|
4020
|
+
}
|
|
4021
|
+
|
|
4022
|
+
if (placed[0] !== last[0]) { placed.insertAfter(last); }
|
|
4023
|
+
last = placed;
|
|
4024
|
+
});
|
|
4025
|
+
|
|
4026
|
+
if (!kept) { anchor.remove(); }
|
|
4027
|
+
});
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
/** Whether a run of nodes has anything in it but whitespace. */
|
|
4031
|
+
function hasContent(nodes) {
|
|
4032
|
+
return nodes.some(function(node) {
|
|
4033
|
+
return node.nodeType === 1 || (node.nodeType === 3 && /\S/.test(node.nodeValue));
|
|
4034
|
+
});
|
|
4035
|
+
}
|
|
4036
|
+
|
|
3952
4037
|
/**
|
|
3953
4038
|
* Wrap column content in <div class="ge-content"> where neccesary
|
|
3954
4039
|
*/
|
|
3955
|
-
function wrapContent() {
|
|
4040
|
+
function wrapContent(cutter) {
|
|
3956
4041
|
canvas.find('.column').each(function() {
|
|
3957
4042
|
var col = $(this);
|
|
3958
4043
|
var contents = $();
|
|
@@ -3966,10 +4051,10 @@ $.fn.gridEditor = function( optionsOrMethod ) {
|
|
|
3966
4051
|
// the next init.
|
|
3967
4052
|
if (child.is('.ge-tools-drawer, .ge-resize-handle')) { return; }
|
|
3968
4053
|
|
|
3969
|
-
// A container sits in the column beside
|
|
3970
|
-
// areas, not inside one, so it ends a run of
|
|
3971
|
-
// content rather than joining it
|
|
3972
|
-
if (child.is('.
|
|
4054
|
+
// A container, or an element, sits in the column beside
|
|
4055
|
+
// the content areas, not inside one, so it ends a run of
|
|
4056
|
+
// loose content rather than joining it
|
|
4057
|
+
if (child.is('.ge-content, .ge-text-block') || child.is(cutter)) {
|
|
3973
4058
|
contents = doWrap(contents);
|
|
3974
4059
|
} else {
|
|
3975
4060
|
contents = contents.add(child);
|
|
@@ -4511,401 +4596,4 @@ $.fn.gridEditor.locales = {
|
|
|
4511
4596
|
},
|
|
4512
4597
|
};
|
|
4513
4598
|
|
|
4514
|
-
})( jQuery );
|
|
4515
|
-
/**
|
|
4516
|
-
* tinyMCE for grid-editor's content areas.
|
|
4517
|
-
*
|
|
4518
|
-
* A text editor plugin: load this file after the editor, and tinyMCE 6
|
|
4519
|
-
* after or before it, and content_types: ['tinymce'] edits each content area
|
|
4520
|
-
* with an inline tinyMCE. What it can ask the editor for is the handle its
|
|
4521
|
-
* factory is called with, described in docs/plugins.md.
|
|
4522
|
-
*
|
|
4523
|
-
* <script src="tinymce/tinymce.min.js"></script>
|
|
4524
|
-
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
4525
|
-
* <script src="dist/plugins/grideditor.tinymce.min.js"></script>
|
|
4526
|
-
*
|
|
4527
|
-
* Up to 6.0 the main bundle carries a copy of this file too.
|
|
4528
|
-
*/
|
|
4529
|
-
(function($) {
|
|
4530
|
-
|
|
4531
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
4532
|
-
'text.tinymce': 'tinyMCE',
|
|
4533
|
-
});
|
|
4534
|
-
|
|
4535
|
-
// tinyMCE snapshots the target element's attributes when an inline editor is
|
|
4536
|
-
// created and restores them on remove(), so this has to run *after* remove()
|
|
4537
|
-
// to keep the grid editor's own class and tinyMCE's leftovers off the element.
|
|
4538
|
-
function cleanUp(contentArea) {
|
|
4539
|
-
contentArea
|
|
4540
|
-
.removeClass('active')
|
|
4541
|
-
.removeClass('ge-rte-active')
|
|
4542
|
-
.removeAttr('id')
|
|
4543
|
-
.removeAttr('style')
|
|
4544
|
-
.removeAttr('spellcheck')
|
|
4545
|
-
.removeAttr('contenteditable')
|
|
4546
|
-
.removeAttr('data-mce-style')
|
|
4547
|
-
;
|
|
4548
|
-
}
|
|
4549
|
-
|
|
4550
|
-
var INITIAL_CONTENT = '<p>Lorem ipsum dolores</p>';
|
|
4551
|
-
|
|
4552
|
-
$.fn.gridEditor.texts.tinymce = function(ge) {
|
|
4553
|
-
return {
|
|
4554
|
-
labelKey: 'text.tinymce',
|
|
4555
|
-
initialContent: INITIAL_CONTENT,
|
|
4556
|
-
missingKey: 'error.tinymce_missing',
|
|
4557
|
-
|
|
4558
|
-
available: function() { return !!window.tinymce; },
|
|
4559
|
-
|
|
4560
|
-
start: function(contentAreas) {
|
|
4561
|
-
var settings = ge.settings;
|
|
4562
|
-
var userConfig = (settings.tinymce && settings.tinymce.config) ? settings.tinymce.config : {};
|
|
4563
|
-
|
|
4564
|
-
contentAreas.each(function() {
|
|
4565
|
-
var contentArea = $(this);
|
|
4566
|
-
if (contentArea.hasClass('active')) { return; }
|
|
4567
|
-
|
|
4568
|
-
if (contentArea.html() == INITIAL_CONTENT) {
|
|
4569
|
-
contentArea.html('');
|
|
4570
|
-
}
|
|
4571
|
-
contentArea.addClass('active');
|
|
4572
|
-
|
|
4573
|
-
var configuration = $.extend({
|
|
4574
|
-
// tinyMCE's own "Upgrade" badge in the menubar. Off by
|
|
4575
|
-
// default because an inline editor here is a column of
|
|
4576
|
-
// someone's page, not tinyMCE's own interface; a host that
|
|
4577
|
-
// wants it back passes promotion: true.
|
|
4578
|
-
promotion: false,
|
|
4579
|
-
}, userConfig, {
|
|
4580
|
-
target: this,
|
|
4581
|
-
inline: true,
|
|
4582
|
-
init_instance_callback: function(editor) {
|
|
4583
|
-
// deinit ran before this init finished, so tear it down again
|
|
4584
|
-
if (contentArea.data('ge-tinymce-pending-remove')) {
|
|
4585
|
-
contentArea.removeData('ge-tinymce-pending-remove');
|
|
4586
|
-
editor.remove();
|
|
4587
|
-
// deinit already ran and cannot clean up after this
|
|
4588
|
-
// late remove(), so do it here instead
|
|
4589
|
-
cleanUp(contentArea);
|
|
4590
|
-
return;
|
|
4591
|
-
}
|
|
4592
|
-
|
|
4593
|
-
contentArea.data('ge-tinymce', editor);
|
|
4594
|
-
|
|
4595
|
-
// The editor rewrote what is inside this content area
|
|
4596
|
-
// while it took it over, so whatever the grid editor
|
|
4597
|
-
// had in there is gone. Saying so lets it put its own
|
|
4598
|
-
// furniture back.
|
|
4599
|
-
ge.textReady(contentArea);
|
|
4600
|
-
|
|
4601
|
-
// Undo and redo rewrite it too, from snapshots that
|
|
4602
|
-
// leave out whatever is marked data-mce-bogus - an
|
|
4603
|
-
// element's drawer among them - so it goes back in
|
|
4604
|
-
// after each of those as well
|
|
4605
|
-
editor.on('Undo Redo', function() {
|
|
4606
|
-
ge.textReady(contentArea);
|
|
4607
|
-
});
|
|
4608
|
-
|
|
4609
|
-
// The inline toolbar is laid out against the element's
|
|
4610
|
-
// geometry at the moment tinyMCE draws it, and an
|
|
4611
|
-
// element that has just appeared - a tab pane, an
|
|
4612
|
-
// accordion body, a column whose width is still
|
|
4613
|
-
// settling - may not have its own width yet. Asking
|
|
4614
|
-
// for the ui again once the browser has laid the frame
|
|
4615
|
-
// out measures it as it now is, instead of leaving a
|
|
4616
|
-
// toolbar wrapped into a narrow column.
|
|
4617
|
-
window.requestAnimationFrame(function() {
|
|
4618
|
-
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
4619
|
-
|
|
4620
|
-
editor.ui.show();
|
|
4621
|
-
});
|
|
4622
|
-
|
|
4623
|
-
// And again whenever the user comes back to this
|
|
4624
|
-
// editor: by then the element may have been resized,
|
|
4625
|
-
// hidden and shown again - a tab switched away from
|
|
4626
|
-
// and back, a column made narrower - and the toolbar
|
|
4627
|
-
// is only ever as right as its last measurement.
|
|
4628
|
-
editor.on('focus', function() {
|
|
4629
|
-
window.requestAnimationFrame(function() {
|
|
4630
|
-
if (editor.removed || !editor.ui || !editor.ui.show) { return; }
|
|
4631
|
-
|
|
4632
|
-
editor.ui.show();
|
|
4633
|
-
});
|
|
4634
|
-
});
|
|
4635
|
-
|
|
4636
|
-
// Bring focus to text field
|
|
4637
|
-
editor.focus();
|
|
4638
|
-
|
|
4639
|
-
// Call the original callbacks, if any were passed in the config
|
|
4640
|
-
if (userConfig.init_instance_callback) {
|
|
4641
|
-
userConfig.init_instance_callback.call(this, editor);
|
|
4642
|
-
}
|
|
4643
|
-
// 'oninit' is the pre-6 name, honoured so existing configs keep working
|
|
4644
|
-
if (userConfig.oninit) {
|
|
4645
|
-
userConfig.oninit.call(this, editor);
|
|
4646
|
-
}
|
|
4647
|
-
}
|
|
4648
|
-
});
|
|
4649
|
-
// We always edit the element we were handed, so a selector in the
|
|
4650
|
-
// user config would only fight with target
|
|
4651
|
-
delete configuration.selector;
|
|
4652
|
-
|
|
4653
|
-
window.tinymce.init(configuration);
|
|
4654
|
-
});
|
|
4655
|
-
},
|
|
4656
|
-
|
|
4657
|
-
stop: function(contentAreas) {
|
|
4658
|
-
contentAreas.filter('.active').each(function() {
|
|
4659
|
-
var contentArea = $(this);
|
|
4660
|
-
var editor = contentArea.data('ge-tinymce');
|
|
4661
|
-
|
|
4662
|
-
if (editor) {
|
|
4663
|
-
contentArea.removeData('ge-tinymce');
|
|
4664
|
-
editor.remove();
|
|
4665
|
-
} else {
|
|
4666
|
-
// tinymce.init() is asynchronous, so the editor may not exist
|
|
4667
|
-
// yet. Leave a note for init_instance_callback to remove it.
|
|
4668
|
-
contentArea.data('ge-tinymce-pending-remove', true);
|
|
4669
|
-
}
|
|
4670
|
-
|
|
4671
|
-
cleanUp(contentArea);
|
|
4672
|
-
});
|
|
4673
|
-
},
|
|
4674
|
-
};
|
|
4675
|
-
};
|
|
4676
|
-
})(jQuery);
|
|
4677
|
-
|
|
4678
|
-
/**
|
|
4679
|
-
* CKEditor for grid-editor's content areas.
|
|
4680
|
-
*
|
|
4681
|
-
* A text editor plugin: load this file after the editor, and CKEditor 4
|
|
4682
|
-
* after or before it, and content_types: ['ckeditor'] edits each content area
|
|
4683
|
-
* with an inline CKEditor. What it can ask the editor for is the handle its
|
|
4684
|
-
* factory is called with, described in docs/plugins.md.
|
|
4685
|
-
*
|
|
4686
|
-
* <script src="ckeditor/ckeditor.js"></script>
|
|
4687
|
-
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
4688
|
-
* <script src="dist/plugins/grideditor.ckeditor.min.js"></script>
|
|
4689
|
-
*
|
|
4690
|
-
* Up to 6.0 the main bundle carries a copy of this file too.
|
|
4691
|
-
*/
|
|
4692
|
-
(function($) {
|
|
4693
|
-
|
|
4694
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
4695
|
-
'text.ckeditor': 'CKEditor',
|
|
4696
|
-
});
|
|
4697
|
-
|
|
4698
|
-
var INITIAL_CONTENT = '<p>Lorem initius... </p>';
|
|
4699
|
-
|
|
4700
|
-
$.fn.gridEditor.texts.ckeditor = function(ge) {
|
|
4701
|
-
|
|
4702
|
-
/**
|
|
4703
|
-
* The instance editing this content area. Kept in jQuery data when it
|
|
4704
|
-
* is made, and looked for among CKEditor's own as a fallback, since
|
|
4705
|
-
* an instance made by another version of this file has no data.
|
|
4706
|
-
*/
|
|
4707
|
-
function instanceOf(contentArea) {
|
|
4708
|
-
var kept = contentArea.data('ge-ckeditor');
|
|
4709
|
-
if (kept) { return kept; }
|
|
4710
|
-
|
|
4711
|
-
var found = null;
|
|
4712
|
-
$.each(window.CKEDITOR.instances, function(name, instance) {
|
|
4713
|
-
if (instance.element && instance.element.$ === contentArea[0]) { found = instance; }
|
|
4714
|
-
});
|
|
4715
|
-
|
|
4716
|
-
return found;
|
|
4717
|
-
}
|
|
4718
|
-
|
|
4719
|
-
return {
|
|
4720
|
-
labelKey: 'text.ckeditor',
|
|
4721
|
-
initialContent: INITIAL_CONTENT,
|
|
4722
|
-
missingKey: 'error.ckeditor_missing',
|
|
4723
|
-
|
|
4724
|
-
available: function() { return !!window.CKEDITOR; },
|
|
4725
|
-
|
|
4726
|
-
start: function(contentAreas) {
|
|
4727
|
-
var settings = ge.settings;
|
|
4728
|
-
|
|
4729
|
-
contentAreas.each(function() {
|
|
4730
|
-
var contentArea = $(this);
|
|
4731
|
-
if (contentArea.hasClass('active')) { return; }
|
|
4732
|
-
|
|
4733
|
-
if (contentArea.html() == INITIAL_CONTENT) {
|
|
4734
|
-
// CKEditor kills this ' ' creating a non usable box :/
|
|
4735
|
-
contentArea.html(' ');
|
|
4736
|
-
}
|
|
4737
|
-
|
|
4738
|
-
// Add the .attr('contenteditable',''true') or CKEditor loads readonly
|
|
4739
|
-
contentArea.addClass('active').attr('contenteditable', 'true');
|
|
4740
|
-
|
|
4741
|
-
var configuration = $.extend(
|
|
4742
|
-
{},
|
|
4743
|
-
(settings.ckeditor && settings.ckeditor.config ? settings.ckeditor.config : {}),
|
|
4744
|
-
{
|
|
4745
|
-
// Focus editor on creation
|
|
4746
|
-
on: {
|
|
4747
|
-
instanceReady: function( evt ) {
|
|
4748
|
-
// Call original instanceReady function, if one was passed in the config
|
|
4749
|
-
var callback;
|
|
4750
|
-
try {
|
|
4751
|
-
callback = settings.ckeditor.config.on.instanceReady;
|
|
4752
|
-
} catch (err) {
|
|
4753
|
-
// No callback passed
|
|
4754
|
-
}
|
|
4755
|
-
if (callback) {
|
|
4756
|
-
callback.call(this, evt);
|
|
4757
|
-
}
|
|
4758
|
-
|
|
4759
|
-
// The editor owns what is inside the
|
|
4760
|
-
// content area now, so the grid editor is
|
|
4761
|
-
// told to put its own furniture back
|
|
4762
|
-
ge.textReady(contentArea);
|
|
4763
|
-
|
|
4764
|
-
instance.focus();
|
|
4765
|
-
}
|
|
4766
|
-
}
|
|
4767
|
-
}
|
|
4768
|
-
);
|
|
4769
|
-
var instance = window.CKEDITOR.inline(contentArea.get(0), configuration);
|
|
4770
|
-
contentArea.data('ge-ckeditor', instance);
|
|
4771
|
-
});
|
|
4772
|
-
},
|
|
4773
|
-
|
|
4774
|
-
stop: function(contentAreas) {
|
|
4775
|
-
contentAreas.filter('.active').each(function() {
|
|
4776
|
-
var contentArea = $(this);
|
|
4777
|
-
|
|
4778
|
-
// This content area's instance, and no other: up to 5.x
|
|
4779
|
-
// closing one content area destroyed every CKEditor on
|
|
4780
|
-
// the page, other editors' and the host's own included
|
|
4781
|
-
var instance = window.CKEDITOR ? instanceOf(contentArea) : null;
|
|
4782
|
-
if (instance) { instance.destroy(); }
|
|
4783
|
-
contentArea.removeData('ge-ckeditor');
|
|
4784
|
-
|
|
4785
|
-
// Cleanup
|
|
4786
|
-
contentArea
|
|
4787
|
-
.removeClass('active cke_focus')
|
|
4788
|
-
.removeAttr('id')
|
|
4789
|
-
.removeAttr('style')
|
|
4790
|
-
.removeAttr('spellcheck')
|
|
4791
|
-
.removeAttr('contenteditable')
|
|
4792
|
-
;
|
|
4793
|
-
});
|
|
4794
|
-
},
|
|
4795
|
-
};
|
|
4796
|
-
};
|
|
4797
|
-
})(jQuery);
|
|
4798
|
-
|
|
4799
|
-
/**
|
|
4800
|
-
* Summernote for grid-editor's content areas.
|
|
4801
|
-
*
|
|
4802
|
-
* A text editor plugin: load this file after the editor, and summernote
|
|
4803
|
-
* after or before it, and content_types: ['summernote'] edits each content
|
|
4804
|
-
* area with summernote in air mode. What it can ask the editor for is the
|
|
4805
|
-
* handle its factory is called with, described in docs/plugins.md.
|
|
4806
|
-
*
|
|
4807
|
-
* <script src="summernote/summernote-bs5.min.js"></script>
|
|
4808
|
-
* <script src="dist/jquery.grideditor.min.js"></script>
|
|
4809
|
-
* <script src="dist/plugins/grideditor.summernote.min.js"></script>
|
|
4810
|
-
*
|
|
4811
|
-
* Up to 6.0 the main bundle carries a copy of this file too.
|
|
4812
|
-
*/
|
|
4813
|
-
(function($) {
|
|
4814
|
-
|
|
4815
|
-
$.extend($.fn.gridEditor.locales.en, {
|
|
4816
|
-
'text.summernote': 'Summernote',
|
|
4817
|
-
});
|
|
4818
|
-
|
|
4819
|
-
var INITIAL_CONTENT = '<p>Lorem ipsum dolores</p>';
|
|
4820
|
-
|
|
4821
|
-
$.fn.gridEditor.texts.summernote = function(ge) {
|
|
4822
|
-
return {
|
|
4823
|
-
labelKey: 'text.summernote',
|
|
4824
|
-
initialContent: INITIAL_CONTENT,
|
|
4825
|
-
missingKey: 'error.summernote_missing',
|
|
4826
|
-
|
|
4827
|
-
available: function() { return !!$.fn.summernote; },
|
|
4828
|
-
|
|
4829
|
-
start: function(contentAreas) {
|
|
4830
|
-
var settings = ge.settings;
|
|
4831
|
-
|
|
4832
|
-
// Summernote 0.9.1 calls $.now(), which jQuery 4 removed, and
|
|
4833
|
-
// cannot open without it. Given back only where it is missing,
|
|
4834
|
-
// and only once summernote is actually used.
|
|
4835
|
-
if (!$.now) { $.now = Date.now; }
|
|
4836
|
-
|
|
4837
|
-
contentAreas.each(function() {
|
|
4838
|
-
var contentArea = $(this);
|
|
4839
|
-
if (contentArea.hasClass('active')) { return; }
|
|
4840
|
-
|
|
4841
|
-
if (contentArea.html() == INITIAL_CONTENT) {
|
|
4842
|
-
contentArea.html('');
|
|
4843
|
-
}
|
|
4844
|
-
contentArea.addClass('active');
|
|
4845
|
-
|
|
4846
|
-
var configuration = $.extend(
|
|
4847
|
-
true, // deep copy
|
|
4848
|
-
{},
|
|
4849
|
-
(settings.summernote && settings.summernote.config ? settings.summernote.config : {}),
|
|
4850
|
-
{
|
|
4851
|
-
tabsize: 2,
|
|
4852
|
-
airMode: true,
|
|
4853
|
-
// Focus editor on creation
|
|
4854
|
-
callbacks: {
|
|
4855
|
-
onInit: function() {
|
|
4856
|
-
|
|
4857
|
-
// Call original oninit function, if one was passed in the config
|
|
4858
|
-
var callback;
|
|
4859
|
-
try {
|
|
4860
|
-
callback = settings.summernote.config.callbacks.onInit;
|
|
4861
|
-
} catch (err) {
|
|
4862
|
-
// No callback passed
|
|
4863
|
-
}
|
|
4864
|
-
if (callback) {
|
|
4865
|
-
callback.call(this);
|
|
4866
|
-
}
|
|
4867
|
-
|
|
4868
|
-
// The editor owns what is inside the
|
|
4869
|
-
// content area now, so the grid editor is
|
|
4870
|
-
// told to put its own furniture back
|
|
4871
|
-
ge.textReady(contentArea);
|
|
4872
|
-
|
|
4873
|
-
contentArea.summernote('focus');
|
|
4874
|
-
}
|
|
4875
|
-
}
|
|
4876
|
-
}
|
|
4877
|
-
);
|
|
4878
|
-
contentArea.summernote(configuration);
|
|
4879
|
-
});
|
|
4880
|
-
},
|
|
4881
|
-
|
|
4882
|
-
stop: function(contentAreas) {
|
|
4883
|
-
contentAreas.filter('.active').each(function() {
|
|
4884
|
-
var contentArea = $(this);
|
|
4885
|
-
contentArea.summernote('destroy');
|
|
4886
|
-
contentArea
|
|
4887
|
-
.removeClass('active')
|
|
4888
|
-
.removeAttr('id')
|
|
4889
|
-
.removeAttr('style')
|
|
4890
|
-
.removeAttr('spellcheck')
|
|
4891
|
-
;
|
|
4892
|
-
});
|
|
4893
|
-
},
|
|
4894
|
-
};
|
|
4895
|
-
};
|
|
4896
|
-
})(jQuery);
|
|
4897
|
-
|
|
4898
|
-
/**
|
|
4899
|
-
* Up to 6.0 the main bundle carries a copy of each text editor plugin, so a
|
|
4900
|
-
* page that loaded only the editor keeps the editor it had. This marks those
|
|
4901
|
-
* copies, and the editor warns once when a content area is edited with one:
|
|
4902
|
-
* 6.0 leaves them out. Loaded on its own, a plugin's file registers itself
|
|
4903
|
-
* again, unmarked, and is the one used.
|
|
4904
|
-
*
|
|
4905
|
-
* Only ever concatenated after the plugins it marks, never built on its own.
|
|
4906
|
-
*/
|
|
4907
|
-
(function($) {
|
|
4908
|
-
['tinymce', 'ckeditor', 'summernote'].forEach(function(type) {
|
|
4909
|
-
if ($.fn.gridEditor.texts[type]) { $.fn.gridEditor.texts[type].bundled = true; }
|
|
4910
|
-
});
|
|
4911
|
-
})(jQuery);
|
|
4599
|
+
})( jQuery );
|