editorjs-image-resize-crop
v1.1.6
Published
Tune image to resize and crop images in EditorJS
Downloads
467
Maintainers
Readme
Image resize and crop tune
Provides Image Tune for the Editor.js.
Allows cropping and resizing images within EditorJS
Installing
Package manager
Using npm:
$ npm install editorjs-image-resize-cropUsing yarn:
$ yarn add editorjs-image-resize-cropUsing pnpm:
$ pnpm add editorjs-image-resize-cropOnce the package is installed, you can import the library using import or require approach:
import { ImageToolTune } from 'editorjs-image-resize-crop';Source code
- Clone this repository:
git clone https://github.com/GuilhermeAGouveia/editorjs-image-resize-crop.git- Install all dependencies
npm install- Run build script:
npm run build- Get the source code in
distdir
How use
Basic use
import EditorJS from '@editorjs/editorjs';
import { ImageToolTune } from 'editorjs-image-resize-crop';
import Image from '@editorjs/image';
const editor = new EditorJS({
tools: {
image: {
class: Image,
tunes: ['imageResize'],
},
imageResize: {
class: ImageToolTune,
config: {
resize: true,
crop: false
}
}
}
});Config Params
| Field | Type | Description |
| -------------- | --------- | ------------------------------- |
| resize | boolean | should start with resize enable |
| caption | boolean | should start with crop enable |
Example:
imageTune: {
class: ImageToolTune as BlockToolConstructable,
config: { resize: true, crop: false },
},Data
This plugin return data using this interface:
interface ImageToolTuneData {
resize: boolean;
resizeSize: number;
crop: boolean;
cropperFrameHeight: number;
cropperFrameWidth: number;
cropperFrameLeft: number;
cropperFrameTop: number;
cropperImageHeight: number;
cropperImageWidth: number;
}Dependencies
- Editor.js (^2.30.8)
- Cropper.js (1.5)
License
- MIT
