aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/documents/Documents.ts15
-rw-r--r--src/client/util/DocumentManager.ts11
-rw-r--r--src/client/views/DocumentDecorations.tsx3
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx4
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx35
-rw-r--r--src/client/views/nodes/DocumentContentsView.tsx32
-rw-r--r--src/client/views/nodes/DocumentView.tsx9
7 files changed, 28 insertions, 81 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index d979e0a3f..b53549f7a 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -80,7 +80,6 @@ export interface DocumentOptions {
opacity?: number;
defaultBackgroundColor?: string;
dropAction?: dropActionType;
- backgroundLayout?: string;
chromeStatus?: string;
columnWidth?: number;
fontSize?: number;
@@ -127,7 +126,6 @@ export namespace Docs {
layout: {
view: LayoutSource,
ext?: string, // optional extension field for layout source
- collectionView?: CollectionViewType
},
options?: Partial<DocumentOptions>
};
@@ -142,7 +140,7 @@ export namespace Docs {
options: { height: 150, backgroundColor: "#f1efeb", defaultBackgroundColor: "#f1efeb" }
}],
[DocumentType.HIST, {
- layout: { view: HistogramBox, collectionView: [CollectionView, data] as CollectionViewType },
+ layout: { view: HistogramBox },
options: { height: 300, backgroundColor: "black" }
}],
[DocumentType.QUERY, {
@@ -290,15 +288,8 @@ export namespace Docs {
// synthesize the default options, the type and title from computed values and
// whatever options pertain to this specific prototype
let options = { title, type, baseProto: true, ...defaultOptions, ...(template.options || {}) };
- let primary = layout.view.LayoutString(layout.ext);
- let collectionView = layout.collectionView;
- if (collectionView) {
- options.layout = collectionView[0].LayoutString(collectionView[1], collectionView[2]);
- options.backgroundLayout = primary;
- } else {
- options.layout = primary;
- }
- return Doc.assign(new Doc(prototypeId, true), { ...options, baseLayout: primary });
+ options.layout = layout.view.LayoutString(layout.ext);
+ return Doc.assign(new Doc(prototypeId, true), { ...options, baseLayout: options.layout });
}
}
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index aed7aafd1..ee6772f8f 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -1,5 +1,5 @@
import { action, computed, observable } from 'mobx';
-import { Doc, DocListCastAsync } from '../../new_fields/Doc';
+import { Doc, DocListCastAsync, DocListCast } from '../../new_fields/Doc';
import { Id } from '../../new_fields/FieldSymbols';
import { List } from '../../new_fields/List';
import { Cast, NumCast, StrCast } from '../../new_fields/Types';
@@ -100,7 +100,13 @@ export class DocumentManager {
@computed
public get LinkedDocumentViews() {
- let pairs = DocumentManager.Instance.DocumentViews.filter(dv => dv.isSelected() || Doc.IsBrushed(dv.props.Document)).reduce((pairs, dv) => {
+ let pairs = DocumentManager.Instance.DocumentViews.filter(dv => dv.isSelected() || Doc.IsBrushed(dv.props.Document)
+ || DocumentManager.Instance.DocumentViews.some(dv2 => {
+ let init = dv2.isSelected() || Doc.IsBrushed(dv2.props.Document);
+ let rest = DocListCast(dv2.props.Document.links).some(l => Doc.AreProtosEqual(l, dv.props.Document));
+ return init && rest;
+ })
+ ).reduce((pairs, dv) => {
let linksList = LinkManager.Instance.getAllRelatedLinks(dv.props.Document);
pairs.push(...linksList.reduce((pairs, link) => {
let linkToDoc = link && LinkManager.Instance.getOppositeAnchor(link, dv.props.Document);
@@ -111,7 +117,6 @@ export class DocumentManager {
});
return pairs;
}, [] as { a: DocumentView, b: DocumentView, l: Doc }[]));
- // }
return pairs;
}, [] as { a: DocumentView, b: DocumentView, l: Doc }[]);
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index 6e8ba2d3d..8409a34da 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -111,7 +111,6 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
Doc.GetProto(docTemplate).layoutNative = layoutNative;
swapViews(fieldTemplate, "", "layoutNative", layoutNative);
layoutNative.layout = StrCast(fieldTemplateView.props.Document.layout).replace(/fieldKey={"[^"]*"}/, `fieldKey={"${metaKey}"}`);
- layoutNative.backgroundLayout = StrCast(fieldTemplateView.props.Document.backgroundLayout).replace(/fieldKey={"[^"]*"}/, `fieldKey={"${metaKey}"}`);
}
}
}
@@ -343,7 +342,7 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
let iconDoc: Doc | undefined = await Cast(doc.minimizedDoc, Doc);
if (!iconDoc || !DocumentManager.Instance.getDocumentView(iconDoc)) {
- const layout = StrCast(doc.backgroundLayout, StrCast(doc.layout, FieldView.LayoutString(DocumentView)));
+ const layout = StrCast(doc.layout, FieldView.LayoutString(DocumentView));
iconDoc = this.createIcon([docView], layout);
}
return iconDoc;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
index a26febda4..e9191c176 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
@@ -68,9 +68,7 @@ export class CollectionFreeFormLinksView extends React.Component {
// });
}
componentWillUnmount() {
- if (this._brushReactionDisposer) {
- this._brushReactionDisposer();
- }
+ this._brushReactionDisposer && this._brushReactionDisposer();
}
@computed
get uniqueConnections() {
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index b3270d507..932b6722b 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -467,22 +467,6 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
getScale: this.getScale
};
}
- getDocumentViewProps(layoutDoc: Doc): DocumentViewProps {
- return {
- ...this.props,
- ScreenToLocalTransform: this.getTransform,
- PanelWidth: layoutDoc[WidthSym],
- PanelHeight: layoutDoc[HeightSym],
- ContentScaling: returnOne,
- ContainingCollectionView: this.props.ContainingCollectionView,
- focus: this.focusDocument,
- backgroundColor: returnEmptyString,
- parentActive: this.props.active,
- bringToFront: this.bringToFront,
- zoomToScale: this.zoomToScale,
- getScale: this.getScale
- };
- }
getCalculatedPositions(params: { doc: Doc, index: number, collection: Doc, docs: Doc[], state: any }): { x?: number, y?: number, z?: number, width?: number, height?: number, transition?: string, state?: any } {
const script = this.Document.arrangeScript;
@@ -682,7 +666,6 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
private childViews = () => {
let children = typeof this.props.children === "function" ? (this.props.children as any)() as JSX.Element[] : [];
return [
- <CollectionFreeFormBackgroundView key="backgroundView" {...this.props} {...this.getDocumentViewProps(this.props.Document)} />,
...children,
...this.views,
];
@@ -712,29 +695,11 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
</CollectionFreeFormViewPannableContents>
</MarqueeView>
{this.overlayViews}
- <CollectionFreeFormOverlayView {...this.props} {...this.getDocumentViewProps(this.props.Document)} />
</div>
);
}
}
-@observer
-class CollectionFreeFormOverlayView extends React.Component<DocumentViewProps & { isSelected: () => boolean }> {
- render() {
- return <DocumentContentsView {...this.props} layoutKey={"overlayLayout"}
- renderDepth={this.props.renderDepth} isSelected={this.props.isSelected} select={emptyFunction} />;
- }
-}
-
-@observer
-class CollectionFreeFormBackgroundView extends React.Component<DocumentViewProps & { isSelected: () => boolean }> {
- render() {
- return !this.props.Document.backgroundLayout ? (null) :
- (<DocumentContentsView {...this.props} layoutKey={"backgroundLayout"}
- renderDepth={this.props.renderDepth} isSelected={this.props.isSelected} select={emptyFunction} />);
- }
-}
-
interface CollectionFreeFormViewPannableContentsProps {
centeringShiftX: () => number;
centeringShiftY: () => number;
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 4971e6ce5..d375405b9 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -92,26 +92,20 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
return { props: list };
}
- @computed get finalLayout() {
- return this.props.layoutKey === "overlayLayout" ? "<div/>" : this.layout;
- }
-
render() {
- let self = this;
- if (this.props.renderDepth > 7) return (null);
- if (!this.layout && this.props.layoutKey !== "overlayLayout") return (null);
- return <ObserverJsxParser
- blacklistedAttrs={[]}
- components={{
- FormattedTextBox, ImageBox, IconBox, DirectoryImportBox, FontIconBox: FontIconBox, ButtonBox, FieldView,
- CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
- PDFBox, VideoBox, AudioBox, HistogramBox, PresBox, YoutubeBox, LinkFollowBox, PresElementBox, QueryBox, ColorBox, DocuLinkBox
- }}
- bindings={this.CreateBindings()}
- jsx={this.finalLayout}
- showWarnings={true}
+ return (this.props.renderDepth > 7 || !this.layout) ? (null) :
+ <ObserverJsxParser
+ blacklistedAttrs={[]}
+ components={{
+ FormattedTextBox, ImageBox, IconBox, DirectoryImportBox, FontIconBox: FontIconBox, ButtonBox, FieldView,
+ CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
+ PDFBox, VideoBox, AudioBox, HistogramBox, PresBox, YoutubeBox, LinkFollowBox, PresElementBox, QueryBox, ColorBox, DocuLinkBox
+ }}
+ bindings={this.CreateBindings()}
+ jsx={this.layout}
+ showWarnings={true}
- onError={(test: any) => { console.log(test); }}
- />;
+ onError={(test: any) => { console.log(test); }}
+ />;
}
} \ No newline at end of file
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index d4c2c512c..48ad7a632 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -163,6 +163,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
@action
componentWillUnmount() {
this._dropDisposer && this._dropDisposer();
+ Doc.UnBrushDoc(this.props.Document);
DocumentManager.Instance.DocumentViews.splice(DocumentManager.Instance.DocumentViews.indexOf(this), 1);
}
@@ -697,11 +698,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
opacity: this.Document.opacity
}}
onDrop={this.onDrop} onContextMenu={this.onContextMenu} onPointerDown={this.onPointerDown} onClick={this.onClick}
- onPointerEnter={() => {
- Doc.UnBrushAllDocs();
- DocListCast(this.props.Document.links).map(Doc.BrushDoc);
- Doc.BrushDoc(this.props.Document);
- }} onPointerLeave={() => Doc.UnBrushDoc(this.props.Document)}
+ onPointerEnter={() => Doc.BrushDoc(this.props.Document)} onPointerLeave={() => Doc.UnBrushDoc(this.props.Document)}
>
{this.props.Document.links && DocListCast(this.props.Document.links).map((d, i) =>
<div style={{ pointerEvents: "none", position: "absolute", transformOrigin: "top left", width: "100%", height: "100%", transform: `scale(${this.props.Document.fitWidth ? 1 : 1 / this.props.ContentScaling()})` }}>
@@ -739,7 +736,6 @@ export async function swapViews(doc: Doc, newLayoutField: string, oldLayoutField
oldLayoutExt.nativeWidth = doc.nativeWidth;
oldLayoutExt.nativeHeight = doc.nativeHeight;
oldLayoutExt.ignoreAspect = doc.ignoreAspect;
- oldLayoutExt.backgroundLayout = doc.backgroundLayout;
oldLayoutExt.type = doc.type;
oldLayoutExt.layout = doc.layout;
}
@@ -752,7 +748,6 @@ export async function swapViews(doc: Doc, newLayoutField: string, oldLayoutField
doc.nativeWidth = newLayoutExt.nativeWidth;
doc.nativeHeight = newLayoutExt.nativeHeight;
doc.ignoreAspect = newLayoutExt.ignoreAspect;
- doc.backgroundLayout = newLayoutExt.backgroundLayout;
doc.type = newLayoutExt.type;
doc.layout = await newLayoutExt.layout;
}