mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 18:51:41 +09:00
#348 향상/문제수정
[A]코드의 파일명 및 설명 입력 추가 [A]시작 줄 번호 입력 추가 [M]옵션이 있을 경우 비정상 동작하던 부분 수정 git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3398 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ca6f7c5293
commit
f79d11a4ef
7 changed files with 131 additions and 80 deletions
|
|
@ -7,70 +7,83 @@
|
|||
|
||||
class code_highlighter extends EditorHandler {
|
||||
|
||||
// editor_sequence 는 에디터에서 필수로 달고 다녀야 함
|
||||
var $editor_sequence = 0;
|
||||
var $component_path = '';
|
||||
// editor_sequence 는 에디터에서 필수로 달고 다녀야 함
|
||||
var $editor_sequence = 0;
|
||||
var $component_path = '';
|
||||
|
||||
/**
|
||||
* @brief editor_sequence과 컴포넌트의 경로를 받음
|
||||
**/
|
||||
function code_highlighter($editor_sequence, $component_path) {
|
||||
$this->editor_sequence = $editor_sequence;
|
||||
$this->component_path = $component_path;
|
||||
}
|
||||
/**
|
||||
* @brief editor_sequence과 컴포넌트의 경로를 받음
|
||||
**/
|
||||
function code_highlighter($editor_sequence, $component_path) {
|
||||
$this->editor_sequence = $editor_sequence;
|
||||
$this->component_path = $component_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief popup window요청시 popup window에 출력할 내용을 추가하면 된다
|
||||
**/
|
||||
function getPopupContent() {
|
||||
// 템플릿을 미리 컴파일해서 컴파일된 소스를 return
|
||||
$tpl_path = $this->component_path.'tpl';
|
||||
$tpl_file = 'popup.html';
|
||||
/**
|
||||
* @brief popup window요청시 popup window에 출력할 내용을 추가하면 된다
|
||||
**/
|
||||
function getPopupContent() {
|
||||
// 템플릿을 미리 컴파일해서 컴파일된 소스를 return
|
||||
$tpl_path = $this->component_path.'tpl';
|
||||
$tpl_file = 'popup.html';
|
||||
|
||||
Context::set("tpl_path", $tpl_path);
|
||||
Context::set("tpl_path", $tpl_path);
|
||||
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
$oTemplate = &TemplateHandler::getInstance();
|
||||
return $oTemplate->compile($tpl_path, $tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method
|
||||
*
|
||||
* 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서
|
||||
* DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경
|
||||
**/
|
||||
function transHTML($xml_obj) {
|
||||
$code_type = $xml_obj->attrs->code_type;
|
||||
$option_collapse = $xml_obj->attrs->collapse;
|
||||
$option_nogutter = $xml_obj->attrs->nogutter;
|
||||
$option_nocontrols = $xml_obj->attrs->nocontrols;
|
||||
if($option_collapse == 'Y') $code_type = $code_type.':collapse';
|
||||
if($option_nogutter == 'Y') $code_type = $code_type.':nogutter';
|
||||
if($option_nocontrols == 'Y' && $option_collapse !== 'Y') $code_type = $code_type.':nocontrols';
|
||||
$body = $xml_obj->body;
|
||||
/**
|
||||
* @brief 에디터 컴포넌트가 별도의 고유 코드를 이용한다면 그 코드를 html로 변경하여 주는 method
|
||||
*
|
||||
* 이미지나 멀티미디어, 설문등 고유 코드가 필요한 에디터 컴포넌트는 고유코드를 내용에 추가하고 나서
|
||||
* DocumentModule::transContent() 에서 해당 컴포넌트의 transHtml() method를 호출하여 고유코드를 html로 변경
|
||||
**/
|
||||
function transHTML($xml_obj) {
|
||||
$code_type = $xml_obj->attrs->code_type;
|
||||
$option_file_path = $xml_obj->attrs->file_path;
|
||||
$option_description = $xml_obj->attrs->description;
|
||||
$option_first_line = $xml_obj->attrs->first_line;
|
||||
$option_collapse = $xml_obj->attrs->collapse;
|
||||
$option_nogutter = $xml_obj->attrs->nogutter;
|
||||
$option_nocontrols = $xml_obj->attrs->nocontrols;
|
||||
if($option_collapse == 'true') $option = $option.':collapse';
|
||||
if($option_nogutter == 'true') $option = $option.':nogutter';
|
||||
if($option_nocontrols == 'true' && $option_collapse != 'true') $option = $option.':nocontrols';
|
||||
if($option_first_line) $option = $option.":firstline[$option_first_line]";
|
||||
$body = $xml_obj->body;
|
||||
|
||||
$body = preg_replace('@(<br\\s*/?>)(\n)?@i' , "\n", $body);
|
||||
$body = strip_tags($body);
|
||||
|
||||
if(!$GLOBALS['_called_code_highlighter_']) {
|
||||
$GLOBALS['_called_code_highlighter_'] = true;
|
||||
$js_code = <<<dpScript
|
||||
|
||||
$body = preg_replace('@(<br\\s*/?>)(\n)?@i' , "\n", $body);
|
||||
$body = strip_tags($body);
|
||||
|
||||
if(!$GLOBALS['_called_code_highlighter_']) {
|
||||
$GLOBALS['_called_code_highlighter_'] = true;
|
||||
$js_code = <<<dpScript
|
||||
<script type="text/javascript">
|
||||
dp.SyntaxHighlighter.ClipboardSwf = '{$this->component_path}script/clipboard.swf';
|
||||
dp.SyntaxHighlighter.HighlightAll('CodeHighLighterArea');
|
||||
dp.SyntaxHighlighter.HighlightAll('code');
|
||||
</script>
|
||||
dpScript;
|
||||
|
||||
Context::addHtmlFooter($js_code);
|
||||
}
|
||||
Context::addHtmlFooter($js_code);
|
||||
}
|
||||
|
||||
Context::addCSSFile($this->component_path.'css/SyntaxHighlighter.css');
|
||||
Context::addCSSFile($this->component_path.'css/SyntaxHighlighter.css');
|
||||
|
||||
Context::addJsFile($this->component_path.'script/shCore.js');
|
||||
Context::addJsFile($this->component_path.'script/shBrush'.$code_type.'.js');
|
||||
Context::addJsFile($this->component_path.'script/shCore.js');
|
||||
Context::addJsFile($this->component_path.'script/shBrush'.$code_type.'.js');
|
||||
|
||||
$output = sprintf('<pre name="CodeHighLighterArea" class="%s">%s</pre>', $code_type, $body);
|
||||
return $output;
|
||||
}
|
||||
$output = null;
|
||||
if(isset($option_file_path) || isset($option_description)) {
|
||||
$output .= '<div class="ch_infobox">';
|
||||
if(isset($option_file_path)) $output .= '<span class="file_path">'.$option_file_path.'</span>';
|
||||
if(isset($option_description)) $output .= '<span class="description">'.$option_description.'</span>';
|
||||
$output .= '</div>';
|
||||
}
|
||||
$output .= sprintf('<pre name="code" class="%s">%s</pre>', $code_type.$option, $body);
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,18 +1,17 @@
|
|||
.dp-highlighter
|
||||
{
|
||||
font-family: "Consolas", "Courier New", Courier, mono, serif;
|
||||
font-family: "Consolas", "Courier New", "Courier", "mono", "serif";
|
||||
font-size: 12px;
|
||||
background-color: #E7E5DC;
|
||||
width: 99%;
|
||||
overflow: auto;
|
||||
margin: 18px 0 18px 0 !important;
|
||||
padding-top: 1px; /* adds a little border on top when controls are hidden */
|
||||
}
|
||||
|
||||
/* clear styles */
|
||||
.dp-highlighter ol,
|
||||
.dp-highlighter ol li,
|
||||
.dp-highlighter ol li span
|
||||
.dp-highlighter ol li span
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
|
@ -281,11 +280,31 @@
|
|||
.dp-abap .datatypes { color: #2E8B57; font-weight: bold; }
|
||||
|
||||
|
||||
pre[name='CodeHighLighterArea'] {
|
||||
max-height: 200px;
|
||||
pre[name='code'] {
|
||||
max-height: 300px;
|
||||
font-size: 1.1em;
|
||||
border: #666666 dotted 1px;
|
||||
border-left: #22AAEE solid 5px;
|
||||
padding: 5px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
|
||||
.ch_infobox {
|
||||
padding: 5px 0;
|
||||
width: 99%;
|
||||
background-color: #F8F8F8;
|
||||
border-top: 1px solid #E7E5DC;
|
||||
}
|
||||
|
||||
.ch_infobox .file_path {
|
||||
font-size: 0.9em;
|
||||
font-weight: bold;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.ch_infobox .description {
|
||||
color: #AAA;
|
||||
font-size: 0.9em;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component version="0.2">
|
||||
<component version="0.3">
|
||||
<title xml:lang="ko">Code Highlighter</title>
|
||||
<title xml:lang="jp">コードハイライト</title>
|
||||
<title xml:lang="zh-CN">代码高亮显示</title>
|
||||
<title xml:lang="zh-CN">代码高亮显示</title>
|
||||
<title xml:lang="en">Code Highlighter</title>
|
||||
<title xml:lang="ru">Подсветка кода</title>
|
||||
<author email_address="bnufactory@gmail.com" link="http://bnufactory.com" date="2007. 11. 29">
|
||||
<author email_address="bnufactory@gmail.com" link="http://bnufactory.com" date="2007. 12. 22">
|
||||
<name xml:lang="ko">BNU</name>
|
||||
<name xml:lang="jp">BNU</name>
|
||||
<name xml:lang="zh-CN">BNU</name>
|
||||
<name xml:lang="zh-CN">BNU</name>
|
||||
<name xml:lang="en">BNU</name>
|
||||
<name xml:lang="ru">BNU</name>
|
||||
<description xml:lang="ko">코드를 보기 좋게 출력합니다.</description>
|
||||
<description xml:lang="jp">ソースコードを見やすく表示します。</description>
|
||||
<description xml:lang="zh-CN">高亮显示所选代码。</description>
|
||||
<description xml:lang="zh-CN">高亮显示所选代码。</description>
|
||||
<description xml:lang="en">Component serving for code highlighting.</description>
|
||||
<description xml:lang="ru">Компонент служащий для подсветки кода</description>
|
||||
</author>
|
||||
|
|
|
|||
|
|
@ -9,4 +9,8 @@
|
|||
$lang->used_collapse = '접기 기능 사용';
|
||||
$lang->hidden_linenumber = '줄 번호 감추기';
|
||||
$lang->hidden_controls = '도구바 감추기';
|
||||
|
||||
$lang->file_path = '파일경로';
|
||||
$lang->description = '설명';
|
||||
$lang->first_line = '시작 줄 번호';
|
||||
?>
|
||||
|
|
@ -74,6 +74,7 @@ dp.sh.Toolbar.Commands = {
|
|||
.replace(/</g,'<')
|
||||
.replace(/>/g,'>')
|
||||
.replace(/&/g,'&')
|
||||
.replace(/ /g,' ')
|
||||
;
|
||||
|
||||
if(window.clipboardData)
|
||||
|
|
|
|||
|
|
@ -32,15 +32,28 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{$lang->used_collapse}</th>
|
||||
<th scope="row">{$lang->file_path}</th>
|
||||
<td>
|
||||
<input type="checkbox" id="collapse" name="collapse" value="Y" />
|
||||
<input type="text" id="file_path" name="file_path" class="inputTypeText w400" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{$lang->hidden_linenumber}</th>
|
||||
<th scope="row">{$lang->description}</th>
|
||||
<td>
|
||||
<input type="checkbox" id="nogutter" name="nogutter" value="Y" />
|
||||
<input type="text" id="description" name="description" class="inputTypeText w400" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{$lang->first_line}</th>
|
||||
<td>
|
||||
<input type="text" id="first_line" name="first_line" value="1" class="inputTypeText w40" />
|
||||
<input type="checkbox" id="nogutter" name="nogutter" value="Y" /> <label for="nogutter">{$lang->hidden_linenumber}</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{$lang->used_collapse}</th>
|
||||
<td>
|
||||
<input type="checkbox" id="collapse" name="collapse" value="Y" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -13,11 +13,18 @@ function getCode() {
|
|||
selected_node = node;
|
||||
|
||||
var code_type = node.getAttribute('code_type');
|
||||
var file_path = node.getAttribute('file_path');
|
||||
var description = node.getAttribute('description');
|
||||
var first_line = node.getAttribute('first_line');
|
||||
var collapse = node.getAttribute('collapse');
|
||||
var nogutter = node.getAttribute('nogutter');
|
||||
var nocontrols = node.getAttribute('nocontrols');
|
||||
|
||||
xGetElementById('code_type').value = code_type;
|
||||
xGetElementById('file_path').value = file_path;
|
||||
xGetElementById('description').value = description;
|
||||
if(!first_line) xGetElementById('first_line').value = '1';
|
||||
else xGetElementById('first_line').value = first_line;
|
||||
if(collapse == 'Y') xGetElementById('collapse').checked = true;
|
||||
if(nogutter == 'Y') xGetElementById('nogutter').checked = true;
|
||||
if(nocontrols == 'Y') xGetElementById('nocontrols').checked = true;
|
||||
|
|
@ -28,6 +35,9 @@ function insertCode() {
|
|||
if(typeof(opener)=='undefined') return;
|
||||
|
||||
var code_type = xGetElementById('code_type').value;
|
||||
var file_path = xGetElementById('file_path').value;
|
||||
var description = xGetElementById('description').value;
|
||||
var first_line = xGetElementById('first_line').value;
|
||||
var collapse = xGetElementById('collapse').checked;
|
||||
var nogutter = xGetElementById("nogutter").checked;
|
||||
var nocontrols = xGetElementById("nocontrols").checked;
|
||||
|
|
@ -40,25 +50,16 @@ function insertCode() {
|
|||
|
||||
if(!content) content = " ";
|
||||
|
||||
var text = "\n<div editor_component=\"code_highlighter\" code_type=\""+code_type+"\" style=\""+style+"\">"+content+"</div>\n<br />";
|
||||
var text = "\n"+'<div editor_component="code_highlighter" code_type="'+code_type+'" file_path="'+file_path+'" description="'+description+'" first_line="'+first_line+'" collapse="'+collapse+'" nogutter="'+nogutter+'" nocontrols="'+nocontrols+'" style="'+style+'">'+content+'</div>'+"\n<br />";
|
||||
|
||||
if(selected_node) {
|
||||
selected_node.setAttribute('code_type', code_type);
|
||||
if(collapse == true) {
|
||||
selected_node.setAttribute('collapse', 'Y');
|
||||
} else {
|
||||
selected_node.setAttribute('collapse', 'N');
|
||||
}
|
||||
if(nogutter == true) {
|
||||
selected_node.setAttribute('nogutter', 'Y');
|
||||
} else {
|
||||
selected_node.setAttribute('nogutter', 'N');
|
||||
}
|
||||
if(nocontrols == true && collapse == false) {
|
||||
selected_node.setAttribute('nocontrols', 'Y');
|
||||
} else {
|
||||
selected_node.setAttribute('nocontrols', 'N');
|
||||
}
|
||||
selected_node.setAttribute('file_path', file_path);
|
||||
selected_node.setAttribute('description', description);
|
||||
selected_node.setAttribute('first_line', first_line);
|
||||
selected_node.setAttribute("collapse", collapse);
|
||||
selected_node.setAttribute('nogutter', nogutter);
|
||||
selected_node.setAttribute('nocontrols', nocontrols);
|
||||
selected_node.setAttribute('style', style);
|
||||
opener.editorFocus(opener.editorPrevSrl);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue