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

Editor | Fix | Update mention names in headers (#2017)

Co-authored-by: konstantiniiv <ki@anytype.io>
This commit is contained in:
Konstantin Ivanov 2021-12-27 12:35:58 +02:00 committed by GitHub
parent ba209bc89b
commit ac3f68e6cb
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 48 deletions

View file

@ -341,6 +341,9 @@ interface TextBlockHolder : TextHolder {
content.pauseTextWatchers {
enableEditMode()
}
content.pauseTextWatchers {
content.applyMovementMethod(item)
}
} else {
enableReadMode()
}

View file

@ -571,23 +571,30 @@ class DefaultBlockViewRenderer(
indent: Int,
details: Block.Details,
selection: Set<Id>
): BlockView.Text.Header.Three = BlockView.Text.Header.Three(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
text = content.text,
color = content.color,
isFocused = block.id == focus.id,
marks = content.marks(details = details, urlBuilder = urlBuilder),
backgroundColor = content.backgroundColor,
indent = indent,
alignment = content.align?.toView(),
cursor = if (block.id == focus.id) setCursor(focus, content) else null,
isSelected = checkIfSelected(
mode = mode,
block = block,
selection = selection
): BlockView.Text.Header.Three {
val marks = content.marks(details = details, urlBuilder = urlBuilder)
val (normalizedText, normalizedMarks) = content.getTextAndMarks(
details = details,
marks = marks
)
)
return BlockView.Text.Header.Three(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
text = normalizedText,
color = content.color,
isFocused = block.id == focus.id,
marks = normalizedMarks,
backgroundColor = content.backgroundColor,
indent = indent,
alignment = content.align?.toView(),
cursor = if (block.id == focus.id) setCursor(focus, content) else null,
isSelected = checkIfSelected(
mode = mode,
block = block,
selection = selection
)
)
}
private fun headerTwo(
mode: EditorMode,
@ -597,23 +604,30 @@ class DefaultBlockViewRenderer(
indent: Int,
details: Block.Details,
selection: Set<Id>
): BlockView.Text.Header.Two = BlockView.Text.Header.Two(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
text = content.text,
color = content.color,
isFocused = block.id == focus.id,
marks = content.marks(details = details, urlBuilder = urlBuilder),
backgroundColor = content.backgroundColor,
indent = indent,
alignment = content.align?.toView(),
cursor = if (block.id == focus.id) setCursor(focus, content) else null,
isSelected = checkIfSelected(
mode = mode,
block = block,
selection = selection
): BlockView.Text.Header.Two {
val marks = content.marks(details = details, urlBuilder = urlBuilder)
val (normalizedText, normalizedMarks) = content.getTextAndMarks(
details = details,
marks = marks
)
)
return BlockView.Text.Header.Two(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
text = normalizedText,
color = content.color,
isFocused = block.id == focus.id,
marks = normalizedMarks,
backgroundColor = content.backgroundColor,
indent = indent,
alignment = content.align?.toView(),
cursor = if (block.id == focus.id) setCursor(focus, content) else null,
isSelected = checkIfSelected(
mode = mode,
block = block,
selection = selection
)
)
}
private fun headerOne(
mode: EditorMode,
@ -623,23 +637,30 @@ class DefaultBlockViewRenderer(
indent: Int,
details: Block.Details,
selection: Set<Id>
): BlockView.Text.Header.One = BlockView.Text.Header.One(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
text = content.text,
color = content.color,
isFocused = block.id == focus.id,
marks = content.marks(details = details, urlBuilder = urlBuilder),
backgroundColor = content.backgroundColor,
indent = indent,
alignment = content.align?.toView(),
cursor = if (block.id == focus.id) setCursor(focus, content) else null,
isSelected = checkIfSelected(
mode = mode,
block = block,
selection = selection
): BlockView.Text.Header.One {
val marks = content.marks(details = details, urlBuilder = urlBuilder)
val (normalizedText, normalizedMarks) = content.getTextAndMarks(
details = details,
marks = marks
)
)
return BlockView.Text.Header.One(
mode = if (mode == EditorMode.Edit) BlockView.Mode.EDIT else BlockView.Mode.READ,
id = block.id,
text = normalizedText,
color = content.color,
isFocused = block.id == focus.id,
marks = normalizedMarks,
backgroundColor = content.backgroundColor,
indent = indent,
alignment = content.align?.toView(),
cursor = if (block.id == focus.id) setCursor(focus, content) else null,
isSelected = checkIfSelected(
mode = mode,
block = block,
selection = selection
)
)
}
private fun checkbox(
mode: EditorMode,