| | 1 | | <div class="container"> |
| | 2 | |
|
| | 3 | | <div class="row"> |
| | 4 | | <div class="col"> |
| | 5 | | <div style="margin:10px 0;"> |
| | 6 | | Theme: |
| | 7 | | <select id="theme" @onchange="ChangeTheme"> |
| | 8 | | <option value="vs">Visual Studio</option> |
| | 9 | | <option value="vs-dark">Visual Studio Dark</option> |
| | 10 | | <option value="hc-black">High Contrast Black</option> |
| | 11 | | </select> |
| | 12 | | </div> |
| | 13 | | </div> |
| | 14 | | </div> |
| | 15 | |
|
| | 16 | | <div class="row"> |
| | 17 | | <div class="col"> |
| | 18 | | <p>⚠️ <strong>WIP</strong></p> |
| | 19 | | </div> |
| | 20 | | </div> |
| | 21 | |
|
| | 22 | | <div class="row"> |
| | 23 | | <div class="col"> |
| | 24 | | <p><strong>Language:</strong> @Language</p> |
| | 25 | | </div> |
| | 26 | | </div> |
| | 27 | |
|
| | 28 | | <div class="row"> |
| | 29 | | <div class="col"> |
| | 30 | | <StandaloneDiffEditor |
| | 31 | | Id="diff-editor" |
| | 32 | | ConstructionOptions="DiffEditorConstructionOptions" |
| | 33 | | OnKeyUpOriginal="OnKeyUpOriginal" |
| | 34 | | OnKeyUpModified="OnKeyUpModified" |
| 0 | 35 | | @ref="_diffEditor" |
| 0 | 36 | | /> |
| 0 | 37 | | @* OnDidInit="EditorOnDidInit" *@ |
| 0 | 38 | | </div> |
| 0 | 39 | | </div> |
| 0 | 40 | | </div> |
| | 41 | |
|
| | 42 | | @code { |
| | 43 | |
|
| 0 | 44 | | [Parameter] public string Language { get; set; } = "javascript"; |
| | 45 | |
|
| 0 | 46 | | [Parameter] public string Original { get; set; } |
| | 47 | |
|
| 0 | 48 | | [Parameter] public string Modified { get; set; } |
| | 49 | |
|
| 0 | 50 | | private StandaloneDiffEditor _diffEditor = null!; |
| | 51 | |
|
| | 52 | | private StandaloneDiffEditorConstructionOptions DiffEditorConstructionOptions(StandaloneDiffEditor editor) |
| 0 | 53 | | { |
| 0 | 54 | | return new StandaloneDiffEditorConstructionOptions |
| 0 | 55 | | { |
| 0 | 56 | | OriginalEditable = true |
| 0 | 57 | | }; |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | protected override async Task OnAfterRenderAsync(bool firstRender) |
| 0 | 61 | | { |
| | 62 | | try |
| 0 | 63 | | { |
| 0 | 64 | | await _diffEditor.SetModel(new DiffEditorModel() |
| 0 | 65 | | { |
| 0 | 66 | | Original = await Global.CreateModel(Original, Language), |
| 0 | 67 | | Modified = await Global.CreateModel(Modified, Language) |
| 0 | 68 | | }); |
| 0 | 69 | | } |
| 0 | 70 | | catch (JSException) |
| 0 | 71 | | { |
| 0 | 72 | | } |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | // private async Task EditorOnDidInit() |
| | 76 | | // { |
| | 77 | | // |
| | 78 | | // } |
| | 79 | |
|
| | 80 | | private void OnKeyUpOriginal(KeyboardEvent keyboardEvent) |
| 0 | 81 | | { |
| 0 | 82 | | Console.WriteLine("OnKeyUpOriginal : " + keyboardEvent.Code); |
| 0 | 83 | | } |
| | 84 | |
|
| | 85 | | private void OnKeyUpModified(KeyboardEvent keyboardEvent) |
| 0 | 86 | | { |
| 0 | 87 | | Console.WriteLine("OnKeyUpModified : " + keyboardEvent.Code); |
| 0 | 88 | | } |
| | 89 | |
|
| | 90 | | private async Task ChangeTheme(ChangeEventArgs e) |
| 0 | 91 | | { |
| 0 | 92 | | Console.WriteLine($"setting theme to: {e.Value?.ToString()}"); |
| 0 | 93 | | await Global.SetTheme(e.Value?.ToString()); |
| 0 | 94 | | } |
| | 95 | | } |