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

media-quill

v0.1.37

Published

Multimedia Rich text Editor based on Quill

Downloads

8

Readme

Media Quill

Rich text editor based on Quill。
The pictures in the copied HTML content, pasteboard pictures, custom picture upload, pictures can be freely controlled in size. You can upload and insert videos by yourself. Since it is an extension of quill, all methods of quill are applicable

Support

Built in vanilla JS, typescript support, so it can be used on React, Vue, Angular as well

Demo

Test Demo

https://www.domilin.com/submit

API

Provide two apis

1: videoInit

Used to reedit text and rich text display

// display side
videoInit({ width: "600px", height: "400px" });
// editor side
mediaQuill.videoInit({ width: "600px", height: "400px" });

width: video component width
height: Video component height

2: mediaUploading

Check for pictures and videos uploaded when submitting rich text

mediaQuill.mediaUploading();

Installation

npm install --save media-quill

VideoPlayer

The video player can be used alone

import { videoInit, videoPlayerCreate, videoPlayer } from "./MediaQuill/blots/VideoPlayBlots/videoPlayer";

// video player example
videoPlayerCreate({
  videoWrapper: document.getElementById("videoPlayerTestWrapper") as HTMLDivElement,
  src: "https://test-hx24-media.huoxing24.com/video/news/2020/06/30/20200630204904878346.mp4",
  id: "videoPlayerTest"
});
videoPlayer({
  id: "videoPlayerTest",
  width: "400px"
});

// html
<div id="videoPlayerTestWrapper"></div>

//css
@import "media-quill/es/videoPlayer.scss";

Example

Since it contains the video player, it contains both ends: editor side, display side

The editor side instance code use Typescript
The display side instance code use Javascript

But they can all use JS or TS

EditorSide

import React, { useState, useEffect } from "react";
import { useDispatch } from "react-redux";
import MediaQuill from "media-quill";
import { RootDispatch } from "../../models/store";

import "./index.scss";

const toolbarOptions = [
  [{ header: [1, 2, 3, false] }],
  ["bold", "italic", "underline", "strike"], // toggled buttons
  ["blockquote"],
  [{ align: [] }],
  [{ list: "ordered" }, { list: "bullet" }],
  ["link", "image", "video"],
  ["clean"], // remove formatting button
];

export default (): JSX.Element => {
  const dispatch: RootDispatch = useDispatch();
  // 设置编辑器
  const [editor, setEditor] = useState<null | MediaQuill>(null);
  useEffect(() => {
    if (editor) return;
    const options = {
      modules: {
        toolbar: {
          container: toolbarOptions,
        },
        imageResize: {},
        clipboard: {
          imageUpload: async (url: string): Promise<string | undefined> => {
            const res = await dispatch.common.urlImgUpload([
              {
                signTime: new Date().getTime(),
                imgSrc: url || "",
              },
            ]);
            if (res?.code === 1 && res?.obj[0]?.imgSrc) {
              return res.obj[0].imgSrc;
            }
          },
          paste: function (event: MouseEvent) {
            console.log(event);
          },
        },
        mediaUploader: {
          imageUpload: async (file: File): Promise<string | undefined> => {
            const res = await dispatch.common.fileImgUpload({
              type: "news",
              uploadFile: file,
            });

            if (res?.code === 1) {
              return res.obj;
            }
          },
          videoUpload: async (file: File): Promise<string | undefined> => {
            const videoUrl = await dispatch.common.fileLargeUpload({ file });
            if (videoUrl) return videoUrl;
          },
        },
      },
      placeholder: "请输入文章内容",
      theme: "snow",
    };
    const editorQuill = new MediaQuill("#editorQuill", options);
    setEditor(editorQuill);

    // Initialize the video player
    editorQuill.videoInit();
    // Check if a picture or video is uploading
    console.log(editorQuill.mediaUploading());
  }, [editor, dispatch]);
  return <div id="editorQuill"></div>;
};
@import "../../../node_modules/media-quill/es/index.scss";

DisplaySide

import React, { useEffect, useState } from "react";
import { videoInit } from "media-quill/es/videoPlayer";
export default () => {
  useEffect(() => {
    videoInit({ width: "640px" });
  }, []);
  return (
    <div className="ql-container ql-snow">
      <div
        className="ql-editor"
        dangerouslySetInnerHTML={{ __html: htmlString }}
      />
    </div>
  );
};
@import "../../../node_modules/media-quill/es/index.scss";

.ql-editor {
    padding: 0;
}

.ql-container.ql-snow {
    border: none;
}