191 lines
5.8 KiB
JavaScript
191 lines
5.8 KiB
JavaScript
function drawEditor(strBody, content, strReadonly)
|
|
{
|
|
if(strReadonly)
|
|
{
|
|
drawEditorRead(strBody, content);
|
|
}
|
|
else
|
|
{
|
|
drawEditorWrite(strBody, content);
|
|
}
|
|
}
|
|
|
|
|
|
//----------------------------------------
|
|
// html 초기화(Write)
|
|
// ----------------------------------------
|
|
function drawEditorWrite(strBody, content)
|
|
{
|
|
var strSelector = '#'+strBody
|
|
|
|
tinymce.init({
|
|
forced_root_block : false,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
|
|
language: 'ko',
|
|
language_url: '/js/tiny_lang/ko.js',
|
|
|
|
selector: strSelector,
|
|
height: 300,
|
|
min_height: 300, // 최소 높이
|
|
toolbar_mode: 'floating',
|
|
//image upload
|
|
image_title: true,
|
|
automatic_uploads: true,
|
|
file_picker_types: 'image',
|
|
file_picker_callback: (cb, value, meta) => {
|
|
const input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
input.addEventListener('change', (e) => {
|
|
const file = e.target.files[0];
|
|
|
|
const reader = new FileReader();
|
|
reader.addEventListener('load', () => {
|
|
const id = 'blobid' + (new Date()).getTime();
|
|
const blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
const base64 = reader.result.split(',')[1];
|
|
const blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
});
|
|
reader.readAsDataURL(file);
|
|
});
|
|
|
|
input.click();
|
|
},
|
|
statusbar: false,
|
|
|
|
// fontsizeinput : 폰트사이즈 사용자 입력
|
|
// fontsizeselect : 폰트사이즈 사용자 선택
|
|
// help 도움말보기
|
|
// 2025.05.21 나혁제 resizable 삭제 플러그인 없음
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table paste code wordcount autoresize '
|
|
],
|
|
toolbar: 'undo redo | fontsizeselect | formatselect | fontselect | '
|
|
+ 'bold italic forecolor backcolor | alignleft aligncenter | '
|
|
+ 'alignright alignjustify | bullist numlist outdent indent | '
|
|
+ 'table | removeformat |'
|
|
+ 'preview print '
|
|
,
|
|
|
|
content_css: '/css/tinymce_font.css', // 외부 CSS 파일 경로
|
|
|
|
font_family_formats:
|
|
'Malgun Gothic=Malgun Gothic;',
|
|
|
|
font_formats:
|
|
'맑은 고딕=Malgun Gothic;'
|
|
+ '돋움=Dotum;'
|
|
+ '돋움체=DotumChe;'
|
|
+ '굴림=Gulim;'
|
|
+ '굴림체=GulimChe;'
|
|
+ '바탕=Batang;'
|
|
+ '바탕체=BatangChe;'
|
|
+ 'Andale Mono=andale mono,times;'
|
|
+ 'Arial=arial,helvetica,sans-serif;'
|
|
+ 'Arial Black=arial black,avant garde;'
|
|
+ 'Book Antiqua=book antiqua,palatino;'
|
|
+ 'Comic Sans MS=comic sans ms,sans-serif;'
|
|
+ 'Courier New=courier new,courier;'
|
|
+ 'Georgia=georgia,palatino;'
|
|
+ 'Helvetica=helvetica;'
|
|
+ 'Impact=impact,chicago;'
|
|
+ 'Symbol=symbol;'
|
|
+ 'Tahoma=tahoma,arial,helvetica,sans-serif;'
|
|
+ 'Terminal=terminal,monaco;'
|
|
+ 'Times New Roman=times new roman,times;'
|
|
+ 'Trebuchet MS=trebuchet ms,geneva;'
|
|
+ 'Verdana=verdana,geneva;'
|
|
+ 'Webdings=webdings;'
|
|
+ 'Wingdings=wingdings,zapf dingbats;'
|
|
|
|
});
|
|
|
|
if(content===undefined || content=='' || content==null)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
tinyMCE.activeEditor.setContent(content);
|
|
}
|
|
}
|
|
|
|
//----------------------------------------
|
|
// html 초기화
|
|
// ----------------------------------------
|
|
function drawEditorRead(strBody, content)
|
|
{
|
|
var strSelector = '#'+strBody
|
|
|
|
tinymce.init({
|
|
forced_root_block : false,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
|
|
selector: strSelector,
|
|
height: 300,
|
|
min_height: 300, // 최소 높이
|
|
toolbar_mode: 'floating',
|
|
// readonly: 1,
|
|
menubar: false,
|
|
//image upload
|
|
image_title: true,
|
|
statusbar: false,
|
|
automatic_uploads: true,
|
|
file_picker_types: 'image',
|
|
file_picker_callback: (cb, value, meta) => {
|
|
const input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
input.addEventListener('change', (e) => {
|
|
const file = e.target.files[0];
|
|
|
|
const reader = new FileReader();
|
|
reader.addEventListener('load', () => {
|
|
const id = 'blobid' + (new Date()).getTime();
|
|
const blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
const base64 = reader.result.split(',')[1];
|
|
const blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
});
|
|
reader.readAsDataURL(file);
|
|
});
|
|
|
|
input.click();
|
|
},
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table paste code help wordcount autoresize'
|
|
],
|
|
toolbar: 'preview print ',
|
|
/*
|
|
toolbar: 'undo redo | fontsizeselect | formatselect | ' +
|
|
'bold italic forecolor backcolor | alignleft aligncenter ' +
|
|
'alignright alignjustify | bullist numlist outdent indent | ' +
|
|
'table | removeformat ',
|
|
*/
|
|
setup: function (editor) {
|
|
// 버튼은 클릭 가능하도록 허용
|
|
editor.on('init', function () {
|
|
editor.getBody().setAttribute('contenteditable', false); // 이걸 제거하면 툴바도 비활성화됨
|
|
});
|
|
}
|
|
});
|
|
if(content===undefined){
|
|
}else{
|
|
tinyMCE.activeEditor.setContent(content);
|
|
}
|
|
}
|
|
|