GithubHelp home page GithubHelp logo

flyween / vue3-quill Goto Github PK

View Code? Open in Web Editor NEW
56.0 3.0 16.0 20.4 MB

Quill editor for vue3

Home Page: https://flyween.github.io/vue3-quill/

License: MIT License

JavaScript 45.44% Vue 44.40% HTML 10.16%
quill vue3 editor richtext

vue3-quill's Introduction

vue3-quill

Quill editor for vue3

Version Downloads License

Homepage

vue3-quill github-page

Usage

npm i vue3-quill

Global Registration:

// global
import { quillEditor } from 'vue3-quill'
app.use(quillEditor)

or Local Registration:

// single file
import { quillEditor } from 'vue3-quill'

export default {
  components: {
    quillEditor
  }
}

Module registration example:

// global
import { quillEditor, Quill } from 'vue3-quill'

// Attention:
// customQuillModule means 'custom module name of Quill',
// not a package's name called 'customQuillModule'.
// Such as:
// import ImageUploader from "quill.imageUploader.js";
// Quill.register("modules/imageUploader", ImageUploader);

import customQuillModule from 'customQuillModule'
Quill.register('modules/customQuillModule', customQuillModule)
app.use(quillEditor)

or in a single component

import { quillEditor, Quill } from 'vue3-quill'
// Attention:
// customQuillModule means 'custom module name of Quill',
// not a package's name called 'customQuillModule'.
// Such as:
// import ImageUploader from "quill.imageUploader.js";
// Quill.register("modules/imageUploader", ImageUploader);
import customQuillModule from 'customQuillModule'
Quill.register('modules/customQuillModule', customQuillModule)

export default {
  components: {
    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>

Event binding

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

The following events are available:

  • blur
  • focus
  • ready
  • change

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.

Quill ImageHandler Module
...

Development

# root dir
yarn serve

Welcome PR

Thanks to the open source. ❤️

vue3-quill's People

Contributors

flyween avatar porkio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue3-quill's Issues

quill 2.0 exposed

How about to move to quill 2.0 version?
That is better modules and possibilities!

Thanks!

Has some problems when custom toolbar

There are no changes when I custom toolbar using toolbar option setting in editorOption.modules

editorOption: { modules: { toolbar: [ [{ header: [1, false] }], ['image'] ] } }

There always show all default buttons in the toolbar.

I holp it can support custom toolbar. Maybe there are some bugs when merge custom options with default options.

"TypeError: Cannot read property 'indexOf' of undefined"

When I added the option:

modules: {
    toolbar: false,
}

console would display "TypeError: Cannot read property 'indexOf' of undefined" whenever my router changes to a different link. The error comes from an if statement in editor.vue on line 55:

    onBeforeUnmount(() => {
      const editorToolbar = editor.value.previousSibling
      if (editorToolbar && editorToolbar.className.indexOf('ql-toolbar') > -1) {
        editorToolbar.parentNode.removeChild(editorToolbar)
      }
    })

This error is messing up my app a lot because it's not unmounting quill properly. Quill editor would show up on pages that should not have quill editor.

Installation is not complete?

Registration in the documentation:

  import { quillEditor, Quill } from 'vue3-quill'

  import customQuillModule from 'customQuillModule'

  Quill.register('modules/customQuillModule', customQuillModule)

  app.use(quillEditor)

but by the installation of the package, any 'customQuillModule' was not installed.
How to get this?

Do not automatically include stylesheets

For properly overriding styles it is necessary to have control where styles are included. By automatically importing them this is not or hardly possible.

Please do not import stylesheets but rather add a hint in the docs explaining how to import them manually.

Component is missing template or render function.

Component is missing template or render function.
at <QuillEditor value="

2333

" onUpdate:value=fn options= {placeholder: "core", modules: {…}} ... >
at <Index errors= {} auth= {user: {…}} flash= {success: null, error: null} ... >
at <Layout errors= {} auth= {user: {…}} flash= {success: null, error: null} >
at <Inertia initialPage= {component: "Workspace/Index", props: {…}, url: "/", version: "2097c87aee6c4ad2326d4070be9c46d4"} initialComponent= {layout: {…}, components: {…}, __file: "resources/js/Pages/Workspace/Index.vue", setup: ƒ, render: ƒ, …} resolveComponent=fn ... >

Cannot use import statement outside a module

When I try to export Quill so that can be used by my other libraries, I get the following error:

import Quill from 'quill'
^^^^^^
SyntaxError: Cannot use import statement outside a module

The problem seems related to the first lines in the src/index.js file of this package.
Could you please help me with this problem? Thanks

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'indexOf') at editor.vue:155:57

File: editor.vue

line153 - line158:

onBeforeUnmount(() => {
  const editorToolbar = editor.value.previousSibling
  if (editorToolbar && editorToolbar.className.indexOf('ql-toolbar') > -1) {
    editorToolbar.parentNode.removeChild(editorToolbar)
  }
})

Modify to the following code:

onBeforeUnmount(() => {
  const editorToolbar = editor.value.previousSibling
  // nodeType === 1 : Element,  nodeType === 8: Comment
  if (editorToolbar && editorToolbar.nodeType === 1 && editorToolbar.className.indexOf('ql-toolbar') > -1) {
    editorToolbar.parentNode.removeChild(editorToolbar)
  }
})

When the theme be 'bubble' mode, the variable editorToolbar's nodeType is Comment, It resulted this error.

Custom Quill Module dependancy issue

After running the "npm i vue3-quill" command and adding the global reference as expressed in the guide I receive a dependency error when trying to serve my app.

This dependency was not found:

  • customQuillModule in ./src/main.js

To install it, you can run: npm install --save customQuillModule

The customQuillModule is not a valid command for the NPM repository. is there a way to get past this issue?

Tags classes are being removed

Hi! The editor works fine but I'm having an issue with the tag's classes.
For example, I have this HTML code:

<p class="text-center mb-2">Hi</p>

When I change Hi to Alo the code gets like this:

<p>Alo</p>

Is it possible to keep the classes?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.