Does not work with vimium C.
- Go to any webpage.
- Press the ”v“ to enter view mode.
- With the text selected, click the “a”.
- The expected result is that the text is highlighted.
- The practical result is that nothing works.
I want to use it with the vimium C plugin, but the hypothesis doesn't work in visual mode. I don't know if it can provide adaptation to vimium C like many other plugins, which is very important for vim users.
I want to use it with the vimium C plugin, but the hypothesis doesn't work in visual mode.
This page about allowing Vimium to be injected into pages created by other extensions is probably not what is required, since the web page you are trying to annotate is not served by the Hypothesis extension. However, I don't think we would allow Vimium to inject into pages that are created by the official Hypothesis extension (eg. our PDF viewer), since it expands the surface area that we (Hypothesis developers) need to be aware of from a security perspective. If users of Vimium want to build their own version of the Hypothesis extension with the changes described on that page, they are welcome though.
If someone wants to investigate why Hypothesis doesn't handle the "a" shortcut when text is selected with Vimium and report back, I can make some suggestions on solutions. Does Vimium make a regular text selection using the browser's selection APIs when using visual mode? Hypothesis's keyboard shortcuts rely on that.
It's most likely because Vimium suppresses other keyboard shortcuts in its visual mode (in order to prevent its own normal mode shortcuts from conflicting). I altered Vimium to use return to exit visual mode while keeping the text selection, after that a or h should work as expected.
@twio142 - Thanks for the tip. Can you share the code or configuration for your alteration?
@robertknight
In content_scripts/mode_visual.js, from line 259:
- this.yank();
+ this.shouldRetainSelectionOnExit = true;
+ this.exit();
return this.suppressEvent;
I actually found a better solution to integrate those hotkeys into Vimium.
Still in the same document content_scripts/mode_visual.js, after line 400, under VisualMode.prototype.movements:
"a"() {
document.querySelector("hypothesis-adder")?.shadowRoot.querySelector("button[aria-label='Annotate (a)']")?.click();
this.exit();
},
"h"() {
document.querySelector("hypothesis-adder")?.shadowRoot.querySelector("button[aria-label='Highlight (h)']")?.click();
this.exit();
},
So in Vimium's visual mode, you can directly use h and a to annotate and then return to normal mode.
I'm closing this issue for now as it looks like a workaround has been found.