Jump to:
| Project: | Asset |
| Version: | 5.x-1.0-beta1 |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Hi authors,
I have been using this module for last 2 months.
Well if we have an asset added with a link on it.
[asset|aid=29|format=link|formatter=asset|title=First Title|align=none|height=undefined|width=undefined]Now I want to change it using tinymce editor,
I click on the "html" button and change the title from the above code.
Works great!
But if I click on the edit link button, its title shows:
aid%3D29%7Cformat%3Dlink%7Cformatter%3Dasset%7Ctitle%3DFirst%20Title%7Calign%3Dnone%7Cheight%3Dundefined%7Cwidth%3DundefinedI can read it and change the title here also. But an end-user who doesn't understand what %20 means can not change it!
Also, if we try to change the text(of the link) by just editing without click on edit button, we can't save the changes.
I understand that those changes are not saved to the asset link because, its not edited properly but viewing the html.
But I think it is almost important for us to allow easier way to edit the title of the asset without editing the html, basically in the tinymce.
This would mean a patch for drupalasset plugin for tinymce, correct me if I am wrong.
Any suggestions?
Comments
#1
Hey Sanket,
To edit an asset in TinyMCE, simply click on it. When you do, you will notice that the "add asset" icon changes into an "edit asset" icon. Click it to edit the selected asset. Can you confirm this is a solution for your problem?
#2
----------------------------------------------------------------------------------------
UPDATED 1032am EST
Well,
I can see the edit image button that wim is talking about...
But I can see this button only for non-link entities!!!
eg: asset like image without a link on it...
It does not work for assets like
1. pdf files.... which obviously are links...
2. image downloadable links...
3. basically all links...
I think the place to look for should be the plugin we are providing for the tinymce module..
let me check if I can see anything...
----------------------------------------------------------------------------------------
Hey Wim,
When I tried the suggested but.... image of add asset button remains there unchanged... it doesn't change into edit asset.
If I am wrong in getting this please don't read further and suggest me a solution! thanks :)
Well if not then,
I am still a bit confused... I think this is not that simple to figure-out.
Let me tell you what I did, (then I have a suggestion as well :-) )
OK so as mentioned,
1. I clicked on the asset link
2. then clicked on the same "add asset button image".
3. Normal asset wizard window popped-up. No change in normal and this asset wizard.
4. I tried to find my asset somewhere in the directories (I like structured storage)
5. clicked on the current asset(after lot of searching), clicked "edit" button,
6. modified the asset title, clicked next, then I see a message "Your changes have been saved."
7. Now I found my asset from the long list again, clicked next, again clicked next! got it!... works wonderful!
What I expected,
I will click on the required asset link, then click on asset button... wizard will open with this asset selected!--> directly go to step 6 from above list. Also the step 7 should not be there... why choose again just save.
Issues here:(tried both versions dev-1.x and beta1)
a. lengthy unclear way to update an asset link.
b. a new link is created so you have to delete the old link.
I am almost sure this is not what the authors would have coded... but did I do something weird... that I got this!
There could be another fix to this problem ie: to modify the drupalasset module in tinymce to handle this edit request using --> tinyMCE.execInstanceCommand('mce_editor_0','mceAdvLink') ..... this function goes through a series of editors for this ones css class ... ie we can edit its title... but there is some work to it to get it working...
But this patch will be for the link and unlink button of tinymce not the drupal asset button.
Sorry about this crazily longgggggg post......
#3
Updated:
I can see the edit button on asset images... but I can not see them for pdf links....
is there anything wrong???
Please ignore the bottom part of my above message... it becomes irrelevant...
But if the edit button with the "pencil" show up for images uploaded using asset...........then why not for pdf which are links..... hmmmmmm
gotta find this.....
#4
This might indeed be confusing. This is something I haven't found a solution for yet: TinyMCE will see the link as just that: a link. When you click on it you will get the anchor options, which in this case are overwriting the asset options. So this could be filed as a bug, but I could really use a hand from a TinyMCE pro on this.
#5
Hey Wim,
Thanks for confirming this with my results.
I think I know what is happing here...
I am working to get it fixed... well tinymce on ever click goes through all the plugins to see if there is anyone to take care of this css class... in our case it is: "mceDrupalAsset" we want this to be read...
but the order in which tinymce consults each plugin first is more likely to be dominated by where in the tinymce plugin list we add our lines...
$plugins['drupalasset'] = array();$plugins['drupalasset']['theme_advanced_buttons1'] = array('drupalasset');
$plugins['drupalasset']['extended_valid_elements'] = array('img[class|src|border=0|alt|title|width|height|align|name]');
I am trying to fix this by making sure that our file namely: /modules/tinymce/tinymce/jscripts/tiny_mce/plugins/drupalasset/editor_plugin.js
is read before any other file..
will update if things get fixed.... thanks for dropping by...
#6
All right after spending few hours I know the real issue:
My note is for the member who helped us by writing the asset / tinymce plugin.
Look at the integration notes of asset and tinymce [#209509].
Look at:
$plugins['drupalasset'] = array();$plugins['drupalasset']['theme_advanced_buttons1'] = array('drupalasset');
$plugins['drupalasset']['extended_valid_elements'] = array('img[class|src|border=0|alt|title|width|height|align|name]');
We are telling tinymce to change the button from add asset to edit asset for "img" type of requests but not for "a" type of requests.
Further in the /modules/tinymce/tinymce/jscripts/tiny_mce/plugins/drupalasset/editor_plugin.js look at the code below: we are checking and writing code to edit only images....
execCommand : function(editor_id, element, command, user_interface, value) {
// Handle commands
switch (command) {
case "mceDrupalAsset":
var name = "";
var nid = "", alt = "", captionTitle = "", captionDesc = "", link = "", align = "", width = "", height = "";
var action = "insert";
var template = new Array();
var inst = tinyMCE.getInstanceById(editor_id);
var focusElm = inst.getFocusElement();
// get base url
var base_url = tinyMCE.baseURL;
base_url = base_url.substring(0, base_url.indexOf('modules'));
template['file'] = base_url + 'index.php?q=asset/wizard/tinymce';
template['width'] = 600;
template['height'] = 400;
template['html'] = false;
// Is selection a asset
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
name = tinyMCE.getAttrib(focusElm, 'class');
if (name.indexOf('mceItemDrupalAsset') == -1) // Not a DrupalImage
return true;
// Get the rest of the DrupalImage attributes
align = tinyMCE.getAttrib(focusElm, 'align');
width = tinyMCE.getAttrib(focusElm, 'width');
height = tinyMCE.getAttrib(focusElm, 'height');
alt = decodeURIComponent(tinyMCE.getAttrib(focusElm, 'title')); // using 'title' because this doesn't seem to work with 'alt'
var miscAttribs = TinyMCE_DrupalAssetPlugin._parsePipeAttributes(alt); // parse the deliminated attributes in the alt tag
aid = miscAttribs['aid'];
template['file'] += '&aid=' + miscAttribs['aid'];
action = "update";
}
//WARNING: "resizable : 'yes'" below is painfully important otherwise
// tinymce will try to open a new window in IE using showModalDialog().
// And for some reason showModalDialog() doesn't respect the target="_top"
// attribute.
tinyMCE.openWindow(template, {editor_id : editor_id, nid : nid, captionTitle : captionTitle, captionDesc : captionDesc, width : width, height : height, action : action, scrollbars: 'yes', resizable: 'yes' });
//tinyMCE.openWindow(template, {editor_id : editor_id, nid : nid, captionTitle : captionTitle, captionDesc : captionDesc, link : link, align : align, width : width, height : height, action : action, resizable : 'yes', scrollbars : 'yes'});
return true;
}
// Pass to next handler in chain
return false;
},
We should actually be handling both cases: "img" and "a" type, something like:
execCommand : function(editor_id, element, command, user_interface, value) {
// Handle commands
switch (command) {
case "mceDrupalAsset":
var name = "";
var nid = "", alt = "", captionTitle = "", captionDesc = "", link = "", align = "", width = "", height = "";
var action = "insert";
var template = new Array();
var inst = tinyMCE.getInstanceById(editor_id);
var focusElm = inst.getFocusElement();
// get base url
var base_url = tinyMCE.baseURL;
base_url = base_url.substring(0, base_url.indexOf('modules'));
template['file'] = base_url + 'index.php?q=asset/wizard/tinymce';
template['width'] = 600;
template['height'] = 400;
template['html'] = false;
// THIS IS MY ADDITIONAL CODE TO THE CODE
if (focusElm != null && focusElm.nodeName.toLowerCase() == "a") {
alert('wow this is a bug!');
name = tinyMCE.getAttrib(focusElm, 'class');
if (name.indexOf('mceItemDrupalAsset') == -1) // Not a DrupalLink return true;
//
//
// here some tinymce pro should help us write a slight modification of the code below.
// This patch here should help edit an asset which is a link (eg a pdf link, image link, etc)
// I know little but will try to update this patch, we need to figure-out the basics
// to edit our assets.... its like a must have function... and tinymce should not stop us from
// doing what we want!
//
//
}
// END OF ADDITIONAL CODE
// Is selection a asset
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
name = tinyMCE.getAttrib(focusElm, 'class');
if (name.indexOf('mceItemDrupalAsset') == -1) // Not a DrupalImage
return true;
// Get the rest of the DrupalImage attributes
align = tinyMCE.getAttrib(focusElm, 'align');
width = tinyMCE.getAttrib(focusElm, 'width');
height = tinyMCE.getAttrib(focusElm, 'height');
alt = decodeURIComponent(tinyMCE.getAttrib(focusElm, 'title')); // using 'title' because this doesn't seem to work with 'alt'
var miscAttribs = TinyMCE_DrupalAssetPlugin._parsePipeAttributes(alt); // parse the deliminated attributes in the alt tag
aid = miscAttribs['aid'];
template['file'] += '&aid=' + miscAttribs['aid'];
action = "update";
}
//WARNING: "resizable : 'yes'" below is painfully important otherwise
// tinymce will try to open a new window in IE using showModalDialog().
// And for some reason showModalDialog() doesn't respect the target="_top"
// attribute.
tinyMCE.openWindow(template, {editor_id : editor_id, nid : nid, captionTitle : captionTitle, captionDesc : captionDesc, width : width, height : height, action : action, scrollbars: 'yes', resizable: 'yes' });
//tinyMCE.openWindow(template, {editor_id : editor_id, nid : nid, captionTitle : captionTitle, captionDesc : captionDesc, link : link, align : align, width : width, height : height, action : action, resizable : 'yes', scrollbars : 'yes'});
return true;
}
// Pass to next handler in chain
return false;
},
#7
Wow thanks a lot Sanket! This really helps so much, I'll get started on this as well.
#8
Hey Roger,
Well I can see from the plugin code, that you are the author of this asset-tinymce plugin.
Now I am not a javascript expert but playing with the code out there I can see the following:
1. When I click on image,
edit option is enabled!
what that means is, the asset wizard knows that it has to replace the current code with the editing that is taking place in the asset wizard...
2. When I click on a pdf link,
edit option is *not* enabled! What this means is... if I add code in the above block there... then it will work ofcourse but it will add a new link with the newly edited title.
I can patch this code to work if we can in asset wizard replace the existing pdf link (any link) based on the "aid" sent, instead of adding a new link.
If you have any suggests.. please do let me know!
Also I can see that the plugin created works but it would be better if in the next upgrade we implement this note from create tinymce plugin documentation
Hope to hear from you roger.. thanks...
#9
Hey Sanket, I'm Wim Mostrey actually, I'm the maintainer of the 5.x-1 branch and Roger is working on the 5.x-2 branch.
If you think you can manage the code to replace the link based on the aid that would be great. I'm currently getting the same behavior as you describe with the code you posted in this issue, although it's a giant step in the good direction. I'm not so much a javascript hero hero myself, but perhaps with combined effort we can make this work :) If you get stuck on something, be sure to post your current code so I can jump in.
Again, thanks a lot. Your help on this is highly appreciated.
#10
Hey thanks Wim for your appreciation.. I will work on this issue.. hopeful we can together call it off as a "bug-fix".
#11
The thing you described in post #1 actually happens to me for normal inline images as well (on title and alt attribute); and the edit button is only there right after I've inserted an image (and haven't saved the node yet); when I try to edit a node later he doesn't manage to "recognise" the images as assets (I think)... I'm guessing this behaviour might be more or less the same issue?
Any progress on a solution yet? :)!
#12
Oh well, after looking at some js-code I found out that the title and alt attribute seem to be used like that as a kind of information storage attribute (which I personally don't think is a good thing to do, as I'd actually like to be able to use those attributes on my page)... The "editing" still doesn't work though, but that might be a different issue then...
#13
I'm marking this as critical: I would like to get this fixed before the first RC which is coming after the next beta version (hopefully). I'm also working on this closely now.
#14
I currently get the "edit asset" when I click on a text link, but it doesn't remember the aid and most importantly: when finishing it just enters a new asset at the cursor place instead of replacing the complete text. Any help would be appreciated.
Sanket, did you have any more luck on this?
#15
I am currently putting work in other issues since I've been spending too much time on this without any decent results. I really want to see this fixed before we hit release candidate 1 but I will focus on other issues for now. Any help from TinyMCE-talented people would be highly appreciated.
#16
Marking as "won't fix". I'm not sure if this is possible and you can always use the TinyMCE link edit to alter the description or target.