Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danyill committed Jun 14, 2024
1 parent b5e59a2 commit 4905732
Show file tree
Hide file tree
Showing 7 changed files with 1,062 additions and 7 deletions.
14 changes: 9 additions & 5 deletions plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@
"src": "plugins/oscd-open/oscd-open.js"
},
{
"name": "Save project",
"translation": {
"de": "Projekt speichern"
},
"name": "Save",
"icon": "save",
"active": true,
"requireDoc": true,
"src": "plugins/oscd-save/oscd-save.js"
"src": "plugins/oscd-save-as/oscd-save-as.js#Save"
},
{
"name": "Save As",
"icon": "save_as",
"active": true,
"requireDoc": true,
"src": "plugins/oscd-save-as/oscd-save-as.js"
},
{
"name": "Import IED",
Expand Down
63 changes: 63 additions & 0 deletions plugins/oscd-save-as/index.deploy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<title>oscd-save-as Demo</title>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&family=Roboto:wght@300;400;500&display=swap"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
/>
<link
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined"
rel="stylesheet"
/>
<!-- tag::plugins[] -->
<open-scd
plugins='{
"menu":
[
{"name": "Open File", "translations": {"de": "Datei öffnen"}, "icon": "folder_open", "active": true, "src": "https://openscd.github.io/oscd-open/oscd-open.js"},
{"name": "(Old) Save File", "translations": {"de": "Datei speichern"}, "icon": "save", "active": true, "src": "https://openscd.github.io/oscd-save/oscd-save.js"},
{"name": "Save", "icon": "save", "active": true, "requireDoc": true, "src": "oscd-save-as.js#Save"},
{"name": "Save As...", "icon": "save_as", "active": true, "requireDoc": true, "src": "oscd-save-as.js"}
]
}'
></open-scd>
<!-- end::plugins[] -->

<script>
const _customElementsDefine = window.customElements.define;
window.customElements.define = (name, cl, conf) => {
if (!customElements.get(name)) {
try {
_customElementsDefine.call(window.customElements, name, cl, conf);
} catch (e) {
console.warn(e);
}
}
};
</script>

<script type="module">
import 'https://openscd.github.io/open-scd-core/open-scd.js';
// import 'open-scd-core/open-scd.js'
// TODO: Could also use: jsdelivr or unpkg

const editor = document.querySelector('open-scd');
const params = new URL(document.location).searchParams;
for (const [name, value] of params) {
editor.setAttribute(name, value);
}
</script>
<style>
* {
margin: 0px;
padding: 0px;
--mdc-icon-font: 'Material Symbols Outlined';
}

body {
background: white;
}
</style>
24 changes: 24 additions & 0 deletions plugins/oscd-save-as/oscd-save-as.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { LitElement, TemplateResult } from 'lit';
import '@material/mwc-snackbar';
import type { Snackbar } from '@material/mwc-snackbar';
/**
* WebComponent for OpenSCD to allow saving to a file system location
* using the File System API
*/
export default class SaveAs extends LitElement {
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
doc: XMLDocument;
docName: string;
editCount: number;
usedDirectory: string;
fileHandle: object | null;
userMessage: string;
usedFileNames: string[];
userMessageUI?: Snackbar;
getSaveFileLocation(): Promise<void>;
constructor();
private handleKeyPress;
run(): Promise<void>;
fileSave(): Promise<void>;
render(): TemplateResult;
}
963 changes: 963 additions & 0 deletions plugins/oscd-save-as/oscd-save-as.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/oscd-save-as/oscd-save-as.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sw.js.map

Large diffs are not rendered by default.

0 comments on commit 4905732

Please sign in to comment.