Browse Source

Fixed the insert quote and extended the SCEditor plugin to support the function InsertText

Signed-off-by: emanuele <[email protected]>
emanuele 12 năm trước cách đây
mục cha
commit
6a47f77211
2 tập tin đã thay đổi với 28 bổ sung7 xóa
  1. 24 4
      Sources/Subs-Editor.php
  2. 4 3
      Themes/default/Post.template.php

+ 24 - 4
Sources/Subs-Editor.php

@@ -1462,10 +1462,30 @@ function create_control_richedit($editorOptions)
 		<link rel="stylesheet" href="' . $settings['default_theme_url'] . '/css/jquery.sceditor.css" type="text/css" media="all" />
 		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/jquery.sceditor.js"></script>
 		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/jquery.sceditor.bbcode.js"></script>
-		<script>$(document).ready(function() {
-			$("#' . $editorOptions['id'] . '").sceditorBBCodePlugin({
-				style: "' . $settings['default_theme_url'] . '/css/jquery.sceditor.default.css"
-			});
+		<script>
+			(function($) {
+				var extensionMethods = {
+					InsertText: function(text) {
+						var bIsSource = this.inSourceMode();
+						var current_value = this.getWysiwygEditorValue() + "\n" + text;
+
+						if (!bIsSource)
+							this.toggleTextMode();
+
+						this.setTextareaValue(current_value);
+
+						if (!bIsSource)
+							this.toggleTextMode();
+					}
+				};
+
+				$.extend(true, $[\'sceditor\'].prototype, extensionMethods);
+			})(jQuery);
+
+			$(document).ready(function() {
+				$("#' . $editorOptions['id'] . '").sceditorBBCodePlugin({
+					style: "' . $settings['default_theme_url'] . '/css/jquery.sceditor.default.css"
+				});
 		});</script>';
 
 		$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');

+ 4 - 3
Themes/default/Post.template.php

@@ -850,19 +850,20 @@ function template_main()
 			function onDocReceived(XMLDoc)
 			{
 				var text = \'\';
-				var bIsSource = $("#', $context['post_box_name'], '").data("sceditor").inSourceMode();
-				var current_value = $("#', $context['post_box_name'], '").data("sceditor").getWysiwygEditorValue() + "\n" + text;
+// 				var bIsSource = $("#', $context['post_box_name'], '").data("sceditor").inSourceMode();
 
 				for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
 					text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
+				$("#', $context['post_box_name'], '").data("sceditor").InsertText(text);
 
+/*				var current_value = $("#', $context['post_box_name'], '").data("sceditor").getWysiwygEditorValue() + "\n" + text;
 				if (!bIsSource)
 					$("#', $context['post_box_name'], '").data("sceditor").toggleTextMode();
 
 				$("#', $context['post_box_name'], '").data("sceditor").setTextareaValue(current_value);
 
 				if (!bIsSource)
-					$("#', $context['post_box_name'], '").data("sceditor").toggleTextMode();
+					$("#', $context['post_box_name'], '").data("sceditor").toggleTextMode();*/
 			}
 		// ]]></script>';
 	}