11import * as vscode from 'vscode' ;
2+ import { DesignerOutlineProvider } from './DesignerOutlineProvider.js' ;
23
34export function getNonce ( ) {
45 let text = '' ;
@@ -11,19 +12,21 @@ export function getNonce() {
1112
1213export class DesignerTextEditor implements vscode . CustomTextEditorProvider {
1314
14- public static register ( context : vscode . ExtensionContext ) : vscode . Disposable {
15- const provider = new DesignerTextEditor ( context ) ;
15+ public static register ( context : vscode . ExtensionContext ) : vscode . Disposable [ ] {
16+ let outlineProvider = new DesignerOutlineProvider ( ) ;
17+ const provider = new DesignerTextEditor ( context , outlineProvider ) ;
1618 const providerRegistration = vscode . window . registerCustomEditorProvider ( DesignerTextEditor . viewType , provider , {
1719 webviewOptions : {
1820 retainContextWhenHidden : true
1921 }
2022 } ) ;
21- return providerRegistration ;
23+ const outlineRegistration = vscode . window . registerCustomEditorOutlineProvider ( 'designer.visualEditor' , outlineProvider )
24+ return [ providerRegistration , outlineRegistration ] ;
2225 }
2326
2427 private static readonly viewType = 'designer.designerTextEditor' ;
2528
26- constructor ( private readonly context : vscode . ExtensionContext ) { }
29+ constructor ( private readonly context : vscode . ExtensionContext , private readonly outline : DesignerOutlineProvider ) { }
2730
2831 public async addCustomElementsJsons ( webviewPanel : vscode . WebviewPanel ) {
2932 //TODO:
@@ -141,6 +144,32 @@ export class DesignerTextEditor implements vscode.CustomTextEditorProvider {
141144 return ;
142145 }
143146 } ) ;
147+
148+ this . outline . setWebview ( webviewPanel . webview ) ;
149+
150+ // Provide some initial outline items
151+ this . outline . updateItems ( [
152+ {
153+ id : 'root' ,
154+ label : 'Canvas' ,
155+ icon : new vscode . ThemeIcon ( 'layout' ) ,
156+ contextValue : 'canvas' ,
157+ children : [
158+ {
159+ id : 'btn-1' ,
160+ label : 'Button' ,
161+ icon : new vscode . ThemeIcon ( 'symbol-event' ) ,
162+ contextValue : 'widget' ,
163+ } ,
164+ {
165+ id : 'input-1' ,
166+ label : 'Text Input' ,
167+ icon : new vscode . ThemeIcon ( 'symbol-field' ) ,
168+ contextValue : 'widget' ,
169+ } ,
170+ ] ,
171+ } ,
172+ ] ) ;
144173 }
145174
146175 /**
0 commit comments