Просмотр исходного кода

Merge pull request #53 from weseek/feat/uploadable-other-than-images

Feat/uploadable other than images
Yuki Takei 9 лет назад
Родитель
Сommit
be471df567
1 измененных файлов с 10 добавлено и 2 удалено
  1. 10 2
      resource/js/legacy/crowi-form.js

+ 10 - 2
resource/js/legacy/crowi-form.js

@@ -463,12 +463,20 @@ $(function() {
         _csrf: csrfToken
       },
       progressText: '(Uploading file...)',
-      urlText: "\n![file]({filename})\n"
+      urlText: "![file]({filename})\n",
+      allowedTypes: '*'
     };
 
+    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,