Skip to content

Commit 73c94cd

Browse files
authored
Merge pull request #1817 from KanoComputing/export-custom-filename
feat: Allows customising the name of exported file
2 parents 8944a63 + 2e8925e commit 73c94cd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/app/lib/editor/editor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class Editor extends EditorOrPlayer {
198198
});
199199
this.sourceEditor.onDidLayout(() => this._onDidLayoutChange.fire());
200200
this.sourceEditor.registerQueryHandlers(this.queryEngine);
201-
201+
202202
this.dialogs.onDidLayout(() => this._onDidLayoutChange.fire());
203203

204204
this.queryEngine.registerTagHandler('alias', aliasTagHandlerFactory(this.queryEngine, this.selectorAliases));
@@ -300,7 +300,7 @@ export class Editor extends EditorOrPlayer {
300300
element.appendChild(this.domNode);
301301
}
302302
// Force a synchronous component update. No performance implications as it is about to render anyway
303-
// Makes inject a synchronous method. Way easier to handle injection
303+
// Makes inject a synchronous method. Way easier to handle injection
304304
(this.domNode as any).update();
305305
this.appendSourceEditor();
306306
this.appendWorkspaceView();
@@ -416,13 +416,13 @@ export class Editor extends EditorOrPlayer {
416416
/**
417417
* Downloads a .kcode file with the exported app
418418
*/
419-
exportToDisk() {
419+
exportToDisk(fileName = 'my-app.kcode') {
420420
const savedApp = this.export();
421421
const a = document.createElement('a');
422422
const file = new Blob([JSON.stringify(savedApp)], { type: 'application/kcode' });
423423
const url = URL.createObjectURL(file);
424424
document.body.appendChild(a);
425-
a.download = 'my-app.kcode';
425+
a.download = fileName;
426426
a.href = url;
427427
a.click();
428428
document.body.removeChild(a);

src/app/lib/editor/workspace/toolbar.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class WorkspaceToolbar extends Plugin {
3535
if (!this.editor || !this.editor.workspaceView) {
3636
return;
3737
}
38-
38+
3939
const editorShadowRoot = this.editor.root;
4040
if (editorShadowRoot) {
4141
this.toolbar = editorShadowRoot.querySelector('kc-workspace-toolbar');
@@ -53,7 +53,7 @@ export class WorkspaceToolbar extends Plugin {
5353
});
5454
entry.onDidActivate(() => this.reset());
5555
this.defaultEntries.set('reset', entry);
56-
56+
5757
entry = this.addSettingsEntry({
5858
title: 'Export',
5959
ironIcon: 'kc-ui:export',
@@ -155,11 +155,11 @@ export class WorkspaceToolbar extends Plugin {
155155
this.resetDialog.open();
156156
this._telemetry.trackEvent({ name: 'reset_clicked' });
157157
}
158-
export() {
158+
export(fileName?: string) {
159159
if (!this.editor) {
160160
return;
161161
}
162-
this.editor.exportToDisk();
162+
this.editor.exportToDisk(fileName);
163163
this._telemetry.trackEvent({ name: 'export_clicked' });
164164
}
165165
import() {

0 commit comments

Comments
 (0)