Ticket #570 (closed enhancement: fixed)
RFC: Clicking alignment button when image selected should set image align="" attribute
| Reported by: | gogo | Owned by: | gogo |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Plugin_ContextMenu | Version: | trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by gogo) (diff)
The is a request for comment on a change I think is useful for the core, but changes behaviour slightly.
Currently, if you select an image in the Xinha area, and click left/right then the entire paragraph the image is in is left/right justified.
The change makes it so that the image has it's align="" attribute set to left/right (so that text flows around the right/left of the image). Clicking the same justification button again removes the align="" attribute.
The advantage of this is simply that it seems more intuitive, if you select an image and click the alignment button then the image is aligned, not surrounding text. It also gives functionality which is not available presently without opening one of the image dialogs.
The change is a simple addition to the switch in execCommand()
case 'justifyleft' :
case 'justifyright' :
{
cmdID.match(/^justify(.*)$/);
var ae = this._activeElement(this._getSelection());
if(ae && ae.tagName.toLowerCase() == 'img')
{
ae.align = ae.align == RegExp.$1 ? '' : RegExp.$1;
}
else
{
this._doc.execCommand(cmdID, UI, param);
}
}
break;
Center alignment is a bit more tricky, probably clicking center would have to add something like style="clear:both;display:block;margin-left:auto;margin-right:auto;" or something to get an "expected" behaviour (well, if HTML supported it then it would truely be centered with text flow on both left and right, but we don't have that option). Unfortunatly that CSS only works in Gecko, I can't find a way to get IE to center an image short of wrapping it in a div or something.
