aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DocumentView.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r--src/client/views/nodes/DocumentView.tsx16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index c35a44860..2ccfad448 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -659,7 +659,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
@undoBatch
@action
- setCustomView = (custom: boolean): void => {
+ setCustomView =
+ (custom: boolean): void => {
if (this.props.ContainingCollectionView?.props.DataDoc || this.props.ContainingCollectionView?.props.Document.isTemplateDoc) {
Doc.MakeMetadataFieldTemplate(this.props.Document, this.props.ContainingCollectionView.props.Document);
} else {
@@ -850,7 +851,14 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
return (showTitle && !showTitleHover ? 0 : 0) + 1;
}
- @computed get finalLayoutKey() { return this.props.layoutKey || "layout"; }
+ @computed get finalLayoutKey() {
+ const { layoutKey } = this.props;
+ if (typeof layoutKey === "string") {
+ return layoutKey;
+ }
+ const fallback = Cast(this.props.Document.layoutKey, "string");
+ return typeof fallback === "string" ? fallback : "layout";
+ }
childScaling = () => (this.layoutDoc.fitWidth ? this.props.PanelWidth() / this.nativeWidth : this.props.ContentScaling());
@computed get contents() {
TraceMobx();
@@ -922,9 +930,9 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
pointerEvents: SelectionManager.GetIsDragging() ? "none" : "all",
}}>
<EditableView ref={this._titleRef}
- contents={(this.props.DataDoc || this.props.Document)[showTitle]}
+ contents={(this.props.DataDoc || this.props.Document)[showTitle]?.toString()}
display={"block"} height={72} fontSize={12}
- GetValue={() => StrCast((this.props.DataDoc || this.props.Document)[showTitle])}
+ GetValue={() => (this.props.DataDoc || this.props.Document)[showTitle]?.toString()}
SetValue={undoBatch((value: string) => (Doc.GetProto(this.props.DataDoc || this.props.Document)[showTitle] = value) ? true : true)}
/>
</div>);