Search code examples
twitter-bootstrapgoogle-chromedrag-and-dropsummernotedisabled-input

summernote drag and drop option does not work


I put summernote editor in my web application.

And I found it still able to drag drop image into editor area. Of course I blocked summernote input with the code below.(Below method is provided in summernote official site)

summernote.summernote('disable');
summernote.summernote({
    disableDragAndDrop : true
});

What else I could try?

FYI, I have initialized my summer note like ...

    var s_note = $('#${id}_summernote');

    var summernote = s_note.summernote({
        height : 200
        , dialogsInBody : true
        , toolbar: [
            ['style', ['style']],
            ['font', ['bold', 'italic', 'underline', 'clear']],
            ['fontname', ['fontname']],
            ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']],
            ['height', ['height']],
            ['table', ['table']],
            ['insert', ['link', 'picture', 'hr']],
            ['view', ['fullscreen', 'codeview']],
            ['help', ['help']]
        ]
        , callbacks : {
            onImageUpload : function(files){
                console.log(files);
                var img = document.createElement('img');
                img.src='http://summernote.org/img/icons/1200x630.png';
                uploadWYSIWYGFile(files);

                s_note.summernote('insertNode', img);
            }
            , onChange : function(){
                console.log(1);
                var richValue = s_note.summernote('code');
                valueHolder.val(richValue);
            } 
        }
    }); 

Solution

  • Summernote doesn't update it's options dynamically. You should pass disableDragAndDrop options when you create editor. For example...

    // 01. create editor with options.
    $('#summernote').summernote({
      disableDragAndDrop:true,
      height: 200
    });
    // 02. then call disable API
    $('#summernote').summernote('disable');
    

    For more details about options....

    http://summernote.org/deep-dive/#initialization-options