@@ -41,6 +41,7 @@ import {
41
41
} from '@openscd/open-scd/src/plugin.events.js' ;
42
42
import { newLogEvent } from '@openscd/core/foundation/deprecated/history.js' ;
43
43
import packageJson from '../package.json' ;
44
+ import { CompasSclDataService } from './compas-services/CompasSclDataService.js' ;
44
45
45
46
/** The `<open-scd>` custom element is the main entry point of the
46
47
* Open Substation Configuration Designer. */
@@ -90,13 +91,6 @@ export class OpenSCD extends LitElement {
90
91
/** The UUID of the current [[`doc`]] */
91
92
@property ( { type : String } ) docId = '' ;
92
93
93
- @state ( )
94
- historyState : HistoryState = {
95
- editCount : - 1 ,
96
- canRedo : false ,
97
- canUndo : false ,
98
- } ;
99
-
100
94
/** Object containing all *.nsdoc files and a function extracting element's label form them*/
101
95
@property ( { attribute : false } )
102
96
nsdoc : Nsdoc = initializeNsdoc ( ) ;
@@ -112,6 +106,13 @@ export class OpenSCD extends LitElement {
112
106
this . dispatchEvent ( newPendingStateEvent ( this . loadDoc ( value ) ) ) ;
113
107
}
114
108
109
+ @state ( )
110
+ historyState : HistoryState = {
111
+ editCount : - 1 ,
112
+ canRedo : false ,
113
+ canUndo : false ,
114
+ } ;
115
+
115
116
@state ( ) private storedPlugins : Plugin [ ] = [ ] ;
116
117
117
118
/** Loads and parses an `XMLDocument` after [[`src`]] has changed. */
@@ -127,6 +128,18 @@ export class OpenSCD extends LitElement {
127
128
if ( src . startsWith ( 'blob:' ) ) URL . revokeObjectURL ( src ) ;
128
129
}
129
130
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
+
130
143
/**
131
144
*
132
145
* @deprecated Use `handleConfigurationPluginEvent` instead
@@ -434,6 +447,7 @@ export class OpenSCD extends LitElement {
434
447
validator : plugin . kind === 'validator' ,
435
448
editor : plugin . kind === 'editor' ,
436
449
} ) } "
450
+ @request-libdoc=${ ( e : CustomEvent ) => this . loadLibDoc ( e ) }
437
451
></${ tag } >` ;
438
452
} ,
439
453
} ;
0 commit comments