Closed glebtv closed 4 years ago
Also inserting headers is broken
Hi, @glebtv
It was really a problem. quill-better-table
can not support inserting other Block blots into table cells except TableCellLine
now. And also can not support other Container blots in table cell.
To support these, I think it might need to modify these relative build-in blots. It will have an effect on
others.
If you really need the supports ?
@glebtv In my product, I disabled inserting table when the cursor is in table cell line.
I fixed this issue by making the editor insert the new table after the existed table:
if (isCaretInTable()) {
const caretContainer = window.getSelection().getRangeAt(0).endContainer;
let nextElement = caretContainer.closest('.quill-better-table-wrapper').nextElementSibling;
setRangeIn(nextElement);
quill.insertText(quill.getSelection(), '\n');
}
// tableModule.insertTable(1, 2);
});
const isCaretInTable = () => {
let caretContainer = window.getSelection().getRangeAt(0).endContainer;
if (!caretContainer.dataset) return false;
else return caretContainer.dataset.row;
};
const setRangeIn = (element) => {
let range = document.createRange();
let sel = window.getSelection();
range.setStart(element, 0);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
this code checks if text caret in a table, if so move the caret after the table then insert there. I'm not sure if this solution satisfies you, but It's a solution.
Like this:![DeepinScreenshot_select-area_20190520115114](https://user-images.githubusercontent.com/1041407/58008681-952f6c00-7af5-11e9-8b0b-d07adee71209.png)