diff --git a/src/SharpIDE.Photino/Components/CodeViewer.razor b/src/SharpIDE.Photino/Components/CodeViewer.razor index 9932c86..2df6ac9 100644 --- a/src/SharpIDE.Photino/Components/CodeViewer.razor +++ b/src/SharpIDE.Photino/Components/CodeViewer.razor @@ -1,16 +1,23 @@ - + + @Path.GetFileName(FilePath) + @if (_unsavedEdits) + { + * + } + - + @code { [Parameter, EditorRequired] public string FilePath { get; set; } = null!; private string? _fileContent; + private bool _unsavedEdits = false; private StandaloneEditorConstructionOptions EditorConstructionOptions(StandaloneCodeEditor editor) { @@ -36,4 +43,17 @@ _fileContent = fileContent; } + private async Task SaveFileToDisk(object obj) + { + if (_unsavedEdits is false) + { + return; + } + var editor = obj as StandaloneCodeEditor; + ArgumentNullException.ThrowIfNull(editor, nameof(editor)); + var editorTextValue = await editor.GetValue(); + await File.WriteAllTextAsync(FilePath, editorTextValue); + _unsavedEdits = false; + } + }