-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looking for a new feature branch for exporting! #3
base: main
Are you sure you want to change the base?
Changes from 1 commit
c636148
03bb4f1
2effb9f
0c7ba3b
b9258d6
988e81f
eaa74a3
4c8325d
cb855ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1 mat-dialog-title>Open Notebook</h1> | ||
<div mat-dialog-content> | ||
<button mat-menu-item (click)="export()">Export All</button> | ||
<button mat-menu-item (click)="exportNotebook()">Export Current Notebook</button> | ||
<button mat-menu-item (click)="destroy()">Delete All Data (caution)</button> | ||
</div> | ||
<div mat-dialog-actions> | ||
<button mat-button (click)="closeDialog()">Close</button> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ExportComponent } from './export.component'; | ||
|
||
describe('ExportComponent', () => { | ||
let component: ExportComponent; | ||
let fixture: ComponentFixture<ExportComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ ExportComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ExportComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Component} from "@angular/core"; | ||
import {MatDialog} from "@angular/material/dialog"; | ||
import * as url from "../shell/url"; | ||
import {DatabaseManager} from "../shell/DatabaseManager"; | ||
|
||
@Component({ | ||
selector: 'app-exporter', | ||
templateUrl: './export.component.html', | ||
styleUrls: ['./export.component.css'] | ||
}) | ||
export class ExportComponent { | ||
channel = new MessageChannel(); | ||
constructor(private dialog: MatDialog, private manager: DatabaseManager) { | ||
} | ||
|
||
closeDialog() { | ||
this.dialog.closeAll(); | ||
} | ||
|
||
async export() { | ||
console.log(await this.manager.exportDatabase()); | ||
} | ||
|
||
async exportNotebook() { | ||
console.log(await this.manager.exportNotebook(url.read("p"))); | ||
} | ||
|
||
async destroy() { | ||
this.manager.destroy(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ export class Shell { | |
private peerAddBlock = false; | ||
private peerRemoveBlock = false; | ||
private peerChangeBlock = false; | ||
// environment is generally window | ||
pranitsh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
constructor(private editor: EditorJS, private environment: any, private databaseManager: DatabaseManager) { | ||
environment.webWorkers = this.jobs; | ||
environment.downloadBlob = downloadBlob; | ||
|
@@ -70,16 +71,6 @@ export class Shell { | |
window.dispatchEvent(new CustomEvent('shell.StopAll')); | ||
this.databaseManager.removeAllBlocks().then(); | ||
}); | ||
environment.addEventListener('shell.ExportNotebook', (event: CustomEvent) => { | ||
// @ts-ignore | ||
globalThis.editor.save()?.then((data) => { | ||
downloadFile([JSON.stringify(data)], {type: 'application/json', filename: `${url.read('n', 'EvaNotebook')}.json`}); | ||
event.detail?.port?.postMessage({ | ||
event: event.detail?.payload?.event, payload: data | ||
}); | ||
} | ||
); | ||
}); | ||
environment.addEventListener('shell.DownloadFile', (event: CustomEvent) => { | ||
downloadFile(event.detail.payload.blobParts, event.detail.payload.options); | ||
}); | ||
|
@@ -105,31 +96,25 @@ export class Shell { | |
block?.call('dispatchShellStop'); | ||
} | ||
}); | ||
//@ts-ignore | ||
environment.addEventListener('localecho.println', (event: CustomEvent) => { | ||
this.editor.blocks.getById(event.detail.payload.threadId)?.call('println', event.detail.payload.text); | ||
}); | ||
//@ts-ignore | ||
environment.addEventListener('shell.RequestCanvas', (event: CustomEvent) => { | ||
this.editor.blocks.getById(event.detail.payload.threadId)?.call('transferControlToOffscreen'); | ||
}); | ||
//@ts-ignore | ||
environment.addEventListener('shell.RequestCaptureStream', (event: CustomEvent) => { | ||
this.editor.blocks.getById(event.detail.payload.threadId)?.call('captureStream'); | ||
}); | ||
//@ts-ignore | ||
environment.addEventListener('shell.transferStreamToOffscreen', (event: CustomEvent) => { | ||
this.jobs.get(event.detail.payload.threadId)?.worker?.postMessage({ | ||
event: 'transferStreamToOffscreen', payload: { | ||
message: event.detail.payload.message | ||
} | ||
}, [event.detail.payload.message]); | ||
}); | ||
//@ts-ignore | ||
environment.addEventListener('table', (event: CustomEvent) => { | ||
this.editor.blocks.getById(event.detail.payload.threadId)?.call('createTable'); | ||
}); | ||
//@ts-ignore | ||
environment.addEventListener('tree', (event: CustomEvent) => { | ||
this.editor.blocks.getById(event.detail.payload.threadId)?.call('createTree'); | ||
}); | ||
|
@@ -385,12 +370,10 @@ export class Shell { | |
this.editor.blocks.update(block.id, block.data); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, kinda struggling to figure out what this is referencing. Could you please clarify which |
||
private handleKeyPress(event: KeyboardEvent) { | ||
private async handleKeyPress(event: KeyboardEvent) { | ||
if (event.ctrlKey && event.key === 's') { | ||
event.preventDefault(); | ||
this.databaseManager.saveInUrl(); | ||
} | ||
} | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable should be declared outside of the loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, any suggested places for this constant?