mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-10 20:27:21 +00:00
Highlighted code blocks inside the app (#1153)
This commit is contained in:
1 parent
0b42c0288e
commit
f4a86c2fb8
60 files changed
+2550
-41
No files matched your search
@@ -4,14 +4,14 @@ using Microsoft.AspNetCore.Components.Rendering;
|
||||
namespace AIStudio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Renders Markdown the way MudMarkdown does, and shows actions next to every code block which is
|
||||
/// one of the files of its message, such as a button to save that block.
|
||||
/// Renders Markdown the way HighlightedMarkdown does, and shows actions next to every code block which
|
||||
/// is one of the files of its message, such as a button to save that block.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In a long answer, the export menu at the top of the message lies far away from the code block
|
||||
/// the user is reading. MudMarkdown renders every code block through RenderCodeBlock, the highlighted
|
||||
/// code together with its copy button, and lets us override that. We wrap what it renders and put our
|
||||
/// actions beside it, so the copy button stays exactly as the library made it.
|
||||
/// code together with its copy button, and lets us override that. We wrap what HighlightedMarkdown
|
||||
/// renders and put our actions beside it, so the copy button stays exactly as it was made.
|
||||
///
|
||||
/// A block finds its file by where it starts. The chat renders an answer in parts, cut around its
|
||||
/// formulas, and Markdig reads each part on its own: a block knows where it starts within its part
|
||||
@@ -19,7 +19,7 @@ namespace AIStudio.Components;
|
||||
/// A block without a file, such as a formula or a block the model never closed, gets no actions,
|
||||
/// just as the export menu does not offer it.
|
||||
/// </remarks>
|
||||
public sealed class ExportableMarkdown : MudMarkdown
|
||||
public sealed class ExportableMarkdown : HighlightedMarkdown
|
||||
{
|
||||
/// <summary>
|
||||
/// The files of the message, as PlainFileExport.ExtractFiles read them out of its text. Without
|
||||
@@ -48,7 +48,7 @@ public sealed class ExportableMarkdown : MudMarkdown
|
||||
/// <returns>The file, or null when no file starts there.</returns>
|
||||
internal static MessageFile? FileAt(IReadOnlyList<MessageFile> files, int position) => files.FirstOrDefault(file => file.Position == position);
|
||||
|
||||
#region Overrides of MudMarkdown
|
||||
#region Overrides of HighlightedMarkdown
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info)
|
||||
|
||||
Reference in new issue
Block a user