ipavelpetrov / ember-cli-trumbowyg

Ember Addon for Trumbowyg WYSIWYG editor
MIT License
3 stars 8 forks source link

Issues with caret and didUpdateAttrs #1

Open pcambra opened 7 years ago

pcambra commented 7 years ago

The didUpdateAttrs method does this:

const optionsUpdated = this.get('optionNames')
  .some(optionName => this._isAttrChanged(attrs, optionName));
const htmlUpdated = Ember.get(attrs, 'newAttrs.html.value') !== this.$().trumbowyg('html');
const disabledUpdated = this._isAttrChanged(attrs, 'disabled');
const placeholderUpdated = this._isAttrChanged(attrs, 'placeholder');
if (optionsUpdated || placeholderUpdated) {
  this._destroyTrumbowyg();
  this._renderTrumbowyg();
}
if (htmlUpdated) {
  this.$().trumbowyg('html', this.get('html'));
}

However, if the html property is not empty (i.e an edit form), when enter is pressed, the caret returns to the beginning of the text and stays there (causing the editor to write backwards as a side effect).

I am not sure why this part is needed as the editor seems to be working fine otherwise

blufish commented 6 years ago

See here: https://www.emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks

I have a pull request in to resolve this.