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

simple-quill-upload

v1.0.3

Published

A module for images and videos to be uploaded to a server instead of being base64 encoded.

Downloads

14

Readme

simple-quill-upload

A module for images and videos to be uploaded to a server instead of being base64 encoded, in ngx-quill from toolbar editor.

Features

  • Written in typescript
  • Bundled in both FESM2015 and UMD formats
  • Just 6.4KB (2.4 KB gzipped)
  • Gives you full control over API call, upload to S3 or server as required
  • Supports png, jpg and jpeg for image uploads
  • Supports mp4 and webm for video uploads
  • Supports <img> tag for image uploads, <video> tag for video uploads
  • Based on quill-upload by john-techfox

Updates

  • Image Attribute support added for ['style','alt','width','height']
  • Concurrent upload handling for images, videos
  • MIME Type check added for files
  • Added Support for providing extensions for the following image and video formats -
    • Supported Image Extensions -
      • 'apng', 'bmp', 'gif', 'ico', 'cur', 'jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp', 'png', 'svg', 'tif', 'tiff', 'webp'
    • Supported Video Extensions -
      • 'mp4', 'webm', '3gp', 'mp4', 'mpeg', 'quickTime', 'ogg'

Installation

  • npm install simple-quill-upload
  • install quill

Usage

In your component.ts

import Quill from 'quill';
import { VideoHandler, ImageHandler, Options } from 'ngx-quill-upload';

Quill.register('modules/imageHandler', ImageHandler);
Quill.register('modules/videoHandler', VideoHandler);


  modules = {
    toolbar: [
    ....
    ....
      ['image', 'video']
    ],
    imageHandler: {
      upload: (file) => {
       return // your uploaded image URL as Promise<string>
      },
      accepts: ['png', 'jpg', 'jpeg', 'jfif'] // Extensions to allow for images (Optional) | Default - ['jpg', 'jpeg', 'png']
    } as Options,
    videoHandler: {
      upload: (file) => {
        return // your uploaded video URL as Promise<string>
      },
      accepts: ['mpeg', 'avi']  // Extensions to allow for videos (Optional) | Default - ['mp4', 'webm']
    } as Options
  };

In your component.html markup

 <quill-editor [modules]="modules"></quill-editor>

A sample upload function for imageHandler

   upload: (file) => {
        return new Promise((resolve, reject) => {

      if (file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg') { // File types supported for image
        if (file.size < 1000000) { // Customize file size as per requirement

        // Sample API Call
          const uploadData = new FormData();
          uploadData.append('file', file, file.name);

          return this.http.post('YOUR API URL', uploadData).toPromise()
            .then(result => {
                resolve(result.message.url); // RETURN IMAGE URL from response
            })
            .catch(error => {
              reject('Upload failed');
              // Handle error control
              console.error('Error:', error);
            });
        } else {
          reject('Size too large');
         // Handle Image size large logic
        }
      } else {
        reject('Unsupported type');
       // Handle Unsupported type logic
      }
    });
  }

ss global register warnings

simple-quill-upload uses Quill.register for overwriting an existing module for Image and Video handler, QuillJS logs a warning. To supress those expected warnings you can turn them off by passing suppressGlobalRegisterWarning: true in ngx-quill config. Read more here