ckeditor_wave 2.0.1 → 2.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8206aa6860a27f3e478e6e0d1450b50e279b79a84e7fc104f4bbfce4aa25919c
4
- data.tar.gz: 342fc1254f476c082913dfe3dc0c4839cde37db2fc84445fbdfb027a71919eb8
3
+ metadata.gz: 7c2b4cc2e99d75ebd00d30430b0a3f3bbaf763484f9a91bc0b113cb63e85a372
4
+ data.tar.gz: b0acaa37c67b369d3c6bf2c41b35fb4174d851ba1ff6582bf66e412b3636c84f
5
5
  SHA512:
6
- metadata.gz: 8b13a5c0b24cf4c169bdc9b8ea96b0aa07f77df5e26e0587227af04f9643fab3d025854e603c70aa8d11e286b68fa4877dabb6e718bd68e7e71245953614de92
7
- data.tar.gz: 9f3287fd2dc39537f28a86898ddedae8ed4b0d59392870d3f544707373b041eb7b93b4f73e97f60b07985c56640a109cca0e4421ab4788b32bd58da95a45f70a
6
+ metadata.gz: 5c89ee6c057e699de8cf2526b41feaf38cf2ba08aebdd7018a5a5333c42c17d79c1431ad837763a2141a246036b373a5b1a7834bbf76d200fb0261bc2fbaa3f1
7
+ data.tar.gz: 56f72975b9d1564e84d0551e5f7d5970def59a3318118d654cce199a120f9cab8caadb540242f466178743834b0e37afbded964d8f3ca647fae453ebb99d2157
data/README.md CHANGED
@@ -36,10 +36,12 @@ mount CkeditorWave::Engine => 'ckeditor_wave'
36
36
  ```
37
37
 
38
38
 
39
- To attach [CKEditor 5](https://docs.ckeditor.com/ckeditor5/) to HTML forms, call the initiateCkeditor() function inside your application.js by giving it one or more CSS selectors as arguments. For example:
39
+ To attach [CKEditor 5](https://docs.ckeditor.com/ckeditor5/) to HTML forms, call the initiateCkeditor() function inside your application.js by wrapping in in a DOMContentLoaded EventListener and giving it one or more CSS selectors as arguments. For example:
40
40
 
41
41
  ```
42
- initiateCkeditor('#editor1', '#editor2', '#editor3')
42
+ document.addEventListener('DOMContentLoaded', () => {
43
+ initiateCkeditor('#editor1', '#editor2', '#editor3');
44
+ });
43
45
  ```
44
46
 
45
47
  ## Dependencies
@@ -1 +1 @@
1
- 'use strict';var _createClass=function(){function a(b,c){for(var e,d=0;d<c.length;d++)e=c[d],e.enumerable=e.enumerable||!1,e.configurable=!0,'value'in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function initiateCkeditor(){var a=Array.from(arguments);document.addEventListener('DOMContentLoaded',function(){a.forEach(function(b){newEditor(b)})})}function newEditor(a){var a=document.querySelector(a);if(null===a)return!1;try{ClassicEditor.create(a).then(function(b){b.plugins.get('FileRepository').createUploadAdapter=function(c){return new UploadAdapter(c)},document.querySelector('.ck-content').addEventListener('DOMNodeRemoved',function(c){var d=c.target,e=d.className.split(' ');e.includes('image')&&server.destroy(id(d.children[0]))})}).catch(function(b){console.error(b)})}catch(b){console.log(b),console.log('Is ckeditor.js included?','https://ckeditor.com/ckeditor-5/download/')}}var UploadAdapter=function(){function a(b){_classCallCheck(this,a),this.loader=b}return _createClass(a,[{key:'upload',value:function(){return server.upload(this.loader.file)}}]),a}(),server={upload:upload,destroy:destroy};function upload(a){return new Promise(function(b,c){var d=new XMLHttpRequest,e=new FormData;d.onreadystatechange=function(){4===d.readyState&&200!==d.status&&c('Image upload failed'),4===d.readyState&&200===d.status&&(b({default:d.responseText}),console.log('Image upload successful'))},e.set('ck_image',a),d.open('POST','/ckeditor_wave/ck_images'),d.send(e)})}function destroy(a){var b=new XMLHttpRequest,c=new FormData;b.onreadystatechange=function(){4===b.readyState&&200!==b.status&&console.log('Image deletion failed'),4===b.readyState&&200===b.status&&console.log(b.responseText)},c.set('method','delete'),b.open('DELETE','/ckeditor_wave/ck_images/'+a),b.send(c)}function id(a){var b=a.src.match(/[^\/]*.$/g).toString();return b.match(/[^.]*/)}
1
+ 'use strict';var _createClass=function(){function a(b,c){for(var e,d=0;d<c.length;d++)e=c[d],e.enumerable=e.enumerable||!1,e.configurable=!0,'value'in e&&(e.writable=!0),Object.defineProperty(b,e.key,e)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}();function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function initiateCkeditor(){var a=Array.from(arguments);a.forEach(function(b){newEditor(b)})}function newEditor(a){var a=document.querySelector(a);if(null===a)return!1;try{ClassicEditor.create(a).then(function(b){b.plugins.get('FileRepository').createUploadAdapter=function(c){return new UploadAdapter(c)},a.nextSibling.querySelector('.ck-content').addEventListener('DOMNodeRemoved',function(c){var d=c.target,e=d.className.split(' ');e.includes('image')&&server.destroy(id(d.children[0]))})}).catch(function(b){console.error(b)})}catch(b){console.log(b),console.log('Is ckeditor.js included?','https://ckeditor.com/ckeditor-5/download/')}}var UploadAdapter=function(){function a(b){_classCallCheck(this,a),this.loader=b}return _createClass(a,[{key:'upload',value:function(){return server.upload(this.loader.file)}}]),a}(),server={upload:upload,destroy:destroy};function upload(a){return new Promise(function(b,c){var d=new XMLHttpRequest,e=new FormData;d.onreadystatechange=function(){4===d.readyState&&200!==d.status&&c('Image upload failed'),4===d.readyState&&200===d.status&&(b({default:d.responseText}),console.log('Image upload successful'))},e.set('ck_image',a),d.open('POST','/ckeditor_wave/ck_images'),d.send(e)})}function destroy(a){var b=new XMLHttpRequest,c=new FormData;b.onreadystatechange=function(){4===b.readyState&&200!==b.status&&console.log('Image deletion failed'),4===b.readyState&&200===b.status&&console.log(b.responseText)},c.set('method','delete'),b.open('DELETE','/ckeditor_wave/ck_images/'+a),b.send(c)}function id(a){var b=a.src.match(/[^\/]*.$/g).toString();return b.match(/[^.]*/)}
@@ -1,24 +1,23 @@
1
1
  function initiateCkeditor() {
2
2
  var editors = Array.from(arguments);
3
- document.addEventListener('DOMContentLoaded', () => {
4
3
  editors.forEach(function(editor){
5
- newEditor(editor)
4
+ newEditor(editor);
6
5
  });
7
- });
8
6
  }
9
7
 
10
- function newEditor(editor) {
11
- var editor = document.querySelector(editor);
8
+ function newEditor(ck_editor) {
9
+ var ck_editor = document.querySelector(ck_editor);
12
10
 
13
- if (editor === null) return false
11
+ if (ck_editor === null) return false;
14
12
  try{
15
13
  ClassicEditor
16
- .create(editor)
14
+ .create(ck_editor)
17
15
  .then(editor => {
18
16
  editor.plugins.get('FileRepository').createUploadAdapter = (loader) => {
19
17
  return new UploadAdapter(loader);
20
18
  };
21
- document.querySelector('.ck-content').addEventListener(
19
+
20
+ ck_editor.nextSibling.querySelector('.ck-content').addEventListener(
22
21
  'DOMNodeRemoved', (event) => {
23
22
  var element = event.target;
24
23
  var classes = element.className.split(' ');
@@ -1,3 +1,3 @@
1
1
  module CkeditorWave
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ckeditor_wave
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeni Radev
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 2.7.6
101
+ rubygems_version: 2.7.4
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: This gem integrates CKEditor 5 with CarrierWave to allow image upload.