r1395 - in xwiki/trunk: core/src/main/java/com/xpn/xwiki/render/macro src/main/web/tiny_mce/themes/wikieditor src/main/web/wiki_editor/plugins
Phung Hai Nam
namphunghai at users.forge.objectweb.org
Mon Oct 16 08:33:23 CEST 2006
Author: namphunghai
Date: 2006-10-16 08:33:23 +0200 (Mon, 16 Oct 2006)
New Revision: 1395
Modified:
xwiki/trunk/core/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java
xwiki/trunk/src/main/web/tiny_mce/themes/wikieditor/image.htm
xwiki/trunk/src/main/web/wiki_editor/plugins/attachments.js
xwiki/trunk/src/main/web/wiki_editor/plugins/core.js
Log:
XWIKI-368 " to be able to specify the alignment properties of an image so that text is place to the right or left (and so on) of the image automatically"
Modified: xwiki/trunk/core/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java
===================================================================
--- xwiki/trunk/core/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java 2006-10-16 03:03:26 UTC (rev 1394)
+++ xwiki/trunk/core/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java 2006-10-16 06:33:23 UTC (rev 1395)
@@ -47,7 +47,7 @@
String img = params.get("text", 0);
String height = params.get("height", 1);
String width = params.get("width", 2);
-
+ String align = params.get("align", 3);
XWikiContext xcontext = ((XWikiRadeoxRenderEngine)engine).getContext();
XWikiDocument doc = xcontext.getDoc();
@@ -61,6 +61,9 @@
if ((!"none".equals(width))&&(width!=null)&&(!"".equals(width.trim()))){
str.append("width=\"" + width.trim() + "\" ");
}
+ if ((!"none".equals(align))&&(align!=null)&&(!"".equals(align.trim()))){
+ str.append("align=\"" + align.trim() + "\" ");
+ }
str.append("alt=\"");
str.append(img);
str.append("\" />");
Modified: xwiki/trunk/src/main/web/tiny_mce/themes/wikieditor/image.htm
===================================================================
--- xwiki/trunk/src/main/web/tiny_mce/themes/wikieditor/image.htm 2006-10-16 03:03:26 UTC (rev 1394)
+++ xwiki/trunk/src/main/web/tiny_mce/themes/wikieditor/image.htm 2006-10-16 06:33:23 UTC (rev 1395)
@@ -11,8 +11,8 @@
var src = document.forms[0].href.value;
var width = document.forms[0].width.value;
var height = document.forms[0].height.value;
-
- window.opener.wikiEditor.insertImage(src, width, height);
+ var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value;
+ window.opener.wikiEditor.insertImage(src, width, height, align);
top.close();
}
}
@@ -164,6 +164,20 @@
<input name="height" type="text" id="height" value="" size="3" maxlength="3" /></td>
</tr>
<tr>
+ <td nowrap="nowrap">{$lang_insert_image_align}:</td>
+ <td><select name="align" style="width: 100px">
+ <option value="">{$lang_insert_image_align_default}</option>
+ <option value="left">{$lang_insert_image_align_left}</option>
+ <option value="right">{$lang_insert_image_align_right}</option>
+ <option value="baseline">{$lang_insert_image_align_baseline}</option>
+ <option value="top">{$lang_insert_image_align_top}</option>
+ <option value="middle">{$lang_insert_image_align_middle}</option>
+ <option value="bottom">{$lang_insert_image_align_bottom}</option>
+ <option value="texttop">{$lang_insert_image_align_texttop}</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
<td nowrap="nowrap"><input type="button" id="insert" name="insert" value="{$lang_insert}" onclick="insertImage();">
</td>
<td align="right"><input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="cancelAction();"></td>
Modified: xwiki/trunk/src/main/web/wiki_editor/plugins/attachments.js
===================================================================
--- xwiki/trunk/src/main/web/wiki_editor/plugins/attachments.js 2006-10-16 03:03:26 UTC (rev 1394)
+++ xwiki/trunk/src/main/web/wiki_editor/plugins/attachments.js 2006-10-16 06:33:23 UTC (rev 1395)
@@ -12,7 +12,7 @@
return;
}
- this.addExternalProcessor((/{\s*image\s*:\s*(.*?)(\|(.*?))?(\|(.*?))?}/i), 'convertImageExternal');
+ this.addExternalProcessor((/{\s*image\s*:\s*(.*?)(\|(.*?))?(\|(.*?))?(\|(.*?))?}/i), 'convertImageExternal');
this.addInternalProcessor((/<img\s*([^>]*)(class=\"wikiimage\")\s*([^>]*)\/>/i), 'convertImageInternal');
this.addExternalProcessor((/{\s*attach\s*:\s*(.*?)}/i), 'convertAttachmentExternal');
@@ -53,8 +53,8 @@
return this.dummyCommand();
}
-WikiEditor.prototype.insertImage = function(src, width, height) {
- this.core.insertImage(this.getImagePath() + src, "", "", "", "", width, height, "", "", "", "");
+WikiEditor.prototype.insertImage = function(src, width, height, align) {
+ this.core.insertImage(this.getImagePath() + src, "", "", "", "", width, height, align, "", "", "");
}
WikiEditor.prototype.convertImageInternal = function(regexp, result, content) {
@@ -75,10 +75,13 @@
str = "{image:" + imgname;
var width=att["width"]?this.trimString(att["width"]):"";
var height=att["height"]?this.trimString(att["height"]):"";
- if(width != "" || height != "") {
- str += "|" + (height?height:"") + "|" + (width?width:"");
- }
- str += "}";
+ var align=att["align"]?this.trimString(att["align"]):"";
+ if (width != "" || height != "" || align != "") {
+ str += "|" + (height?height:" ") + "|" + (width?width:" ");
+ if (align != "") str += "|" + (align?align:"");
+ }
+
+ str += "}";
}
}
return content.replace(regexp, str);
@@ -88,17 +91,21 @@
WikiEditor.prototype.convertImageExternal = function(regexp, result, content) {
var str = "<img id=\"" + result[1] + "\" class=\"" + this.IMAGE_CLASS_NAME + "\" src=\"" + this.getImagePath() + result[1] + "\" ";
- var width, height;
+ var width, height, align;
if( result[5] && (width = this.trimString(result[5])) != "") {
str += "width=\"" + width + "\" ";
}
if( result[3] && (height = this.trimString(result[3])) != "") {
str += "height=\"" + height + "\" ";
}
-
- str += "\/>";
-
- return content.replace(regexp, str);
+
+ if( result[7] && (align = this.trimString(result[7])) != "") {
+ str += "align=\"" + align + "\" ";
+ }
+
+ str += "\/>";
+
+ return content.replace(regexp, str);
}
WikiEditor.prototype.handleAttachmentsButtons = function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
Modified: xwiki/trunk/src/main/web/wiki_editor/plugins/core.js
===================================================================
--- xwiki/trunk/src/main/web/wiki_editor/plugins/core.js 2006-10-16 03:03:26 UTC (rev 1394)
+++ xwiki/trunk/src/main/web/wiki_editor/plugins/core.js 2006-10-16 06:33:23 UTC (rev 1395)
@@ -28,7 +28,7 @@
this.addInternalProcessor((/<a\s*([^>]*)(class=\"wikiexternallink\"|class=\"wikilink\")\s*([^>]*)>(.*?)<\/a>/i), 'convertLinkInternal');
// Must convert external images inside table before convert the table
- this.addExternalProcessor((/{\s*image\s*:\s*(.*?)(\|(.*?))?(\|(.*?))?}/i), 'convertImageExternal');
+ this.addExternalProcessor((/{\s*image\s*:\s*(.*?)(\|(.*?))?(\|(.*?))?(\|(.*?))?}/i), 'convertImageExternal');
this.addExternalProcessor((/\{table\}([\s\S]+?)\{table\}/i), 'convertTableExternal');
this.addInternalProcessor((/<table\s*([^>]*)class=\"wiki-table\"\s*([^>]*)>([\s\S]+?)<\/table>/i), 'convertTableInternal');
More information about the Xwiki-notifications
mailing list