diff --git a/app/menus/DocumentMenu.tsx b/app/menus/DocumentMenu.tsx index 479a48eb5..8100e6e20 100644 --- a/app/menus/DocumentMenu.tsx +++ b/app/menus/DocumentMenu.tsx @@ -9,6 +9,7 @@ import { toast } from "sonner"; import styled from "styled-components"; import breakpoint from "styled-components-breakpoint"; import { s, ellipsis } from "@shared/styles"; +import { UserPreference } from "@shared/types"; import { getEventFiles } from "@shared/utils/files"; import Document from "~/models/Document"; import ContextMenu from "~/components/ContextMenu"; @@ -324,7 +325,13 @@ function DocumentMenu({ label={t("Full width")} checked={document.fullWidth} onChange={(ev) => { - document.fullWidth = ev.currentTarget.checked; + const fullWidth = ev.currentTarget.checked; + user.setPreference( + UserPreference.FullWidthDocuments, + fullWidth + ); + void user.save(); + document.fullWidth = fullWidth; void document.save(); }} /> diff --git a/app/scenes/DocumentNew.tsx b/app/scenes/DocumentNew.tsx index aadd2a1fe..7fe618cff 100644 --- a/app/scenes/DocumentNew.tsx +++ b/app/scenes/DocumentNew.tsx @@ -4,6 +4,7 @@ import { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useHistory, useLocation, useRouteMatch } from "react-router-dom"; import { toast } from "sonner"; +import { UserPreference } from "@shared/types"; import CenteredContent from "~/components/CenteredContent"; import Flex from "~/components/Flex"; import PlaceholderDocument from "~/components/PlaceholderDocument"; @@ -42,7 +43,9 @@ function DocumentNew({ template }: Props) { const document = await documents.create({ collectionId: collection?.id, parentDocumentId, - fullWidth: parentDocument?.fullWidth, + fullWidth: + parentDocument?.fullWidth || + user.getPreference(UserPreference.FullWidthDocuments), templateId: query.get("templateId") ?? undefined, template, title: "", diff --git a/shared/types.ts b/shared/types.ts index 3802e52ab..5f72a9635 100644 --- a/shared/types.ts +++ b/shared/types.ts @@ -116,6 +116,8 @@ export enum UserPreference { CodeBlockLineNumers = "codeBlockLineNumbers", /** Whether documents have a separate edit mode instead of always editing. */ SeamlessEdit = "seamlessEdit", + /** Whether documents should start in full-width mode. */ + FullWidthDocuments = "fullWidthDocuments", } export type UserPreferences = { [key in UserPreference]?: boolean };