Commit de0f3ab3 authored by webchick's avatar webchick

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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment