fixes and functions
This commit is contained in:
@@ -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",
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user