|
|
@@ -0,0 +1,110 @@
|
|
|
+/*
|
|
|
+ * Summernote Java Script written by gagamel.
|
|
|
+ *
|
|
|
+ * Copyright (c) 2010 gagamel
|
|
|
+ * Dual licensed under GPL (GPL-LICENSE.txt) licenses.
|
|
|
+ *
|
|
|
+ * $Date: 2020-10-29 $
|
|
|
+ *
|
|
|
+ * 사용 예)
|
|
|
+ * // HTML 태그는 textarea로 구성
|
|
|
+ * // id는 gagaSn.summernote 함수 호출 시에 넘겨줘야 한다.
|
|
|
+ * <textarea class="textareaR4" name="clauseContent" id="clauseContent"></textarea>
|
|
|
+ *
|
|
|
+ * // Import할 자바스크립트 파일
|
|
|
+ * <script type="text/javascript" src="/ux/plugins/summernote/summernote.js?v=2020102902"></script>
|
|
|
+ * <script type="text/javascript" src="/ux/plugins/gaga/gaga.summernote.js?v=2020102902"></script>
|
|
|
+ *
|
|
|
+ * <script type="text/javascript">
|
|
|
+ * // Get a summernote options
|
|
|
+ * var snOptions = gagaSn.getToolbarOptions();
|
|
|
+ *
|
|
|
+ * $(document).ready(function() {
|
|
|
+ * // Create a summernote
|
|
|
+ * gagaSn.createSummernote(snOptions, '#clauseContent');
|
|
|
+ * });
|
|
|
+ * </script>
|
|
|
+ */
|
|
|
+
|
|
|
+var gagaSn = {
|
|
|
+ /**
|
|
|
+ * Get a Toolbar options
|
|
|
+ * @param type - 유형(default, media: 사진/동영상 업로드)
|
|
|
+ */
|
|
|
+ getToolbarOptions : function(type) {
|
|
|
+ if (typeof(type) == 'undefined' || type == 'default') {
|
|
|
+ return [
|
|
|
+ ['style', ['style']],
|
|
|
+ ['Font Style', ['fontname']],
|
|
|
+ ['fontsize', ['fontsize']],
|
|
|
+ ['height', ['height']],
|
|
|
+ ['style', ['bold', 'italic', 'underline','clear']],
|
|
|
+ ['font', ['strikethrough', 'superscript', 'subscript']],
|
|
|
+ ['color', ['color']],
|
|
|
+ ['para', ['ul', 'ol', 'paragraph']],
|
|
|
+ ['Insert', ['table']],
|
|
|
+ ['Insert', ['link']],
|
|
|
+ ['misc', ['emoji', 'print']], // 이모지, 프린트
|
|
|
+ ['code', ['fullscreen', 'codeview', 'help']]
|
|
|
+ ];
|
|
|
+ } else if (type == 'media') {
|
|
|
+ return [
|
|
|
+ ['style', ['style']],
|
|
|
+ ['Font Style', ['fontname']],
|
|
|
+ ['fontsize', ['fontsize']],
|
|
|
+ ['height', ['height']],
|
|
|
+ ['style', ['bold', 'italic', 'underline','clear']],
|
|
|
+ ['font', ['strikethrough', 'superscript', 'subscript']],
|
|
|
+ ['color', ['color']],
|
|
|
+ ['para', ['ul', 'ol', 'paragraph']],
|
|
|
+ ['Insert', ['table']],
|
|
|
+ ['Insert', ['link', 'picture', 'video']],
|
|
|
+ ['misc', ['emoji', 'print']], // 이모지, 프린트
|
|
|
+ ['code', ['fullscreen', 'codeview', 'help']]
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create a summernote
|
|
|
+ * @param toolbarOptions - 툴바옵션
|
|
|
+ * @param editorId - 에디터 ID
|
|
|
+ * @param editorHeight - 에디터 height
|
|
|
+ */
|
|
|
+ createSummernote : function(toolbarOptions, editorId, editorHeight) {
|
|
|
+ if (typeof(editorHeight) == 'undefined') editorHeight = 300;
|
|
|
+
|
|
|
+ $(editorId).summernote({
|
|
|
+ disableDragAndDrop: true, //drag&drop 사용안함
|
|
|
+ placeholder: '내용을 입력하세요',
|
|
|
+ height: editorHeight, //에디터 기본 높이
|
|
|
+ lang : 'ko-KR', //기본 언어 인코딩
|
|
|
+ fontNames: ['Malgun Gothic', 'HY견고딕', 'Helvetica', 'Verdana', 'Arial', 'Arial Black'], //폰트 스타일
|
|
|
+ fontNamesIgnoreCheck: ['Malgun Gothic'], //기본폰트 스타일
|
|
|
+ focus: true, //로드시 에디터창에 포커싱
|
|
|
+ fontSizes: ['8','9','10','11','12','13','14','15','16','17','18','19','20','24','30','36'],
|
|
|
+ toolbar: toolbarOptions,
|
|
|
+ callbacks: {
|
|
|
+ onImageUpload: function(files, editor, welEditable) { //이미지 업로드
|
|
|
+ for (var i = files.length - 1; i >= 0; i--) {
|
|
|
+ sendFile(files[i], this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set value to summernote
|
|
|
+ */
|
|
|
+ setContents : function(editorId, content) {
|
|
|
+ var content = content.replaceAll("<", "<").replaceAll(">",">");
|
|
|
+
|
|
|
+ try {
|
|
|
+ $(editorId).summernote('code', content);
|
|
|
+ } catch(e) {
|
|
|
+ // Do nothing
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|