A tinyMCE plugin for upload image on HTML5(input[type=file] or drag and drop)
npm install tinymce-plugin-h5img
You can import the plugin easily as commonjs
/ es6
modules. (with tsc
, webpack
, etc)
import 'tinymce-plugin-h5img'
require('tinymce-plugin-h5img')
If you didn't use a modules resolver. You can also use dist/plugin.js
directly.
window.tinyMCE.init({
plugins: ['h5img', /* and other plugins */],
toolbar: 'h5img',
uploadConfig: {
// configure
}
});
The uploadConfig
has theese attributes:
Define a function to upload HTML5 File
object to web server.
The function will get a File object and return a promise.
The type define is:
interface ISendResult {
file: File;
url?: string;
}
type IUploadFile = (file: File) => Promise<ISendResult>
If uploadConfig.uploadFile
is not defined, it will only display local image, without post file.
Accept upload image's type, e.g: ['image/jpeg','image/png',...], default scene allowed jpg, png and gif.
Icon on toolbar, default value is 'image' (same to tinymce image icon)
Background color when drag img into editor, default is #f8ffe5
.