aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-15 15:43:24 -0400
committerbobzel <zzzman@gmail.com>2021-09-15 15:43:24 -0400
commit1395ce3fbf73bf5df5ed4add744c333cfc8008c9 (patch)
treeac3b3c91e1e286dce93c4ec215f169f60e0be6fd /src
parentc3758877393812d5c25230b486d1b235796fc1bc (diff)
another windows fix for contextmenus on web pages
Diffstat (limited to 'src')
-rw-r--r--src/client/views/MainView.tsx1
-rw-r--r--src/client/views/nodes/WebBox.tsx30
2 files changed, 19 insertions, 12 deletions
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 5bda9f6bf..d854f118f 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -214,6 +214,7 @@ export class MainView extends React.Component {
}
}
}, false);
+ document.oncontextmenu = () => false;
}
initAuthenticationRouters = async () => {
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index fe5070fa4..cce71329d 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -224,15 +224,20 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
}
// bcz: hack - iframe grabs all events which messes up how we handle contextMenus. So this super naively simulates the event stack to get the specific menu items and the doc view menu items.
- if (e.button === 2 && ContextMenu.Instance.getItems().length) {
- ContextMenu.Instance.displayMenu(e.pageX, e.pageY);
- }
- else {
- ContextMenu.Instance.closeMenu();
- if (e.button === 2) {
+ if (e.button === 2) {
+ e.preventDefault();
+ e.stopPropagation();
+ const where = this.props.ScreenToLocalTransform().inverse().transformPoint(e.pageX, e.pageY);
+ if (ContextMenu.Instance.getItems().length) {
+ ContextMenu.Instance.displayMenu(where[0], where[1]);
+ }
+ else {
+ ContextMenu.Instance.closeMenu();
this.specificContextMenu(e);
- this.props.docViewPath().lastElement().docView?.onContextMenu(undefined, e.pageX, e.pageY);
+ this.props.docViewPath().lastElement().docView?.onContextMenu(undefined, where[0], where[1]);
}
+ } else {
+ ContextMenu.Instance.closeMenu();
}
}
@@ -511,11 +516,12 @@ export class WebBox extends ViewBoxAnnotatableComponent<ViewBoxAnnotatableProps
@computed get annotationLayer() {
TraceMobx();
- return <div className="webBox-annotationLayer" style={{ height: Doc.NativeHeight(this.Document) || undefined }} ref={this._annotationLayer}>
- {this.inlineTextAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y)).map(anno =>
- <Annotation {...this.props} fieldKey={this.annotationKey} showInfo={this.showInfo} dataDoc={this.dataDoc} anno={anno} key={`${anno[Id]}-annotation`} />)
- }
- </div>;
+ return !this.inlineTextAnnotations.length ? (null) :
+ <div className="webBox-annotationLayer" style={{ height: Doc.NativeHeight(this.Document) || undefined }} ref={this._annotationLayer}>
+ {this.inlineTextAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y)).map(anno =>
+ <Annotation {...this.props} fieldKey={this.annotationKey} showInfo={this.showInfo} dataDoc={this.dataDoc} anno={anno} key={`${anno[Id]}-annotation`} />)
+ }
+ </div>;
}
@observable _showSidebar = false;