mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-17 18:44:45 +02:00
This commit is contained in:
parent
2d0a53eaca
commit
e2a79c16c1
@ -7,7 +7,6 @@ import { ContextMenuOptions, ContextMenuItemType } from '../../../utils/contextM
|
|||||||
import { menuItems } from '../../../utils/contextMenu';
|
import { menuItems } from '../../../utils/contextMenu';
|
||||||
import MenuUtils from '@joplin/lib/services/commands/MenuUtils';
|
import MenuUtils from '@joplin/lib/services/commands/MenuUtils';
|
||||||
import CommandService from '@joplin/lib/services/CommandService';
|
import CommandService from '@joplin/lib/services/CommandService';
|
||||||
import convertToScreenCoordinates from '../../../../utils/convertToScreenCoordinates';
|
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
|
|
||||||
import Resource from '@joplin/lib/models/Resource';
|
import Resource from '@joplin/lib/models/Resource';
|
||||||
@ -25,15 +24,21 @@ function contextMenuElement(editor: any, x: number, y: number) {
|
|||||||
const iframes = document.getElementsByClassName('tox-edit-area__iframe');
|
const iframes = document.getElementsByClassName('tox-edit-area__iframe');
|
||||||
if (!iframes.length) return null;
|
if (!iframes.length) return null;
|
||||||
|
|
||||||
const iframeRect = convertToScreenCoordinates(Setting.value('windowContentZoomFactor'), iframes[0].getBoundingClientRect());
|
const zoom = Setting.value('windowContentZoomFactor') / 100;
|
||||||
|
const xScreen = x / zoom;
|
||||||
|
const yScreen = y / zoom;
|
||||||
|
|
||||||
if (iframeRect.x < x && iframeRect.y < y && iframeRect.right > x && iframeRect.bottom > y) {
|
// We use .elementFromPoint to handle the case where a dialog is covering
|
||||||
const relativeX = x - iframeRect.x;
|
// part of the editor.
|
||||||
const relativeY = y - iframeRect.y;
|
const targetElement = document.elementFromPoint(xScreen, yScreen);
|
||||||
return editor.getDoc().elementFromPoint(relativeX, relativeY);
|
if (targetElement !== iframes[0]) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
const iframeRect = iframes[0].getBoundingClientRect();
|
||||||
|
const relativeX = xScreen - iframeRect.left;
|
||||||
|
const relativeY = yScreen - iframeRect.top;
|
||||||
|
return editor.getDoc().elementFromPoint(relativeX, relativeY);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ContextMenuActionOptions {
|
interface ContextMenuActionOptions {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user