@compas-oscd/open-scd 0.34.0 → 0.34.1
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/WizardDivider.js +37 -0
- package/dist/WizardDivider.js.map +1 -0
- package/dist/Wizarding.js +38 -0
- package/dist/Wizarding.js.map +1 -0
- package/dist/action-icon.js +220 -0
- package/dist/action-icon.js.map +1 -0
- package/dist/action-pane.js +176 -0
- package/dist/action-pane.js.map +1 -0
- package/dist/addons/Editor.js +106 -0
- package/dist/addons/Editor.js.map +1 -0
- package/dist/addons/History.js +490 -0
- package/dist/addons/History.js.map +1 -0
- package/dist/addons/Layout.js +619 -0
- package/dist/addons/Layout.js.map +1 -0
- package/dist/addons/Settings.js +465 -0
- package/dist/addons/Settings.js.map +1 -0
- package/dist/addons/Waiter.js +45 -0
- package/dist/addons/Waiter.js.map +1 -0
- package/dist/addons/Wizards.js +48 -0
- package/dist/addons/Wizards.js.map +1 -0
- package/dist/addons/editor/edit-action-to-v1-converter.js +96 -0
- package/dist/addons/editor/edit-action-to-v1-converter.js.map +1 -0
- package/dist/addons/editor/edit-v1-to-v2-converter.js +37 -0
- package/dist/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
- package/dist/addons/history/get-log-text.js +26 -0
- package/dist/addons/history/get-log-text.js.map +1 -0
- package/dist/addons/menu-tabs/menu-tabs.js +74 -0
- package/dist/addons/menu-tabs/menu-tabs.js.map +1 -0
- package/dist/addons/plugin-manager/custom-plugin-dialog.js +177 -0
- package/dist/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
- package/dist/addons/plugin-manager/plugin-manager.js +165 -0
- package/dist/addons/plugin-manager/plugin-manager.js.map +1 -0
- package/dist/core/api/api.js +7 -0
- package/dist/core/api/api.js.map +1 -0
- package/dist/core/api/editor/subject.js +22 -0
- package/dist/core/api/editor/subject.js.map +1 -0
- package/dist/core/api/editor/xml-editor.js +82 -0
- package/dist/core/api/editor/xml-editor.js.map +1 -0
- package/dist/core/api/plugin-state-api.js +27 -0
- package/dist/core/api/plugin-state-api.js.map +1 -0
- package/dist/core/foundation/cyrb64.js +26 -0
- package/dist/core/foundation/cyrb64.js.map +1 -0
- package/dist/core/foundation/deprecated/edit-event.js +44 -0
- package/dist/core/foundation/deprecated/edit-event.js.map +1 -0
- package/dist/core/foundation/deprecated/editor.js +94 -0
- package/dist/core/foundation/deprecated/editor.js.map +1 -0
- package/dist/core/foundation/deprecated/history.js +17 -0
- package/dist/core/foundation/deprecated/history.js.map +1 -0
- package/dist/core/foundation/deprecated/open-event.js +9 -0
- package/dist/core/foundation/deprecated/open-event.js.map +1 -0
- package/dist/core/foundation/deprecated/settings.js +19 -0
- package/dist/core/foundation/deprecated/settings.js.map +1 -0
- package/dist/core/foundation/deprecated/validation.js +8 -0
- package/dist/core/foundation/deprecated/validation.js.map +1 -0
- package/dist/core/foundation/deprecated/waiter.js +12 -0
- package/dist/core/foundation/deprecated/waiter.js.map +1 -0
- package/dist/core/foundation/edit-completed-event.js +11 -0
- package/dist/core/foundation/edit-completed-event.js.map +1 -0
- package/dist/core/foundation/edit-event.js +8 -0
- package/dist/core/foundation/edit-event.js.map +1 -0
- package/dist/core/foundation/edit.js +31 -0
- package/dist/core/foundation/edit.js.map +1 -0
- package/dist/core/foundation/handle-edit.js +151 -0
- package/dist/core/foundation/handle-edit.js.map +1 -0
- package/dist/core/foundation/open-event.js +8 -0
- package/dist/core/foundation/open-event.js.map +1 -0
- package/dist/core/foundation/plugin.js +2 -0
- package/dist/core/foundation/plugin.js.map +1 -0
- package/dist/core/foundation.js +14 -0
- package/dist/core/foundation.js.map +1 -0
- package/dist/core/locales.js +21 -0
- package/dist/core/locales.js.map +1 -0
- package/dist/filtered-list.js +168 -0
- package/dist/filtered-list.js.map +1 -0
- package/dist/finder-list.js +207 -0
- package/dist/finder-list.js.map +1 -0
- package/dist/foundation/compare.js +273 -0
- package/dist/foundation/compare.js.map +1 -0
- package/dist/foundation/dai.js +127 -0
- package/dist/foundation/dai.js.map +1 -0
- package/dist/foundation/generators.js +67 -0
- package/dist/foundation/generators.js.map +1 -0
- package/dist/foundation/ied.js +84 -0
- package/dist/foundation/ied.js.map +1 -0
- package/dist/foundation/nsd.js +13 -0
- package/dist/foundation/nsd.js.map +1 -0
- package/dist/foundation/nsdoc.js +180 -0
- package/dist/foundation/nsdoc.js.map +1 -0
- package/dist/foundation/scl.js +64 -0
- package/dist/foundation/scl.js.map +1 -0
- package/dist/foundation.js +1922 -0
- package/dist/foundation.js.map +1 -0
- package/dist/icons/compare.js +11 -0
- package/dist/icons/compare.js.map +1 -0
- package/dist/icons/icons.js +611 -0
- package/dist/icons/icons.js.map +1 -0
- package/dist/icons/ied-icons.js +11 -0
- package/dist/icons/ied-icons.js.map +1 -0
- package/dist/icons/lnode.js +50 -0
- package/dist/icons/lnode.js.map +1 -0
- package/dist/open-scd.js +483 -0
- package/dist/open-scd.js.map +1 -0
- package/dist/openscd/src/WizardDivider.js +37 -0
- package/dist/openscd/src/WizardDivider.js.map +1 -0
- package/dist/openscd/src/Wizarding.js +38 -0
- package/dist/openscd/src/Wizarding.js.map +1 -0
- package/dist/openscd/src/action-icon.js +220 -0
- package/dist/openscd/src/action-icon.js.map +1 -0
- package/dist/openscd/src/action-pane.js +176 -0
- package/dist/openscd/src/action-pane.js.map +1 -0
- package/dist/openscd/src/addons/Editor.js +106 -0
- package/dist/openscd/src/addons/Editor.js.map +1 -0
- package/dist/openscd/src/addons/History.js +490 -0
- package/dist/openscd/src/addons/History.js.map +1 -0
- package/dist/openscd/src/addons/Layout.js +619 -0
- package/dist/openscd/src/addons/Layout.js.map +1 -0
- package/dist/openscd/src/addons/Settings.js +465 -0
- package/dist/openscd/src/addons/Settings.js.map +1 -0
- package/dist/openscd/src/addons/Waiter.js +45 -0
- package/dist/openscd/src/addons/Waiter.js.map +1 -0
- package/dist/openscd/src/addons/Wizards.js +48 -0
- package/dist/openscd/src/addons/Wizards.js.map +1 -0
- package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js +96 -0
- package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js.map +1 -0
- package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js +37 -0
- package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
- package/dist/openscd/src/addons/history/get-log-text.js +26 -0
- package/dist/openscd/src/addons/history/get-log-text.js.map +1 -0
- package/dist/openscd/src/addons/menu-tabs/menu-tabs.js +74 -0
- package/dist/openscd/src/addons/menu-tabs/menu-tabs.js.map +1 -0
- package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js +177 -0
- package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
- package/dist/openscd/src/addons/plugin-manager/plugin-manager.js +165 -0
- package/dist/openscd/src/addons/plugin-manager/plugin-manager.js.map +1 -0
- package/dist/openscd/src/filtered-list.js +168 -0
- package/dist/openscd/src/filtered-list.js.map +1 -0
- package/dist/openscd/src/finder-list.js +207 -0
- package/dist/openscd/src/finder-list.js.map +1 -0
- package/dist/openscd/src/foundation/compare.js +273 -0
- package/dist/openscd/src/foundation/compare.js.map +1 -0
- package/dist/openscd/src/foundation/dai.js +127 -0
- package/dist/openscd/src/foundation/dai.js.map +1 -0
- package/dist/openscd/src/foundation/generators.js +67 -0
- package/dist/openscd/src/foundation/generators.js.map +1 -0
- package/dist/openscd/src/foundation/ied.js +84 -0
- package/dist/openscd/src/foundation/ied.js.map +1 -0
- package/dist/openscd/src/foundation/nsd.js +13 -0
- package/dist/openscd/src/foundation/nsd.js.map +1 -0
- package/dist/openscd/src/foundation/nsdoc.js +180 -0
- package/dist/openscd/src/foundation/nsdoc.js.map +1 -0
- package/dist/openscd/src/foundation/scl.js +64 -0
- package/dist/openscd/src/foundation/scl.js.map +1 -0
- package/dist/openscd/src/foundation.js +1922 -0
- package/dist/openscd/src/foundation.js.map +1 -0
- package/dist/openscd/src/icons/compare.js +11 -0
- package/dist/openscd/src/icons/compare.js.map +1 -0
- package/dist/openscd/src/icons/icons.js +611 -0
- package/dist/openscd/src/icons/icons.js.map +1 -0
- package/dist/openscd/src/icons/ied-icons.js +11 -0
- package/dist/openscd/src/icons/ied-icons.js.map +1 -0
- package/dist/openscd/src/icons/lnode.js +50 -0
- package/dist/openscd/src/icons/lnode.js.map +1 -0
- package/dist/openscd/src/open-scd.js +483 -0
- package/dist/openscd/src/open-scd.js.map +1 -0
- package/dist/openscd/src/oscd-filter-button.js +89 -0
- package/dist/openscd/src/oscd-filter-button.js.map +1 -0
- package/dist/openscd/src/plain-compare-list.js +132 -0
- package/dist/openscd/src/plain-compare-list.js.map +1 -0
- package/dist/openscd/src/plugin-tag.js +23 -0
- package/dist/openscd/src/plugin-tag.js.map +1 -0
- package/dist/openscd/src/plugin.events.js +12 -0
- package/dist/openscd/src/plugin.events.js.map +1 -0
- package/dist/openscd/src/plugin.js +2 -0
- package/dist/openscd/src/plugin.js.map +1 -0
- package/dist/openscd/src/plugins.js +256 -0
- package/dist/openscd/src/plugins.js.map +1 -0
- package/dist/openscd/src/schemas.js +9325 -0
- package/dist/openscd/src/schemas.js.map +1 -0
- package/dist/openscd/src/themes.js +122 -0
- package/dist/openscd/src/themes.js.map +1 -0
- package/dist/openscd/src/translations/de.js +954 -0
- package/dist/openscd/src/translations/de.js.map +1 -0
- package/dist/openscd/src/translations/en.js +950 -0
- package/dist/openscd/src/translations/en.js.map +1 -0
- package/dist/openscd/src/translations/loader.js +10 -0
- package/dist/openscd/src/translations/loader.js.map +1 -0
- package/dist/openscd/src/wizard-checkbox.js +152 -0
- package/dist/openscd/src/wizard-checkbox.js.map +1 -0
- package/dist/openscd/src/wizard-dialog.js +374 -0
- package/dist/openscd/src/wizard-dialog.js.map +1 -0
- package/dist/openscd/src/wizard-select.js +115 -0
- package/dist/openscd/src/wizard-select.js.map +1 -0
- package/dist/openscd/src/wizard-textfield.js +191 -0
- package/dist/openscd/src/wizard-textfield.js.map +1 -0
- package/dist/openscd/src/wizards.js +196 -0
- package/dist/openscd/src/wizards.js.map +1 -0
- package/dist/oscd-filter-button.js +89 -0
- package/dist/oscd-filter-button.js.map +1 -0
- package/dist/plain-compare-list.js +132 -0
- package/dist/plain-compare-list.js.map +1 -0
- package/dist/plugin-tag.js +23 -0
- package/dist/plugin-tag.js.map +1 -0
- package/dist/plugin.events.js +12 -0
- package/dist/plugin.events.js.map +1 -0
- package/dist/plugin.js +2 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugins.js +256 -0
- package/dist/plugins.js.map +1 -0
- package/dist/schemas.js +9325 -0
- package/dist/schemas.js.map +1 -0
- package/dist/themes.js +122 -0
- package/dist/themes.js.map +1 -0
- package/dist/translations/de.js +954 -0
- package/dist/translations/de.js.map +1 -0
- package/dist/translations/en.js +950 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/loader.js +10 -0
- package/dist/translations/loader.js.map +1 -0
- package/dist/wizard-checkbox.js +152 -0
- package/dist/wizard-checkbox.js.map +1 -0
- package/dist/wizard-dialog.js +374 -0
- package/dist/wizard-dialog.js.map +1 -0
- package/dist/wizard-select.js +115 -0
- package/dist/wizard-select.js.map +1 -0
- package/dist/wizard-textfield.js +191 -0
- package/dist/wizard-textfield.js.map +1 -0
- package/dist/wizards.js +196 -0
- package/dist/wizards.js.map +1 -0
- package/dist/xml/src/foundation.js +67 -0
- package/dist/xml/src/foundation.js.map +1 -0
- package/dist/xml/src/index.js +2 -0
- package/dist/xml/src/index.js.map +1 -0
- package/package.json +99 -4
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement, html, LitElement, property, state, query, css, } from 'lit-element';
|
|
3
|
+
import { get } from 'lit-translate';
|
|
4
|
+
import { newPendingStateEvent } from '@openscd/core/foundation/deprecated/waiter.js';
|
|
5
|
+
import { newSettingsUIEvent } from '@openscd/core/foundation/deprecated/settings.js';
|
|
6
|
+
import { pluginIcons, } from '../open-scd.js';
|
|
7
|
+
import { HistoryUIKind, newEmptyIssuesEvent, newHistoryUIEvent } from './History.js';
|
|
8
|
+
import { List } from '@material/mwc-list';
|
|
9
|
+
import '@material/mwc-drawer';
|
|
10
|
+
import '@material/mwc-list';
|
|
11
|
+
import '@material/mwc-dialog';
|
|
12
|
+
import '@material/mwc-switch';
|
|
13
|
+
import '@material/mwc-select';
|
|
14
|
+
import '@material/mwc-textfield';
|
|
15
|
+
import { pluginTag } from '../plugin-tag.js';
|
|
16
|
+
import "./plugin-manager/plugin-manager.js";
|
|
17
|
+
import "./plugin-manager/custom-plugin-dialog.js";
|
|
18
|
+
import "./menu-tabs/menu-tabs.js";
|
|
19
|
+
let OscdLayout = class OscdLayout extends LitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
/** The `XMLDocument` to be edited */
|
|
23
|
+
this.doc = null;
|
|
24
|
+
/** The name of the current [[`doc`]] */
|
|
25
|
+
this.docName = '';
|
|
26
|
+
/** Index of the last [[`EditorAction`]] applied. */
|
|
27
|
+
this.editCount = -1;
|
|
28
|
+
/** The plugins to render the layout. */
|
|
29
|
+
this.plugins = [];
|
|
30
|
+
this.validated = Promise.resolve();
|
|
31
|
+
this.shouldValidate = false;
|
|
32
|
+
this.activeEditor = this.calcActiveEditors()[0];
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return html `
|
|
36
|
+
<div
|
|
37
|
+
@open-plugin-download=${() => this.pluginDownloadUI.show()}
|
|
38
|
+
@oscd-activate-editor=${this.handleActivateEditorByEvent}
|
|
39
|
+
@oscd-run-menu=${this.handleRunMenuByEvent}
|
|
40
|
+
>
|
|
41
|
+
<slot></slot>
|
|
42
|
+
${this.renderHeader()} ${this.renderAside()} ${this.renderMenuContent()}
|
|
43
|
+
${this.renderContent()} ${this.renderLanding()} ${this.renderPlugging()}
|
|
44
|
+
</div>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
renderPlugging() {
|
|
48
|
+
return html ` ${this.renderPluginUI()} ${this.renderDownloadUI()} `;
|
|
49
|
+
}
|
|
50
|
+
getMenuContent(src) {
|
|
51
|
+
const tag = pluginTag(src);
|
|
52
|
+
return this.menuContent.querySelector(tag);
|
|
53
|
+
}
|
|
54
|
+
/** Renders the "Add Custom Plug-in" UI*/
|
|
55
|
+
renderDownloadUI() {
|
|
56
|
+
return html `
|
|
57
|
+
<oscd-custom-plugin-dialog id="pluginAdd"></oscd-custom-plugin-dialog>
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Renders the plug-in management UI (turning plug-ins on/off)
|
|
62
|
+
*/
|
|
63
|
+
renderPluginUI() {
|
|
64
|
+
return html `
|
|
65
|
+
<oscd-plugin-manager id="pluginManager" .plugins=${this.plugins}></oscd-plugin-manager>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
// Computed properties
|
|
69
|
+
get validators() {
|
|
70
|
+
return this.plugins.filter(plugin => plugin.active && plugin.kind === 'validator');
|
|
71
|
+
}
|
|
72
|
+
get menuEntries() {
|
|
73
|
+
return this.plugins.filter(plugin => plugin.active && plugin.kind === 'menu');
|
|
74
|
+
}
|
|
75
|
+
get topMenu() {
|
|
76
|
+
return this.menuEntries.filter(plugin => plugin.position === 'top');
|
|
77
|
+
}
|
|
78
|
+
get middleMenu() {
|
|
79
|
+
return this.menuEntries.filter(plugin => plugin.position === 'middle');
|
|
80
|
+
}
|
|
81
|
+
get bottomMenu() {
|
|
82
|
+
return this.menuEntries.filter(plugin => plugin.position === 'bottom');
|
|
83
|
+
}
|
|
84
|
+
get menu() {
|
|
85
|
+
const topMenu = this.generateMenu(this.topMenu, 'top');
|
|
86
|
+
const middleMenu = this.generateMenu(this.middleMenu, 'middle');
|
|
87
|
+
const bottomMenu = this.generateMenu(this.bottomMenu, 'bottom');
|
|
88
|
+
const validators = this.generateValidatorMenus(this.validators);
|
|
89
|
+
if (middleMenu.length > 0)
|
|
90
|
+
middleMenu.push('divider');
|
|
91
|
+
if (bottomMenu.length > 0)
|
|
92
|
+
bottomMenu.push('divider');
|
|
93
|
+
return [
|
|
94
|
+
'divider',
|
|
95
|
+
...topMenu,
|
|
96
|
+
'divider',
|
|
97
|
+
{
|
|
98
|
+
icon: 'undo',
|
|
99
|
+
name: 'undo',
|
|
100
|
+
actionItem: true,
|
|
101
|
+
action: () => {
|
|
102
|
+
this.editor.undo();
|
|
103
|
+
},
|
|
104
|
+
disabled: () => !this.editor.canUndo,
|
|
105
|
+
kind: 'static',
|
|
106
|
+
content: () => html ``,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
icon: 'redo',
|
|
110
|
+
name: 'redo',
|
|
111
|
+
actionItem: true,
|
|
112
|
+
action: () => {
|
|
113
|
+
this.editor.redo();
|
|
114
|
+
},
|
|
115
|
+
disabled: () => !this.editor.canRedo,
|
|
116
|
+
kind: 'static',
|
|
117
|
+
content: () => html ``,
|
|
118
|
+
},
|
|
119
|
+
...validators,
|
|
120
|
+
{
|
|
121
|
+
icon: 'list',
|
|
122
|
+
name: 'menu.viewLog',
|
|
123
|
+
actionItem: true,
|
|
124
|
+
action: () => {
|
|
125
|
+
this.dispatchEvent(newHistoryUIEvent(true, HistoryUIKind.log));
|
|
126
|
+
},
|
|
127
|
+
kind: 'static',
|
|
128
|
+
content: () => html ``,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
icon: 'history',
|
|
132
|
+
name: 'menu.viewHistory',
|
|
133
|
+
actionItem: true,
|
|
134
|
+
action: () => {
|
|
135
|
+
this.dispatchEvent(newHistoryUIEvent(true, HistoryUIKind.history));
|
|
136
|
+
},
|
|
137
|
+
kind: 'static',
|
|
138
|
+
content: () => html ``,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
icon: 'rule',
|
|
142
|
+
name: 'menu.viewDiag',
|
|
143
|
+
actionItem: true,
|
|
144
|
+
action: () => {
|
|
145
|
+
this.dispatchEvent(newHistoryUIEvent(true, HistoryUIKind.diagnostic));
|
|
146
|
+
},
|
|
147
|
+
kind: 'static',
|
|
148
|
+
content: () => html ``,
|
|
149
|
+
},
|
|
150
|
+
'divider',
|
|
151
|
+
...middleMenu,
|
|
152
|
+
{
|
|
153
|
+
icon: 'settings',
|
|
154
|
+
name: 'settings.title',
|
|
155
|
+
action: () => {
|
|
156
|
+
this.dispatchEvent(newSettingsUIEvent(true));
|
|
157
|
+
},
|
|
158
|
+
kind: 'static',
|
|
159
|
+
content: () => html ``,
|
|
160
|
+
},
|
|
161
|
+
...bottomMenu,
|
|
162
|
+
{
|
|
163
|
+
icon: 'extension',
|
|
164
|
+
name: 'plugins.heading',
|
|
165
|
+
action: () => this.pluginUI.show(),
|
|
166
|
+
kind: 'static',
|
|
167
|
+
content: () => html ``,
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
get editors() {
|
|
172
|
+
return this.plugins.filter(plugin => plugin.active && plugin.kind === 'editor');
|
|
173
|
+
}
|
|
174
|
+
// Keyboard Shortcuts
|
|
175
|
+
handleKeyPress(e) {
|
|
176
|
+
// currently we only handley key shortcuts when users press ctrl
|
|
177
|
+
if (!e.ctrlKey) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const keyFunctionMap = {
|
|
181
|
+
'm': () => this.menuUI.open = !this.menuUI.open,
|
|
182
|
+
'o': () => this.menuUI.querySelector('mwc-list-item[iconid="folder_open"]')?.click(),
|
|
183
|
+
'O': () => this.menuUI.querySelector('mwc-list-item[iconid="create_new_folder"]')?.click(),
|
|
184
|
+
's': () => this.menuUI.querySelector('mwc-list-item[iconid="save"]')?.click(),
|
|
185
|
+
'P': () => this.pluginUI.show(),
|
|
186
|
+
};
|
|
187
|
+
const fn = keyFunctionMap[e.key];
|
|
188
|
+
if (!fn) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
fn();
|
|
193
|
+
}
|
|
194
|
+
connectedCallback() {
|
|
195
|
+
super.connectedCallback();
|
|
196
|
+
this.host.addEventListener('close-drawer', async () => {
|
|
197
|
+
this.menuUI.open = false;
|
|
198
|
+
});
|
|
199
|
+
this.host.addEventListener('validate', async () => {
|
|
200
|
+
this.shouldValidate = true;
|
|
201
|
+
await this.validated;
|
|
202
|
+
if (!this.shouldValidate) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
this.shouldValidate = false;
|
|
206
|
+
this.validated = Promise.allSettled(this.menuUI
|
|
207
|
+
.querySelector('mwc-list')
|
|
208
|
+
.items.filter(item => item.className === 'validator')
|
|
209
|
+
.map(item => {
|
|
210
|
+
const src = item.dataset.src ?? '';
|
|
211
|
+
const menuContentElement = this.getMenuContent(src);
|
|
212
|
+
if (!menuContentElement) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
return menuContentElement.validate();
|
|
216
|
+
})).then();
|
|
217
|
+
this.dispatchEvent(newPendingStateEvent(this.validated));
|
|
218
|
+
});
|
|
219
|
+
this.handleKeyPress = this.handleKeyPress.bind(this);
|
|
220
|
+
document.onkeydown = this.handleKeyPress;
|
|
221
|
+
document.addEventListener("open-plugin-download", () => {
|
|
222
|
+
this.pluginDownloadUI.show();
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
generateMenu(plugins, kind) {
|
|
226
|
+
return plugins.map(plugin => {
|
|
227
|
+
return {
|
|
228
|
+
icon: plugin.icon || pluginIcons['menu'],
|
|
229
|
+
name: plugin.name,
|
|
230
|
+
src: plugin.src,
|
|
231
|
+
action: ae => {
|
|
232
|
+
const menuContentElement = this.getMenuContent(plugin.src);
|
|
233
|
+
if (!menuContentElement) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.dispatchEvent(newPendingStateEvent(menuContentElement.run()));
|
|
237
|
+
},
|
|
238
|
+
disabled: () => plugin.requireDoc && this.doc === null,
|
|
239
|
+
content: () => {
|
|
240
|
+
if (plugin.content) {
|
|
241
|
+
return plugin.content();
|
|
242
|
+
}
|
|
243
|
+
return html ``;
|
|
244
|
+
},
|
|
245
|
+
kind: kind,
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
generateValidatorMenus(plugins) {
|
|
250
|
+
return plugins.map(plugin => {
|
|
251
|
+
return {
|
|
252
|
+
icon: plugin.icon || pluginIcons['validator'],
|
|
253
|
+
name: plugin.name,
|
|
254
|
+
src: plugin.src,
|
|
255
|
+
action: ae => {
|
|
256
|
+
this.dispatchEvent(newEmptyIssuesEvent(plugin.src));
|
|
257
|
+
const menuContentElement = this.getMenuContent(plugin.src);
|
|
258
|
+
if (!menuContentElement) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
this.dispatchEvent(newPendingStateEvent(menuContentElement.validate()));
|
|
262
|
+
},
|
|
263
|
+
disabled: () => this.doc === null,
|
|
264
|
+
content: plugin.content ?? (() => html ``),
|
|
265
|
+
kind: 'validator',
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
renderMenuItem(me) {
|
|
270
|
+
const isDivider = me === 'divider';
|
|
271
|
+
const hasActionItem = me !== 'divider' && me.actionItem;
|
|
272
|
+
if (isDivider) {
|
|
273
|
+
return html `<li divider padded role="separator"></li>`;
|
|
274
|
+
}
|
|
275
|
+
if (hasActionItem) {
|
|
276
|
+
return html ``;
|
|
277
|
+
}
|
|
278
|
+
return html `
|
|
279
|
+
<mwc-list-item
|
|
280
|
+
class="${me.kind}"
|
|
281
|
+
iconid="${me.icon}"
|
|
282
|
+
graphic="icon"
|
|
283
|
+
data-name="${me.name}"
|
|
284
|
+
data-src="${me.src ?? ''}"
|
|
285
|
+
.disabled=${me.disabled?.() || !me.action}
|
|
286
|
+
><mwc-icon slot="graphic">${me.icon}</mwc-icon>
|
|
287
|
+
<span>${get(me.name)}</span>
|
|
288
|
+
${me.hint
|
|
289
|
+
? html `<span slot="secondary"><tt>${me.hint}</tt></span>`
|
|
290
|
+
: ''}
|
|
291
|
+
</mwc-list-item>
|
|
292
|
+
`;
|
|
293
|
+
}
|
|
294
|
+
renderActionItem(me) {
|
|
295
|
+
if (me === 'divider' || !me.actionItem) {
|
|
296
|
+
return html ``;
|
|
297
|
+
}
|
|
298
|
+
return html `
|
|
299
|
+
<mwc-icon-button
|
|
300
|
+
slot="actionItems"
|
|
301
|
+
icon="${me.icon}"
|
|
302
|
+
label="${me.name}"
|
|
303
|
+
?disabled=${me.disabled?.() || !me.action}
|
|
304
|
+
@click=${me.action}
|
|
305
|
+
></mwc-icon-button>`;
|
|
306
|
+
}
|
|
307
|
+
renderEditorTab({ name, icon }) {
|
|
308
|
+
return html `<mwc-tab label=${name} icon=${icon || 'edit'}> </mwc-tab>`;
|
|
309
|
+
}
|
|
310
|
+
/** Renders top bar which features icon buttons for undo, redo, log, scl history and diagnostics*/
|
|
311
|
+
renderHeader() {
|
|
312
|
+
return html `<mwc-top-app-bar-fixed>
|
|
313
|
+
<mwc-icon-button
|
|
314
|
+
icon="menu"
|
|
315
|
+
label="Menu"
|
|
316
|
+
slot="navigationIcon"
|
|
317
|
+
@click=${() => (this.menuUI.open = true)}
|
|
318
|
+
></mwc-icon-button>
|
|
319
|
+
${this.renderTitle()}
|
|
320
|
+
${this.renderActionItems()}
|
|
321
|
+
</mwc-top-app-bar-fixed>`;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Renders the title section in the top bar
|
|
325
|
+
* Make sure to use slot="title" for the returned template
|
|
326
|
+
*/
|
|
327
|
+
renderTitle() {
|
|
328
|
+
return html `<div slot="title" id="title">${this.docName}</div>`;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Renders the action items for the top bar
|
|
332
|
+
* Make sure to use slot="actionItems" for each element
|
|
333
|
+
*/
|
|
334
|
+
renderActionItems() {
|
|
335
|
+
return html `${this.menu.map(this.renderActionItem)}`;
|
|
336
|
+
}
|
|
337
|
+
renderMenuContent() {
|
|
338
|
+
return html `
|
|
339
|
+
<div id="menuContent">
|
|
340
|
+
${this.menu
|
|
341
|
+
.filter(p => p.content)
|
|
342
|
+
.map(p => p.content())}
|
|
343
|
+
</div>
|
|
344
|
+
`;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Renders a drawer toolbar featuring the scl filename, enabled menu plugins,
|
|
348
|
+
* settings, help, scl history and plug-ins management
|
|
349
|
+
*/
|
|
350
|
+
renderAside() {
|
|
351
|
+
return html `
|
|
352
|
+
<mwc-drawer class="mdc-theme--surface" hasheader type="modal" id="menu">
|
|
353
|
+
<span slot="title">${get('menu.title')}</span>
|
|
354
|
+
${renderTitle(this.docName)}
|
|
355
|
+
<mwc-list
|
|
356
|
+
wrapFocus
|
|
357
|
+
@action=${makeListAction(this.menu)}
|
|
358
|
+
>
|
|
359
|
+
${this.menu.map(this.renderMenuItem)}
|
|
360
|
+
</mwc-list>
|
|
361
|
+
</mwc-drawer>
|
|
362
|
+
`;
|
|
363
|
+
function renderTitle(docName) {
|
|
364
|
+
if (!docName)
|
|
365
|
+
return html ``;
|
|
366
|
+
return html `<span slot="subtitle">${docName}</span>`;
|
|
367
|
+
}
|
|
368
|
+
function makeListAction(menuItems) {
|
|
369
|
+
return function listAction(ae) {
|
|
370
|
+
//FIXME: dirty hack to be fixed in open-scd-core
|
|
371
|
+
// if clause not necessary when oscd... components in open-scd not list
|
|
372
|
+
if (ae.target instanceof List)
|
|
373
|
+
(menuItems.filter(item => item !== 'divider' && !item.actionItem)[ae.detail.index])?.action?.(ae);
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
calcActiveEditors() {
|
|
378
|
+
const hasActiveDoc = Boolean(this.doc);
|
|
379
|
+
return this.editors
|
|
380
|
+
.filter(editor => {
|
|
381
|
+
// this is necessary because `requireDoc` can be undefined
|
|
382
|
+
// and that is not the same as false
|
|
383
|
+
const doesNotRequireDoc = editor.requireDoc === false;
|
|
384
|
+
return doesNotRequireDoc || hasActiveDoc;
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
/** Renders the enabled editor plugins and a tab bar to switch between them*/
|
|
388
|
+
renderContent() {
|
|
389
|
+
const activeEditors = this.calcActiveEditors()
|
|
390
|
+
.map(this.renderEditorTab);
|
|
391
|
+
const hasActiveEditors = activeEditors.length > 0;
|
|
392
|
+
if (!hasActiveEditors) {
|
|
393
|
+
return html ``;
|
|
394
|
+
}
|
|
395
|
+
return html `
|
|
396
|
+
<oscd-menu-tabs
|
|
397
|
+
.editors=${this.calcActiveEditors()}
|
|
398
|
+
.activeEditor=${this.activeEditor}
|
|
399
|
+
@oscd-editor-tab-activated=${this.handleEditorTabActivated}
|
|
400
|
+
>
|
|
401
|
+
</oscd-menu-tabs>
|
|
402
|
+
${renderEditorContent(this.doc, this.activeEditor)}
|
|
403
|
+
`;
|
|
404
|
+
function renderEditorContent(doc, activeEditor) {
|
|
405
|
+
const editor = activeEditor;
|
|
406
|
+
const requireDoc = editor?.requireDoc;
|
|
407
|
+
if (requireDoc && !doc) {
|
|
408
|
+
return html ``;
|
|
409
|
+
}
|
|
410
|
+
const content = editor?.content;
|
|
411
|
+
if (!content) {
|
|
412
|
+
return html ``;
|
|
413
|
+
}
|
|
414
|
+
return html `${content()}`;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
handleEditorTabActivated(e) {
|
|
418
|
+
this.activeEditor = e.detail.editor;
|
|
419
|
+
}
|
|
420
|
+
handleActivateEditorByEvent(e) {
|
|
421
|
+
const { name, src } = e.detail;
|
|
422
|
+
const editors = this.calcActiveEditors();
|
|
423
|
+
const wantedEditor = editors.find(editor => editor.name === name || editor.src === src);
|
|
424
|
+
if (!wantedEditor) {
|
|
425
|
+
return;
|
|
426
|
+
} // TODO: log error
|
|
427
|
+
this.activeEditor = wantedEditor;
|
|
428
|
+
}
|
|
429
|
+
handleRunMenuByEvent(e) {
|
|
430
|
+
// TODO: this is a workaround, fix it
|
|
431
|
+
this.menuUI.open = true;
|
|
432
|
+
const menuEntry = this.menuUI.querySelector(`[data-name="${e.detail.name}"]`);
|
|
433
|
+
const menuContentElement = this.getMenuContent(menuEntry.dataset.src ?? '');
|
|
434
|
+
if (!menuContentElement) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
menuContentElement.run();
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Renders the landing buttons (open project and new project)
|
|
441
|
+
* it no document loaded we display the menu item that are in the position
|
|
442
|
+
* 'top' and are not disabled
|
|
443
|
+
*
|
|
444
|
+
* To enable replacement of this part we have to convert it to either an addon
|
|
445
|
+
* or a plugin
|
|
446
|
+
*/
|
|
447
|
+
renderLanding() {
|
|
448
|
+
if (this.doc) {
|
|
449
|
+
return html ``;
|
|
450
|
+
}
|
|
451
|
+
return html `
|
|
452
|
+
<div class="landing">
|
|
453
|
+
${renderMenuItems(this.menu, this.menuUI)}
|
|
454
|
+
</div>`;
|
|
455
|
+
function renderMenuItems(menuItemsAndDividers, menuUI) {
|
|
456
|
+
const menuItems = menuItemsAndDividers.filter(mi => mi !== 'divider');
|
|
457
|
+
return menuItems.map((mi, index) => {
|
|
458
|
+
if (mi.kind !== 'top' || mi.disabled?.()) {
|
|
459
|
+
return html ``;
|
|
460
|
+
}
|
|
461
|
+
return html `
|
|
462
|
+
<mwc-icon-button
|
|
463
|
+
class="landing_icon"
|
|
464
|
+
icon="${mi.icon}"
|
|
465
|
+
@click="${() => clickListItem(index)}"
|
|
466
|
+
>
|
|
467
|
+
<div class="landing_label">${mi.name}</div>
|
|
468
|
+
</mwc-icon-button>
|
|
469
|
+
`;
|
|
470
|
+
});
|
|
471
|
+
function clickListItem(index) {
|
|
472
|
+
const listItem = menuUI.querySelector('mwc-list').items[index];
|
|
473
|
+
listItem.click();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
OscdLayout.styles = css `
|
|
479
|
+
mwc-drawer {
|
|
480
|
+
position: absolute;
|
|
481
|
+
top: 0;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
mwc-top-app-bar-fixed {
|
|
485
|
+
--mdc-theme-text-disabled-on-light: rgba(255, 255, 255, 0.38);
|
|
486
|
+
} /* hack to fix disabled icon buttons rendering black */
|
|
487
|
+
|
|
488
|
+
mwc-tab {
|
|
489
|
+
background-color: var(--primary);
|
|
490
|
+
--mdc-theme-primary: var(--mdc-theme-on-primary);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
input[type='file'] {
|
|
494
|
+
display: none;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
mwc-dialog {
|
|
498
|
+
--mdc-dialog-max-width: 98vw;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
mwc-dialog > form {
|
|
502
|
+
display: flex;
|
|
503
|
+
flex-direction: column;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
mwc-dialog > form > * {
|
|
507
|
+
display: block;
|
|
508
|
+
margin-top: 16px;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
mwc-linear-progress {
|
|
512
|
+
position: fixed;
|
|
513
|
+
--mdc-linear-progress-buffer-color: var(--primary);
|
|
514
|
+
--mdc-theme-primary: var(--secondary);
|
|
515
|
+
left: 0px;
|
|
516
|
+
top: 0px;
|
|
517
|
+
width: 100%;
|
|
518
|
+
pointer-events: none;
|
|
519
|
+
z-index: 1000;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
tt {
|
|
523
|
+
font-family: 'Roboto Mono', monospace;
|
|
524
|
+
font-weight: 300;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.landing {
|
|
528
|
+
position: absolute;
|
|
529
|
+
text-align: center;
|
|
530
|
+
top: 50%;
|
|
531
|
+
left: 50%;
|
|
532
|
+
transform: translate(-50%, -50%);
|
|
533
|
+
width: 100%;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.landing_icon:hover {
|
|
537
|
+
box-shadow: 0 12px 17px 2px rgba(0, 0, 0, 0.14),
|
|
538
|
+
0 5px 22px 4px rgba(0, 0, 0, 0.12), 0 7px 8px -4px rgba(0, 0, 0, 0.2);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.landing_icon {
|
|
542
|
+
margin: 12px;
|
|
543
|
+
border-radius: 16px;
|
|
544
|
+
width: 160px;
|
|
545
|
+
height: 140px;
|
|
546
|
+
text-align: center;
|
|
547
|
+
color: var(--mdc-theme-on-secondary);
|
|
548
|
+
background: var(--secondary);
|
|
549
|
+
--mdc-icon-button-size: 100px;
|
|
550
|
+
--mdc-icon-size: 100px;
|
|
551
|
+
--mdc-ripple-color: rgba(0, 0, 0, 0);
|
|
552
|
+
box-shadow: rgb(0 0 0 / 14%) 0px 6px 10px 0px,
|
|
553
|
+
rgb(0 0 0 / 12%) 0px 1px 18px 0px, rgb(0 0 0 / 20%) 0px 3px 5px -1px;
|
|
554
|
+
transition: box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.landing_label {
|
|
558
|
+
width: 160px;
|
|
559
|
+
height: 50px;
|
|
560
|
+
margin-top: 100px;
|
|
561
|
+
margin-left: -30px;
|
|
562
|
+
font-family: 'Roboto', sans-serif;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.plugin.menu {
|
|
566
|
+
display: flex;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.plugin.validator {
|
|
570
|
+
display: flex;
|
|
571
|
+
}
|
|
572
|
+
`;
|
|
573
|
+
__decorate([
|
|
574
|
+
property({ attribute: false })
|
|
575
|
+
], OscdLayout.prototype, "doc", void 0);
|
|
576
|
+
__decorate([
|
|
577
|
+
property({ type: String })
|
|
578
|
+
], OscdLayout.prototype, "docName", void 0);
|
|
579
|
+
__decorate([
|
|
580
|
+
property({ type: Number })
|
|
581
|
+
], OscdLayout.prototype, "editCount", void 0);
|
|
582
|
+
__decorate([
|
|
583
|
+
property({ type: Object })
|
|
584
|
+
], OscdLayout.prototype, "editor", void 0);
|
|
585
|
+
__decorate([
|
|
586
|
+
property({ type: Array })
|
|
587
|
+
], OscdLayout.prototype, "plugins", void 0);
|
|
588
|
+
__decorate([
|
|
589
|
+
property({ type: Object })
|
|
590
|
+
], OscdLayout.prototype, "host", void 0);
|
|
591
|
+
__decorate([
|
|
592
|
+
state()
|
|
593
|
+
], OscdLayout.prototype, "validated", void 0);
|
|
594
|
+
__decorate([
|
|
595
|
+
state()
|
|
596
|
+
], OscdLayout.prototype, "shouldValidate", void 0);
|
|
597
|
+
__decorate([
|
|
598
|
+
state()
|
|
599
|
+
], OscdLayout.prototype, "activeEditor", void 0);
|
|
600
|
+
__decorate([
|
|
601
|
+
query('#menu')
|
|
602
|
+
], OscdLayout.prototype, "menuUI", void 0);
|
|
603
|
+
__decorate([
|
|
604
|
+
query('#menuContent')
|
|
605
|
+
], OscdLayout.prototype, "menuContent", void 0);
|
|
606
|
+
__decorate([
|
|
607
|
+
query('#pluginManager')
|
|
608
|
+
], OscdLayout.prototype, "pluginUI", void 0);
|
|
609
|
+
__decorate([
|
|
610
|
+
query('#pluginList')
|
|
611
|
+
], OscdLayout.prototype, "pluginList", void 0);
|
|
612
|
+
__decorate([
|
|
613
|
+
query('#pluginAdd')
|
|
614
|
+
], OscdLayout.prototype, "pluginDownloadUI", void 0);
|
|
615
|
+
OscdLayout = __decorate([
|
|
616
|
+
customElement('oscd-layout')
|
|
617
|
+
], OscdLayout);
|
|
618
|
+
export { OscdLayout };
|
|
619
|
+
//# sourceMappingURL=Layout.js.map
|