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.tsx20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 97ff346e4..70b20aec7 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -23,9 +23,7 @@ import { OpenWhere } from './nodes/OpenWhere';
* Many of these methods only make sense for specific viewBox'es, but they should be written to
* be as general as possible
*/
-export interface ViewBoxInterface {
- fieldKey?: string;
- annotationKey?: string;
+export class ViewBoxInterface<P> extends ObservableReactComponent<React.PropsWithChildren<P>> {
promoteCollection?: () => void; // moves contents of collection to parent
updateIcon?: () => void; // updates the icon representation of the document
getAnchor?: (addAsAnnotation: boolean, pinData?: PinProps) => Doc; // returns an Anchor Doc that represents the current state of the doc's componentview (e.g., the current playhead location of a an audio/video box)
@@ -61,7 +59,7 @@ export interface ViewBoxInterface {
snapPt?: (pt: { X: number; Y: number }, excludeSegs?: number[]) => { nearestPt: { X: number; Y: number }; distance: number };
search?: (str: string, bwd?: boolean, clear?: boolean) => boolean;
dontRegisterView?: () => boolean; // KeyValueBox's don't want to register their views
- isUnstyledView?: () => boolean; // SchemaView and KeyValue are untyled -- not tiles, no opacity
+ isUnstyledView?: () => boolean; // SchemaView and KeyValue are unstyled -- not titles, no opacity, no animations
}
/**
* DocComponent returns a React base class used by Doc views with accessors for unpacking the Document,layoutDoc, and dataDoc's
@@ -113,7 +111,7 @@ export function DocComponent<P extends DocComponentProps>() {
* Example views include: InkingStroke, FontIconBox, EquationBox, etc
*/
export function ViewBoxBaseComponent<P extends FieldViewProps>() {
- class Component extends ObservableReactComponent<React.PropsWithChildren<P>> {
+ class Component extends ViewBoxInterface<P> {
constructor(props: P) {
super(props);
makeObservable(this);
@@ -168,7 +166,7 @@ export function ViewBoxBaseComponent<P extends FieldViewProps>() {
* Example views include: PDFBox, ImageBox, MapBox, etc
*/
export function ViewBoxAnnotatableComponent<P extends FieldViewProps>() {
- class Component extends ObservableReactComponent<React.PropsWithChildren<P>> {
+ class Component extends ViewBoxInterface<P> {
@observable _annotationKeySuffix = () => 'annotations';
@observable _isAnyChildContentActive = false;
@@ -219,8 +217,7 @@ export function ViewBoxAnnotatableComponent<P extends FieldViewProps>() {
return this.fieldKey + (this._annotationKeySuffix() ? '_' + this._annotationKeySuffix() : '');
}
- @action.bound
- removeDocument(docIn: Doc | Doc[], annotationKey?: string, leavePushpin?: boolean, dontAddToRemoved?: boolean): boolean {
+ override removeDocument = (docIn: Doc | Doc[], annotationKey?: string, leavePushpin?: boolean, dontAddToRemoved?: boolean): boolean => {
const effectiveAcl = GetEffectiveAcl(this.dataDoc);
const docs = toList(docIn).filter(fdoc => [AclEdit, AclAdmin].includes(effectiveAcl) || GetEffectiveAcl(fdoc) === AclAdmin);
@@ -249,12 +246,11 @@ export function ViewBoxAnnotatableComponent<P extends FieldViewProps>() {
}
return false;
- }
+ };
// this is called with the document that was dragged and the collection to move it into.
// if the target collection is the same as this collection, then the move will be allowed.
// otherwise, the document being moved must be able to be removed from its container before
// moving it into the target.
- @action.bound
moveDocument = (docs: Doc | Doc[], targetCollection: Doc | undefined, addDocument: (doc: Doc | Doc[], annotationKey?: string) => boolean, annotationKey?: string): boolean => {
if (Doc.AreProtosEqual(this._props.Document, targetCollection)) {
return true;
@@ -265,8 +261,8 @@ export function ViewBoxAnnotatableComponent<P extends FieldViewProps>() {
}
return false;
};
- @action.bound
- addDocument = (docIn: Doc | Doc[], annotationKey?: string): boolean => {
+
+ override addDocument = (docIn: Doc | Doc[], annotationKey?: string): boolean => {
const docs = toList(docIn);
if (this._props.filterAddDocument?.(docs) === false || docs.find(fdoc => Doc.AreProtosEqual(fdoc, this.Document) && Doc.LayoutField(fdoc) === Doc.LayoutField(this.Document))) {
return false;