CKEditor 사용 방법

4145 단어 CKEDITOR
자세히 보기

$(function() {
		Cms.siteFlow("${base}", location.href, document.referrer);
		CKEDITOR.replace( 'contents' );
		/* CKEDITOR.editorConfig = function( config ) {config.language = 'en';}; */
	});
function checkForm() {
		var title = $("#title").val();
		if (title == "") {
			alert(" !");
			return false;
		}
		var content = $("#content").val();
		if (content == "") {
			alert(" !");
			return false;
		}
		 $("#pubInfoForm").submit();
		/* var imageUrl = $("#imageUrl").val();
		var contents = CKEDITOR.instances.contents.getData();
		alert(contents);
		  $.ajax({
            type:"POST",
            url:"${base}/notice/publicMarket.jspx",
            data:{title:title,
            	  imageUrl:imageUrl,
            	  contents:encodeURI(contents)},
            datatype: "html",
            success:function(data){
            }   ,
            error: function(){
                alert(" !")
            }        
         }); */

textArea 상자 설정


주의: CKEiditor 패스에 잘못된 코드가 있습니다.

백그라운드에서 처리

String s1 =StringUtils.replace(mInfo.getContents(), "“", "\\\"");

String s2 =StringUtils.replace(s1, "<", "String s3 =StringUtils.replace(s2, ">", ">");

String s4 =StringUtils.replace(s3, ";", ";");

String s5 =StringUtils.replace(s4, "/", "\\/");

프론트 데스크 페이지 표시

CKEDITOR.instances.contents.setData('${mInfo.contents!}');

$("#contents").html('${mInfo.contents!}');

CKEDITOR 자동 줄 바꿈 문제는 config입니다.js에서 설정 규칙,

CKEDITOR.on( 'instanceReady', function( ev ) { with (ev.editor.dataProcessor.writer) {
setRules("p", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("h1", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("h2", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("h3", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("h4", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("h5", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("div", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("table", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("tr", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("td", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("iframe", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("li", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("ul", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
setRules("ol", {indent : false, breakBeforeOpen : false, breakAfterOpen : false, breakBeforeClose : false, breakAfterClose : false} );
}
});


좋은 웹페이지 즐겨찾기