memspace / zefyr

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

Export document as Widget Tree #243

Open jayaike opened 4 years ago

jayaike commented 4 years ago

Is there any way to export the document as a Widget Tree?

OR

Is there a function that can convert the document to a Widget Tree?

Maybe it would automatically decode the document format and insert the appropriate widget?

cgestes commented 4 years ago

What is a Widget Tree?

Because it sounds like what you are describing is what zefyr does, convert a document to a tree of widget. (to display the document).

jayaike commented 4 years ago

Zyfer, based on what I have seen so far, turns into json. Where the document is then defined with different keys such as "insert", "embed". How can I get it to show as, for example, RichText, TextSpan, etc. @cgestes

cgestes commented 4 years ago

You can turn the list of insert into your widget tree if you want. would that fit your usecase?

On Wed, Feb 5, 2020 at 3:54 PM jayy notifications@github.com wrote:

Zyfer, based on what I have seen so far, turns into json. Where the document is then defined with different keys such as "insert", "embed". How can I get it to show as, for example, RichText, TextSpan, etc.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/memspace/zefyr/issues/243?email_source=notifications&email_token=AAAL75MDRC3Z53TONMUGHVTRBLHKZA5CNFSM4KQDXKJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK3WTYI#issuecomment-582445537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL75OOEIP2NX7JFIWEJVTRBLHKZANCNFSM4KQDXKJQ .

jayaike commented 4 years ago

Yes it would! How can I do that that @cgestes

cgestes commented 4 years ago

have a look here: https://github.com/memspace/zefyr/pull/194/files

Insead of generating html, generate your widget tree.

By the way, why can't you use zefyr for displaying the content (a ZefyrView for example)?

jayaike commented 4 years ago

I am not too sure how to modify that PR to change it to widgets. @cgestes . It is actually pretty urgent so I might even have the time to modify the PR. Maybe later, I would be able to do that.

I didn't see any reference to ZyferView in the docs. Where can I get docs on that and how to use it?

cgestes commented 4 years ago

Afaik you have to read the code. Its quite easy. Parameters are similar to ZefyrEditor.

jayaike commented 4 years ago

But where is the code for the ZefyrView. I can't find any reference to it @cgestes

cgestes commented 4 years ago

https://github.com/memspace/zefyr/blob/master/packages/zefyr/lib/src/widgets/view.dart

jayaike commented 4 years ago

Thanks! I found some docs here https://pub.dev/documentation/zefyr/latest/zefyr/ZefyrView-class.html.

How do I make the image made with image delegate occupy full width and maintain aspect ratio?