Closed thibaudcolas closed 6 years ago
Merging this with #138.
I find that draftail doesn't preserves any kind of table on paste.
Is there any workaround for this?
@tutuca no, tables aren’t supported by the editor.
@thibaudcolas I can't find an open issue here but there seems to be some prior art around draft.js proper [1] [2]. It seems hard to believe that there's nobody with the need to paste some tables here and there. Is it too much a hassle to support some pasted tabulated content?
[1] https://github.com/draft-js-plugins/draft-js-plugins/issues/921 [2] https://github.com/SamyPesse/draft-js-table
I know people who have wished for table support in the past. I think the main reason why this hasn't happened is that it's not that easy to build in rich text, so most people will just give up on the idea of being able to have tables anywhere in their content. They'll instead choose to make something more purpose-built, custom, and less likely to be open-sourced. For example some integration of https://handsontable.com/.
For Draft.js (and Draftail) in particular, I know it's possible but not easy because Draft.js doesn't have good support for nested editing (eg. using Draft.js features within the cells of the tables, having text formatting inside table). I think folks who were frustrated with this tended to switch to Slate, but I didn't follow up.
It's still definitely possible though even if not easy – all it takes is for someone to dedicate time to it. https://github.com/SamyPesse/draft-js-table would probably be a good place to start, after having assessed the caveat in its README header about needing https://github.com/facebook/draft-js/pull/388.
Without any kind of nested editing, I believe that a custom block using https://handsontable.com/ or similar would be much easier to implement. But that has its own limitations of course.
What's your opinions on the posibility of a slate port?. I can tell the fatigue from afar having just read that you switched from hallo to draft. I wouldn't want to fragment the contributors maintaining yet another editor.
Thanks for the deailed response!. I'll keep you posted if I came around implementing paste support for tables.
I considered Slate about 1.5 years ago, but wasn't convinced. The main reason why I didn't pursue it further is that it doesn't have the backing of a big engineering organisation like Facebook's. Technically, Slate seems much more flexible than Draft.js, but in ways that mostly didn't matter to me at the time (wanting to build something for Wagtail specifically).
If you or anyone else wants to invest time in building a competing editor, I think it's worth exploring, and I'll be happy to help with my rich text knowledge, but it's a big investment.
I'd be much more interested in porting Draftail to the draft-js-plugins
architecture (#83) to make it easier to integrate things from that ecosystem, and make it all easier to maintain. I'll add a few more notes about this on #83.
See https://github.com/thibaudcolas/draftjs-filters/blob/master/pasting/README.md first.