Author: vjrj Date: 2009-03-06 02:07:03 +0100 (Fri, 06 Mar 2009) New Revision: 1060 Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/richtext.css trunk/src/main/java/org/ourproject/kune/app/public/css/rte.css trunk/src/main/java/org/ourproject/kune/platf/client/ui/Location.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java Log: Incomplete - task Better RTE (Rich Text Editor) support Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/richtext.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/public/css/richtext.css 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/app/public/css/richtext.css 2009-03-06 01:07:03 UTC (rev 1060) @@ -13,4 +13,4 @@ Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 2.4.1 -*/h1{font-size:138.5%;}h2{font-size:123.099998%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:700;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style:decimal outside;}ul li{list-style:disc outside;}dl dd{margin-left:1em;}th,td{border:1px solid #000;padding:.5em;}th{font-weight:700;text-align:center;}caption{margin-bottom:.5em;text-align:center;}p,fieldset,table,pre{margin-bottom:1em;}input[type=text],input[type=password],textarea{width:12.25em;width:11.9em;}body{font-family:arial, sans;margin:5px;}.k-rte-comment span{border:1px dashed silver;font-size:85%;line-height:1.4;padding:1px;background-color:#D7FFD7;} \ No newline at end of file +*/h1{font-size:138.5%;}h2{font-size:123.099998%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:700;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style:decimal outside;}ul li{list-style:disc outside;}dl dd{margin-left:1em;}th,td{border:1px solid #000;padding:.5em;}th{font-weight:700;text-align:center;}caption{margin-bottom:.5em;text-align:center;}p,fieldset,table,pre{margin-bottom:1em;}input[type=text],input[type=password],textarea{width:12.25em;width:11.9em;}body{font-family:arial, sans;margin:5px;}.k-rte-comment{border:1px dashed silver;line-height:1.4;padding:3px;background-color:#D7FFD7;} \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/rte.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/public/css/rte.css 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/app/public/css/rte.css 2009-03-06 01:07:03 UTC (rev 1060) @@ -3,10 +3,9 @@ margin: 5px; } -.k-rte-comment span { +.k-rte-comment { border:1px dashed #C0C0C0; - font-size:85%; line-height:1.4; - padding:1px; + padding:3px; background-color:#D7FFD7; } \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/Location.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/Location.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/Location.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -1,4 +1,3 @@ - /* * Copyright 2006 Robert Hanson <iamroberthanson AT gmail.com> * @@ -30,22 +29,52 @@ private String queryString; private HashMap<String, String> paramMap; + /** + * sample: #site.docs.3.1 + **/ public String getHash() { return hash; } + /** + * sample: locahost:8080 + * + * @return + */ public String getHost() { return host; } + /** + * sample: locahost + * + * @return + */ public String getHostName() { return hostName; } + /** + * sample: + * http://localhost:8080/kune/#site.docs.3.1?locale=en&log_level=INFO + **/ public String getHref() { return href; } + public String getParameter(final String name) { + return paramMap.get(name); + } + + public Map<String, String> getParameterMap() { + return paramMap; + } + + /** + * sample: /kune/ + * + * @return + */ public String getPath() { return path; } @@ -58,6 +87,11 @@ return protocol; } + /** + * sample: ?locale=en&log_level=INFO + * + * @return + */ public String getQueryString() { return queryString; } @@ -97,8 +131,8 @@ if (queryString != null && queryString.length() > 1) { String qs = queryString.substring(1); String[] kvPairs = qs.split("&"); - for (int i = 0; i < kvPairs.length; i++) { - String[] kv = kvPairs[i].split("="); + for (String kvPair : kvPairs) { + String[] kv = kvPair.split("="); if (kv.length > 1) { paramMap.put(kv[0], unescape(kv[1])); } else { @@ -109,15 +143,7 @@ } private native String unescape(String val) /*-{ - return unescape(val); - }-*/; + return unescape(val); + }-*/; - public String getParameter(final String name) { - return paramMap.get(name); - } - - public Map<String, String> getParameterMap() { - return paramMap; - } - } \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -57,9 +57,9 @@ public void addComment(String userName) { String time = i18n.formatDateWithLocale(new Date(), true); Element span = DOM.createSpan(); - span.setInnerText(i18n.t("type here") + " -" + userName + " " + time); + span.setInnerHTML("<em>" + i18n.t("type here") + "</em> -" + userName + " " + time); DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment"); - insertHtml(span.getString()); + insertHtml(span.getString() + " "); } public void adjustSize(int height) { @@ -279,10 +279,12 @@ updateStatus(); fireEdit(); if (modifiers != 0) { + Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")"); ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers)); if (actionItem != null) { - Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")"); actionManager.doAction(actionItem); + } else { + Log.debug("...but not mapped to any command"); } } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -216,7 +216,7 @@ subscript.setParentMenuTitle(i18n.t(FORMAT_MENU)); subscript.setTextDescription(i18n.t("Subscript")); subscript.setIconCls(getCssName(imgResources.subscript())); - subscript.setShortcut(new ActionShortcut(true, ',')); + subscript.setShortcut(new ActionShortcut(true, '0')); subscript.setAddCondition(canBeBasic); ActionToolbarMenuDescriptor<Object> superscript = new ActionToolbarMenuDescriptor<Object>(accessRol, @@ -228,7 +228,7 @@ superscript.setParentMenuTitle(i18n.t(FORMAT_MENU)); superscript.setTextDescription(i18n.t("Superscript")); superscript.setIconCls(getCssName(imgResources.superscript())); - superscript.setShortcut(new ActionShortcut(true, '.')); + superscript.setShortcut(new ActionShortcut(true, '9')); superscript.setAddCondition(canBeBasic); ActionToolbarButtonDescriptor<Object> justifyLeft = new ActionToolbarButtonDescriptor<Object>(accessRol, @@ -421,7 +421,7 @@ ul.setIconCls(getCssName(imgResources.defaultbullet())); ul.setToolTip(i18n.t("Bullet List")); ul.setShortcut(new ActionShortcut(true, '8')); - ul.setRightSeparator(ActionToolbarButtonSeparator.spacer); + ul.setRightSeparator(ActionToolbarButtonSeparator.separator); ul.setAddCondition(canBeExtended); ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, @@ -490,11 +490,11 @@ topActions.add(withNoItem(hr)); topActions.add(withNoItem(subscript)); topActions.add(withNoItem(superscript)); - sndActions.add(withNoItem(hrButton)); sndActions.add(withNoItem(decreaseIndent)); sndActions.add(withNoItem(increaseIndent)); sndActions.add(withNoItem(ol)); sndActions.add(withNoItem(ul)); + sndActions.add(withNoItem(hrButton)); sndActions.add(withNoItem(img)); sndActions.add(withNoItem(createLink)); sndActions.add(withNoItem(removeLink)); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -35,48 +35,42 @@ @Override public native void initElement() /*-{ - // Mozilla doesn't allow designMode to be set reliably until the iframe is - // fully loaded. - var _this = this; - var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + // Mozilla doesn't allow designMode to be set reliably until the iframe is + // fully loaded. + var _this = this; + var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - iframe.onload = function() { - // Some Mozillae have the nasty habit of calling onload again when you set - // designMode, so let's avoid doing it more than once. - iframe.onload = null; + iframe.onload = function() { + // Some Mozillae have the nasty habit of calling onload again when you set + // designMode, so let's avoid doing it more than once. + iframe.onload = null; - // patch ccs inject: + // patch ccs inject: - var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document; - head=doc.getElementsByTagName('head')[0]; - link=document.createElement('link'); - link.setAttribute('rel',"stylesheet"); - link.setAttribute('type',"text/css"); - link.setAttribute('href',"css/richtext.css" ); - head.appendChild(link); + var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document; + head=doc.getElementsByTagName('head')[0]; + link=document.createElement('link'); + link.setAttribute('rel',"stylesheet"); + link.setAttribute('type',"text/css"); + link.setAttribute('href',$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" ); + head.appendChild(link); - var styles = document.createElement('style'); - styles.setAttribute('type', 'text/css'); - var newStyle = document.createTextNode('\n<!--\nbody{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:400;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:400;}q:before,q:after{content:\'\';}abbr,acronym{border:0;font-variant:normal;}sup,sub{line-height:-1px;vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}body{font:13px/1.22 arial,helvetica,clean,sans-serif;font-size:small;font:x-small;}table{font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;font-size:108%;line-height:99%;}h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:700;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style:decimal outside;}ul li{list-style:disc outside;}dl dd{margin-left:1em;}th,td{border:1px solid #000;padding:.5em;}th{font-weight:700;text-align:center;}caption{margin-bottom:.5em;text-align:center;}p,fieldset,table,pre{margin-bottom:1em;}input[type=text],input[type=password],textarea{width:12.25em;width:11.9em;}body{font-family:arial, sans;margin:5px}\n-->\n'); - styles.appendChild(newStyle); - head.appendChild(styles); + // -- patch - // -- patch + // Send notification that the iframe has finished loading. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - // Send notification that the iframe has finished loading. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - - // Don't set designMode until the RTA actually gets focused. This is - // necessary because editing won't work on Mozilla if the iframe is - // *hidden, but attached*. Waiting for focus gets around this issue. - // - // Note: This onfocus will not conflict with the addEventListener('focus', - // ...) // in RichTextAreaImplStandard. - iframe.contentWindow.onfocus = function() { - iframe.contentWindow.onfocus = null; - iframe.contentWindow.document.designMode = 'On'; - }; - }; - }-*/; + // Don't set designMode until the RTA actually gets focused. This is + // necessary because editing won't work on Mozilla if the iframe is + // *hidden, but attached*. Waiting for focus gets around this issue. + // + // Note: This onfocus will not conflict with the addEventListener('focus', + // ...) // in RichTextAreaImplStandard. + iframe.contentWindow.onfocus = function() { + iframe.contentWindow.onfocus = null; + iframe.contentWindow.document.designMode = 'On'; + }; + }; + }-*/; } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -25,24 +25,24 @@ @Override public native void initElement() /*-{ - // Most browsers don't like setting designMode until slightly _after_ - // the iframe becomes attached to the DOM. Any non-zero timeout will do - // just fine. - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - // Turn on design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; - // patch css inject: - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - var ct = "<html><head><style>@import url('" + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - // -- patch + // Most browsers don't like setting designMode until slightly _after_ + // the iframe becomes attached to the DOM. Any non-zero timeout will do + // just fine. + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + setTimeout(function() { + // Turn on design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; + // patch css inject: + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + // -- patch - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -25,25 +25,25 @@ @Override public native void initElement() /*-{ - // Most browsers don't like setting designMode until slightly _after_ - // the iframe becomes attached to the DOM. Any non-zero timeout will do - // just fine. - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - // Turn on design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; + // Most browsers don't like setting designMode until slightly _after_ + // the iframe becomes attached to the DOM. Any non-zero timeout will do + // just fine. + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + setTimeout(function() { + // Turn on design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; - // patch css inject: - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - var ct = "<html><head><style>@import url('" + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - // -- patch + // patch css inject: + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + // -- patch - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; } Modified: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-05 13:57:02 UTC (rev 1059) +++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-06 01:07:03 UTC (rev 1060) @@ -28,6 +28,15 @@ } @Test + public void ctrl_coma() { + ActionShortcut shortcut = new ActionShortcut(true, ','); + assertEquals(" (Ctrl+,)", shortcut.toString(i18n)); + assertTrue(shortcut.is(',', KeyboardListener.MODIFIER_CTRL)); + assertTrue(!shortcut.is(',', KeyboardListener.MODIFIER_ALT)); + assertTrue(!shortcut.is(',', KeyboardListener.MODIFIER_SHIFT)); + } + + @Test public void ctrl_s() { ActionShortcut shortcut = new ActionShortcut(true, 's'); assertEquals(" (Ctrl+S)", shortcut.toString(i18n));