diff options
| author | Andy Rickert <andrew_rickert@brown.edu> | 2020-06-03 16:40:09 -0400 | 
|---|---|---|
| committer | Andy Rickert <andrew_rickert@brown.edu> | 2020-06-03 16:40:09 -0400 | 
| commit | 954948ddd511578af4ca2c50c960765a5a7bc637 (patch) | |
| tree | 16fafd254a5db95d5c39838d4313d7ddf59753af /src/client/views/DocComponent.tsx | |
| parent | 6d8d3c00587c43ae61392db4fe6915ee492c2e4a (diff) | |
| parent | 9588e56079f7e4ab98da1849f44996656649bc06 (diff) | |
merge
Diffstat (limited to 'src/client/views/DocComponent.tsx')
| -rw-r--r-- | src/client/views/DocComponent.tsx | 26 | 
1 files changed, 20 insertions, 6 deletions
| diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index 881e352a6..1ba9fcc32 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -1,13 +1,14 @@ -import { Doc, Opt, DataSym, DocListCast } from '../../new_fields/Doc'; +import { Doc, Opt, DataSym, DocListCast } from '../../fields/Doc';  import { Touchable } from './Touchable';  import { computed, action, observable } from 'mobx'; -import { Cast, BoolCast, ScriptCast } from '../../new_fields/Types'; -import { listSpec } from '../../new_fields/Schema'; +import { Cast, BoolCast, ScriptCast } from '../../fields/Types'; +import { listSpec } from '../../fields/Schema';  import { InkingControl } from './InkingControl'; -import { InkTool } from '../../new_fields/InkField'; +import { InkTool } from '../../fields/InkField';  import { InteractionUtils } from '../util/InteractionUtils'; -import { List } from '../../new_fields/List'; -import { DateField } from '../../new_fields/DateField'; +import { List } from '../../fields/List'; +import { DateField } from '../../fields/DateField'; +import { ScriptField } from '../../fields/ScriptField';  ///  DocComponent returns a generic React base class used by views that don't have 'fieldKey' props (e.g.,CollectionFreeFormDocumentView, DocumentView) @@ -94,6 +95,19 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T          lookupField = (field: string) => ScriptCast((this.layoutDoc as any).lookupField)?.script.run({ self: this.layoutDoc, data: this.rootDoc, field: field }).result; +        styleFromLayoutString = (scale: number) => { +            const style: { [key: string]: any } = {}; +            const divKeys = ["width", "height", "background", "top", "position"]; +            const replacer = (match: any, expr: string, offset: any, string: any) => { // bcz: this executes a script to convert a property expression string:  { script }  into a value +                return ScriptField.MakeFunction(expr, { self: Doc.name, this: Doc.name, scale: "number" })?.script.run({ self: this.rootDoc, this: this.layoutDoc, scale }).result as string || ""; +            }; +            divKeys.map((prop: string) => { +                const p = (this.props as any)[prop] as string; +                p && (style[prop] = p?.replace(/{([^.'][^}']+)}/g, replacer)); +            }); +            return style; +        } +          protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;          _annotationKey: string = "annotations"; | 
