core/modules/ckeditor/ckeditor.module | 2 +-
.../js/plugins/drupalimagecaption/plugin.js | 18 ++++-
.../js/plugins/drupalimagecaption/theme.js | 5 ++
.../Plugin/CKEditorPlugin/DrupalImageCaption.php | 2 +-
.../lib/Drupal/editor/Form/EditorImageDialog.php | 69 ++++++++++----------
5 files changed, 57 insertions(+), 39 deletions(-)
diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module
index ea02cfb..24a0f85 100644
--- a/core/modules/ckeditor/ckeditor.module
+++ b/core/modules/ckeditor/ckeditor.module
@@ -150,7 +150,7 @@ function ckeditor_theme() {
function ckeditor_ckeditor_css_alter(array &$css, Editor $editor) {
$filters = array();
if (!empty($editor->format)) {
- $filters = filter_format_load($editor->format)
+ $filters = entity_load('filter_format', $editor->format)
->filters()
->getAll();
}
diff --git a/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
index 944bc74..eeb6c7b 100644
--- a/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
+++ b/core/modules/ckeditor/js/plugins/drupalimagecaption/plugin.js
@@ -38,6 +38,7 @@ CKEDITOR.plugins.add('drupalimagecaption', {
// Save the initial widget data.
this.setData({
+ 'data-editor-file-uuid': image.getAttribute('data-editor-file-uuid'),
src: image.getAttribute('src'),
width: image.getAttribute('width') || '',
height: image.getAttribute('height') || '',
@@ -54,10 +55,18 @@ CKEDITOR.plugins.add('drupalimagecaption', {
// Called after initialization and on "data" changes.
data: function () {
+ if (this.data['data-editor-file-uuid'] !== null) {
+ this.parts.image.setAttribute('data-editor-file-uuid', this.data['data-editor-file-uuid']);
+ this.parts.image.setAttribute('data-cke-saved-data-editor-file-uuid', this.data['data-editor-file-uuid']);
+ }
this.parts.image.setAttribute('src', this.data.src);
+ this.parts.image.setAttribute('data-cke-saved-src', this.data.src);
this.parts.image.setAttribute('alt', this.data.alt);
+ this.parts.image.setAttribute('data-cke-saved-alt', this.data.alt);
this.parts.image.setAttribute('width', this.data.width);
+ this.parts.image.setAttribute('data-cke-saved-width', this.data.width);
this.parts.image.setAttribute('height', this.data.height);
+ this.parts.image.setAttribute('data-cke-saved-height', this.data.height);
// Float the wrapper too.
if (this.data.data_align === null) {
@@ -119,18 +128,23 @@ CKEDITOR.plugins.add('drupalimagecaption', {
return;
}
+ editor.fire('saveSnapshot');
+
// Build the HTML for the widget.
var html = '';
var el = new CKEDITOR.dom.element.createFromHtml(html, editor.document);
@@ -161,10 +175,10 @@ CKEDITOR.plugins.add('drupalimagecaption', {
edit: function () {
var that = this;
var saveCallback = function (returnValues) {
- // Save snapshot for undo support.
editor.fire('saveSnapshot');
// Set the updated widget data.
that.setData({
+ 'data-editor-file-uuid': returnValues.attributes['data-editor-file-uuid'],
src: returnValues.attributes.src,
width: returnValues.attributes.width,
height: returnValues.attributes.height,
@@ -173,6 +187,8 @@ CKEDITOR.plugins.add('drupalimagecaption', {
data_caption: returnValues.hasCaption ? that.data.data_caption : '',
data_align: returnValues.attributes.data_align === 'none' ? null : returnValues.attributes.data_align
});
+ // Save snapshot for undo support.
+ editor.fire('saveSnapshot');
};
var override = {
imageDOMElement: this.parts.image.$,
diff --git a/core/modules/ckeditor/js/plugins/drupalimagecaption/theme.js b/core/modules/ckeditor/js/plugins/drupalimagecaption/theme.js
index d35ddb5..8d9e872 100644
--- a/core/modules/ckeditor/js/plugins/drupalimagecaption/theme.js
+++ b/core/modules/ckeditor/js/plugins/drupalimagecaption/theme.js
@@ -152,6 +152,8 @@ CKEDITOR.on('instanceCreated', function (event) {
return;
}
+ editor.fire('saveSnapshot');
+
// Build the HTML for the widget.
var html = '