diff options
Diffstat (limited to 'src/fields/Proxy.ts')
-rw-r--r-- | src/fields/Proxy.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/fields/Proxy.ts b/src/fields/Proxy.ts index 1266e6e3c..55d1d9ea4 100644 --- a/src/fields/Proxy.ts +++ b/src/fields/Proxy.ts @@ -5,9 +5,8 @@ import { observable, action, runInAction, computed } from 'mobx'; import { DocServer } from '../client/DocServer'; import { RefField } from './RefField'; import { ObjectField } from './ObjectField'; -import { Id, Copy, ToScriptString, ToString } from './FieldSymbols'; +import { Id, Copy, ToScriptString, ToString, ToValue } from './FieldSymbols'; import { scriptingGlobal } from '../client/util/ScriptingGlobals'; -import { Plugins } from './util'; function deserializeProxy(field: any) { if (!field.cache.field) { @@ -30,6 +29,10 @@ export class ProxyField<T extends RefField> extends ObjectField { } } + [ToValue](doc: any) { + return ProxyField.toValue(this); + } + [Copy]() { if (this.cache.field) return new ProxyField<T>(this.cache.field); return new ProxyField<T>(this.fieldId); @@ -105,12 +108,10 @@ export namespace ProxyField { } } - export function initPlugin() { - Plugins.addGetterPlugin((doc, _, value) => { - if (useProxy && value instanceof ProxyField) { - return { value: value.value }; - } - }); + export function toValue(value: any) { + if (useProxy) { + return { value: value.value }; + } } } |