diff options
author | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-10-07 22:49:05 -0400 |
---|---|---|
committer | alyssaf16 <alyssa_feinberg@brown.edu> | 2024-10-07 22:49:05 -0400 |
commit | b67de10bc8b2eab16de7bb5dd4a7a8646e2a8d5f (patch) | |
tree | c405d8af41af09d146cfac4871c3a11c25410e83 /src/fields/Doc.ts | |
parent | 66950dca6e7add542aba3c6caa8115ce7f1ecd73 (diff) | |
parent | efaa2991ac2670c73a81ab07f61c1626a4300507 (diff) |
Merge branch 'alyssa-starter' of https://github.com/brown-dash/Dash-Web into alyssa-starter
Diffstat (limited to 'src/fields/Doc.ts')
-rw-r--r-- | src/fields/Doc.ts | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts index 7a1ab3b4f..74f18cbc8 100644 --- a/src/fields/Doc.ts +++ b/src/fields/Doc.ts @@ -97,9 +97,8 @@ export namespace Field { }); return script; } - export function toString(fieldIn: unknown) { - const field = fieldIn as FieldType; - if (typeof field === 'string' || typeof field === 'number' || typeof field === 'boolean') return String(field); + export function toString(field: FieldResult<FieldType> | FieldType | undefined) { + if (field instanceof Promise || typeof field === 'string' || typeof field === 'number' || typeof field === 'boolean') return String(field); return field?.[ToString]?.() || ''; } export function IsField(field: unknown): field is FieldType; @@ -111,7 +110,7 @@ export namespace Field { export function Copy(field: unknown) { return field instanceof ObjectField ? ObjectField.MakeCopy(field) : (field as FieldType); } - UndoManager.SetFieldPrinter(toString); + UndoManager.SetFieldPrinter((val: unknown) => (IsField(val) ? toString(val) : '')); } export type FieldType = number | string | boolean | ObjectField | RefField; export type Opt<T> = T | undefined; @@ -463,7 +462,6 @@ export class Doc extends RefField { }); } } - export namespace Doc { export let SelectOnLoad: Doc | undefined; export function SetSelectOnLoad(doc: Doc | undefined) { |