aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-08-08 10:58:04 -0400
committerbob <bcz@cs.brown.edu>2019-08-08 10:58:04 -0400
commit44a0bc3546eca5fa18f3599448ebcebf709e3f90 (patch)
tree83e44be4be892e05f8b750fcf708ef69b33c6687
parentff087aca29a01a8aa254148c9ab6082c3921fb3b (diff)
fixed titling of aliases. fixed docking panel initial size.
-rw-r--r--src/client/util/LinkManager.ts3
-rw-r--r--src/client/util/type_decls.d1
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx17
-rw-r--r--src/new_fields/Doc.ts6
4 files changed, 17 insertions, 10 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index c87e4a022..8a668e8d8 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -253,6 +253,3 @@ Scripting.addGlobal(function links(doc: any) {
return new List(LinkManager.Instance.getAllRelatedLinks(doc));
});
-Scripting.addGlobal(function renameAlias(doc: any, n: any) {
- return doc.title;// StrCast(doc.title).replace(/\\([0-9]*\\)/, "") + `(${n})`;
-});
diff --git a/src/client/util/type_decls.d b/src/client/util/type_decls.d
index 79a4e50d5..622e10960 100644
--- a/src/client/util/type_decls.d
+++ b/src/client/util/type_decls.d
@@ -74,6 +74,7 @@ interface String {
normalize(form: "NFC" | "NFD" | "NFKC" | "NFKD"): string;
normalize(form?: string): string;
repeat(count: number): string;
+ replace(a:any, b:any):string; // bcz: fix this
startsWith(searchString: string, position?: number): boolean;
anchor(name: string): string;
big(): string;
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index ab537a356..feca66bc3 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -18,7 +18,6 @@ import { SelectionManager } from '../../util/SelectionManager';
import { Transform } from '../../util/Transform';
import { undoBatch, UndoManager } from "../../util/UndoManager";
import { DocumentView } from "../nodes/DocumentView";
-import { CollectionViewType } from './CollectionBaseView';
import "./CollectionDockingView.scss";
import { SubCollectionViewProps } from "./CollectionSubView";
import { ParentDocSelector } from './ParentDocumentSelector';
@@ -509,7 +508,7 @@ interface DockedFrameProps {
}
@observer
export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
- _mainCont = React.createRef<HTMLDivElement>();
+ _mainCont: HTMLDivElement | undefined = undefined;
@observable private _panelWidth = 0;
@observable private _panelHeight = 0;
@observable private _document: Opt<Doc>;
@@ -567,9 +566,9 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
}
ScreenToLocalTransform = () => {
- if (this._mainCont.current && this._mainCont.current.children) {
- let { scale, translateX, translateY } = Utils.GetScreenTransform(this._mainCont.current.children[0].firstChild as HTMLElement);
- scale = Utils.GetScreenTransform(this._mainCont.current).scale;
+ if (this._mainCont && this._mainCont!.children) {
+ let { scale, translateX, translateY } = Utils.GetScreenTransform(this._mainCont.children[0].firstChild as HTMLElement);
+ scale = Utils.GetScreenTransform(this._mainCont).scale;
return CollectionDockingView.Instance.props.ScreenToLocalTransform().translate(-translateX, -translateY).scale(1 / this.contentScaling() / scale);
}
return Transform.Identity();
@@ -614,7 +613,13 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
@computed get content() {
return (
- <div className="collectionDockingView-content" ref={this._mainCont}
+ <div className="collectionDockingView-content" ref={action((ref: HTMLDivElement) => {
+ this._mainCont = ref;
+ if (ref) {
+ this._panelWidth = Number(getComputedStyle(ref).width!.replace("px", ""));
+ this._panelHeight = Number(getComputedStyle(ref).height!.replace("px", ""));
+ }
+ })}
style={{ transform: `translate(${this.previewPanelCenteringOffset}px, 0px)` }}>
{this.docView}
</div >);
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index c51b42e07..ba01cfd9c 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -393,6 +393,7 @@ export namespace Doc {
let alias = !GetT(doc, "isPrototype", "boolean", true) ? Doc.MakeCopy(doc) : Doc.MakeDelegate(doc);
let aliasNumber = Doc.GetProto(doc).aliasNumber = NumCast(Doc.GetProto(doc).aliasNumber) + 1;
let script = `return renameAlias(self, ${aliasNumber})`;
+ //let script = "StrCast(self.title).replace(/\\([0-9]*\\)/, \"\") + `(${n})`";
let compiled = CompileScript(script, { params: { this: "Doc" }, capturedVariables: { self: doc }, typecheck: false });
if (compiled.compiled) {
alias.title = new ComputedField(compiled);
@@ -588,4 +589,7 @@ export namespace Doc {
let index = manager.BrushedDoc.indexOf(doc);
if (index !== -1) runInAction(() => manager.BrushedDoc.splice(index, 1));
}
-} \ No newline at end of file
+}
+Scripting.addGlobal(function renameAlias(doc: any, n: any) {
+ return StrCast(doc.title).replace(/\([0-9]*\)/, "") + `(${n})`;
+}); \ No newline at end of file