diff --git a/public/images/wymeditor/skins/refinery/text_indent.png b/public/images/wymeditor/skins/refinery/text_indent.png new file mode 100644 index 0000000000..9364532344 Binary files /dev/null and b/public/images/wymeditor/skins/refinery/text_indent.png differ diff --git a/public/images/wymeditor/skins/refinery/text_indent_remove.png b/public/images/wymeditor/skins/refinery/text_indent_remove.png new file mode 100644 index 0000000000..1651b074eb Binary files /dev/null and b/public/images/wymeditor/skins/refinery/text_indent_remove.png differ diff --git a/public/javascripts/refinery/boot_wym.js b/public/javascripts/refinery/boot_wym.js index 11337a217b..9a00860c11 100755 --- a/public/javascripts/refinery/boot_wym.js +++ b/public/javascripts/refinery/boot_wym.js @@ -15,6 +15,10 @@ var wymeditor_boot_options = $.extend({ ,{'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'} ,{'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'} ,{'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'} + /*,{'name': 'Indent', 'title': 'Indent', 'css': 'wym_tools_indent'} + ,{'name': 'Outdent', 'title': 'Outdent', 'css': 'wym_tools_outdent'} + ,{'name': 'Undo', 'title': 'Undo', 'css': 'wym_tools_undo'} + ,{'name': 'Redo', 'title': 'Redo', 'css': 'wym_tools_redo'}*/ ,{'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'} ,{'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'} ,{'name': 'InsertImage', 'title': 'Image', 'css': 'wym_tools_image'} diff --git a/public/javascripts/wymeditor/jquery.refinery.wymeditor.js b/public/javascripts/wymeditor/jquery.refinery.wymeditor.js index 50ca85c7a5..7b01b330a0 100755 --- a/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +++ b/public/javascripts/wymeditor/jquery.refinery.wymeditor.js @@ -1,6 +1,6 @@ /* * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/ + * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ * Dual licensed under the MIT (MIT-license.txt) * and GPL (GPL-license.txt) licenses. * @@ -19,7 +19,7 @@ * Scott Lewis (lewiscot a-t gmail dotcom) * Bermi Ferrer (wymeditor a-t bermi dotorg) * Daniel Reszka (d.reszka a-t wymeditor dotorg) - * Jonatan Lundin (jonatan.lundin _at_ gmail.com) + * Jonatan Lundin (jonatan.lundin a-t gmail dotcom) */ /* @@ -117,7 +117,7 @@ $.extend(WYMeditor, { */ - VERSION : "0.5-b2-refinery", + VERSION : "0.5-rc1-refinery", INSTANCES : [], STRINGS : [], SKINS : [], @@ -454,11 +454,11 @@ $.fn.wymeditor = function(options) { + WYMeditor.CLASSES_ITEMS + "", - classesItemHtml: "
]*>(.*?)<\/pre>','gmi')); + if(matches) { + for(var i=0; i', 'g'), String.fromCharCode(13,10))); + } + } + return xhtml; }; WYMeditor.XhtmlSaxListener.prototype.getResult = function() @@ -3871,7 +3893,7 @@ WYMeditor.WymCssLexer = function(parser, only_wym_blocks) this.addExitPattern("/\\\x2a[<\/\\s]*WYMeditor[>\\s]*\\\x2a/", 'WymCss'); } - this.addSpecialPattern("\\\x2e[a-z-_0-9]+[\\sa-z1-6]*", 'WymCss', 'WymCssStyleDeclaration'); + this.addSpecialPattern("[\\sa-z1-6]*\\\x2e[a-z-_0-9]+", 'WymCss', 'WymCssStyleDeclaration'); this.addEntryPattern("/\\\x2a", 'WymCss', 'WymCssComment'); this.addExitPattern("\\\x2a/", 'WymCssComment'); @@ -3879,8 +3901,8 @@ WYMeditor.WymCssLexer = function(parser, only_wym_blocks) this.addEntryPattern("\x7b", 'WymCss', 'WymCssStyle'); this.addExitPattern("\x7d", 'WymCssStyle'); - this.addEntryPattern("/\\\x2a", 'WymCssStyle', 'WymCssFeddbackStyle'); - this.addExitPattern("\\\x2a/", 'WymCssFeddbackStyle'); + this.addEntryPattern("/\\\x2a", 'WymCssStyle', 'WymCssFeedbackStyle'); + this.addExitPattern("\\\x2a/", 'WymCssFeedbackStyle'); return this; }; @@ -3944,7 +3966,7 @@ WYMeditor.WymCssParser.prototype.WymCssStyle = function(match, status) return true; }; -WYMeditor.WymCssParser.prototype.WymCssFeddbackStyle = function(match, status) +WYMeditor.WymCssParser.prototype.WymCssFeedbackStyle = function(match, status) { if(status == WYMeditor.LEXER_UNMATCHED){ this._current_item[this._current_element].feedback_style = match.replace(/^([\s\/\*]*)|([\s\/\*]*)$/gm,''); @@ -3957,10 +3979,10 @@ WYMeditor.WymCssParser.prototype.WymCssStyleDeclaration = function(match) match = match.replace(/^([\s\.]*)|([\s\.*]*)$/gm, ''); var tag = ''; - if(match.indexOf(' ') > 0){ - var parts = match.split(' '); - this._current_element = parts[0]; - var tag = parts[1]; + if(match.indexOf('.') > 0){ + var parts = match.split('.'); + this._current_element = parts[1]; + var tag = parts[0]; }else{ this._current_element = match; } @@ -4105,7 +4127,7 @@ function titleize(words) { /* * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/ + * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ * Dual licensed under the MIT (MIT-license.txt) * and GPL (GPL-license.txt) licenses. * @@ -4121,13 +4143,15 @@ function titleize(words) { * Jean-Francois Hovinne (jf.hovinne a-t wymeditor dotorg) * Bermi Ferrer (wymeditor a-t bermi dotorg) * Frédéric Palluel-Lafleur (fpalluel a-t gmail dotcom) - * Jonatan Lundin (jonatan.lundin _at_ gmail.com) + * Jonatan Lundin (jonatan.lundin a-t gmail dotcom) */ WYMeditor.WymClassExplorer = function(wym) { - this._wym = wym; - this._class = "className"; - this._newLine = "\r\n"; + + this._wym = wym; + this._class = "className"; + this._newLine = "\r\n"; + }; WYMeditor.WymClassExplorer.prototype.initIframe = function(iframe) { @@ -4195,43 +4219,53 @@ WYMeditor.WymClassExplorer.prototype.initIframe = function(iframe) { //init designMode this._doc.designMode="on"; - try{ - // (bermi's note) noticed when running unit tests on IE6 - // Is this really needed, it trigger an unexisting property on IE6 - this._doc = iframe.contentWindow.document; + // (bermi's note) noticed when running unit tests on IE6 + // Is this really needed, it trigger an unexisting property on IE6 + this._doc = iframe.contentWindow.document; }catch(e){} }; WYMeditor.WymClassExplorer.prototype._exec = function(cmd,param) { - switch(cmd) { + + switch(cmd) { + case WYMeditor.INDENT: case WYMeditor.OUTDENT: - // determine whether we're in a list item. - if (this.findUp(this.container(), WYMeditor.LI)) { - this._doc.execCommand(cmd); - } - break; + + var container = this.findUp(this.container(), WYMeditor.LI); + if(container) { + var ancestor = container.parentNode.parentNode; + if(container.parentNode.childNodes.length>1 + || ancestor.tagName.toLowerCase() == WYMeditor.OL + || ancestor.tagName.toLowerCase() == WYMeditor.UL) + this._doc.execCommand(cmd); + } + break; default: - if(param) this._doc.execCommand(cmd,false,param); - else this._doc.execCommand(cmd); - break; - } + if(param) this._doc.execCommand(cmd,false,param); + else this._doc.execCommand(cmd); + break; + } - this.listen(); }; WYMeditor.WymClassExplorer.prototype.selected = function() { - if((caretPos = this._iframe.contentWindow.document.caretPos)!=null && caretPos.parentElement!=undefined) { - return(caretPos.parentElement()); - } + + var caretPos = this._iframe.contentWindow.document.caretPos; + if(caretPos!=null) { + if(caretPos.parentElement!=undefined) + return(caretPos.parentElement()); + } }; WYMeditor.WymClassExplorer.prototype.saveCaret = function() { - this._doc.caretPos = this._doc.selection.createRange(); + + this._doc.caretPos = this._doc.selection.createRange(); }; WYMeditor.WymClassExplorer.prototype.addCssRule = function(styles, oCss) { - styles.addRule(oCss.name, oCss.css); + + styles.addRule(oCss.name, oCss.css); }; WYMeditor.WymClassExplorer.prototype.insert = function(html) { @@ -4286,18 +4320,19 @@ WYMeditor.WymClassExplorer.prototype.keyup = function() { this._selected_image = null; }; -WYMeditor.WymClassExplorer.prototype.setFocusToNode = function(node) { +WYMeditor.WymClassExplorer.prototype.setFocusToNode = function(node, toStart) { var range = this._doc.selection.createRange(); + toStart = toStart ? true : false; + range.moveToElementText(node); - range.collapse(false); - range.move('character',-1); + range.collapse(toStart); range.select(); node.focus(); }; /* * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/ + * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ * Dual licensed under the MIT (MIT-license.txt) * and GPL (GPL-license.txt) licenses. * @@ -4325,6 +4360,8 @@ WYMeditor.WymClassMozilla = function(wym) { WYMeditor.WymClassMozilla.prototype.initIframe = function(iframe) { + var wym = this; + this._iframe = iframe; this._doc = iframe.contentDocument; @@ -4362,7 +4399,10 @@ WYMeditor.WymClassMozilla.prototype.initIframe = function(iframe) { $(this._doc).bind("paste", this.intercept_paste); //bind editor focus events (used to reset designmode - Gecko bug) - $(this._doc).bind("focus", this.enableDesignMode); + $(this._doc).bind("focus", function (){ + // Fix scope + wym.enableDesignMode.call(wym); + }); //post-init functions if($.isFunction(this._options.postInit)) this._options.postInit(this); @@ -4431,10 +4471,6 @@ WYMeditor.WymClassMozilla.prototype._exec = function(cmd,param) { var container = this.selected(); if(container.tagName.toLowerCase() == WYMeditor.BODY) this._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); - - //add event handlers on doc elements - - this.listen(); }; @@ -4499,6 +4535,16 @@ WYMeditor.WymClassMozilla.prototype.keydown = function(evt) { return false; } } + else if(evt.keyCode == 13) { + if(!evt.shiftKey){ + //fix PRE bug #73 + container = wym.selected(); + if(container && container.tagName.toLowerCase() == WYMeditor.PRE) { + evt.preventDefault(); + wym.insert(''); + } + } + } }; //keyup handler, mainly used for cleanups @@ -4537,23 +4583,14 @@ WYMeditor.WymClassMozilla.prototype.keyup = function(evt) { }; WYMeditor.WymClassMozilla.prototype.enableDesignMode = function() { - if(this.designMode == "off") { + if(this._doc.designMode == "off") { try { - this.designMode = "on"; - this.execCommand("styleWithCSS", '', false); + this._doc.designMode = "on"; + this._doc.execCommand("styleWithCSS", '', false); } catch(e) { } } }; -WYMeditor.WymClassMozilla.prototype.setFocusToNode = function(node) { - var range = document.createRange(); - range.selectNode(node); - var selected = this._iframe.contentWindow.getSelection(); - selected.addRange(range); - selected.collapse(node, node.childNodes.length); - this._iframe.contentWindow.focus(); -}; - WYMeditor.WymClassMozilla.prototype.openBlockTag = function(tag, attributes) { var attributes = this.validator.getValidTagAttributes(tag, attributes); @@ -4579,13 +4616,13 @@ WYMeditor.WymClassMozilla.prototype.getTagForStyle = function(style) { if(/bold/.test(style)) return 'strong'; if(/italic/.test(style)) return 'em'; if(/sub/.test(style)) return 'sub'; - if(/sub/.test(style)) return 'super'; + if(/super/.test(style)) return 'super'; return false; }; /* * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/ + * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ * Dual licensed under the MIT (MIT-license.txt) * and GPL (GPL-license.txt) licenses. * @@ -4655,8 +4692,6 @@ WYMeditor.WymClassOpera.prototype.initIframe = function(iframe) { WYMeditor.WymClassOpera.prototype._exec = function(cmd,param) { if(param) this._doc.execCommand(cmd,false,param); else this._doc.execCommand(cmd); - - this.listen(); }; WYMeditor.WymClassOpera.prototype.selected = function() { @@ -4683,8 +4718,7 @@ WYMeditor.WymClassOpera.prototype.keydown = function(evt) { startNode = sel.getRangeAt(0).startContainer; //Get a P instead of no container - if(!$(startNode).parentsOrSelf( - WYMeditor.MAIN_CONTAINERS.join(","))[0] + if(!$(startNode).parentsOrSelf(WYMeditor.MAIN_CONTAINERS.join(","))[0] && !$(startNode).parentsOrSelf('li') && evt.keyCode != WYMeditor.KEY.ENTER && evt.keyCode != WYMeditor.KEY.LEFT @@ -4705,14 +4739,9 @@ WYMeditor.WymClassOpera.prototype.keyup = function(evt) { wym._selected_image = null; }; -// TODO: implement me -WYMeditor.WymClassOpera.prototype.setFocusToNode = function(node) { - -}; - /* * WYMeditor : what you see is What You Mean web-based editor - * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/ + * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/ * Dual licensed under the MIT (MIT-license.txt) * and GPL (GPL-license.txt) licenses. * @@ -4879,9 +4908,6 @@ WYMeditor.WymClassSafari.prototype._exec = function(cmd,param) { var container = this.selected(); if(container && container.tagName.toLowerCase() == WYMeditor.BODY) this._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); - - //add event handlers on doc elements - this.listen(); }; /* @name selected @@ -5024,16 +5050,6 @@ WYMeditor.WymClassSafari.prototype.keyup = function(evt) { } }; - -WYMeditor.WymClassSafari.prototype.setFocusToNode = function(node) { - var range = this._iframe.contentDocument.createRange(); - range.selectNode(node); - var selected = this._iframe.contentWindow.getSelection(); - selected.addRange(range); - selected.collapse(node, node.childNodes.length); - this._iframe.contentWindow.focus(); -}; - WYMeditor.WymClassSafari.prototype.openBlockTag = function(tag, attributes) { var attributes = this.validator.getValidTagAttributes(tag, attributes); diff --git a/public/stylesheets/wymeditor/skins/refinery/skin.css b/public/stylesheets/wymeditor/skins/refinery/skin.css index 68dfac930b..091d08fd7f 100755 --- a/public/stylesheets/wymeditor/skins/refinery/skin.css +++ b/public/stylesheets/wymeditor/skins/refinery/skin.css @@ -16,7 +16,7 @@ /*WYM_BOX*/ - .wym_skin_refinery { border: 1px solid gray; background: #F2F2F2; padding: 5px} + .wym_skin_refinery { border: 1px solid #999999; background: #F2F2F2; padding: 5px} /*auto-clear the wym_box*/ .wym_skin_refinery:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } @@ -30,7 +30,7 @@ /*WYM_IFRAME*/ .wym_skin_refinery .wym_iframe { width: 100%;} - .wym_skin_refinery .wym_iframe iframe { width: 99%; border: 1px solid gray; background: white } + .wym_skin_refinery .wym_iframe iframe { width: 99%; border: 1px solid #999999; background: white } /* adjust for two rows of icons */ .wym_two_column .wym_skin_refinery .wym_iframe iframe, .wym_two_column .wym_skin_refinery .wym_html textarea { height: 376px; } @@ -82,7 +82,7 @@ .wym_skin_refinery .wym_buttons li.wym_tools_ordered_list a { background-image: url('/images/wymeditor/skins/refinery/text_list_numbers.png');} .wym_skin_refinery .wym_buttons li.wym_tools_unordered_list a{ background-image: url('/images/wymeditor/skins/refinery/text_list_bullets.png');} .wym_skin_refinery .wym_buttons li.wym_tools_indent a { background-image: url('/images/wymeditor/skins/refinery/text_indent.png');} - .wym_skin_refinery .wym_buttons li.wym_tools_outdent a { background-image: url('/images/wymeditor/skins/refinery/text_outdent.png');} + .wym_skin_refinery .wym_buttons li.wym_tools_outdent a { background-image: url('/images/wymeditor/skins/refinery/text_indent_remove.png');} .wym_skin_refinery .wym_buttons li.wym_tools_undo a { background-image: url('/images/wymeditor/skins/refinery/arrow_undo.png');} .wym_skin_refinery .wym_buttons li.wym_tools_redo a { background-image: url('/images/wymeditor/skins/refinery/arrow_redo.png');} .wym_skin_refinery .wym_buttons li.wym_tools_link a { background-image: url('/images/wymeditor/skins/refinery/link_add.png');}