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

Toggling the theme does not update the editor theme without refreshing the page #16

Open
jaredmahan opened this issue Oct 11, 2018 · 1 comment

Comments

@jaredmahan
Copy link

I have a theme toggle (from light to dark) on the page and it does not update the theme option unless I refresh the page and the editor is initialized with the theme value.

@jaredmahan
Copy link
Author

jaredmahan commented Oct 11, 2018

After further digging, I found that this is not an issue of the angular plugin but rather of the editor itself, changing the template option in the editor does not take effect until the editor is destroyed and recreated. Below is the code changes I made, but I am hoping there is a better way to accomplish this rather than redrawing the entire component as it is not the most performant solution.
ngOnChanges(changes: SimpleChanges) { const config: SimpleChange = changes.config; if ( !!config && !!config.currentValue && config.previousValue && config.currentValue.theme !== config.previousValue.theme ) { let value = ''; if (!!this.editor.value) value = this.editor.value; this.editor.destruct(); this.editor = new Jodit(this.element, this.config); this.editor.value = value; } }

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