Skip to content

Commit e0b440c

Browse files
committed
docs(API): remove plugin management
1 parent 5cf26cb commit e0b440c

File tree

1 file changed

+12
-81
lines changed

1 file changed

+12
-81
lines changed

API.md renamed to docs/API.plugins.md

Lines changed: 12 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
# OpenSCD core API
1+
# OpenSCD core API for plugins
22

33
## Overview
44

55
**OpenSCD** is a plugin-based editor for editing XML files in the IEC 61850-6 "SCL" dialect directly in the browser.
66

77
**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.
88

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.
1410

1511
The **OpenSCD core API** describes the ways in which:
1612
- OpenSCD core communicates relevant data to the plugins,
@@ -24,42 +20,15 @@ OpenSCD core communicates the data necessary for editing SCL documents by settin
2420

2521
```typescript
2622
export default class MyPlugin extends HTMLElement {
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-
type LogEntry = {
47-
redo: Edit; // `Edit` defined below
48-
undo: Edit;
49-
title?: string
50-
}
51-
52-
type Plugin = {
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
5828
}
5929
```
6030

6131
### `docs`
62-
6332
`docs` is set to an object mapping `string` keys (document names) to `XMLDocument` values.
6433

6534
### `docName`
@@ -68,22 +37,10 @@ The name of the `XMLDocument` currently being edited.
6837
### `doc`
6938
The `XMLDocument` currently being edited.
7039

71-
### `editable`
72-
Filename extensions of user-editable documents.
73-
74-
### `history`
75-
History of edits done to `doc`.
76-
7740
### `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`.
8442

8543
### `locale`
86-
8744
Selected language (IETF language tag).
8845

8946
## Communicating user intent to OpenSCD core
@@ -123,16 +80,15 @@ declare global {
12380
}
12481
```
12582

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.
12784

12885
The `squash` flag indicates whether the edit should be merged with the previous edit in the history.
12986

13087
#### `Edit` type
131-
13288
The `EditDetailV2` defined above contains an `edit` of this type:
13389

13490
```typescript
135-
export type EditV2 = Insert | SetAttributes | SetTextContent | Remove | Edit[];
91+
export type EditV2 = Insert | SetAttributes | SetTextContent | Remove | EditV2[];
13692
```
13793

13894
This means that a single edit can either consist in a sequence of other edits or in one of the following atomic edit types:
@@ -204,7 +160,7 @@ The **wizard event** allows the plugin to request opening a modal dialog enablin
204160
```typescript
205161
/* eslint-disable no-undef */
206162
interface WizardRequestBase {
207-
subWizard?: boolean;
163+
subWizard?: boolean; // TODO: describe what this currently means
208164
}
209165

210166
export interface EditWizardRequest extends WizardRequestBase {
@@ -277,30 +233,6 @@ declare global {
277233
}
278234
```
279235

280-
### `ConfigurePluginEvent`
281-
282-
The **configure plugin event** allows the plugin to request that OpenSCD core add, remove, or reconfigure a plugin.
283-
284-
```typescript
285-
export type ConfigurePluginDetail = {
286-
name: string;
287-
kind: 'menu' | 'editor';
288-
config: Plugin | null;
289-
};
290-
291-
export type ConfigurePluginEvent = CustomEvent<ConfigurePluginDetail>;
292-
293-
export function newConfigurePluginEvent(name: string, kind: 'menu' | 'editor', config: Plugin | null): ConfigurePluginEvent {
294-
return new CustomEvent<ConfigurePluginDetail>('oscd-configure-plugin', {
295-
bubbles: true,
296-
composed: true,
297-
detail: { name, kind, config },
298-
});
299-
}
300-
```
301-
302-
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-
304236
## Theming
305237

306238
OpenSCD core sets the following CSS variables on the plugin:
@@ -321,8 +253,7 @@ OpenSCD core sets the following CSS variables on the plugin:
321253
--oscd-base3: var(--oscd-theme-base3, #fdf6e3);
322254

323255
--oscd-text-font: var(--oscd-theme-text-font, 'Roboto');
256+
--oscd-text-font-mono: var(--oscd-theme-text-font-mono, 'Roboto Mono');
324257
--oscd-icon-font: var(--oscd-theme-icon-font, 'Material Icons');
325258
}
326259
```
327-
328-
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

Comments
 (0)