npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

quill-resize-module

v2.0.4

Published

A module for Quill rich text editor to allow images/iframe/video and custom elements(covert to placeholder) to be resized.

Downloads

3,972

Readme

Quill Resize Module

A module for Quill rich text editor to allow images/iframe/video and custom elements to be resized.

This module is original forked from https://github.com/whatcould/quill-image-resize-module.

Changed V2

  1. Support Quill2
  2. Removed formats/image formats/placeholder
  3. Removed options.styles
  4. Add embedTags option for custom embed element
  5. Add tools option for custom toolbar

Features

  • Image resize

  • Embed resize (Default to iframe/video tag)

  • Custom any elements resize

  • Limit minWidth/maxWidth/minHeight/maxHeight

  • Limit Width/Height ratio

  • Selected embed element style

  • Direction key support

Demo

https://codesandbox.io/p/sandbox/9m9vl8 demo

Usage

Webpack/ES6

import Quill from 'quill';
import QuillResize from 'quill-resize-module';
Quill.register('modules/resize', QuillResize);

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

Script Tag

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

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

Config

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

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

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: {
        // ...
        resize: {
            modules: [ 'Resize', 'DisplaySize', 'Toolbar' ]
        }
    }
});

Customize the toolbar buttons with "tools" option.

For example, add handler for image alt attribute:

const quill = new Quill(editor, {
    // ...
    modules: {
        // ...
        resize: {
            tools: [
              'left', 'right',
              {
                text: 'Alt',
                verify (activeEle) {
                    return (activeEle && activeEle.tagName === 'IMG')
                },
                handler (evt, button, activeEle) {
                    let alt = activeEle.alt || ''
                    alt = window.prompt('Alt for image', alt)
                    if (alt == null) return
                    activeEle.setAttribute('alt', alt)
                }
              }
            ]
        }
    }
});

Resize - Resize the element

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

The look and feel can be controlled with options:

var quill = new Quill(editor, {
    // ...
    modules: {
        // ...
        resize: {
            // ...
            // set parchment key to enable resize module
            parchment: {
                image: {
                    attribute: ['width'],  // ['width', 'height']
                    limit: {
                        minWidth: 200,
                        maxWidth: 600,
                        minHeight: 200,
                        maxHeight: 450,
                        ratio: .5625  // keep width/height ratio. (ratio=height/width)
                    }
                }
            }
        }
    }
});

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 QuillResize from 'quill-resize-module';
Quill.register('modules/resize', QuillResize);

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

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