mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 14:38:13 +08:00
@@ -3,7 +3,7 @@ import { reactive, readonly } from "vue";
|
||||
|
||||
import { download, downloadBlob, upload } from "@/utility-functions/files";
|
||||
import { Editor } from "@/wasm-communication/editor";
|
||||
import { TriggerFileDownload, TriggerRasterDownload, FrontendDocumentDetails, TriggerFileUpload, UpdateActiveDocument, UpdateOpenDocumentsList } from "@/wasm-communication/messages";
|
||||
import { TriggerFileDownload, TriggerRasterDownload, FrontendDocumentDetails, TriggerOpenDocument, TriggerImport, UpdateActiveDocument, UpdateOpenDocumentsList } from "@/wasm-communication/messages";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export function createPortfolioState(editor: Editor) {
|
||||
@@ -22,11 +22,15 @@ export function createPortfolioState(editor: Editor) {
|
||||
const activeId = state.documents.findIndex((doc) => doc.id === updateActiveDocument.document_id);
|
||||
state.activeDocumentIndex = activeId;
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerFileUpload, async () => {
|
||||
editor.subscriptions.subscribeJsMessage(TriggerOpenDocument, async () => {
|
||||
const extension = editor.instance.file_save_suffix();
|
||||
const data = await upload(extension);
|
||||
const data = await upload(extension, "text");
|
||||
editor.instance.open_document_file(data.filename, data.content);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerImport, async () => {
|
||||
const data = await upload("image/*", "data");
|
||||
editor.instance.paste_image(data.type, Uint8Array.from(data.content));
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerFileDownload, (triggerFileDownload) => {
|
||||
download(triggerFileDownload.name, triggerFileDownload.document);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user