Skip to content

Commit

Permalink
show context menu on touchscreen long press
Browse files Browse the repository at this point in the history
Addresses: zotero/zotero/#4094
  • Loading branch information
abaevbog authored and mrtcode committed May 16, 2024
1 parent f655c01 commit 646cce0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/core/editor-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,15 @@ class EditorCore {
handleDOMEvents: {
// Node (image, citation) selection happens on mouseup, therefore we can't open context menu on mousedown.
// This limitation probably comes from ProseMirror side
mouseup: (view, event) => {
if (event.button === 2) {
setTimeout(() => {
const { $from } = view.state.selection;
let node = view.state.doc.nodeAt($from.pos);
if (!node) {
node = $from.parent;
}
options.onOpenContextMenu($from.pos, node, event.screenX, event.screenY);
}, 0);
}
contextmenu: (view, event) => {
setTimeout(() => {
const { $from } = view.state.selection;
let node = view.state.doc.nodeAt($from.pos);
if (!node) {
node = $from.parent;
}
options.onOpenContextMenu($from.pos, node, event.screenX, event.screenY);
}, 0);
},
click: (view, event) => {
if (event.target.closest('a')) {
Expand Down

0 comments on commit 646cce0

Please sign in to comment.