Skip to content

Commit

Permalink
adds missing ckeditor uploadfile plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Dec 27, 2016
1 parent 985ecea commit 4e715f7
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions external/editors/ckeditor/plugins/uploadfile/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/

'use strict';

( function() {
CKEDITOR.plugins.add( 'uploadfile', {
requires: 'uploadwidget,link',
init: function( editor ) {
// Do not execute this paste listener if it will not be possible to upload file.
if ( !CKEDITOR.plugins.clipboard.isFileApiSupported ) {
return;
}

var fileTools = CKEDITOR.fileTools,
uploadUrl = fileTools.getUploadUrl( editor.config );

if ( !uploadUrl ) {
CKEDITOR.error( 'uploadfile-config' );
return;
}

fileTools.addUploadWidget( editor, 'uploadfile', {
uploadUrl: fileTools.getUploadUrl( editor.config ),

fileToElement: function( file ) {
// Show a placeholder with an empty link during the upload.
var a = new CKEDITOR.dom.element( 'a' );
a.setText( file.name );
a.setAttribute( 'href', '#' );
return a;
},

onUploaded: function( upload ) {
this.replaceWith( '<a href="' + upload.url + '" target="_blank">' + upload.fileName + '</a>' );
}
} );
}
} );
} )();

0 comments on commit 4e715f7

Please sign in to comment.