Skip to content

hockic/summernote-ext-filedialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

summernote-ext-filedialog

Based on summernote's ImageDialog

Setup

  • Include summernote project script
  • Include Font Awesome
  • Include the script tag below in your document
<script src="http://example.com/summernote-ext-filedialog.js"></script>

Usage

$('.summernote').summernote({
    toolbar:[
        ['insert', ['file']],
    ],
    callbacks: {
		onFileUpload: function(files, text) {
			var data = new FormData();
			var that = this;
			
			// Uploading just the first selected file for now
			// @todo Multiple file upload example
			data.append("file", files[0]);

			$.ajax ({
				data: data,
				type: 'post',
				url: 'https://path.to/your/upload/process',
				cache: false,
				contentType: false,
				processData: false,
				success: function(response) {
				    /**
					 * In this example the file uploader returned the filename
					 * and relative path to the file.
					 */
					$(that).summernote('createLink', {
						text: text || response.filename,
						url: response.url,
						newWindow: true
					});
				}
			});
		}
	}
});

License

summernote-ext-filedialog may be freely distributed under the MIT license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published