باید افزونه بنویسید. فایل paste_code.html آن در مسیر plugins:
<label>
Code:</label>
<textarea id="redactor_insert_code_area" name="redactor_insert_code_area" style="height: 211px; width: 538px;" />
<label>
Language:</label>
<select id="redactor_insert_code_lang">
<option>CSharp</option>
<option>VB</option>
<option>JScript</option>
<option>Sql</option>
<option>XML</option>
<option>CSS</option>
<option>Java</option>
<option>Delphi</option>
</select>
<br />
<input type="button" name="insert" id="redactor_insert_btn" value="%RLANG.insert%" />
و قسمت فعال سازی آن در فایل redactor.js ذیل setColorNone
showCodesPage: function () {
this.modalInit('Insert Code', this.opts.path + '/plugins/paste_code.html', 600, $.proxy(function () {
var sel = this.getSelection();
var currentCode = '';
this.opts.codeElement = false;
if ($.browser.msie) {
var parent = this.getParentNode();
if (parent.nodeName === 'PRE') {
this.opts.codeElement = parent;
currentCode = $(parent).text();
} else {
if (this.oldIE()) {
currentCode = sel.text;
} else {
currentCode = sel.toString();
}
}
} else {
if (sel && sel.anchorNode && sel.anchorNode.parentNode.tagName === 'PRE') {
this.opts.codeElement = sel.anchorNode.parentNode;
currentCode = $(sel.anchorNode.parentNode).text();
} else {
currentCode = sel.toString();
}
}
if (this.opts.codeElement) {
$("#redactor_insert_btn").val("Update");
}
if (currentCode) $('#redactor_insert_code_area').val(currentCode);
$('#redactor_insert_code_area').focus();
$('#redactor_insert_btn').click($.proxy(this.insertCodesPage, this));
}, this));
},
insertCodesPage: function () {
var lang = $("#redactor_insert_code_lang").val();
var code = $("#redactor_insert_code_area").val();
code = code.replace(/\s+$/, ""); //rtrim;
code = $('<span/>').text(code).html(); // encode
this.$editor.focus();
var preBlock;
if (this.opts.codeElement) {
preBlock = $(this.getParentNode());
} else {
preBlock = $("<pre/>");
}
preBlock.replaceWith("");
var htmlCode = "<pre language='" + lang + "' name='code'>" + code + "</pre></div>";
var codeBlock = "<div align='left' dir='ltr'>" + htmlCode + "</div><br/>";
this.execCommand('inserthtml', codeBlock);
this.modalClose();
},
و بعد ثبت آن در فایلهای public.js و default.js
ذیل دکمه justify
code:
{
title: 'Code',
func: 'showCodesPage'
},
به css آن هم باید یک سطر ذیل را اضافه کنید:
body .redactor_toolbar li a.redactor_btn_code span { background: url(../img/code_red.png) no-repeat center; }