Giter Site home page Giter Site logo

Comments (6)

Artem-Schander avatar Artem-Schander commented on June 4, 2024 1

i used 'clipboard' as the module object's key

That was the solution. See this sandbox. Everything should work just fine this way.
I'll add a demo for vue-quill to the readme as soon as I find some time.

from quill-paste-smart.

Artem-Schander avatar Artem-Schander commented on June 4, 2024

Hi @MiniJude
I don't fully understand what you mean. Are you asking how to use it in Ecma Script? If so, refer to the docs.
Besides that.. what do you need the modules default export for? there is nothing you can do with it in your code (at least i can not think of anything)

from quill-paste-smart.

MiniJude avatar MiniJude commented on June 4, 2024

Hi @MiniJude I don't fully understand what you mean. Are you asking how to use it in Ecma Script? If so, refer to the docs. Besides that.. what do you need the modules default export for? there is nothing you can do with it in your code (at least i can not think of anything)

Thank you for your reply! I'm sorry i wasn't clear :)
I need to use the paste plug-in on the component VueQuill. I saw your demo . But options are not used in this example, which is what i want to do.

My current solution is to download the module.js file and use it this way:

<template>
  <QuillEditor ref="editorRef" :content="content" contentType="html" :toolbar="defaultToolBar" :modules="modules" theme="snow" />
</template>

<script lang="ts" setup>
import { onMounted, ref, watch } from 'vue'
// @ts-expect-error
import BlotFormatter from 'quill-blot-formatter/dist/BlotFormatter'
// @ts-expect-error
import PasteSmart from './pasteSmartModule.js' // this is your module.js
const props = withDefaults(
  defineProps<{
    content: string
  }>(),
  {
    content: '',
  }
)

const emits = defineEmits<{
  (event: 'update:content', content: string): void
}>()

const editorRef = ref()

const defaultToolBar = [['bold', 'italic', 'underline'], ['image'], ['formula']]

const modules = [
  {
    name: 'blotFormatter',
    module: BlotFormatter
  },
  {
    name: 'clipboard',
    module: PasteSmart,
    options: {
      allowed: {
        tags: ['a', 'b', 'strong', 'u', 's', 'i', 'p', 'br', 'ul', 'ol', 'li', 'img'],
        attributes: ['href', 'rel', 'target', 'class', 'src']
      },
      keepSelection: true,
      substituteBlockElements: true,
    }
  }
]
</script>

from quill-paste-smart.

Artem-Schander avatar Artem-Schander commented on June 4, 2024

Ok, I peeked into vue-quill and tried to reproduce your issue.
I could not find any issue with importing the module by import QuillPasteSmart from 'quill-paste-smart'.
But @vueup/vue-quill seems to fire the paste event twice. This results in duplicate content.
For now I have no idea how to prevent this from happening. Tbh I think its an issue with @vueup/vue-quill since it does not happen in vanilla quill (or any other derivation I know of).
I'll try to find some time to tackle this.

from quill-paste-smart.

MiniJude avatar MiniJude commented on June 4, 2024

Ok, I peeked into vue-quill and tried to reproduce your issue. I could not find any issue with importing the module by import QuillPasteSmart from 'quill-paste-smart'. But @vueup/vue-quill seems to fire the paste event twice. This results in duplicate content. For now I have no idea how to prevent this from happening. Tbh I think its an issue with @vueup/vue-quill since it does not happen in vanilla quill (or any other derivation I know of). I'll try to find some time to tackle this.

Every plug-in in 'modules' object will be registered into quill editor by @vueup/vue-quill, and the quill-paste-smart has registered by itemself. So it caused two triggers?
my code does not trigger twice. i used 'clipboard' as the module object's key. but yours is 'QuillPasteSmart', which is different from the one used when registering your component.
Perhaps my guess is wrong. Looking forward to your answer.

from quill-paste-smart.

Artem-Schander avatar Artem-Schander commented on June 4, 2024

Every plug-in in 'modules' object will be registered into quill editor by @vueup/vue-quill, and the quill-paste-smart has registered by itemself. So it caused two triggers?

That was my first thought also. But it seems not to be the case. vue-quill does not register the plugin (at least not correctly). I get an error if I remove the "register itself" bit.

from quill-paste-smart.

Related Issues (20)

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.