Closed (fixed)
Project:
Wysiwyg
Version:
6.x-2.0-alpha1
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
23 May 2009 at 15:03 UTC
Updated:
18 Jun 2009 at 21:50 UTC
Jump to comment: Most recent file
Such behavior make impossible to use array of objects as options setting (i.e. the template TinyMCE plugin expect to get list of templates as array of objects). I think code should be altere to collapse only simple array. If scripts detects that array has another array or object as an element, it should pass it "as is".
Also Drupal.wysiwyg.clone should not convert arrays into objects during cloning as this can prevent some plugins (again TinyMCE template plugin is one of them) from working correctly. Update code follows:
Drupal.wysiwyg.clone = function(obj, clone_type) {
var clone = (clone_type == 'array' ?[]:{});
for (var i in obj) {
if (typeof obj[i] == 'object') {
clone[i] = Drupal.wysiwyg.clone(obj[i]);
}
if (typeof obj[i] == 'array') {
clone[i] = Drupal.wysiwyg.clone(obj[i], 'array');
}
else {
clone[i] = obj[i];
}
}
return clone;
};
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | wysiwyg-HEAD.clone_.patch | 1.91 KB | sun |
Comments
Comment #1
sunBetter title. I think.
Comment #2
jfhovinne commentedI'm not sure about the real purpose of this function, but if you want to recursively clone any type of object in JS, jQuery.extend() does it very well:
var newObject = jQuery.extend(true, {}, oldObject);
More info at:
http://stackoverflow.com/questions/122102/what-is-the-most-efficent-way-...
HTH
--jf
Comment #3
sunWow. Sometimes, it's very helpful to have some JS masters around ;)
Attached patch completely replaces Drupal.wysiwyg.clone().
This needs to be tested with all editors, their default configurations, with native editor plugins only, but also with Drupal plugins.
If everything still works, this fix will make WYMeditor as well as YUI editor finally possible.
Comment #4
sunComment #5
jfhovinne commentedHappy to help :)
FYI, your patch works fine with latest WYMeditor files (r642), see also #28 in #362137: Add WYMeditor support.
Comment #6
sunThanks for reporting, reviewing, and testing! Committed to all 2.x branches.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.