+
+
{{ selectedMessage().name }}
+
+
+
@if(values()) { @for (item of selectedMessage().values; track $index) {
();
selectedMessage = input.required();
+ indentSize = input(2);
showRaw = input(true);
@@ -40,7 +49,11 @@ export class EditorComponent {
if (!this.values()) {
return;
}
- const json = JSON.stringify(this.values(), undefined, 2);
+ const json = JSON.stringify(
+ this.values(),
+ undefined,
+ this.indentSize()
+ );
const highlighted = hljs.highlightAuto(json, ['json']);
const sanitized = sanitizer.sanitize(
SecurityContext.HTML,
@@ -94,10 +107,25 @@ export class EditorComponent {
protected async copyToClipboard() {
await navigator.clipboard.writeText(
- JSON.stringify(this.values(), undefined, 2)
+ JSON.stringify(this.values(), undefined, this.indentSize())
);
this.snackBar.open('Successully copied to clipboard', 'Close', {
duration: 2000,
});
}
+
+ protected async save() {
+ const selectedFile = this.selectedFile();
+ if (!selectedFile) {
+ return;
+ }
+ try {
+ await writeTextFile(
+ selectedFile,
+ JSON.stringify(this.values(), undefined, this.indentSize())
+ );
+ } catch (err) {
+ console.error('Failed to write to file ${this.selectedFile()}', err);
+ }
+ }
}
diff --git a/src/styles.scss b/src/styles.scss
index b730084..c6101d5 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -30,6 +30,7 @@ html {
@include mat.list-theme(theme.$rose-theme);
@include mat.select-theme(theme.$rose-theme);
@include mat.snack-bar-theme(theme.$rose-theme);
+ @include mat.tooltip-theme(theme.$rose-theme);
@include custom-colours(theme.$rose-theme);
}