mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Add attempt at context menu hint mode
This commit is contained in:
parent
9ccd23d00c
commit
958bc855a0
2 changed files with 16 additions and 1 deletions
|
@ -3680,6 +3680,7 @@ export function unset(...keys: string[]) {
|
|||
- -# yank an element's anchor URL to clipboard
|
||||
- -c [selector] hint links that match the css selector
|
||||
- `bind ;c hint -c [class*="expand"],[class="togg"]` works particularly well on reddit and HN
|
||||
- -C open context menu
|
||||
- -f [text] hint links and inputs that display the given text
|
||||
- `bind <c-e> hint -f Edit`
|
||||
- -fr [text] use RegExp to hint the links and inputs
|
||||
|
@ -3950,6 +3951,17 @@ export async function hint(option?: string, selectors?: string, ...rest: string[
|
|||
)
|
||||
break
|
||||
|
||||
case "-C":
|
||||
selectHints = hinting.pipe_elements(
|
||||
hinting.hintables(selectors),
|
||||
elem => {
|
||||
DOM.mouseEvent(elem,"context")
|
||||
return elem
|
||||
},
|
||||
rapid,
|
||||
)
|
||||
break
|
||||
|
||||
case "-r":
|
||||
selectHints = hinting.pipe_elements(
|
||||
DOM.elementsWithText(),
|
||||
|
|
|
@ -91,7 +91,7 @@ function isEditableHTMLInput(element: HTMLInputElement) {
|
|||
*/
|
||||
export function mouseEvent(
|
||||
element: Element,
|
||||
type: "hover" | "unhover" | "click",
|
||||
type: "hover" | "unhover" | "click" | "context",
|
||||
modifierKeys = {},
|
||||
) {
|
||||
let events = []
|
||||
|
@ -104,6 +104,9 @@ export function mouseEvent(
|
|||
case "hover":
|
||||
events = ["mouseover", "mouseenter", "mousemove"].concat(events)
|
||||
break
|
||||
case "context":
|
||||
events = ["contextmenu"]
|
||||
break
|
||||
}
|
||||
events.forEach(type => {
|
||||
const event = new MouseEvent(type, {
|
||||
|
|
Loading…
Add table
Reference in a new issue