visual-space / visual-editor

Rich text editor for Flutter based on Delta format (Quill fork)
MIT License
283 stars 44 forks source link

Convertors - HTML Convertor #5

Open chifandeyu opened 2 years ago

chifandeyu commented 2 years ago

I want get editor delta json convert HTML and set to clipboard.But no convert function for dart.

adrian-moisa commented 2 years ago

Hmmm, that will be a tall order. Technically it's possible but I first need to finish the code cleanup and a few other more burning improvements. There are quite a few tags and exceptions to handle.

Several things to consider:

In essence there will be some differences. Overall I would not encourage anyone to use html as the blob document format stored in the DB. Mainly because if you use HTML, you usually want it HTML because of the human readability factor. Such that novices can do edits. And large part of these edits can end up as being giberish for our reading script. In other words you get the HTML but no touching it.

Plus, just in case you don't know, you can already render in browsers. The only major issue right now in the browsers missing support for video player. It is on my radar since I need it as well.

Basically the only real value of Delta to HTML is when you want to render a SSR version of your app for unlogged users to deal with SEO issues from google. That's my plan for making Visual Space SEO friendly. As you know, Flutter, by it's nature, is by far not a feasible/recommended option for document handling apps. The content gets rendered in a canvas element for performance reasons. The HTML renderer is nowhere close to compete with hand crafted HTML/JS in terms of performance.

I'll keep this issue open for a while to hear more thoughts from the devs interested in this topic. I'd be happy to hear how other editors deal with the HTML issue. So I can't promise a delivery date sooner than end of summer. In the meantime do consider to join the discord server. I'll be also covering this topic in an YT episode once I have a more concrete plan/set of specs.

adrian-moisa commented 2 years ago

I'm thinking maybe it's possible to highjack the HTML renderer from Quill JS if it has any. QuillJS as far as I know reads the same delta format. But I can't guarantee this will work at all. I don't have much knowledge abotu QuillJS and if the delta formats have drifted between the JS and Dart versions.

Wishmater commented 2 years ago

In my specific app, I need to provide a rich text editor for the user to enter content that will be sent by email. The only way to do this is by converting to html. I'm currently using quill, which has some issues but the editor itself works decently well. The problem is in the "workaround" I found for converting to html. I use markdown_quill to convert the deltas to markdown and then markdown to convert the markdown to html. This process, as you might imagine, has a LOT of unpredictable bugs.

I thing being able to somewhat reliably export html would be a strong feature for any text editing package, just for the sheer compatibility html has with everything.

adrian-moisa commented 2 years ago

Exporting to html will be easy compared to importing from HTML. That's one of the issues I have on the radar for this feature. I see what you mean about editing HTML templates. This feature can easily blow in a massive way. For example we are currently missing support for tables. Tables are a must have before going into html. So I guess it will be a while until we get to this stage. But yes, using it for editing email templates seems like a worthy cause. Would be happy to learn more from you what particular details we need to take care when doing the conversion.

Wishmater commented 2 years ago

Even a basic export, supporting only text styles, bullet lists and tables would cover a lot of use cases. Images and video would be a lot harder, but that can be left for later. I understand other features have priority (starting with the tables themselves of course), but I think this definitely has enough value to implement at some point.

kairan77 commented 2 years ago

@chifandeyu , @Wishmater > I want get editor delta json convert HTML and set to clipboard.But no convert function for dart.

There exists several two way delta <-> markdown conversion packages and several two way markdown <->html conversion packages on pub.dev.

It's merely less than a dozen lines of code to chain everything together using those packages.

adrian-moisa commented 1 year ago

After spending the past 6-7 months refactoring and fixing this fork of Quill I'm better equipped to understand the scope of the challenge. So far I can say we are heavily focused on making it work smoothly and reliable. HTML or MD conversions are not top prios at the moment. But if we are to become a popular editor we definitely need them. I can't say an estimated ETA date since at the moment we have more hot potatoes than we can cary, including the Visual Space platform. So therefore, maybe mid 2023 we will have some dedicated time in this direction.

In the mean time, if I manage to attract enough support from the community, maybe it can be done earlier. But expecting the community to contribute now is unrealistic plan for several reasons. First most contributions are subpar to the coding standards that we request. So far no external contributor has bothered to take our training regiment. So it's only us the core devs. So far we have 3 PRs that we requested to be improved, no additional changes were received. So there goes plan A. As for investing into marketing right now to attract more devs, that's not going to happen until we don't have the VS MVP ready. So that's at best March-April 2023.

Until then our focus is on ironing out all known bugs and testing the hell out of the platform. Our main goal is to have a rock solid editor that can handle all sorts of scenarios. In Quill we faced constant issues with all sorts of edge cases that were not fully managed by the core team. Interim conclusion: delta to HTML and HTML to delta will be coming, but not soon.

PS

I don't think stitching together existing packages will fix this issue since we already added new delta attributes. I'm not fully aware if these packages can handle our markers attributes gracefully. And then in HTML we don't know what would be the best output for markers, if any.

adrian-moisa commented 1 year ago

Parked until we have the resources to deal with this. If you can contribute ping me and we reopen.