attoae / quill-table-better

A module that enhances the table functionality of Quill.
MIT License
20 stars 4 forks source link

[BUG] Replacing default <p> tags by div make quill-table-better crash #22

Open sylvainpe opened 1 week ago

sylvainpe commented 1 week ago

Replacing default p tags by div make quill-table-better crash on load

const Block = Quill.import('blots/block');
Block.tagName = 'div';
Quill.register(Block);

How I load default data in editor:

const delta = quillEditor.clipboard.convert({
      html: defaultValue,
      text: '\n'
    });
    const range = quillEditor.selection.getRange();
    quillEditor.updateContents(delta, Quill.sources.USER);
    quillEditor.setSelection(delta.length() - range.length, Quill.sources.SILENT);
attoae commented 1 week ago

Why change the tagName of BlockBlock is the super class of Quill. Maybe you want to change the tagName of TableCellBlock, as follow:

const TableCellBlock = Quill.import('formats/table-cell-block');
TableCellBlock.tagName = 'div';
attoae commented 1 week ago

I'm not sure if changing it like this will cause other problems. I'm wondering what is your starting point for doing this?

sylvainpe commented 1 week ago

I managed to keep using P as default. it's just that when i render my quill html I don't really like having paragraphs, because sometimes I just want to display things "in line".

(edit: I saw this: https://stackoverflow.com/questions/45496023/quill-make-editor-wrap-text-in-div-instead-of-p-tag)

I think you can close the issue if you like.

attoae commented 1 week ago

Okay, I need some time to verify this issue and get back to you later.

attoae commented 1 week ago

You can use the following method in the current version.

const Block = Quill.import('blots/block');
Block.tagName = 'div';
Quill.register({ 'blots/block': Block }, true);

Quill.register({
  'modules/table-better': QuillTableBetter
}, true);

const TableCellBlock = Quill.import('formats/table-cell-block');
TableCellBlock.tagName = 'div';

I am considering whether to remove TableCellBlock.tagName and inherit Block.tagName in future versions.