You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API.plugins.md
+12-81Lines changed: 12 additions & 81 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,12 @@
1
-
# OpenSCD core API
1
+
# OpenSCD core API for plugins
2
2
3
3
## Overview
4
4
5
5
**OpenSCD** is a plugin-based editor for editing XML files in the IEC 61850-6 "SCL" dialect directly in the browser.
6
6
7
7
**OpenSCD core** is the central supervisory component which coordinates the work of all the plugins, allowing them to work together in editing the same SCL document.
8
8
9
-
An **OpenSCD plugin** is a [JavaScript module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) which exports a particular [custom element class](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#implementing_a_custom_element) as its [default export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#default_exports_versus_named_exports). OpenSCD core imports the module, registers its custom element under a uniquely generated tag name, and finally renders a new element with that tag name into the app.
10
-
11
-
An **OpenSCD menu plugin** is an OpenSCD plugin with an additional `run()` instance method which is called when the plugin's entry is clicked in OpenSCD's menu. It is continuously rendered into the app and is expected to normally not display any content of its own. It is meant for one-shot editing tasks or tasks that always run in the background (like validation).
12
-
13
-
An **OpenSCD editor plugin** is a OpenSCD plugin that is only rendered as long as the user has its tab selected in OpenSCD's tab bar. It is meant for rendering the main part of OpenSCD's user interface.
9
+
An **OpenSCD plugin** is a [custom element](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#implementing_a_custom_element) that has been registered in the global [`customElements`](https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements) registry under some tag name. OpenSCD core renders an element with that tag name into the app. The component may optionally provide a `run()` method for OpenSCD core to call in order to trigger an action.
14
10
15
11
The **OpenSCD core API** describes the ways in which:
16
12
- OpenSCD core communicates relevant data to the plugins,
@@ -24,42 +20,15 @@ OpenSCD core communicates the data necessary for editing SCL documents by settin
24
20
25
21
```typescript
26
22
exportdefaultclassMyPluginextendsHTMLElement {
27
-
docs:Record<string, XMLDocument> = {};
28
-
doc?:XMLDocument;
29
-
docName?:string;
30
-
editable:string[] = [
31
-
'cid',
32
-
'icd',
33
-
'iid',
34
-
'scd',
35
-
'sed',
36
-
'ssd',
37
-
];
38
-
history:LogEntry[];
39
-
editCount:number=0;
40
-
plugins: { menu:Plugin[], editor:Plugin[] }[];
41
-
locale:string='en';
42
-
}
43
-
44
-
/** Helper types exported by OpenSCD core **/
45
-
46
-
typeLogEntry= {
47
-
redo:Edit; // `Edit` defined below
48
-
undo:Edit;
49
-
title?:string
50
-
}
51
-
52
-
typePlugin= {
53
-
name:string;
54
-
translations?:Record<string, string>;
55
-
src:string;
56
-
icon:string; // Material icon name or image URL
57
-
requireDoc?:boolean; // disable plugin if no doc is opened
23
+
docs:Record<string, XMLDocument> = {}; // all loaded documents
24
+
doc?:XMLDocument; // the document currently being edited
25
+
docName?:string; // the current doc's name
26
+
docVersion:unknown; // current doc's state indicator
27
+
locale:string='en'; // the end user's chosen locale
58
28
}
59
29
```
60
30
61
31
### `docs`
62
-
63
32
`docs` is set to an object mapping `string` keys (document names) to `XMLDocument` values.
64
33
65
34
### `docName`
@@ -68,22 +37,10 @@ The name of the `XMLDocument` currently being edited.
68
37
### `doc`
69
38
The `XMLDocument` currently being edited.
70
39
71
-
### `editable`
72
-
Filename extensions of user-editable documents.
73
-
74
-
### `history`
75
-
History of edits done to `doc`.
76
-
77
40
### `docVersion`
78
-
79
-
A change in the property indicates a change to the `doc` as a result of edits (including undo and redo).
80
-
81
-
### `plugins`
82
-
83
-
Arrays of `Plugin` objects describing the currently loaded `menu` and `editor` plugins, respectively.
41
+
A change in this property's value indicates a change to the `doc`.
84
42
85
43
### `locale`
86
-
87
44
Selected language (IETF language tag).
88
45
89
46
## Communicating user intent to OpenSCD core
@@ -123,16 +80,15 @@ declare global {
123
80
}
124
81
```
125
82
126
-
Its `title` property is a human-readable description of the edit for displaying in the editing history dialog.
83
+
Its `title` property is a human-readable description of the edit.
127
84
128
85
The `squash` flag indicates whether the edit should be merged with the previous edit in the history.
129
86
130
87
#### `Edit` type
131
-
132
88
The `EditDetailV2` defined above contains an `edit` of this type:
The combination of `name` and `kind` uniquely identifies the plugin to be configured. If `config` is `null`, the plugin is removed. Otherwise, the plugin is added or reconfigured.
303
-
304
236
## Theming
305
237
306
238
OpenSCD core sets the following CSS variables on the plugin:
@@ -321,8 +253,7 @@ OpenSCD core sets the following CSS variables on the plugin:
It is expected that the fonts `--oscd-theme-text-font` and `--oscd-theme-icon-font` will be loaded in OpenSCD's `index.html` file. OpenSCD core does not load any fonts by itself.
0 commit comments