@omicronenergy/oscd-shell 0.0.9 → 0.0.10
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/colors.d.ts +1 -0
- package/dist/colors.js +60 -0
- package/dist/colors.js.map +1 -0
- package/dist/foundation/cyrb64.js +0 -3
- package/dist/foundation/cyrb64.js.map +1 -1
- package/dist/foundation/events.d.ts +17 -0
- package/dist/foundation/events.js +2 -0
- package/dist/foundation/events.js.map +1 -0
- package/dist/foundation.js.map +1 -1
- package/dist/landing-page/landing-page.d.ts +26 -0
- package/dist/landing-page/landing-page.js +163 -0
- package/dist/landing-page/landing-page.js.map +1 -0
- package/dist/landing-page/landing-page.spec.d.ts +1 -0
- package/dist/landing-page/landing-page.spec.js +87 -0
- package/dist/landing-page/landing-page.spec.js.map +1 -0
- package/dist/locales/de.d.ts +0 -5
- package/dist/locales/de.js +0 -5
- package/dist/locales/de.js.map +1 -1
- package/dist/locales.js.map +1 -1
- package/dist/localization.d.ts +15 -0
- package/dist/localization.js +22 -0
- package/dist/localization.js.map +1 -0
- package/dist/menus/files-menu.d.ts +27 -0
- package/dist/menus/files-menu.js +102 -0
- package/dist/menus/files-menu.js.map +1 -0
- package/dist/menus/files-menu.spec.d.ts +1 -0
- package/dist/menus/files-menu.spec.js +33 -0
- package/dist/menus/files-menu.spec.js.map +1 -0
- package/dist/menus/plugins-menu.d.ts +32 -0
- package/dist/menus/plugins-menu.js +128 -0
- package/dist/menus/plugins-menu.js.map +1 -0
- package/dist/menus/plugins-menu.spec.d.ts +1 -0
- package/dist/menus/plugins-menu.spec.js +65 -0
- package/dist/menus/plugins-menu.spec.js.map +1 -0
- package/dist/oscd-shell.d.ts +70 -84
- package/dist/oscd-shell.js +378 -549
- package/dist/oscd-shell.js.map +1 -1
- package/dist/side-panel/editor-plugins-panel.d.ts +29 -0
- package/dist/side-panel/editor-plugins-panel.js +151 -0
- package/dist/side-panel/editor-plugins-panel.js.map +1 -0
- package/dist/side-panel/editor-plugins-panel.spec.d.ts +1 -0
- package/dist/side-panel/editor-plugins-panel.spec.js +87 -0
- package/dist/side-panel/editor-plugins-panel.spec.js.map +1 -0
- package/dist/theming.d.ts +1 -0
- package/dist/theming.js +76 -0
- package/dist/theming.js.map +1 -0
- package/dist/utils/plugin-utils.d.ts +1 -1
- package/dist/utils/plugin-utils.js +8 -11
- package/dist/utils/plugin-utils.js.map +1 -1
- package/dist/utils/plugin-utils.spec.js.map +1 -1
- package/dist/utils/testing/plugin-helpers.d.ts +24 -0
- package/dist/utils/testing/plugin-helpers.js +74 -0
- package/dist/utils/testing/plugin-helpers.js.map +1 -0
- package/dist/utils/testing/test-doc-helpers.d.ts +7 -0
- package/dist/utils/testing/test-doc-helpers.js +28 -0
- package/dist/utils/testing/test-doc-helpers.js.map +1 -0
- package/dist/utils/testing/test-plugins.d.ts +44 -0
- package/dist/utils/testing/test-plugins.js +56 -0
- package/dist/utils/testing/test-plugins.js.map +1 -0
- package/package.json +61 -125
- package/dist/AddPlugins.js +0 -39
- package/dist/DemoPluginSrc.js +0 -7
- package/dist/embedded.html +0 -17
- package/dist/index.html +0 -112
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement } from 'lit';
|
|
3
|
+
import { property, query } from 'lit/decorators.js';
|
|
4
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';
|
|
5
|
+
import { localized } from '@lit/localize';
|
|
6
|
+
import { OscdIcon } from '@omicronenergy/oscd-ui/icon/OscdIcon.js';
|
|
7
|
+
import { OscdMenu } from '@omicronenergy/oscd-ui/menu/OscdMenu.js';
|
|
8
|
+
import { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';
|
|
9
|
+
import { OscdTextButton } from '@omicronenergy/oscd-ui/button/OscdTextButton.js';
|
|
10
|
+
let FilesMenu = class FilesMenu extends ScopedElementsMixin(LitElement) {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/* Properties */
|
|
14
|
+
this.editableDocs = [];
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
return html `
|
|
18
|
+
<oscd-text-button
|
|
19
|
+
id="fileMenuButton"
|
|
20
|
+
@click=${() => this.menu.show()}
|
|
21
|
+
trailing-icon
|
|
22
|
+
>
|
|
23
|
+
${this.selectedDocName}
|
|
24
|
+
<oscd-icon slot="icon">code</oscd-icon></oscd-filled-icon-button
|
|
25
|
+
>
|
|
26
|
+
</oscd-text-button>
|
|
27
|
+
|
|
28
|
+
<oscd-menu
|
|
29
|
+
fixed
|
|
30
|
+
id="fileMenu"
|
|
31
|
+
anchor="fileMenuButton"
|
|
32
|
+
corner="BOTTOM_END"
|
|
33
|
+
>
|
|
34
|
+
${this.editableDocs.map(name => html `<oscd-menu-item
|
|
35
|
+
@click=${() => {
|
|
36
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
37
|
+
bubbles: true,
|
|
38
|
+
composed: true,
|
|
39
|
+
detail: { name },
|
|
40
|
+
}));
|
|
41
|
+
}}
|
|
42
|
+
?selected=${this.selectedDocName === name}
|
|
43
|
+
>${name}</oscd-menu-item
|
|
44
|
+
>`)}
|
|
45
|
+
</oscd-menu>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
FilesMenu.scopedElements = {
|
|
50
|
+
'oscd-text-button': OscdTextButton,
|
|
51
|
+
'oscd-icon': OscdIcon,
|
|
52
|
+
'oscd-menu': OscdMenu,
|
|
53
|
+
'oscd-menu-item': OscdMenuItem,
|
|
54
|
+
};
|
|
55
|
+
FilesMenu.styles = css `
|
|
56
|
+
:host {
|
|
57
|
+
position: relative;
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
gap: 4px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:host oscd-text-button {
|
|
64
|
+
--md-text-button-label-text-line-height: normal;
|
|
65
|
+
--md-text-button-label-text-family: 'Roboto';
|
|
66
|
+
--md-text-button-label-text-weight: 500;
|
|
67
|
+
--md-text-button-label-text-size: 18px;
|
|
68
|
+
--md-text-button-label-text-style: normal;
|
|
69
|
+
--md-sys-color-primary: var(--oscd-base3);
|
|
70
|
+
display: inline;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host oscd-text-button oscd-icon {
|
|
74
|
+
transform: rotate(90deg);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
oscd-menu {
|
|
78
|
+
min-width: 350px;
|
|
79
|
+
padding: 12px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
oscd-menu-item {
|
|
83
|
+
width: 100%;
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
__decorate([
|
|
87
|
+
property({ type: Array })
|
|
88
|
+
], FilesMenu.prototype, "editableDocs", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
property({ type: String })
|
|
91
|
+
], FilesMenu.prototype, "selectedDocName", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ type: String, reflect: true })
|
|
94
|
+
], FilesMenu.prototype, "locale", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
query('#fileMenu')
|
|
97
|
+
], FilesMenu.prototype, "menu", void 0);
|
|
98
|
+
FilesMenu = __decorate([
|
|
99
|
+
localized()
|
|
100
|
+
], FilesMenu);
|
|
101
|
+
export { FilesMenu };
|
|
102
|
+
//# sourceMappingURL=files-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-menu.js","sourceRoot":"","sources":["../../src/menus/files-menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO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AE,MAAM,EAAE,CAAC;kDACS;AAGpC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCACvB;AAKnB;IADC,KAAK,CAAC,WAAW,CAAC;uCACH;AAtBL,SAAS;IADrB,SAAS,EAAE;GACC,SAAS,CA6FrB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\nimport { localized } from '@lit/localize';\n\nimport { OscdIcon } from '@omicronenergy/oscd-ui/icon/OscdIcon.js';\nimport { OscdMenu } from '@omicronenergy/oscd-ui/menu/OscdMenu.js';\nimport { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';\nimport { OscdTextButton } from '@omicronenergy/oscd-ui/button/OscdTextButton.js';\n\nimport { LocaleTag } from '../localization.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'files-menu': FilesMenu;\n }\n}\n@localized()\nexport class FilesMenu extends ScopedElementsMixin(LitElement) {\n static scopedElements = {\n 'oscd-text-button': OscdTextButton,\n 'oscd-icon': OscdIcon,\n 'oscd-menu': OscdMenu,\n 'oscd-menu-item': OscdMenuItem,\n };\n\n /* Properties */\n\n @property({ type: Array })\n editableDocs: string[] = [];\n\n @property({ type: String })\n selectedDocName: string | undefined;\n\n @property({ type: String, reflect: true })\n locale!: LocaleTag;\n\n /* Queries */\n\n @query('#fileMenu')\n menu!: OscdMenu;\n\n render() {\n return html`\n <oscd-text-button\n id=\"fileMenuButton\"\n @click=${() => this.menu.show()}\n trailing-icon\n >\n ${this.selectedDocName}\n <oscd-icon slot=\"icon\">code</oscd-icon></oscd-filled-icon-button\n >\n </oscd-text-button>\n\n <oscd-menu\n fixed\n id=\"fileMenu\"\n anchor=\"fileMenuButton\"\n corner=\"BOTTOM_END\"\n >\n ${this.editableDocs.map(\n name =>\n html`<oscd-menu-item\n @click=${() => {\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true,\n detail: { name },\n }),\n );\n }}\n ?selected=${this.selectedDocName === name}\n >${name}</oscd-menu-item\n >`,\n )}\n </oscd-menu>\n `;\n }\n\n static styles = css`\n :host {\n position: relative;\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n :host oscd-text-button {\n --md-text-button-label-text-line-height: normal;\n --md-text-button-label-text-family: 'Roboto';\n --md-text-button-label-text-weight: 500;\n --md-text-button-label-text-size: 18px;\n --md-text-button-label-text-style: normal;\n --md-sys-color-primary: var(--oscd-base3);\n display: inline;\n }\n\n :host oscd-text-button oscd-icon {\n transform: rotate(90deg);\n }\n\n oscd-menu {\n min-width: 350px;\n padding: 12px;\n }\n\n oscd-menu-item {\n width: 100%;\n }\n `;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../oscd-shell.js';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import '../oscd-shell.js';
|
|
3
|
+
import { createTestDocs } from '../utils/testing/test-doc-helpers.js';
|
|
4
|
+
describe('files-menu', () => {
|
|
5
|
+
let oscdShell;
|
|
6
|
+
let filesMenu;
|
|
7
|
+
let docs;
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
docs = createTestDocs(3);
|
|
10
|
+
oscdShell = (await fixture(html `<oscd-shell
|
|
11
|
+
.docs=${docs}
|
|
12
|
+
docName=${Object.keys(docs)[0]}
|
|
13
|
+
></oscd-shell>`));
|
|
14
|
+
filesMenu = oscdShell.shadowRoot.querySelector('files-menu');
|
|
15
|
+
await oscdShell.updateComplete;
|
|
16
|
+
await filesMenu.updateComplete;
|
|
17
|
+
});
|
|
18
|
+
it('allows the user to switch documents', async () => {
|
|
19
|
+
const fileDropdownButton = filesMenu.shadowRoot?.querySelector('oscd-text-button');
|
|
20
|
+
expect(fileDropdownButton).to.exist;
|
|
21
|
+
fileDropdownButton?.click();
|
|
22
|
+
await filesMenu.updateComplete;
|
|
23
|
+
filesMenu.menu.firstElementChild.click();
|
|
24
|
+
await oscdShell.updateComplete;
|
|
25
|
+
const oldDocName = oscdShell.docName;
|
|
26
|
+
fileDropdownButton?.click();
|
|
27
|
+
await filesMenu.updateComplete;
|
|
28
|
+
filesMenu.menu.lastElementChild.click();
|
|
29
|
+
await oscdShell.updateComplete;
|
|
30
|
+
expect(oscdShell).to.not.have.property('docName', oldDocName);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=files-menu.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-menu.spec.js","sourceRoot":"","sources":["../../src/menus/files-menu.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIzD,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAGtE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,SAAoB,CAAC;IACzB,IAAI,SAAoB,CAAC;IACzB,IAAI,IAAiC,CAAC;IAEtC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,IAAI,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;QACzB,SAAS,GAAc,CACrB,MAAM,OAAO,CACX,IAAI,CAAA;kBACM,IAAI;oBACF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;uBACjB,CAChB,CACF,CAAC;QACF,SAAS,GAAG,SAAS,CAAC,UAAW,CAAC,aAAa,CAAC,YAAY,CAAE,CAAC;QAC/D,MAAM,SAAS,CAAC,cAAc,CAAC;QAC/B,MAAM,SAAS,CAAC,cAAc,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,kBAAkB,GACtB,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;QAC1D,MAAM,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACpC,kBAAkB,EAAE,KAAK,EAAE,CAAC;QAC5B,MAAM,SAAS,CAAC,cAAc,CAAC;QAC9B,SAAS,CAAC,IAAI,CAAC,iBAAkC,CAAC,KAAK,EAAE,CAAC;QAC3D,MAAM,SAAS,CAAC,cAAc,CAAC;QAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC;QACrC,kBAAkB,EAAE,KAAK,EAAE,CAAC;QAC5B,MAAM,SAAS,CAAC,cAAc,CAAC;QAC9B,SAAS,CAAC,IAAI,CAAC,gBAAiC,CAAC,KAAK,EAAE,CAAC;QAC1D,MAAM,SAAS,CAAC,cAAc,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\nimport { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';\nimport type { OscdShell } from '../oscd-shell.js';\n\nimport '../oscd-shell.js';\nimport { createTestDocs } from '../utils/testing/test-doc-helpers.js';\nimport { FilesMenu } from './files-menu.js';\n\ndescribe('files-menu', () => {\n let oscdShell: OscdShell;\n let filesMenu: FilesMenu;\n let docs: Record<string, XMLDocument>;\n\n beforeEach(async () => {\n docs = createTestDocs(3);\n oscdShell = <OscdShell>(\n await fixture(\n html`<oscd-shell\n .docs=${docs}\n docName=${Object.keys(docs)[0]}\n ></oscd-shell>`,\n )\n );\n filesMenu = oscdShell.shadowRoot!.querySelector('files-menu')!;\n await oscdShell.updateComplete;\n await filesMenu.updateComplete;\n });\n\n it('allows the user to switch documents', async () => {\n const fileDropdownButton =\n filesMenu.shadowRoot?.querySelector('oscd-text-button');\n expect(fileDropdownButton).to.exist;\n fileDropdownButton?.click();\n await filesMenu.updateComplete;\n (filesMenu.menu.firstElementChild as OscdMenuItem).click();\n await oscdShell.updateComplete;\n const oldDocName = oscdShell.docName;\n fileDropdownButton?.click();\n await filesMenu.updateComplete;\n (filesMenu.menu.lastElementChild as OscdMenuItem).click();\n await oscdShell.updateComplete;\n expect(oscdShell).to.not.have.property('docName', oldDocName);\n });\n});\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { OscdFilledIconButton } from '@omicronenergy/oscd-ui/iconbutton/OscdFilledIconButton.js';
|
|
3
|
+
import { OscdIcon } from '@omicronenergy/oscd-ui/icon/OscdIcon.js';
|
|
4
|
+
import { OscdMenu } from '@omicronenergy/oscd-ui/menu/OscdMenu.js';
|
|
5
|
+
import { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';
|
|
6
|
+
import { LocaleTag } from '../localization.js';
|
|
7
|
+
import { PluginEntry } from '../oscd-shell.js';
|
|
8
|
+
declare global {
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'plugin-menu': PluginsMenu;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
declare const PluginsMenu_base: typeof LitElement & import("@open-wc/scoped-elements/lit-element.js").ScopedElementsHostConstructor;
|
|
14
|
+
export declare class PluginsMenu extends PluginsMenu_base {
|
|
15
|
+
static scopedElements: {
|
|
16
|
+
'oscd-filled-icon-button': typeof OscdFilledIconButton;
|
|
17
|
+
'oscd-icon': typeof OscdIcon;
|
|
18
|
+
'oscd-menu': typeof OscdMenu;
|
|
19
|
+
'oscd-menu-item': typeof OscdMenuItem;
|
|
20
|
+
};
|
|
21
|
+
editableDocs: string[];
|
|
22
|
+
menuPlugins: PluginEntry[];
|
|
23
|
+
appIcon: string;
|
|
24
|
+
appTitle: string;
|
|
25
|
+
locale: LocaleTag;
|
|
26
|
+
open: () => void;
|
|
27
|
+
menu: OscdMenu;
|
|
28
|
+
renderMenuItem(plugin: PluginEntry, disabled: boolean): import("lit-html").TemplateResult<1>;
|
|
29
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
30
|
+
static styles: import("lit").CSSResult;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
+
import { property, query } from 'lit/decorators.js';
|
|
4
|
+
import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';
|
|
5
|
+
import { localized, msg } from '@lit/localize';
|
|
6
|
+
import { OscdFilledIconButton } from '@omicronenergy/oscd-ui/iconbutton/OscdFilledIconButton.js';
|
|
7
|
+
import { OscdIcon } from '@omicronenergy/oscd-ui/icon/OscdIcon.js';
|
|
8
|
+
import { OscdMenu } from '@omicronenergy/oscd-ui/menu/OscdMenu.js';
|
|
9
|
+
import { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';
|
|
10
|
+
let PluginsMenu = class PluginsMenu extends ScopedElementsMixin(LitElement) {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/* Properties */
|
|
14
|
+
this.editableDocs = [];
|
|
15
|
+
this.menuPlugins = [];
|
|
16
|
+
this.open = () => {
|
|
17
|
+
this.menu.show();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
renderMenuItem(plugin, disabled) {
|
|
21
|
+
return html `
|
|
22
|
+
<oscd-menu-item
|
|
23
|
+
.disabled=${disabled}
|
|
24
|
+
@click=${() => {
|
|
25
|
+
this.dispatchEvent(new CustomEvent('menu-plugin-select', {
|
|
26
|
+
detail: { plugin },
|
|
27
|
+
bubbles: true,
|
|
28
|
+
composed: true,
|
|
29
|
+
}));
|
|
30
|
+
this.menu.close();
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<oscd-icon slot="start">${plugin.icon}</oscd-icon>
|
|
34
|
+
<div slot="headline">
|
|
35
|
+
${plugin.translations?.[this.locale] || plugin.name}
|
|
36
|
+
</div>
|
|
37
|
+
</oscd-menu-item>
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
return html `
|
|
42
|
+
${this.appIcon ? html `<img src=${this.appIcon} alt="logo" />` : nothing}
|
|
43
|
+
<h1 class="app-title">${this.appTitle}</h1>
|
|
44
|
+
<oscd-filled-icon-button
|
|
45
|
+
id="menu-button"
|
|
46
|
+
aria-label="${msg('Menu')}"
|
|
47
|
+
@click=${async () => {
|
|
48
|
+
if (this.menu.open) {
|
|
49
|
+
this.menu.close();
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
this.menu.show();
|
|
53
|
+
}
|
|
54
|
+
}}
|
|
55
|
+
><oscd-icon>arrow_drop_down_circle</oscd-icon></oscd-filled-icon-button
|
|
56
|
+
>
|
|
57
|
+
<oscd-menu
|
|
58
|
+
quick
|
|
59
|
+
anchor="menu-button"
|
|
60
|
+
menuCorner="START_END"
|
|
61
|
+
anchorCorner="START_END"
|
|
62
|
+
>
|
|
63
|
+
${this.menuPlugins.map(plugin => this.renderMenuItem(plugin, !!(plugin.requireDoc && (this.editableDocs ?? []).length === 0)))}
|
|
64
|
+
</oscd-menu>
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
PluginsMenu.scopedElements = {
|
|
69
|
+
'oscd-filled-icon-button': OscdFilledIconButton,
|
|
70
|
+
'oscd-icon': OscdIcon,
|
|
71
|
+
'oscd-menu': OscdMenu,
|
|
72
|
+
'oscd-menu-item': OscdMenuItem,
|
|
73
|
+
};
|
|
74
|
+
PluginsMenu.styles = css `
|
|
75
|
+
:host {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 4px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
img {
|
|
82
|
+
height: 34.4px;
|
|
83
|
+
width: auto;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host h1.app-title {
|
|
87
|
+
font-family: Roboto;
|
|
88
|
+
font-size: 22.114px;
|
|
89
|
+
font-style: normal;
|
|
90
|
+
font-weight: 400;
|
|
91
|
+
line-height: normal;
|
|
92
|
+
display: inline;
|
|
93
|
+
}
|
|
94
|
+
oscd-menu {
|
|
95
|
+
min-width: 350px;
|
|
96
|
+
padding: 12px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
oscd-menu-item {
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Array })
|
|
105
|
+
], PluginsMenu.prototype, "editableDocs", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
property({ type: Array })
|
|
108
|
+
], PluginsMenu.prototype, "menuPlugins", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: String })
|
|
111
|
+
], PluginsMenu.prototype, "appIcon", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: String })
|
|
114
|
+
], PluginsMenu.prototype, "appTitle", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String, reflect: true })
|
|
117
|
+
], PluginsMenu.prototype, "locale", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
property({ type: String, reflect: true })
|
|
120
|
+
], PluginsMenu.prototype, "open", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
query('oscd-menu')
|
|
123
|
+
], PluginsMenu.prototype, "menu", void 0);
|
|
124
|
+
PluginsMenu = __decorate([
|
|
125
|
+
localized()
|
|
126
|
+
], PluginsMenu);
|
|
127
|
+
export { PluginsMenu };
|
|
128
|
+
//# sourceMappingURL=plugins-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins-menu.js","sourceRoot":"","sources":["../../src/menus/plugins-menu.ts"],"names":[],"mappings":";AAAA,OAAO,EAA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IAAI,EAAE,CAAC;2CACvB;AAGnB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAGxC;AAIF;IADC,KAAK,CAAC,WAAW,CAAC;yCACH;AA/BL,WAAW;IADvB,SAAS,EAAE;GACC,WAAW,CAqHvB","sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';\nimport { localized, msg } from '@lit/localize';\n\nimport { OscdFilledIconButton } from '@omicronenergy/oscd-ui/iconbutton/OscdFilledIconButton.js';\nimport { OscdIcon } from '@omicronenergy/oscd-ui/icon/OscdIcon.js';\nimport { OscdMenu } from '@omicronenergy/oscd-ui/menu/OscdMenu.js';\nimport { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';\n\nimport { LocaleTag, Translation } from '../localization.js';\nimport { PluginEntry } from '../oscd-shell.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'plugin-menu': PluginsMenu;\n }\n}\n\n@localized()\nexport class PluginsMenu extends ScopedElementsMixin(LitElement) {\n static scopedElements = {\n 'oscd-filled-icon-button': OscdFilledIconButton,\n 'oscd-icon': OscdIcon,\n 'oscd-menu': OscdMenu,\n 'oscd-menu-item': OscdMenuItem,\n };\n\n /* Properties */\n @property({ type: Array })\n editableDocs: string[] = [];\n\n @property({ type: Array })\n menuPlugins: PluginEntry[] = [];\n\n @property({ type: String })\n appIcon!: string;\n\n @property({ type: String })\n appTitle!: string;\n\n @property({ type: String, reflect: true })\n locale!: LocaleTag;\n\n @property({ type: String, reflect: true })\n open = () => {\n this.menu.show();\n };\n\n /* Queries */\n @query('oscd-menu')\n menu!: OscdMenu;\n\n renderMenuItem(plugin: PluginEntry, disabled: boolean) {\n return html`\n <oscd-menu-item\n .disabled=${disabled}\n @click=${() => {\n this.dispatchEvent(\n new CustomEvent('menu-plugin-select', {\n detail: { plugin },\n bubbles: true,\n composed: true,\n }),\n );\n this.menu.close();\n }}\n >\n <oscd-icon slot=\"start\">${plugin.icon}</oscd-icon>\n <div slot=\"headline\">\n ${plugin.translations?.[this.locale as Translation] || plugin.name}\n </div>\n </oscd-menu-item>\n `;\n }\n\n render() {\n return html`\n ${this.appIcon ? html`<img src=${this.appIcon} alt=\"logo\" />` : nothing}\n <h1 class=\"app-title\">${this.appTitle}</h1>\n <oscd-filled-icon-button\n id=\"menu-button\"\n aria-label=\"${msg('Menu')}\"\n @click=${async () => {\n if (this.menu.open) {\n this.menu.close();\n } else {\n this.menu.show();\n }\n }}\n ><oscd-icon>arrow_drop_down_circle</oscd-icon></oscd-filled-icon-button\n >\n <oscd-menu\n quick\n anchor=\"menu-button\"\n menuCorner=\"START_END\"\n anchorCorner=\"START_END\"\n >\n ${this.menuPlugins.map(plugin =>\n this.renderMenuItem(\n plugin,\n !!(plugin.requireDoc && (this.editableDocs ?? []).length === 0),\n ),\n )}\n </oscd-menu>\n `;\n }\n\n static styles = css`\n :host {\n display: flex;\n align-items: center;\n gap: 4px;\n }\n\n img {\n height: 34.4px;\n width: auto;\n }\n\n :host h1.app-title {\n font-family: Roboto;\n font-size: 22.114px;\n font-style: normal;\n font-weight: 400;\n line-height: normal;\n display: inline;\n }\n oscd-menu {\n min-width: 350px;\n padding: 12px;\n }\n\n oscd-menu-item {\n width: 100%;\n }\n `;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../oscd-shell.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
|
2
|
+
import '../oscd-shell.js';
|
|
3
|
+
import { createTestDocs } from '../utils/testing/test-doc-helpers.js';
|
|
4
|
+
import sinon from 'sinon';
|
|
5
|
+
import { sampleMenuPlugins } from '../utils/testing/plugin-helpers.js';
|
|
6
|
+
import { TestMenuPlugin1 } from '../utils/testing/test-plugins.js';
|
|
7
|
+
const findMenuOpenButton = (pluginsMenu) => {
|
|
8
|
+
const menuOpenButton = pluginsMenu.shadowRoot?.querySelector('oscd-filled-icon-button');
|
|
9
|
+
expect(menuOpenButton).to.exist;
|
|
10
|
+
return menuOpenButton;
|
|
11
|
+
};
|
|
12
|
+
describe('plugins-menu', () => {
|
|
13
|
+
let oscdShell;
|
|
14
|
+
let pluginsMenu;
|
|
15
|
+
let docs;
|
|
16
|
+
beforeEach(async () => {
|
|
17
|
+
docs = createTestDocs(1);
|
|
18
|
+
oscdShell = (await fixture(html `<oscd-shell
|
|
19
|
+
.docs=${docs}
|
|
20
|
+
docName=${Object.keys(docs)[0]}
|
|
21
|
+
></oscd-shell>`));
|
|
22
|
+
if (!oscdShell.registry?.get('test-menu-plugin1')) {
|
|
23
|
+
oscdShell.registry?.define('test-menu-plugin1', TestMenuPlugin1);
|
|
24
|
+
}
|
|
25
|
+
oscdShell.plugins = {
|
|
26
|
+
menu: sampleMenuPlugins,
|
|
27
|
+
};
|
|
28
|
+
pluginsMenu = oscdShell.shadowRoot.querySelector('plugins-menu');
|
|
29
|
+
await oscdShell.updateComplete;
|
|
30
|
+
await pluginsMenu.updateComplete;
|
|
31
|
+
});
|
|
32
|
+
it('displays a menu item for each menu plugin', async () => {
|
|
33
|
+
const menuOpenButton = findMenuOpenButton(pluginsMenu);
|
|
34
|
+
menuOpenButton?.click();
|
|
35
|
+
await pluginsMenu.updateComplete;
|
|
36
|
+
expect(pluginsMenu.menu).to.have.property('open', true);
|
|
37
|
+
expect(pluginsMenu.menu.children).to.have.length(oscdShell.plugins.menu.length);
|
|
38
|
+
});
|
|
39
|
+
it('executes the run() function of the associated plugin, when the plugin menu item is clicked', async () => {
|
|
40
|
+
const menuPluginSelectSpy = sinon.spy();
|
|
41
|
+
pluginsMenu.addEventListener('menu-plugin-select', menuPluginSelectSpy);
|
|
42
|
+
const pluginRunSpy = sinon.spy();
|
|
43
|
+
const menuPluginEntry = pluginsMenu.menuPlugins[0];
|
|
44
|
+
const firstMenuPlugin = oscdShell.shadowRoot.querySelector(menuPluginEntry.tagName);
|
|
45
|
+
firstMenuPlugin.run = pluginRunSpy;
|
|
46
|
+
const menuOpenButton = findMenuOpenButton(pluginsMenu);
|
|
47
|
+
menuOpenButton?.click();
|
|
48
|
+
await pluginsMenu.updateComplete;
|
|
49
|
+
const firstMenuItem = pluginsMenu.menu.firstElementChild;
|
|
50
|
+
firstMenuItem.click();
|
|
51
|
+
await pluginsMenu.updateComplete;
|
|
52
|
+
expect(pluginRunSpy.calledOnce).to.be.true;
|
|
53
|
+
});
|
|
54
|
+
it('closes when clicking on the menu button, if its currently open', async () => {
|
|
55
|
+
const menuOpenButton = findMenuOpenButton(pluginsMenu);
|
|
56
|
+
menuOpenButton?.click();
|
|
57
|
+
await pluginsMenu.updateComplete;
|
|
58
|
+
expect(pluginsMenu.menu).to.have.property('open', true);
|
|
59
|
+
// Click again to close
|
|
60
|
+
menuOpenButton?.click();
|
|
61
|
+
await pluginsMenu.updateComplete;
|
|
62
|
+
expect(pluginsMenu.menu).to.have.property('open', false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=plugins-menu.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins-menu.spec.js","sourceRoot":"","sources":["../../src/menus/plugins-menu.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGzD,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEnE,MAAM,kBAAkB,GAAG,CAAC,WAAwB,EAAE,EAAE;IACtD,MAAM,cAAc,GAAG,WAAW,CAAC,UAAU,EAAE,aA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AAC;QAExD,uBAAuB;QACvB,cAAc,EAAE,KAAK,EAAE,CAAC;QACxB,MAAM,WAAW,CAAC,cAAc,CAAC;QACjC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture, html } from '@open-wc/testing';\nimport { OscdMenuItem } from '@omicronenergy/oscd-ui/menu/OscdMenuItem.js';\nimport type { OscdShell } from '../oscd-shell.js';\nimport '../oscd-shell.js';\nimport { PluginsMenu } from './plugins-menu.js';\nimport { createTestDocs } from '../utils/testing/test-doc-helpers.js';\nimport { OscdFilledIconButton } from '@omicronenergy/oscd-ui/iconbutton/OscdFilledIconButton.js';\nimport sinon from 'sinon';\nimport { LitElement } from 'lit';\nimport { sampleMenuPlugins } from '../utils/testing/plugin-helpers.js';\nimport { TestMenuPlugin1 } from '../utils/testing/test-plugins.js';\n\nconst findMenuOpenButton = (pluginsMenu: PluginsMenu) => {\n const menuOpenButton = pluginsMenu.shadowRoot?.querySelector(\n 'oscd-filled-icon-button',\n ) as OscdFilledIconButton;\n expect(menuOpenButton).to.exist;\n return menuOpenButton;\n};\n\ndescribe('plugins-menu', () => {\n let oscdShell: OscdShell;\n let pluginsMenu: PluginsMenu;\n let docs: Record<string, XMLDocument>;\n\n beforeEach(async () => {\n docs = createTestDocs(1);\n oscdShell = <OscdShell>(\n await fixture(\n html`<oscd-shell\n .docs=${docs}\n docName=${Object.keys(docs)[0]}\n ></oscd-shell>`,\n )\n );\n if (!oscdShell.registry?.get('test-menu-plugin1')) {\n oscdShell.registry?.define('test-menu-plugin1', TestMenuPlugin1);\n }\n oscdShell.plugins = {\n menu: sampleMenuPlugins,\n };\n pluginsMenu = oscdShell.shadowRoot!.querySelector('plugins-menu')!;\n await oscdShell.updateComplete;\n await pluginsMenu.updateComplete;\n });\n\n it('displays a menu item for each menu plugin', async () => {\n const menuOpenButton = findMenuOpenButton(pluginsMenu);\n menuOpenButton?.click();\n await pluginsMenu.updateComplete;\n expect(pluginsMenu.menu).to.have.property('open', true);\n expect(pluginsMenu.menu.children).to.have.length(\n oscdShell.plugins!.menu.length,\n );\n });\n\n it('executes the run() function of the associated plugin, when the plugin menu item is clicked', async () => {\n const menuPluginSelectSpy = sinon.spy();\n pluginsMenu.addEventListener('menu-plugin-select', menuPluginSelectSpy);\n\n const pluginRunSpy = sinon.spy();\n const menuPluginEntry = pluginsMenu.menuPlugins[0];\n const firstMenuPlugin = oscdShell.shadowRoot!.querySelector(\n menuPluginEntry.tagName,\n )! as unknown as LitElement & {\n run: () => void;\n };\n firstMenuPlugin.run = pluginRunSpy;\n\n const menuOpenButton = findMenuOpenButton(pluginsMenu);\n menuOpenButton?.click();\n await pluginsMenu.updateComplete;\n\n const firstMenuItem = pluginsMenu.menu.firstElementChild as OscdMenuItem;\n firstMenuItem.click();\n await pluginsMenu.updateComplete;\n\n expect(pluginRunSpy.calledOnce).to.be.true;\n });\n\n it('closes when clicking on the menu button, if its currently open', async () => {\n const menuOpenButton = findMenuOpenButton(pluginsMenu);\n menuOpenButton?.click();\n await pluginsMenu.updateComplete;\n expect(pluginsMenu.menu).to.have.property('open', true);\n\n // Click again to close\n menuOpenButton?.click();\n await pluginsMenu.updateComplete;\n expect(pluginsMenu.menu).to.have.property('open', false);\n });\n});\n"]}
|
package/dist/oscd-shell.d.ts
CHANGED
|
@@ -1,49 +1,25 @@
|
|
|
1
|
-
import '
|
|
2
|
-
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';
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { OscdFilledIconButton } from '@omicronenergy/oscd-ui/iconbutton/OscdFilledIconButton.js';
|
|
24
3
|
import { XMLEditor } from '@omicronenergy/oscd-editor';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
editCount: number;
|
|
35
|
-
locale: string;
|
|
36
|
-
}
|
|
4
|
+
import { EditEventV2, OpenEvent } from '@openscd/oscd-api';
|
|
5
|
+
import { LocaleTag, Translations } from './localization.js';
|
|
6
|
+
import { EditorPluginsPanel } from './side-panel/editor-plugins-panel.js';
|
|
7
|
+
import { PluginsMenu } from './menus/plugins-menu.js';
|
|
8
|
+
import { LandingPage } from './landing-page/landing-page.js';
|
|
9
|
+
import { RenameEvent, CloseEvent } from './foundation/events.js';
|
|
10
|
+
import { FilesMenu } from './menus/files-menu.js';
|
|
11
|
+
import { OscdAppBar } from '@omicronenergy/oscd-ui/app-bar/OscdAppBar.js';
|
|
12
|
+
import { OscdIcon } from '@omicronenergy/oscd-ui/icon/OscdIcon.js';
|
|
37
13
|
export type PluginEntry = {
|
|
38
14
|
name: string;
|
|
39
|
-
translations?:
|
|
15
|
+
translations?: Translations;
|
|
40
16
|
tagName: string;
|
|
41
17
|
icon: string;
|
|
42
18
|
requireDoc?: boolean;
|
|
43
19
|
};
|
|
44
20
|
export type SourcedPluginEntry = {
|
|
45
21
|
name: string;
|
|
46
|
-
translations?:
|
|
22
|
+
translations?: Translations;
|
|
47
23
|
src: string;
|
|
48
24
|
icon: string;
|
|
49
25
|
requireDoc?: boolean;
|
|
@@ -53,67 +29,77 @@ export type PluginSet<P = PluginEntry> = {
|
|
|
53
29
|
editor: P[];
|
|
54
30
|
background: P[];
|
|
55
31
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
32
|
+
declare const OscdShell_base: typeof LitElement & import("@open-wc/scoped-elements/lit-element.js").ScopedElementsHostConstructor;
|
|
33
|
+
export declare class OscdShell extends OscdShell_base {
|
|
34
|
+
static scopedElements: {
|
|
35
|
+
'oscd-app-bar': typeof OscdAppBar;
|
|
36
|
+
'oscd-filled-icon-button': typeof OscdFilledIconButton;
|
|
37
|
+
'oscd-icon': typeof OscdIcon;
|
|
38
|
+
'files-menu': typeof FilesMenu;
|
|
39
|
+
'plugins-menu': typeof PluginsMenu;
|
|
40
|
+
'editor-plugins-panel': typeof EditorPluginsPanel;
|
|
41
|
+
'landing-page': typeof LandingPage;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Url to the app icon displayed in the app bar
|
|
45
|
+
*/
|
|
46
|
+
appIcon: string;
|
|
47
|
+
appTitle: string;
|
|
48
|
+
landingPageHeading: string;
|
|
49
|
+
landingPageSubHeading: string;
|
|
68
50
|
/** The file endings of editable files */
|
|
69
51
|
editable: string[];
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
get locale(): LocaleTag;
|
|
53
|
+
set locale(tag: LocaleTag);
|
|
54
|
+
_plugins: PluginSet;
|
|
55
|
+
get plugins(): PluginSet;
|
|
56
|
+
set plugins(plugins: Partial<PluginSet<Partial<PluginEntry | SourcedPluginEntry>>>);
|
|
57
|
+
get canRedo(): boolean;
|
|
58
|
+
get canUndo(): boolean;
|
|
59
|
+
get editor(): string;
|
|
60
|
+
private editorIndex;
|
|
61
|
+
get doc(): XMLDocument;
|
|
62
|
+
/** The name of the [[`doc`]] currently being edited */
|
|
63
|
+
docName: string;
|
|
73
64
|
/** The set of `XMLDocument`s currently loaded */
|
|
65
|
+
private _docs;
|
|
74
66
|
get docs(): Record<string, XMLDocument>;
|
|
75
67
|
set docs(newDocs: Record<string, XMLDocument>);
|
|
76
|
-
onDocsChanged(): void;
|
|
77
|
-
/** The name of the [[`doc`]] currently being edited */
|
|
78
|
-
docName: string;
|
|
79
|
-
get doc(): XMLDocument;
|
|
80
|
-
xmlEditor: XMLEditor;
|
|
81
68
|
docVersion: number;
|
|
69
|
+
get editableDocs(): string[];
|
|
82
70
|
get last(): number;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
xmlEditor: XMLEditor;
|
|
72
|
+
pluginsMenu: PluginsMenu;
|
|
73
|
+
editorPluginsPanel: EditorPluginsPanel;
|
|
74
|
+
private _landingPageNodes?;
|
|
75
|
+
constructor();
|
|
76
|
+
connectedCallback(): void;
|
|
77
|
+
disconnectedCallback(): void;
|
|
78
|
+
handleOpenDoc: ({ detail: { docName, doc } }: OpenEvent) => void;
|
|
79
|
+
handleRenameDoc: (customEvent: RenameEvent) => void;
|
|
80
|
+
handleEditV2: (event: EditEventV2) => void;
|
|
81
|
+
handleCloseDoc: (event: CloseEvent) => void;
|
|
82
|
+
handleUndo: () => void;
|
|
83
|
+
handleRedo: () => void;
|
|
84
|
+
private handleKeyPress;
|
|
85
|
+
handleOpenPluginMenu: () => void;
|
|
88
86
|
/** Undo the last `n` [[Edit]]s committed */
|
|
89
|
-
undo(n?: number)
|
|
87
|
+
undo: (n?: number) => void;
|
|
90
88
|
/** Redo the last `n` [[Edit]]s that have been undone */
|
|
91
|
-
redo(n?: number)
|
|
92
|
-
editFileUI: OscdDialog;
|
|
93
|
-
menuUI: OscdNavigationDrawer;
|
|
94
|
-
fileNameUI: HTMLInputElement;
|
|
95
|
-
fileExtensionUI: HTMLInputElement;
|
|
96
|
-
fileMenuUI: OscdMenu;
|
|
97
|
-
fileMenuButtonUI?: OscdFilledIconButton;
|
|
98
|
-
get locale(): LocaleTag;
|
|
99
|
-
set locale(tag: LocaleTag);
|
|
100
|
-
private editorIndex;
|
|
101
|
-
get editor(): string;
|
|
102
|
-
private controls;
|
|
103
|
-
get menu(): Required<Control>[];
|
|
104
|
-
get editors(): RenderedPlugin[];
|
|
89
|
+
redo: (n?: number) => void;
|
|
105
90
|
private hotkeys;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
91
|
+
isEditable(docName: string): boolean;
|
|
92
|
+
onDocsChanged(): void;
|
|
93
|
+
renderPlugin(tagName: string): import("lit-html").TemplateResult;
|
|
94
|
+
onMenuPluginSelect(customEvent: CustomEvent): void;
|
|
95
|
+
renderOffScreenPlugins(): import("lit-html").TemplateResult<1>;
|
|
96
|
+
renderDefaultLandingPage(): import("lit-html").TemplateResult<1>;
|
|
97
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
112
98
|
static styles: import("lit").CSSResult;
|
|
113
99
|
}
|
|
114
100
|
declare global {
|
|
115
101
|
interface HTMLElementTagNameMap {
|
|
116
|
-
'oscd-shell':
|
|
102
|
+
'oscd-shell': OscdShell;
|
|
117
103
|
}
|
|
118
104
|
}
|
|
119
105
|
export {};
|