aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/DocComponent.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r--src/client/views/DocComponent.tsx10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index b5bd17572..dfc298840 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -12,12 +12,14 @@ import { DocumentManager } from '../util/DocumentManager';
import { ObservableReactComponent } from './ObservableReactComponent';
import { CollectionFreeFormView } from './collections/collectionFreeForm';
import { DocumentView } from './nodes/DocumentView';
+import { Transform } from '../util/Transform';
/// DocComponent returns a generic React base class used by views that don't have 'fieldKey' props (e.g.,CollectionFreeFormDocumentView, DocumentView)
export interface DocComponentProps {
Document: Doc;
LayoutTemplate?: () => Opt<Doc>;
LayoutTemplateString?: string;
+ ScreenToLocalTransform: () => Transform;
}
export function DocComponent<P extends DocComponentProps>() {
class Component extends ObservableReactComponent<React.PropsWithChildren<P>> {
@@ -26,6 +28,8 @@ export function DocComponent<P extends DocComponentProps>() {
makeObservable(this);
}
+ ScreenToLocalBoxXf = () => this._props.ScreenToLocalTransform();
+
//TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then
get Document() {
return this._props.Document;
@@ -50,10 +54,13 @@ interface ViewBoxBaseProps {
fieldKey: string;
isSelected: () => boolean;
isContentActive: () => boolean | undefined;
+ ScreenToLocalTransform: () => Transform;
renderDepth: number;
}
export function ViewBoxBaseComponent<P extends ViewBoxBaseProps>() {
class Component extends ObservableReactComponent<React.PropsWithChildren<P>> {
+ ScreenToLocalBoxXf = () => this._props.ScreenToLocalTransform();
+
//TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then
get Document() {
return this._props.Document;
@@ -83,6 +90,7 @@ export interface ViewBoxAnnotatableProps {
isContentActive: () => boolean | undefined;
select: (isCtrlPressed: boolean) => void;
whenChildContentsActiveChanged: (isActive: boolean) => void;
+ ScreenToLocalTransform: () => Transform;
isSelected: () => boolean;
renderDepth: number;
isAnnotationOverlay?: boolean;
@@ -94,6 +102,8 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps>()
makeObservable(this);
}
+ ScreenToLocalBoxXf = () => this._props.ScreenToLocalTransform();
+
@observable _annotationKeySuffix = () => 'annotations';
@observable _isAnyChildContentActive = false;
//TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then