Skip to content

Commit

Permalink
fix: Revert unnecessary enabled check. Fix readonly and disabled styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
TatuLund committed Jan 10, 2024
1 parent ad24a86 commit f454d3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/vaadin/tinymce/TinyMce.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public TinyMce(boolean shadowRoot) {
} else {
getElement().appendChild(ta);
}
getElement().getClassList().add("tinymce-flow");
}

public TinyMce() {
Expand Down Expand Up @@ -141,10 +142,8 @@ void runBeforeClientResponse(SerializableConsumer<UI> command) {

@ClientCallable
private void updateValue(String htmlString) {
if (this.isEnabled() && !this.isReadOnly()) {
this.currentValue = htmlString;
setModelValue(htmlString, true);
}
this.currentValue = htmlString;
setModelValue(htmlString, true);
}

public String getCurrentValue() {
Expand Down Expand Up @@ -207,6 +206,11 @@ public void setEnabled(boolean enabled) {
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
setEnabled(!readOnly);
if (readOnly) {
getElement().setAttribute("readonly", "");
} else {
getElement().removeAttribute("readonly");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ div.tox-collection__item > div.tox-collection__item-icon {
.tox .tox-fancymenuitem .tox-insert-table-picker .tox-insert-table-picker {
border-color: var(--lumo-contrast-20pct);
}

.tinymce-flow[readonly] .tox-editor-header {
display: none;
}

.tinymce-flow[disabled]:not([readonly]) {
opacity: 0.5;
}
3 changes: 2 additions & 1 deletion src/test/java/org/vaadin/tinymce/OnAttachTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ public OnAttachTest() {

public static class EditorView extends Composite<TinyMce> {
private String value;
private TinyMce tinyMce;

public EditorView(String value) {
this.value = value;
getContent().setWidth("600px");
getContent().configurePlugin(true, Plugin.TABLE).configureToolbar(true,
Toolbar.TABLE);
getContent().addValueChangeListener(e -> {
this.value = e.getValue();
Notification.show(this.value);
});
getContent().setEnabled(false);
}
Expand Down

0 comments on commit f454d3c

Please sign in to comment.