@omicronenergy/oscd-shell 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddPlugins.js +39 -0
- package/dist/DemoPluginSrc.js +7 -0
- package/dist/embedded.html +17 -0
- package/dist/index.html +112 -0
- package/dist/oscd-shell.d.ts +59 -55
- package/dist/oscd-shell.js +107 -153
- package/dist/oscd-shell.js.map +1 -1
- package/dist/utils/plugin-utils.d.ts +29 -0
- package/dist/utils/plugin-utils.js +138 -0
- package/dist/utils/plugin-utils.js.map +1 -0
- package/dist/utils/plugin-utils.spec.d.ts +1 -0
- package/dist/utils/plugin-utils.spec.js +115 -0
- package/dist/utils/plugin-utils.spec.js.map +1 -0
- package/package.json +20 -18
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* eslint-disable no-alert */
|
|
2
|
+
export default class AddPlugins extends HTMLElement {
|
|
3
|
+
/* eslint-disable-next-line class-methods-use-this */
|
|
4
|
+
run() {
|
|
5
|
+
const editor = this.getRootNode().host;
|
|
6
|
+
const kind = window.confirm(
|
|
7
|
+
`Add a menu type plugin?
|
|
8
|
+
If you choose 'Cancel', an editor type plugin will be added instead.`,
|
|
9
|
+
)
|
|
10
|
+
? 'menu'
|
|
11
|
+
: 'editor';
|
|
12
|
+
const requireDoc = window.confirm(
|
|
13
|
+
'Does the plugin require a loaded document? (OK=yes, Cancel=no)',
|
|
14
|
+
);
|
|
15
|
+
const name =
|
|
16
|
+
window.prompt('Plugin name', 'My plugin') || 'Default plugin name';
|
|
17
|
+
const icon =
|
|
18
|
+
window.prompt('Plugin icon (material icon name)', 'extension') ||
|
|
19
|
+
'extension';
|
|
20
|
+
const src =
|
|
21
|
+
window.prompt(
|
|
22
|
+
'Plugin source URI',
|
|
23
|
+
`/demo/DemoPluginSrc.js?${Date.now()}`,
|
|
24
|
+
) || 'data:text/javascript,';
|
|
25
|
+
const plugin = { name, src, icon, requireDoc };
|
|
26
|
+
if (
|
|
27
|
+
!window.confirm(
|
|
28
|
+
`Add ${kind} plugin ${JSON.stringify(plugin, null, ' ')}?`,
|
|
29
|
+
)
|
|
30
|
+
) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
editor.plugins = {
|
|
34
|
+
...editor.plugins,
|
|
35
|
+
[kind]: [...(editor.plugins[kind] || []), plugin],
|
|
36
|
+
};
|
|
37
|
+
editor.requestUpdate('plugins');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<title>OpenSCD Core Embedding Demo</title>
|
|
3
|
+
<iframe src="./index.html?locale=de&dark"></iframe>
|
|
4
|
+
<style>
|
|
5
|
+
iframe {
|
|
6
|
+
width:50vw;
|
|
7
|
+
height: 50vh;
|
|
8
|
+
position: relative;
|
|
9
|
+
top: 25vh;
|
|
10
|
+
left: 25vw;
|
|
11
|
+
border: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
body {
|
|
15
|
+
background-color: darkseagreen;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>OpenSCD Shell Demo</title>
|
|
5
|
+
<link
|
|
6
|
+
rel="stylesheet"
|
|
7
|
+
href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&family=Roboto:wght@300;400;500&display=swap"
|
|
8
|
+
/>
|
|
9
|
+
<link
|
|
10
|
+
rel="stylesheet"
|
|
11
|
+
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
|
|
12
|
+
/>
|
|
13
|
+
<link
|
|
14
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined"
|
|
15
|
+
rel="stylesheet"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<oscd-shell></oscd-shell>
|
|
19
|
+
|
|
20
|
+
<script type="module">
|
|
21
|
+
import OscdMenuOpen from '@omicronenergy/oscd-menu-open';
|
|
22
|
+
import OscdMenuSave from '@omicronenergy/oscd-menu-save';
|
|
23
|
+
import OscdBackgroundEditV1 from '@omicronenergy/oscd-background-editv1';
|
|
24
|
+
|
|
25
|
+
import '../oscd-shell.js';
|
|
26
|
+
|
|
27
|
+
customElements.define('oscd-menu-open', OscdMenuOpen);
|
|
28
|
+
customElements.define('oscd-menu-save', OscdMenuSave);
|
|
29
|
+
customElements.define('oscd-background-editv1', OscdBackgroundEditV1);
|
|
30
|
+
|
|
31
|
+
const plugins = {
|
|
32
|
+
menu: [
|
|
33
|
+
{
|
|
34
|
+
name: 'Add plugins...',
|
|
35
|
+
translations: { de: 'Erweitern...' },
|
|
36
|
+
icon: 'extension',
|
|
37
|
+
src: '/demo/AddPlugins.js',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Open File',
|
|
41
|
+
translations: { de: 'Datei öffnen' },
|
|
42
|
+
icon: 'folder_open',
|
|
43
|
+
tagName: 'oscd-menu-open',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Save File',
|
|
47
|
+
translations: { de: 'Datei speichern' },
|
|
48
|
+
icon: 'save',
|
|
49
|
+
requireDoc: true,
|
|
50
|
+
tagName: 'oscd-menu-save',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
editor: [
|
|
54
|
+
{
|
|
55
|
+
name: 'Start',
|
|
56
|
+
translations: {
|
|
57
|
+
de: 'Start',
|
|
58
|
+
},
|
|
59
|
+
icon: 'start',
|
|
60
|
+
src: 'https://openenergytools.github.io/scl-editor-landing/scl-editor-landing.js',
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
{
|
|
64
|
+
name: 'Substation',
|
|
65
|
+
icon: 'margin',
|
|
66
|
+
requireDoc: true,
|
|
67
|
+
src: 'https://openenergytools.github.io/scl-substation-editor/scl-substation-editor.js',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Design SLD',
|
|
71
|
+
translations: {
|
|
72
|
+
de: 'Designer',
|
|
73
|
+
},
|
|
74
|
+
icon: 'add_box',
|
|
75
|
+
requireDoc: true,
|
|
76
|
+
src: 'https://openenergytools.github.io/oscd-designer/oscd-designer.js',
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
background: [
|
|
80
|
+
{
|
|
81
|
+
name: 'EditV1 Events Listener',
|
|
82
|
+
icon: 'none',
|
|
83
|
+
requireDoc: true,
|
|
84
|
+
tagName: 'oscd-background-editv1',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const editor = document.querySelector('oscd-shell');
|
|
90
|
+
const params = new URL(document.location).searchParams;
|
|
91
|
+
for (const [name, value] of params) {
|
|
92
|
+
editor.setAttribute(name, value);
|
|
93
|
+
}
|
|
94
|
+
editor.plugins = plugins;
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
html,
|
|
99
|
+
body {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
* {
|
|
105
|
+
margin: 0px;
|
|
106
|
+
padding: 0px;
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
109
|
+
</head>
|
|
110
|
+
|
|
111
|
+
<body></body>
|
|
112
|
+
</html>
|
package/dist/oscd-shell.d.ts
CHANGED
|
@@ -1,36 +1,57 @@
|
|
|
1
1
|
import '@webcomponents/scoped-custom-element-registry';
|
|
2
2
|
import { LitElement, TemplateResult } from 'lit';
|
|
3
|
-
import
|
|
4
|
-
import { OscdDialog } from '@omicronenergy/oscd-ui/dialog/OscdDialog.js';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import
|
|
3
|
+
import '@omicronenergy/oscd-ui/app-bar/oscd-app-bar.js';
|
|
4
|
+
import type { OscdDialog } from '@omicronenergy/oscd-ui/dialog/OscdDialog.js';
|
|
5
|
+
import '@omicronenergy/oscd-ui/dialog/oscd-dialog.js';
|
|
6
|
+
import '@omicronenergy/oscd-ui/divider/oscd-divider.js';
|
|
7
|
+
import type { OscdFilledIconButton } from '@omicronenergy/oscd-ui/iconbutton/OscdFilledIconButton.js';
|
|
8
|
+
import '@omicronenergy/oscd-ui/iconbutton/oscd-filled-icon-button.js';
|
|
9
|
+
import '@omicronenergy/oscd-ui/select/oscd-filled-select.js';
|
|
10
|
+
import '@omicronenergy/oscd-ui/textfield/oscd-filled-text-field.js';
|
|
11
|
+
import '@omicronenergy/oscd-ui/icon/oscd-icon.js';
|
|
12
|
+
import '@omicronenergy/oscd-ui/list/oscd-list.js';
|
|
13
|
+
import '@omicronenergy/oscd-ui/list/oscd-list-item.js';
|
|
14
|
+
import type { OscdMenu } from '@omicronenergy/oscd-ui/menu/OscdMenu.js';
|
|
15
|
+
import '@omicronenergy/oscd-ui/menu/oscd-menu.js';
|
|
16
|
+
import '@omicronenergy/oscd-ui/menu/oscd-menu-item.js';
|
|
17
|
+
import type { OscdNavigationDrawer } from '@omicronenergy/oscd-ui/navigation-drawer/OscdNavigationDrawer.js';
|
|
18
|
+
import '@omicronenergy/oscd-ui/navigation-drawer/oscd-navigation-drawer.js';
|
|
19
|
+
import '@omicronenergy/oscd-ui/navigation-drawer/oscd-navigation-drawer-header.js';
|
|
20
|
+
import '@omicronenergy/oscd-ui/tabs/oscd-secondary-tab.js';
|
|
21
|
+
import '@omicronenergy/oscd-ui/select/oscd-select-option.js';
|
|
22
|
+
import '@omicronenergy/oscd-ui/tabs/oscd-tabs.js';
|
|
23
|
+
import '@omicronenergy/oscd-ui/button/oscd-text-button.js';
|
|
20
24
|
import { XMLEditor } from '@omicronenergy/oscd-editor';
|
|
21
|
-
import { OpenEvent } from '@omicronenergy/oscd-api';
|
|
25
|
+
import { EditV2, OpenEvent, Transactor } from '@omicronenergy/oscd-api';
|
|
22
26
|
import { allLocales, targetLocales } from './locales.js';
|
|
23
|
-
export
|
|
27
|
+
export interface Plugin {
|
|
28
|
+
editor: Transactor<EditV2>;
|
|
29
|
+
docs: Record<string, XMLDocument>;
|
|
30
|
+
doc?: XMLDocument;
|
|
31
|
+
docName?: string;
|
|
32
|
+
docVersion: unknown;
|
|
33
|
+
/** @deprecated Use `docVersion` instead */
|
|
34
|
+
editCount: number;
|
|
35
|
+
locale: string;
|
|
36
|
+
}
|
|
37
|
+
export type PluginEntry = {
|
|
38
|
+
name: string;
|
|
39
|
+
translations?: Record<(typeof targetLocales)[number], string>;
|
|
40
|
+
tagName: string;
|
|
41
|
+
icon: string;
|
|
42
|
+
requireDoc?: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type SourcedPluginEntry = {
|
|
24
45
|
name: string;
|
|
25
46
|
translations?: Record<(typeof targetLocales)[number], string>;
|
|
26
47
|
src: string;
|
|
27
48
|
icon: string;
|
|
28
49
|
requireDoc?: boolean;
|
|
29
50
|
};
|
|
30
|
-
export type PluginSet = {
|
|
31
|
-
menu:
|
|
32
|
-
editor:
|
|
33
|
-
background:
|
|
51
|
+
export type PluginSet<P = PluginEntry> = {
|
|
52
|
+
menu: P[];
|
|
53
|
+
editor: P[];
|
|
54
|
+
background: P[];
|
|
34
55
|
};
|
|
35
56
|
type Control = {
|
|
36
57
|
icon: string;
|
|
@@ -42,45 +63,27 @@ type RenderedPlugin = Control & {
|
|
|
42
63
|
tagName: string;
|
|
43
64
|
};
|
|
44
65
|
type LocaleTag = (typeof allLocales)[number];
|
|
45
|
-
declare
|
|
46
|
-
export declare class OpenSCD extends OpenSCD_base {
|
|
66
|
+
export declare class OpenSCD extends LitElement {
|
|
47
67
|
#private;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'oscd-menu-item': typeof OscdMenuItem;
|
|
60
|
-
'oscd-navigation-drawer': typeof OscdNavigationDrawer;
|
|
61
|
-
'oscd-navigation-drawer-header': typeof OscdNavigationDrawerHeader;
|
|
62
|
-
'oscd-secondary-tab': typeof OscdSecondaryTab;
|
|
63
|
-
'oscd-tabs': typeof OscdTabs;
|
|
64
|
-
'oscd-text-button': typeof OscdTextButton;
|
|
65
|
-
'oscd-menu': typeof OscdMenu;
|
|
66
|
-
};
|
|
68
|
+
/** The file endings of editable files */
|
|
69
|
+
editable: string[];
|
|
70
|
+
isEditable(docName: string): boolean;
|
|
71
|
+
get editableDocs(): string[];
|
|
72
|
+
private _docs;
|
|
73
|
+
/** The set of `XMLDocument`s currently loaded */
|
|
74
|
+
get docs(): Record<string, XMLDocument>;
|
|
75
|
+
set docs(newDocs: Record<string, XMLDocument>);
|
|
76
|
+
onDocsChanged(): void;
|
|
77
|
+
/** The name of the [[`doc`]] currently being edited */
|
|
78
|
+
docName: string;
|
|
67
79
|
get doc(): XMLDocument;
|
|
68
80
|
xmlEditor: XMLEditor;
|
|
81
|
+
docVersion: number;
|
|
69
82
|
get last(): number;
|
|
70
83
|
get canUndo(): boolean;
|
|
71
84
|
get canRedo(): boolean;
|
|
72
|
-
/** The set of `XMLDocument`s currently loaded */
|
|
73
|
-
docs: Record<string, XMLDocument>;
|
|
74
|
-
/** The name of the [[`doc`]] currently being edited */
|
|
75
|
-
docName: string;
|
|
76
|
-
/** The file endings of editable files */
|
|
77
|
-
editable: string[];
|
|
78
|
-
isEditable(docName: string): boolean;
|
|
79
|
-
get editableDocs(): string[];
|
|
80
85
|
get plugins(): PluginSet;
|
|
81
|
-
set plugins(plugins: Partial<PluginSet
|
|
82
|
-
get loadedPlugins(): PluginSet;
|
|
83
|
-
addLoadedPlugin(tagName: string, kind: keyof PluginSet, plugin: Plugin, index: number): void;
|
|
86
|
+
set plugins(plugins: Partial<PluginSet<Partial<PluginEntry | SourcedPluginEntry>>>);
|
|
84
87
|
handleOpenDoc({ detail: { docName, doc } }: OpenEvent): void;
|
|
85
88
|
/** Undo the last `n` [[Edit]]s committed */
|
|
86
89
|
undo(n?: number): void;
|
|
@@ -103,6 +106,7 @@ export declare class OpenSCD extends OpenSCD_base {
|
|
|
103
106
|
private handleKeyPress;
|
|
104
107
|
constructor();
|
|
105
108
|
updated(changedProps: Map<string, unknown>): void;
|
|
109
|
+
renderPlugin(tagName: string): TemplateResult;
|
|
106
110
|
render(): TemplateResult<1>;
|
|
107
111
|
firstUpdated(): void;
|
|
108
112
|
static styles: import("lit").CSSResult;
|