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:
parent
26c3335a3c
commit
c964f71b4e
3 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue