2026-05-14 12:31:35 +02:00
|
|
|
@page "/editor"
|
|
|
|
|
@page "/editor/{action}"
|
|
|
|
|
@page "/editor/{action}/{projectId:int}"
|
|
|
|
|
@inject IOllamaService OllamaService
|
|
|
|
|
@inject IProjectService ProjectService
|
|
|
|
|
@inject NavigationManager Navigation
|
|
|
|
|
|
|
|
|
|
<PageTitle>Editor - Author Buddy</PageTitle>
|
|
|
|
|
|
|
|
|
|
<div class="editor-container">
|
|
|
|
|
<textarea @bind="editorContent" placeholder="Schreibe hier deinen Text..."></textarea>
|
|
|
|
|
<div class="editor-toolbar">
|
|
|
|
|
<span style="flex: 1; font-size: 12px; color: var(--border-color);">
|
|
|
|
|
@statusText
|
|
|
|
|
</span>
|
|
|
|
|
@if (isChecking)
|
|
|
|
|
{
|
|
|
|
|
<progress value="@checkProgress" max="100"></progress>
|
|
|
|
|
}
|
|
|
|
|
<button @onclick="CheckStyle" disabled="@isChecking">
|
|
|
|
|
Stil prüfen
|
|
|
|
|
</button>
|
|
|
|
|
<button @onclick="SpellCheck" disabled="@isChecking">
|
|
|
|
|
Rechtschreibung prüfen
|
|
|
|
|
</button>
|
|
|
|
|
<button @onclick="RagSearch">
|
|
|
|
|
Fakten suchen (RAG)
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-17 07:27:18 +02:00
|
|
|
@if (showSpellDiff && !string.IsNullOrEmpty(correctedText))
|
2026-05-14 12:31:35 +02:00
|
|
|
{
|
2026-05-17 07:27:18 +02:00
|
|
|
<div class="diff-panel">
|
|
|
|
|
<h4>Rechtschreibprüfung - Änderungen:</h4>
|
|
|
|
|
<DiffView Original="@originalText" Corrected="@correctedText" />
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(analysisResult))
|
|
|
|
|
{
|
|
|
|
|
<div class="result-panel">
|
|
|
|
|
<h4>Ergebnis:</h4>
|
|
|
|
|
<div class="result-text">@analysisResult</div>
|
2026-05-14 12:31:35 +02:00
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter]
|
|
|
|
|
public string? Action { get; set; }
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public int? ProjectId { get; set; }
|
|
|
|
|
|
|
|
|
|
private string editorContent = string.Empty;
|
|
|
|
|
private string statusText = "Bereit";
|
|
|
|
|
private bool isChecking;
|
|
|
|
|
private double checkProgress;
|
|
|
|
|
private string analysisResult = string.Empty;
|
2026-05-17 07:27:18 +02:00
|
|
|
private string originalText = string.Empty;
|
|
|
|
|
private string correctedText = string.Empty;
|
|
|
|
|
private bool showSpellDiff;
|
2026-05-14 12:31:35 +02:00
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
if (Action == "newproject")
|
|
|
|
|
{
|
|
|
|
|
statusText = "Bitte nutze die Einstellungen zum Erstellen eines neuen Projekts.";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task CheckStyle()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(editorContent)) return;
|
|
|
|
|
|
|
|
|
|
isChecking = true;
|
|
|
|
|
statusText = "Ollama analysiert Stil...";
|
|
|
|
|
checkProgress = 50;
|
2026-05-17 07:27:18 +02:00
|
|
|
showSpellDiff = false;
|
2026-05-14 12:31:35 +02:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-05-16 16:13:35 +02:00
|
|
|
//analysisResult = await OllamaService.StreamStyleCheckAsync(editorContent);
|
2026-05-14 12:31:35 +02:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
analysisResult = $"Fehler: {ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
statusText = "Bereit";
|
|
|
|
|
isChecking = false;
|
|
|
|
|
checkProgress = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task SpellCheck()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(editorContent)) return;
|
|
|
|
|
|
|
|
|
|
isChecking = true;
|
|
|
|
|
statusText = "Ollama prüft Rechtschreibung...";
|
|
|
|
|
checkProgress = 50;
|
2026-05-17 07:27:18 +02:00
|
|
|
showSpellDiff = false;
|
2026-05-14 12:31:35 +02:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2026-05-17 07:27:18 +02:00
|
|
|
originalText = editorContent;
|
|
|
|
|
correctedText = await OllamaService.QuickSpellCheckAsync(editorContent);
|
|
|
|
|
showSpellDiff = true;
|
2026-05-14 12:31:35 +02:00
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
analysisResult = $"Fehler: {ex.Message}";
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
statusText = "Bereit";
|
|
|
|
|
isChecking = false;
|
|
|
|
|
checkProgress = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task RagSearch()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(editorContent)) return;
|
|
|
|
|
|
|
|
|
|
isChecking = true;
|
|
|
|
|
statusText = "Suche verwandte Fakten...";
|
2026-05-17 07:27:18 +02:00
|
|
|
showSpellDiff = false;
|
2026-05-14 12:31:35 +02:00
|
|
|
|
|
|
|
|
await Task.Delay(500);
|
|
|
|
|
analysisResult = "RAG-Suche: Stelle sicher, dass ein Projekt geladen und indexiert wurde.";
|
|
|
|
|
statusText = "Bereit";
|
|
|
|
|
isChecking = false;
|
|
|
|
|
}
|
|
|
|
|
}
|