@compas-oscd/open-scd 0.34.16 → 0.34.18
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.d.ts +8 -8
- package/dist/WizardDivider.js +26 -26
- package/dist/Wizarding.js +36 -36
- package/dist/Wizarding.js.map +1 -1
- package/dist/action-icon.d.ts +25 -25
- package/dist/action-icon.js +51 -51
- package/dist/action-pane.d.ts +25 -25
- package/dist/action-pane.js +86 -86
- package/dist/addons/Editor.d.ts +25 -25
- package/dist/addons/Editor.js +105 -105
- package/dist/addons/Editor.js.map +1 -1
- package/dist/addons/History.d.ts +86 -93
- package/dist/addons/History.js +301 -302
- package/dist/addons/History.js.map +1 -1
- package/dist/addons/Layout.d.ts +96 -96
- package/dist/addons/Layout.js +448 -448
- package/dist/addons/Layout.js.map +1 -1
- package/dist/addons/Settings.d.ts +68 -68
- package/dist/addons/Settings.js +272 -272
- package/dist/addons/Settings.js.map +1 -1
- package/dist/addons/Waiter.d.ts +14 -14
- package/dist/addons/Waiter.js +40 -40
- package/dist/addons/Waiter.js.map +1 -1
- package/dist/addons/Wizards.d.ts +15 -15
- package/dist/addons/Wizards.js +46 -46
- package/dist/addons/editor/edit-action-to-v1-converter.d.ts +3 -3
- package/dist/addons/editor/edit-action-to-v1-converter.js +95 -95
- package/dist/addons/editor/edit-action-to-v1-converter.js.map +1 -1
- package/dist/addons/editor/edit-v1-to-v2-converter.d.ts +2 -2
- package/dist/addons/editor/edit-v1-to-v2-converter.js +36 -36
- package/dist/addons/editor/edit-v1-to-v2-converter.js.map +1 -1
- package/dist/addons/history/get-log-text.d.ts +5 -5
- package/dist/addons/history/get-log-text.js +25 -25
- package/dist/addons/history/get-log-text.js.map +1 -1
- package/dist/addons/menu-tabs/menu-tabs.d.ts +22 -22
- package/dist/addons/menu-tabs/menu-tabs.js +59 -59
- package/dist/addons/plugin-manager/custom-plugin-dialog.d.ts +28 -28
- package/dist/addons/plugin-manager/custom-plugin-dialog.js +71 -71
- package/dist/addons/plugin-manager/plugin-manager.d.ts +20 -20
- package/dist/addons/plugin-manager/plugin-manager.js +77 -77
- 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.d.ts +27 -27
- package/dist/filtered-list.js +118 -118
- package/dist/finder-list.d.ts +37 -37
- package/dist/finder-list.js +153 -153
- package/dist/foundation/compare.d.ts +79 -79
- package/dist/foundation/compare.js +216 -216
- package/dist/foundation/dai.d.ts +30 -30
- package/dist/foundation/dai.js +126 -126
- package/dist/foundation/generators.d.ts +13 -13
- package/dist/foundation/generators.js +66 -66
- package/dist/foundation/ied.d.ts +22 -22
- package/dist/foundation/ied.js +83 -83
- package/dist/foundation/ied.js.map +1 -1
- package/dist/foundation/nsd.d.ts +4 -4
- package/dist/foundation/nsd.js +12 -12
- package/dist/foundation/nsdoc.d.ts +14 -14
- package/dist/foundation/nsdoc.js +178 -178
- package/dist/foundation/scl.d.ts +1 -1
- package/dist/foundation/scl.js +63 -63
- package/dist/foundation.d.ts +230 -230
- package/dist/foundation.js +1921 -1921
- package/dist/foundation.js.map +1 -1
- package/dist/icons/compare.d.ts +3 -3
- package/dist/icons/compare.js +4 -4
- package/dist/icons/icons.d.ts +41 -41
- package/dist/icons/icons.js +92 -92
- package/dist/icons/ied-icons.d.ts +3 -3
- package/dist/icons/ied-icons.js +4 -4
- package/dist/icons/lnode.d.ts +16 -16
- package/dist/icons/lnode.js +17 -17
- package/dist/open-scd.d.ts +131 -131
- package/dist/open-scd.js +438 -438
- package/dist/open-scd.js.map +1 -1
- 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.d.ts +27 -27
- package/dist/oscd-filter-button.js +59 -59
- package/dist/plain-compare-list.d.ts +36 -36
- package/dist/plain-compare-list.js +70 -70
- package/dist/plugin-tag.d.ts +6 -6
- package/dist/plugin-tag.js +22 -22
- package/dist/plugin.d.ts +23 -23
- package/dist/plugin.events.d.ts +15 -15
- package/dist/plugin.events.js +11 -11
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +255 -255
- package/dist/schemas.d.ts +58 -58
- package/dist/schemas.js +59 -59
- package/dist/themes.d.ts +3 -3
- package/dist/themes.js +13 -13
- package/dist/themes.js.map +1 -1
- package/dist/translations/de.d.ts +2 -2
- package/dist/translations/de.js +952 -952
- package/dist/translations/en.d.ts +963 -963
- package/dist/translations/en.js +948 -948
- package/dist/translations/loader.d.ts +12 -12
- package/dist/translations/loader.js +9 -9
- package/dist/translations/loader.js.map +1 -1
- package/dist/wizard-checkbox.d.ts +37 -37
- package/dist/wizard-checkbox.js +130 -130
- package/dist/wizard-dialog.d.ts +45 -45
- package/dist/wizard-dialog.js +235 -235
- package/dist/wizard-dialog.js.map +1 -1
- package/dist/wizard-select.d.ts +31 -31
- package/dist/wizard-select.js +102 -102
- package/dist/wizard-textfield.d.ts +50 -50
- package/dist/wizard-textfield.js +162 -162
- package/dist/wizards.d.ts +23 -23
- package/dist/wizards.js +148 -148
- package/dist/wizards.js.map +1 -1
- 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 +29 -127
- package/dist/Wizarding.d.ts +0 -10
package/dist/addons/Layout.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
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 '@
|
|
5
|
-
import { newSettingsUIEvent } from '@
|
|
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() {
|
|
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
35
|
return html `
|
|
36
36
|
<div
|
|
37
37
|
@open-plugin-download=${() => this.pluginDownloadUI.show()}
|
|
@@ -42,239 +42,239 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
42
42
|
${this.renderHeader()} ${this.renderAside()} ${this.renderMenuContent()}
|
|
43
43
|
${this.renderContent()} ${this.renderLanding()} ${this.renderPlugging()}
|
|
44
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() {
|
|
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
56
|
return html `
|
|
57
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() {
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Renders the plug-in management UI (turning plug-ins on/off)
|
|
62
|
+
*/
|
|
63
|
+
renderPluginUI() {
|
|
64
64
|
return html `
|
|
65
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
|
-
}
|
|
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
278
|
return html `
|
|
279
279
|
<mwc-list-item
|
|
280
280
|
class="${me.kind}"
|
|
@@ -285,16 +285,16 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
285
285
|
.disabled=${me.disabled?.() || !me.action}
|
|
286
286
|
><mwc-icon slot="graphic">${me.icon}</mwc-icon>
|
|
287
287
|
<span>${get(me.name)}</span>
|
|
288
|
-
${me.hint
|
|
289
|
-
? html `<span slot="secondary"><tt>${me.hint}</tt></span>`
|
|
288
|
+
${me.hint
|
|
289
|
+
? html `<span slot="secondary"><tt>${me.hint}</tt></span>`
|
|
290
290
|
: ''}
|
|
291
291
|
</mwc-list-item>
|
|
292
|
-
`;
|
|
293
|
-
}
|
|
294
|
-
renderActionItem(me) {
|
|
295
|
-
if (me === 'divider' || !me.actionItem) {
|
|
296
|
-
return html ``;
|
|
297
|
-
}
|
|
292
|
+
`;
|
|
293
|
+
}
|
|
294
|
+
renderActionItem(me) {
|
|
295
|
+
if (me === 'divider' || !me.actionItem) {
|
|
296
|
+
return html ``;
|
|
297
|
+
}
|
|
298
298
|
return html `
|
|
299
299
|
<mwc-icon-button
|
|
300
300
|
slot="actionItems"
|
|
@@ -302,13 +302,13 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
302
302
|
label="${me.name}"
|
|
303
303
|
?disabled=${me.disabled?.() || !me.action}
|
|
304
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() {
|
|
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
312
|
return html `<mwc-top-app-bar-fixed>
|
|
313
313
|
<mwc-icon-button
|
|
314
314
|
icon="menu"
|
|
@@ -318,36 +318,36 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
318
318
|
></mwc-icon-button>
|
|
319
319
|
${this.renderTitle()}
|
|
320
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() {
|
|
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
338
|
return html `
|
|
339
339
|
<div id="menuContent">
|
|
340
|
-
${this.menu
|
|
341
|
-
.filter(p => p.content)
|
|
340
|
+
${this.menu
|
|
341
|
+
.filter(p => p.content)
|
|
342
342
|
.map(p => p.content())}
|
|
343
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() {
|
|
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
351
|
return html `
|
|
352
352
|
<mwc-drawer class="mdc-theme--surface" hasheader type="modal" id="menu">
|
|
353
353
|
<span slot="title">${get('menu.title')}</span>
|
|
@@ -359,39 +359,39 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
359
359
|
${this.menu.map(this.renderMenuItem)}
|
|
360
360
|
</mwc-list>
|
|
361
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
|
-
}
|
|
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
395
|
return html `
|
|
396
396
|
<oscd-menu-tabs
|
|
397
397
|
.editors=${this.calcActiveEditors()}
|
|
@@ -400,64 +400,64 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
400
400
|
>
|
|
401
401
|
</oscd-menu-tabs>
|
|
402
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
|
-
}
|
|
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
451
|
return html `
|
|
452
452
|
<div class="landing">
|
|
453
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
|
-
}
|
|
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
461
|
return html `
|
|
462
462
|
<mwc-icon-button
|
|
463
463
|
class="landing_icon"
|
|
@@ -466,15 +466,15 @@ let OscdLayout = class OscdLayout extends LitElement {
|
|
|
466
466
|
>
|
|
467
467
|
<div class="landing_label">${mi.name}</div>
|
|
468
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
|
-
};
|
|
469
|
+
`;
|
|
470
|
+
});
|
|
471
|
+
function clickListItem(index) {
|
|
472
|
+
const listItem = menuUI.querySelector('mwc-list').items[index];
|
|
473
|
+
listItem.click();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
478
|
OscdLayout.styles = css `
|
|
479
479
|
mwc-drawer {
|
|
480
480
|
position: absolute;
|
|
@@ -569,51 +569,51 @@ OscdLayout.styles = css `
|
|
|
569
569
|
.plugin.validator {
|
|
570
570
|
display: flex;
|
|
571
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 };
|
|
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
619
|
//# sourceMappingURL=Layout.js.map
|