Is it a good practive to define event listeners in toDOM
method like below or I should define custom node view (which comparing to toDOM
gives me a getPos
method to figure out node position)? Also, I was wondering whether instead of creating node views with specific listeners, I could create a plugin with click
listeners which based on target figure out which node was clicked and do specific action. Is it acceptable?
const dom = document.createElement('img');
dom.src = node.attrs.src;
dom.width = node.attrs.width;
dom.onclick = () => console.log('Hi');
return { dom };