Javascript CollectionFS Meteor、所见即所得、Summernote、图像上传

Javascript CollectionFS Meteor、所见即所得、Summernote、图像上传,javascript,collections,meteor,wysiwyg,summernote,Javascript,Collections,Meteor,Wysiwyg,Summernote,各位晚上好 我一直在努力使用WYSIWYG编辑器和collectionFS在Meteor中上传文件。我一直在尝试使用Summernote,但我不介意使用Redactor或Froala 显然,我没有足够的技能将WYSIWYG编辑器与CollectionFS连接起来,以便将文件上载到本地路径 这是我的密码 Template.postSubmit.rendered = function(){ $('#edit').summernote(); }; Template.postSubmit.

各位晚上好

我一直在努力使用WYSIWYG编辑器和collectionFS在Meteor中上传文件。我一直在尝试使用Summernote,但我不介意使用Redactor或Froala

显然,我没有足够的技能将WYSIWYG编辑器与CollectionFS连接起来,以便将文件上载到本地路径

这是我的密码

Template.postSubmit.rendered = function(){
    $('#edit').summernote();

};


Template.postSubmit.events({
  'submit #postSubmit':function(event, template) {
    FS.Utility.eachFile(event, function(file) {
      Images.insert(file, function (err, fileObj) {
        //Inserted new doc with ID fileObj._id, and kicked off the data upload using HTTP
      });
    });
  }
});

Images = new FS.Collection("images", {
  stores: [new FS.Store.FileSystem("images", {path: "img2"})]
});

Images.allow({
    insert: function() {
        return true;
    },
    update: function() {
        return true;
    },
    remove: function() {
        return true;
    },
    download: function() {
        return true;
    }
});
据我所知,我必须补充

onImageUpload: function(files, editor, welEditable) {
                        sendFile(files[0],editor,welEditable);
                       }
在summernote脚本中(是吗?)

我似乎做不到!非常感谢您的指点、指导和帮助

编辑1:

Template.postSubmit.rendered = function(){
    $('#edit').summernote({
        onImageUpload: function(file) {
    FS.Utility.eachFile(event, function(file) {
      Images.insert(file, function (err, fileObj) {
        //Inserted new doc with ID fileObj._id, and kicked off the data upload using HTTP
      });
    });
  } 
    });
};
所以我把我的代码编辑成这个,现在它可以工作了!它将文件上载到指定路径。现在的问题是,, 1.它将立即上传图像(只要我点击添加图像,而不是在我提交表单时)。 2.上传的图像不会显示在编辑器中。

这对我来说很有用:

Template.blogList.rendered = function() {
    var template = this;
    $('#summernote').summernote({
        height: 400,
        maxHeight:800,
        minHeight:250,
        onImageUpload: function(files, editor, $editable) {

            Images.insert(files[0], function (err, fileObj) {
                console.log("after insert:", fileObj._id);
                template.autorun(function (c) {
                  fileObj = Images.findOne(fileObj._id);
                  var url = fileObj.url();
                  if (url) {
                    $("#summernote").summernote("insertImage", fileObj.url(), "Image Title"); 
                    c.stop();
                  }
                });
            });

        }   
    });
}

希望这有帮助。这个问题可能是重复的:我们还没有有效的解决方案!