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

Setting value only works sometimes #33

Open
confususs opened this issue Jul 20, 2022 · 1 comment
Open

Setting value only works sometimes #33

confususs opened this issue Jul 20, 2022 · 1 comment
Labels

Comments

@confususs
Copy link

First of all, thanks for building this web component. It makes the life of me and my colleagues a lot easier 😄.

After implementing it I encountered some cases where the value setter didn't propagate the new value correctly to the TinyMCE editor. The value only seems to be propagated when the internal _status is "Ready".

It would be great if we could set this value regardless of what the status is, so that we are able to set the value prior to 'Ready', or even during initializing.

This is the way we go around it currently:

const tinyMCEWebComponent = this.querySelector('tinymce-editor');
if (tinyMCEWebComponent._editor) {
  const target = tinyMCEWebComponent._editor.getElement();
  if (target) {
    target.value = value;
  }
}

// Only set the textContent when the status is 'Raw', which is the state
// prior to Initializing. When initializing, it is often too late to
// set the value to the textContent since it is read immediately after it switched state to Initializing.
if (tinyMCEWebComponent._status === 0) { // 0 equals 'Raw'. Other states are 'Initializing' and 'Ready'.
  tinyMCEWebComponent.textContent = value;
}

// Always try to set the value through the setter of the tinymce web
// component. It has some checks internally, so it is only setting the
// value when the state is 'Ready'.
tinyMCEWebComponent.value = value;

Which I'd like to avoid 🙂

@exalate-issue-sync
Copy link

Ref: INT-2958

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

No branches or pull requests

1 participant