@themarioga/grid-editor 5.1.1 → 5.2.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.
Files changed (41) hide show
  1. package/BUILDING.md +6 -0
  2. package/CHANGELOG.md +45 -0
  3. package/README.md +18 -8
  4. package/UPGRADING.md +25 -0
  5. package/dist/grideditor.css +3 -0
  6. package/dist/grideditor.min.css +1 -1
  7. package/dist/grideditor.min.css.map +1 -1
  8. package/dist/jquery.grideditor.bundle.min.js +2 -2
  9. package/dist/jquery.grideditor.js +374 -218
  10. package/dist/jquery.grideditor.min.js +1 -1
  11. package/dist/jquery.grideditor.min.js.map +1 -1
  12. package/dist/plugins/grideditor.ckeditor.js +115 -0
  13. package/dist/plugins/grideditor.ckeditor.min.js +2 -0
  14. package/dist/plugins/grideditor.ckeditor.min.js.map +1 -0
  15. package/dist/plugins/grideditor.summernote.js +93 -0
  16. package/dist/plugins/grideditor.summernote.min.js +2 -0
  17. package/dist/plugins/grideditor.summernote.min.js.map +1 -0
  18. package/dist/plugins/grideditor.tinymce.js +157 -0
  19. package/dist/plugins/grideditor.tinymce.min.js +2 -0
  20. package/dist/plugins/grideditor.tinymce.min.js.map +1 -0
  21. package/docs/plugins.md +86 -3
  22. package/example/attributes.html +364 -0
  23. package/example/autosave.html +2 -0
  24. package/example/basic.html +2 -0
  25. package/example/ckeditor.html +2 -0
  26. package/example/clipboard.html +2 -0
  27. package/example/containers.html +2 -0
  28. package/example/elements.html +2 -0
  29. package/example/index.html +8 -0
  30. package/example/summernote.html +2 -0
  31. package/example/wrap_content.html +2 -0
  32. package/package.json +1 -1
  33. package/src/js/compat/bundled-texts.js +14 -0
  34. package/src/js/jquery.grideditor.js +73 -14
  35. package/src/js/plugins/grideditor.ckeditor.js +115 -0
  36. package/src/js/plugins/grideditor.summernote.js +93 -0
  37. package/src/js/plugins/grideditor.tinymce.js +157 -0
  38. package/src/less/grideditor.less +4 -0
  39. package/src/js/jquery.grideditor.ckeditor.js +0 -77
  40. package/src/js/jquery.grideditor.summernote.js +0 -72
  41. package/src/js/jquery.grideditor.tinymce.js +0 -135
@@ -1,77 +0,0 @@
1
- (function($) {
2
- $.fn.gridEditor.RTEs.ckeditor = {
3
-
4
- init: function(settings, contentAreas) {
5
-
6
- if (!window.CKEDITOR) {
7
- console.error($.fn.gridEditor.t(settings, 'error.ckeditor_missing'));
8
- }
9
-
10
- var self = this;
11
- contentAreas.each(function() {
12
- var contentArea = $(this);
13
- if (!contentArea.hasClass('active')) {
14
- if (contentArea.html() == self.initialContent) {
15
- // CKEditor kills this '&nbsp' creating a non usable box :/
16
- contentArea.html(' ');
17
- }
18
-
19
- // Add the .attr('contenteditable',''true') or CKEditor loads readonly
20
- contentArea.addClass('active').attr('contenteditable', 'true');
21
-
22
- var configuration = $.extend(
23
- {},
24
- (settings.ckeditor && settings.ckeditor.config ? settings.ckeditor.config : {}),
25
- {
26
- // Focus editor on creation
27
- on: {
28
- instanceReady: function( evt ) {
29
- // Call original instanceReady function, if one was passed in the config
30
- var callback;
31
- try {
32
- callback = settings.ckeditor.config.on.instanceReady;
33
- } catch (err) {
34
- // No callback passed
35
- }
36
- if (callback) {
37
- callback.call(this, evt);
38
- }
39
-
40
- // The editor owns what is inside the
41
- // content area now, so the grid editor is
42
- // told to put its own furniture back
43
- contentArea.trigger('ge-rte-ready');
44
-
45
- instance.focus();
46
- }
47
- }
48
- }
49
- );
50
- var instance = CKEDITOR.inline(contentArea.get(0), configuration);
51
- }
52
- });
53
- },
54
-
55
- deinit: function(settings, contentAreas) {
56
- contentAreas.filter('.active').each(function() {
57
- var contentArea = $(this);
58
-
59
- // Destroy all CKEditor instances
60
- $.each(CKEDITOR.instances, function(_, instance) {
61
- instance.destroy();
62
- });
63
-
64
- // Cleanup
65
- contentArea
66
- .removeClass('active cke_focus')
67
- .removeAttr('id')
68
- .removeAttr('style')
69
- .removeAttr('spellcheck')
70
- .removeAttr('contenteditable')
71
- ;
72
- });
73
- },
74
-
75
- initialContent: '<p>Lorem initius... </p>',
76
- };
77
- })(jQuery);
@@ -1,72 +0,0 @@
1
- (function($) {
2
-
3
- $.fn.gridEditor.RTEs.summernote = {
4
-
5
- init: function(settings, contentAreas) {
6
-
7
- if (!jQuery().summernote) {
8
- console.error($.fn.gridEditor.t(settings, 'error.summernote_missing'));
9
- }
10
-
11
- var self = this;
12
- contentAreas.each(function() {
13
- var contentArea = $(this);
14
- if (!contentArea.hasClass('active')) {
15
- if (contentArea.html() == self.initialContent) {
16
- contentArea.html('');
17
- }
18
- contentArea.addClass('active');
19
-
20
- var configuration = $.extend(
21
- true, // deep copy
22
- {},
23
- (settings.summernote && settings.summernote.config ? settings.summernote.config : {}),
24
- {
25
- tabsize: 2,
26
- airMode: true,
27
- // Focus editor on creation
28
- callbacks: {
29
- onInit: function() {
30
-
31
- // Call original oninit function, if one was passed in the config
32
- var callback;
33
- try {
34
- callback = settings.summernote.config.callbacks.onInit;
35
- } catch (err) {
36
- // No callback passed
37
- }
38
- if (callback) {
39
- callback.call(this);
40
- }
41
-
42
- // The editor owns what is inside the
43
- // content area now, so the grid editor is
44
- // told to put its own furniture back
45
- contentArea.trigger('ge-rte-ready');
46
-
47
- contentArea.summernote('focus');
48
- }
49
- }
50
- }
51
- );
52
- contentArea.summernote(configuration);
53
- }
54
- });
55
- },
56
-
57
- deinit: function(settings, contentAreas) {
58
- contentAreas.filter('.active').each(function() {
59
- var contentArea = $(this);
60
- contentArea.summernote('destroy');
61
- contentArea
62
- .removeClass('active')
63
- .removeAttr('id')
64
- .removeAttr('style')
65
- .removeAttr('spellcheck')
66
- ;
67
- });
68
- },
69
-
70
- initialContent: '<p>Lorem ipsum dolores</p>',
71
- };
72
- })(jQuery);
@@ -1,135 +0,0 @@
1
- (function($) {
2
-
3
- // tinyMCE snapshots the target element's attributes when an inline editor is
4
- // created and restores them on remove(), so this has to run *after* remove()
5
- // to keep the grid editor's own class and tinyMCE's leftovers off the element.
6
- function cleanUp(contentArea) {
7
- contentArea
8
- .removeClass('active')
9
- .removeClass('ge-rte-active')
10
- .removeAttr('id')
11
- .removeAttr('style')
12
- .removeAttr('spellcheck')
13
- .removeAttr('contenteditable')
14
- .removeAttr('data-mce-style')
15
- ;
16
- }
17
-
18
- $.fn.gridEditor.RTEs.tinymce = {
19
-
20
- init: function(settings, contentAreas) {
21
-
22
- if (!window.tinymce) {
23
- console.error($.fn.gridEditor.t(settings, 'error.tinymce_missing'));
24
- return;
25
- }
26
-
27
- var self = this;
28
- var userConfig = (settings.tinymce && settings.tinymce.config) ? settings.tinymce.config : {};
29
-
30
- contentAreas.each(function() {
31
- var contentArea = $(this);
32
- if (contentArea.hasClass('active')) { return; }
33
-
34
- if (contentArea.html() == self.initialContent) {
35
- contentArea.html('');
36
- }
37
- contentArea.addClass('active');
38
-
39
- var configuration = $.extend({
40
- // tinyMCE's own "Upgrade" badge in the menubar. Off by
41
- // default because an inline editor here is a column of
42
- // someone's page, not tinyMCE's own interface; a host that
43
- // wants it back passes promotion: true.
44
- promotion: false,
45
- }, userConfig, {
46
- target: this,
47
- inline: true,
48
- init_instance_callback: function(editor) {
49
- // deinit ran before this init finished, so tear it down again
50
- if (contentArea.data('ge-tinymce-pending-remove')) {
51
- contentArea.removeData('ge-tinymce-pending-remove');
52
- editor.remove();
53
- // deinit already ran and cannot clean up after this
54
- // late remove(), so do it here instead
55
- cleanUp(contentArea);
56
- return;
57
- }
58
-
59
- contentArea.data('ge-tinymce', editor);
60
-
61
- // The editor rewrote what is inside this content area
62
- // while it took it over, so whatever the grid editor
63
- // had in there is gone. Saying so lets it put its own
64
- // furniture back (see RTE_READY in the core).
65
- contentArea.trigger('ge-rte-ready');
66
-
67
- // The inline toolbar is laid out against the element's
68
- // geometry at the moment tinyMCE draws it, and an
69
- // element that has just appeared - a tab pane, an
70
- // accordion body, a column whose width is still
71
- // settling - may not have its own width yet. Asking
72
- // for the ui again once the browser has laid the frame
73
- // out measures it as it now is, instead of leaving a
74
- // toolbar wrapped into a narrow column.
75
- window.requestAnimationFrame(function() {
76
- if (editor.removed || !editor.ui || !editor.ui.show) { return; }
77
-
78
- editor.ui.show();
79
- });
80
-
81
- // And again whenever the user comes back to this
82
- // editor: by then the element may have been resized,
83
- // hidden and shown again - a tab switched away from
84
- // and back, a column made narrower - and the toolbar
85
- // is only ever as right as its last measurement.
86
- editor.on('focus', function() {
87
- window.requestAnimationFrame(function() {
88
- if (editor.removed || !editor.ui || !editor.ui.show) { return; }
89
-
90
- editor.ui.show();
91
- });
92
- });
93
-
94
- // Bring focus to text field
95
- editor.focus();
96
-
97
- // Call the original callbacks, if any were passed in the config
98
- if (userConfig.init_instance_callback) {
99
- userConfig.init_instance_callback.call(this, editor);
100
- }
101
- // 'oninit' is the pre-6 name, honoured so existing configs keep working
102
- if (userConfig.oninit) {
103
- userConfig.oninit.call(this, editor);
104
- }
105
- }
106
- });
107
- // We always edit the element we were handed, so a selector in the
108
- // user config would only fight with target
109
- delete configuration.selector;
110
-
111
- window.tinymce.init(configuration);
112
- });
113
- },
114
-
115
- deinit: function(settings, contentAreas) {
116
- contentAreas.filter('.active').each(function() {
117
- var contentArea = $(this);
118
- var editor = contentArea.data('ge-tinymce');
119
-
120
- if (editor) {
121
- contentArea.removeData('ge-tinymce');
122
- editor.remove();
123
- } else {
124
- // tinymce.init() is asynchronous, so the editor may not exist
125
- // yet. Leave a note for init_instance_callback to remove it.
126
- contentArea.data('ge-tinymce-pending-remove', true);
127
- }
128
-
129
- cleanUp(contentArea);
130
- });
131
- },
132
-
133
- initialContent: '<p>Lorem ipsum dolores</p>',
134
- };
135
- })(jQuery);