smarteditor2 code lint

This commit is contained in:
Amberstone 2024-09-20 20:30:44 +09:00
parent bcf53b3a41
commit 4cc841ced1
Signed by: amber
GPG key ID: 094B0E55F98D8BF1
15 changed files with 28766 additions and 26876 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,30 +1,30 @@
(function($){
$(document).ready(function() {
$(".smarteditor2").each( function(index){
var get_id = $(this).attr("id");
(function ($) {
$(document).ready(function () {
$(".smarteditor2").each(function (index) {
var get_id = $(this).attr("id");
if( !get_id || $(this).prop("nodeName") != 'TEXTAREA' ) return true;
if (!get_id || $(this).prop("nodeName") != 'TEXTAREA') return true;
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors,
elPlaceHolder: get_id,
sSkinURI: g5_editor_url+"/SmartEditor2Skin.html",
htParams : {
bUseToolbar : true, // 툴바 사용 여부 (true:사용/ false:사용하지 않음)
bUseVerticalResizer : true, // 입력창 크기 조절바 사용 여부 (true:사용/ false:사용하지 않음)
bUseModeChanger : true, // 모드 탭(Editor | HTML | TEXT) 사용 여부 (true:사용/ false:사용하지 않음)
bSkipXssFilter : true, // client-side xss filter 무시 여부 (true:사용하지 않음 / 그외:사용)
//aAdditionalFontList : aAdditionalFontSet, // 추가 글꼴 목록
fOnBeforeUnload : function(){
//alert("완료!");
}
}, //boolean
fOnAppLoad : function(){
//예제 코드
//oEditors.getById["ir1"].exec("PASTE_HTML", ["로딩이 완료된 후에 본문에 삽입되는 text입니다."]);
},
fCreator: "createSEditor2"
});
});
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors,
elPlaceHolder: get_id,
sSkinURI: g5_editor_url + "/SmartEditor2Skin.html",
htParams: {
bUseToolbar: true, // 툴바 사용 여부 (true:사용/ false:사용하지 않음)
bUseVerticalResizer: true, // 입력창 크기 조절바 사용 여부 (true:사용/ false:사용하지 않음)
bUseModeChanger: true, // 모드 탭(Editor | HTML | TEXT) 사용 여부 (true:사용/ false:사용하지 않음)
bSkipXssFilter: true, // client-side xss filter 무시 여부 (true:사용하지 않음 / 그외:사용)
//aAdditionalFontList : aAdditionalFontSet, // 추가 글꼴 목록
fOnBeforeUnload: function () {
//alert("완료!");
}
}, //boolean
fOnAppLoad: function () {
//예제 코드
//oEditors.getById["ir1"].exec("PASTE_HTML", ["로딩이 완료된 후에 본문에 삽입되는 text입니다."]);
},
fCreator: "createSEditor2"
});
});
});
})(jQuery);

View file

@ -1,24 +1,123 @@
@charset "UTF-8";
/* NHN Web Standardization Team (http://html.nhndesign.com/) HHJ 090226 */
/* COMMON */
body,.se2_inputarea{margin:0;padding:0;font-family:'돋움',Dotum,Helvetica,Sans-serif;font-size:12px;line-height:1.5}
/* body,.se2_inputarea,.se2_inputarea th,.se2_inputarea td{margin:0;padding:0;font-family:'돋움',Dotum,Helvetica,Sans-serif;font-size:12px;line-height:1.5;color:#666} */
.se2_inputarea p,.se2_inputarea br{margin:0;padding:0}
.se2_inputarea{margin:15px;word-wrap:break-word;*word-wrap:normal;*word-break:break-all}
.se2_inputarea td{word-break:break-all}
.se2_inputarea_890{width:741px;margin:20px 0 10px 64px}
.se2_inputarea_698{width:548px;margin:20px 0 10px 64px}
@media screen and (-webkit-min-device-pixel-ratio: 0) {
.se2_inputarea td:empty:after,.se2_inputarea td > p:empty:after{content:"\00A0";line-height:1}
body,
.se2_inputarea {
margin: 0;
padding: 0;
font-family: '돋움', Dotum, Helvetica, Sans-serif;
font-size: 12px;
line-height: 1.5
}
/* body,.se2_inputarea,.se2_inputarea th,.se2_inputarea td{margin:0;padding:0;font-family:'돋움',Dotum,Helvetica,Sans-serif;font-size:12px;line-height:1.5;color:#666} */
.se2_inputarea p,
.se2_inputarea br {
margin: 0;
padding: 0
}
.se2_inputarea {
margin: 15px;
word-wrap: break-word;
*word-wrap: normal;
*word-break: break-all
}
.se2_inputarea td {
word-break: break-all
}
.se2_inputarea_890 {
width: 741px;
margin: 20px 0 10px 64px
}
.se2_inputarea_698 {
width: 548px;
margin: 20px 0 10px 64px
}
@media screen and (-webkit-min-device-pixel-ratio: 0) {
.se2_inputarea td:empty:after,
.se2_inputarea td>p:empty:after {
content: "\00A0";
line-height: 1
}
}
/* TEXT_TOOLBAR : QUOTE */
.se2_quote1{margin:0 0 30px 20px;padding:0 8px;border-left:2px solid #ccc;color:#888}
.se2_quote2{margin:0 0 30px 13px;padding:0 8px 0 16px;background:url("../../img/bg_quote2.gif") 0 3px no-repeat;color:#888}
.se2_quote3{margin:0 0 30px;padding:12px 10px 11px;border:1px dashed #ccc;color:#888}
.se2_quote4{margin:0 0 30px;padding:12px 10px 11px;border:1px dashed #66b246;color:#888}
.se2_quote5{margin:0 0 30px;padding:12px 10px 11px;border:1px dashed #ccc;background:#fafafa;color:#888}
.se2_quote6{margin:0 0 30px;padding:12px 10px 11px;border:1px solid #e5e5e5;color:#888}
.se2_quote7{margin:0 0 30px;padding:12px 10px 11px;border:1px solid #66b246;color:#888}
.se2_quote8{margin:0 0 30px;padding:12px 10px 11px;border:1px solid #e5e5e5;background:#fafafa;color:#888}
.se2_quote9{margin:0 0 30px;padding:12px 10px 11px;border:2px solid #e5e5e5;color:#888}
.se2_quote10{margin:0 0 30px;padding:12px 10px 11px;border:2px solid #e5e5e5;background:#fafafa;color:#888}
.se2_quote1 {
margin: 0 0 30px 20px;
padding: 0 8px;
border-left: 2px solid #ccc;
color: #888
}
.se2_quote2 {
margin: 0 0 30px 13px;
padding: 0 8px 0 16px;
background: url("../../img/bg_quote2.gif") 0 3px no-repeat;
color: #888
}
.se2_quote3 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 1px dashed #ccc;
color: #888
}
.se2_quote4 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 1px dashed #66b246;
color: #888
}
.se2_quote5 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 1px dashed #ccc;
background: #fafafa;
color: #888
}
.se2_quote6 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 1px solid #e5e5e5;
color: #888
}
.se2_quote7 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 1px solid #66b246;
color: #888
}
.se2_quote8 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 1px solid #e5e5e5;
background: #fafafa;
color: #888
}
.se2_quote9 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 2px solid #e5e5e5;
color: #888
}
.se2_quote10 {
margin: 0 0 30px;
padding: 12px 10px 11px;
border: 2px solid #e5e5e5;
background: #fafafa;
color: #888
}

View file

@ -1,43 +1,44 @@
<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if (!defined('_GNUBOARD_'))
exit; // 개별 페이지 접근 불가
function editor_html($id, $content, $is_dhtml_editor=true)
function editor_html($id, $content, $is_dhtml_editor = true)
{
global $g5, $config, $w, $board, $write;
static $js = true;
global $g5, $config, $w, $board, $write;
static $js = true;
if(
$is_dhtml_editor && $content &&
(
(!$w && (isset($board['bo_insert_content']) && !empty($board['bo_insert_content'])))
|| ($w == 'u' && isset($write['wr_option']) && strpos($write['wr_option'], 'html') === false )
)
){ //글쓰기 기본 내용 처리
if( preg_match('/\r|\n/', $content) && $content === strip_tags($content, '<a><strong><b>') ) { //textarea로 작성되고, html 내용이 없다면
$content = nl2br($content);
}
if (
$is_dhtml_editor && $content &&
(
(!$w && (isset($board['bo_insert_content']) && !empty($board['bo_insert_content'])))
|| ($w == 'u' && isset($write['wr_option']) && strpos($write['wr_option'], 'html') === false)
)
) { //글쓰기 기본 내용 처리
if (preg_match('/\r|\n/', $content) && $content === strip_tags($content, '<a><strong><b>')) { //textarea로 작성되고, html 내용이 없다면
$content = nl2br($content);
}
}
$editor_url = G5_EDITOR_URL.'/'.$config['cf_editor'];
$editor_url = G5_EDITOR_URL . '/' . $config['cf_editor'];
$html = "";
$html .= "<span class=\"sound_only\">웹에디터 시작</span>";
if ($is_dhtml_editor)
$html .= '<script>document.write("<div class=\'cke_sc\'><button type=\'button\' class=\'btn_cke_sc\'>단축키 일람</button></div>");</script>';
$html = "";
$html .= "<span class=\"sound_only\">웹에디터 시작</span>";
if ($is_dhtml_editor)
$html .= '<script>document.write("<div class=\'cke_sc\'><button type=\'button\' class=\'btn_cke_sc\'>단축키 일람</button></div>");</script>';
if ($is_dhtml_editor && $js) {
$html .= "\n".'<script src="'.$editor_url.'/js/service/HuskyEZCreator.js"></script>';
$html .= "\n".'<script>var g5_editor_url = "'.$editor_url.'", oEditors = [], ed_nonce = "'.ft_nonce_create('smarteditor').'";</script>';
$html .= "\n".'<script src="'.$editor_url.'/config.js"></script>';
$html .= "\n<script>";
$html .= '
if ($is_dhtml_editor && $js) {
$html .= "\n" . '<script src="' . $editor_url . '/js/service/HuskyEZCreator.js"></script>';
$html .= "\n" . '<script>var g5_editor_url = "' . $editor_url . '", oEditors = [], ed_nonce = "' . ft_nonce_create('smarteditor') . '";</script>';
$html .= "\n" . '<script src="' . $editor_url . '/config.js"></script>';
$html .= "\n<script>";
$html .= '
$(function(){
$(".btn_cke_sc").click(function(){
if ($(this).next("div.cke_sc_def").length) {
$(this).next("div.cke_sc_def").remove();
$(this).text("단축키 일람");
} else {
$(this).after("<div class=\'cke_sc_def\' />").next("div.cke_sc_def").load("'.$editor_url.'/shortcut.html");
$(this).after("<div class=\'cke_sc_def\' />").next("div.cke_sc_def").load("' . $editor_url . '/shortcut.html");
$(this).text("단축키 일람 닫기");
}
});
@ -45,36 +46,36 @@ function editor_html($id, $content, $is_dhtml_editor=true)
$(this).parent("div.cke_sc_def").remove();
});
});';
$html .= "\n</script>";
$js = false;
}
$html .= "\n</script>";
$js = false;
}
$smarteditor_class = $is_dhtml_editor ? "smarteditor2" : "";
$html .= "\n<textarea id=\"$id\" name=\"$id\" class=\"$smarteditor_class\" maxlength=\"65536\" style=\"width:100%;height:300px\">$content</textarea>";
$html .= "\n<span class=\"sound_only\">웹 에디터 끝</span>";
return $html;
$smarteditor_class = $is_dhtml_editor ? "smarteditor2" : "";
$html .= "\n<textarea id=\"$id\" name=\"$id\" class=\"$smarteditor_class\" maxlength=\"65536\" style=\"width:100%;height:300px\">$content</textarea>";
$html .= "\n<span class=\"sound_only\">웹 에디터 끝</span>";
return $html;
}
// textarea 로 값을 넘긴다. javascript 반드시 필요
function get_editor_js($id, $is_dhtml_editor=true)
function get_editor_js($id, $is_dhtml_editor = true)
{
if ($is_dhtml_editor) {
return "var {$id}_editor_data = oEditors.getById['{$id}'].getIR();\noEditors.getById['{$id}'].exec('UPDATE_CONTENTS_FIELD', []);\nif(jQuery.inArray(document.getElementById('{$id}').value.toLowerCase().replace(/^\s*|\s*$/g, ''), ['&nbsp;','<p>&nbsp;</p>','<p><br></p>','<div><br></div>','<p></p>','<br>','']) != -1){document.getElementById('{$id}').value='';}\n";
} else {
return "var {$id}_editor = document.getElementById('{$id}');\n";
}
if ($is_dhtml_editor) {
return "var {$id}_editor_data = oEditors.getById['{$id}'].getIR();\noEditors.getById['{$id}'].exec('UPDATE_CONTENTS_FIELD', []);\nif(jQuery.inArray(document.getElementById('{$id}').value.toLowerCase().replace(/^\s*|\s*$/g, ''), ['&nbsp;','<p>&nbsp;</p>','<p><br></p>','<div><br></div>','<p></p>','<br>','']) != -1){document.getElementById('{$id}').value='';}\n";
} else {
return "var {$id}_editor = document.getElementById('{$id}');\n";
}
}
// textarea 의 값이 비어 있는지 검사
function chk_editor_js($id, $is_dhtml_editor=true)
function chk_editor_js($id, $is_dhtml_editor = true)
{
if ($is_dhtml_editor) {
return "if (!{$id}_editor_data || jQuery.inArray({$id}_editor_data.toLowerCase(), ['&nbsp;','<p>&nbsp;</p>','<p><br></p>','<p></p>','<br>']) != -1) { alert(\"내용을 입력해 주십시오.\"); oEditors.getById['{$id}'].exec('FOCUS'); return false; }\n";
} else {
return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";
}
if ($is_dhtml_editor) {
return "if (!{$id}_editor_data || jQuery.inArray({$id}_editor_data.toLowerCase(), ['&nbsp;','<p>&nbsp;</p>','<p><br></p>','<p></p>','<br>']) != -1) { alert(\"내용을 입력해 주십시오.\"); oEditors.getById['{$id}'].exec('FOCUS'); return false; }\n";
} else {
return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";
}
}
/*
@ -82,90 +83,95 @@ https://github.com/timostamm/NonceUtil-PHP
*/
if (!defined('FT_NONCE_UNIQUE_KEY'))
define( 'FT_NONCE_UNIQUE_KEY' , sha1($_SERVER['SERVER_SOFTWARE'].G5_MYSQL_USER.session_id().G5_TABLE_PREFIX) );
define('FT_NONCE_UNIQUE_KEY', sha1($_SERVER['SERVER_SOFTWARE'] . G5_MYSQL_USER . session_id() . G5_TABLE_PREFIX));
if (!defined('FT_NONCE_SESSION_KEY'))
define( 'FT_NONCE_SESSION_KEY' , substr(md5(FT_NONCE_UNIQUE_KEY), 5) );
define('FT_NONCE_SESSION_KEY', substr(md5(FT_NONCE_UNIQUE_KEY), 5));
if (!defined('FT_NONCE_DURATION'))
define( 'FT_NONCE_DURATION' , 60 * 60 ); // 300 makes link or form good for 5 minutes from time of generation, 300은 5분간 유효, 60 * 60 은 1시간
define('FT_NONCE_DURATION', 60 * 60); // 300 makes link or form good for 5 minutes from time of generation, 300은 5분간 유효, 60 * 60 은 1시간
if (!defined('FT_NONCE_KEY'))
define( 'FT_NONCE_KEY' , '_nonce' );
define('FT_NONCE_KEY', '_nonce');
// This method creates a key / value pair for a url string
if(!function_exists('ft_nonce_create_query_string')){
function ft_nonce_create_query_string( $action = '' , $user = '' ){
return FT_NONCE_KEY."=".ft_nonce_create( $action , $user );
}
if (!function_exists('ft_nonce_create_query_string')) {
function ft_nonce_create_query_string($action = '', $user = '')
{
return FT_NONCE_KEY . "=" . ft_nonce_create($action, $user);
}
}
if(!function_exists('ft_get_secret_key')){
function ft_get_secret_key($secret){
return md5(FT_NONCE_UNIQUE_KEY.$secret);
}
if (!function_exists('ft_get_secret_key')) {
function ft_get_secret_key($secret)
{
return md5(FT_NONCE_UNIQUE_KEY . $secret);
}
}
// This method creates an nonce. It should be called by one of the previous two functions.
if(!function_exists('ft_nonce_create')){
function ft_nonce_create( $action = '',$user='', $timeoutSeconds=FT_NONCE_DURATION ){
if (!function_exists('ft_nonce_create')) {
function ft_nonce_create($action = '', $user = '', $timeoutSeconds = FT_NONCE_DURATION)
{
$secret = ft_get_secret_key($action.$user);
$secret = ft_get_secret_key($action . $user);
set_session('token_'.FT_NONCE_SESSION_KEY, $secret);
set_session('token_' . FT_NONCE_SESSION_KEY, $secret);
$salt = ft_nonce_generate_hash();
$time = time();
$maxTime = $time + $timeoutSeconds;
$nonce = $salt . "|" . $maxTime . "|" . sha1( $salt . $secret . $maxTime );
return $nonce;
$salt = ft_nonce_generate_hash();
$time = time();
$maxTime = $time + $timeoutSeconds;
$nonce = $salt . "|" . $maxTime . "|" . sha1($salt . $secret . $maxTime);
return $nonce;
}
}
}
// This method validates an nonce
if(!function_exists('ft_nonce_is_valid')){
function ft_nonce_is_valid( $nonce, $action = '', $user='' ){
if (!function_exists('ft_nonce_is_valid')) {
function ft_nonce_is_valid($nonce, $action = '', $user = '')
{
$secret = ft_get_secret_key($action.$user);
$secret = ft_get_secret_key($action . $user);
$token = get_session('token_'.FT_NONCE_SESSION_KEY);
$token = get_session('token_' . FT_NONCE_SESSION_KEY);
if ($secret != $token){
return false;
}
if (is_string($nonce) == false) {
return false;
}
$a = explode('|', $nonce);
if (count($a) != 3) {
return false;
}
$salt = $a[0];
$maxTime = intval($a[1]);
$hash = $a[2];
$back = sha1( $salt . $secret . $maxTime );
if ($back != $hash) {
return false;
}
if (time() > $maxTime) {
return false;
}
return true;
if ($secret != $token) {
return false;
}
if (is_string($nonce) == false) {
return false;
}
$a = explode('|', $nonce);
if (count($a) != 3) {
return false;
}
$salt = $a[0];
$maxTime = intval($a[1]);
$hash = $a[2];
$back = sha1($salt . $secret . $maxTime);
if ($back != $hash) {
return false;
}
if (time() > $maxTime) {
return false;
}
return true;
}
}
// This method generates the nonce timestamp
if(!function_exists('ft_nonce_generate_hash')){
function ft_nonce_generate_hash(){
$length = 10;
$chars='1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
$ll = strlen($chars)-1;
$o = '';
while (strlen($o) < $length) {
$o .= $chars[ rand(0, $ll) ];
}
return $o;
if (!function_exists('ft_nonce_generate_hash')) {
function ft_nonce_generate_hash()
{
$length = 10;
$chars = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
$ll = strlen($chars) - 1;
$o = '';
while (strlen($o) < $length) {
$o .= $chars[rand(0, $ll)];
}
return $o;
}
}

View file

@ -1,23 +1,23 @@
<dl>
<dt>CTRL+B</dt>
<dd>글자 굵게</dd>
<dt>CTRL+U</dt>
<dd>글자 밑줄</dd>
<dt>CTRL+I</dt>
<dd>글자 기울임</dd>
<dt>CTRL+D</dt>
<dd>글자 취소선</dd>
<dt>TAB</dt>
<dd>들여쓰기</dd>
<dt>SHIFT+TAB</dt>
<dd>내어쓰기</dd>
<dt>CTRL+K</dt>
<dd>링크 걸기</dd>
<dt>CTRL+F</dt>
<dd>단어 찾기</dd>
<dt>CTRL+H</dt>
<dd>단어 바꾸기</dd>
<dt>CTRL+A</dt>
<dd>전체 선택</dd>
<dt>CTRL+B</dt>
<dd>글자 굵게</dd>
<dt>CTRL+U</dt>
<dd>글자 밑줄</dd>
<dt>CTRL+I</dt>
<dd>글자 기울임</dd>
<dt>CTRL+D</dt>
<dd>글자 취소선</dd>
<dt>TAB</dt>
<dd>들여쓰기</dd>
<dt>SHIFT+TAB</dt>
<dd>내어쓰기</dd>
<dt>CTRL+K</dt>
<dd>링크 걸기</dd>
<dt>CTRL+F</dt>
<dd>단어 찾기</dd>
<dt>CTRL+H</dt>
<dd>단어 바꾸기</dd>
<dt>CTRL+A</dt>
<dd>전체 선택</dd>
</dl>
<button type="button" class="btn_cke_sc_close">닫기</button>

View file

@ -1,8 +1,11 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Smart Editor&#8482; WYSIWYG Mode</title>
<meta charset="utf-8">
<title>Smart Editor&#8482; WYSIWYG Mode</title>
</head>
<body class="se2_inputarea" style="height:0;-webkit-nbsp-mode:normal"></body>
</html>

View file

@ -1,9 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<title>Smart Editor&#8482; WYSIWYG Mode</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<title>Smart Editor&#8482; WYSIWYG Mode</title>
</head>
<body class="se2_inputarea" style="height:0"></body>
</html>