Skip to content
Snippets Groups Projects
Commit de0f3ab3 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2071957 by Wim Leers: Fixed Cannot change existing images or links...

Issue #2071957 by Wim Leers: Fixed Cannot change existing images or links through Text Editor's image/link dialogs.
parent c3c67435
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -26,15 +26,23 @@ CKEDITOR.plugins.add('drupalimage', {
existingValues.width = imageDOMElement ? imageDOMElement.width : '';
existingValues.height = imageDOMElement ? imageDOMElement.height : '';
// Populate all other attributes by their specified attribute values.
var attribute = null;
var attribute = null, attributeName;
for (var key = 0; key < imageDOMElement.attributes.length; key++) {
attribute = imageDOMElement.attributes.item(key);
existingValues[attribute.nodeName.toLowerCase()] = attribute.nodeValue;
attributeName = attribute.nodeName.toLowerCase();
// Don't consider data-cke-saved- attributes; they're just there to
// work around browser quirks.
if (attributeName.substring(0, 15) === 'data-cke-saved-') {
continue;
}
// Store the value for this attribute, unless there's a
// data-cke-saved- alternative for it, which will contain the quirk-
// free, original value.
existingValues[attributeName] = imageElement.data('cke-saved-' + attributeName) || attribute.nodeValue;
}
}
function saveCallback (returnValues) {
// Save snapshot for undo support.
editor.fire('saveSnapshot');
// Create a new image element if needed.
......@@ -53,7 +61,9 @@ CKEDITOR.plugins.add('drupalimage', {
if (returnValues.attributes.hasOwnProperty(key)) {
// Update the property if a value is specified.
if (returnValues.attributes[key].length > 0) {
imageElement.setAttribute(key, returnValues.attributes[key]);
var value = returnValues.attributes[key];
imageElement.data('cke-saved-' + key, value);
imageElement.setAttribute(key, value);
}
// Delete the property if set to an empty string.
else {
......@@ -62,6 +72,9 @@ CKEDITOR.plugins.add('drupalimage', {
}
}
}
// Save snapshot for undo support.
editor.fire('saveSnapshot');
}
// Drupal.t() will not work inside CKEditor plugins because CKEditor
......
......@@ -25,16 +25,24 @@ CKEDITOR.plugins.add('drupallink', {
linkDOMElement = linkElement.$;
// Populate an array with the link's current attributes.
var attribute = null;
var attribute = null, attributeName;
for (var key = 0; key < linkDOMElement.attributes.length; key++) {
attribute = linkDOMElement.attributes.item(key);
existingValues[attribute.nodeName.toLowerCase()] = attribute.nodeValue;
attributeName = attribute.nodeName.toLowerCase();
// Don't consider data-cke-saved- attributes; they're just there to
// work around browser quirks.
if (attributeName.substring(0, 15) === 'data-cke-saved-') {
continue;
}
// Store the value for this attribute, unless there's a
// data-cke-saved- alternative for it, which will contain the quirk-
// free, original value.
existingValues[attributeName] = linkElement.data('cke-saved-' + attributeName) || attribute.nodeValue;
}
}
// Prepare a save callback to be used upon saving the dialog.
var saveCallback = function (returnValues) {
// Save snapshot for undo support.
editor.fire('saveSnapshot');
// Create a new link element if needed.
......@@ -65,7 +73,9 @@ CKEDITOR.plugins.add('drupallink', {
if (returnValues.attributes.hasOwnProperty(key)) {
// Update the property if a value is specified.
if (returnValues.attributes[key].length > 0) {
linkElement.setAttribute(key, returnValues.attributes[key]);
var value = returnValues.attributes[key];
linkElement.data('cke-saved-' + key, value);
linkElement.setAttribute(key, value);
}
// Delete the property if set to an empty string.
else {
......@@ -74,6 +84,9 @@ CKEDITOR.plugins.add('drupallink', {
}
}
}
// Save snapshot for undo support.
editor.fire('saveSnapshot');
};
// Drupal.t() will not work inside CKEditor plugins because CKEditor
// loads the JavaScript file instead of Drupal. Pull translated strings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment