You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My use case is I make heavy use of Markdown widgets to display output from LLM agents. When the user clicks on the widget, I copy the text in the widget to the clipboard to allow it to be pasted elsewhere. This works well, but is problematic when I only want to grab a code block, not the surrounding commentary.
New Goal
I'm trying to make this smarter and to detect if within the Markdown widget, they clicked within a inline code block and if so, only copy the text of the code block. I looking for help with good strategies to accomplish this.
From the Textual code, I see that the Markdown widget will use an internal MarkdownFence widget which contains the code block. What might be a good approach? I'm thinking of:
registering an on_click message for MarkdownFence; this seems easiest but since this widget type is private to Markdown, seems like it would be a fragile solution
get the x,y coordinates from the mouse click and traverse down the widget children and see if I can locate the right widget (content_region attribute?) - this also seems feasible but a bit more complicated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
My use case is I make heavy use of Markdown widgets to display output from LLM agents. When the user clicks on the widget, I copy the text in the widget to the clipboard to allow it to be pasted elsewhere. This works well, but is problematic when I only want to grab a code block, not the surrounding commentary.
New Goal
I'm trying to make this smarter and to detect if within the Markdown widget, they clicked within a
inline code block
and if so, only copy the text of the code block. I looking for help with good strategies to accomplish this.From the Textual code, I see that the Markdown widget will use an internal MarkdownFence widget which contains the code block. What might be a good approach? I'm thinking of:
Better ideas?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions