diff options
author | bobzel <zzzman@gmail.com> | 2024-03-31 23:09:53 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-03-31 23:09:53 -0400 |
commit | 108e27f0d08a8d6d3b3fcd456d6cca999c077e8b (patch) | |
tree | 1941a7b26f4cfe5abcb6c2c622c2e363a27b6a55 /src/fields/util.ts | |
parent | 1e37adacfe5b44a71ed7d7dfd785c6c2d0808eae (diff) |
fixed scrolling to targets in text views. fixed referencing fields on another doc from text box. fixed '@name' technique for publishing documents to also remove documents and work anywhere a title is set.
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r-- | src/fields/util.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts index c2ec3f13a..ad592391e 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -1,4 +1,4 @@ -import { $mobx, action, observable, runInAction, trace } from 'mobx'; +import { $mobx, action, observable, runInAction, trace, values } from 'mobx'; import { computedFn } from 'mobx-utils'; import { returnZero } from '../Utils'; import { DocServer } from '../client/DocServer'; @@ -16,6 +16,7 @@ import { RichTextField } from './RichTextField'; import { SchemaHeaderField } from './SchemaHeaderField'; import { ComputedField } from './ScriptField'; import { DocCast, ScriptCast, StrCast } from './Types'; +import { BaseException } from 'pdfjs-dist/types/src/shared/util'; function _readOnlySetter(): never { throw new Error("Documents can't be modified in read-only mode"); @@ -56,6 +57,8 @@ const _setterImpl = action(function (target: any, prop: string | symbol | number delete curValue[FieldChanged]; } + if (typeof prop === 'string' && _propSetterCB.has(prop)) _propSetterCB.get(prop)!(target[SelfProxy], value); + const effectiveAcl = GetEffectiveAcl(target); const writeMode = DocServer.getFieldWriteMode(prop as string); @@ -282,6 +285,17 @@ export function distributeAcls(key: string, acl: SharingPermissions, target: Doc dataDocChanged && updateCachedAcls(dataDoc); } +export var _propSetterCB = new Map<string, ((target: any, value: any) => void) | undefined>(); +/** + * sets a callback function to be called whenever a value is assigned to the specified field key. + * For example, this is used to "publish" documents with titles that start with '@' + * @param prop + * @param setter + */ +export function SetPropSetterCb(prop: string, setter: ((target: any, value: any) => void) | undefined) { + _propSetterCB.set(prop, setter); +} + // // target should be either a Doc or ListImpl. receiver should be a Proxy<Doc> Or List. // |