diff --git a/app/scenes/DocumentNew.tsx b/app/scenes/DocumentNew.tsx index 1b629f014..b7650c40e 100644 --- a/app/scenes/DocumentNew.tsx +++ b/app/scenes/DocumentNew.tsx @@ -23,6 +23,10 @@ function DocumentNew() { useEffect(() => { async function createDocument() { const params = queryString.parse(location.search); + const parentDocumentId = params.parentDocumentId?.toString(); + const parentDocument = parentDocumentId + ? documents.get(parentDocumentId) + : undefined; let collection; try { @@ -31,7 +35,8 @@ function DocumentNew() { } const document = await documents.create({ collectionId: collection?.id, - parentDocumentId: params.parentDocumentId?.toString(), + parentDocumentId, + fullWidth: parentDocument?.fullWidth, templateId: params.templateId?.toString(), template: params.template === "true" ? true : false, title: "", diff --git a/server/commands/documentCreator.ts b/server/commands/documentCreator.ts index 323dc1e2f..843027163 100644 --- a/server/commands/documentCreator.ts +++ b/server/commands/documentCreator.ts @@ -12,9 +12,10 @@ type Props = { collectionId?: string | null; parentDocumentId?: string | null; importId?: string; - templateDocument?: Document | null; publishedAt?: Date; template?: boolean; + templateDocument?: Document | null; + fullWidth?: boolean; createdAt?: Date; updatedAt?: Date; user: User; @@ -33,12 +34,13 @@ export default async function documentCreator({ publish, collectionId, parentDocumentId, + template, templateDocument, + fullWidth, importId, createdAt, // allows override for import updatedAt, - template, user, editorVersion, publishedAt, @@ -76,6 +78,7 @@ export default async function documentCreator({ createdById: user.id, template, templateId, + fullWidth, publishedAt, importId, title: templateDocument diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 63756fb22..5cd88fae8 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -1267,6 +1267,7 @@ router.post( publish, collectionId, parentDocumentId, + fullWidth, templateId, template, } = ctx.input.body; @@ -1320,6 +1321,7 @@ router.post( parentDocumentId, templateDocument, template, + fullWidth, user, editorVersion, ip: ctx.request.ip, diff --git a/server/routes/api/documents/schema.ts b/server/routes/api/documents/schema.ts index 8a1a9d2a8..26b387214 100644 --- a/server/routes/api/documents/schema.ts +++ b/server/routes/api/documents/schema.ts @@ -289,6 +289,9 @@ export const DocumentsCreateSchema = BaseSchema.extend({ /** Create doc with this template */ templateId: z.string().uuid().optional(), + /** Boolean to denote if the doc should occupy full width */ + fullWidth: z.boolean().optional(), + /** Whether to create a template doc */ template: z.boolean().optional(), }),