slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
42.3k stars 3.31k forks source link

Copy/pasted html is treated as plain text #4268

Open conradfr opened 1 week ago

conradfr commented 1 week ago

I can't figure how to get pasted html text (as a user, not programmatically) and get it interpreted correctly and not as plain text.

I try :

const quill = new Quill('#editor', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block'],
    ],
  },
  placeholder: 'Compose an epic...',
  theme: 'snow', // or 'bubble'
});

and

const quill = new Quill('#editor', {
  modules: {
    toolbar: [
      [{ header: [1, 2, false] }],
      ['bold', 'italic', 'underline'],
      ['image', 'code-block'],
    ],
    clipboard: {
      allowed: {
        tags: ['a', 'b', 'strong', 'em', 'i', 'p', 'br']
      }
    }
  },
  placeholder: 'Compose an epic...',
  theme: 'snow', // or 'bubble'
});

here

Expected behavior:

When html content like <p>Lorem ipsum</p> dolor <strong>sit</strong> amet is pasted by the user the content is formatted by Quill accordingly.

Actual behavior:

It's displayed as-is.

Platforms:

Firefox / Chrome / Safari

Version:

2.02

I guess I'm missing something very basic but what?