@@ -18,6 +18,7 @@ import com.swmansion.enriched.markdown.utils.common.FeatureFlags
1818import com.swmansion.enriched.markdown.utils.common.MarkdownSegmentRenderer
1919import com.swmansion.enriched.markdown.utils.common.RenderedSegment
2020import com.swmansion.enriched.markdown.utils.common.splitASTIntoSegments
21+ import com.swmansion.enriched.markdown.utils.text.view.applyMarkdownSelectionColors
2122import com.swmansion.enriched.markdown.utils.text.view.emitLinkLongPressEvent
2223import com.swmansion.enriched.markdown.utils.text.view.emitLinkPressEvent
2324import com.swmansion.enriched.markdown.views.BlockSegmentView
@@ -54,6 +55,8 @@ class EnrichedMarkdown
5455 private var maxFontSizeMultiplier: Float = 0f
5556 private var allowTrailingMargin: Boolean = false
5657 private var selectable: Boolean = true
58+ private var propSelectionColor: Int? = null
59+ private var propSelectionHandleColor: Int? = null
5760
5861 private var onLinkPressCallback: ((String ) -> Unit )? = null
5962 private var onLinkLongPressCallback: ((String ) -> Unit )? = null
@@ -128,6 +131,22 @@ class EnrichedMarkdown
128131 }
129132 }
130133
134+ fun setSelectionColorFromProps (color : Int? ) {
135+ propSelectionColor = color
136+ applySelectionColorsToSegments()
137+ }
138+
139+ fun setSelectionHandleColorFromProps (color : Int? ) {
140+ propSelectionHandleColor = color
141+ applySelectionColorsToSegments()
142+ }
143+
144+ private fun applySelectionColorsToSegments () {
145+ segmentViews.filterIsInstance<EnrichedMarkdownInternalText >().forEach {
146+ it.applyMarkdownSelectionColors(propSelectionColor, propSelectionHandleColor)
147+ }
148+ }
149+
131150 fun setOnLinkPressCallback (callback : (String ) -> Unit ) {
132151 onLinkPressCallback = callback
133152 }
@@ -234,6 +253,8 @@ class EnrichedMarkdown
234253 if (contextMenuItemTexts.isNotEmpty()) {
235254 setContextMenuItems(contextMenuItemTexts, ::forwardContextMenuItemPress)
236255 }
256+
257+ applyMarkdownSelectionColors(propSelectionColor, propSelectionHandleColor)
237258 }
238259
239260 private fun createTableView (
0 commit comments