@@ -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
1211112074customElements.define('oscd-menu-open', OscdMenuOpen);
1211212075customElements.define('oscd-background-editv1', OscdBackgroundEditV1);
1211312076
12114- customElements.define('oscd-template- menu', OscdTemplateMenu );
12077+ customElements.define('oscd-menu-save ', SaveProjectPlugin );
1211512078
1211612079const 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: [],
0 commit comments