119 lines
3.4 KiB
TypeScript
119 lines
3.4 KiB
TypeScript
// Metro module 5188 (f5189).
|
|
import { AppContext } from "../Constants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import { getCurrentlyInteractingAppContext } from "../modules/main_app_window/web/AppWindowContext";
|
|
import { isDesktop } from "../utils/PlatformUtils";
|
|
import { addResultListener } from "../utils/SpellcheckUtils";
|
|
const openContextMenu = function openContextMenu(a0, a1, a2, a3) {
|
|
a0.stopPropagation();
|
|
if (!(a0.currentTarget.contains != null && !a0.currentTarget.contains(a0.target))) {
|
|
const r3 = "pageX" in a0;
|
|
let r15 = 0;
|
|
let r14 = 0;
|
|
if (r3) {
|
|
r14 = a0.pageX;
|
|
r15 = a0.pageY;
|
|
}
|
|
let r10 = r15;
|
|
let r28 = r14;
|
|
if (r28 === 0) {
|
|
r10 = r15;
|
|
r28 = r14;
|
|
if (r15 === 0) {
|
|
const target = a0.target;
|
|
const r5 = target == null;
|
|
let r13 = void 0;
|
|
if (!r5) {
|
|
const defaultView = target.ownerDocument.defaultView;
|
|
r13 = defaultView == null ? void 0 : defaultView.getSelection();
|
|
}
|
|
let r34 = r15;
|
|
let r35 = r14;
|
|
if (r13 != null) {
|
|
const rangeCount = r13.rangeCount;
|
|
r34 = r15;
|
|
r35 = r14;
|
|
if (rangeCount > 0) {
|
|
r34 = r15;
|
|
r35 = r14;
|
|
if (target != null) {
|
|
const rangeAt = r13.getRangeAt(0);
|
|
const r39 = target.contains(rangeAt.commonAncestorContainer);
|
|
r34 = r15;
|
|
r35 = r14;
|
|
if (r39) {
|
|
const boundingClientRect = rangeAt.getBoundingClientRect();
|
|
const height = boundingClientRect.height;
|
|
r34 = r15;
|
|
r35 = r14;
|
|
if (height !== 0) {
|
|
r35 = boundingClientRect.left;
|
|
r34 = boundingClientRect.bottom;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
r10 = r34;
|
|
r28 = r35;
|
|
if (r28 === 0) {
|
|
r10 = r34;
|
|
r28 = r35;
|
|
if (r34 === 0) {
|
|
let r44 = target == null ? void 0 : target.getBoundingClientRect();
|
|
if (r44 == null) {
|
|
r44 = {};
|
|
}
|
|
const { left = 0, top = 0, width = 0, height: height2 } = r44;
|
|
const r53 = left + width / 2;
|
|
r10 = top + (height2 !== void 0 ? height2 : 0) / 2;
|
|
r28 = r53;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let target2 = a0.target;
|
|
if (target2 == null) {
|
|
target2 = a0.currentTarget;
|
|
}
|
|
const r58 = {
|
|
render: a1,
|
|
renderLazy: a3,
|
|
target: target2,
|
|
rect: new DOMRect(r28, r10, 0, 0),
|
|
config: null
|
|
};
|
|
let context = getCurrentlyInteractingAppContext();
|
|
if (context == null) {
|
|
context = AppContext.APP;
|
|
}
|
|
let c14719_1;
|
|
r58.config = {
|
|
context,
|
|
...a2
|
|
};
|
|
const contextMenu = r58;
|
|
const r82 = "nativeEvent" in a0 ? a0.nativeEvent : a0;
|
|
if (a2?.enableSpellCheck && (isDesktop() && r82.isTrusted)) {
|
|
c14719_1 = addResultListener(function() {
|
|
c14719_1();
|
|
Dispatcher.dispatch({
|
|
type: "CONTEXT_MENU_OPEN",
|
|
contextMenu
|
|
});
|
|
});
|
|
} else {
|
|
a0.preventDefault();
|
|
Dispatcher.dispatch({
|
|
type: "CONTEXT_MENU_OPEN",
|
|
contextMenu
|
|
});
|
|
}
|
|
}
|
|
};
|
|
export function closeContextMenu() {}
|
|
export { openContextMenu };
|
|
export function openContextMenuLazy(a0, a1, a2) {
|
|
openContextMenu(a0, void 0, a2, a1);
|
|
}
|