question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trying to render (read-only) tables with Quill

See original GitHub issue

It is more a technical question rather than an issue but I cannot figure out how to solve it.

I am trying to render make Quill render a simple table. I do not intend to have manipulations on that table, only on the text in the cells.

<div id="content">
    <table>
        <tbody>
            <tr>
                <th data-rte-fence=""><b>Table header</b></th>
            </tr>
            <tr>
                <td data-rte-fence="">row 1</td>
            </tr>
            <tr>
                <td data-rte-fence="">row 2</td>
            </tr>
        </tbody>
    </table>
</div>

I created my blots like so:

import Quill from 'quill';

const { Block, Container } = Quill.import('parchment');

class TableCell extends Block {
    static tagName = 'TD';
    static blotName = 'table-cell';
}

class TableHead extends Block {
    static tagName = 'TH';
    static blotName = 'table-head';
}

class TableRow extends Block {
    static tagName = 'TR';
    static blotName = 'table-row';
    static allowedChildren = [TableHead, TableCell];
}

class TableBody extends Block {
    static tagName = 'TBODY';
    static blotName = 'table-body';
    static allowedChildren = [TableRow];
}

class Table extends Block {
    static tagName = 'TABLE';
    static blotName = 'table';
    static allowedChildren = [TableBody];
}

Quill.register(Table);
Quill.register(TableBody);
Quill.register(TableRow);
Quill.register(TableCell);
Quill.register(TableHead);

However I spin it I am still getting this error:

Uncaught Error: Cannot insert block into scroll

After reading the parchment docs I understood that Block blots are similar to block like elements like <p></p> or <div></div> so I figured that they could be a good fit for <table>, <tbody> etc. So I figured that it would be enough just to create the blots and populate them with the correct tag names and Quill will simply render them.

In the parchment docs only three kind of blots are described: Block, Inline and Embed however in the Quill code base I see all sorts of blots used like: Container, Scroll etc. I couldn’t find the relationship between them and I don’t understand when to use one and when the other. In my examples, I simply inherit from the Block blot.

Any help is kindly appreciated thanks!

Steps for Reproduction

Demo here: https://codesandbox.io/s/rmlrl2oqqn StackOverflow question: https://stackoverflow.com/questions/53871816/handling-table-raw-html-in-quill

Expected behavior: Simply rendering the table

Actual behavior: Error when inserting the block

Platforms:

Chrome, MacOS Mojave

Version:

1.3.6

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andrei-caciocommented, Jan 6, 2019

The demo is based on Quill 2.0. Which isn’t released yet. I wouldn’t feel too comfortable going in production with a dev release. All the docs and reading material are written for Quill 1.x. (Or if there are docs for Quill 2.0 please link me). I tried installing Quill 2.0 but a lot of the API’s have changed and I would have to rewrite a lot of logic for it to work. Also because of there aren’t any docs I have to dig deep into the source code to understand how everything works in Quill 2.0.

Isn’t there a way to make tables work in Quill 1.x?

0reactions
padraigflcommented, Nov 7, 2019

moved comment to more relevant issue here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there any way to make the quill better-table uneditable?
I have a quill editor with a quill-better-table module. I want it to be uneditable at certain times, so I set it to...
Read more >
API - Quill Rich Text Editor
Quill is a free, open source WYSIWYG editor built for the modern web. Completely customize it for any need with its modular architecture...
Read more >
@sankartw/quill-better-table - npm
Clicking on tables in quill editor will initialize the tools for table, all features are based on it. Multiple lines in table cell....
Read more >
Quill
Quill's implicit joins use a monadic syntax making them pleasant to use for joining many tables together. They look a lot like Scala...
Read more >
Hello I'm using the new Add-On "Rich-Text-Editor" for a ...
https://codesandbox.io/examples/package/quill-table ... but as soon as I try to activate the module within one of the "module: {}" blocks, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found