Explorar o código

change inline-attachment setting according to the type of uploading file

Yuki Takei %!s(int64=9) %!d(string=hai) anos
pai
achega
3fefd39117
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      resource/js/legacy/crowi-form.js

+ 8 - 1
resource/js/legacy/crowi-form.js

@@ -466,9 +466,16 @@ $(function() {
       urlText: "\n![file]({filename})\n"
     };
 
+    attachmentOption.onFileReceived = function(file) {
+      // if not image
+      if (!file.type.match(/^image\/.+$/)) {
+        // modify urlText with 'a' tag
+        this.settings.urlText = `<a href="{filename}">${file.name}</a>\n`;
+      }
+    }
+
     attachmentOption.onFileUploadResponse = function(res) {
       var result = JSON.parse(res.response);
-      console.log(result);
 
       if (result.ok && result.pageCreated) {
         var page = result.page,