Modern Apps git

← Modern-Apps.git

library-ui: render paragraph left-indent + list-level indent in the editor (indent buttons now visibly work)

Commit
dfd66a29734f2395592791dea57b9a0e9ea250ad
Author
Vayun Mathur <[email protected]>
When
2026-07-06 17:36 UTC (5 months ago)
Parents
9025d59

Diff

library/ui/src/main/java/com/vayunmathur/library/ui/odf/OdfTextEditorView.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/ui/odf/OdfTextEditorView.kt b/library/ui/src/main/java/com/vayunmathur/library/ui/odf/OdfTextEditorView.ktindex df9159b6a3..208d50d2f5 100644--- a/library/ui/src/main/java/com/vayunmathur/library/ui/odf/OdfTextEditorView.kt+++ b/library/ui/src/main/java/com/vayunmathur/library/ui/odf/OdfTextEditorView.kt@@ -312,7 +312,8 @@ fun ContinuousParagraphEditor(  private fun sameLayout(a: OdfParagraph, b: OdfParagraph): Boolean =     a.alignment == b.alignment && a.lineHeightPercent == b.lineHeightPercent &&-        a.textIndent == 0f && b.textIndent == 0f+        a.textIndent == 0f && b.textIndent == 0f &&+        a.marginLeft == b.marginLeft && a.listLevel == b.listLevel  /**  * Transformed-text start offset (start of the injected prefix) for each paragraph. Every paragraph@@ -420,7 +421,11 @@ private fun buildDocTransformed(             // overrides the alignment/indent of real content. (A5/A6 + paragraph-spacing fix)             if (groupEnds) {                 val styleSrc = (groupFirst..i).firstOrNull { lens[it] > 0 }?.let { paras[it] } ?: paras[groupFirst]-                val firstLineIndent = if (styleSrc.textIndent != 0f) styleSrc.textIndent.sp else 0.sp+                // Left indent for the whole paragraph = paragraph margin + nested-list level; applied to+                // every line via TextIndent.restLine, with the first line getting the extra first-line indent.+                val leftIndent = styleSrc.marginLeft + maxOf(0, styleSrc.listLevel - 1) * 16f+                val firstLineIndent = (leftIndent + styleSrc.textIndent).sp+                val restIndent = leftIndent.sp                 // Justify is stretched at draw time, but BasicTextField computes caret / selection /                 // handle positions from the UNSTRETCHED glyph advances, so they drift left of the                 // displayed justified glyphs. Render the editable field with Start alignment so the@@ -432,7 +437,7 @@ private fun buildDocTransformed(                     androidx.compose.ui.text.ParagraphStyle(                         textAlign = editorAlign,                         lineHeight = styleSrc.lineHeightPercent?.let { (22f * mult * it).sp } ?: TextUnit.Unspecified,-                        textIndent = if (styleSrc.textIndent != 0f) androidx.compose.ui.text.style.TextIndent(firstLine = firstLineIndent, restLine = 0.sp) else androidx.compose.ui.text.style.TextIndent.None+                        textIndent = if (leftIndent != 0f || styleSrc.textIndent != 0f) androidx.compose.ui.text.style.TextIndent(firstLine = firstLineIndent, restLine = restIndent) else androidx.compose.ui.text.style.TextIndent.None                     ),                     groupStart, length                 )