temp work

This commit is contained in:
2023-12-04 12:18:34 +01:00
75 changed files with 3079 additions and 3357 deletions

View File

@ -1,4 +1,5 @@
import { type Editor } from "./main";
import { socket } from "./IO/OSC";
const handleResize = (canvas: HTMLCanvasElement) => {
if (!canvas) return;
@ -26,19 +27,21 @@ export const saveBeforeExit = (app: Editor): null => {
app.currentFile().candidate = app.view.state.doc.toString();
app.currentFile().committed = app.view.state.doc.toString();
app.settings.saveApplicationToLocalStorage(app.universes, app.settings);
// Close the websocket
socket.close();
return null;
};
export const installWindowBehaviors = (
app: Editor,
window: Window,
preventMultipleTabs: boolean = false
preventMultipleTabs: boolean = false,
) => {
window.addEventListener("resize", () =>
handleResize(app.interface.scope as HTMLCanvasElement)
handleResize(app.interface.scope as HTMLCanvasElement),
);
window.addEventListener("resize", () =>
handleResize(app.interface.feedback as HTMLCanvasElement)
handleResize(app.interface.feedback as HTMLCanvasElement),
);
window.addEventListener("beforeunload", (event) => {
event.preventDefault();
@ -61,11 +64,11 @@ export const installWindowBehaviors = (
if (e.key == "page_available") {
document.getElementById("all")!.classList.add("invisible");
alert(
"Topos is already opened in another tab. Close this tab now to prevent data loss."
"Topos is already opened in another tab. Close this tab now to prevent data loss.",
);
}
},
false
false,
);
}
};