-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add editor HTML element to plugin bindings #131
Comments
why do we need it inside plugin? |
I think it will be helpful in case someone wants to interact directly with the actual HTML element. Take for instance the clear-styles plugin that uses an inefficient way to find the host element of the editor. Or even in the case of #130 where @sajithk was having problems with the focus on the editor. If he was to create a plugin that sets focus, he should find a way to decide which is the owner editor. We could pass the ID of the element if we do not want to have the whole editor object being transferred between the bindings. |
yes, "focus" is a good example. but " clear-styles" should work only with ngModel, no? |
I think that ngModel contains the text along with any styles (e.g. p, li, br). If it is like that, there is no easy way to get the text only. except from textContent property of the element. |
in this case if you want to work with DOM properties, you can just create virtual element, put content there and do textContent. Could you provide at least on more example please? |
I gave a second thought on the issue and I think it is not worth to provide it as a binding, for the reasons you have already mentioned. Could you please provide an example with the use of the virtual element that you describe? I would be really interested to integrate such a solution to the clear-styles plugin. Alternatively, we could provide a service that gets the active editor and each plugin could inject it when needed. |
|
I am struggling to understand how can this be used in clear-styles plugin. Could you please elaborate a bit? |
|
it's the same what we did here |
I really like your approach. Never thought of it! It is also much more testable. I will make the change and submit a PR for that. Thanks! |
@stevermeister what do you think about passing the HTML element that hosts the editor in the bindings property of ngWigPlugin? In that way, we could overcome difficulties that appear when using multiple editors in a template and simplify the way to find in which editor the plugin belongs to.
For example, in clear-styles plugin, we use the following to find the actual editor element:
which is really error prone and difficult to read and test. It could be changed to something like:
var container = angular.element(this.hostElement);
The text was updated successfully, but these errors were encountered: