diff options
| author | madelinegr <mgriswold99@gmail.com> | 2019-03-11 18:15:18 -0400 |
|---|---|---|
| committer | madelinegr <mgriswold99@gmail.com> | 2019-03-11 18:15:18 -0400 |
| commit | e502c8fd15951e8b724ec98bef32294e4a6faa5f (patch) | |
| tree | 8cfb34fcddec1115aade0c718c37819fce0a9e2a /src/fields | |
| parent | 0692b142d84bf7a921b53581f28840260254724d (diff) | |
| parent | 618e66a5a070f1aac9224bd3f44b76a5ac314bfa (diff) | |
mer con
Diffstat (limited to 'src/fields')
| -rw-r--r-- | src/fields/Document.ts | 8 | ||||
| -rw-r--r-- | src/fields/KeyStore.ts | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts index 2e873439c..25e239417 100644 --- a/src/fields/Document.ts +++ b/src/fields/Document.ts @@ -1,6 +1,6 @@ import { Key } from "./Key" import { KeyStore } from "./KeyStore"; -import { Field, Cast, FieldWaiting, FieldValue, FieldId } from "./Field" +import { Field, Cast, FieldWaiting, FieldValue, FieldId, Opt } from "./Field" import { NumberField } from "./NumberField"; import { ObservableMap, computed, action } from "mobx"; import { TextField } from "./TextField"; @@ -128,6 +128,12 @@ export class Document extends Field { return false; } + GetTAsync<T extends Field>(key: Key, ctor: { new(): T }, callback: (field: Opt<T>) => void): boolean { + return this.GetAsync(key, (field) => { + callback(Cast(field, ctor)); + }) + } + /** * Same as {@link Document#GetAsync}, except a field of the given type * will be created if there is no field associated with the given key, diff --git a/src/fields/KeyStore.ts b/src/fields/KeyStore.ts index f1f4eebe8..d9ba251ae 100644 --- a/src/fields/KeyStore.ts +++ b/src/fields/KeyStore.ts @@ -28,6 +28,10 @@ export namespace KeyStore { export const ActiveFrame = new Key("ActiveFrame"); export const DocumentText = new Key("DocumentText"); export const PresentationView = new Key("PresentationView"); + export const LinkedToDocs = new Key("LinkedToDocs"); + export const LinkedFromDocs = new Key("LinkedFromDocs"); + export const LinkDescription = new Key("LinkDescription"); + export const LinkTags = new Key("LinkTag"); export const Thumbnail = new Key("Thumbnail"); export const CurPage = new Key("CurPage"); export const NumPages = new Key("NumPages"); |
