From 402eb2edaaf8f8526d5375d7f5acd1cb30e2bb35 Mon Sep 17 00:00:00 2001 From: Eston Bond Date: Mon, 1 Nov 2010 15:53:06 -0700 Subject: [PATCH] Bad console.log! Bad! --- scratch/css/editor.css | 1 + scratch/edit.html | 7 ++----- scratch/js/gollum-editor/gollum.editor.js | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/scratch/css/editor.css b/scratch/css/editor.css index 51777e14..4b49b901 100644 --- a/scratch/css/editor.css +++ b/scratch/css/editor.css @@ -6,6 +6,7 @@ #gollum-editor { border: 1px solid #e4e4e4; background: #f9f9f9; + margin-bottom: 5em; overflow: hidden; padding: 1em; diff --git a/scratch/edit.html b/scratch/edit.html index a22342ef..1fc56a9a 100644 --- a/scratch/edit.html +++ b/scratch/edit.html @@ -30,14 +30,14 @@
Bold Italic - - Underline Code   Unordered List Ordered List Blockquote + + Horizontal Rule   Link Image @@ -52,9 +52,6 @@
- diff --git a/scratch/js/gollum-editor/gollum.editor.js b/scratch/js/gollum-editor/gollum.editor.js index c6e3fba3..3cf77c3e 100644 --- a/scratch/js/gollum-editor/gollum.editor.js +++ b/scratch/js/gollum-editor/gollum.editor.js @@ -42,7 +42,6 @@ debug('Loading language definition for ' + ActiveOptions.MarkupType); LanguageDefinition.loadFor( ActiveOptions.MarkupType, function(data, textStatus) { - console.log( data, textStatus ); if ( textStatus != 'success' ) { debug('Language definition could not be loaded for markup ' + 'type ' + ActiveOptions.MarkupType); @@ -72,7 +71,6 @@ * Used by the definitions in langs/ to register language definitions. */ $.GollumEditor.defineLanguage = function( language_name, languageObject ) { - console.log('Defining language for ' + language_name); if ( typeof languageObject == 'object' ) LanguageDefinition.define( language_name, languageObject ); else @@ -288,6 +286,7 @@ .getFieldSelectionPosition( $('#gollum-editor-body') ); var selText = FunctionBar.getFieldSelection( $('#gollum-editor-body') ); var repText = selText; + var reselect = true; // execute a replacement function if one exists if ( definitionObject.exec && @@ -315,12 +314,16 @@ // append if necessary if ( definitionObject.append && typeof definitionObject.append == 'string' ) { + if ( repText == selText ) { + reselect = false; + } repText += definitionObject.append; + } if (repText) FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), - repText ); + repText, reselect ); }, @@ -370,15 +373,20 @@ * * @param jQuery A jQuery object for the textarea. * @param string The string to replace the current selection with. + * @param boolean Reselect the new text range. */ - replaceFieldSelection: function( $field, replaceText ) { + replaceFieldSelection: function( $field, replaceText, reselect ) { var selPos = FunctionBar.getFieldSelectionPosition( $field ); var fullStr = $field.val(); + var selectNew = true; + if ( reselect === false) { + var selectNew = false; + } $field.val( fullStr.substring(0, selPos.start) + replaceText + fullStr.substring(selPos.end)); - if ( $field[0].setSelectionRange ) { + if ( selectNew && $field[0].setSelectionRange ) { $field[0].focus(); $field[0].setSelectionRange( selPos.start, selPos.start + replaceText.length );