diff options
Diffstat (limited to 'src/client/views/nodes/FieldView.tsx')
-rw-r--r-- | src/client/views/nodes/FieldView.tsx | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx index e53422ab7..85dd779fc 100644 --- a/src/client/views/nodes/FieldView.tsx +++ b/src/client/views/nodes/FieldView.tsx @@ -20,7 +20,7 @@ export interface FieldViewProps extends DocumentViewSharedProps { select: (isCtrlPressed: boolean) => void; isContentActive: (outsideReaction?: boolean) => boolean | undefined; - isDocumentActive?: () => boolean; + isDocumentActive?: () => boolean | undefined; isSelected: (outsideReaction?: boolean) => boolean; setHeight?: (height: number) => void; NativeDimScaling?: () => number; // scaling the DocumentView does to transform its contents into its panel & needed by ScreenToLocal NOTE: Must also be added to DocumentViewInternalsProps @@ -32,6 +32,7 @@ export interface FieldViewProps extends DocumentViewSharedProps { // See currentUserUtils headerTemplate for examples of creating text boxes from html which set some of these fields // Also, see InkingStroke for examples of creating text boxes from render() methods which set some of these fields backgroundColor?: string; + treeViewDoc?: Doc; color?: string; fontSize?: number; height?: number; @@ -49,50 +50,18 @@ export class FieldView extends React.Component<FieldViewProps> { @computed get field(): FieldResult { - const { Document, fieldKey } = this.props; + const { Document, fieldKey: fieldKey } = this.props; return Document[fieldKey]; } render() { const field = this.field; - if (field === undefined) { - return <p>{'<null>'}</p>; - } - // if (typeof field === "string") { - // return <p>{field}</p>; - // } - // else if (field instanceof RichTextField) { - // return <FormattedTextBox {...this.props} />; - // } - // else if (field instanceof ImageField) { - // return <ImageBox {...this.props} />; - // } - // else if (field instaceof PresBox) { - // return <PresBox {...this.props} />; - // } - // else if (field instanceof VideoField) { - // return <VideoBox {...this.props} />; - // } - // else if (field instanceof AudioField) { - // return <AudioBox {...this.props} />; - //} - else if (field instanceof DateField) { - return <p>{field.date.toLocaleString()}</p>; - } else if (field instanceof Doc) { - return ( - <p> - <b>{field.title?.toString()}</b> - </p> - ); - } else if (field instanceof List) { - return <div> {field.length ? field.map(f => Field.toString(f)).join(', ') : ''} </div>; - } - // bcz: this belongs here, but it doesn't render well so taking it out for now - else if (field instanceof WebField) { - return <p>{Field.toString(field.url.href)}</p>; - } else if (!(field instanceof Promise)) { - return <p>{Field.toString(field)}</p>; - } else { - return <p> {'Waiting for server...'} </p>; - } + // prettier-ignore + if (field instanceof Doc) return <p> <b>{field.title?.toString()}</b></p>; + if (field === undefined) return <p>{'<null>'}</p>; + if (field instanceof DateField) return <p>{field.date.toLocaleString()}</p>; + if (field instanceof List) return <div> {field.map(f => Field.toString(f)).join(', ')} </div>; + if (field instanceof WebField) return <p>{Field.toString(field.url.href)}</p>; + if (!(field instanceof Promise)) return <p>{Field.toString(field)}</p>; + return <p> {'Waiting for server...'} </p>; } } |