Browse Source

! when inserting a smiley, only add spaces (pre/post) when needed editor.js

Spuds 13 years ago
parent
commit
f629a72b36
1 changed files with 5 additions and 2 deletions
  1. 5 2
      Themes/default/scripts/editor.js

+ 5 - 2
Themes/default/scripts/editor.js

@@ -668,8 +668,11 @@ smc_Editor.prototype.insertSmiley = function(oSmileyProperties)
 {
 	// In text mode we just add it in as we always did.
 	if (!this.bRichTextEnabled)
-		this.insertText(' ' + oSmileyProperties.sCode);
-
+	{		
+		var begin = this.oTextHandle.value.substr(this.oTextHandle.selectionStart - 1, 1);
+		var end = this.oTextHandle.value.substr(this.oTextHandle.selectionEnd, 1);
+		this.insertText((begin != ' ' ? ' ' : '') + oSmileyProperties.sCode + (end != ' ' ? ' ' : ''));
+	}
 	// Otherwise we need to do a whole image...
 	else
 	{