Gathering detailed insights and metrics for @portive/quill-images
Gathering detailed insights and metrics for @portive/quill-images
Gathering detailed insights and metrics for @portive/quill-images
Gathering detailed insights and metrics for @portive/quill-images
npm install @portive/quill-images
Typescript
Module System
Node Version
NPM Version
TypeScript (97.69%)
HTML (1.6%)
JavaScript (0.71%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
14 Stars
60 Commits
1 Watchers
5 Branches
2 Contributors
Updated on Jul 02, 2024
Latest Version
1.0.11
Package Id
@portive/quill-images@1.0.11
Unpacked Size
221.09 kB
Size
55.34 kB
File Count
6
NPM Version
8.19.4
Node Version
16.20.2
Published on
Dec 07, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
Add image uploads with click to upload, drag and drop and paste support. Includes upload progress bar, quick image preview, server side image resizing, presets, support for higher DPI devices with srcset. Configurable styling.
See the Codepen demo.
npm install @portive/quill-images --save
1<!-- Include Quill Editor and Stylesheet --> 2<script src="//cdn.quilljs.com/1.3.6/quill.js"></script> 3<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet" /> 4 5<!-- Include Quill Images --> 6<script src="https://cdn.jsdelivr.net/npm/@portive/quill-images@1.0.9/.dist/index.global.js"></script> 7 8<!-- Create the editor container --> 9<div id="editor" style="width: 720px; height: 481px"> 10 <p>Add images via toolbar button, drag & drop or paste.</p> 11</div> 12 13<!-- Register quill-images (aka ImagePlus), instantiate Quill --> 14<script> 15 ImagePlusModule.registerImagePlus(); 16 const quill = new Quill("#editor", { 17 theme: "snow", 18 modules: { 19 imagePlus: { 20 // Don't worry. This auth token is a public demo. 21 // Committing to the repo is intentional. 22 // Get your own token from portive.com after trying the demo. 23 portiveAuthToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InZ5S1R2N0ZvbXVzTTkyVG0ifQ.eyJpYXQiOjE3MDAxNjYzNDIsImV4cCI6NDg1NTkyNjM0Mn0.cQMl0Wt0z5USr7BlU6v-mTuTuRxlcNNAnZwWbr4Fdn8", 24 }, 25 toolbar: [ 26 ["bold", "italic", "underline", "strike"], 27 ["link", "image"], 28 ], 29 }, 30 }); 31</script>
This assumes usage of JavaScript through an imported /src/main.js
. Get your Portive auth token from https://portive.com.
1import Quill from "quill"; 2import { registerImagePlus } from "@portive/quill-images"; 3 4// must be called to register the module with Quill 5registerImagePlus(); 6 7const quill = new Quill("#editor", { 8 theme: "snow", 9 modules: { 10 imagePlus: { 11 // Don't worry. This auth token is a public demo. 12 // Committing to the repo is intentional. 13 // Get your own token from portive.com after trying the demo. 14 portiveAuthToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InZ5S1R2N0ZvbXVzTTkyVG0ifQ.eyJpYXQiOjE3MDAxNjYzNDIsImV4cCI6NDg1NTkyNjM0Mn0.cQMl0Wt0z5USr7BlU6v-mTuTuRxlcNNAnZwWbr4Fdn8", 15 }, 16 toolbar: [ 17 ["bold", "italic", "underline", "strike"], 18 ["link", "image"], 19 ], 20 }, 21});
If you're using TypeScript, you can get some type safety by importing the ImagePlusOptions
type and using it for the options.
1import Quill from "quill"; 2import { registerImagePlus, ImagePlusOptions } from "@portive/quill-images"; 3 4// must be called to register this module with Quill 5registerImagePlus(); 6 7const imagePlusOptions: ImagePlusOptions = { 8 // Don't worry. This auth token is a public demo. 9 // Committing to the repo is intentional. 10 // Get your own token from portive.com after trying the demo. 11 portiveAuthToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InZ5S1R2N0ZvbXVzTTkyVG0ifQ.eyJpYXQiOjE3MDAxNjYzNDIsImV4cCI6NDg1NTkyNjM0Mn0.cQMl0Wt0z5USr7BlU6v-mTuTuRxlcNNAnZwWbr4Fdn8", 12}; 13 14const quill = new Quill("#editor", { 15 theme: "snow", 16 modules: { 17 imagePlus: imagePlusOptions, 18 toolbar: [ 19 ["bold", "italic", "underline", "strike"], 20 ["link", "image"], 21 ], 22 }, 23});
These are the options you can pass to modules.imagePlus
when instantiating the quill editor. For example:
1const quill = new Quill("#editor", { 2 theme: "snow", 3 modules: { 4 imagePlus: { 5 /* add your options here */ 6 }, 7 toolbar: [ 8 ["bold", "italic", "underline", "strike"], 9 ["link", "image"], 10 ], 11 }, 12});
portiveAuthToken: string
Enter the Portive Auth Token.
Get an auth token from https://portive.com
.
minWidth?: number = 50
When resizing the image, the minimum width an image can be resized to in pixels. If the image is beneath the minimum width, the image cannot be resized.
By default this is 50px.
maxWidth?: number = 480
When resizing an image, the maximum width the image can be resized to in pixels.
By default this is 480px.
imageBorderRadius?: number = 0
The radius at the corner of the image that is displayed. This number can be increased to make the image appear rounder.
By default the image is square at 0px.
Styling the image when it has the current focus after clicking on it.
focusBorderWidth?: number = 4
The width of the border when the image is focused.
By default the border is 4px.
focusBorderColor: string = "black"
The color of the border when the image is focused. It may be specified as any valid CSS color like #0060c0
or black
or rgb(128,128,128)
.
The default is black
.
Styling of the label that displays the width/height at the bottom of the image while the image is being resized.
labelColor: string = "white"
Text color of the label.
labelBackground: string = "black"
Background color of the label.
labelHeight: number = 20
The height of the label in px.
labelBorderRadius: number = 3
The border radius of the label in px.
labelBorderColor: string = "rgba(255, 255, 255, 0.25)"
The color of the border around the label. The default is white with opacity. What this does is it lets the label itself (which is default black) be visible against a black background by adding a bit of transparent white to the border.
labelBorderWidth: number = 1
The width of the border around the label.
labelFontFamily: string = "sans-serif"
The font family used for the label.
labelFontSize: number = 10
The font size for the label.
labelOffset: number = 4
The offset of the label from the bottom edge of the image.
resizePresets: Array<number | string> = [160, 320, "1/2", "100%"]
An array of values that specify a preset size for the image to resize to. The individual preset values can be:
number
: Specifies the width to resize the image to. Note that if the uploaded image is less than the width of the preset, this preset will be shown as disabled.
string
in a format like "1/2": When a string is in the format of a fraction, the image will be resized to that ratio.
string
in a format like "25%": When a string is in the format of a percentage, the image will be resized to that given percentage.
Styling of the image resize presets. The presets are a number of suggested preset sizes for images. See Resize Presets section for details on how to specify the presets themselves.
presetColor: string = 'white'
The color of the preset text.
presetBackground: string = "#000"
The color of the preset background.
presetDisabledColor: string = "#aaa"
The color of the preset text when the option is disabled.
This typically occurs if the resize preset is larger than the actual image size and therefore the image can't be resized to that size.
presetDisabledBackground: string = "#333"
The background color of the preset when the option is disabled.
This typically occurs if the resize preset is larger than the actual image size and therefore the image can't be resized to that size.
presetFocusColor: string = "yellow"
The color of the preset when the mouse hovers over it.
presetFocusBackground: string = "black"
The background color of the preset when the mouse hovers over it.
presetHeight: number = 20
The height of the preset in px.
presetBorderRadius: number = 3
The border radius of the preset in px.
presetBorderColor: string = "rgba(255, 255, 255, 0.25)"
The color of the border around the preset.
presetBorderWidth: number = 1
The width of the border around the preset.
presetFontFamily: string = "sans-serif"
The font family of the text in the preset.
presetFontSize: number = 10
The font size of the text in the preset.
presetOffset: number = 2
The offset of the preset from the top edge of the image.
These options style the resize handle and also specify when the small handle should be used.
As the image is resized, having the resize handle inside the image obscures the image. To improve the user experience, the handle is switched to a smaller handle that appears just outside the image.
handleColor: string = "black"
The color of the resize handle.
smallHandleThreshold: { width: number, height: number } = { width: 100, height: 100 }
If the image is less than the given width or height, the handler switches to the small handle. This ensures that the image is not obscured at small sizes. The handle is also moved outside of the image.
bigHandleRadius: number = 8
The border radius of the big handle.
bigHandleWidth: number = 16
The width of the big handle.
bigHandleHeight: number = 48
The height of the big handle.
smallHandleRadius: number = 6
The border radius of the small handle.
smallHandleWidth: number = 16
The width of the small handle.
smallHandleHeight: number = 24
The height of the small handle.
smallHandleColor: string = "black"
The color of the small handle.
smallHandleOffset: number = 1
The offset of the small handle from the right edge of the image.
No vulnerabilities found.
No security vulnerabilities found.