-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
1,062 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.