Skip to content
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

gui: Markdown renderer/chat content display #177

Closed
alexlyp opened this issue Mar 20, 2023 · 2 comments
Closed

gui: Markdown renderer/chat content display #177

alexlyp opened this issue Mar 20, 2023 · 2 comments
Labels
gui Issues pertaining to Bison Relay GUI medium medium priority

Comments

@alexlyp
Copy link
Member

alexlyp commented Mar 20, 2023

Due to the various issues currently open that are due to roughly the same overall issue, I figured I'd open up an issue that would describe the current problems and requirements for a new (or forked) widget.

(Issues that would be fixed: #160, #135)
Currently, we are using the 'official' markdown renderer package flutter_markdown. While this does do a pretty good job at displaying a wide range of content, we're currently experiencing issues with a few different element types within the markdown, namely embeded images, code blocks and quotes. And currently we can't have nice text selection due to an issue with the widget (and roughly described in the opened issue here: flutter/flutter#99819).

My first proposal is to create a parent widget that would still use Markdown below, but would first parse various portions of the text to render and then create a series of widgets to display the content as expected. So for instance if the message/md sent was the following:


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc id ipsum tellus. Sed accumsan lectus diam, ac eleifend metus hendrerit scelerisque. Vivamus eleifend neque vitae cursus gravida. Sed dictum diam quis diam cursus, ut pharetra nunc aliquam. In sed velit a tortor tincidunt scelerisque. Phasellus dignissim at felis id fringilla. Vestibulum efficitur nulla et ex viverra, in tincidunt dolor finibus. Donec vitae dui vel turpis vehicula condimentum sit amet nec mi. Vestibulum et est lorem. Praesent auctor fringilla leo a eleifend. Maecenas rhoncus lacus ut leo vehicula bibendum. Quisque dictum eros vitae est accumsan eleifend. Sed at lorem augue. Morbi cursus massa nisi. Phasellus non nisl eros.

Carl-Aqua-Teen-Hunger-Force

Vestibulum condimentum dolor a libero blandit, tempor venenatis tortor euismod. Donec vitae suscipit sapien. Phasellus quis rhoncus turpis. Nunc laoreet nulla sed facilisis cursus. Ut eu egestas odio, ut vehicula lacus. Mauris tellus velit, tempus vitae euismod id, pharetra sit amet massa. Etiam velit leo, tincidunt nec convallis quis, lacinia at quam. Nulla aliquam volutpat purus id malesuada. In hendrerit sit amet velit at dictum.

Quisque dolor quam, fringilla eu leo sed, molestie lacinia nisl. Quisque porta luctus laoreet. Fusce a ultricies turpis. In placerat augue at tempus vulputate. Donec felis eros, ullamcorper nec fermentum ut, convallis eu lectus. Sed vel ipsum nec odio volutpat aliquam. Praesent sodales urna id mi posuere, quis viverra tellus rutrum. Cras quis condimentum nibh. Praesent et orci sed nisi iaculis accumsan. Quisque congue elementum elit sed sagittis. Morbi semper auctor rhoncus.


This message would then be split up into 4 "different" widgets below that would offer more granularity for things like scroll-downs and correct sizing for images. The parser could find the image, the codeblock and the quote area and handle them individually and then present them all together as a single message for the end user.

This is just a brainstorming activity now to hopefully capture all the limitations of our currently markdown situation.

@tiagoalvesdulce
Copy link
Contributor

We can customize flutter_markdown's MarkdownBody with MarkdownElementBuilders. It doesn't work so nice for nested tags, like <pre><code>some text</code></pre> because we can't pass a MarkdownElementBuilder to both tags without changing the package code. Also, we don't have much control about inline text elements styles, like strikethrough, bold, italic, code, etc. because they are basically TextSpans in a huge Text.rich Widget. That means we can only pass TextStyle styles to them and we can't control some stuff like borders, etc.

That said, I think flutter_markdown with MarkdownElementBuilders and some tweaks to my forked repo is enough for our needs.

@alexlyp alexlyp added the medium medium priority label Jan 18, 2024
@miki-totefu
Copy link
Collaborator

selection works on master
reopen if it breaks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Issues pertaining to Bison Relay GUI medium medium priority
Projects
None yet
Development

No branches or pull requests

3 participants