feat: Optional full-width toggle for document display (#2869)

* Migration, model, presenter

* Working implementation

* fix: Account for table of contents

* Checkbox -> Toggle

* Checkbox -> Toggle
This commit is contained in:
Tom Moor
2021-12-19 13:58:16 -08:00
committed by GitHub
parent 73bc7d9f2a
commit 66d5a567c2
18 changed files with 239 additions and 146 deletions

View File

@@ -50,6 +50,10 @@ export default class Document extends BaseModel {
@observable
template: boolean;
@Field
@observable
fullWidth: boolean;
@Field
@observable
templateId: string | undefined;
@@ -311,6 +315,7 @@ export default class Document extends BaseModel {
{
id: this.id,
title: options.title || this.title,
fullWidth: this.fullWidth,
},
{
lastRevision: options.lastRevision,
@@ -327,7 +332,7 @@ export default class Document extends BaseModel {
};
@action
save = async (options: SaveOptions | undefined) => {
save = async (options?: SaveOptions | undefined) => {
if (this.isSaving) return this;
const isCreating = !this.id;
this.isSaving = true;
@@ -349,24 +354,21 @@ export default class Document extends BaseModel {
);
}
if (options?.lastRevision) {
return await this.store.update(
{
id: this.id,
title: this.title,
text: this.text,
templateId: this.templateId,
},
{
lastRevision: options?.lastRevision,
publish: options?.publish,
done: options?.done,
autosave: options?.autosave,
}
);
}
throw new Error("Attempting to update without a lastRevision");
return await this.store.update(
{
id: this.id,
title: this.title,
text: this.text,
fullWidth: this.fullWidth,
templateId: this.templateId,
},
{
lastRevision: options?.lastRevision || this.revision,
publish: options?.publish,
done: options?.done,
autosave: options?.autosave,
}
);
} finally {
this.isSaving = false;
}