Skip to content
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

Firefox: execCommand throughs NS_ERROR_FAILURE when used with angular #68

Open
josefromsanjose opened this issue Aug 26, 2016 · 2 comments

Comments

@josefromsanjose
Copy link

josefromsanjose commented Aug 26, 2016

this.options.ownerDocument.execCommand throws an NS_ERROR_FAILURE when wrapped in an angular wrapper whenexecActionInternal() is called for the ordered and unordered list buttons.

It causes some weird behavior that duplicates the medium editor element's parent node several times.

Example:
before:

<div class="parent">
<p medium-editor class="medium-editor">I am an editor and the p tag is my editor element</p>
<div>Some sibling element</div>
</div>

after:

<div class="parent">
<p medium-editor class="medium-editor">I am an editor and the p tag is my editor element</p>
</div>
<div class="parent">
<div>Some sibling element</div>
</div>

Anyone have any idea that is and if there is a solution. It works fine as long as it is not used with Angular.

This is only an issue in Firefox.

@kkulikowski
Copy link

hello @josefromsanjose, did you figure it out? I have the same issue and nothing i had in mind works..

@josefromsanjose
Copy link
Author

josefromsanjose commented Nov 2, 2016

Hi @kkulikowski, no I didn't, at least with this project. I ended up creating my own directive because I need a bit more than this project offers. I found that this is an issue when there is not initial html tags inside the element that is the editor. We solved it by making sure it was always initialized with a paragraph tag.

If you look at the source code around line 27.

I changed this

ngModel.$render = function() {
          ngModel.editor.setContent(ngModel.$viewValue || "");
          var placeholder = ngModel.editor.getExtensionByName('placeholder');
          if (placeholder) {
            placeholder.updatePlaceholder(iElement[0]);
 }

To this:

ngModel.$render = function() {
          ngModel.editor.setContent(ngModel.$viewValue || "<p></p>");
          var placeholder = ngModel.editor.getExtensionByName('placeholder');
          if (placeholder) {
            placeholder.updatePlaceholder(iElement[0]);
 }

Try that and see if it helps. Firefox in general doesn't seem to work well with Medium Editor and adding Angular to the mix didn't seem to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants