Plugin support for onMouseOver, onMouseOut etc.
See original GitHub issueDo you want to request a feature or report a bug?
Feature
What’s the current behavior?
If a plugin wants to handle onMouseOver or onMouseOut events, it either needs to bind arguments in the render method, or store data in a data-attribute. The specific use case I’m trying to achieve is taking action based on mark data on mouse over.
class Plugin {
static onMouseOver(event) {
console.log(event.target.getAttribute('data-foovalue')
}
static renderMark() {
const fooValue = props.mark.data.get("foo");
return (
<span data-foovalue={fooValue} onMouseOver={Plugin.onMouseOver}>
{props.children}
</span>
)
}
}
What’s the expected behavior?
It would be great if onMouseOver and onMouseOut were supported “naturally”, such that we got an event
and a change
, so we had access to value, document, fragment, or mark data. We wouldn’t need a renderMark function then, and could do something like:
class Plugin {
static onMouseOver(event, change) {
// vague-ish pseudo-code. could also handle this by addition
// of a new `hover` range to the change object, similar to selection.
const node = findNode(event.target, change.value)
const marks = node.getMarksAtRange(rangeOfNode),
console.log(marks[0].data.get("foo"))
}
}
I’m happy to put together an initial pass at this, if it’s likely to be accepted in principle, and if I can be pointed in the right direction 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:9 (8 by maintainers)
Top Results From Across the Web
onmouseover doesn't work when using javascript to add img ...
I need some javascript code that dynamically adds an img tag to a div, and the img tag needs onmouseover and onmouseout handlers....
Read more >onMouseOut() not being called - DSP and Plug-in Development ...
I have this code, with mouseOver being initialised to FALSE, and draw() only draws lines for the crossfair if the mouseOver is TRUE....
Read more >IMG mouseover plugin for WordPress - The Woodwork
Download. Please go to IMG Mouseover on WordPress.org. When clicked, the image should be changed to this. To revert, simply mouseout of the...
Read more >Topic: onmouseout/onmouseover in sidepanel widget
Hi I am trying to figure out how to make a mouseover effect ork in sidebar widget. My problem is that the editor...
Read more >Moving the mouse over a control with a tooltip reset the scroll ...
There are onmouseover and onmouseout events attached to the div that ... at the mouseover/mouseenter/mouseout etc and modify accordingly.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates on this? Do we need someone to dive into it? As this is also a requirement for me too
I see, you’re optimising for memory. Perhaps it’s worth writing a proper component and letting react optimise for multiple instances of the same component
and
I guess it’s similar to my other suggestion.
Your suggestion seems like a common pattern in Slate.js so it’s quite easy to reason about. Serialisation rules work in the same way: loop over all rules, find one that can generate a node from content. Having convenient access to the
value
,change
is important, but pure components don’t need to know anything about it - just feed them callbacks.Anyway, sounds like you already know how to implement it. Give it a go!