Skip to content

Commit 5efe540

Browse files
committed
Move the styling action to the else block of the when
1 parent 738a6e8 commit 5efe540

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/toolbar/AztecToolbar.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -559,16 +559,6 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
559559
return editor!!.setSelectedStyles(textFormats)
560560
}
561561

562-
// if text is selected and action is styling - toggle the style
563-
if (action.isStylingAction() && action != ToolbarAction.HEADING && action != ToolbarAction.LIST && action != ToolbarAction.CODE) {
564-
aztecToolbarListener?.onToolbarFormatButtonClicked(action.textFormats.first(), false)
565-
val returnValue = editor!!.toggleFormatting(action.textFormats.first())
566-
567-
highlightAppliedStyles()
568-
569-
return returnValue
570-
}
571-
572562
// other toolbar action
573563
when (action) {
574564
ToolbarAction.ADD_MEDIA_COLLAPSE, ToolbarAction.ADD_MEDIA_EXPAND -> {
@@ -615,7 +605,17 @@ class AztecToolbar : FrameLayout, IAztecToolbar, OnMenuItemClickListener {
615605
}
616606
}
617607
else -> {
618-
Toast.makeText(context, "Unsupported action", Toast.LENGTH_SHORT).show()
608+
// if text is selected and action is styling - toggle the style
609+
if (action.isStylingAction()) {
610+
aztecToolbarListener?.onToolbarFormatButtonClicked(action.textFormats.first(), false)
611+
val returnValue = editor!!.toggleFormatting(action.textFormats.first())
612+
613+
highlightAppliedStyles()
614+
615+
return returnValue
616+
} else {
617+
Toast.makeText(context, "Unsupported action", Toast.LENGTH_SHORT).show()
618+
}
619619
}
620620
}
621621
}

0 commit comments

Comments
 (0)