Skip to content

Commit

Permalink
feat(demo): add new toolbar button icon replacement example
Browse files Browse the repository at this point in the history
  • Loading branch information
paodb committed Feb 16, 2023
1 parent 06c94ab commit fe3e8b7
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.icon.Icon;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.textfield.TextArea;
Expand Down Expand Up @@ -33,6 +34,7 @@ protected void initView() {
createEditorWithPlaceholders();
createEditorWithCustomButtons();
createEditorWithCustomShortcutsForStandardButtons();
createEditorWithIconReplacementForStandardButtons();
}

private void createDefaultEditor() {
Expand Down Expand Up @@ -67,6 +69,33 @@ private void createEditorWithCustomShortcutsForStandardButtons() {
addCard("Basic Rich Text Editor with custom shortcuts for standard buttons", rte);
}

private void createEditorWithIconReplacementForStandardButtons() {
// begin-source-example
// source-example-heading: Basic Rich Text Editor with icon replacement for standard buttons
EnhancedRichTextEditor rte = new EnhancedRichTextEditor();

// replace undo button icon
Icon newUndoIcon = new Icon(VaadinIcon.ARROW_BACKWARD);
newUndoIcon.setColor("grey");
newUndoIcon.setSize("1.25em");
rte.replaceStandardToolbarButtonIcon(ToolbarButton.UNDO, newUndoIcon);

// replace redo button icon
Icon newRedoIcon = new Icon(VaadinIcon.ARROW_FORWARD);
newRedoIcon.setColor("grey");
newRedoIcon.setSize("1.25em");
rte.replaceStandardToolbarButtonIcon(ToolbarButton.REDO, newRedoIcon);

// replace redo button icon
Icon imageIcon = new Icon(VaadinIcon.PICTURE);
imageIcon.setSize("1.25em");
rte.replaceStandardToolbarButtonIcon(ToolbarButton.IMAGE, imageIcon);

// end-source-example
addCard("Basic Rich Text Editor with icon replacement for standard buttons", rte);
}


private void createEditorWithCustomButtons() {
// begin-source-example
// source-example-heading: Rich Text Editor With Custom Buttons
Expand Down

0 comments on commit fe3e8b7

Please sign in to comment.