Explorar el Código

And here it is the spell check! It should work but I have no possibility to test it live

Signed-off-by: emanuele <[email protected]>
emanuele hace 12 años
padre
commit
d6b8090f37

+ 0 - 10
Sources/Subs-Editor.php

@@ -1476,16 +1476,6 @@ function create_control_richedit($editorOptions)
 		<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
 			<input type="hidden" name="spellstring" value="" />
 		</form>';
-
-			// Also make sure that spell check works with rich edit.
-			$context['html_headers'] .= '
-		<script type="text/javascript"><!-- // --><![CDATA[
-		function spellCheckDone()
-		{
-			for (i = 0; i < smf_editorArray.length; i++)
-				setTimeout("smf_editorArray[" + i + "].spellCheckEnd()", 150);
-		}
-		// ]]></script>';
 		}
 	}
 

+ 1 - 1
Sources/Subs-Post.php

@@ -1482,7 +1482,7 @@ function SpellCheck()
 	// Construct a bit of Javascript code.
 	$context['spell_js'] = '
 		var txt = {"done": "' . $txt['spellcheck_done'] . '"};
-		var mispstr = window.opener.document.forms[spell_formname][spell_fieldname].value;
+		var mispstr = window.opener.spellCheckGetText(spell_fieldname);
 		var misps = Array(';
 
 	// Get all the words (Javascript already separated them).

+ 3 - 0
Themes/default/GenericControls.template.php

@@ -85,6 +85,9 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 
 						$(".sceditor-toolbar").append(content);
 					},
+					storeLastState: function (){
+						this.wasSource = this.inSourceMode();
+					},
 					setTextMode: function () {
 						if (!this.inSourceMode())
 							this.toggleTextMode();

+ 7 - 11
Themes/default/scripts/editor.js

@@ -1,4 +1,7 @@
 // *** smc_Editor class.
+/*
+ Kept for compatibility with SMF 2.0 editor
+ */
 function smc_Editor(oOptions)
 {
 	this.opt = oOptions;
@@ -30,18 +33,11 @@ smc_Editor.prototype.spellCheckStart = function()
 	if (!spellCheck)
 		return false;
 
+	$('#' + this.sUniqueId).data("sceditor").storeLastState();
 	// If we're in HTML mode we need to get the non-HTML text.
-	if (this.bRichTextEnabled)
-	{
-		var sText = escape(this.getText(true, 1).php_to8bit());
-
-		this.tmpMethod = sendXMLDocument;
-		this.tmpMethod(smf_prepareScriptUrl(smf_scripturl) + 'action=jseditor;view=0;' + this.opt.sSessionVar + '=' + this.opt.sSessionId + ';xml', 'message=' + sText, this.onSpellCheckDataReceived);
-		delete tmpMethod;
-	}
-	// Otherwise start spellchecking right away.
-	else
-		spellCheck(this.sFormId, this.opt.sUniqueId);
+	$('#' + this.sUniqueId).data("sceditor").setTextMode()
+
+	spellCheck(false, this.opt.sUniqueId);
 
 	return true;
 }

+ 13 - 6
Themes/default/scripts/spellcheck.js

@@ -18,7 +18,7 @@ function spellCheck(formName, fieldName)
 	var aWordCharacters = ['-', '\''];
 
 	var aWords = new Array(), aResult = new Array();
-	var sText = document.forms[formName][fieldName].value;
+	var sText = $('#' + fieldName).data("sceditor").getTextareaValue(false);
 	var bInCode = false;
 	var iOffset1, iOffset2;
 
@@ -235,11 +235,7 @@ function nextWord(ignoreall)
 		mispstr = mispstr.replace(/_\|_/g, "\n");
 
 		// Get a handle to the field we need to re-populate.
-		window.opener.document.forms[spell_formname][spell_fieldname].value = mispstr;
-		if (!window.opener.spellCheckDone)
-			window.opener.document.forms[spell_formname][spell_fieldname].focus();
-		else
-			window.opener.spellCheckDone();
+		window.opener.spellCheckSetText(mispstr, spell_fieldname);
 
 		window.close();
 		return true;
@@ -294,4 +290,15 @@ function htmlspecialchars(thetext)
 function openSpellWin(width, height)
 {
 	window.open("", "spellWindow", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + width + ",height=" + height);
+}
+
+function spellCheckGetText(editorID)
+{
+	return $("#" + editorID).data("sceditor").getTextareaValue(false);
+}
+function spellCheckSetText(text, editorID)
+{
+	$("#" + editorID).data("sceditor").InsertText(text, true);
+	if (!$("#" + editorID).data("sceditor").wasSource)
+		$("#" + editorID).data("sceditor").toggleTextMode();
 }