3.0.29 • Published 4 years ago

quill-image-and-figure-resizer v3.0.29

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

WIP

Quill ImageResize Module

A module for Quill rich text editor to allow images to be resized.

Also see quill-image-drop-module, a module that enables copy-paste and drag/drop for Quill.

Demo

Plunker

Usage

Webpack/ES6

import Quill from "quill";
import { ImageResize } from "quill-image-resize-module";

Quill.register("modules/imageResize", ImageResize);

const quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		imageResize: {
			// See optional "config" below
		},
	},
});

Script Tag

Copy image-resize.min.js into your web root or include from node_modules

<script src="/node_modules/quill-image-resize-module/image-resize.min.js"></script>
var quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {
			// See optional "config" below
		},
	},
});

Config

For the default experience, pass an empty object, like so:

var quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {},
	},
});

Functionality is broken down into modules, which can be mixed and matched as you like. For example, the default is to include all modules:

const quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {
			modules: ["Resize", "DisplaySize", "Toolbar"],
		},
	},
});

Each module is described below.

Resize - Resize the image

Adds handles to the image's corners which can be dragged with the mouse to resize the image.

The look and feel can be controlled with options:

var quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {
			// ...
			handleStyles: {
				backgroundColor: "black",
				border: "none",
				color: white,
				// other camelCase styles for size display
			},
		},
	},
});

DisplaySize - Display pixel size

Shows the size of the image in pixels near the bottom right of the image.

The look and feel can be controlled with options:

var quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {
			// ...
			displayStyles: {
				backgroundColor: "black",
				border: "none",
				color: white,
				// other camelCase styles for size display
			},
		},
	},
});

Toolbar - Image alignment tools

Displays a toolbar below the image, where the user can select an alignment for the image.

The look and feel can be controlled with options:

var quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {
			// ...
			toolbarStyles: {
				backgroundColor: "black",
				border: "none",
				color: white,
				// other camelCase styles for size display
			},
			toolbarButtonStyles: {
				// ...
			},
			toolbarButtonSvgStyles: {
				// ...
			},
		},
	},
});

BaseModule - Include your own custom module

You can write your own module by extending the BaseModule class, and then including it in the module setup.

For example,

import { Resize, BaseModule } from "quill-image-resize-module";

class MyModule extends BaseModule {
	// See src/modules/BaseModule.js for documentation on the various lifecycle callbacks
}

var quill = new Quill(editor, {
	// ...
	modules: {
		// ...
		ImageResize: {
			modules: [MyModule, Resize],
			// ...
		},
	},
});
3.0.29

4 years ago

3.0.28

4 years ago

3.0.27

4 years ago

3.0.26

4 years ago

3.0.25

4 years ago

3.0.24

4 years ago

3.0.23

4 years ago

3.0.22

4 years ago

3.0.21

4 years ago

3.0.20

4 years ago

3.0.19

4 years ago

3.0.18

4 years ago

3.0.17

4 years ago

3.0.16

4 years ago

3.0.15

4 years ago

3.0.14

4 years ago

3.0.13

4 years ago

3.0.12

4 years ago

3.0.11

4 years ago

3.0.10

4 years ago

3.0.9

4 years ago

3.0.8

4 years ago

3.0.7

4 years ago

3.0.6

4 years ago

3.0.5

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago