Skip to content

Commit 88b9b43

Browse files
author
github-actions
committed
Updates
1 parent 66aab23 commit 88b9b43

14 files changed

+71
-388
lines changed

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<html><head><title>oscd-template-menu demo</title><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&amp;family=Roboto:wght@300;400;500&amp;display=swap"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Symbols+Outlined&amp;display=block"></head><body><oscd-shell></oscd-shell><style>*{--oscd-theme-text-font:'Roboto';--oscd-theme-icon-font:'Material Symbols Outlined';margin:0;padding:0}abbr{text-decoration:none;border-bottom:none}</style><script type="module" src="./inline-module-de7882cbb3fda1a32685e9cb5006df5d.js"></script></body></html>
1+
<html><head><title>oscd-menu-save demo</title><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&amp;family=Roboto:wght@300;400;500&amp;display=swap"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Symbols+Outlined&amp;display=block"></head><body><oscd-shell></oscd-shell><style>*{--oscd-theme-text-font:'Roboto';--oscd-theme-icon-font:'Material Symbols Outlined';margin:0;padding:0}abbr{text-decoration:none;border-bottom:none}</style><script type="module" src="./inline-module-de7882cbb3fda1a32685e9cb5006df5d.js"></script></body></html>

demo/inline-module-de7882cbb3fda1a32685e9cb5006df5d.js

Lines changed: 24 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12044,74 +12044,37 @@ class OscdBackgroundEditV1 extends HTMLElement {
1204412044
}
1204512045
}
1204612046

12047-
class OscdTemplateMenu extends ScopedElementsMixin(i$3) {
12047+
class SaveProjectPlugin extends HTMLElement {
1204812048
async run() {
12049-
// Implement the logic for the run method
12050-
if (this.docName) {
12051-
console.log(`Running with document: ${this.docName}`);
12049+
if (this.doc) {
12050+
let documentAsString = new XMLSerializer().serializeToString(this.doc);
12051+
// Add XML declaration/prolog if it's been stripped
12052+
// TODO: This can be removed once the improved OpenSCD core edit API is present
12053+
documentAsString = documentAsString.startsWith('<?xml')
12054+
? documentAsString
12055+
: '<?xml version="1.0" encoding="UTF-8"?>' + '\n' + documentAsString;
12056+
const blob = new Blob([documentAsString], {
12057+
type: 'application/xml',
12058+
});
12059+
const a = document.createElement('a');
12060+
a.download = this.docName;
12061+
a.href = URL.createObjectURL(blob);
12062+
a.dataset.downloadurl = ['application/xml', a.download, a.href].join(':');
12063+
a.style.display = 'none';
12064+
document.body.appendChild(a);
12065+
a.click();
12066+
document.body.removeChild(a);
12067+
setTimeout(function () {
12068+
URL.revokeObjectURL(a.href);
12069+
}, 5000);
1205212070
}
1205312071
}
12054-
render() {
12055-
/* Anything rendered in here for a Menu plugin, will be hidden
12056-
* Typically you would render dialogs here, where the run method
12057-
* may set the dialogs state to open.
12058-
*/
12059-
return x `
12060-
<h1>OSCD Template Menu</h1>
12061-
<p>
12062-
Welcome to the OSCD Template Menu. Currently selected Document is:
12063-
${this.docName}.
12064-
</p>
12065-
`;
12066-
}
1206712072
}
12068-
OscdTemplateMenu.scopedElements = {
12069-
/*
12070-
* add any web-components this component will reference here.
12071-
* E.g.
12072-
* "oscd-button": OscdButton,
12073-
*
12074-
* Important!
12075-
* Importing the web-component class should NOT result in the web-component being registered with the global customElements registry.
12076-
* Otherwise it will fail to render at all. You'll only get an empty tag, no web component.
12077-
*/
12078-
};
12079-
OscdTemplateMenu.styles = i$6 `
12080-
:host {
12081-
/* Ideal place to set CSS to the root of the component */
12082-
background-color: var(--oscd-something);
12083-
}
12084-
12085-
* {
12086-
/* Ideal place to set CSS variables, which should be applied to all elements.
12087-
* typically done to set Material Component theme variables.
12088-
*/
12089-
--md-something: var(--oscd-something);
12090-
}
12091-
`;
12092-
__decorate([
12093-
n$3({ type: Object })
12094-
], OscdTemplateMenu.prototype, "editor", void 0);
12095-
__decorate([
12096-
n$3({ type: Object })
12097-
], OscdTemplateMenu.prototype, "docs", void 0);
12098-
__decorate([
12099-
n$3({ type: Object })
12100-
], OscdTemplateMenu.prototype, "doc", void 0);
12101-
__decorate([
12102-
n$3({ type: String })
12103-
], OscdTemplateMenu.prototype, "docName", void 0);
12104-
__decorate([
12105-
n$3({ attribute: false })
12106-
], OscdTemplateMenu.prototype, "docVersion", void 0);
12107-
__decorate([
12108-
n$3({ type: String })
12109-
], OscdTemplateMenu.prototype, "locale", void 0);
1211012073

1211112074
customElements.define('oscd-menu-open', OscdMenuOpen);
1211212075
customElements.define('oscd-background-editv1', OscdBackgroundEditV1);
1211312076

12114-
customElements.define('oscd-template-menu', OscdTemplateMenu);
12077+
customElements.define('oscd-menu-save', SaveProjectPlugin);
1211512078

1211612079
const plugins = {
1211712080
menu: [
@@ -12126,7 +12089,7 @@ const plugins = {
1212612089
translations: { de: 'Datei speichern' },
1212712090
icon: 'save',
1212812091
requireDoc: true,
12129-
tagName: 'oscd-template-menu',
12092+
tagName: 'oscd-menu-save',
1213012093
},
1213112094
],
1213212095
editor: [],

demo/inline-module-de7882cbb3fda1a32685e9cb5006df5d.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/oscd-menu-save.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default class SaveProjectPlugin extends HTMLElement {
2+
docs: Record<string, XMLDocument>;
3+
doc: XMLDocument;
4+
docName: string;
5+
run(): Promise<void>;
6+
}

demo/oscd-template-menu.d.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

demo/plugins.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import OscdMenuOpen from '@omicronenergy/oscd-menu-open';
22
import OscdBackgroundEditV1 from '@omicronenergy/oscd-background-editv1';
33

4-
import OscdMenuSave from '../oscd-template-menu.js';
4+
import OscdMenuSave from '../oscd-menu-save.js';
55

66
customElements.define('oscd-menu-open', OscdMenuOpen);
77
customElements.define('oscd-background-editv1', OscdBackgroundEditV1);
88

9-
customElements.define('oscd-template-menu', OscdMenuSave);
9+
customElements.define('oscd-menu-save', OscdMenuSave);
1010

1111
export const plugins = {
1212
menu: [
@@ -21,7 +21,7 @@ export const plugins = {
2121
translations: { de: 'Datei speichern' },
2222
icon: 'save',
2323
requireDoc: true,
24-
tagName: 'oscd-template-menu',
24+
tagName: 'oscd-menu-save',
2525
},
2626
],
2727
editor: [],

oscd-menu-save.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default class SaveProjectPlugin extends HTMLElement {
2+
docs: Record<string, XMLDocument>;
3+
doc: XMLDocument;
4+
docName: string;
5+
run(): Promise<void>;
6+
}

oscd-menu-save.js

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

oscd-menu-save.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)