From ad526600b27dfbccf28dbb000c137eaba9b977b6 Mon Sep 17 00:00:00 2001 From: nojaf Date: Mon, 15 Apr 2024 11:07:55 +0200 Subject: [PATCH] Add static setters to KernelExtension. --- .../KernelExtension.fs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/XPlot.Plotly.Interactive/KernelExtension.fs b/src/XPlot.Plotly.Interactive/KernelExtension.fs index ce963ef3..f32868fe 100644 --- a/src/XPlot.Plotly.Interactive/KernelExtension.fs +++ b/src/XPlot.Plotly.Interactive/KernelExtension.fs @@ -19,18 +19,20 @@ open Giraffe.ViewEngine open XPlot.Plotly.Interactive.PowerShell.Commands type KernelExtension() = + static let mutable PlotlyUrl = "https://cdn.plot.ly/plotly-1.49.2.min" + static let mutable RequireJsUrl = "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" let getScriptElementWithRequire (script: string) = let newScript = StringBuilder() newScript.AppendLine("""") |> ignore newScript.ToString() @@ -70,6 +72,12 @@ var renderPlotly = function() { registerPowerShellAccelerators() registerPowerShellModule() + /// Override the Plotly cdn url value used in all KernelExtensions. + static member SetPlotlyUrl(url: string) = PlotlyUrl <- url + + /// Override the RequireJS cdn url value used in all KernelExtensions. + static member SetRequireJsUrl(url: string) = RequireJsUrl <- url + interface IKernelExtension with member _.OnLoadAsync kernel = registerPlotlyFormatters()