@@ -41,6 +41,7 @@ import {
4141} from '@openscd/open-scd/src/plugin.events.js' ;
4242import { newLogEvent } from '@openscd/core/foundation/deprecated/history.js' ;
4343import packageJson from '../package.json' ;
44+ import { CompasSclDataService } from './compas-services/CompasSclDataService.js' ;
4445
4546/** The `<open-scd>` custom element is the main entry point of the
4647 * Open Substation Configuration Designer. */
@@ -90,13 +91,6 @@ export class OpenSCD extends LitElement {
9091 /** The UUID of the current [[`doc`]] */
9192 @property ( { type : String } ) docId = '' ;
9293
93- @state ( )
94- historyState : HistoryState = {
95- editCount : - 1 ,
96- canRedo : false ,
97- canUndo : false ,
98- } ;
99-
10094 /** Object containing all *.nsdoc files and a function extracting element's label form them*/
10195 @property ( { attribute : false } )
10296 nsdoc : Nsdoc = initializeNsdoc ( ) ;
@@ -112,6 +106,13 @@ export class OpenSCD extends LitElement {
112106 this . dispatchEvent ( newPendingStateEvent ( this . loadDoc ( value ) ) ) ;
113107 }
114108
109+ @state ( )
110+ historyState : HistoryState = {
111+ editCount : - 1 ,
112+ canRedo : false ,
113+ canUndo : false ,
114+ } ;
115+
115116 @state ( ) private storedPlugins : Plugin [ ] = [ ] ;
116117
117118 /** Loads and parses an `XMLDocument` after [[`src`]] has changed. */
@@ -127,6 +128,18 @@ export class OpenSCD extends LitElement {
127128 if ( src . startsWith ( 'blob:' ) ) URL . revokeObjectURL ( src ) ;
128129 }
129130
131+ /** Loads the LNodeTypeDB.ssd document from the CompasSclDataService */
132+ private async loadLibDoc ( e : CustomEvent ) : Promise < void > {
133+ const doc = await CompasSclDataService ( )
134+ . getSclDocument ( this , 'SSD' , '3942f511-7d87-4482-bff9-056a98c6ce15' )
135+ . catch ( ( ) => null ) ;
136+ if ( doc instanceof Document ) {
137+ e . detail . callback ( doc ) ;
138+ } else {
139+ e . detail . callback ( undefined ) ;
140+ }
141+ }
142+
130143 /**
131144 *
132145 * @deprecated Use `handleConfigurationPluginEvent` instead
@@ -434,6 +447,7 @@ export class OpenSCD extends LitElement {
434447 validator : plugin . kind === 'validator' ,
435448 editor : plugin . kind === 'editor' ,
436449 } ) } "
450+ @request-libdoc=${ ( e : CustomEvent ) => this . loadLibDoc ( e ) }
437451 ></${ tag } >` ;
438452 } ,
439453 } ;
0 commit comments