From 44a0bc3546eca5fa18f3599448ebcebf709e3f90 Mon Sep 17 00:00:00 2001 From: bob Date: Thu, 8 Aug 2019 10:58:04 -0400 Subject: fixed titling of aliases. fixed docking panel initial size. --- src/client/util/LinkManager.ts | 3 --- src/client/util/type_decls.d | 1 + src/client/views/collections/CollectionDockingView.tsx | 17 +++++++++++------ src/new_fields/Doc.ts | 6 +++++- 4 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') 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 { - _mainCont = React.createRef(); + _mainCont: HTMLDivElement | undefined = undefined; @observable private _panelWidth = 0; @observable private _panelHeight = 0; @observable private _document: Opt; @@ -567,9 +566,9 @@ export class DockedFrameRenderer extends React.Component { } 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 { @computed get content() { return ( -
{ + 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}
); 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 -- cgit v1.2.3-70-g09d2