Переглянути джерело

Paste Upload 버그 수정
- 한글파일 Upload 성공 이후, 유저한테 decoded file name을 보여줘야 했지만
그 과정이 생략되어 있었음. 이에 JS 코드를 수정함.
- file name을 입력하는 prompt 창에서 cancel할 경우 error alert가 아닌 cancel alert를 표시

Roeniss Moon 6 роки тому
батько
коміт
da8a794aea
1 змінених файлів з 3 додано та 4 видалено
  1. 3 4
      views/main_css/js/upload_image_with_paste.js

+ 3 - 4
views/main_css/js/upload_image_with_paste.js

@@ -22,6 +22,7 @@ function pasteListener(e) {
       if (items[i].type.indexOf("image") !== -1) {
         const file = items[i].getAsFile();
         const customName = prompt("파일 이름을 설정해주세요. (확장자는 생략)");
+        if (!customName) return alert("취소되었습니다.")
         const customFile = new File([file], customName + ".png", { type: file.type });
         formData.append("f_data[]", customFile);
         haveImageInClipboard = true;
@@ -40,10 +41,8 @@ function pasteListener(e) {
         if (res.status === 200 || res.status === 201) {
           const url = res.url;
           alert(
-            `이미지 복붙 업로드 성공. 다음 텍스트로 본문에 삽입할 수 있습니다 : [[${url.replace(
-              /.*\/w\/file/,
-              "file"
-            )}]]`
+            `이미지 복붙 업로드 성공. 아래 텍스트로 본문에 삽입할 수 있습니다.
+[[${decodeURIComponent(url.replace(/.*\/w\/file/, "file"))}]]`
           );
         } else {
           console.error("[ERROR] PasteUpload Fail :", res.statusText);