Extend XtermBlazor to load addons

This commit is contained in:
Pat Hartl 2026-01-03 18:27:26 -06:00
parent e85eeb01db
commit 9b515623df
2 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,19 @@
using LANCommander.UI.Extensions;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using XtermBlazor;
namespace LANCommander.UI.Components;
public partial class Terminal : Xterm
{
[Inject]
IJSRuntime JS { get; set; }
protected override async Task OnInitializedAsync()
{
await JS.ExecuteVoidAsync("RegisterXtermAddons");
await base.OnInitializedAsync();
}
}

View file

@ -0,0 +1,9 @@
import { Readline } from "xterm-readline"
import { FitAddon } from "@xterm/addon-fit"
export function RegisterXtermAddons() {
(<any>window).XtermBlazor.registerAddons({
"readline": new Readline(),
"addon-fit": new FitAddon(),
});
}