Rahul Jain
Rahul Jain

Reputation: 21

How to enable functionality paste table in quill editor

we are trying to enable the functionality to paste the table in quill editor, but it's not working .

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

;

Upvotes: 2

Views: 8535

Answers (1)

Andre
Andre

Reputation: 788

In the documentation for QuillJS it states "Note: This particular example was selected to show what is possible. It is often easier to just use an API or configuration the existing module exposes. In this example, the existing Clipboard’s addMatcher API is suitable for most paste customization scenarios." (https://quilljs.com/docs/modules/)

Meaning you can catch the text that is pasted from the clipboard, ex:

quill.clipboard.addMatcher(Node.TEXT_NODE, function(node, delta) {
  return new Delta().insert(node.data);
});

You can then handle the event data appropriately and return however you would like the data to be formatted. In your case, you can check the variables if it looks like a table and properly insert a table based off the parsed data.

Upvotes: 0

Related Questions