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
How to Insert dom element into editor? #51
Comments
Sounds like you have an interesting project! That isn't really something textAngular was designed to support natively as all our dom manipulation is done through document.execCommand which doesn't support what you want to do. action: function(){
var element = $compile("<eg-todo>")(this.$parent);
//figure out how to insert it here using something like Rangy to get the current cursor position/selection, then inserting your compiled html
this.$parent.displayElements.text[0].focus(); // refocus on the WYSIWYG editor after loosing it to the button
this.$parent.updateSelectedStyles(); // you can omit this if you aren't implementing activeState or the active class
this.$parent.updateTaBindtext(); // updates the model
} I'd say you'd also need to change line 442 of textAngular from No guarantees it will work, if it does we could consider making the ability to insert directives dynamically a feature in the future, which sounds cooler the more I think about it. But I have no idea what the implications are of allowing this on security and performance and I have a feeling these could be a tricky. |
If we living in directive world i think we must to support it. Checkbox button:
$compile before insert and example of
i try to use it on page with 14 editors, and 200 checkboxes per editor. |
first problem: loose raw text, it's not dom |
Cool, great that it's working for you and thanks for sharing your code. I'm not able to look into this properly till Feb next year due to Family commitments. I agree that it's a good idea to allow the use of directives in the wysiwyg, I just have some concerns about essentially allowing dynamic injecting of directives into your code. It opens up a nice big hole in your app if we use your approach as is. From what I can see any angular directives put into the raw HTML view will be activated and run using the WYSIWYG view which normally you can't do afaik. |
I wan't to create button in toolbar, which will insert some angular directive in editor.
So, if i insert some directive, i must to $compile it:
The text was updated successfully, but these errors were encountered: