1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-11 10:18:05 +09:00
* #409: add code block

* #409: update block code

* #409: block code action bar

* #409: Read mode for code block

* #409: fix package

* #409: update bg when selected

* #409: fix font

* #409: design fix

* start tests

* #409: tests off
This commit is contained in:
Konstantin Ivanov 2020-05-12 13:08:26 +03:00 committed by GitHub
parent f67533adb9
commit ff2a5185fd
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 171 additions and 21 deletions

View file

@ -1278,6 +1278,9 @@ class PageViewModel(
is BlockView.Toggle -> block.copy(isSelected = true).also {
select(block.id)
}
is BlockView.Code -> block.copy(isSelected = true).also {
select(block.id)
}
else -> block
}
}
@ -1519,6 +1522,7 @@ class PageViewModel(
is BlockView.Bulleted -> block.copy(isSelected = isSelected(target))
is BlockView.Numbered -> block.copy(isSelected = isSelected(target))
is BlockView.Toggle -> block.copy(isSelected = isSelected(target))
is BlockView.Code -> block.copy(isSelected = isSelected(target))
else -> block
}
else

View file

@ -111,7 +111,7 @@ class DefaultBlockViewRenderer(
}
Content.Text.Style.CODE_SNIPPET -> {
counter.reset()
result.add(code(block, content))
result.add(code(mode, block, content, focus))
}
Content.Text.Style.BULLET -> {
counter.reset()
@ -270,11 +270,15 @@ class DefaultBlockViewRenderer(
)
private fun code(
mode: EditorMode,
block: Block,
content: Content.Text
content: Content.Text,
focus: Id
): BlockView.Code = BlockView.Code(
mode = if (mode == EditorMode.EDITING) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
snippet = content.text
text = content.text,
focused = block.id == focus
)
private fun highlight(