diff options
author | bob <bcz@cs.brown.edu> | 2020-02-04 10:38:14 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2020-02-04 10:38:14 -0500 |
commit | 92a5efa6876db1a497640aeb13fef5c8d99b102d (patch) | |
tree | 7d10bfd9e0cfb3cd5c715410c645248571fdaff3 /src/new_fields/Doc.ts | |
parent | 72f50feacb1c023d093b8169ef85e1e7773aa483 (diff) |
fixing layout stuff
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index 4dcdc6581..7033b23f1 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -1,4 +1,4 @@ -import { observable, ObservableMap, runInAction, action } from "mobx"; +import { observable, ObservableMap, runInAction, action, computed } from "mobx"; import { alias, map, serializable } from "serializr"; import { DocServer } from "../client/DocServer"; import { DocumentType } from "../client/documents/DocumentTypes"; @@ -89,6 +89,7 @@ export function DocListCast(field: FieldResult): Doc[] { export const WidthSym = Symbol("Width"); export const HeightSym = Symbol("Height"); export const DataSym = Symbol("Data"); +export const LayoutSym = Symbol("Layout"); export const UpdatingFromServer = Symbol("UpdatingFromServer"); const CachedUpdates = Symbol("Cached updates"); @@ -167,6 +168,17 @@ export class Doc extends RefField { public [WidthSym] = () => NumCast(this[SelfProxy]._width); public [HeightSym] = () => NumCast(this[SelfProxy]._height); public get [DataSym]() { return Cast(this[SelfProxy].resolvedDataDoc, Doc, null) || this[SelfProxy]; } + @computed public get __LAYOUT__() { + const layoutKey = StrCast(this[SelfProxy].layoutKey); + const resolvedLayout = Cast(this[SelfProxy][layoutKey], Doc); + if (resolvedLayout instanceof Doc) { + let x = resolvedLayout[Id]; + let layout = (resolvedLayout.layout as string).split("'")[1]; + const layoutDoc = this[SelfProxy][layout + "-layout[" + x + "]"]; + return layoutDoc || this[SelfProxy]; + } + return undefined; + } [ToScriptString]() { return "invalid"; |