Compare commits

..

No commits in common. "6d5b4a33b951b045d4b8ccf48961c906c86da3a1" and "735fbfb83dc59c085df176cdb954254b4c167835" have entirely different histories.

7 changed files with 35 additions and 142 deletions

View File

@ -1,32 +0,0 @@
<UserControl x:Class="EleCho.MdViewer.Controls.CodeSpanControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:EleCho.MdViewer.Controls"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="160">
<StackPanel Orientation="Horizontal" Margin="5">
<local:SelectableTextBlock Text="{Binding Text}" VerticalAlignment="Center"/>
<Button x:Name="Copy"
Content="复制"
Click="Copy_Click"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Padding="4,0"
Opacity="1"
Height="20"
Background="#AAFFFFFF"
BorderThickness="1">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="True">
<Setter Property="Opacity" Value="0.8"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
</UserControl>

View File

@ -1,51 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace EleCho.MdViewer.Controls
{
/// <summary>
/// CodeSpanControl.xaml 的交互逻辑
/// </summary>
public partial class CodeSpanControl : UserControl
{
/// <summary>
/// Text
/// </summary>
public string Text
{
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
/// <summary>
/// Text property
/// </summary>
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(CodeSpanControl), new PropertyMetadata(string.Empty));
public CodeSpanControl()
{
InitializeComponent();
this.DataContext = this;
}
private void Copy_Click(object sender, RoutedEventArgs e)
{
}
}
}

View File

@ -428,49 +428,38 @@ public class MarkdownWpfRenderer
CornerRadius = new CornerRadius(8), CornerRadius = new CornerRadius(8),
Margin = new Thickness(0, 0, 0, NormalSize) Margin = new Thickness(0, 0, 0, NormalSize)
}; };
if (!fencedCodeBlock.Info.StartsWith("Excel", StringComparison.CurrentCultureIgnoreCase))
var codeContentElement = new SelectableTextBlock()
{ {
var codeContentElement = new SelectableTextBlock() TextWrapping = TextWrapping.Wrap,
{ Padding = new Thickness(NormalSize / 2),
TextWrapping = TextWrapping.Wrap,
Padding = new Thickness(NormalSize / 2),
FontSize = NormalSize, FontSize = NormalSize,
FontFamily = GetCodeTextFontFamily(), FontFamily = GetCodeTextFontFamily(),
}; };
codeElement.Child = codeElement.Child =
codeContentElement; codeContentElement;
codeElement.BindCodeBlockBackground(); codeElement.BindCodeBlockBackground();
codeContentElement.BindCodeBlockForeground(); codeContentElement.BindCodeBlockForeground();
var language = ColorCode.Languages.FindById(fencedCodeBlock.Info); var language = ColorCode.Languages.FindById(fencedCodeBlock.Info);
/*StyleDictionary styleDict = ColorMode switch /*StyleDictionary styleDict = ColorMode switch
{
ColorMode.Light => StyleDictionary.DefaultLight,
ColorMode.Dark => StyleDictionary.DefaultDark,
_ => StyleDictionary.DefaultLight
};*/
StyleDictionary styleDict = StyleDictionary.DefaultDark;
WpfSyntaxHighLighting writer = new(styleDict);
writer.FormatTextBlock(fencedCodeBlock.Lines.ToString(), language, codeContentElement);
}
else
{ {
var codeSpanControl = new CodeSpanControl(); ColorMode.Light => StyleDictionary.DefaultLight,
codeSpanControl.SetResourceReference(Control.ForegroundProperty, MarkdownResKey.MainForeground); ColorMode.Dark => StyleDictionary.DefaultDark,
codeSpanControl.SetResourceReference(Control.BackgroundProperty, MarkdownResKey.CodeBlockBackground);
codeSpanControl.Text = fencedCodeBlock.Lines.ToString(); _ => StyleDictionary.DefaultLight
codeElement.Child = codeSpanControl; };*/
} StyleDictionary styleDict = StyleDictionary.DefaultDark;
WpfSyntaxHighLighting writer = new(styleDict);
writer.FormatTextBlock(fencedCodeBlock.Lines.ToString(), language, codeContentElement);
return codeElement; return codeElement;
} }
public FrameworkElement RenderCodeBlock(CodeBlock codeBlock, CancellationToken cancellationToken) public FrameworkElement RenderCodeBlock(CodeBlock codeBlock, CancellationToken cancellationToken)
@ -577,7 +566,7 @@ public class MarkdownWpfRenderer
SelectableTextBlock paragraphElement = new SelectableTextBlock() SelectableTextBlock paragraphElement = new SelectableTextBlock()
{ {
TextWrapping = TextWrapping.Wrap, TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(0, NormalSize, 0, NormalSize), Margin = new Thickness(0, 0, 0, NormalSize),
FontSize = NormalSize, FontSize = NormalSize,
}; };

View File

@ -48,9 +48,7 @@ class PromptUtil
4. 4.
5. 使 5. 使
6. 使
```Excel_{{}}
=SUM(A1:A100)
"; ";
} }

View File

@ -23,12 +23,6 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets> <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<OptimizationPreference>Size</OptimizationPreference> <OptimizationPreference>Size</OptimizationPreference>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="Web\**" />
<EmbeddedResource Remove="Web\**" />
<None Remove="Web\**" />
<Page Remove="Web\**" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="HL\SQL.xshd" /> <None Remove="HL\SQL.xshd" />
</ItemGroup> </ItemGroup>
@ -75,6 +69,9 @@
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.2.24473.5" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.2.24473.5" />
<PackageReference Include="TinyPinyin" Version="1.1.0" /> <PackageReference Include="TinyPinyin" Version="1.1.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Web\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\EleCho.MdViewer\src\EleCho.MdViewer\EleCho.MdViewer.csproj" /> <ProjectReference Include="..\EleCho.MdViewer\src\EleCho.MdViewer\EleCho.MdViewer.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -14,7 +14,7 @@ public class Excel2Prompt
/// <param name="columns"></param> /// <param name="columns"></param>
/// <param name="startCell">A</param> /// <param name="startCell">A</param>
/// <returns></returns> /// <returns></returns>
public static string ConverterToPrompt(IEnumerable<dynamic> excelData, Dictionary<string, string> columns, string startCell,string sheetName) public static string ConverterToPrompt(IEnumerable<dynamic> excelData, Dictionary<string,string> columns, string startCell)
{ {
/* /*
: :
@ -37,7 +37,7 @@ public class Excel2Prompt
- Missing values: 7007 - Missing values: 7007
*/ */
var prompts = new List<string>(); var prompts = new List<string>();
prompts.Add($"This Excel file contains the following columns:"); prompts.Add("This Excel file contains the following columns:");
var dataList = excelData.ToList(); var dataList = excelData.ToList();
// 解析 startCell获取起始列的索引 // 解析 startCell获取起始列的索引
@ -70,8 +70,6 @@ public class Excel2Prompt
$" - Sample values: ['{string.Join("', '", sampleValues)}']"; $" - Sample values: ['{string.Join("', '", sampleValues)}']";
prompts.Add(prompt); prompts.Add(prompt);
} }
prompts.Add($"Sheet Name: {sheetName}");
prompts.Add($"Max Row: {excelData.Count()}");
return string.Join(Environment.NewLine + Environment.NewLine, prompts); return string.Join(Environment.NewLine + Environment.NewLine, prompts);
} }

View File

@ -179,7 +179,7 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
MaxRow = ExcelData.Count(); MaxRow = ExcelData.Count();
ExcelPromptString = Excel2Prompt.ConverterToPrompt(excelData, _columnMappings, StartCell,currentSheetName); ExcelPromptString = Excel2Prompt.ConverterToPrompt(ExcelData, _columnMappings, StartCell);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -347,16 +347,10 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
} }
private static string TEST_AI_CONTENT = @" private const string TEST_AI_CONTENT = @"
```Excel_H <think>
1231231122222222222222222222 1231231
123 </think>
1
23
12
3
12
```
"; ";
#region Props #region Props
[ObservableProperty] [ObservableProperty]