-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get DOM element type clicked on #608
Comments
Hey! Great question. We didn't yet finish the view docs in the architecture introduction so this bit isn't covered yet. The way to retrieve the clicked element would be to listen to editor.editing.view.on( 'click', ( evt, data ) => {
data.target; // -> engine.view.Element
} ); However, the import ClickObserver from '@ckeditor/ckeditor5-engine/src/view/observer/clickobserver';
// Somewhere in your plugin's init() callback:
editor.editing.view.addObserver( ClickObserver ); Now, the event will be fired as expected. However, you will soon notice that this event is fired with a data containing the PS. I'm not sure what you want to implement exactly, but checking what was clicked may not be the most adequate option. Sometimes, it's worth checking where the selection landed and, for instance, use the model. I actually don't remember how the link's feature implementation ended up, but I remember that we had to try a couple of options to find a good UX. It's, unfortunately, not something that the engine could solve for the developer. |
@Reinmar Is it possible to listen to clicks on specific elements to get cursor position with ClickObserver? I need to track clicks near the image to change its alignment and add a paragraph near it and don't know the right way to do that. |
a |
There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may be relevant, so if you're interested in the solution, leave a comment or reaction under this issue. |
We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it). |
Hi! Firstly I would like to thank you for creating such amazing software. I am very excited to start using CKE5!
I need to see on what type of DOM element I clicked on. This will allow my custom interface (great feature btw) to show "delete" button if the user clicked on an image/table or show "bold/italic" buttons if the user clicked on text.
I started looking into the Observer classes, but cannot quite figure out how I can achieve this.
Any advice would be greatly appreciated?
The text was updated successfully, but these errors were encountered: