blob: b9a97b42d36abb83f9523f90bc12f57bfc0bd8b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import { observer } from "mobx-react";
import { Doc } from "../../../new_fields/Doc";
import { documentSchema } from "../../../new_fields/documentSchemas";
import { makeInterface } from "../../../new_fields/Schema";
import { ComputedField } from "../../../new_fields/ScriptField";
import { emptyFunction, emptyPath } from "../../../Utils";
import { ContextMenu } from "../ContextMenu";
import { ContextMenuProps } from "../ContextMenuItem";
import { DocComponent } from "../DocComponent";
import { ContentFittingDocumentView } from "./ContentFittingDocumentView";
import "./DocumentBox.scss";
import { FieldView, FieldViewProps } from "./FieldView";
import React = require("react");
type DocBoxSchema = makeInterface<[typeof documentSchema]>;
const DocBoxDocument = makeInterface(documentSchema);
@observer
export class DocumentBox extends DocComponent<FieldViewProps, DocBoxSchema>(DocBoxDocument) {
public static LayoutString(fieldKey: string) { return FieldView.LayoutString(DocumentBox, fieldKey); }
specificContextMenu = (e: React.MouseEvent): void => {
const funcs: ContextMenuProps[] = [];
funcs.push({ description: "Auto Show Selected", event: () => Doc.GetProto(this.props.Document).data = ComputedField.MakeFunction("selectedDocs(this,true,[_last_])?.[0]"), icon: "expand-arrows-alt" });
ContextMenu.Instance.addItem({ description: "DocumentBox Funcs...", subitems: funcs, icon: "asterisk" });
}
render() {
const containedDoc = this.props.Document[this.props.fieldKey] as Doc;
return <div className="documentBox-container" onContextMenu={this.specificContextMenu}>
{!containedDoc ? (null) : <ContentFittingDocumentView
Document={containedDoc}
DataDocument={undefined}
LibraryPath={emptyPath}
fitToBox={this.props.fitToBox}
addDocument={this.props.addDocument}
moveDocument={this.props.moveDocument}
removeDocument={this.props.removeDocument}
ruleProvider={this.props.ruleProvider}
addDocTab={this.props.addDocTab}
pinToPres={this.props.pinToPres}
getTransform={this.props.ScreenToLocalTransform}
renderDepth={this.props.renderDepth - 1}
PanelWidth={this.props.PanelWidth}
PanelHeight={this.props.PanelHeight}
focus={this.props.focus}
active={this.props.active}
whenActiveChanged={this.props.whenActiveChanged}
setPreviewScript={emptyFunction}
previewScript={undefined}
/>}
</div>;
}
}
|