1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

Turning text blocks into code snippet block (#470)

This commit is contained in:
Evgenii Kozlov 2020-05-26 16:21:46 +03:00 committed by GitHub
parent 26c3335a3c
commit c964f71b4e
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View file

@ -62,6 +62,8 @@ enum class UiBlock {
category == Category.TEXT || category == Category.LIST
}
fun isCode() : Boolean = this == CODE
enum class Category {
TEXT, LIST, PAGE, OBJECT, OTHER
}

View file

@ -213,5 +213,6 @@ fun UiBlock.style(): Block.Content.Text.Style = when (this) {
UiBlock.BULLETED -> Block.Content.Text.Style.BULLET
UiBlock.NUMBERED -> Block.Content.Text.Style.NUMBERED
UiBlock.TOGGLE -> Block.Content.Text.Style.TOGGLE
UiBlock.CODE -> Block.Content.Text.Style.CODE_SNIPPET
else -> throw IllegalStateException("Could not extract style from block: $this")
}

View file

@ -1158,7 +1158,7 @@ class PageViewModel(
}
override fun onTurnIntoBlockClicked(target: String, block: UiBlock) {
if (block.isText()) {
if (block.isText() || block.isCode()) {
proceedWithUpdatingTextStyle(
style = block.style(),
targets = listOf(target)
@ -1168,7 +1168,7 @@ class PageViewModel(
}
override fun onTurnIntoMultiSelectBlockClicked(block: UiBlock) {
if (block.isText()) {
if (block.isText() || block.isCode()) {
val targets = currentSelection().toList()
clearSelections()
proceedWithUpdatingTextStyle(