@@ -14,21 +14,39 @@ import {
1414 WEB_VIEW_NAME ,
1515 WEB_VIEW_TITLE ,
1616} from "../constants" ;
17+ import { ExtensionConfig } from "../helper/extensionConfigs" ;
1718
1819export class MainPanel {
1920 public static currentPanel : MainPanel | undefined ;
2021 private readonly _panel : WebviewPanel ;
22+ public static extensionConfig : ExtensionConfig ;
2123 private _disposables : Disposable [ ] = [ ] ;
2224 // to add debouncing on diagram update after a file change
2325 private _lastTimeout : NodeJS . Timeout | null = null ;
2426
25- private constructor ( panel : WebviewPanel , context : ExtensionContext ) {
27+ private constructor (
28+ panel : WebviewPanel ,
29+ context : ExtensionContext ,
30+ extensionConfigSession : string ,
31+ ) {
2632 this . _panel = panel ;
27-
2833 this . _panel . onDidDispose ( ( ) => this . dispose ( ) , null , this . _disposables ) ;
29- this . _panel . webview . html = WebviewHelper . setupHtml (
34+
35+ const extensionConfig = new ExtensionConfig ( extensionConfigSession ) ;
36+ const defaultPageConfig = extensionConfig . getDefaultPageConfig ( ) ;
37+
38+ const html = WebviewHelper . setupHtml (
3039 this . _panel . webview ,
3140 context ,
41+ defaultPageConfig ,
42+ ) ;
43+
44+ this . _panel . webview . html = html ;
45+
46+ WebviewHelper . setupWebviewHooks (
47+ this . _panel . webview ,
48+ extensionConfig ,
49+ this . _disposables ,
3250 ) ;
3351 }
3452
@@ -51,7 +69,10 @@ export class MainPanel {
5169 MainPanel . currentPanel ?. _disposables . push ( disposable ) ;
5270 }
5371
54- public static render ( context : ExtensionContext ) {
72+ public static render (
73+ context : ExtensionContext ,
74+ extensionConfigSession : string ,
75+ ) {
5576 const editor = window . activeTextEditor ;
5677 if ( ! editor ) {
5778 window . showErrorMessage (
@@ -77,7 +98,11 @@ export class MainPanel {
7798 } ,
7899 ) ;
79100
80- MainPanel . currentPanel = new MainPanel ( panel , context ) ;
101+ MainPanel . currentPanel = new MainPanel (
102+ panel ,
103+ context ,
104+ extensionConfigSession ,
105+ ) ;
81106 MainPanel . registerDiagramUpdaterOnfFileChange ( ) ;
82107 }
83108
0 commit comments