memspace / zefyr

Soft and gentle rich text editing for Flutter applications.
https://zefyr-editor.gitbook.io
2.22k stars 551 forks source link

quill delta format to PDF and HTML #33

Open ghost opened 6 years ago

ghost commented 6 years ago

is there any interest in this ?

This woudl allow a user to print a zefyr document by first converting it to PDF.

This dart package looks like the good: https://github.com/DavBfr/dart_pdf

SO all we only need to do write a generic parser in Dart that takes the current zefyr / quill format and convert it to PDF. Because zefyr format is limited ( like markdown in a way) it should not be too hard.

I am not sure if its Notus that is the actual on data structure we work from ?

ghost commented 6 years ago

i found a nodejs quill-delta to html. It would be a good spec / example to work from. https://www.npmjs.com/package/quill-delta-to-html

But again i dont know if its Notus that is the source format ?

leedstyh commented 6 years ago

Converting to PDF would be very helpful!

ghost commented 6 years ago

hey @pulyaevskiy what do you think of the idea ?

If you have other plans in this area, i am happy to adapt.

stemuk commented 6 years ago

@gedw99 It would be really helpful to have such functionality for delta documents in flutter!

And while I believe that this functionality would be best implemented outside of the zefyr editor in a separate package, I would love to help with building such functionality or help with testing if you already have something in the making.

https://flutter.io/developing-packages/ This article would then go into detail on how to publish a package on pub.dartlang.org once it is ready.

pulyaevskiy commented 6 years ago

Sorry for late response here. I definitely think this is a valuable thing to do.

There is one thing I’m mostly concerned about which is bringing in too many dependencies into Zefyr or Notus. I’d like these packages to be lightweight and not force users downloads the rest of Pub with them.

I currently have basic markdown converter in notus, but I’m starting to consider stripping out into a separate notus_convert package. This package would also be a good place for HTML and PDF converters.

I can go ahead and set it up if this would help you guys to contribute.

Let me know your thoughts.

ghost commented 6 years ago

hey @pulyaevskiy thats the exact approach i would do also - converters.

SO to Print a Zefyr doc, your thinking zefyr --> Notus ( file ) --> Markdown --> PDF ? https://github.com/memspace/zefyr/blob/master/packages/notus/lib/src/convert/markdown.dart

I would also like: zefyr --> Notus ( file ) --> PDF Here is why.. Converting to Markdown is damn useful because you can then do anything with it. Save it into github, put on a webpage, etc etc Converting from Notus --> PDF will ensure you have a pixel perfect match always. Markdown is the lowest common denominator, but Notus to PDF will always be pure exact copy visually.

Also there is another reason too. Zefyr proves whats possible with Flutter in terms of highly interactive software. I think that Spreadsheets, Powerpoints and SVG Editors will be built with Flutter ongoing. Especially since it runs on Desktop quite well now. All with collaboration possibilities thanks to quill. For instance, so say i wanted to build an SVG Editor ! I would be taking your zefyr code and maybe using 40% of it to make a SVG Editor app. Then build a Notus equivalent on top of quill package. Call it SVGNotus format. Then for PDF export, i would look at the Notus --> PDF package and take x% of it too. Basically its a 3 layer stack archi of: a. Presentation b. File Format / Serialisation c. Export to PDF

You should keep Zefyr & Notus and the exporter light and focussed. i agree. But i can see also a leaning towards one day abstracting some of Zefyr & Notus out to a core package maybe. I expect this will happen sometime down the road.

ghost commented 6 years ago

About Notus to PDF... We will need to re-layout the zefyr document at some point because you need to calculate exact x and y positions for the PDF page size. But Notus does not hold the x and y placement data. It only holds the structural relationship ?

SO to go from notus to pdf, how to calc the x and y ? Seems maybe we have to use some of zefyr ?

See example: https://github.com/DavBfr/dart_pdf/tree/master/pdf

stemuk commented 5 years ago

@gedw99 Any progress on this feature so far? I would love to help with testing/prototyping since I believe most zefyr users would benefit in one way or another from having an export feature. After separating the notus_convert package as @pulyaevskiy mentioned the remaining work should be much easier since Markdown to PDF renders are already existing and a simple port to dart should do the trick.

stemuk commented 5 years ago

@pulyaevskiy I was lately looking into exporting a Zefyr document into Markdown using the Notus converter you mentioned above, but I had trouble finding it. Could you maybe quickly outline how to access the Markdown generated by the Notus markdown converter?

ghost commented 5 years ago

hey @stemuk Nothng on my side. Too many things going on. GO for it and please comment back here how you go.

Has the notus_convert package been seperated out yet though ?

stemuk commented 5 years ago

@gedw99 I will let you know if I make any progress on this side, for now I am focusing on exporting to Markdown though. As for the separation I think the notus_convert package has not yet been separated but I believe the basic markdown functionality should already be usable.

Panthro commented 5 years ago

My users are asking for this one, I successfully released a version of my app with "note taking" feature, but now people are asking for a way to "export" the notes with formatting :-)

pulyaevskiy commented 5 years ago

Thanks for the feedback @Panthro!

I’m planning to have more updates in January. This is not very high on the list yet but I’ll keep everyone posted when I get to this.

tth05 commented 5 years ago

Nice, I'd love to see this actually happening

lukepighetti commented 5 years ago

@pulyaevskiy May I recommend exporting an interface for conversion, something like, ZefyrOutputDelegate (just made up the name), which can be implemented by any package. For example, it could result in zefyr_markdown, zefyr_pdf, zefyr_html, zefyr_hewn_stone_tablet, zefyr_smoke_signals, whatever.

Or perhaps notus_html etc.

And you would provide the converter/serializer when you create a new Zefyr widget.

Panthro commented 5 years ago

hey @pulyaevskiy any update on this? :-)

Has anyone found a way to export the document to pdf or html?

thanks

ghost commented 5 years ago

@Panthro There is a PR that does conversion to HTML

SO from HTML, its easy to convert to PDF using the PDF Dart lib. There are a few out there. I am bogged down with other stuff right now. If i had time it woudl be something i would do. I dont think its that complex.

dedikusnadi207 commented 5 years ago

@pulyaevskiy Has anyone found a way to export the document to pdf? And save as template file?

Thanks