浏览代码

First part of backward compatibility: the editor should work even loading the old smc_Editor object (it works in Penguin without any change to the template)

Signed-off-by: emanuele <[email protected]>
emanuele 13 年之前
父节点
当前提交
c048258f68
共有 3 个文件被更改,包括 32 次插入1081 次删除
  1. 2 1
      Sources/Subs-Editor.php
  2. 25 25
      Themes/default/GenericControls.template.php
  3. 5 1055
      Themes/default/scripts/editor.js

+ 2 - 1
Sources/Subs-Editor.php

@@ -1459,6 +1459,7 @@ function create_control_richedit($editorOptions)
 				prompt_text_img: \'' . addcslashes($txt['prompt_text_img'], "'") . '\'
 			}
 		// ]]></script>
+		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/editor.js?alp21"></script>
 		<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>';
@@ -1539,7 +1540,7 @@ function create_control_richedit($editorOptions)
 			),
 			array(
 				'image' => 'underline',
-				'code' => 'uunderline',
+				'code' => 'underline',
 				'before' => '[u]',
 				'after' => '[/u]',
 				'description' => $txt['underline']

+ 25 - 25
Themes/default/GenericControls.template.php

@@ -29,7 +29,7 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 
 			(function($) {
 				var extensionMethods = {
-					InsertText: function(text) {
+					InsertText: function(text, bClear) {
 						var bIsSource = this.inSourceMode();
 
 						// @TODO make it put the quote close to the current selection
@@ -37,7 +37,7 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 						if (!bIsSource)
 							this.toggleTextMode();
 
-						var current_value = this.getTextareaValue(false) + "\n" + text;
+						var current_value = bClear ? text : this.getTextareaValue(false) + "\n" + text;
 						this.setTextareaValue(current_value);
 
 						if (!bIsSource)
@@ -196,14 +196,14 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 				$.sceditor.setCommand(
 					\'glow\',
 					function () {
-						this.wysiwygEditorInsertText(\'[glow=red,2,300][/glow]\');
+						this.wysiwygEditorInsertHtml(\'[glow=red,2,300]\', \'[/glow]\');
 					},
 					', javaScriptEscape($txt['glow']), '
 				);
 				$.sceditor.setCommand(
 					\'shadow\',
 					function () {
-						this.wysiwygEditorInsertText(\'[shadow=red,left][/shadow]\');
+						this.wysiwygEditorInsertHtml(\'[shadow=red,left]\', \'[/shadow]\');
 					},
 					', javaScriptEscape($txt['shadow']), '
 				);
@@ -277,30 +277,30 @@ function template_control_richedit($editor_id, $smileyContainer = null, $bbcCont
 			echo ',
 					toolbar: "emoticon,source",';
 
-/*
-// 		// Now it's all drawn out we'll actually setup the box.
-// 		echo '
-// 				var oEditorHandle_', $editor_id, ' = new smc_Editor({
-// 					sSessionId: smf_session_id,
-// 					sSessionVar: smf_session_var,
-// 					sFormId: ', JavaScriptEscape($editor_context['form']), ',
-// 					sUniqueId: ', JavaScriptEscape($editor_id), ',
-// 					bRTL: ', $txt['lang_rtl'] ? 'true' : 'false', ',
-// 					bWysiwyg: ', $editor_context['rich_active'] ? 'true' : 'false', ',
-// 					sText: ', JavaScriptEscape($editor_context['rich_active'] ? $editor_context['rich_value'] : ''), ',
-// 					sEditWidth: ', JavaScriptEscape($editor_context['width']), ',
-// 					sEditHeight: ', JavaScriptEscape($editor_context['height']), ',
-// 					bRichEditOff: ', empty($modSettings['disable_wysiwyg']) ? 'false' : 'true', ',
-// 					oSmileyBox: ', !empty($context['smileys']['postform']) && !$editor_context['disable_smiley_box'] && $smileyContainer !== null ? 'oSmileyBox_' . $editor_id : 'null', ',
-// 					oBBCBox: ', $context['show_bbc'] && $bbcContainer !== null ? 'oBBCBox_' . $editor_id : 'null', '
-// 				});
-// 				smf_editorArray[smf_editorArray.length] = oEditorHandle_', $editor_id, ';';
-*/
 		echo '
 				})
 				$("#', $editor_id, '").data("sceditor").createPermanentDropDown();
-				$(".sceditor-container").width("100%").height("100%");
-			});
+				$(".sceditor-container").width("100%").height("100%");', 
+				/*$editor_context['rich_active'] ? '$("#' . $editor_id . '").toggleTextMode();' :*/ '', '
+			});';
+
+		// Now for backward compatibility let's collect few infos in the good ol' style
+		echo '
+				var oEditorHandle_', $editor_id, ' = new smc_Editor({
+					sSessionId: smf_session_id,
+					sSessionVar: smf_session_var,
+					sFormId: ', JavaScriptEscape($editor_context['form']), ',
+					sUniqueId: ', JavaScriptEscape($editor_id), ',
+					bRTL: ', $txt['lang_rtl'] ? 'true' : 'false', ',
+					bWysiwyg: ', $editor_context['rich_active'] ? 'true' : 'false', ',
+					sText: ', JavaScriptEscape($editor_context['rich_active'] ? $editor_context['rich_value'] : ''), ',
+					sEditWidth: ', JavaScriptEscape($editor_context['width']), ',
+					sEditHeight: ', JavaScriptEscape($editor_context['height']), ',
+					bRichEditOff: ', empty($modSettings['disable_wysiwyg']) ? 'false' : 'true', ',
+					oSmileyBox: null,
+					oBBCBox: null
+				});
+// 				smf_editorArray[smf_editorArray.length] = oEditorHandle_', $editor_id, ';
 			// ]]></script>';
 }
 

文件差异内容过多而无法显示
+ 5 - 1055
Themes/default/scripts/editor.js


部分文件因为文件数量过多而无法显示