Reputation: 3
in the previous versions of tinymce it was possible with the advanced theme that whenever a user does a resize of the editor this will be saved as a cookie. The next time the user opens the same page the size will be like he had adjusted.
theme : "advanced"
I did not find a way in the current 5.6 version and I also did not find this in the documentation.
Can someone help?
Upvotes: 0
Views: 36
Reputation: 13744
The advanced theme was from TinyMCE 3.x (no longer supported) and no similar theme exists in either TinyMCE 4 (also no longer supported) or TinyMCE 5.
In TinyMCE 5 you could rely on the ResizeEditor
event of TinyMCE to try to capture the current editor's size and store that somewhere that you would then use later to set the default size when initializing the editor again.
Here is a working TinyMCE Fiddle that shows this in action: https://fiddle.tiny.cloud/mDhaab
The code in question is in the setup function:
setup: function (editor) {
editor.on('ResizeEditor', function (e) {
var editorContainer = document.getElementsByClassName("tox-tinymce");
console.log(editorContainer[editor.id].style.height);
});
}
I would note that this relies on the div of the editor having a specific class name. You could also look for the div that is the first sibling of the textarea that was replaced with TinyMCE. While the fiddle does not do this you could then store that value as a cookie (or in local storage) and reuse that later when initializing TinyMCE.
Upvotes: 1