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

vue-quilly

v1.1.0

Published

[![npm version](https://img.shields.io/npm/v/vue-quilly?logo=npm&logoColor=fff)](https://www.npmjs.com/package/vue-quilly) [![npm bundle size](https://img.shields.io/bundlephobia/min/vue-quilly)](https://www.npmjs.com/package/vue-quilly?activeTab=code) [!

Downloads

7,897

Readme

vue-quilly

npm version npm bundle size NPM Type Definitions GitHub License

Tiny Vue component, that helps to create Quill v2 based WYSIWYG editors in Vue-powered apps. Flexible setup, no styles, ready for further customization.

Default input data format is HTML, but also has Delta support - using Quill API and exposed Quill instance. In short, HTML and Delta inputs works in a same way, you can use one of them or both formats to change editor data model.

It's not a all-in-one solution and requires further Quill configuration. In other hand, you can build your own editor, that matches your needs, with easy. No matter if you want to create full-featured editor with all Quill's modules or small custom solution with extra functionality, you can use this package as a base start point:

  • Run demo, that shows editors, builded upon QuillyEditor component.
  • See editors example.
  • Create editors with Nuxt 3.

Features

  • Builded on top of Quill v2 and Vue 3
  • Uses quill/core to prevent importing all Quill modules
  • Works with both HTML and Quill Delta format
  • Typescript support

Setup

Browser:

<!-- Include Quill 2 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.snow.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/quill.js"></script>

<!-- Import Vue and vue-quilly -->
<script type="importmap">
  {
    "imports": {
      "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js",
      "vue-quilly": "https://unpkg.com/[email protected]/dist/vue-quilly.js"
    }
  }
</script>

<!-- Initialize the editor -->
<div id="app">
  <quilly-editor ref="editor" v-model="model" :options="options" />
</div>

<script type="module">
  import { createApp, ref, onMounted } from 'vue'
  import { QuillyEditor } from 'vue-quilly'

  createApp({
    setup() {
      const options = {
        theme: 'snow',
        modules: {
          toolbar: true,
        },
        placeholder: 'Compose an epic...',
        readOnly: false
      }
      
      const editor = ref()
      const model = ref('<p>Hello Quilly!</p>')
      let quill = null
      
      onMounted(() => {
        quill = editor.value.initialize(Quill)
      })
      
      return {
        editor,
        options,
        model
      }
    }
  })
    .component('QuillyEditor', QuillyEditor)
    .mount('#app')
</script>

Browser setup demo - https://codepen.io/redrobot753/pen/VwJwPLP

Bundlers:

npm install quill vue-quilly
# Or
yarn add quill vue-quilly
# Or
pnpm add quill vue-quilly

Import Quill full build if you need all modules or core build with minimum required modules:

import Quill from 'quill' // Full build
import Quill from 'quill/core' // Core build
import { QuillyEditor } from 'vue-quilly'

Add core styles. Also import one of Quill's themes, if you need one:

import 'quill/dist/quill.core.css' // Required
import 'quill/dist/quill.snow.css' // For snow theme (optional)
import 'quill/dist/quill.bubble.css' // For bubble theme (optional)

Define Quill options:

const options = {
  theme: 'snow', // If you need Quill theme
  modules: {
    toolbar: true,
  },
  placeholder: 'Compose an epic...',
  readOnly: false
}

Initialize the editor:

const editor = ref<InstanceType<typeof QuillyEditor>>()
const model = ref<string>('<p>Hello Quilly!</p>')
// Quill instance
let quill: Quill | null = null
onMounted(() => {
  quill = editor.value?.initialize(Quill)!
})
<QuillyEditor
  ref="editor"
  v-model="model"
  :options="options"
  @update:modelValue="(value) => console.log('HTML model updated:', value)"
  @text-change="({ delta, oldContent, source }) => console.log('text-change', delta, oldContent, source)"
  @selection-change="({ range, oldRange, source }) => console.log('selection-change', range, oldRange, source)"
  @editor-change="(eventName) => console.log('editor-change', `eventName: ${eventName}`)"
  @focus="(quill) => console.log('focus', quill)"
  @blur="(quill) => console.log('blur', quill)"
  @ready="(quill) => console.log('ready', quill)"
/>

⚠️ Use v-model for HTML content type. The received content is equal to Quill's editor element innerHTML property value.

In some cases it will be better to use quill.semanticHTML() to get a clean HTML output. For doing this just set a property :is-semantic-html-model="true". See SemanticHTMLEditor example.

Also you can set content in Delta format using Quill instance:

quill?.setContents(
  new Delta()
    .insert('Hello')
    .insert('\n', { header: 1 })
    .insert('Some ')
    .insert('initial', { bold: true })
    .insert(' ')
    .insert('content', { underline: true })
    .insert('\n')
)

This is just basic example and shows you how to build your editor. See creating editors with QullyEditor example or run demo.

Events

The component emits text-change, selection-change, editor-change events, similar to Quill events.

All events types:

| Event name | Params | | ------------------- | ---------------------------------------------------------------- | | update:modelValue | value: string | | text-change | { delta: Delta, oldContent: Delta, source: EmitterSource } | | selection-change | { range: Range, oldRange: Range, source: EmitterSource } | | editor-change | eventName: string | | focus | quill: Quill | | blur | quill: Quill | | ready | quill: Quill |

Nuxt

You must build your editor, based on VueQuilly component first. Then put it inside ClientOnly component if you plan to use SSR:

<ClientOnly>
  <CompleteEditor />
</ClientOnly>

See Nuxt 3 example.

License

MIT

Inspiration projects and useful links

https://github.com/quilljs/quill

https://github.com/surmon-china/vue-quill-editor

https://github.com/vueup/vue-quill

https://www.matijanovosel.com/blog/making-and-publishing-components-with-vue-3-and-vite