visual-space / visual-editor

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

Embeds - Add support for custom embeds #157

Closed adrian-moisa closed 1 year ago

adrian-moisa commented 1 year ago

Currently the editor supports only image and video embeds. We need to add support for albums. But these albums are custom crafted to fit our app. Therefore we need support for generic custom embeds.

Had a look in the codebase, apparently the embeds are initialised via this line of code unknown-1

If the value of an insert op is string then it inits strings. Otherwise it goes for embeds. It uses the embed builder. Current version uses only 2 embeds: image or video. At the time when I forked apparently the web images were disable even if working... Looks like we can render image embeds just fine. unknown-2

I forked before the custom embeds were added. I looked trough the code that supports embeds, it's not that hard to replicate. Also had a scan trough the code that renders the embeds. The default embed builder is rather straight forward business. unknown-3

The trouble is that it needs a good dose of cleanup (component diagram style). Right now it's all in monolith methods We should deal with that. That's how text_line makes use of the embed builder. unknown-1

Either it renders a one paragraph embed or in mix mode unknown-2

Read this part here unknown-3

Here there's logic for rendering embeds within text lines unknown-1

Obviously we need doc page and tests.

Ref: 877

Join on discord to get advice and help or follow us on YouTube Visual Coding to learn more about the architecture of Visual Editor and other Flutter apps.