diff --git a/core/modules/ckeditor/ckeditor.libraries.yml b/core/modules/ckeditor/ckeditor.libraries.yml index 902cb99..68ea65b 100644 --- a/core/modules/ckeditor/ckeditor.libraries.yml +++ b/core/modules/ckeditor/ckeditor.libraries.yml @@ -15,6 +15,12 @@ drupal.ckeditor: # Ensure to run after core/matchmedia. - core/matchmedia +drupal.ckeditor.plugins.drupalimage.drag-and-drop-uploads: + version: VERSION + css: + component: + css/plugins/drupalimage/ckeditor.drag-and-drop-uploads.css: {} + drupal.ckeditor.plugins.drupalimagecaption: version: VERSION css: diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 115afe2..54f4793 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -65,6 +65,9 @@ function ckeditor_ckeditor_css_alter(array &$css, Editor $editor) { if ($editor->getFilterFormat()->filters('filter_caption')->status) { $css[] = drupal_get_path('module', 'filter') . '/css/filter.caption.css'; } + + // Add the drupalimage drag-and-drop CSS to enhance UX. + $css[] = drupal_get_path('module', 'ckeditor') . '/css/plugins/drupalimage/ckeditor.drag-and-drop-uploads.css'; } /** diff --git a/core/modules/ckeditor/css/plugins/drupalimage/ckeditor.drag-and-drop-uploads.css b/core/modules/ckeditor/css/plugins/drupalimage/ckeditor.drag-and-drop-uploads.css new file mode 100644 index 0000000..cc29f91 --- /dev/null +++ b/core/modules/ckeditor/css/plugins/drupalimage/ckeditor.drag-and-drop-uploads.css @@ -0,0 +1,6 @@ +/** + * Needed in CKEditor, to enhance the UX of the drag-and-drop image uploading. + */ +img[data-cke-drupalimage-preview] { + opacity: 0.3; +} diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js index 2868daa..5f34daa 100644 --- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js +++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js @@ -273,7 +273,6 @@ supportedTypes: /image\/(gif|png|jpg|jpeg)/, fileToElement: function () { var el = new CKEDITOR.dom.element('span'); - el.addClass('cke_upload_uploading'); el.setText('Loading...'); return el; }, @@ -281,8 +280,6 @@ var el = new CKEDITOR.dom.element('img'); el.setAttribute('data-cke-drupalimage-preview', true); el.setAttribute('src', loader.data); - //this.replaceWith(''); - console.log(el) this.replaceWith(el.getOuterHtml()); } }); diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index 170305d..641e607 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -365,6 +365,7 @@ public function getLangcodes() { public function getLibraries(Editor $editor) { $libraries = array( 'ckeditor/drupal.ckeditor', + 'ckeditor/drupal.ckeditor.plugins.drupalimage.drag-and-drop-uploads', ); // Get the required libraries for any enabled plugins.