Index: base3.10/src/main/java/froala/editor/web/EditorController.java
===================================================================
--- base3.10/src/main/java/froala/editor/web/EditorController.java (revision 70)
+++ base3.10/src/main/java/froala/editor/web/EditorController.java (revision 71)
@@ -116,7 +116,7 @@
// DB부분
String fileId = editorService.insertEditorFile(fileVO);
- fileVO.setFileId(null);
+ fileVO.setFileId(fileId);
fileVO.setFullPath(null);
fileVO.setUploadDir(null);
fileVO.setSysFileNm(null);
Index: base3.10/src/main/webapp/resource/editor/js/froala_editor_script_custom.js
===================================================================
--- base3.10/src/main/webapp/resource/editor/js/froala_editor_script_custom.js (revision 70)
+++ base3.10/src/main/webapp/resource/editor/js/froala_editor_script_custom.js (revision 71)
@@ -31,7 +31,6 @@
hiddenFileName: 'atch_file_editor_id',
inputFileId: '',
maxSize : 10, // 첨부파일 개수
-// sysUrl: window.location.protocol + "//" + window.location.host,
txtAreaId: 'nttCn',
authorType : 'user', // 파일 목록 디자인(사용자, 관리자)
toolbarSticky: false //툴바 고정 해제
@@ -86,21 +85,47 @@
fncMaxLength(editor.options);
})
// uploaded -> inserted -> loaded
- .on('froalaEditor.image.uploaded', function (e, editor, response) {
+ .on('froalaEditor.image.uploaded', function (e, ed, html) {
// Do something here.
- //console.log("uploaded");
+ //console.log("uploaded", e, ed, html);
+ if( editor.options.inputFileId != '' ) {
+ var link = JSON.parse(html);
+
+ var dom = '';
+ if(options.authorType != 'user'){
+ dom = defaultsDom(link);
+ }else{
+ dom = defaultsDomUser(link);
+ }
+
+ $('#'+editor.options.fileListDivId).append(dom);
+ // 업로드시 div 표시
+ $('#' + editor.options.fileListDivId).removeAttr('style');
+
+ // 이벤트 추가
+ fncFileTrigger(link);
+
+ var atch_id = $('input[name="'+editor.options.hiddenFileName+'"]').val();
+
+ if (atch_id.length == 0) {
+ atch_id = link.fileId;
+ } else {
+ atch_id = atch_id + "," + link.fileId;
+ }
+
+ $('input[name="'+editor.options.hiddenFileName+'"]').val(atch_id);
+ }
})
.on('froalaEditor.image.loaded', function (e, editor, $img) {
// Do something here.
-// console.log("loaded");
+// console.log("loaded", e, editor, $img);
})
.on('froalaEditor.image.inserted', function (e, editor, $img, response) {
// Do something here.
- //console.log("inserted");
+// console.log("inserted", e, editor, $img, response);
})
// Catch image removal from the editor.
.on('froalaEditor.image.removed', function (e, editor, $img) {
-// console.log($img);
$.ajax({
// Request method.
method: "POST",
@@ -124,7 +149,7 @@
fncUnlink(editor.options, link.getAttribute('href'));
})
.on('froalaEditor.file.uploaded', function (e, ed, html) {
- // Do something here.
+// console.log(e, ed, html);
if( editor.options.inputFileId != '' ) {
var link = JSON.parse(html);
@@ -308,7 +333,12 @@
//파일 에디터에 넣기
var fncFileInsert = function(options, link, name) {
- $('#'+options.txtAreaId).froalaEditor('file.insert', link, name, {link: link});
+ // 이미지 여부 확인
+ if (isFileImage(name)) {
+ $('#'+options.txtAreaId).froalaEditor('image.insert', link);
+ } else {
+ $('#'+options.txtAreaId).froalaEditor('file.insert', link, name, {link: link});
+ }
}
//파일 이벤트 추가(삭제, 본문에 넣기)
@@ -506,6 +536,11 @@
}
return fileSize;
}
+ // 이미지 여부
+ function isFileImage(fileName) {
+ const acceptedImageType = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tif', 'tiff'];
+ return acceptedImageType.includes(fileName.split('.').reverse()[0]);
+ }
})(jQuery);
/*
*=====================================
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?