Skip to content

Commit 6e26af9

Browse files
Remove file extension on all open document file calls
1 parent 250921b commit 6e26af9

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

frontend/src/components/panels/Document.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@
151151
return;
152152
}
153153
154-
if (file.name.endsWith(".graphite")) {
154+
const graphiteFileSuffix = "." + editor.handle.fileExtension();
155+
if (file.name.endsWith(graphiteFileSuffix)) {
155156
const content = await file.text();
156-
editor.handle.openDocumentFile(file.name, content);
157+
const documentName = file.name.slice(0, -graphiteFileSuffix.length);
158+
editor.handle.openDocumentFile(documentName, content);
157159
return;
158160
}
159161
});

frontend/src/components/panels/Layers.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,11 @@
438438
}
439439
440440
// When we eventually have sub-documents, this should be changed to import the document instead of opening it in a separate tab
441-
if (file.name.endsWith(".graphite")) {
441+
const graphiteFileSuffix = "." + editor.handle.fileExtension();
442+
if (file.name.endsWith(graphiteFileSuffix)) {
442443
const content = await file.text();
443-
editor.handle.openDocumentFile(file.name, content);
444+
const documentName = file.name.slice(0, -graphiteFileSuffix.length);
445+
editor.handle.openDocumentFile(documentName, content);
444446
return;
445447
}
446448
});

frontend/src/components/window/workspace/Panel.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@
8383
return;
8484
}
8585
86-
if (file.name.endsWith(".graphite")) {
86+
const graphiteFileSuffix = "." + editor.handle.fileExtension();
87+
if (file.name.endsWith(graphiteFileSuffix)) {
8788
const content = await file.text();
88-
editor.handle.openDocumentFile(file.name, content);
89+
const documentName = file.name.slice(0, -graphiteFileSuffix.length);
90+
editor.handle.openDocumentFile(documentName, content);
8991
return;
9092
}
9193
});

frontend/src/io-managers/input.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
334334
editor.handle.pasteImage(file.name, new Uint8Array(imageData.data), imageData.width, imageData.height);
335335
}
336336

337-
if (file.name.endsWith(".graphite")) {
338-
editor.handle.openDocumentFile(file.name, await file.text());
337+
const graphiteFileSuffix = "." + editor.handle.fileExtension();
338+
if (file.name.endsWith(graphiteFileSuffix)) {
339+
const content = await file.text();
340+
const documentName = file.name.slice(0, -graphiteFileSuffix.length);
341+
editor.handle.openDocumentFile(documentName, content);
339342
}
340343
});
341344
}

frontend/src/state-providers/portfolio.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ export function createPortfolioState(editor: Editor) {
8383
}
8484

8585
// In case the user accidentally uploads a Graphite file, open it instead of failing to import it
86-
if (data.filename.endsWith("." + editor.handle.fileExtension())) {
87-
editor.handle.openDocumentFile(data.filename, data.content.text);
86+
const graphiteFileSuffix = "." + editor.handle.fileExtension();
87+
if (data.filename.endsWith(graphiteFileSuffix)) {
88+
const documentName = data.filename.slice(0, -graphiteFileSuffix.length);
89+
editor.handle.openDocumentFile(documentName, data.content.text);
8890
return;
8991
}
9092

0 commit comments

Comments
 (0)