Skip to content

Commit

Permalink
Deprecated old obsoleted method
Browse files Browse the repository at this point in the history
  • Loading branch information
mstahv committed Jan 2, 2024
1 parent 44f2a89 commit 03ffe3e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
29 changes: 19 additions & 10 deletions src/main/java/org/vaadin/tinymce/TinyMce.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@ public TinyMce() {
this(false);
}

/**
* Old public method from era when this component didn't
* properly implement the HasValue interfaces.
* Don't use this but the standard setValue method instead.
*
* @param html
* @deprecated use {@link #setValue(Object)} instead
*/
@Deprecated(forRemoval = true)
public void setEditorContent(String html) {
this.currentValue = html;
if (initialContentSent) {
runBeforeClientResponse(ui -> getElement()
.callJsFunction("$connector.setEditorContent", html));
} else {
ta.setProperty("innerHTML", html);
}
setPresentationValue(html);
}

@Override
Expand Down Expand Up @@ -260,12 +263,18 @@ public void setReadOnly(boolean readOnly) {
}

@Override
protected void setPresentationValue(String t) {
setEditorContent(t);
protected void setPresentationValue(String html) {
this.currentValue = html;
if (initialContentSent) {
runBeforeClientResponse(ui -> getElement()
.callJsFunction("$connector.setEditorContent", html));
} else {
ta.setProperty("innerHTML", html);
}
}

private TinyMce createBasicTinyMce() {
this.setEditorContent("");
setValue("");
this.configure("branding", false);
this.basicTinyMCECreated = true;
this.configurePlugin(false, Plugin.ADVLIST, Plugin.AUTOLINK,
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/vaadin/tinymce/DeepLinkingView.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public class DeepLinkingView extends Div {
public DeepLinkingView() {
tinyMce = new TinyMce();

tinyMce.setEditorContent("<p>Voi <strong>jorma</strong>!<p>");
tinyMce.setValue("<p>Voi <strong>jorma</strong>!<p>");
tinyMce.setHeight("700px");

add(tinyMce);

Button b = new Button("Set content dynamically", e -> {
tinyMce.setEditorContent("New value");
tinyMce.setValue("New value");
});
add(b);

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/vaadin/tinymce/DemoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class DemoView extends Div {
public DemoView() {
tinyMce = new TinyMce();

tinyMce.setEditorContent("<p>Voi <strong>jorma</strong>!<p>");
tinyMce.setValue("<p>Voi <strong>jorma</strong>!<p>");
tinyMce.setHeight("700px");

add(tinyMce);

Button b = new Button("Set content dynamically", e -> {
tinyMce.setEditorContent("New value");
tinyMce.setValue("New value");
});
add(b);

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/vaadin/tinymce/GitHubIssue2.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class GitHubIssue2 extends Composite<VerticalLayout> {
public GitHubIssue2() {
this.getContent().setSizeFull();
TinyMce editor = new TinyMce();
editor.setEditorContent("sample text");
editor.setValue("sample text");
tab1Layout.add(new Span("Tiny MCE Editor"), editor);
tab2Layout.add(new Span("tab 2"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ImageUploadsEnabledView() {
tinyMce = new TinyMce();
tinyMce.configure("plugins", "code", "link", "image");
tinyMce.configure("toolbar", "toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent' | link image");
tinyMce.setEditorContent("<p>Voi <strong>jorma</strong>!<p>");
tinyMce.setValue("<p>Voi <strong>jorma</strong>!<p>");
tinyMce.setHeight("700px");
add(tinyMce);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class UpdateValueOnDetachedEditor extends VerticalLayout {
public UpdateValueOnDetachedEditor() {

TinyMce tinyMce = new TinyMce();
tinyMce.setValue("Jorma");

Button b = new Button("Replace value while detached");
b.addClickListener(e -> {
Expand Down

0 comments on commit 03ffe3e

Please sign in to comment.