mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Merge pull request #238 from johnbeard/hintkill
Add hint kill submode (;k)
This commit is contained in:
commit
d59a6fc971
4 changed files with 32 additions and 0 deletions
|
@ -73,6 +73,7 @@ const DEFAULTS = o({
|
||||||
"F": "hint -b",
|
"F": "hint -b",
|
||||||
";i": "hint -i",
|
";i": "hint -i",
|
||||||
";I": "hint -I",
|
";I": "hint -I",
|
||||||
|
";k": "hint -k",
|
||||||
";y": "hint -y",
|
";y": "hint -y",
|
||||||
";p": "hint -p",
|
";p": "hint -p",
|
||||||
";r": "hint -r",
|
";r": "hint -r",
|
||||||
|
|
|
@ -1301,6 +1301,7 @@ import * as hinting from './hinting_background'
|
||||||
- -r read an element's text with text-to-speech
|
- -r read an element's text with text-to-speech
|
||||||
- -i view an image
|
- -i view an image
|
||||||
- -I view an image in a new tab
|
- -I view an image in a new tab
|
||||||
|
- -k delete an element from the page
|
||||||
- -; focus an element
|
- -; focus an element
|
||||||
- -# yank an element's anchor URL to clipboard
|
- -# yank an element's anchor URL to clipboard
|
||||||
- -c [selector] hint links that match the css selector
|
- -c [selector] hint links that match the css selector
|
||||||
|
@ -1316,6 +1317,7 @@ export function hint(option?: string, selectors="") {
|
||||||
else if (option === "-p") hinting.hintPageTextYank()
|
else if (option === "-p") hinting.hintPageTextYank()
|
||||||
else if (option === "-i") hinting.hintImage(false)
|
else if (option === "-i") hinting.hintImage(false)
|
||||||
else if (option === "-I") hinting.hintImage(true)
|
else if (option === "-I") hinting.hintImage(true)
|
||||||
|
else if (option === "-k") hinting.hintKill()
|
||||||
else if (option === "-;") hinting.hintFocus()
|
else if (option === "-;") hinting.hintFocus()
|
||||||
else if (option === "-#") hinting.hintPageAnchorYank()
|
else if (option === "-#") hinting.hintPageAnchorYank()
|
||||||
else if (option === "-c") hinting.hintPageSimple(selectors)
|
else if (option === "-c") hinting.hintPageSimple(selectors)
|
||||||
|
|
|
@ -234,6 +234,12 @@ function anchors() {
|
||||||
return DOM.getElemsBySelector(HINTTAGS_anchor_selectors, [DOM.isVisible])
|
return DOM.getElemsBySelector(HINTTAGS_anchor_selectors, [DOM.isVisible])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Array of items that can be killed with hint kill
|
||||||
|
*/
|
||||||
|
function killables() {
|
||||||
|
return DOM.getElemsBySelector(HINTTAGS_killable_selectors, [DOM.isVisible])
|
||||||
|
}
|
||||||
|
|
||||||
// CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.
|
// CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.
|
||||||
const HINTTAGS_selectors = `
|
const HINTTAGS_selectors = `
|
||||||
input:not([type=hidden]):not([disabled]),
|
input:not([type=hidden]):not([disabled]),
|
||||||
|
@ -280,6 +286,16 @@ const HINTTAGS_anchor_selectors = `
|
||||||
[name]
|
[name]
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const HINTTAGS_killable_selectors = `
|
||||||
|
span,
|
||||||
|
div,
|
||||||
|
iframe,
|
||||||
|
img,
|
||||||
|
button,
|
||||||
|
article,
|
||||||
|
summary
|
||||||
|
`
|
||||||
|
|
||||||
import {activeTab, browserBg, l, firefoxVersionAtLeast} from './lib/webext'
|
import {activeTab, browserBg, l, firefoxVersionAtLeast} from './lib/webext'
|
||||||
|
|
||||||
async function openInBackground(url: string) {
|
async function openInBackground(url: string) {
|
||||||
|
@ -387,6 +403,14 @@ function hintRead() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Hint elements and delete the selection from the page
|
||||||
|
*/
|
||||||
|
function hintKill() {
|
||||||
|
hintPage(killables(), hint=>{
|
||||||
|
hint.target.remove();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function selectFocusedHint() {
|
function selectFocusedHint() {
|
||||||
console.log("Selecting hint.", state.mode)
|
console.log("Selecting hint.", state.mode)
|
||||||
const focused = modeState.focusedHint
|
const focused = modeState.focusedHint
|
||||||
|
@ -407,4 +431,5 @@ addListener('hinting_content', attributeCaller({
|
||||||
hintImage,
|
hintImage,
|
||||||
hintFocus,
|
hintFocus,
|
||||||
hintRead,
|
hintRead,
|
||||||
|
hintKill,
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -44,6 +44,10 @@ export async function hintRead() {
|
||||||
return await messageActiveTab('hinting_content', 'hintRead')
|
return await messageActiveTab('hinting_content', 'hintRead')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function hintKill() {
|
||||||
|
return await messageActiveTab('hinting_content', 'hintKill')
|
||||||
|
}
|
||||||
|
|
||||||
import {MsgSafeKeyboardEvent} from './msgsafe'
|
import {MsgSafeKeyboardEvent} from './msgsafe'
|
||||||
|
|
||||||
/** At some point, this might be turned into a real keyseq parser
|
/** At some point, this might be turned into a real keyseq parser
|
||||||
|
|
Loading…
Add table
Reference in a new issue