aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx5
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx3
-rw-r--r--src/client/views/nodes/DocumentBox.tsx33
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx2
4 files changed, 25 insertions, 18 deletions
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 28f620157..deff3d177 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -184,6 +184,11 @@ class TreeView extends React.Component<TreeViewProps> {
EditableView.loadId = doc[Id];
return this.props.addDocument(doc);
})}
+ onClick={() => {
+ SelectionManager.DeselectAll();
+ Doc.UserDoc().SelectedDocs = new List([this.props.document]);
+ return false;
+ }}
OnTab={undoBatch((shift?: boolean) => {
EditableView.loadId = this.dataDoc[Id];
shift ? this.props.outdentDocument?.() : this.props.indentDocument?.();
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index a331f736f..28f8bc048 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -542,8 +542,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
}, [[minx, maxx], [miny, maxy]]);
const cscale = this.props.ContainingCollectionDoc ? NumCast(this.props.ContainingCollectionDoc.scale) : 1;
- const panelDim = this.props.ScreenToLocalTransform().transformDirection(this.props.PanelWidth() / this.zoomScaling() * cscale,
- this.props.PanelHeight() / this.zoomScaling() * cscale);
+ const panelDim = [this.props.PanelWidth() * cscale / this.zoomScaling(), this.props.PanelHeight() * cscale / this.zoomScaling()];
if (ranges[0][0] - dx > (this.panX() + panelDim[0] / 2)) x = ranges[0][1] + panelDim[0] / 2;
if (ranges[0][1] - dx < (this.panX() - panelDim[0] / 2)) x = ranges[0][0] - panelDim[0] / 2;
if (ranges[1][0] - dy > (this.panY() + panelDim[1] / 2)) y = ranges[1][1] + panelDim[1] / 2;
diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx
index db7be334f..f04962db9 100644
--- a/src/client/views/nodes/DocumentBox.tsx
+++ b/src/client/views/nodes/DocumentBox.tsx
@@ -1,17 +1,16 @@
-import { IReactionDisposer, reaction } from "mobx";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { IReactionDisposer, reaction, computed } from "mobx";
import { observer } from "mobx-react";
import { Doc, Field } from "../../../new_fields/Doc";
import { documentSchema } from "../../../new_fields/documentSchemas";
-import { List } from "../../../new_fields/List";
import { makeInterface } from "../../../new_fields/Schema";
import { ComputedField } from "../../../new_fields/ScriptField";
-import { Cast, StrCast, BoolCast } from "../../../new_fields/Types";
-import { emptyFunction, emptyPath } from "../../../Utils";
+import { Cast, StrCast } from "../../../new_fields/Types";
+import { emptyPath } from "../../../Utils";
import { ContextMenu } from "../ContextMenu";
import { ContextMenuProps } from "../ContextMenuItem";
-import { DocComponent, DocAnnotatableComponent } from "../DocComponent";
+import { DocAnnotatableComponent } from "../DocComponent";
import { ContentFittingDocumentView } from "./ContentFittingDocumentView";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import "./DocumentBox.scss";
import { FieldView, FieldViewProps } from "./FieldView";
import React = require("react");
@@ -26,8 +25,8 @@ export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxS
_selections: Doc[] = [];
_curSelection = -1;
componentDidMount() {
- this._prevSelectionDisposer = reaction(() => Cast(this.props.Document[this.props.fieldKey], Doc) as Doc, (data) => {
- if (data && !this.isSelectionLocked()) {
+ this._prevSelectionDisposer = reaction(() => this.contentDoc[this.props.fieldKey], (data) => {
+ if (data instanceof Doc && !this.isSelectionLocked()) {
this._selections.indexOf(data) !== -1 && this._selections.splice(this._selections.indexOf(data), 1);
this._selections.push(data);
this._curSelection = this._selections.length - 1;
@@ -40,19 +39,23 @@ export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxS
specificContextMenu = (e: React.MouseEvent): void => {
const funcs: ContextMenuProps[] = [];
funcs.push({ description: (this.isSelectionLocked() ? "Show" : "Lock") + " Selection", event: () => this.toggleLockSelection, icon: "expand-arrows-alt" });
+ funcs.push({ description: (this.props.Document.excludeCollections ? "Include" : "Exclude") + " Collections", event: () => this.props.Document.excludeCollections = !this.props.Document.excludeCollections, icon: "expand-arrows-alt" });
funcs.push({ description: `${this.props.Document.forceActive ? "Select" : "Force"} Contents Active`, event: () => this.props.Document.forceActive = !this.props.Document.forceActive, icon: "project-diagram" });
ContextMenu.Instance.addItem({ description: "DocumentBox Funcs...", subitems: funcs, icon: "asterisk" });
}
+ @computed get contentDoc() {
+ return (this.props.Document.isTemplateDoc || this.props.Document.isTemplateForField ? this.props.Document : Doc.GetProto(this.props.Document));
+ }
lockSelection = () => {
- Doc.GetProto(this.props.Document)[this.props.fieldKey] = this.props.Document[this.props.fieldKey];
+ this.contentDoc[this.props.fieldKey] = this.props.Document[this.props.fieldKey];
}
showSelection = () => {
- Doc.GetProto(this.props.Document)[this.props.fieldKey] = ComputedField.MakeFunction("selectedDocs(this,true,[_last_])?.[0]");
+ this.contentDoc[this.props.fieldKey] = ComputedField.MakeFunction(`selectedDocs(this,this.excludeCollections,[_last_])?.[0]`);
}
isSelectionLocked = () => {
- const kvpstring = Field.toKeyValueString(this.props.Document, this.props.fieldKey);
- return !(kvpstring.startsWith("=") || kvpstring.startsWith(":="));
+ const kvpstring = Field.toKeyValueString(this.contentDoc, this.props.fieldKey);
+ return !kvpstring || kvpstring.includes("DOC");
}
toggleLockSelection = () => {
!this.isSelectionLocked() ? this.lockSelection() : this.showSelection();
@@ -61,13 +64,13 @@ export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxS
prevSelection = () => {
this.lockSelection();
if (this._curSelection > 0) {
- Doc.GetProto(this.props.Document)[this.props.fieldKey] = this._selections[--this._curSelection];
+ this.contentDoc[this.props.fieldKey] = this._selections[--this._curSelection];
return true;
}
}
nextSelection = () => {
if (this._curSelection < this._selections.length - 1 && this._selections.length) {
- Doc.GetProto(this.props.Document)[this.props.fieldKey] = this._selections[++this._curSelection];
+ this.contentDoc[this.props.fieldKey] = this._selections[++this._curSelection];
return true;
}
}
@@ -94,7 +97,7 @@ export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxS
pheight = () => this.props.PanelHeight() - 30;
getTransform = () => this.props.ScreenToLocalTransform().translate(-15, -15);
render() {
- const containedDoc = this.dataDoc[this.props.fieldKey] as Doc;
+ const containedDoc = this.contentDoc[this.props.fieldKey];
return <div className="documentBox-container" ref={this._contRef}
onContextMenu={this.specificContextMenu}
onPointerDown={this.onPointerDown} onClick={this.onClick}
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index dcb6d4a31..f121ba3e0 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -91,7 +91,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
render() {
TraceMobx();
- return (this.props.renderDepth > 7 || !this.layout || !this.layoutDoc) ? (null) :
+ return (this.props.renderDepth > 12 || !this.layout || !this.layoutDoc) ? (null) :
<ObserverJsxParser
blacklistedAttrs={[]}
components={{