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

vue3-quill-editor-vite

v0.0.5

Published

Quill editor component for Vue

Downloads

96

Readme

vue3-quill

Quill editor for vue3

Homepage

vue3-quill-editor-vite github-page

Usage

npm i vue3-quill-editor-vite
yarn add vue3-quill-editor-vite

Global Registration:

// global
import { QuillEditor, Quill } from 'vue3-quill-editor-vite'
import 'vue3-quill-editor-vite/dist/style.css'
app.use(QuillEditor)

or Local Registration:

//single file
import { QuillEditor, Quill } from 'vue3-quill-editor-vite'
import 'vue3-quill-editor-vite/dist/style.css'

export default {
  components: {
    [QuillEditor.name]: QuillEditor
  }
}

In .vue

<template>
  <quill-editor
    v-model:value="state.content"
    :options="state.editorOption"
    :disabled="state.disabled"
    @blur="onEditorBlur($event)"
    @focus="onEditorFocus($event)"
    @ready="onEditorReady($event)"
    @change="onEditorChange($event)"
  />
</template>

<script>
import { reactive } from 'vue'

export default {
  name: 'App',
  setup() {
    const state = reactive({
      content: '<p>2333</p>',
      _content: '',
      editorOption: {
        placeholder: 'core',
        modules: {
          // toolbars: [
            // custom toolbars options
            // will override the default configuration
          // ],
          // other moudle options here
          // otherMoudle: {}
        },
        // more options
      },
      disabled: false
    })

    const onEditorBlur = (quill) => {
      console.log('editor blur!', quill)
    }
    const onEditorFocus = (quill) => {
      console.log('editor focus!', quill)
    }
    const onEditorReady = (quill) => {
      console.log('editor ready!', quill)
    }
    const onEditorChange = ({ quill, html, text }) => {
      console.log('editor change!', quill, html, text)
      state._content = html
    }

    setTimeout(() => {
      state.disabled = true
    }, 2000)

    return { state, onEditorBlur, onEditorFocus, onEditorReady, onEditorChange }
  }
}
</script>

Options

Form Input Bindings: v-model

The v-model directive can be used to create a two-way data binding. For example:

<quill-editor v-model:value="state.content"></quill-editor>

// tsx
<QuillEditor v-model:value={state.content} />

Event binding

<quill-editor
    v-model:value="state.content"
    @blur="onEditorBlur($event)"
    @focus="onEditorFocus($event)"
    @ready="onEditorReady($event)"
    @change="onEditorChange($event)"
  />

// tsx
<QuillEditor
    v-model:value={state.content}
    @blur={onEditorBlur}
    @focus={onEditorFocus}
    @ready={onEditorReady}
    @change={onEditorChange}
  />

readOnly

const options = {readOnly: true}

<quill-editor
    v-model:value="state.content"
    :options="options"
  />

// tsx
<QuillEditor
    v-model:value={state.content}
    options={options}
  />

image upload

const state = reactive({
	value: '',
	content: '',
	insertImage: ''
})
const quillImage = ref(null)
const options = {readOnly: true}

// Select file event
const selectFile = () => {
	if (quillImage.value) {
		const inputFile = quillImage.value as HTMLInputElement
		inputFile.click()
	}
}

const uploadImage = function (res: Event) {
	const inputFile = res.target as HTMLInputElement
	if (inputFile.files && inputFile.files.length) {
		// Picture upload logic
		doUpload(inputFile.files[0]).then((value: string) => {
			console.log(value)
			state.insertImage = value
		})
	}
}

<quill-editor
	height={'100%'}
	v-model={state.value}
	content={state.content}
	imageCallback={selectFile}
	insertImage={state.insertImage}
>
	<template #uploadButton>
		<input ref="quillImage" type="file" onChange="uploadImage" accept="image/*" />
	</template>
</quill-editor>

// tsx
<QuillEditor
		height={'100%'}
		v-model={state.value}
		content={state.content}
		imageCallback={selectImage}
		insertImage={state.insertImage}
		v-slots={{
			'uploadButton': () => <input ref={quillImage} type="file" onChange={uploadImage} accept="image/*" />
		}}
	/>

The following events and arguments are available:

  • blur argu: quill
  • focus argu: quill
  • ready argu: quill
  • change argu: html, text, quill

Options prop

  • options
    Apply the default options by not passing this prop.
    The options passed in will override the default preset options.
    For example:
    modules: {
      toolbar: []
    }
    this option will generate an empty toolbar.
    Check the offical doc Quill Documentation for all options.
  • disabled
    Default: false
    Set true to disabled the editor. As the value of readOnly when initialized. Value changing will call API Quill Documentation of quill after initialization.

Default Quill options

modules: {
  toolbar: [
    ['bold', 'italic', 'underline', 'strike'],
    ['blockquote', 'code-block'],
    [{ header: 1 }, { header: 2 }],
    [{ list: 'ordered' }, { list: 'bullet' }],
    [{ script: 'sub' }, { script: 'super' }],
    [{ indent: '-1' }, { indent: '+1' }],
    [{ direction: 'rtl' }],
    [{ size: ['small', false, 'large', 'huge'] }],
    [{ header: [1, 2, 3, 4, 5, 6, false] }],
    [{ color: [] }, { background: [] }],
    [{ font: [] }],
    [{ align: [] }],
    ['clean'],
    ['link', 'image', 'video']
  ]
}

Packages

Borrowing from: vue-quill-editor Inspired by this one

Development

# root dir
yarn serve

Welcome PR

Thanks to the open source. :heart: