aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/MainView.tsx2
-rw-r--r--src/client/views/linking/LinkMenu.tsx23
-rw-r--r--src/client/views/nodes/DocumentLinksButton.tsx4
3 files changed, 16 insertions, 13 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 007d531c8..d03cb1bb2 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -790,7 +790,7 @@ export class MainView extends React.Component {
<FormatShapePane />
<div style={{ display: "none" }}><RichTextMenu key="rich" /></div>
{LinkDescriptionPopup.descriptionPopup ? <LinkDescriptionPopup /> : null}
- {DocumentLinksButton.EditLink ? <LinkMenu location={DocumentLinksButton.EditLinkLoc} docView={DocumentLinksButton.EditLink} addDocTab={DocumentLinksButton.EditLink.props.addDocTab} changeFlyout={emptyFunction} /> : (null)}
+ {DocumentLinksButton.EditLink ? <LinkMenu docView={DocumentLinksButton.EditLink} addDocTab={DocumentLinksButton.EditLink.props.addDocTab} changeFlyout={emptyFunction} /> : (null)}
{LinkDocPreview.LinkInfo ? <LinkDocPreview location={LinkDocPreview.LinkInfo.Location} backgroundColor={this.defaultBackgroundColors}
linkDoc={LinkDocPreview.LinkInfo.linkDoc} linkSrc={LinkDocPreview.LinkInfo.linkSrc} href={LinkDocPreview.LinkInfo.href}
addDocTab={LinkDocPreview.LinkInfo.addDocTab} /> : (null)}
diff --git a/src/client/views/linking/LinkMenu.tsx b/src/client/views/linking/LinkMenu.tsx
index 7b5fb0127..8023928a1 100644
--- a/src/client/views/linking/LinkMenu.tsx
+++ b/src/client/views/linking/LinkMenu.tsx
@@ -19,7 +19,6 @@ interface Props {
docView: DocumentView;
changeFlyout: () => void;
addDocTab: (document: Doc, where: string) => boolean;
- location: number[];
}
@observer
@@ -85,17 +84,25 @@ export class LinkMenu extends React.Component<Props> {
return linkItems;
}
+ @computed
+ get position() {
+ const docView = this.props.docView;
+ const transform = (docView.props.ScreenToLocalTransform().scale(docView.props.ContentScaling())).inverse();
+ const [sptX, sptY] = transform.transformPoint(0, 0);
+ const [bptX, bptY] = transform.transformPoint(docView.props.PanelWidth(), docView.props.PanelHeight());
+ return { x: sptX, y: sptY, r: bptX, b: bptY };
+ }
+
render() {
+ console.log("computed", this.position.x, this.position.b);
const sourceDoc = this.props.docView.props.Document;
const groups: Map<string, Doc[]> = LinkManager.Instance.getRelatedGroupedLinks(sourceDoc);
return <div className="linkMenu" ref={this._linkMenuRef} >
- {!this._editingLink ? <div className="linkMenu-list" style={{
- left: this.props.location[0], top: this.props.location[1]
- }}>
- {this.renderAllGroups(groups)}
- </div> : <div className="linkMenu-listEditor" style={{
- left: this.props.location[0], top: this.props.location[1]
- }}>
+ {!this._editingLink ?
+ <div className="linkMenu-list" style={{ left: this.position.x, top: this.position.b + 15 }}>
+ {this.renderAllGroups(groups)}
+ </div> :
+ <div className="linkMenu-listEditor" style={{ left: this.position.x, top: this.position.b + 15 }}>
<LinkEditor sourceDoc={this.props.docView.props.Document} linkDoc={this._editingLink}
showLinks={action(() => this._editingLink = undefined)} />
</div>
diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx
index cb79e1522..c2f27c85a 100644
--- a/src/client/views/nodes/DocumentLinksButton.tsx
+++ b/src/client/views/nodes/DocumentLinksButton.tsx
@@ -74,7 +74,6 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp
}
} else if (!this.props.InMenu) {
DocumentLinksButton.EditLink = this.props.View;
- DocumentLinksButton.EditLinkLoc = [e.clientX + 10, e.clientY];
}
}));
}
@@ -91,7 +90,6 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp
//action(() => Doc.BrushDoc(this.props.View.Document));
} else if (!this.props.InMenu) {
DocumentLinksButton.EditLink = this.props.View;
- DocumentLinksButton.EditLinkLoc = [e.clientX + 10, e.clientY];
}
}
@@ -147,8 +145,6 @@ export class DocumentLinksButton extends React.Component<DocumentLinksButtonProp
@observable
public static EditLink: DocumentView | undefined;
- public static EditLinkLoc: number[] = [0, 0];
-
@action clearLinks() {
DocumentLinksButton.StartLink = undefined;