Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Allow for structured message responses

Open fozziethebeat opened this issue 2 years ago • 11 comments

Right now the message textarea just creates a flat response. When writing code or formatted responses, we want to preserve that structure.

This probably could switch the textarea to a Markdown editor that creates structured markdown (with code blocks).

fozziethebeat avatar Jan 19 '23 06:01 fozziethebeat

https://uiwjs.github.io/react-md-editor/

https://github.com/HarryChen0506/react-markdown-editor-lite

If using markdown, we have to be VERY CAREFUL because of XSS

AbdBarho avatar Jan 20 '23 10:01 AbdBarho

Ah yes XSS opportunities. I see there's sanitizers that should be a good first layer of protection.

fozziethebeat avatar Jan 20 '23 12:01 fozziethebeat

https://github.com/remarkjs/react-markdown

This one says its "safe by default"

jojopirker avatar Jan 20 '23 15:01 jojopirker

Would second on react-markdown with appropriate plugins.

rjmacarthy avatar Jan 21 '23 21:01 rjmacarthy

I've used react-markdown as well a few times. Worked smoothly.

fozziethebeat avatar Jan 22 '23 00:01 fozziethebeat

Hey, @fozziethebeat, I have previously worked with react-markdown and would like to build this feature. Before that, can you share a screenshot of where you want markdown rendering?

KarthikRaju391 avatar Jan 22 '23 07:01 KarthikRaju391

First step is to render text using Markdown rendering during the review and messages phase.

Second, make the text editor easier to use and support previewing the markdown before submitting.

Will post some images about where this should go soon.

fozziethebeat avatar Jan 24 '23 06:01 fozziethebeat

I can take a look at this today. Feel free to assign me. The plan is to use react-markdown with plugins for syntax highlighting of coding languages and possibly even remark-math (also a plugin I think) for math figures. I'll follow @fozziethebeat's first step and work on getting a markdown rendering of messages and during the preview phase before submission for replies/prompts.

Something like https://uiwjs.github.io/react-markdown-editor/ might be useful once we wish to move to an interactive editor.

mashdragon avatar Feb 08 '23 01:02 mashdragon

Assigning to @mashdragon to give it a whirl

fozziethebeat avatar Feb 08 '23 05:02 fozziethebeat

It would be great if you can make the component render lazily, react-markdown + syntax highlighting is ~200kb when gziped, which basically doubles our bundle size & loading times.

AbdBarho avatar Feb 08 '23 17:02 AbdBarho

It would be great if you can make the component render lazily, react-markdown + syntax highlighting is ~200kb when gziped, which basically doubles our bundle size & loading times.

Ok, I have implemented lazy loading with dd119f7. The raw message is displayed before the content is rendered so the space taken up doesn't change as much when it loads.

I need some help with the lack of styling on many HTML elements, so if you can, please connect someone who knows how the website styling works.

mashdragon avatar Feb 09 '23 02:02 mashdragon