-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parchment custom encoders #371
base: master
Are you sure you want to change the base?
Parchment custom encoders #371
Conversation
…ncode custom embed blocks
Thank you for this PR @cotw-fabier |
I'm a bit green when it comes to PRs so let me know if you need anything else from me. I'm just busy over here coding :). But I'm happy to help! |
Can you please take care of greening the pipeline? Seems there are some issues with the analyzer |
My bad, Pushed updated version. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #371 +/- ##
==========================================
- Coverage 87.96% 87.87% -0.10%
==========================================
Files 64 65 +1
Lines 10433 10446 +13
==========================================
+ Hits 9177 9179 +2
- Misses 1256 1267 +11 ☔ View full report in Codecov by Sentry. |
@cotw-fabier are you intending to continue working this PR? |
Thanks to your help in #369 I have been steadily working to implement Fleather into an app I am working on. One change which I think was worth pushing upstream to you all is the concept of building custom encoders. I originally wanted to do both encoders and decoders, but I started to run out of steam after finishing the encoders section.
I created a custom class [EncoderExtension] which encapsulates a function that both the HTML and Markdown encoder were updated to make use of. This allows you to convert custom [EmbeddableObject]s into basically any string you want using the fields in the EmbeddableObject.
I put together a pretty feature complete example which you can see in the parchment examples folder.
So my Youtube custom embed (in the example) which displays beautifully in the editor now will also be exportable into both markdown and html in whatever format you desire with whatever code you want to attach to it. Can use this for any custom embed block. This basically makes fleather infinitely extendable by the developers like myself with, hopefully, very little extra overhead.
I know this wasn't a requested feature, so I understand if it isn't something you all would like to make use of, But I feel like this is a fairly minimal expansion to Fleather which won't interrupt the current api in any problematic way so I thought I'd push it up and see if y'all would like to make use of it.
Feel free to adjust in any way you desire!
Example code from
encoder_example.dart
: