fixes and functions

This commit is contained in:
Mateusz Gruszczyński
2026-08-04 23:21:27 +02:00
parent 6fc408ddf7
commit 4b25085bb5
28 changed files with 306 additions and 330 deletions
+6 -1
View File
@@ -10,10 +10,15 @@
const VIEWS = new Set(["edit", "split", "preview"]);
const MODES = new Set(["markdown", "text"]);
function defaultEditorView() {
return window.matchMedia("(max-width: 760px)").matches ? "edit" : "split";
}
export function readEditorState() {
const params = new URLSearchParams(window.location.search);
const requestedView = params.get("view");
return {
view: VIEWS.has(params.get("view")) ? params.get("view") : "split",
view: VIEWS.has(requestedView) ? requestedView : defaultEditorView(),
mode: MODES.has(params.get("mode")) ? params.get("mode") : "markdown",
};
}