slab / quill

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

[Parchment] Maximum optimize iterations when creating Table blots #2455

Closed andrei-cacio closed 5 months ago

andrei-cacio commented 5 years ago

I am trying to understand how blots work and I wanted to recreate step by step the Table example from the parchment repo. For now I wrote the following code:

import Quill from 'quill';
import { ContainerBlot } from 'parchment';

class TableBody extends ContainerBlot {}
TableBody.blotName = 'table-body';
TableBody.tagName = 'TBODY';

class Table extends ContainerBlot {}
Table.tagName = 'TABLE';
Table.blotName = 'table-container';
Table.allowedChildren = [TableBody];

Quill.register(Table, true);

and the main node on which Quill is instantiated has the following content:

<table>
    <tbody>
        <tr>
            <th><b>Title</b></th>
        </tr>
        <tr>
            <td >
                  Some row
            </td>
        </tr>
    </tbody>
</table>

and I get the following error:

bundle.js:231739 Uncaught Error: [Parchment] Maximum optimize iterations reached

Steps for Reproduction

-

Expected behavior:

I would expect only the <table><tbody></tbody></table> to render.

Actual behavior:

Error

Platforms:

Chrome MacOS Mojave

Version:

2.0.0-dev

Kiaba commented 3 years ago

I have the same problem. Who can help ?

salkao commented 2 years ago

Any updates on this one? I also have the same issue after extending Header class.

MonkeyInWind commented 2 years ago

+1

inventivejon commented 2 years ago

+1

twada7777 commented 2 years ago

Dose the following work?

- class Table extends ContainerBlot {}
+ class Table extends ContainerBlot {
+   optimize(context);
+   if (this.domNode.tagName !== this.statics.tagName[0]) {
+     this.replaceWith(this.statics.blotName);
+   }
+ }

- Table.tagName = 'TABLE';
+ Table.tagName = ['TABLE'. 'T'];

see also https://github.com/quilljs/quill/blob/develop/formats/bold.js

nehalsoni23 commented 10 months ago

Is there any update on this issue?

quill-bot commented 5 months ago

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: