From d99641d12261b948a4216ce9cba21f9862d9f355 Mon Sep 17 00:00:00 2001 From: kir rio Date: Wed, 11 Jan 2023 10:21:44 +0900 Subject: [PATCH] =?UTF-8?q?cheditor=205.1.9.4=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/editor/cheditor5/cheditor.js | 5 +- .../cheditor5/icons/imageUpload/broken.png | Bin 0 -> 16882 bytes .../editor/cheditor5/imageUpload/config.php | 14 +- .../editor/cheditor5/imageUpload/upload.php | 4 +- plugin/editor/cheditor5/popup/flash.html | 12 +- plugin/editor/cheditor5/popup/google_map.html | 4 +- .../editor/cheditor5/popup/image.html5.m.html | 1 + plugin/editor/cheditor5/popup/js/flash.js | 162 ++++++++++++++---- .../editor/cheditor5/popup/js/google_map.js | 45 ++--- .../editor/cheditor5/popup/js/image.html5.js | 121 ++++++------- .../cheditor5/popup/js/image.html5.m.js | 111 ++++++------ plugin/editor/cheditor5/template.dtd | 43 +++++ 12 files changed, 335 insertions(+), 187 deletions(-) create mode 100644 plugin/editor/cheditor5/icons/imageUpload/broken.png create mode 100644 plugin/editor/cheditor5/template.dtd diff --git a/plugin/editor/cheditor5/cheditor.js b/plugin/editor/cheditor5/cheditor.js index 9e39e3408..58790b338 100644 --- a/plugin/editor/cheditor5/cheditor.js +++ b/plugin/editor/cheditor5/cheditor.js @@ -1,9 +1,9 @@ // ================================================================ -// CHEditor 5.1.9.3-p4 +// CHEditor 5.1.9.4 // ---------------------------------------------------------------- // Homepage: http://www.chcode.com // EMail: support@chcode.com -// Copyright (c) 1997-2020 CHSOFT +// Copyright (c) 1997-2021 CHSOFT // ================================================================ var GB = { colors: ['#000000','#313131','#434343','#535353','#666666','#999999','#a0a0a0','#b5b5b5','#c0c0c0','#dcdcdc','#eeeeee','#ffffff', @@ -568,6 +568,7 @@ function setConfig() { this.cheditor.tabSpaces = ''; this.cheditor.modifyState = false; this.cheditor.tabSpaces = new Array(this.config.tabIndent + 1).join(' '); + // this.URI = URI; } function cheditor() { diff --git a/plugin/editor/cheditor5/icons/imageUpload/broken.png b/plugin/editor/cheditor5/icons/imageUpload/broken.png new file mode 100644 index 0000000000000000000000000000000000000000..3db85a17170990b6b344e30d7510ee3ed4db4081 GIT binary patch literal 16882 zcmeI3c~lek7RN_GL5K)ypDZpBwTd-N_K+A75TxuNVgW_TBr}1qBq0e97er7LUlmYX zaYGTTMJc?hb*YGAp(<^0w<01{MC$@V-G#gfAjA>pc;4$f@1L1-vfSVOeea$5{OaQ$ZhkhjeS0Jx82 zAz_*@e?Oi?5$^=S3NhlOjaQFq2>5V2eJ%yaR_DkQ~j0h zNVLprp$eI`Fd#&-Fjm5a9fSgNzLtjuh(|OKSsNcGSM#(k4qb71=zsk%=s@n8qKS2J zaMLFwhxrGQ-4!Z?%yME=Bs7LInZtFWvAE83=2SABN@IgmE=Xfis5Bmx%cIiBJ%@w9 z9R0^v!BSqZhi6YZ)N*l%)@YPG5KK-^c1mVADO6D)jmzbNR60nfQ_vX{^#ZvD(o*E= z@!dh*#qmJY5|vD;ktyV4eOySaNYuDEIOr4g9zE9;uk1}ESNE_(DS}!^3DTUXV1FW5 z(yLJ>s^Yp%4VHjN91@SnHEL8x>sP0YR%jIJXvIfT_PRfs7+n*8|K8mFo^O17zp2%l z8A&LD9;E#$)gcR%2pEj06^SYdG9wASl=1yty+$VOTb%bI={+AkcSI}uh)nP4mUWdv z_X_dRYvsAC5J;m?g(wtpg6=8{dWVqg?yj#Y4ta8@Ob#oO)sB1+E9qPBzG#RCq(KCF zC56hN&{!cEGm!AHjH5~6B`5V z9~ja=pA^M#u0b4F!jmdg@sLI!i-)2RP$`e%gMEVrGkdFw=dOrTsL<0w1Pngd->`wI ztI~Mha)N4|kV=i{`_IMUT?6)RX}vp^ zUendbJV>J7+XNDQdmu0$d~dYxw0f02GTDdA`DqBc;~U67o+CLLk>j;jcc`ve9}l8d zNHxij3UP}m4g#m(Z61edBV7vq_3=n*iz=h8T<0WumfZ&@1E_^;1FM$gK1m7fZ;q$?G z30xQ;_$Gl1pAW`M;KBgGHwj$$d@x=D7X}EvN#MfggYgo$FhKB40vA3XjF-TL0fKK5 zxbXR4yaX-`5PXxsh0h1$C2(PY;F|<4d_EX2feQl!-z0G1^TButTo@quCV>l|55`O2 z!T`ZH30(MmFkS)|1_-`M;KJvF@e;T&K=4gmT;_eRa3XT_z0G9w1l9s2tK01~MH@TUj>c$)!Wq+(sWz(#D0Et>&{Kv(;CMb8yi~;H?FL1A(4&+lSpmpLYlvJ)aVY~mEus6k&zMUTyZGl z^yB4?;z27$j~qBq2R8n(uv4c?Mc;+hpUm>?;$dksfkD?2s*tLA`DcyRmsPEH1FVmZ=m?&Nz==i)i-ua`XV&--!AT-D&o%?+bM$BR!*%dY$7wPjW5#y$Qg zN>YlOCNvITQM;w^QX4<;lHWb@+0=xLB{yw;-C%zF(ms>cJL?~X+YKt1{Pu3;cbwYE z&LLmtXSxSz9Jd<{Otdzcb|195+&SQygS^vXS3-idMl;;>L9Lr_(YIUAxMk7~d;4jk z&C_d_RyH{`3zWZcw+P@HIZsk&CdC{w{*3H1?D=o-2-`DMznBvh1tx7=o7txO+>u;eoros(cdU6%)4~Tv>APdQom^Ir8G*01zsE zq0OIrNnJo)zc!e^B*nO){bE%=t!FPi|;kXQfECTCwYUVXn1rc9G8Rg2lKewpyMu zpYO8y{4@W@*5HtvbJACauD0!%v`Sc2omgYuY(=x$(Upzfjxq4OS;AbaDaDKt;9NND9413au`pt9ZN$ajB#>PD=Ej#*R zhdLV!$h6!`op#UI)ak{x^X*MXhwf}%#I9MU8*OSo#8i}ely3=-RX!=4)znsPximQD z;mSz?e*AA5#x1{HD5=g$nv%a~giq{gD*V=^Zj{leI@iMU1Fo?>+V+Ht?yp~M^HtLC zD|YT;^M9E@-pS6bAJ%$&sP)Jsmv2j_T1+gwZZ1VPqHrJWgr~^l-WY;easq(blMJJVIxDHCYVr^xTR(Lwc)p5x-VE}K- zxUF{i)Y4^Xf04_XL0`IBnK12r_utx9utdGKv8?&kA2*vdFP`Vt=N07qvd%B=^su6s z=t~dgl{7BOA7SRETnRM%u;;3Y&&-ZjcIvBv&cBBGrFJ-$JZw8>@f~g5*qBYfPkeOV zZQM0mDEsbE+q83glR6enVKlVXl+s~y_OzF=mHcO~zkXdm3mH{+s%-Q^_TIBms=M?$ZS>-kwH2bo`IFw}6lV+Hp1pqS z#5B`1-!HQx_(w{A1g~y#J7{|O%Mz=VH`a`K*=cWYbm7hPh?^<5D{>jRxwFSDx0$lx zHRILdq6^Xahd$rnQx;s@p=vsvG2_6YF?HWZmC{*>&q}XOYmq8jxcul6U)zUcN7p}% zD7?5pH*cSbYvW(C!>%pEYZsM={K5Hc))=PlEYzSrczb1}{hHm)3+kghJ;UZiz;_>o zvjhEZA9K1Avtf(a`gn?9tzXF@(ev_MM+WAGIz^T@m6Qy-9J4wgaQGU}Rn>PU3>z#i zvw0(p@-|K>@jWp=Qhw@kN^u2mTXu!PypR%&XI`rT@UlYS%d0JqC}+%|&dpufBNrkn^WcifsnxQt53# zQUAE8{8U(L1I+X-$^_+g9**30CfB*8H5#UiWU6lTB DpODlJ literal 0 HcmV?d00001 diff --git a/plugin/editor/cheditor5/imageUpload/config.php b/plugin/editor/cheditor5/imageUpload/config.php index 0f81cdcb8..418c1bf5f 100644 --- a/plugin/editor/cheditor5/imageUpload/config.php +++ b/plugin/editor/cheditor5/imageUpload/config.php @@ -1,15 +1,15 @@ - + + CHEditor - + @@ -11,12 +11,12 @@
- <동영상 소스 코드> iframe 또는 object 태그를 입력하세요. + 동영상 링크 URL 또는 IFRAME이나 EMBED 소스 코드를 붙여 넣거나 입력하세요.
- +
- \ No newline at end of file + diff --git a/plugin/editor/cheditor5/popup/google_map.html b/plugin/editor/cheditor5/popup/google_map.html index 5f7ed0955..def38e1cb 100644 --- a/plugin/editor/cheditor5/popup/google_map.html +++ b/plugin/editor/cheditor5/popup/google_map.html @@ -6,13 +6,13 @@ - +
찾을 주소: - +
찾으실 도로명 주소, 지번 또는 건물명을 입력하세요.
diff --git a/plugin/editor/cheditor5/popup/image.html5.m.html b/plugin/editor/cheditor5/popup/image.html5.m.html index 0f9debb67..a2d7183c3 100644 --- a/plugin/editor/cheditor5/popup/image.html5.m.html +++ b/plugin/editor/cheditor5/popup/image.html5.m.html @@ -64,6 +64,7 @@
사진 여백 넣기
+
diff --git a/plugin/editor/cheditor5/popup/js/flash.js b/plugin/editor/cheditor5/popup/js/flash.js index e18df665b..2b10818f9 100644 --- a/plugin/editor/cheditor5/popup/js/flash.js +++ b/plugin/editor/cheditor5/popup/js/flash.js @@ -1,5 +1,5 @@ // ================================================================ -// CHEditor 5 +// Movie // ================================================================ var button = [ { alt : '', img : 'play.gif', cmd : doPlay }, @@ -7,7 +7,10 @@ var button = [ { alt : '', img : 'cancel.gif', cmd : popupClose } ], oEditor = null, - iframeSource = false; + iframeSource = null, + showMovie = false, + defaultMovieWidth = 640, + defaultMovieHeight = 360; function init(dialog) { var dlg = new Dialog(this); @@ -17,52 +20,65 @@ function init(dialog) { dlg.setDialogHeight(); } -function doPlay() -{ - var elem = oEditor.trimSpace(document.getElementById("fm_embed").value), - embed = null, div = document.createElement('div'), - pos, str, object, child, movieHeight, movieWidth, i, params = []; +function getSource() { + return oEditor.trimSpace(document.getElementById("fm_source").value); +} - elem = oEditor.trimSpace(elem); - if (elem == '') { +function doPlay() { + var embed = null, + div = document.createElement('div'), + pos, str, object, child, movieHeight, movieWidth, params = [], showWrapper, + source = getSource(), iframe; + + showMovie = true; + if (source === '') { return; } - if (elem.toLowerCase().indexOf("iframe") !== -1) { - document.getElementById('fm_player').innerHTML = elem; - iframeSource = true; + showWrapper = document.getElementById('fm_player'); + if (source.toLowerCase().indexOf("iframe") !== -1) { + showWrapper.innerHTML = source; + iframeSource = source; return; } - pos = elem.toLowerCase().indexOf("embed"); + if (/https?:\/\//.test(source)) { + iframe = createIframeElement(defaultMovieWidth, defaultMovieHeight, source); + if (iframe) { + showWrapper.innerHTML = ''; + showWrapper.appendChild(iframe); + iframeSource = iframe; + } + return; + } + + pos = source.toLowerCase().indexOf("embed"); if (pos !== -1) { - str = elem.substr(pos); + str = source.substr(pos); pos = str.indexOf(">"); div.innerHTML = "<" + str.substr(0, pos) + ">"; embed = div.firstChild; } else { - div.innerHTML = elem; + div.innerHTML = source; object = div.getElementsByTagName('OBJECT')[0]; if (object && object.hasChildNodes()) { child = object.firstChild; - movieWidth = (isNaN(object.width) !== true) ? object.width : 320; - movieHeight = (isNaN(object.height) !== true) ? object.height : 240; + movieWidth = (isNaN(object.width) !== true) ? object.width : defaultMovieWidth; + movieHeight = (isNaN(object.height) !== true) ? object.height : defaultMovieHeight; do { - if ((child.nodeName === 'PARAM') && (typeof child.name !== 'undefined') && (typeof child.value !== 'undefined')) { - params.push({key: (child.name == 'movie') ? 'src' : child.name, val: child.value}); + if (child.nodeName === 'PARAM' && typeof child.name !== 'undefined' && typeof child.value !== 'undefined') + { + params.push({ + key: child.name === 'movie' ? 'src' : child.name, + val: child.value + }); } child = child.nextSibling; } while (child); if (params.length > 0) { - embed = document.createElement('embed'); - embed.setAttribute("width", movieWidth); - embed.setAttribute("height", movieHeight); - for (i = 0; i < params.length; i++) { - embed.setAttribute(params[i].key, params[i].val); - } - embed.setAttribute("type", "application/x-shockwave-flash"); + embed = createEmbedElement(movieWidth, movieHeight, params, null); } } } @@ -72,6 +88,89 @@ function doPlay() } } +function createIframeElement(width, height, src) { + var iframe = document.createElement('iframe'), uri, query, id, movie = null; + + uri = new oEditor.URI(src); + if (uri.path && uri.path.charAt(0) !== '/') { + uri.path = '/' + uri.path; + } + + switch (uri.authority) { + case 'youtu.be' : + case 'youtube.com': + case 'www.youtube.com': + if (uri.path === '/watch' && uri.query) { + query = uri.query.split('='); + if (query[0] === 'v') { + movie = '/' + query[1]; + } + } + if (!movie && uri.path) { + movie = uri.path; + if (uri.query) { + movie += '?' + uri.query; + } + } + if (movie) { + movie = 'https://www.youtube.com/embed' + movie; + } + break; + case 'vimeo.com' : + if (uri.path) { + movie = 'https://player.vimeo.com/video' + uri.path; + } + break; + case 'afree.ca' : + if (uri.path) { + movie = 'http://play.afreecatv.com' + uri.path + '/embed'; + } + break; + case 'tv.naver.com' : + if (uri.path) { + id = uri.path.substring(uri.path.lastIndexOf('/')); + movie = 'https://tv.naver.com/embed' + id + '?autoPlay=true'; + } + break; + case 'tv.kakao.com' : + if (uri.path) { + id = uri.path.substring(uri.path.lastIndexOf('/')); + movie = 'https://tv.kakao.com/embed/player/cliplink' + id; + } + break; + default : + movie = null; + } + if (!movie) { + return null; + } + + iframe.setAttribute('width', width); + iframe.setAttribute('height', height); + iframe.setAttribute('frameborder', "0"); + iframe.setAttribute('allowfullscreen', "true"); + iframe.setAttribute('src', movie); + return iframe; +} + +function createEmbedElement(width, height, params, src) { + var embed = document.createElement('embed'), i; + + embed.setAttribute("type", "application/x-shockwave-flash"); + embed.setAttribute('width', width); + embed.setAttribute('height', height); + + if (src) { + embed.setAttribute('src', src); + } + + for (i = 0; i < params.length; i++) { + embed.setAttribute(params[i].key, params[i].val); + } + + return embed; +} + function popupClose() { document.getElementById('fm_player').innerHTML = ''; oEditor.popupWinCancel(); @@ -79,13 +178,17 @@ function popupClose() { function doSubmit() { - var source = String(oEditor.trimSpace(document.getElementById("fm_embed").value)); + var source = getSource(); if (source === '') { popupClose(); } + if (!showMovie) { + document.getElementById('fm_player').style.visibility = 'hidden'; + doPlay(); + } - if (iframeSource || source.indexOf("iframe") !== -1) { - oEditor.insertHtmlPopup(source); + if (iframeSource) { + oEditor.insertHtmlPopup(iframeSource); } else { oEditor.insertFlash(source); } @@ -93,3 +196,4 @@ function doSubmit() document.getElementById('fm_player').innerHTML = ''; oEditor.popupWinClose(); } + diff --git a/plugin/editor/cheditor5/popup/js/google_map.js b/plugin/editor/cheditor5/popup/js/google_map.js index cf6109076..416b055b0 100644 --- a/plugin/editor/cheditor5/popup/js/google_map.js +++ b/plugin/editor/cheditor5/popup/js/google_map.js @@ -13,7 +13,9 @@ var oEditor = null, mapWidth = 512, mapHeight = 320, panorama, - panoramaVisible = false; + panoramaVisible = false, + marker, + staticMapsAPI = 'STATIC_MAPS_API_KEY'; function doSubmit() { var mapImg = document.createElement("img"), @@ -29,10 +31,9 @@ function doSubmit() { mapImg.style.width = mapWidth + 'px'; mapImg.style.height = mapHeight + 'px'; mapImg.style.border = '1px #000 solid'; - mapImg.setAttribute("alt", "Google Map"); + mapImg.setAttribute('alt', 'Google Map'); mapImg.onload = function () { oEditor.insertHtmlPopup(mapImg); - oEditor.setImageEvent(true); oEditor.popupWinClose(); }; @@ -41,42 +42,46 @@ function doSubmit() { panoramaHeading = panorama.getPov().heading; panoramaZoom = panorama.getPov().zoom; panoramaPosition = panorama.getPosition(); - - mapImg.src = "http://maps.googleapis.com/maps/api/streetview?location=" + panoramaPosition + + mapImg.src = "http://maps.googleapis.com/maps/api/streetview?" + + "location=" + panoramaPosition.lat() + ',' + panoramaPosition.lng() + "&pitch=" + panoramaPitch + "&heading=" + panoramaHeading + "&size=" + mapWidth + 'x' + mapHeight + "&zoom=" + panoramaZoom + "&sensor=false" + - "®ion=KR"; + "®ion=KR" + + "&key=" + staticMapsAPI; } else { - mapImg.src = "http://maps.google.com/maps/api/staticmap?center=" + centerLat + ',' + centerLng + + mapImg.src = "http://maps.google.com/maps/api/staticmap?" + + "center=" + centerLat + ',' + centerLng + "&zoom=" + setZoom + "&size=" + mapWidth + 'x' + mapHeight + "&maptype=" + mapType + - //"&markers=" + marker_lat + ',' + marker_lng + + "&markers=" + marker_lat + ',' + marker_lng + "&sensor=false" + "&language=ko" + - "®ion=KR"; + "®ion=KR" + + "&key=" + staticMapsAPI; } } function searchAddress() { var address = document.getElementById('fm_address').value, geocoder = new google.maps.Geocoder(); - //var results, status; - //var marker = new google.maps.Marker({ 'map': map, 'draggable': true }); geocoder.geocode({'address' : address}, - function (results, status) { - if (status === google.maps.GeocoderStatus.OK) { - centerLat = results[0].geometry.location.lat(); - centerLng = results[0].geometry.location.lng(); - latlng = new google.maps.LatLng(centerLat, centerLng); - map.setCenter(latlng); - map.setZoom(setZoom); - } - }); + function (results, status) { + if (status === google.maps.GeocoderStatus.OK) { + centerLat = results[0].geometry.location.lat(); + centerLng = results[0].geometry.location.lng(); + latlng = new google.maps.LatLng(centerLat, centerLng); + map.setCenter(latlng); + map.setZoom(setZoom); + marker = new google.maps.Marker({ 'map': map, 'draggable': true, 'position': latlng, + animation: google.maps.Animation.DROP}); + marker.setMap(map); + } + }); } function initMap(zoom) { diff --git a/plugin/editor/cheditor5/popup/js/image.html5.js b/plugin/editor/cheditor5/popup/js/image.html5.js index c3e3f46c4..afa16b87e 100644 --- a/plugin/editor/cheditor5/popup/js/image.html5.js +++ b/plugin/editor/cheditor5/popup/js/image.html5.js @@ -36,7 +36,8 @@ var activeImage = null, uploadImagePath = '', uploadMaxNumber = 12, uploadScript, - useWebGL = false; + useWebGL = false, + supportImageOrientation; if (ArrayBuffer && !ArrayBuffer.prototype.slice) { ArrayBuffer.prototype.slice = function (start, end) { @@ -437,11 +438,6 @@ function fileFilterError(file) { "gif, png, jpg, webp 사진 파일만 전송할 수 있습니다."); } -function explorerFileFilterError(file) { - alert("선택하신 '" + file + "' 파일은 전송할 수 없습니다.\n" + - "익스플로러 환경에서는 gif, png, jpg 사진 파일만 \n전송할 수 있습니다."); -} - function imgComplete(img, imgSize, boxId) { var resizeW, resizeH, M, elem; img.setAttribute("border", '0'); @@ -929,7 +925,7 @@ function DoUpload() { blob = new Blob(); for (key in blob) { - if (blob.hasOwnProperty(key)) { + if ({}.hasOwnProperty.call(blob, key)) { (function (key) { Object.defineProperty(MYBLOB.prototype, key, @@ -967,13 +963,7 @@ DoUpload.prototype = { file = files[i]; if (!file.type.match(fileTypeRe)) { - // 엣지를 제외한 ie브라우저인지 체크 - var agent = navigator.userAgent.toLowerCase(); - if (agent.indexOf('trident') != -1 || agent.indexOf("msie") != -1) { - explorerFileFilterError(file.name); - } else { - FileFilterError(file.name); - } + fileFilterError(file.name); continue; } this.list.push(file); @@ -1032,15 +1022,22 @@ DoUpload.prototype = { offset = 2, marker, little, tags, i; + // JPEG가 아닌 경우, 알 수 없음 if (view.getUint16(0, false) !== 0xffd8) { return -2; } while (offset < length) { + // 알 수 없음 + if (view.getUint16(offset + 2, false) <= 8) { + return -1; + } + marker = view.getUint16(offset, false); offset += 2; if (marker === 0xffe1) { + // 알 수 없음 if (view.getUint32(offset += 2, false) !== 0x45786966) { return -1; } @@ -1061,7 +1058,7 @@ DoUpload.prototype = { offset += view.getUint16(offset, false); } } - + // 알 수 없음 return -1; }, @@ -1076,7 +1073,7 @@ DoUpload.prototype = { || window.MSBlobBuilder; if (e.name === 'TypeError' && window.BlobBuilder) { - blobb = new BlobBuilder(); + // eslint-disable-next-line no-undef blobb.append(data); blob = blobb.getBlob(datatype); console.log("TypeError"); @@ -1089,50 +1086,46 @@ DoUpload.prototype = { return blob; }, - imageResize : function (image, filetype, resizeWidth, orientation, addWaterMark) { - var canvas, source_w = image.width, source_h = image.height, - resize_h, resize_w, ratio_w, ratio_h, ratio_w_half, ratio_h_half, + imageResize : function (image, filetype, resize_w, orientation, addWaterMark) { + var canvas = document.createElement("canvas"), + ctx = canvas.getContext("2d"), + source_w = image.width, + source_h = image.height, + resize_h, ratio_w, ratio_h, ratio_w_half, ratio_h_half, source_img, resize_img, source_data, resize_data, j, i, - x2, weight, weights, weights_alpha, gx_a, gx_b, gx_g, gx_r, center_x, center_y, x_start, x_stop, - y_start, y_stop, y, dy, part_w, x, dx, w, pos_x, - ctx, gl, imageData = null; + x2, weight, weights, weights_alpha, gx_a, gx_b, gx_g, gx_r, + center_x, center_y, x_start, x_stop, + y_start, y_stop, y, dy, part_w, x, dx, w, pos_x, gl, imageData = null; // 카메라 로테이션 보정 - if (orientation > 0) { - canvas = document.createElement("canvas"); - canvas.width = source_w; - canvas.height = source_h; - ctx = canvas.getContext("2d"); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.save(); + if (orientation > 0 && !supportImageOrientation) { + if ([5,6,7,8].indexOf(orientation) > -1) { + canvas.width = source_h; + canvas.height = source_w; + } else { + canvas.width = source_w; + canvas.height = source_h; + } switch (orientation) { - case 2 : - ctx.translate(-1, 0, 0, 1, canvas.width, 0); break; - case 3 : - ctx.translate(-1, 0, 0, -1, canvas.width, canvas.height); break; - case 4 : - ctx.translate(1, 0, 0, -1, 0, canvas.height); break; - case 5 : - ctx.translate(0, 1, 1, 0, 0, 0); break; - case 6 : - ctx.translate(0, 1, -1, 0, canvas.height, 0); break; - case 7 : - ctx.translate(0, -1, -1, 0, canvas.height, canvas.width); break; - case 8 : - ctx.translate(0, -1, 1, 0, 0, canvas.width); break; + case 2 : ctx.transform(-1, 0, 0, 1, source_w, 0); break; + case 3 : ctx.transform(-1, 0, 0, -1, source_w, source_h); break; + case 4 : ctx.transform(1, 0, 0, -1, 0, source_h); break; + case 5 : ctx.transform(0, 1, 1, 0, 0, 0); break; + case 6 : ctx.transform(0, 1, -1, 0, source_h, 0); break; + case 7 : ctx.transform(0, -1, -1, 0, source_h, source_w); break; + case 8 : ctx.transform(0, -1, 1, 0, 0, source_w); break; default: break; } - ctx.drawImage(image, 0, 0); + ctx.drawImage(image, 0, 0, source_w, source_h); imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); ctx.restore(); source_w = canvas.width; source_h = canvas.height; } - if (source_w > resizeWidth) { - resize_w = resizeWidth; + if (source_w > resize_w) { resize_h = Math.ceil(resize_w / source_w * source_h); try { @@ -1143,8 +1136,6 @@ DoUpload.prototype = { canvas = gl_canvas; }); } catch (ignore) { - canvas = document.createElement("canvas"); - ctx = canvas.getContext("2d"); canvas.width = source_w; canvas.height = source_h; @@ -1216,14 +1207,10 @@ DoUpload.prototype = { canvas.height = resize_h; ctx.putImageData(resize_img, 0, 0); } - } else { - canvas = document.createElement("canvas"), - canvas.width = source_w; canvas.height = source_h; - ctx = canvas.getContext("2d"); + canvas.width = source_w; + canvas.height = source_h; ctx.drawImage(image, 0, 0); - resize_h = source_h; - resize_w = source_w; } if (this.reader.watermark && addWaterMark) { @@ -1276,7 +1263,8 @@ DoUpload.prototype = { filename = evt.target.file.name, filetype = evt.target.file.type, file = evt.target.file, - blob, image, orientation = 1, slice = 64 * 1024; + blob, image, orientation = 1, + slice = 64 * 1024; if (slice > file.size - 1) { slice = file.size; @@ -1298,12 +1286,12 @@ DoUpload.prototype = { xhr.open('POST', uploadScript, true); - if (imageResizeWidth > 0) { + fileFormat = filename.substring(filename.lastIndexOf('.')); + if (imageResizeWidth > 0 && fileFormat !== '.gif') { bitmapData = self.imageResize(this, filetype, imageResizeWidth, orientation, true); file = self.canvasToBlob(bitmapData, filetype); } - fileFormat = filename.substring(filename.lastIndexOf('.')); randomName = self.makeFilename(fileFormat); data.append('origname', filename); @@ -1375,7 +1363,6 @@ DoUpload.prototype = { blob = null; xhr.send(data); }; - image.src = blob.getURL(); } }, @@ -1484,7 +1471,7 @@ function setResizeWidth() { } function init(dialog) { - var dlg, i, elem, input, select, value, name, xhr_f, xhr_v, tmpcanvas, glicon; + var dlg, i, elem, input, select, value, name, xhr_f, xhr_v, tmpcanvas, glicon, testImg; oEditor = this; oEditor.dialog = dialog; @@ -1588,8 +1575,24 @@ function init(dialog) { xhr_f.send(); xhr_v.send(); } + glicon = new Image(); glicon.className = 'webgl_logo'; glicon.src = uploadImagePath + (useWebGL ? "/webgl.png" : "/webgl-off.png"); document.getElementById('webgl_logo_wrapper').appendChild(glicon); + + // 브라우저가 사진 Orientation 보정을 자동으로 지원하지는지 확인 + testImg = new Image(); + testImg.onload = function () { + supportImageOrientation = testImg.width === 2 && testImg.height === 3; + }; + testImg.src = + 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' + + 'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' + + 'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' + + 'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/x' + + 'ABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAA' + + 'AAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQ' + + 'voP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXw' + + 'H/9k='; } diff --git a/plugin/editor/cheditor5/popup/js/image.html5.m.js b/plugin/editor/cheditor5/popup/js/image.html5.m.js index e50c3389f..13549fd3e 100644 --- a/plugin/editor/cheditor5/popup/js/image.html5.m.js +++ b/plugin/editor/cheditor5/popup/js/image.html5.m.js @@ -35,8 +35,9 @@ var activeImage = null, tmpTop = 0, uploadImagePath = '', uploadMaxNumber = 12, - uploadScript; - useWebGL = false; + uploadScript, + useWebGL = false, + supportImageOrientation; if (ArrayBuffer && !ArrayBuffer.prototype.slice) { ArrayBuffer.prototype.slice = function (start, end) { @@ -434,12 +435,7 @@ function startUpload(list) { function fileFilterError(file) { alert("선택하신 '" + file + "' 파일은 전송할 수 없습니다.\n" + - "gif, png, jpg, webp 사진 파일만 전송할 수 있습니다."); -} - -function explorerFileFilterError(file) { - alert("선택하신 '" + file + "' 파일은 전송할 수 없습니다.\n" + - "익스플로러 환경에서는 gif, png, jpg 사진 파일만 \n전송할 수 있습니다."); + "gif, png, jpg 사진 파일만 전송할 수 있습니다."); } function imgComplete(img, imgSize, boxId) { @@ -967,16 +963,10 @@ DoUpload.prototype = { file = files[i]; if (!file.type.match(fileTypeRe)) { - // 엣지를 제외한 ie브라우저인지 체크 - var agent = navigator.userAgent.toLowerCase(); - if (agent.indexOf('trident') != -1 || agent.indexOf("msie") != -1) { - explorerFileFilterError(file.name); - } else { - FileFilterError(file.name); - } + fileFilterError(file.name); continue; } - this.list.push(file); + this.list.push(file); } if (this.list.length < 1) { @@ -1089,50 +1079,46 @@ DoUpload.prototype = { return blob; }, - imageResize : function (image, filetype, resizeWidth, orientation, addWaterMark) { - var canvas, source_w = image.width, source_h = image.height, - resize_h, resize_w, ratio_w, ratio_h, ratio_w_half, ratio_h_half, + imageResize : function (image, filetype, resize_w, orientation, addWaterMark) { + var canvas = document.createElement("canvas"), + ctx = canvas.getContext("2d"), + source_w = image.width, + source_h = image.height, + resize_h, ratio_w, ratio_h, ratio_w_half, ratio_h_half, source_img, resize_img, source_data, resize_data, j, i, - x2, weight, weights, weights_alpha, gx_a, gx_b, gx_g, gx_r, center_x, center_y, x_start, x_stop, - y_start, y_stop, y, dy, part_w, x, dx, w, pos_x, - ctx, gl, imageData = null; + x2, weight, weights, weights_alpha, gx_a, gx_b, gx_g, gx_r, + center_x, center_y, x_start, x_stop, + y_start, y_stop, y, dy, part_w, x, dx, w, pos_x, gl, imageData = null; // 카메라 로테이션 보정 - if (orientation > 0) { - canvas = document.createElement("canvas"); - canvas.width = source_w; - canvas.height = source_h; - ctx = canvas.getContext("2d"); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.save(); + if (orientation > 0 && !supportImageOrientation) { + if ([5,6,7,8].indexOf(orientation) > -1) { + canvas.width = source_h; + canvas.height = source_w; + } else { + canvas.width = source_w; + canvas.height = source_h; + } switch (orientation) { - case 2 : - ctx.translate(-1, 0, 0, 1, canvas.width, 0); break; - case 3 : - ctx.translate(-1, 0, 0, -1, canvas.width, canvas.height); break; - case 4 : - ctx.translate(1, 0, 0, -1, 0, canvas.height); break; - case 5 : - ctx.translate(0, 1, 1, 0, 0, 0); break; - case 6 : - ctx.translate(0, 1, -1, 0, canvas.height, 0); break; - case 7 : - ctx.translate(0, -1, -1, 0, canvas.height, canvas.width); break; - case 8 : - ctx.translate(0, -1, 1, 0, 0, canvas.width); break; + case 2 : ctx.transform(-1, 0, 0, 1, source_w, 0); break; + case 3 : ctx.transform(-1, 0, 0, -1, source_w, source_h); break; + case 4 : ctx.transform(1, 0, 0, -1, 0, source_h); break; + case 5 : ctx.transform(0, 1, 1, 0, 0, 0); break; + case 6 : ctx.transform(0, 1, -1, 0, source_h, 0); break; + case 7 : ctx.transform(0, -1, -1, 0, source_h, source_w); break; + case 8 : ctx.transform(0, -1, 1, 0, 0, source_w); break; default: break; } - ctx.drawImage(image, 0, 0); + ctx.drawImage(image, 0, 0, source_w, source_h); imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); ctx.restore(); source_w = canvas.width; source_h = canvas.height; } - if (source_w > resizeWidth) { - resize_w = resizeWidth; + if (source_w > resize_w) { resize_h = Math.ceil(resize_w / source_w * source_h); try { @@ -1143,8 +1129,6 @@ DoUpload.prototype = { canvas = gl_canvas; }); } catch (ignore) { - canvas = document.createElement("canvas"); - ctx = canvas.getContext("2d"); canvas.width = source_w; canvas.height = source_h; @@ -1216,14 +1200,10 @@ DoUpload.prototype = { canvas.height = resize_h; ctx.putImageData(resize_img, 0, 0); } - } else { - canvas = document.createElement("canvas"), - canvas.width = source_w; canvas.height = source_h; - ctx = canvas.getContext("2d"); + canvas.width = source_w; + canvas.height = source_h; ctx.drawImage(image, 0, 0); - resize_h = source_h; - resize_w = source_w; } if (this.reader.watermark && addWaterMark) { @@ -1484,7 +1464,7 @@ function setResizeWidth() { } function init(dialog) { - var dlg, i, elem, input, select, value, name, xhr_f, xhr_v, tmpcanvas, glicon; + var dlg, i, elem, input, select, value, name, xhr_f, xhr_v, tmpcanvas, glicon, testImg; oEditor = this; oEditor.dialog = dialog; @@ -1556,11 +1536,6 @@ function init(dialog) { } } - if (browser.mobile) { - input = document.getElementById('inputImageUpload'); - input.setAttribute('capture', 'filesystem'); - } - tmpcanvas = document.createElement('canvas'); if (tmpcanvas.getContext('webgl', {preserveDrawingBuffer: true}) || tmpcanvas.getContext('experimental-webgl', {preserveDrawingBuffer: true})) @@ -1588,8 +1563,24 @@ function init(dialog) { xhr_f.send(); xhr_v.send(); } + glicon = new Image(); glicon.className = 'webgl_logo'; glicon.src = uploadImagePath + (useWebGL ? "/webgl.png" : "/webgl-off.png"); document.getElementById('webgl_logo_wrapper').appendChild(glicon); + + // 브라우저가 사진 Orientation 보정을 자동으로 지원하지는지 확인 + testImg = new Image(); + testImg.onload = function () { + supportImageOrientation = testImg.width === 2 && testImg.height === 3; + }; + testImg.src = + 'data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAA' + + 'AAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBA' + + 'QEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE' + + 'BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAIAAwMBEQACEQEDEQH/x' + + 'ABRAAEAAAAAAAAAAAAAAAAAAAAKEAEBAQADAQEAAAAAAAAAAAAGBQQDCAkCBwEBAAAAAAA' + + 'AAAAAAAAAAAAAABEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEQMRAD8AG8T9NfSMEVMhQ' + + 'voP3fFiRZ+MTHDifa/95OFSZU5OzRzxkyejv8ciEfhSceSXGjS8eSdLnZc2HDm4M3BxcXw' + + 'H/9k='; } diff --git a/plugin/editor/cheditor5/template.dtd b/plugin/editor/cheditor5/template.dtd new file mode 100644 index 000000000..212845e57 --- /dev/null +++ b/plugin/editor/cheditor5/template.dtd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file