-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Description
I want to have user inserted className on table, tr, and td tags. Below is an example code for inserting className on tr tag.
I have the following changes in TableRow
const QuillTableRow = Quill.import("formats/table-row");
class TableRow extends QuillTableRow {
static create(value) {
const node = super.create();
if (value) node.setAttribute("class", value);
return node;
}
static formats(domNode, scroll) {
if (domNode.hasAttribute("class")) {
return domNode.getAttribute("class")
}
return undefined;
}
formats() {
return TableRow.formats(this.domNode);
}
format(name, value) {
if (name === TableRow.blotName && value) {
this.domNode.setAttribute('class', value);
} else {
super.format(name, value);
}
}
}
Quill.register(TableRow);
Shouldn't this implementation be respected?
Given a row (by selection) gotten from quill.getModule("table").getTable() when I call formatLine:
const index = quill.getIndex(row);
quill.formatLine(index, 1, TableRow.blotName, classes);
the format is NOT applied (as in the className is not preserved in tr tag) and the cell in selection disappears (gets deleted).
Also when I try to insert html containing a row format by doing the following:
const value = (
`<table>
<tbody>
<tr class="dangling-modification">
<td data-row="row-t9q9">foo</td>
<td data-row="row-t9q9">bar</td>
</tr>
<tr>
<td data-row="row-xgef"><br/></td>
<td data-row="row-xgef"><br/></td>
</tr>
</tbody>
</table>`);
quill.clipboard.dangerouslyPasteHTML(value);
a cell still disappears.
Is there some other ways of doing this?
Or any other suggestions?
TIA
Metadata
Metadata
Assignees
Labels
No labels