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

Huge texts getting slow on controlled editor #570

Open
FabricioK opened this issue Feb 9, 2025 · 0 comments
Open

Huge texts getting slow on controlled editor #570

FabricioK opened this issue Feb 9, 2025 · 0 comments

Comments

@FabricioK
Copy link

FabricioK commented Feb 9, 2025

What is the current behavior?
Currently while editing long texts on a controller editor, the validation located on the handleEditorChange function causes the editor to run the tinyMCE native function getContent while another request is already running, thus making the editor too slow.

https://codesandbox.io/p/sandbox/tinymce-slow-4jlprj

What is the expected behavior?
Adding a simple debounce seens to fix the issue

`
private handleEditorChange = (_evt: EditorEvent) => {
debounce(() => {
const editor = this.editor;
if (editor && editor.initialized) {
const newContent = editor.getContent();
if (this.props.value !== undefined && this.props.value !== newContent && this.props.rollback !== false) {
// start a timer and revert to the value if not applied in time
if (!this.rollbackTimer) {
this.rollbackTimer = window.setTimeout(
this.rollbackChange,
typeof this.props.rollback === 'number' ? this.props.rollback : 200
);
}
}

    if (newContent !== this.currentContent) {
      this.currentContent = newContent;
      if (isFunction(this.props.onEditorChange)) {
        this.props.onEditorChange(newContent, editor);
      }
    }
  }
}
, 100
);

};
`

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-react?

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

1 participant