Add opt-in RTL compatibility for markdown rendering#63
Conversation
4d65c94 to
c35efd3
Compare
c35efd3 to
aa018ee
Compare
93636e9 to
7aaf63a
Compare
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/MarkdownRichText.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/MarkdownRichText.kt
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
richtext-ui/src/commonMain/kotlin/com/halilibo/richtext/ui/FormattedList.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/TraverseUtils.kt
Outdated
Show resolved
Hide resolved
| * Lets list and quote containers override paragraph alignment without forcing a different | ||
| * direction-detection rule for the text inside the item. |
There was a problem hiding this comment.
Curious why this is better than wrapping the Text with a different LocalLayoutDirection value?
There was a problem hiding this comment.
I think LayoutDirection solves some of it but not all.
We have cases of an item in a list, which may be LTR or RTL, and the list itself (decide by first item) may have the list marked on the left or right. So we have both LTR and RTL text that we may need to align either left or right depending on the case.
| val markdownAnimationState = remember { MarkdownAnimationState() } | ||
|
|
||
| if (richTextRenderOptions.enableRtlCompatibility && astNode.type is AstDocument) { | ||
| BasicRichText(modifier = Modifier.width(IntrinsicSize.Max)) { |
There was a problem hiding this comment.
Would just using a Column here work? Seems like we have other simpler options available than putting another BasicRichText...
There was a problem hiding this comment.
Oh... I had a long back and forth with Codex about this. It claimed it won't, I made it do it, and it ended up winning since it broke direction on some things and I didn't fully understand why, but it said we need to reset the lists and stuff so all items will be considered part of the same doc or something.
There was a problem hiding this comment.
I do want to remove the duplicaiton here, should I extract a local Composable function? I'm not a fan too much of it.
There was a problem hiding this comment.
I don't get it... why would we only need to reset lists if we want to change the RTL compatibility bit?
richtext-markdown/src/commonMain/kotlin/com/halilibo/richtext/markdown/BasicMarkdown.kt
Show resolved
Hide resolved
|
|
||
| is AstUnorderedList, | ||
| is AstOrderedList -> { | ||
| val items = remember(astNode) { |
There was a problem hiding this comment.
Looks like before we didn't remember this by astNode, I hope this doesn't break anything, I'm assuming it shouldn't....
Codex:
Summary
RichTextRenderOptions.enableRtlCompatibilityfor markdown paragraph and heading alignment on top of [codex] Extract RTL compatibility samples #66Testing
./gradlew :richtext-ui:allTests :richtext-markdown:allTests :android-sample:testDebugUnitTest