FreeChat icon indicating copy to clipboard operation
FreeChat copied to clipboard

Response text should be easily selectable

Open psugihara opened this issue 2 years ago • 5 comments

Currently you can only select text 1 paragraph at a time due to the markdown package we use. This is incredibly annoying! There's an issue tracking that here but no line of sight to a solution https://github.com/gonzalezreal/swift-markdown-ui/issues/264

An alternative to get this functionality could be to use libcmark_gfm directly like FSNotes does here then put the resulting HTML in a web view. https://github.com/glushchenko/fsnotes/blob/2d15de3f8148eba312fd3552e86725f264f1497b/FSNotes/Business/Markdown.swift#L13

Maybe there's an even better solution, idk

psugihara avatar Oct 17 '23 19:10 psugihara

I know Markdown is a very common thing with it's simple formatting, and looks nice on a screen. But as a writer or just doing research, it would be great to just have plain text; no formatting and no bulleted/numbered lists ... it becomes a tedious editing step after doing a copy/paste into Sublime, Textedit, or Google Docs. Maybe a user selectable on/off option for Markdown would be great.

cleesmith avatar Nov 30 '23 12:11 cleesmith

Good suggestion @cleesmith, thanks. Let's definitely implement that! A checkbox in Settings would be a good way to handle it.

psugihara avatar Nov 30 '23 15:11 psugihara

just have plain text

hey @cleesmith... small clarification. Is your request to see the output as plaintext (e.g. unrendered markdown)? That's what I originally thought you were asking for, but note that it would still include numbered lists, etc. To get it to have a different format you'd need to ask the model (either through the system prompt or your chat). The default system prompt includes a request for markdown, so take that out if you don't want it.

Here's an example of what that would look like (unrendered markdown). Screenshot 2023-11-30 at 11 37 55 AM

psugihara avatar Nov 30 '23 19:11 psugihara

~~I've started my own OS MacOS chat client and am forking FreeChat to get the job done. This issue really bugged me, so I spent some time looking for a solution. Markdown rendering solutions for MacOS swift UI are not that great, but @psugihara's webview suggestion seems to be pretty workable. I have a small writeup with my findings.~~

~~Summarised, I use Ink to parse markdown into HTML and render it into a custom WKWebView, which autosizes itself based on the content inside. Scroll events are passed on to the next responder to prevent the WKWebView from consuming them.~~

~~The result is a pretty fast MD renderer with reasonable default styling, good customisability and most importantly, freely selectable text.~~

WKWebView didn't work out so well. This was my solution after some wrangling.

finallyblueskies avatar Apr 10 '24 02:04 finallyblueskies

Good to know it worked. Happy for any contribution back if the component is portable.

psugihara avatar Apr 10 '24 05:04 psugihara