Skip to content

Commit

Permalink
Maintain disabled/readOnly mode on refresh
Browse files Browse the repository at this point in the history
See #27
  • Loading branch information
mstahv committed Jan 19, 2024
1 parent a9f9d75 commit ea5247b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/main/java/org/vaadin/tinymce/TinyMce.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.vaadin.flow.component.AbstractCompositeField;
import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.ClientCallable;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.DetachEvent;
import com.vaadin.flow.component.Focusable;
Expand All @@ -26,10 +25,6 @@
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.dependency.JavaScript;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.dom.DebouncePhase;
import com.vaadin.flow.dom.DomEvent;
import com.vaadin.flow.dom.DomEventListener;
import com.vaadin.flow.dom.DomListenerRegistration;
import com.vaadin.flow.dom.Element;
Expand Down Expand Up @@ -161,8 +156,8 @@ private void initConnector() {

runBeforeClientResponse(ui -> {
ui.getPage().executeJs(
"window.Vaadin.Flow.tinymceConnector.initLazy($0, $1, $2, $3, $4)",
rawConfig, getElement(), ta, config, currentValue);
"window.Vaadin.Flow.tinymceConnector.initLazy($0, $1, $2, $3, $4, $5)",
rawConfig, getElement(), ta, config, currentValue, (enabled && !readOnly));
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
window.Vaadin.Flow.tinymceConnector = {
initLazy: function (customConfig, c, ta, options, initialContent) {
initLazy: function (customConfig, c, ta, options, initialContent, enabled) {
// Check whether the connector was already initialized
if (c.$connector) {
c.$connector.editor.remove();
Expand Down Expand Up @@ -36,6 +36,10 @@ window.Vaadin.Flow.tinymceConnector = {
baseconfig['height'] = "100%";

baseconfig['target'] = ta;

if(!enabled) {
baseconfig['readonly'] = true;
}

baseconfig['setup'] = function(ed) {
c.$connector.editor = ed;
Expand Down

0 comments on commit ea5247b

Please sign in to comment.