From 406131a3dd90a859f03d496fba6066b4ae42bf9c Mon Sep 17 00:00:00 2001 From: Wavesonics Date: Sat, 27 Jan 2024 16:41:52 -0800 Subject: [PATCH 01/26] Handle link clicks in BasicRichTextEditor --- .../richeditor/ui/BasicRichTextEditor.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index a6e6ed56..7ca31ea9 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -211,6 +211,19 @@ public fun BasicRichTextEditor( state.singleParagraphMode = singleParagraph } + LaunchedEffect(interactionSource) { + scope.launch { + interactionSource.interactions.collect { interaction -> + if (interaction is PressInteraction.Press) { + val clickedLink = state.getLinkByOffset(interaction.pressPosition) + if (clickedLink != null) { + uriHandler.openUri(clickedLink) + } + } + } + } + } + if (!singleParagraph) { // Workaround for Android to fix a bug in BasicTextField where it doesn't select the correct text // when the text contains multiple paragraphs. From 5972cc57930c9cc069bc22deb9fbac47035c0e95 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 1 Feb 2024 15:49:13 -0800 Subject: [PATCH 02/26] Re move arg --- .../com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 7ca31ea9..4faf2ea1 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -16,7 +16,10 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor -import androidx.compose.ui.platform.* +import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalLayoutDirection +import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction @@ -196,6 +199,8 @@ public fun BasicRichTextEditor( @Composable { innerTextField -> innerTextField() }, contentPadding: PaddingValues ) { + val scope = rememberCoroutineScope() + val uriHandler = LocalUriHandler.current val density = LocalDensity.current val localTextStyle = LocalTextStyle.current val layoutDirection = LocalLayoutDirection.current From 31f064ed30115a67a2132f7cec45c5b0f2ab6157 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 1 Feb 2024 19:53:43 -0800 Subject: [PATCH 03/26] Add callback for handling click on RichSpans This update introduces a callback function `onRichSpanClick` to allow apps to handle clicks on RichSpans in the RichTextEditor. The updates also modify the visibility of some classes and properties to support this- `RichSpan`, `ParagraphType` and `getRichSpanByOffset` method in `RichTextState` are now publicly visible. --- .../mohamedrejeb/richeditor/model/RichSpan.kt | 3 +-- .../richeditor/model/RichTextState.kt | 4 +-- .../richeditor/paragraph/RichParagraph.kt | 2 +- .../paragraph/type/ParagraphType.kt | 2 +- .../richeditor/ui/BasicRichTextEditor.kt | 26 ++++++++++++------- .../ui/material/OutlinedRichTextEditor.kt | 5 +++- .../richeditor/ui/material/RichTextEditor.kt | 4 +++ .../ui/material3/OutlinedRichTextEditor.kt | 4 +++ .../richeditor/ui/material3/RichTextEditor.kt | 6 +++-- 9 files changed, 38 insertions(+), 18 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt index 81476da9..182fcf53 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt @@ -14,8 +14,7 @@ import kotlin.collections.indices /** * A rich span is a part of a rich paragraph. */ -@OptIn(ExperimentalRichTextApi::class) -internal class RichSpan( +class RichSpan( internal val key: Int? = null, val children: MutableList = mutableListOf(), var paragraph: RichParagraph, diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index ad6305e2..c409a136 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -76,7 +76,7 @@ public class RichTextState internal constructor( internal var singleParagraphMode by mutableStateOf(false) - internal var textLayoutResult: TextLayoutResult? by mutableStateOf(null) + var textLayoutResult: TextLayoutResult? by mutableStateOf(null) private set private var lastPressPosition: Offset? by mutableStateOf(null) @@ -2731,7 +2731,7 @@ public class RichTextState internal constructor( return richSpan } - private fun getRichSpanByOffset(offset: Offset): RichSpan? { + fun getRichSpanByOffset(offset: Offset): RichSpan? { this.textLayoutResult?.let { textLayoutResult -> val position = textLayoutResult.getOffsetForPosition(offset) return getRichSpanByTextIndex(position, true) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt index 088e42cf..ec5c16dd 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt @@ -12,7 +12,7 @@ import com.mohamedrejeb.richeditor.paragraph.type.ParagraphType import com.mohamedrejeb.richeditor.paragraph.type.ParagraphType.Companion.startText import com.mohamedrejeb.richeditor.ui.test.getRichTextStyleTreeRepresentation -internal class RichParagraph( +class RichParagraph( val key: Int = 0, val children: MutableList = mutableListOf(), var paragraphStyle: ParagraphStyle = DefaultParagraphStyle, diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt index 7e40deba..c487ac33 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt @@ -4,7 +4,7 @@ import androidx.compose.ui.text.ParagraphStyle import com.mohamedrejeb.richeditor.model.RichSpan import com.mohamedrejeb.richeditor.model.RichTextConfig -internal interface ParagraphType { +interface ParagraphType { fun getStyle(config: RichTextConfig): ParagraphStyle diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 4faf2ea1..835c0e79 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -19,15 +19,16 @@ import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.LayoutDirection +import com.mohamedrejeb.richeditor.model.RichSpan import com.mohamedrejeb.richeditor.model.RichTextState import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch /** @@ -65,6 +66,7 @@ import kotlinx.coroutines.CoroutineScope * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. * @param maxLength the maximum length of the text field. If the text is longer than this value, * it will be ignored. The default value of this parameter is [Int.MAX_VALUE]. + * @param onRichSpanClick A callback to allow handling of click on RichSpans. * @param onTextLayout Callback that is executed when a new text layout is calculated. A * [TextLayoutResult] object that callback provides contains paragraph information, size of the * text, baselines and other details. The callback can be used to add additional decoration or @@ -97,6 +99,7 @@ public fun BasicRichTextEditor( minLines: Int = 1, maxLength: Int = Int.MAX_VALUE, onRichTextChangedListener: RichTextChangedListener? = null, + onRichSpanClick: RichSpanClickListener? = null, onTextLayout: (TextLayoutResult) -> Unit = {}, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, cursorBrush: Brush = SolidColor(Color.Black), @@ -116,6 +119,7 @@ public fun BasicRichTextEditor( minLines = minLines, maxLength = maxLength, onRichTextChangedListener = onRichTextChangedListener, + onRichSpanClick = onRichSpanClick, onTextLayout = onTextLayout, interactionSource = interactionSource, cursorBrush = cursorBrush, @@ -159,6 +163,7 @@ public fun BasicRichTextEditor( * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. * @param maxLength the maximum length of the text field. If the text is longer than this value, * it will be ignored. The default value of this parameter is [Int.MAX_VALUE]. + * @param onRichSpanClick A callback to allow handling of click on RichSpans. * @param onTextLayout Callback that is executed when a new text layout is calculated. A * [TextLayoutResult] object that callback provides contains paragraph information, size of the * text, baselines and other details. The callback can be used to add additional decoration or @@ -192,6 +197,7 @@ public fun BasicRichTextEditor( minLines: Int = 1, maxLength: Int = Int.MAX_VALUE, onRichTextChangedListener: RichTextChangedListener? = null, + onRichSpanClick: RichSpanClickListener? = null, onTextLayout: (TextLayoutResult) -> Unit = {}, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, cursorBrush: Brush = SolidColor(Color.Black), @@ -200,7 +206,6 @@ public fun BasicRichTextEditor( contentPadding: PaddingValues ) { val scope = rememberCoroutineScope() - val uriHandler = LocalUriHandler.current val density = LocalDensity.current val localTextStyle = LocalTextStyle.current val layoutDirection = LocalLayoutDirection.current @@ -216,13 +221,15 @@ public fun BasicRichTextEditor( state.singleParagraphMode = singleParagraph } - LaunchedEffect(interactionSource) { - scope.launch { - interactionSource.interactions.collect { interaction -> - if (interaction is PressInteraction.Press) { - val clickedLink = state.getLinkByOffset(interaction.pressPosition) - if (clickedLink != null) { - uriHandler.openUri(clickedLink) + if(onRichSpanClick != null) { + // Start listening for rich span clicks + LaunchedEffect(interactionSource) { + scope.launch { + interactionSource.interactions.collect { interaction -> + if (interaction is PressInteraction.Press) { + state.getRichSpanByOffset(interaction.pressPosition)?.let { clickedSpan -> + onRichSpanClick(clickedSpan) + } } } } @@ -336,3 +343,4 @@ internal suspend fun adjustTextIndicatorOffset( } public typealias RichTextChangedListener = (RichTextState) -> Unit +typealias RichSpanClickListener = (RichSpan) -> Unit diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditor.kt index 290291fb..ac883e3f 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditor.kt @@ -22,6 +22,7 @@ import androidx.compose.ui.unit.dp import com.mohamedrejeb.richeditor.model.RichTextState import com.mohamedrejeb.richeditor.ui.BasicRichTextEditor import com.mohamedrejeb.richeditor.ui.RichTextChangedListener +import com.mohamedrejeb.richeditor.ui.RichSpanClickListener /** * Material Design outlined rich text field @@ -66,8 +67,8 @@ import com.mohamedrejeb.richeditor.ui.RichTextChangedListener * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. * @param minLines the minimum height in terms of minimum number of visible lines. It is required * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. - * @param onRichTextChangedListener A callback when the RichTextState changes. + * @param onRichSpanClick A callback to allow handling of click on RichSpans. * @param interactionSource the [MutableInteractionSource] representing the stream of * [Interaction]s for this OutlinedTextField. You can create and pass in your own remembered * [MutableInteractionSource] if you want to observe [Interaction]s and customize the @@ -96,6 +97,7 @@ public fun OutlinedRichTextEditor( minLines: Int = 1, maxLength: Int = Int.MAX_VALUE, onRichTextChangedListener: RichTextChangedListener? = null, + onRichSpanClick: RichSpanClickListener? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = MaterialTheme.shapes.small, colors: TextFieldColors = TextFieldDefaults.outlinedTextFieldColors() @@ -135,6 +137,7 @@ public fun OutlinedRichTextEditor( minLines = minLines, maxLength = maxLength, onRichTextChangedListener = onRichTextChangedListener, + onRichSpanClick = onRichSpanClick, decorationBox = @Composable { innerTextField -> TextFieldDefaults.OutlinedTextFieldDecorationBox( value = state.textFieldValue.text, diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/RichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/RichTextEditor.kt index 56629e00..5895b638 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/RichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material/RichTextEditor.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.text.input.KeyboardType import com.mohamedrejeb.richeditor.model.RichTextState import com.mohamedrejeb.richeditor.ui.BasicRichTextEditor import com.mohamedrejeb.richeditor.ui.RichTextChangedListener +import com.mohamedrejeb.richeditor.ui.RichSpanClickListener import com.mohamedrejeb.richeditor.ui.material3.RichTextEditor /** @@ -65,6 +66,7 @@ import com.mohamedrejeb.richeditor.ui.material3.RichTextEditor * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. * @param minLines the minimum height in terms of minimum number of visible lines. It is required * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. + * @param onRichSpanClick A callback to allow handling of click on RichSpans. * @param interactionSource the [MutableInteractionSource] representing the stream of * [Interaction]s for this TextField. You can create and pass in your own remembered * [MutableInteractionSource] if you want to observe [Interaction]s and customize the @@ -100,6 +102,7 @@ public fun RichTextEditor( minLines: Int = 1, maxLength: Int = Int.MAX_VALUE, onRichTextChangedListener: RichTextChangedListener? = null, + onRichSpanClick: RichSpanClickListener? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = MaterialTheme.shapes.small.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize), @@ -133,6 +136,7 @@ public fun RichTextEditor( minLines = minLines, maxLength = maxLength, onRichTextChangedListener = onRichTextChangedListener, + onRichSpanClick = onRichSpanClick, decorationBox = @Composable { innerTextField -> // places leading icon, text field with label and placeholder, trailing icon TextFieldDefaults.TextFieldDecorationBox( diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditor.kt index 8a3d7073..59e53b28 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditor.kt @@ -31,6 +31,7 @@ import androidx.compose.ui.unit.* import com.mohamedrejeb.richeditor.model.RichTextState import com.mohamedrejeb.richeditor.ui.BasicRichTextEditor import com.mohamedrejeb.richeditor.ui.RichTextChangedListener +import com.mohamedrejeb.richeditor.ui.RichSpanClickListener import kotlin.math.max import kotlin.math.roundToInt @@ -78,6 +79,7 @@ import kotlin.math.roundToInt * @param maxLength the maximum length of the text field. If the text is longer than this value, * it will be ignored. The default value of this parameter is [Int.MAX_VALUE]. * onTextLayout + * @param onRichSpanClick A callback to allow handling of click on RichSpans. * @param interactionSource the [MutableInteractionSource] representing the stream of [Interaction]s * for this text field. You can create and pass in your own `remember`ed instance to observe * [Interaction]s and customize the appearance / behavior of this text field in different states. @@ -107,6 +109,7 @@ public fun OutlinedRichTextEditor( minLines: Int = 1, maxLength: Int = Int.MAX_VALUE, onRichTextChangedListener: RichTextChangedListener? = null, + onRichSpanClick: RichSpanClickListener? = null, onTextLayout: (TextLayoutResult) -> Unit = {}, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = RichTextEditorDefaults.outlinedShape, @@ -148,6 +151,7 @@ public fun OutlinedRichTextEditor( minLines = minLines, maxLength = maxLength, onRichTextChangedListener = onRichTextChangedListener, + onRichSpanClick = onRichSpanClick, onTextLayout = onTextLayout, decorationBox = { innerTextField -> RichTextEditorDefaults.OutlinedRichTextEditorDecorationBox( diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/RichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/RichTextEditor.kt index f9ae4908..819ab1b2 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/RichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/material3/RichTextEditor.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.selection.LocalTextSelectionColors import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.* -import androidx.compose.material3.Typography import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember @@ -21,7 +20,6 @@ import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.graphics.takeOrElse import androidx.compose.ui.layout.* -import androidx.compose.ui.layout.layoutId import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction @@ -29,6 +27,7 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.* import com.mohamedrejeb.richeditor.model.RichTextState import com.mohamedrejeb.richeditor.ui.BasicRichTextEditor +import com.mohamedrejeb.richeditor.ui.RichSpanClickListener import kotlin.math.max import kotlin.math.roundToInt @@ -76,6 +75,7 @@ import kotlin.math.roundToInt * that 1 <= [minLines] <= [maxLines]. This parameter is ignored when [singleLine] is true. * @param maxLength the maximum length of the text field. If the text is longer than this value, * it will be ignored. The default value of this parameter is [Int.MAX_VALUE]. + * @param onRichSpanClick A callback to allow handling of click on RichSpans. * @param interactionSource the [MutableInteractionSource] representing the stream of [Interaction]s * for this text field. You can create and pass in your own `remember`ed instance to observe * [Interaction]s and customize the appearance / behavior of this text field in different states. @@ -104,6 +104,7 @@ public fun RichTextEditor( maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, minLines: Int = 1, maxLength: Int = Int.MAX_VALUE, + onRichSpanClick: RichSpanClickListener? = null, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, shape: Shape = RichTextEditorDefaults.filledShape, colors: RichTextEditorColors = RichTextEditorDefaults.richTextEditorColors(), @@ -137,6 +138,7 @@ public fun RichTextEditor( maxLines = maxLines, minLines = minLines, maxLength = maxLength, + onRichSpanClick = onRichSpanClick, interactionSource = interactionSource, cursorBrush = SolidColor(colors.cursorColor(isError).value), decorationBox = @Composable { innerTextField -> From 51dcf4192833a298d8abe83baf92bb87fc1af862 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 1 Feb 2024 19:54:10 -0800 Subject: [PATCH 04/26] Add some code for testing span clicks --- .../common/richeditor/RichEditorContent.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index 9b868276..3d291d08 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -19,7 +19,7 @@ import com.mohamedrejeb.richeditor.ui.material3.OutlinedRichTextEditor import com.mohamedrejeb.richeditor.ui.material3.RichText import com.mohamedrejeb.richeditor.ui.material3.RichTextEditor -@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) +@OptIn(ExperimentalMaterial3Api::class) @Composable fun RichEditorContent() { val navigator = LocalNavigator.currentOrThrow @@ -50,8 +50,7 @@ fun RichEditorContent() { } ) }, - modifier = Modifier - .fillMaxSize() + modifier = Modifier.fillMaxSize() ) { paddingValue -> LazyColumn( contentPadding = paddingValue, @@ -84,6 +83,17 @@ fun RichEditorContent() { BasicRichTextEditor( modifier = Modifier.fillMaxWidth(), state = basicRichTextState, + onRichSpanClick = { span -> + println("clicked") + if (span.style is SpellCheck) { + println("Spell check clicked") + val position = + basicRichTextState.textLayoutResult + ?.multiParagraph + ?.getBoundingBox(span.textRange.start) + println("Position: ${position}") + } + } ) } From 4c6b28321012a90bdbbe0cdc67e695760f553322 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 1 Feb 2024 20:31:21 -0800 Subject: [PATCH 05/26] Spellcheck test --- .../common/richeditor/RichEditorContent.kt | 56 ++++++++++++++----- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index 3d291d08..f9fe417f 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -5,9 +5,10 @@ import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.* -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow @@ -80,21 +81,46 @@ fun RichEditorContent() { } item { - BasicRichTextEditor( - modifier = Modifier.fillMaxWidth(), - state = basicRichTextState, - onRichSpanClick = { span -> - println("clicked") - if (span.style is SpellCheck) { - println("Spell check clicked") - val position = - basicRichTextState.textLayoutResult - ?.multiParagraph - ?.getBoundingBox(span.textRange.start) - println("Position: ${position}") + Box { + var spellCheckExpanded by remember { mutableStateOf(null) } + + BasicRichTextEditor( + modifier = Modifier.fillMaxWidth(), + state = basicRichTextState, + onRichSpanClick = { span -> + println("clicked") + if (span.style is SpellCheck) { + println("Spell check clicked") + val position = + basicRichTextState.textLayoutResult + ?.multiParagraph + ?.getBoundingBox(span.textRange.start) + println("Position: ${position}") + spellCheckExpanded = position + } } + ) + + DropdownMenu( + expanded = spellCheckExpanded != null, + onDismissRequest = { spellCheckExpanded = null }, + offset = DpOffset( + x = spellCheckExpanded?.left?.dp ?: 0.dp, + y = spellCheckExpanded?.top?.dp ?: 0.dp, + ), + ) { + DropdownMenuItem( + text = { Text("Spelling") }, + onClick = {} + ) + + DropdownMenuItem( + text = { Text("Spelling") }, + onClick = {} + ) } - ) + + } } item { From af563d0b871c4ea828053860714f4824856dcdf9 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 12 Nov 2024 18:30:20 -0800 Subject: [PATCH 06/26] Make explicitly public --- .../mohamedrejeb/richeditor/model/RichSpan.kt | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt index 182fcf53..f596dcc5 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt @@ -9,20 +9,19 @@ import com.mohamedrejeb.richeditor.annotation.ExperimentalRichTextApi import com.mohamedrejeb.richeditor.paragraph.RichParagraph import com.mohamedrejeb.richeditor.utils.customMerge import com.mohamedrejeb.richeditor.utils.isSpecifiedFieldsEquals -import kotlin.collections.indices /** * A rich span is a part of a rich paragraph. */ -class RichSpan( +public class RichSpan( internal val key: Int? = null, - val children: MutableList = mutableListOf(), - var paragraph: RichParagraph, - var parent: RichSpan? = null, - var text: String = "", - var textRange: TextRange = TextRange(start = 0, end = 0), - var spanStyle: SpanStyle = SpanStyle(), - var richSpanStyle: RichSpanStyle = RichSpanStyle.Default, + public val children: MutableList = mutableListOf(), + public var paragraph: RichParagraph, + public var parent: RichSpan? = null, + public var text: String = "", + public var textRange: TextRange = TextRange(start = 0, end = 0), + public var spanStyle: SpanStyle = SpanStyle(), + public var richSpanStyle: RichSpanStyle = RichSpanStyle.Default, ) { /** * Return the full text range of the rich span. @@ -50,7 +49,7 @@ class RichSpan( * * @return The full span style of the rich span */ - val fullSpanStyle: SpanStyle get() { + public val fullSpanStyle: SpanStyle get() { var spanStyle = this.spanStyle var parent = this.parent @@ -62,7 +61,7 @@ class RichSpan( return spanStyle } - val fullStyle: RichSpanStyle get() { + public val fullStyle: RichSpanStyle get() { var style = this.richSpanStyle var parent = this.parent @@ -74,7 +73,7 @@ class RichSpan( return style } - val before: RichSpan? get() { + public val before: RichSpan? get() { val parentChildren = parent?.children ?: paragraph.children val index = parentChildren.indexOf(this) @@ -96,7 +95,7 @@ class RichSpan( * * @return The next rich span or null if the rich span is the last in the paragraph */ - val after: RichSpan? get() { + public val after: RichSpan? get() { if (children.isNotEmpty()) return children.first() @@ -133,7 +132,7 @@ class RichSpan( * * @return True if the rich span is the first in the paragraph, false otherwise */ - val isFirstInParagraph: Boolean get() { + public val isFirstInParagraph: Boolean get() { var current: RichSpan var parent: RichSpan = this @@ -152,7 +151,7 @@ class RichSpan( * * @return True if the rich span is the last in the paragraph, false otherwise */ - val isLastInParagraph: Boolean get() { + public val isLastInParagraph: Boolean get() { var current: RichSpan var parent: RichSpan = this @@ -174,7 +173,7 @@ class RichSpan( * * @return True if the rich span is empty, false otherwise */ - fun isEmpty(): Boolean = text.isEmpty() && isChildrenEmpty() && richSpanStyle !is RichSpanStyle.Image + public fun isEmpty(): Boolean = text.isEmpty() && isChildrenEmpty() && richSpanStyle !is RichSpanStyle.Image /** * Check if the rich span is blank. @@ -182,7 +181,7 @@ class RichSpan( * * @return True if the rich span is blank, false otherwise */ - fun isBlank(): Boolean = text.isBlank() && isChildrenBlank() && richSpanStyle !is RichSpanStyle.Image + public fun isBlank(): Boolean = text.isBlank() && isChildrenBlank() && richSpanStyle !is RichSpanStyle.Image /** * Check if the rich span children are empty @@ -347,7 +346,7 @@ class RichSpan( * @return A pair of the offset and the rich span or null if the rich span is not found */ @OptIn(ExperimentalRichTextApi::class) - fun getRichSpanByTextIndex( + public fun getRichSpanByTextIndex( textIndex: Int, offset: Int = 0, ignoreCustomFiltering: Boolean = false @@ -401,7 +400,7 @@ class RichSpan( * @param offset The offset of the text range * @return The rich span list */ - fun getRichSpanListByTextRange( + public fun getRichSpanListByTextRange( searchTextRange: TextRange, offset: Int = 0, ): Pair> { @@ -432,7 +431,7 @@ class RichSpan( /** * Removes the current rich span from its parent and clears its text. */ - fun remove() { + public fun remove() { text = "" parent?.children?.remove(this) } @@ -443,7 +442,7 @@ class RichSpan( * @param removeTextRange The text range to remove * @return The rich span with the removed text range or null if the rich span is empty */ - fun removeTextRange( + public fun removeTextRange( removeTextRange: TextRange, offset: Int, ): Pair { @@ -510,7 +509,7 @@ class RichSpan( * @param spanStyle The span style * @return The closest parent rich span or null if not found */ - fun getClosestRichSpan(spanStyle: SpanStyle, newRichSpanStyle: RichSpanStyle): RichSpan? { + public fun getClosestRichSpan(spanStyle: SpanStyle, newRichSpanStyle: RichSpanStyle): RichSpan? { if ( spanStyle.isSpecifiedFieldsEquals(this.fullSpanStyle, strict = true) && newRichSpanStyle::class == richSpanStyle::class @@ -524,14 +523,14 @@ class RichSpan( * * @param newParagraph The new paragraph */ - fun updateChildrenParagraph(newParagraph: RichParagraph) { + public fun updateChildrenParagraph(newParagraph: RichParagraph) { children.fastForEach { childRichSpan -> childRichSpan.paragraph = newParagraph childRichSpan.updateChildrenParagraph(newParagraph) } } - fun removeEmptyChildren() { + public fun removeEmptyChildren() { val toRemoveIndices = mutableListOf() children.fastForEachIndexed { i, richSpan -> @@ -546,7 +545,7 @@ class RichSpan( } } - fun copy( + public fun copy( newParagraph: RichParagraph = paragraph, ): RichSpan { val newSpan = RichSpan( From 93265ad23bb1376e4da6d15e645e4e79eb638cd4 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 12 Nov 2024 18:36:38 -0800 Subject: [PATCH 07/26] It compiles again --- .../richeditor/model/RichTextState.kt | 4 +- .../richeditor/paragraph/RichParagraph.kt | 40 +++++++++---------- .../paragraph/type/ParagraphType.kt | 14 +++---- .../richeditor/ui/BasicRichTextEditor.kt | 8 +++- .../common/richeditor/RichEditorContent.kt | 30 ++++++++++++-- 5 files changed, 61 insertions(+), 35 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index c409a136..50060f13 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -76,7 +76,7 @@ public class RichTextState internal constructor( internal var singleParagraphMode by mutableStateOf(false) - var textLayoutResult: TextLayoutResult? by mutableStateOf(null) + public var textLayoutResult: TextLayoutResult? by mutableStateOf(null) private set private var lastPressPosition: Offset? by mutableStateOf(null) @@ -2731,7 +2731,7 @@ public class RichTextState internal constructor( return richSpan } - fun getRichSpanByOffset(offset: Offset): RichSpan? { + public fun getRichSpanByOffset(offset: Offset): RichSpan? { this.textLayoutResult?.let { textLayoutResult -> val position = textLayoutResult.getOffsetForPosition(offset) return getRichSpanByTextIndex(position, true) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt index ec5c16dd..29837fed 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt @@ -12,15 +12,15 @@ import com.mohamedrejeb.richeditor.paragraph.type.ParagraphType import com.mohamedrejeb.richeditor.paragraph.type.ParagraphType.Companion.startText import com.mohamedrejeb.richeditor.ui.test.getRichTextStyleTreeRepresentation -class RichParagraph( - val key: Int = 0, - val children: MutableList = mutableListOf(), - var paragraphStyle: ParagraphStyle = DefaultParagraphStyle, - var type: ParagraphType = DefaultParagraph(), +public class RichParagraph( + internal val key: Int = 0, + internal val children: MutableList = mutableListOf(), + internal var paragraphStyle: ParagraphStyle = DefaultParagraphStyle, + internal var type: ParagraphType = DefaultParagraph(), ) { @OptIn(ExperimentalRichTextApi::class) - fun getRichSpanByTextIndex( + public fun getRichSpanByTextIndex( paragraphIndex: Int, textIndex: Int, offset: Int = 0, @@ -72,7 +72,7 @@ class RichParagraph( } @OptIn(ExperimentalRichTextApi::class) - fun getRichSpanListByTextRange( + public fun getRichSpanListByTextRange( paragraphIndex: Int, searchTextRange: TextRange, offset: Int = 0, @@ -109,7 +109,7 @@ class RichParagraph( return index to richSpanList } - fun removeTextRange( + public fun removeTextRange( textRange: TextRange, offset: Int, ): RichParagraph? { @@ -163,9 +163,9 @@ class RichParagraph( return true } - fun isNotEmpty(ignoreStartRichSpan: Boolean = true): Boolean = !isEmpty(ignoreStartRichSpan) + public fun isNotEmpty(ignoreStartRichSpan: Boolean = true): Boolean = !isEmpty(ignoreStartRichSpan) - fun isBlank(ignoreStartRichSpan: Boolean = true): Boolean { + public fun isBlank(ignoreStartRichSpan: Boolean = true): Boolean { if (!ignoreStartRichSpan && !type.startRichSpan.isBlank()) return false if (children.isEmpty()) return true @@ -175,9 +175,9 @@ class RichParagraph( return true } - fun isNotBlank(ignoreStartRichSpan: Boolean = true): Boolean = !isBlank(ignoreStartRichSpan) + public fun isNotBlank(ignoreStartRichSpan: Boolean = true): Boolean = !isBlank(ignoreStartRichSpan) - fun getFirstNonEmptyChild(offset: Int = -1): RichSpan? { + public fun getFirstNonEmptyChild(offset: Int = -1): RichSpan? { children.fastForEach { richSpan -> if (richSpan.text.isNotEmpty()) { if (offset != -1) @@ -211,7 +211,7 @@ class RichParagraph( /** * Trim the rich paragraph */ - fun trim() { + public fun trim() { val isEmpty = trimStart() if (!isEmpty) trimEnd() @@ -222,7 +222,7 @@ class RichParagraph( * * @return True if the rich paragraph is empty after trimming, false otherwise */ - fun trimStart(): Boolean { + public fun trimStart(): Boolean { children.fastForEach { richSpan -> val isEmpty = richSpan.trimStart() @@ -238,7 +238,7 @@ class RichParagraph( * * @return True if the rich paragraph is empty after trimming, false otherwise */ - fun trimEnd(): Boolean { + public fun trimEnd(): Boolean { children.fastForEachReversed { richSpan -> val isEmpty = richSpan.trimEnd() @@ -254,14 +254,14 @@ class RichParagraph( * * @param newParagraph The new paragraph */ - fun updateChildrenParagraph(newParagraph: RichParagraph) { + public fun updateChildrenParagraph(newParagraph: RichParagraph) { children.fastForEach { childRichSpan -> childRichSpan.paragraph = newParagraph childRichSpan.updateChildrenParagraph(newParagraph) } } - fun removeEmptyChildren() { + public fun removeEmptyChildren() { val toRemoveIndices = mutableListOf() children.fastForEachIndexed { index, richSpan -> @@ -276,7 +276,7 @@ class RichParagraph( } } - fun copy(): RichParagraph { + public fun copy(): RichParagraph { val newParagraph = RichParagraph( paragraphStyle = paragraphStyle, type = type.copy(), @@ -299,7 +299,7 @@ class RichParagraph( return stringBuilder.toString() } - companion object { - val DefaultParagraphStyle = ParagraphStyle() + public companion object { + public val DefaultParagraphStyle: ParagraphStyle = ParagraphStyle() } } \ No newline at end of file diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt index c487ac33..f21da66f 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt @@ -4,17 +4,17 @@ import androidx.compose.ui.text.ParagraphStyle import com.mohamedrejeb.richeditor.model.RichSpan import com.mohamedrejeb.richeditor.model.RichTextConfig -interface ParagraphType { +public interface ParagraphType { - fun getStyle(config: RichTextConfig): ParagraphStyle + public fun getStyle(config: RichTextConfig): ParagraphStyle - val startRichSpan: RichSpan + public val startRichSpan: RichSpan - fun getNextParagraphType(): ParagraphType + public fun getNextParagraphType(): ParagraphType - fun copy(): ParagraphType + public fun copy(): ParagraphType - companion object { - val ParagraphType.startText : String get() = startRichSpan.text + public companion object { + public val ParagraphType.startText : String get() = startRichSpan.text } } \ No newline at end of file diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 835c0e79..2f1e1c2e 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -9,7 +9,11 @@ import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.LocalTextStyle -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.geometry.Offset @@ -343,4 +347,4 @@ internal suspend fun adjustTextIndicatorOffset( } public typealias RichTextChangedListener = (RichTextState) -> Unit -typealias RichSpanClickListener = (RichSpan) -> Unit +public typealias RichSpanClickListener = (RichSpan) -> Unit diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index f9fe417f..b456ef5e 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -1,11 +1,33 @@ package com.mohamedrejeb.richeditor.sample.common.richeditor -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.ime +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack -import androidx.compose.material3.* -import androidx.compose.runtime.* +import androidx.compose.material3.DropdownMenu +import androidx.compose.material3.DropdownMenuItem +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Rect import androidx.compose.ui.unit.DpOffset @@ -89,7 +111,7 @@ fun RichEditorContent() { state = basicRichTextState, onRichSpanClick = { span -> println("clicked") - if (span.style is SpellCheck) { + if (span.richSpanStyle is SpellCheck) { println("Spell check clicked") val position = basicRichTextState.textLayoutResult From 894a01480c4483d7b57abfdf6cf4eca9e9db6305 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 12 Nov 2024 21:08:24 -0800 Subject: [PATCH 08/26] API --- .../api/android/richeditor-compose.api | 89 ++++++++++++++++++- .../api/desktop/richeditor-compose.api | 89 ++++++++++++++++++- 2 files changed, 176 insertions(+), 2 deletions(-) diff --git a/richeditor-compose/api/android/richeditor-compose.api b/richeditor-compose/api/android/richeditor-compose.api index 81bce638..6f0ed139 100644 --- a/richeditor-compose/api/android/richeditor-compose.api +++ b/richeditor-compose/api/android/richeditor-compose.api @@ -29,6 +29,45 @@ public final class com/mohamedrejeb/richeditor/model/ImageLoaderKt { public static final fun getLocalImageLoader ()Landroidx/compose/runtime/ProvidableCompositionLocal; } +public final class com/mohamedrejeb/richeditor/model/RichSpan { + public static final field $stable I + public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public static synthetic fun copy$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getAfter ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getBefore ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getChildren ()Ljava/util/List; + public final fun getClosestRichSpan (Landroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getFullSpanStyle ()Landroidx/compose/ui/text/SpanStyle; + public final fun getFullStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; + public final fun getParagraph ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; + public final fun getParent ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getRichSpanByTextIndex (IIZ)Lkotlin/Pair; + public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;IIZILjava/lang/Object;)Lkotlin/Pair; + public final fun getRichSpanListByTextRange-72CqOWE (JI)Lkotlin/Pair; + public static synthetic fun getRichSpanListByTextRange-72CqOWE$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;JIILjava/lang/Object;)Lkotlin/Pair; + public final fun getRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; + public final fun getSpanStyle ()Landroidx/compose/ui/text/SpanStyle; + public final fun getText ()Ljava/lang/String; + public final fun getTextRange-d9O1mEE ()J + public final fun isBlank ()Z + public final fun isEmpty ()Z + public final fun isFirstInParagraph ()Z + public final fun isLastInParagraph ()Z + public final fun remove ()V + public final fun removeEmptyChildren ()V + public final fun removeTextRange-72CqOWE (JI)Lkotlin/Pair; + public final fun setParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V + public final fun setParent (Lcom/mohamedrejeb/richeditor/model/RichSpan;)V + public final fun setRichSpanStyle (Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)V + public final fun setSpanStyle (Landroidx/compose/ui/text/SpanStyle;)V + public final fun setText (Ljava/lang/String;)V + public final fun setTextRange-5zc-tL8 (J)V + public fun toString ()Ljava/lang/String; + public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V +} + public abstract interface class com/mohamedrejeb/richeditor/model/RichSpanStyle { public static final field Companion Lcom/mohamedrejeb/richeditor/model/RichSpanStyle$Companion; public abstract fun appendCustomContent (Landroidx/compose/ui/text/AnnotatedString$Builder;Lcom/mohamedrejeb/richeditor/model/RichTextState;)Landroidx/compose/ui/text/AnnotatedString$Builder; @@ -150,11 +189,13 @@ public final class com/mohamedrejeb/richeditor/model/RichTextState { public final fun getCurrentRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getCurrentSpanStyle ()Landroidx/compose/ui/text/SpanStyle; public final fun getParagraphStyle-5zc-tL8 (J)Landroidx/compose/ui/text/ParagraphStyle; + public final fun getRichSpanByOffset-k-4lQ0M (J)Lcom/mohamedrejeb/richeditor/model/RichSpan; public final fun getRichSpanStyle-5zc-tL8 (J)Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getSelectedLinkText ()Ljava/lang/String; public final fun getSelectedLinkUrl ()Ljava/lang/String; public final fun getSelection-d9O1mEE ()J public final fun getSpanStyle-5zc-tL8 (J)Landroidx/compose/ui/text/SpanStyle; + public final fun getTextLayoutResult ()Landroidx/compose/ui/text/TextLayoutResult; public final fun isCode ()Z public final fun isCodeSpan ()Z public final fun isLink ()Z @@ -218,6 +259,52 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { public fun toString ()Ljava/lang/String; } +public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph { + public static final field $stable I + public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion; + public fun ()V + public fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)V + public synthetic fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; + public final fun getFirstNonEmptyChild (I)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public static synthetic fun getFirstNonEmptyChild$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getRichSpanByTextIndex (IIIZ)Lkotlin/Pair; + public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IIIZILjava/lang/Object;)Lkotlin/Pair; + public final fun getRichSpanListByTextRange-Sb-Bc2M (IJI)Lkotlin/Pair; + public static synthetic fun getRichSpanListByTextRange-Sb-Bc2M$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IJIILjava/lang/Object;)Lkotlin/Pair; + public final fun isBlank (Z)Z + public static synthetic fun isBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun isEmpty (Z)Z + public static synthetic fun isEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun isNotBlank (Z)Z + public static synthetic fun isNotBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun isNotEmpty (Z)Z + public static synthetic fun isNotEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun removeEmptyChildren ()V + public final fun removeTextRange-72CqOWE (JI)Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; + public fun toString ()Ljava/lang/String; + public final fun trim ()V + public final fun trimEnd ()Z + public final fun trimStart ()Z + public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V +} + +public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion { + public final fun getDefaultParagraphStyle ()Landroidx/compose/ui/text/ParagraphStyle; +} + +public abstract interface class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType { + public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion; + public abstract fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; + public abstract fun getNextParagraphType ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; + public abstract fun getStartRichSpan ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public abstract fun getStyle (Lcom/mohamedrejeb/richeditor/model/RichTextConfig;)Landroidx/compose/ui/text/ParagraphStyle; +} + +public final class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion { + public final fun getStartText (Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)Ljava/lang/String; +} + public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V @@ -284,7 +371,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILandroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { diff --git a/richeditor-compose/api/desktop/richeditor-compose.api b/richeditor-compose/api/desktop/richeditor-compose.api index a4c017d5..7505888f 100644 --- a/richeditor-compose/api/desktop/richeditor-compose.api +++ b/richeditor-compose/api/desktop/richeditor-compose.api @@ -29,6 +29,45 @@ public final class com/mohamedrejeb/richeditor/model/ImageLoaderKt { public static final fun getLocalImageLoader ()Landroidx/compose/runtime/ProvidableCompositionLocal; } +public final class com/mohamedrejeb/richeditor/model/RichSpan { + public static final field $stable I + public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public static synthetic fun copy$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getAfter ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getBefore ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getChildren ()Ljava/util/List; + public final fun getClosestRichSpan (Landroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getFullSpanStyle ()Landroidx/compose/ui/text/SpanStyle; + public final fun getFullStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; + public final fun getParagraph ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; + public final fun getParent ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getRichSpanByTextIndex (IIZ)Lkotlin/Pair; + public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;IIZILjava/lang/Object;)Lkotlin/Pair; + public final fun getRichSpanListByTextRange-72CqOWE (JI)Lkotlin/Pair; + public static synthetic fun getRichSpanListByTextRange-72CqOWE$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;JIILjava/lang/Object;)Lkotlin/Pair; + public final fun getRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; + public final fun getSpanStyle ()Landroidx/compose/ui/text/SpanStyle; + public final fun getText ()Ljava/lang/String; + public final fun getTextRange-d9O1mEE ()J + public final fun isBlank ()Z + public final fun isEmpty ()Z + public final fun isFirstInParagraph ()Z + public final fun isLastInParagraph ()Z + public final fun remove ()V + public final fun removeEmptyChildren ()V + public final fun removeTextRange-72CqOWE (JI)Lkotlin/Pair; + public final fun setParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V + public final fun setParent (Lcom/mohamedrejeb/richeditor/model/RichSpan;)V + public final fun setRichSpanStyle (Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)V + public final fun setSpanStyle (Landroidx/compose/ui/text/SpanStyle;)V + public final fun setText (Ljava/lang/String;)V + public final fun setTextRange-5zc-tL8 (J)V + public fun toString ()Ljava/lang/String; + public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V +} + public abstract interface class com/mohamedrejeb/richeditor/model/RichSpanStyle { public static final field Companion Lcom/mohamedrejeb/richeditor/model/RichSpanStyle$Companion; public abstract fun appendCustomContent (Landroidx/compose/ui/text/AnnotatedString$Builder;Lcom/mohamedrejeb/richeditor/model/RichTextState;)Landroidx/compose/ui/text/AnnotatedString$Builder; @@ -150,11 +189,13 @@ public final class com/mohamedrejeb/richeditor/model/RichTextState { public final fun getCurrentRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getCurrentSpanStyle ()Landroidx/compose/ui/text/SpanStyle; public final fun getParagraphStyle-5zc-tL8 (J)Landroidx/compose/ui/text/ParagraphStyle; + public final fun getRichSpanByOffset-k-4lQ0M (J)Lcom/mohamedrejeb/richeditor/model/RichSpan; public final fun getRichSpanStyle-5zc-tL8 (J)Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getSelectedLinkText ()Ljava/lang/String; public final fun getSelectedLinkUrl ()Ljava/lang/String; public final fun getSelection-d9O1mEE ()J public final fun getSpanStyle-5zc-tL8 (J)Landroidx/compose/ui/text/SpanStyle; + public final fun getTextLayoutResult ()Landroidx/compose/ui/text/TextLayoutResult; public final fun isCode ()Z public final fun isCodeSpan ()Z public final fun isLink ()Z @@ -218,6 +259,52 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { public fun toString ()Ljava/lang/String; } +public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph { + public static final field $stable I + public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion; + public fun ()V + public fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)V + public synthetic fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public final fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; + public final fun getFirstNonEmptyChild (I)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public static synthetic fun getFirstNonEmptyChild$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; + public final fun getRichSpanByTextIndex (IIIZ)Lkotlin/Pair; + public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IIIZILjava/lang/Object;)Lkotlin/Pair; + public final fun getRichSpanListByTextRange-Sb-Bc2M (IJI)Lkotlin/Pair; + public static synthetic fun getRichSpanListByTextRange-Sb-Bc2M$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IJIILjava/lang/Object;)Lkotlin/Pair; + public final fun isBlank (Z)Z + public static synthetic fun isBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun isEmpty (Z)Z + public static synthetic fun isEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun isNotBlank (Z)Z + public static synthetic fun isNotBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun isNotEmpty (Z)Z + public static synthetic fun isNotEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z + public final fun removeEmptyChildren ()V + public final fun removeTextRange-72CqOWE (JI)Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; + public fun toString ()Ljava/lang/String; + public final fun trim ()V + public final fun trimEnd ()Z + public final fun trimStart ()Z + public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V +} + +public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion { + public final fun getDefaultParagraphStyle ()Landroidx/compose/ui/text/ParagraphStyle; +} + +public abstract interface class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType { + public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion; + public abstract fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; + public abstract fun getNextParagraphType ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; + public abstract fun getStartRichSpan ()Lcom/mohamedrejeb/richeditor/model/RichSpan; + public abstract fun getStyle (Lcom/mohamedrejeb/richeditor/model/RichTextConfig;)Landroidx/compose/ui/text/ParagraphStyle; +} + +public final class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion { + public final fun getStartText (Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)Ljava/lang/String; +} + public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V @@ -284,7 +371,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILandroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { From 2e3ec692e6edf9281c17b8c6aab2521e478fd4f5 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 13 Nov 2024 19:01:38 -0800 Subject: [PATCH 09/26] Add click position to RichSpanClickListener --- .../com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 2f1e1c2e..ebcd5a59 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -232,7 +232,7 @@ public fun BasicRichTextEditor( interactionSource.interactions.collect { interaction -> if (interaction is PressInteraction.Press) { state.getRichSpanByOffset(interaction.pressPosition)?.let { clickedSpan -> - onRichSpanClick(clickedSpan) + onRichSpanClick(clickedSpan, interaction.pressPosition) } } } @@ -347,4 +347,4 @@ internal suspend fun adjustTextIndicatorOffset( } public typealias RichTextChangedListener = (RichTextState) -> Unit -public typealias RichSpanClickListener = (RichSpan) -> Unit +public typealias RichSpanClickListener = (RichSpan, Offset) -> Unit From 8fff367a5959a81b4135121d6863709abbd56001 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 13 Nov 2024 22:11:31 -0800 Subject: [PATCH 10/26] API --- .../api/android/richeditor-compose.api | 12 ++++++------ .../api/desktop/richeditor-compose.api | 12 ++++++------ .../sample/common/richeditor/RichEditorContent.kt | 5 +++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/richeditor-compose/api/android/richeditor-compose.api b/richeditor-compose/api/android/richeditor-compose.api index 6f0ed139..42ff05e3 100644 --- a/richeditor-compose/api/android/richeditor-compose.api +++ b/richeditor-compose/api/android/richeditor-compose.api @@ -306,8 +306,8 @@ public final class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Comp } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -324,11 +324,11 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich } public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -336,7 +336,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { @@ -371,7 +371,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { diff --git a/richeditor-compose/api/desktop/richeditor-compose.api b/richeditor-compose/api/desktop/richeditor-compose.api index 7505888f..a304f793 100644 --- a/richeditor-compose/api/desktop/richeditor-compose.api +++ b/richeditor-compose/api/desktop/richeditor-compose.api @@ -306,8 +306,8 @@ public final class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Comp } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -324,11 +324,11 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich } public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -336,7 +336,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { @@ -371,7 +371,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index b456ef5e..bcbb608f 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -109,7 +109,7 @@ fun RichEditorContent() { BasicRichTextEditor( modifier = Modifier.fillMaxWidth(), state = basicRichTextState, - onRichSpanClick = { span -> + onRichSpanClick = { span, offset -> println("clicked") if (span.richSpanStyle is SpellCheck) { println("Spell check clicked") @@ -117,7 +117,8 @@ fun RichEditorContent() { basicRichTextState.textLayoutResult ?.multiParagraph ?.getBoundingBox(span.textRange.start) - println("Position: ${position}") + println("Position: $position") + println("Offset: $offset") spellCheckExpanded = position } } From 90dfde098ace3a421252eb82236089a49b9b6838 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 21 Nov 2024 19:09:52 -0800 Subject: [PATCH 11/26] Refactored so we dont need to expose things --- .../api/android/richeditor-compose.api | 99 ++----------------- .../api/desktop/richeditor-compose.api | 99 ++----------------- .../mohamedrejeb/richeditor/model/RichSpan.kt | 48 ++++----- .../richeditor/model/RichTextState.kt | 40 ++++---- .../richeditor/paragraph/RichParagraph.kt | 40 ++++---- .../paragraph/type/ParagraphType.kt | 12 +-- .../richeditor/ui/BasicRichTextEditor.kt | 7 +- .../common/richeditor/RichEditorContent.kt | 48 +++------ 8 files changed, 97 insertions(+), 296 deletions(-) diff --git a/richeditor-compose/api/android/richeditor-compose.api b/richeditor-compose/api/android/richeditor-compose.api index 42ff05e3..dd7e5999 100644 --- a/richeditor-compose/api/android/richeditor-compose.api +++ b/richeditor-compose/api/android/richeditor-compose.api @@ -29,45 +29,6 @@ public final class com/mohamedrejeb/richeditor/model/ImageLoaderKt { public static final fun getLocalImageLoader ()Landroidx/compose/runtime/ProvidableCompositionLocal; } -public final class com/mohamedrejeb/richeditor/model/RichSpan { - public static final field $stable I - public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun copy (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public static synthetic fun copy$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getAfter ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getBefore ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getChildren ()Ljava/util/List; - public final fun getClosestRichSpan (Landroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getFullSpanStyle ()Landroidx/compose/ui/text/SpanStyle; - public final fun getFullStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; - public final fun getParagraph ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; - public final fun getParent ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getRichSpanByTextIndex (IIZ)Lkotlin/Pair; - public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;IIZILjava/lang/Object;)Lkotlin/Pair; - public final fun getRichSpanListByTextRange-72CqOWE (JI)Lkotlin/Pair; - public static synthetic fun getRichSpanListByTextRange-72CqOWE$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;JIILjava/lang/Object;)Lkotlin/Pair; - public final fun getRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; - public final fun getSpanStyle ()Landroidx/compose/ui/text/SpanStyle; - public final fun getText ()Ljava/lang/String; - public final fun getTextRange-d9O1mEE ()J - public final fun isBlank ()Z - public final fun isEmpty ()Z - public final fun isFirstInParagraph ()Z - public final fun isLastInParagraph ()Z - public final fun remove ()V - public final fun removeEmptyChildren ()V - public final fun removeTextRange-72CqOWE (JI)Lkotlin/Pair; - public final fun setParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V - public final fun setParent (Lcom/mohamedrejeb/richeditor/model/RichSpan;)V - public final fun setRichSpanStyle (Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)V - public final fun setSpanStyle (Landroidx/compose/ui/text/SpanStyle;)V - public final fun setText (Ljava/lang/String;)V - public final fun setTextRange-5zc-tL8 (J)V - public fun toString ()Ljava/lang/String; - public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V -} - public abstract interface class com/mohamedrejeb/richeditor/model/RichSpanStyle { public static final field Companion Lcom/mohamedrejeb/richeditor/model/RichSpanStyle$Companion; public abstract fun appendCustomContent (Landroidx/compose/ui/text/AnnotatedString$Builder;Lcom/mohamedrejeb/richeditor/model/RichTextState;)Landroidx/compose/ui/text/AnnotatedString$Builder; @@ -189,13 +150,11 @@ public final class com/mohamedrejeb/richeditor/model/RichTextState { public final fun getCurrentRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getCurrentSpanStyle ()Landroidx/compose/ui/text/SpanStyle; public final fun getParagraphStyle-5zc-tL8 (J)Landroidx/compose/ui/text/ParagraphStyle; - public final fun getRichSpanByOffset-k-4lQ0M (J)Lcom/mohamedrejeb/richeditor/model/RichSpan; public final fun getRichSpanStyle-5zc-tL8 (J)Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getSelectedLinkText ()Ljava/lang/String; public final fun getSelectedLinkUrl ()Ljava/lang/String; public final fun getSelection-d9O1mEE ()J public final fun getSpanStyle-5zc-tL8 (J)Landroidx/compose/ui/text/SpanStyle; - public final fun getTextLayoutResult ()Landroidx/compose/ui/text/TextLayoutResult; public final fun isCode ()Z public final fun isCodeSpan ()Z public final fun isLink ()Z @@ -259,55 +218,9 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { public fun toString ()Ljava/lang/String; } -public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph { - public static final field $stable I - public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion; - public fun ()V - public fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)V - public synthetic fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; - public final fun getFirstNonEmptyChild (I)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public static synthetic fun getFirstNonEmptyChild$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getRichSpanByTextIndex (IIIZ)Lkotlin/Pair; - public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IIIZILjava/lang/Object;)Lkotlin/Pair; - public final fun getRichSpanListByTextRange-Sb-Bc2M (IJI)Lkotlin/Pair; - public static synthetic fun getRichSpanListByTextRange-Sb-Bc2M$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IJIILjava/lang/Object;)Lkotlin/Pair; - public final fun isBlank (Z)Z - public static synthetic fun isBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun isEmpty (Z)Z - public static synthetic fun isEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun isNotBlank (Z)Z - public static synthetic fun isNotBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun isNotEmpty (Z)Z - public static synthetic fun isNotEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun removeEmptyChildren ()V - public final fun removeTextRange-72CqOWE (JI)Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; - public fun toString ()Ljava/lang/String; - public final fun trim ()V - public final fun trimEnd ()Z - public final fun trimStart ()Z - public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V -} - -public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion { - public final fun getDefaultParagraphStyle ()Landroidx/compose/ui/text/ParagraphStyle; -} - -public abstract interface class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType { - public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion; - public abstract fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; - public abstract fun getNextParagraphType ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; - public abstract fun getStartRichSpan ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public abstract fun getStyle (Lcom/mohamedrejeb/richeditor/model/RichTextConfig;)Landroidx/compose/ui/text/ParagraphStyle; -} - -public final class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion { - public final fun getStartText (Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)Ljava/lang/String; -} - public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -324,11 +237,11 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich } public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -336,7 +249,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { @@ -371,7 +284,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { diff --git a/richeditor-compose/api/desktop/richeditor-compose.api b/richeditor-compose/api/desktop/richeditor-compose.api index a304f793..305130f8 100644 --- a/richeditor-compose/api/desktop/richeditor-compose.api +++ b/richeditor-compose/api/desktop/richeditor-compose.api @@ -29,45 +29,6 @@ public final class com/mohamedrejeb/richeditor/model/ImageLoaderKt { public static final fun getLocalImageLoader ()Landroidx/compose/runtime/ProvidableCompositionLocal; } -public final class com/mohamedrejeb/richeditor/model/RichSpan { - public static final field $stable I - public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public synthetic fun (Ljava/lang/Integer;Ljava/util/List;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;Lcom/mohamedrejeb/richeditor/model/RichSpan;Ljava/lang/String;JLandroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;Lkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun copy (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public static synthetic fun copy$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getAfter ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getBefore ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getChildren ()Ljava/util/List; - public final fun getClosestRichSpan (Landroidx/compose/ui/text/SpanStyle;Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getFullSpanStyle ()Landroidx/compose/ui/text/SpanStyle; - public final fun getFullStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; - public final fun getParagraph ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; - public final fun getParent ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getRichSpanByTextIndex (IIZ)Lkotlin/Pair; - public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;IIZILjava/lang/Object;)Lkotlin/Pair; - public final fun getRichSpanListByTextRange-72CqOWE (JI)Lkotlin/Pair; - public static synthetic fun getRichSpanListByTextRange-72CqOWE$default (Lcom/mohamedrejeb/richeditor/model/RichSpan;JIILjava/lang/Object;)Lkotlin/Pair; - public final fun getRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; - public final fun getSpanStyle ()Landroidx/compose/ui/text/SpanStyle; - public final fun getText ()Ljava/lang/String; - public final fun getTextRange-d9O1mEE ()J - public final fun isBlank ()Z - public final fun isEmpty ()Z - public final fun isFirstInParagraph ()Z - public final fun isLastInParagraph ()Z - public final fun remove ()V - public final fun removeEmptyChildren ()V - public final fun removeTextRange-72CqOWE (JI)Lkotlin/Pair; - public final fun setParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V - public final fun setParent (Lcom/mohamedrejeb/richeditor/model/RichSpan;)V - public final fun setRichSpanStyle (Lcom/mohamedrejeb/richeditor/model/RichSpanStyle;)V - public final fun setSpanStyle (Landroidx/compose/ui/text/SpanStyle;)V - public final fun setText (Ljava/lang/String;)V - public final fun setTextRange-5zc-tL8 (J)V - public fun toString ()Ljava/lang/String; - public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V -} - public abstract interface class com/mohamedrejeb/richeditor/model/RichSpanStyle { public static final field Companion Lcom/mohamedrejeb/richeditor/model/RichSpanStyle$Companion; public abstract fun appendCustomContent (Landroidx/compose/ui/text/AnnotatedString$Builder;Lcom/mohamedrejeb/richeditor/model/RichTextState;)Landroidx/compose/ui/text/AnnotatedString$Builder; @@ -189,13 +150,11 @@ public final class com/mohamedrejeb/richeditor/model/RichTextState { public final fun getCurrentRichSpanStyle ()Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getCurrentSpanStyle ()Landroidx/compose/ui/text/SpanStyle; public final fun getParagraphStyle-5zc-tL8 (J)Landroidx/compose/ui/text/ParagraphStyle; - public final fun getRichSpanByOffset-k-4lQ0M (J)Lcom/mohamedrejeb/richeditor/model/RichSpan; public final fun getRichSpanStyle-5zc-tL8 (J)Lcom/mohamedrejeb/richeditor/model/RichSpanStyle; public final fun getSelectedLinkText ()Ljava/lang/String; public final fun getSelectedLinkUrl ()Ljava/lang/String; public final fun getSelection-d9O1mEE ()J public final fun getSpanStyle-5zc-tL8 (J)Landroidx/compose/ui/text/SpanStyle; - public final fun getTextLayoutResult ()Landroidx/compose/ui/text/TextLayoutResult; public final fun isCode ()Z public final fun isCodeSpan ()Z public final fun isLink ()Z @@ -259,55 +218,9 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { public fun toString ()Ljava/lang/String; } -public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph { - public static final field $stable I - public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion; - public fun ()V - public fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)V - public synthetic fun (ILjava/util/List;Landroidx/compose/ui/text/ParagraphStyle;Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;ILkotlin/jvm/internal/DefaultConstructorMarker;)V - public final fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; - public final fun getFirstNonEmptyChild (I)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public static synthetic fun getFirstNonEmptyChild$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IILjava/lang/Object;)Lcom/mohamedrejeb/richeditor/model/RichSpan; - public final fun getRichSpanByTextIndex (IIIZ)Lkotlin/Pair; - public static synthetic fun getRichSpanByTextIndex$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IIIZILjava/lang/Object;)Lkotlin/Pair; - public final fun getRichSpanListByTextRange-Sb-Bc2M (IJI)Lkotlin/Pair; - public static synthetic fun getRichSpanListByTextRange-Sb-Bc2M$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;IJIILjava/lang/Object;)Lkotlin/Pair; - public final fun isBlank (Z)Z - public static synthetic fun isBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun isEmpty (Z)Z - public static synthetic fun isEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun isNotBlank (Z)Z - public static synthetic fun isNotBlank$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun isNotEmpty (Z)Z - public static synthetic fun isNotEmpty$default (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;ZILjava/lang/Object;)Z - public final fun removeEmptyChildren ()V - public final fun removeTextRange-72CqOWE (JI)Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph; - public fun toString ()Ljava/lang/String; - public final fun trim ()V - public final fun trimEnd ()Z - public final fun trimStart ()Z - public final fun updateChildrenParagraph (Lcom/mohamedrejeb/richeditor/paragraph/RichParagraph;)V -} - -public final class com/mohamedrejeb/richeditor/paragraph/RichParagraph$Companion { - public final fun getDefaultParagraphStyle ()Landroidx/compose/ui/text/ParagraphStyle; -} - -public abstract interface class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType { - public static final field Companion Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion; - public abstract fun copy ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; - public abstract fun getNextParagraphType ()Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType; - public abstract fun getStartRichSpan ()Lcom/mohamedrejeb/richeditor/model/RichSpan; - public abstract fun getStyle (Lcom/mohamedrejeb/richeditor/model/RichTextConfig;)Landroidx/compose/ui/text/ParagraphStyle; -} - -public final class com/mohamedrejeb/richeditor/paragraph/type/ParagraphType$Companion { - public final fun getStartText (Lcom/mohamedrejeb/richeditor/paragraph/type/ParagraphType;)Ljava/lang/String; -} - public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -324,11 +237,11 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich } public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -336,7 +249,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { @@ -371,7 +284,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function2;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt index f596dcc5..b1f89693 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt @@ -13,15 +13,15 @@ import com.mohamedrejeb.richeditor.utils.isSpecifiedFieldsEquals /** * A rich span is a part of a rich paragraph. */ -public class RichSpan( +internal class RichSpan( internal val key: Int? = null, - public val children: MutableList = mutableListOf(), - public var paragraph: RichParagraph, - public var parent: RichSpan? = null, - public var text: String = "", - public var textRange: TextRange = TextRange(start = 0, end = 0), - public var spanStyle: SpanStyle = SpanStyle(), - public var richSpanStyle: RichSpanStyle = RichSpanStyle.Default, + val children: MutableList = mutableListOf(), + var paragraph: RichParagraph, + var parent: RichSpan? = null, + var text: String = "", + var textRange: TextRange = TextRange(start = 0, end = 0), + var spanStyle: SpanStyle = SpanStyle(), + var richSpanStyle: RichSpanStyle = RichSpanStyle.Default, ) { /** * Return the full text range of the rich span. @@ -49,7 +49,7 @@ public class RichSpan( * * @return The full span style of the rich span */ - public val fullSpanStyle: SpanStyle get() { + val fullSpanStyle: SpanStyle get() { var spanStyle = this.spanStyle var parent = this.parent @@ -61,7 +61,7 @@ public class RichSpan( return spanStyle } - public val fullStyle: RichSpanStyle get() { + val fullStyle: RichSpanStyle get() { var style = this.richSpanStyle var parent = this.parent @@ -73,7 +73,7 @@ public class RichSpan( return style } - public val before: RichSpan? get() { + val before: RichSpan? get() { val parentChildren = parent?.children ?: paragraph.children val index = parentChildren.indexOf(this) @@ -95,7 +95,7 @@ public class RichSpan( * * @return The next rich span or null if the rich span is the last in the paragraph */ - public val after: RichSpan? get() { + val after: RichSpan? get() { if (children.isNotEmpty()) return children.first() @@ -132,7 +132,7 @@ public class RichSpan( * * @return True if the rich span is the first in the paragraph, false otherwise */ - public val isFirstInParagraph: Boolean get() { + val isFirstInParagraph: Boolean get() { var current: RichSpan var parent: RichSpan = this @@ -151,7 +151,7 @@ public class RichSpan( * * @return True if the rich span is the last in the paragraph, false otherwise */ - public val isLastInParagraph: Boolean get() { + val isLastInParagraph: Boolean get() { var current: RichSpan var parent: RichSpan = this @@ -173,7 +173,7 @@ public class RichSpan( * * @return True if the rich span is empty, false otherwise */ - public fun isEmpty(): Boolean = text.isEmpty() && isChildrenEmpty() && richSpanStyle !is RichSpanStyle.Image + fun isEmpty(): Boolean = text.isEmpty() && isChildrenEmpty() && richSpanStyle !is RichSpanStyle.Image /** * Check if the rich span is blank. @@ -181,7 +181,7 @@ public class RichSpan( * * @return True if the rich span is blank, false otherwise */ - public fun isBlank(): Boolean = text.isBlank() && isChildrenBlank() && richSpanStyle !is RichSpanStyle.Image + fun isBlank(): Boolean = text.isBlank() && isChildrenBlank() && richSpanStyle !is RichSpanStyle.Image /** * Check if the rich span children are empty @@ -346,7 +346,7 @@ public class RichSpan( * @return A pair of the offset and the rich span or null if the rich span is not found */ @OptIn(ExperimentalRichTextApi::class) - public fun getRichSpanByTextIndex( + fun getRichSpanByTextIndex( textIndex: Int, offset: Int = 0, ignoreCustomFiltering: Boolean = false @@ -400,7 +400,7 @@ public class RichSpan( * @param offset The offset of the text range * @return The rich span list */ - public fun getRichSpanListByTextRange( + fun getRichSpanListByTextRange( searchTextRange: TextRange, offset: Int = 0, ): Pair> { @@ -431,7 +431,7 @@ public class RichSpan( /** * Removes the current rich span from its parent and clears its text. */ - public fun remove() { + fun remove() { text = "" parent?.children?.remove(this) } @@ -442,7 +442,7 @@ public class RichSpan( * @param removeTextRange The text range to remove * @return The rich span with the removed text range or null if the rich span is empty */ - public fun removeTextRange( + fun removeTextRange( removeTextRange: TextRange, offset: Int, ): Pair { @@ -509,7 +509,7 @@ public class RichSpan( * @param spanStyle The span style * @return The closest parent rich span or null if not found */ - public fun getClosestRichSpan(spanStyle: SpanStyle, newRichSpanStyle: RichSpanStyle): RichSpan? { + fun getClosestRichSpan(spanStyle: SpanStyle, newRichSpanStyle: RichSpanStyle): RichSpan? { if ( spanStyle.isSpecifiedFieldsEquals(this.fullSpanStyle, strict = true) && newRichSpanStyle::class == richSpanStyle::class @@ -523,14 +523,14 @@ public class RichSpan( * * @param newParagraph The new paragraph */ - public fun updateChildrenParagraph(newParagraph: RichParagraph) { + fun updateChildrenParagraph(newParagraph: RichParagraph) { children.fastForEach { childRichSpan -> childRichSpan.paragraph = newParagraph childRichSpan.updateChildrenParagraph(newParagraph) } } - public fun removeEmptyChildren() { + fun removeEmptyChildren() { val toRemoveIndices = mutableListOf() children.fastForEachIndexed { i, richSpan -> @@ -545,7 +545,7 @@ public class RichSpan( } } - public fun copy( + fun copy( newParagraph: RichParagraph = paragraph, ): RichSpan { val newSpan = RichSpan( diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index 50060f13..f235032d 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -76,7 +76,7 @@ public class RichTextState internal constructor( internal var singleParagraphMode by mutableStateOf(false) - public var textLayoutResult: TextLayoutResult? by mutableStateOf(null) + internal var textLayoutResult: TextLayoutResult? by mutableStateOf(null) private set private var lastPressPosition: Offset? by mutableStateOf(null) @@ -1743,24 +1743,24 @@ public class RichTextState internal constructor( // If the new paragraph is empty apply style depending on the config if (tempTextFieldValue.selection.collapsed && newParagraph.isEmpty()) { - val newParagraphFirstRichSpan = newParagraph.getFirstNonEmptyChild() - - val isSelectionAtNewRichSpan = - newParagraphFirstRichSpan?.textRange?.min == tempTextFieldValue.selection.min - 1 - - // Check if the cursor is at the new paragraph - if ( - (!config.preserveStyleOnEmptyLine || richSpan.paragraph.isEmpty()) && - isSelectionAtNewRichSpan - ) { - newParagraphFirstRichSpan.spanStyle = SpanStyle() - newParagraphFirstRichSpan.richSpanStyle = RichSpanStyle.Default - } else if ( - config.preserveStyleOnEmptyLine && - isSelectionAtNewRichSpan - ) { - newParagraphFirstRichSpan.spanStyle = currentSpanStyle - newParagraphFirstRichSpan.richSpanStyle = currentRichSpanStyle + newParagraph.getFirstNonEmptyChild()?.let { newParagraphFirstRichSpan -> + val isSelectionAtNewRichSpan = + newParagraphFirstRichSpan.textRange.min == tempTextFieldValue.selection.min - 1 + + // Check if the cursor is at the new paragraph + if ( + (!config.preserveStyleOnEmptyLine || richSpan.paragraph.isEmpty()) && + isSelectionAtNewRichSpan + ) { + newParagraphFirstRichSpan.spanStyle = SpanStyle() + newParagraphFirstRichSpan.richSpanStyle = RichSpanStyle.Default + } else if ( + config.preserveStyleOnEmptyLine && + isSelectionAtNewRichSpan + ) { + newParagraphFirstRichSpan.spanStyle = currentSpanStyle + newParagraphFirstRichSpan.richSpanStyle = currentRichSpanStyle + } } } @@ -2731,7 +2731,7 @@ public class RichTextState internal constructor( return richSpan } - public fun getRichSpanByOffset(offset: Offset): RichSpan? { + internal fun getRichSpanByOffset(offset: Offset): RichSpan? { this.textLayoutResult?.let { textLayoutResult -> val position = textLayoutResult.getOffsetForPosition(offset) return getRichSpanByTextIndex(position, true) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt index 29837fed..088e42cf 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/RichParagraph.kt @@ -12,15 +12,15 @@ import com.mohamedrejeb.richeditor.paragraph.type.ParagraphType import com.mohamedrejeb.richeditor.paragraph.type.ParagraphType.Companion.startText import com.mohamedrejeb.richeditor.ui.test.getRichTextStyleTreeRepresentation -public class RichParagraph( - internal val key: Int = 0, - internal val children: MutableList = mutableListOf(), - internal var paragraphStyle: ParagraphStyle = DefaultParagraphStyle, - internal var type: ParagraphType = DefaultParagraph(), +internal class RichParagraph( + val key: Int = 0, + val children: MutableList = mutableListOf(), + var paragraphStyle: ParagraphStyle = DefaultParagraphStyle, + var type: ParagraphType = DefaultParagraph(), ) { @OptIn(ExperimentalRichTextApi::class) - public fun getRichSpanByTextIndex( + fun getRichSpanByTextIndex( paragraphIndex: Int, textIndex: Int, offset: Int = 0, @@ -72,7 +72,7 @@ public class RichParagraph( } @OptIn(ExperimentalRichTextApi::class) - public fun getRichSpanListByTextRange( + fun getRichSpanListByTextRange( paragraphIndex: Int, searchTextRange: TextRange, offset: Int = 0, @@ -109,7 +109,7 @@ public class RichParagraph( return index to richSpanList } - public fun removeTextRange( + fun removeTextRange( textRange: TextRange, offset: Int, ): RichParagraph? { @@ -163,9 +163,9 @@ public class RichParagraph( return true } - public fun isNotEmpty(ignoreStartRichSpan: Boolean = true): Boolean = !isEmpty(ignoreStartRichSpan) + fun isNotEmpty(ignoreStartRichSpan: Boolean = true): Boolean = !isEmpty(ignoreStartRichSpan) - public fun isBlank(ignoreStartRichSpan: Boolean = true): Boolean { + fun isBlank(ignoreStartRichSpan: Boolean = true): Boolean { if (!ignoreStartRichSpan && !type.startRichSpan.isBlank()) return false if (children.isEmpty()) return true @@ -175,9 +175,9 @@ public class RichParagraph( return true } - public fun isNotBlank(ignoreStartRichSpan: Boolean = true): Boolean = !isBlank(ignoreStartRichSpan) + fun isNotBlank(ignoreStartRichSpan: Boolean = true): Boolean = !isBlank(ignoreStartRichSpan) - public fun getFirstNonEmptyChild(offset: Int = -1): RichSpan? { + fun getFirstNonEmptyChild(offset: Int = -1): RichSpan? { children.fastForEach { richSpan -> if (richSpan.text.isNotEmpty()) { if (offset != -1) @@ -211,7 +211,7 @@ public class RichParagraph( /** * Trim the rich paragraph */ - public fun trim() { + fun trim() { val isEmpty = trimStart() if (!isEmpty) trimEnd() @@ -222,7 +222,7 @@ public class RichParagraph( * * @return True if the rich paragraph is empty after trimming, false otherwise */ - public fun trimStart(): Boolean { + fun trimStart(): Boolean { children.fastForEach { richSpan -> val isEmpty = richSpan.trimStart() @@ -238,7 +238,7 @@ public class RichParagraph( * * @return True if the rich paragraph is empty after trimming, false otherwise */ - public fun trimEnd(): Boolean { + fun trimEnd(): Boolean { children.fastForEachReversed { richSpan -> val isEmpty = richSpan.trimEnd() @@ -254,14 +254,14 @@ public class RichParagraph( * * @param newParagraph The new paragraph */ - public fun updateChildrenParagraph(newParagraph: RichParagraph) { + fun updateChildrenParagraph(newParagraph: RichParagraph) { children.fastForEach { childRichSpan -> childRichSpan.paragraph = newParagraph childRichSpan.updateChildrenParagraph(newParagraph) } } - public fun removeEmptyChildren() { + fun removeEmptyChildren() { val toRemoveIndices = mutableListOf() children.fastForEachIndexed { index, richSpan -> @@ -276,7 +276,7 @@ public class RichParagraph( } } - public fun copy(): RichParagraph { + fun copy(): RichParagraph { val newParagraph = RichParagraph( paragraphStyle = paragraphStyle, type = type.copy(), @@ -299,7 +299,7 @@ public class RichParagraph( return stringBuilder.toString() } - public companion object { - public val DefaultParagraphStyle: ParagraphStyle = ParagraphStyle() + companion object { + val DefaultParagraphStyle = ParagraphStyle() } } \ No newline at end of file diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt index f21da66f..060f9a9c 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt @@ -4,17 +4,17 @@ import androidx.compose.ui.text.ParagraphStyle import com.mohamedrejeb.richeditor.model.RichSpan import com.mohamedrejeb.richeditor.model.RichTextConfig -public interface ParagraphType { +internal interface ParagraphType { - public fun getStyle(config: RichTextConfig): ParagraphStyle + fun getStyle(config: RichTextConfig): ParagraphStyle - public val startRichSpan: RichSpan + val startRichSpan: RichSpan - public fun getNextParagraphType(): ParagraphType + fun getNextParagraphType(): ParagraphType - public fun copy(): ParagraphType + fun copy(): ParagraphType - public companion object { + companion object { public val ParagraphType.startText : String get() = startRichSpan.text } } \ No newline at end of file diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index ebcd5a59..6f0a3d21 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -24,12 +24,13 @@ import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.text.TextLayoutResult +import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.LayoutDirection -import com.mohamedrejeb.richeditor.model.RichSpan +import com.mohamedrejeb.richeditor.model.RichSpanStyle import com.mohamedrejeb.richeditor.model.RichTextState import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @@ -232,7 +233,7 @@ public fun BasicRichTextEditor( interactionSource.interactions.collect { interaction -> if (interaction is PressInteraction.Press) { state.getRichSpanByOffset(interaction.pressPosition)?.let { clickedSpan -> - onRichSpanClick(clickedSpan, interaction.pressPosition) + onRichSpanClick(clickedSpan.richSpanStyle, clickedSpan.textRange, interaction.pressPosition) } } } @@ -347,4 +348,4 @@ internal suspend fun adjustTextIndicatorOffset( } public typealias RichTextChangedListener = (RichTextState) -> Unit -public typealias RichSpanClickListener = (RichSpan, Offset) -> Unit +public typealias RichSpanClickListener = (RichSpanStyle, TextRange, Offset) -> Unit diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index bcbb608f..c34e2250 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -1,35 +1,13 @@ package com.mohamedrejeb.richeditor.sample.common.richeditor -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.ime -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.windowInsetsPadding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBar -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue +import androidx.compose.material3.* +import androidx.compose.runtime.* import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Rect +import androidx.compose.ui.geometry.Offset import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.dp import cafe.adriel.voyager.navigator.LocalNavigator @@ -104,22 +82,18 @@ fun RichEditorContent() { item { Box { - var spellCheckExpanded by remember { mutableStateOf(null) } + var spellCheckExpanded by remember { mutableStateOf(null) } BasicRichTextEditor( modifier = Modifier.fillMaxWidth(), state = basicRichTextState, - onRichSpanClick = { span, offset -> + onRichSpanClick = { span, range, offset -> println("clicked") - if (span.richSpanStyle is SpellCheck) { + if (span is SpellCheck) { println("Spell check clicked") - val position = - basicRichTextState.textLayoutResult - ?.multiParagraph - ?.getBoundingBox(span.textRange.start) - println("Position: $position") + println("Range: $range") println("Offset: $offset") - spellCheckExpanded = position + spellCheckExpanded = offset } } ) @@ -128,8 +102,8 @@ fun RichEditorContent() { expanded = spellCheckExpanded != null, onDismissRequest = { spellCheckExpanded = null }, offset = DpOffset( - x = spellCheckExpanded?.left?.dp ?: 0.dp, - y = spellCheckExpanded?.top?.dp ?: 0.dp, + x = spellCheckExpanded?.x?.dp ?: 0.dp, + y = spellCheckExpanded?.y?.dp ?: 0.dp, ), ) { DropdownMenuItem( From 13f2ce0d6158f14538a44da34d986f2eae2decae Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Sun, 24 Nov 2024 23:10:51 -0800 Subject: [PATCH 12/26] Add onRichSpanClick to Outline --- .../sample/common/richeditor/RichEditorContent.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index c34e2250..74d6a355 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -180,7 +180,15 @@ fun RichEditorContent() { state = outlinedRichTextState, onRichTextChangedListener = { println("Rich text changed!") - } + }, + onRichSpanClick = { span, range, offset -> + println("clicked") + if (span is SpellCheck) { + println("Spell check clicked") + println("Range: $range") + println("Offset: $offset") + } + }, ) } From 7314ee2fbc2e27400ef47c2aa702270dbd7e1352 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Sun, 24 Nov 2024 23:20:44 -0800 Subject: [PATCH 13/26] Correct touch position for contentPadding --- .../com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 6f0a3d21..353fa596 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -232,7 +232,11 @@ public fun BasicRichTextEditor( scope.launch { interactionSource.interactions.collect { interaction -> if (interaction is PressInteraction.Press) { - state.getRichSpanByOffset(interaction.pressPosition)?.let { clickedSpan -> + val topPadding = with(density) { contentPadding.calculateTopPadding().toPx() } + val startPadding = with(density) { contentPadding.calculateStartPadding(layoutDirection).toPx() } + val localPosition = interaction.pressPosition - Offset(x = startPadding, y = topPadding) + + state.getRichSpanByOffset(localPosition)?.let { clickedSpan -> onRichSpanClick(clickedSpan.richSpanStyle, clickedSpan.textRange, interaction.pressPosition) } } From ad1cf31930052c872fb2877643f6824fc8909415 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Sun, 24 Nov 2024 23:37:19 -0800 Subject: [PATCH 14/26] Will CI build this? --- .../richeditor/model/RichTextState.kt | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index f235032d..d8646221 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -1743,24 +1743,23 @@ public class RichTextState internal constructor( // If the new paragraph is empty apply style depending on the config if (tempTextFieldValue.selection.collapsed && newParagraph.isEmpty()) { - newParagraph.getFirstNonEmptyChild()?.let { newParagraphFirstRichSpan -> - val isSelectionAtNewRichSpan = - newParagraphFirstRichSpan.textRange.min == tempTextFieldValue.selection.min - 1 - - // Check if the cursor is at the new paragraph - if ( - (!config.preserveStyleOnEmptyLine || richSpan.paragraph.isEmpty()) && - isSelectionAtNewRichSpan - ) { - newParagraphFirstRichSpan.spanStyle = SpanStyle() - newParagraphFirstRichSpan.richSpanStyle = RichSpanStyle.Default - } else if ( - config.preserveStyleOnEmptyLine && - isSelectionAtNewRichSpan - ) { - newParagraphFirstRichSpan.spanStyle = currentSpanStyle - newParagraphFirstRichSpan.richSpanStyle = currentRichSpanStyle - } + val newParagraphFirstRichSpan = newParagraph.getFirstNonEmptyChild() + val isSelectionAtNewRichSpan = + newParagraphFirstRichSpan.textRange.min == tempTextFieldValue.selection.min - 1 + + // Check if the cursor is at the new paragraph + if ( + (!config.preserveStyleOnEmptyLine || richSpan.paragraph.isEmpty()) && + isSelectionAtNewRichSpan + ) { + newParagraphFirstRichSpan.spanStyle = SpanStyle() + newParagraphFirstRichSpan.richSpanStyle = RichSpanStyle.Default + } else if ( + config.preserveStyleOnEmptyLine && + isSelectionAtNewRichSpan + ) { + newParagraphFirstRichSpan.spanStyle = currentSpanStyle + newParagraphFirstRichSpan.richSpanStyle = currentRichSpanStyle } } From 485bba2fe8c9c010c118ee02dc0d8f79286013d9 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Sun, 24 Nov 2024 23:40:20 -0800 Subject: [PATCH 15/26] Ooohhh this fixes it --- .../kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt | 3 ++- .../mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt index d8646221..57c632ac 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt @@ -1744,8 +1744,9 @@ public class RichTextState internal constructor( // If the new paragraph is empty apply style depending on the config if (tempTextFieldValue.selection.collapsed && newParagraph.isEmpty()) { val newParagraphFirstRichSpan = newParagraph.getFirstNonEmptyChild() + val isSelectionAtNewRichSpan = - newParagraphFirstRichSpan.textRange.min == tempTextFieldValue.selection.min - 1 + newParagraphFirstRichSpan?.textRange?.min == tempTextFieldValue.selection.min - 1 // Check if the cursor is at the new paragraph if ( diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt index 060f9a9c..7e40deba 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/paragraph/type/ParagraphType.kt @@ -15,6 +15,6 @@ internal interface ParagraphType { fun copy(): ParagraphType companion object { - public val ParagraphType.startText : String get() = startRichSpan.text + val ParagraphType.startText : String get() = startRichSpan.text } } \ No newline at end of file From 62b1b9af71c5d2b578f2c02d2b59d93a0d928910 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Sun, 24 Nov 2024 23:41:28 -0800 Subject: [PATCH 16/26] clean up --- .../kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt index b1f89693..c57c0b2f 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt @@ -13,6 +13,7 @@ import com.mohamedrejeb.richeditor.utils.isSpecifiedFieldsEquals /** * A rich span is a part of a rich paragraph. */ +@OptIn(ExperimentalRichTextApi::class) internal class RichSpan( internal val key: Int? = null, val children: MutableList = mutableListOf(), From f6b4cb7e50db0b46e6109048b1952938cd7a050f Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 25 Nov 2024 19:46:38 -0800 Subject: [PATCH 17/26] more cleanup --- .../com/mohamedrejeb/richeditor/model/RichSpan.kt | 1 + .../mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt | 10 ++-------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt index c57c0b2f..81476da9 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichSpan.kt @@ -9,6 +9,7 @@ import com.mohamedrejeb.richeditor.annotation.ExperimentalRichTextApi import com.mohamedrejeb.richeditor.paragraph.RichParagraph import com.mohamedrejeb.richeditor.utils.customMerge import com.mohamedrejeb.richeditor.utils.isSpecifiedFieldsEquals +import kotlin.collections.indices /** * A rich span is a part of a rich paragraph. diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 353fa596..121f3468 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -9,20 +9,14 @@ import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.LocalTextStyle -import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor -import androidx.compose.ui.platform.LocalClipboardManager -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.platform.LocalLayoutDirection +import androidx.compose.ui.platform.* import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.TextRange import androidx.compose.ui.text.TextStyle From 0f0e6415d2716c97f2b902cf74a602c58695e4a6 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 27 Nov 2024 00:32:45 -0800 Subject: [PATCH 18/26] Provide a more robust way of handling different kinds of interactions on RichSpans --- gradle/libs.versions.toml | 2 + richeditor-compose/build.gradle.kts | 2 + .../richeditor/ui/BasicRichTextEditor.kt | 115 ++++++++++++++---- .../common/richeditor/RichEditorContent.kt | 29 +++-- 4 files changed, 118 insertions(+), 30 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 972d219e..561f53f0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,6 +4,7 @@ kotlin = "2.0.21" compose = "1.7.1" dokka = "1.9.10" +kotlinxDatetime = "0.6.1" ksoup = "0.4.0" jetbrainsMarkdown = "0.7.3" coil = "3.0.1" @@ -21,6 +22,7 @@ android-minSdk = "21" android-compileSdk = "34" [libraries] +kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" } ksoup-html = { module = "com.mohamedrejeb.ksoup:ksoup-html", version.ref = "ksoup" } ksoup-entities = { module = "com.mohamedrejeb.ksoup:ksoup-entities", version.ref = "ksoup" } jetbrains-markdown = { module = "org.jetbrains:markdown", version.ref = "jetbrainsMarkdown" } diff --git a/richeditor-compose/build.gradle.kts b/richeditor-compose/build.gradle.kts index ca0579c1..ee40fd76 100644 --- a/richeditor-compose/build.gradle.kts +++ b/richeditor-compose/build.gradle.kts @@ -51,6 +51,8 @@ kotlin { implementation(compose.material) implementation(compose.material3) + implementation(libs.kotlinx.datetime) + // HTML parsing library implementation(libs.ksoup.html) implementation(libs.ksoup.entities) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 121f3468..70284ffc 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -1,5 +1,6 @@ package com.mohamedrejeb.richeditor.ui +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.interaction.Interaction import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.PressInteraction @@ -11,11 +12,16 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material3.LocalTextStyle import androidx.compose.runtime.* import androidx.compose.ui.Modifier +import androidx.compose.ui.composed import androidx.compose.ui.focus.focusProperties import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.input.pointer.PointerEventPass +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.isSecondaryPressed +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.* import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.TextRange @@ -28,6 +34,8 @@ import com.mohamedrejeb.richeditor.model.RichSpanStyle import com.mohamedrejeb.richeditor.model.RichTextState import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import kotlinx.datetime.Clock +import kotlin.time.Duration.Companion.milliseconds /** @@ -220,25 +228,6 @@ public fun BasicRichTextEditor( state.singleParagraphMode = singleParagraph } - if(onRichSpanClick != null) { - // Start listening for rich span clicks - LaunchedEffect(interactionSource) { - scope.launch { - interactionSource.interactions.collect { interaction -> - if (interaction is PressInteraction.Press) { - val topPadding = with(density) { contentPadding.calculateTopPadding().toPx() } - val startPadding = with(density) { contentPadding.calculateStartPadding(layoutDirection).toPx() } - val localPosition = interaction.pressPosition - Offset(x = startPadding, y = topPadding) - - state.getRichSpanByOffset(localPosition)?.let { clickedSpan -> - onRichSpanClick(clickedSpan.richSpanStyle, clickedSpan.textRange, interaction.pressPosition) - } - } - } - } - } - } - if (!singleParagraph) { // Workaround for Android to fix a bug in BasicTextField where it doesn't select the correct text // when the text contains multiple paragraphs. @@ -247,7 +236,9 @@ public fun BasicRichTextEditor( if (interaction is PressInteraction.Press) { val pressPosition = interaction.pressPosition val topPadding = with(density) { contentPadding.calculateTopPadding().toPx() } - val startPadding = with(density) { contentPadding.calculateStartPadding(layoutDirection).toPx() } + val startPadding = with(density) { + contentPadding.calculateStartPadding(layoutDirection).toPx() + } adjustTextIndicatorOffset( pressPosition = pressPosition, @@ -277,6 +268,20 @@ public fun BasicRichTextEditor( topPadding = with(density) { contentPadding.calculateTopPadding().toPx() }, startPadding = with(density) { contentPadding.calculateStartPadding(layoutDirection).toPx() }, ) + .handleInteractions(onRichSpanClick != null) { type, offset -> + val topPadding = with(density) { contentPadding.calculateTopPadding().toPx() } + val startPadding = with(density) { contentPadding.calculateStartPadding(layoutDirection).toPx() } + val localPosition = offset - Offset(x = startPadding, y = topPadding) + + state.getRichSpanByOffset(localPosition)?.let { clickedSpan -> + onRichSpanClick?.invoke( + clickedSpan.richSpanStyle, + clickedSpan.textRange, + offset, + type + ) + } ?: false + } .then( if (!readOnly) Modifier @@ -346,4 +351,72 @@ internal suspend fun adjustTextIndicatorOffset( } public typealias RichTextChangedListener = (RichTextState) -> Unit -public typealias RichSpanClickListener = (RichSpanStyle, TextRange, Offset) -> Unit + +public enum class InteractionType { PrimaryClick, PrimaryDoubleClick, SecondaryClick, Tap, DoubleTap } +public typealias RichSpanClickListener = (RichSpanStyle, TextRange, Offset, InteractionType) -> Boolean + +/** + * Provide a unified callback for listening for different types of interactions + */ +private fun Modifier.handleInteractions( + enabled: Boolean = true, + onInteraction: ((InteractionType, Offset) -> Boolean)? = null +): Modifier = composed { + this + .pointerInput(enabled) { + awaitPointerEventScope { + while (true) { + val event = awaitPointerEvent(PointerEventPass.Main) + if (!enabled) continue + + if (event.type == PointerEventType.Press) { + val position = event.changes.first().position + + if (event.buttons.isSecondaryPressed) { + val consumed = onInteraction?.invoke(InteractionType.SecondaryClick, position) ?: false + if (consumed) { + event.changes.forEach { it.consume() } + } + } else { + val timeoutEnd = Clock.System.now() + 300.milliseconds + var secondPress: Boolean = false + + while (Clock.System.now() < timeoutEnd && !secondPress) { + val nextEvent = awaitPointerEvent(PointerEventPass.Main) + if (nextEvent.type == PointerEventType.Press) { + secondPress = true + val consumed = onInteraction?.invoke(InteractionType.PrimaryDoubleClick, position) ?: false + if (consumed) { + nextEvent.changes.forEach { it.consume() } + } + break + } + } + + if (!secondPress) { + val consumed = onInteraction?.invoke(InteractionType.PrimaryClick, position) ?: false + if (consumed) { + event.changes.forEach { it.consume() } + } + } + } + } + } + } + } + // Handle touch interactions + .pointerInput(enabled) { + detectTapGestures( + onTap = { offset -> + if (enabled) { + onInteraction?.invoke(InteractionType.Tap, offset) + } + }, + onDoubleTap = { offset -> + if (enabled) { + onInteraction?.invoke(InteractionType.DoubleTap, offset) + } + } + ) + } +} diff --git a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt index 74d6a355..ed1e83b3 100644 --- a/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt +++ b/sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt @@ -16,6 +16,7 @@ import com.mohamedrejeb.richeditor.model.rememberRichTextState import com.mohamedrejeb.richeditor.sample.common.components.RichTextStyleRow import com.mohamedrejeb.richeditor.sample.common.ui.theme.ComposeRichEditorTheme import com.mohamedrejeb.richeditor.ui.BasicRichTextEditor +import com.mohamedrejeb.richeditor.ui.InteractionType import com.mohamedrejeb.richeditor.ui.material3.OutlinedRichTextEditor import com.mohamedrejeb.richeditor.ui.material3.RichText import com.mohamedrejeb.richeditor.ui.material3.RichTextEditor @@ -87,13 +88,20 @@ fun RichEditorContent() { BasicRichTextEditor( modifier = Modifier.fillMaxWidth(), state = basicRichTextState, - onRichSpanClick = { span, range, offset -> - println("clicked") - if (span is SpellCheck) { - println("Spell check clicked") - println("Range: $range") - println("Offset: $offset") - spellCheckExpanded = offset + onRichSpanClick = { span, range, offset, type -> + println("clicked: $type") + if (type == InteractionType.PrimaryClick || type == InteractionType.DoubleTap) { + if (span is SpellCheck) { + println("Spell check clicked") + println("Range: $range") + println("Offset: $offset") + spellCheckExpanded = offset + true + } else { + false + } + } else { + false } } ) @@ -181,12 +189,15 @@ fun RichEditorContent() { onRichTextChangedListener = { println("Rich text changed!") }, - onRichSpanClick = { span, range, offset -> - println("clicked") + onRichSpanClick = { span, range, offset, type -> + println("clicked: $type") if (span is SpellCheck) { println("Spell check clicked") println("Range: $range") println("Offset: $offset") + true + } else { + false } }, ) From 1c43ed80338f64284b57b222dc969dc1d4f27b00 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 27 Nov 2024 00:47:24 -0800 Subject: [PATCH 19/26] API Dump --- .../api/android/richeditor-compose.api | 23 ++++++++++++++----- .../api/desktop/richeditor-compose.api | 23 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/richeditor-compose/api/android/richeditor-compose.api b/richeditor-compose/api/android/richeditor-compose.api index dd7e5999..145bae9d 100644 --- a/richeditor-compose/api/android/richeditor-compose.api +++ b/richeditor-compose/api/android/richeditor-compose.api @@ -219,8 +219,8 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -236,12 +236,23 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich public final fun getLambda-2$richeditor_compose_release ()Lkotlin/jvm/functions/Function3; } +public final class com/mohamedrejeb/richeditor/ui/InteractionType : java/lang/Enum { + public static final field DoubleTap Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field PrimaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field PrimaryDoubleClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field SecondaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field Tap Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static fun values ()[Lcom/mohamedrejeb/richeditor/ui/InteractionType; +} + public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -249,7 +260,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { @@ -284,7 +295,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { diff --git a/richeditor-compose/api/desktop/richeditor-compose.api b/richeditor-compose/api/desktop/richeditor-compose.api index 305130f8..c2f00bff 100644 --- a/richeditor-compose/api/desktop/richeditor-compose.api +++ b/richeditor-compose/api/desktop/richeditor-compose.api @@ -219,8 +219,8 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -236,12 +236,23 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich public final fun getLambda-2$richeditor_compose ()Lkotlin/jvm/functions/Function3; } +public final class com/mohamedrejeb/richeditor/ui/InteractionType : java/lang/Enum { + public static final field DoubleTap Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field PrimaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field PrimaryDoubleClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field SecondaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static final field Tap Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static fun getEntries ()Lkotlin/enums/EnumEntries; + public static fun valueOf (Ljava/lang/String;)Lcom/mohamedrejeb/richeditor/ui/InteractionType; + public static fun values ()[Lcom/mohamedrejeb/richeditor/ui/InteractionType; +} + public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -249,7 +260,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { @@ -284,7 +295,7 @@ public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorDefaul } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function3;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextKt { From 3f63695c47bb9f33fcae7695a81b910cb8845e36 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 27 Nov 2024 15:46:21 -0800 Subject: [PATCH 20/26] Simplified --- .../richeditor/ui/BasicRichTextEditor.kt | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 70284ffc..8798001f 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -20,6 +20,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.input.pointer.PointerEventPass import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.isPressed +import androidx.compose.ui.input.pointer.isPrimaryPressed import androidx.compose.ui.input.pointer.isSecondaryPressed import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.platform.* @@ -352,7 +354,7 @@ internal suspend fun adjustTextIndicatorOffset( public typealias RichTextChangedListener = (RichTextState) -> Unit -public enum class InteractionType { PrimaryClick, PrimaryDoubleClick, SecondaryClick, Tap, DoubleTap } +public enum class InteractionType { PrimaryClick, SecondaryClick, Tap, DoubleTap } public typealias RichSpanClickListener = (RichSpanStyle, TextRange, Offset, InteractionType) -> Boolean /** @@ -372,32 +374,16 @@ private fun Modifier.handleInteractions( if (event.type == PointerEventType.Press) { val position = event.changes.first().position - if (event.buttons.isSecondaryPressed) { - val consumed = onInteraction?.invoke(InteractionType.SecondaryClick, position) ?: false + if (event.buttons.isPrimaryPressed) { + val consumed = onInteraction?.invoke(InteractionType.PrimaryClick, position) ?: false if (consumed) { event.changes.forEach { it.consume() } } - } else { - val timeoutEnd = Clock.System.now() + 300.milliseconds - var secondPress: Boolean = false - - while (Clock.System.now() < timeoutEnd && !secondPress) { - val nextEvent = awaitPointerEvent(PointerEventPass.Main) - if (nextEvent.type == PointerEventType.Press) { - secondPress = true - val consumed = onInteraction?.invoke(InteractionType.PrimaryDoubleClick, position) ?: false - if (consumed) { - nextEvent.changes.forEach { it.consume() } - } - break - } - } - - if (!secondPress) { - val consumed = onInteraction?.invoke(InteractionType.PrimaryClick, position) ?: false - if (consumed) { - event.changes.forEach { it.consume() } - } + } + else if (event.buttons.isSecondaryPressed) { + val consumed = onInteraction?.invoke(InteractionType.SecondaryClick, position) ?: false + if (consumed) { + event.changes.forEach { it.consume() } } } } From 677c6f8872eecf418cb51352af422787f3778f0f Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 28 Nov 2024 11:33:36 -0800 Subject: [PATCH 21/26] Fixed Touch VS Mouse input --- .../api/android/richeditor-compose.api | 1 - .../api/desktop/richeditor-compose.api | 1 - .../richeditor/ui/BasicRichTextEditor.kt | 77 ++++++++++--------- 3 files changed, 39 insertions(+), 40 deletions(-) diff --git a/richeditor-compose/api/android/richeditor-compose.api b/richeditor-compose/api/android/richeditor-compose.api index 145bae9d..c0802abd 100644 --- a/richeditor-compose/api/android/richeditor-compose.api +++ b/richeditor-compose/api/android/richeditor-compose.api @@ -239,7 +239,6 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich public final class com/mohamedrejeb/richeditor/ui/InteractionType : java/lang/Enum { public static final field DoubleTap Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static final field PrimaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; - public static final field PrimaryDoubleClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static final field SecondaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static final field Tap Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static fun getEntries ()Lkotlin/enums/EnumEntries; diff --git a/richeditor-compose/api/desktop/richeditor-compose.api b/richeditor-compose/api/desktop/richeditor-compose.api index c2f00bff..f8ffaeb8 100644 --- a/richeditor-compose/api/desktop/richeditor-compose.api +++ b/richeditor-compose/api/desktop/richeditor-compose.api @@ -239,7 +239,6 @@ public final class com/mohamedrejeb/richeditor/ui/ComposableSingletons$BasicRich public final class com/mohamedrejeb/richeditor/ui/InteractionType : java/lang/Enum { public static final field DoubleTap Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static final field PrimaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; - public static final field PrimaryDoubleClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static final field SecondaryClick Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static final field Tap Lcom/mohamedrejeb/richeditor/ui/InteractionType; public static fun getEntries ()Lkotlin/enums/EnumEntries; diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 8798001f..fa4e014e 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -1,6 +1,5 @@ package com.mohamedrejeb.richeditor.ui -import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.interaction.Interaction import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.PressInteraction @@ -20,7 +19,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import androidx.compose.ui.input.pointer.PointerEventPass import androidx.compose.ui.input.pointer.PointerEventType -import androidx.compose.ui.input.pointer.isPressed +import androidx.compose.ui.input.pointer.PointerType import androidx.compose.ui.input.pointer.isPrimaryPressed import androidx.compose.ui.input.pointer.isSecondaryPressed import androidx.compose.ui.input.pointer.pointerInput @@ -35,9 +34,6 @@ import androidx.compose.ui.unit.LayoutDirection import com.mohamedrejeb.richeditor.model.RichSpanStyle import com.mohamedrejeb.richeditor.model.RichTextState import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch -import kotlinx.datetime.Clock -import kotlin.time.Duration.Companion.milliseconds /** @@ -366,43 +362,48 @@ private fun Modifier.handleInteractions( ): Modifier = composed { this .pointerInput(enabled) { - awaitPointerEventScope { - while (true) { - val event = awaitPointerEvent(PointerEventPass.Main) - if (!enabled) continue + awaitPointerEventScope { + while (true) { + val event = awaitPointerEvent(PointerEventPass.Main) + if (!enabled) continue - if (event.type == PointerEventType.Press) { - val position = event.changes.first().position + if (event.type == PointerEventType.Press) { + val position = event.changes.first().position - if (event.buttons.isPrimaryPressed) { - val consumed = onInteraction?.invoke(InteractionType.PrimaryClick, position) ?: false - if (consumed) { - event.changes.forEach { it.consume() } - } - } - else if (event.buttons.isSecondaryPressed) { - val consumed = onInteraction?.invoke(InteractionType.SecondaryClick, position) ?: false - if (consumed) { - event.changes.forEach { it.consume() } + when (event.changes.first().type) { + PointerType.Touch -> { + onInteraction?.invoke( + InteractionType.Tap, + event.changes.first().position + ) + } + + PointerType.Mouse -> { + if (event.buttons.isPrimaryPressed) { + val consumed = + onInteraction?.invoke( + InteractionType.PrimaryClick, + position + ) + ?: false + if (consumed) { + event.changes.forEach { it.consume() } + } + } else if (event.buttons.isSecondaryPressed) { + val consumed = + onInteraction?.invoke( + InteractionType.SecondaryClick, + position + ) + ?: false + if (consumed) { + event.changes.forEach { it.consume() } + } + } + } } } } } } - } - // Handle touch interactions - .pointerInput(enabled) { - detectTapGestures( - onTap = { offset -> - if (enabled) { - onInteraction?.invoke(InteractionType.Tap, offset) - } - }, - onDoubleTap = { offset -> - if (enabled) { - onInteraction?.invoke(InteractionType.DoubleTap, offset) - } - } - ) - } -} +} \ No newline at end of file From 5f180b88c7ebb782b085d22cb41437abd387c8ad Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 28 Nov 2024 21:19:36 -0800 Subject: [PATCH 22/26] Not needed anymore --- .../kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index fa4e014e..0ddd9fc2 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -210,7 +210,6 @@ public fun BasicRichTextEditor( @Composable { innerTextField -> innerTextField() }, contentPadding: PaddingValues ) { - val scope = rememberCoroutineScope() val density = LocalDensity.current val localTextStyle = LocalTextStyle.current val layoutDirection = LocalLayoutDirection.current From 6e2aa8b9eb2ab65ce28df149046e4d10a244019e Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 28 Nov 2024 21:21:03 -0800 Subject: [PATCH 23/26] Not needed anymore --- gradle/libs.versions.toml | 2 -- richeditor-compose/build.gradle.kts | 2 -- 2 files changed, 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 561f53f0..972d219e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,6 @@ kotlin = "2.0.21" compose = "1.7.1" dokka = "1.9.10" -kotlinxDatetime = "0.6.1" ksoup = "0.4.0" jetbrainsMarkdown = "0.7.3" coil = "3.0.1" @@ -22,7 +21,6 @@ android-minSdk = "21" android-compileSdk = "34" [libraries] -kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinxDatetime" } ksoup-html = { module = "com.mohamedrejeb.ksoup:ksoup-html", version.ref = "ksoup" } ksoup-entities = { module = "com.mohamedrejeb.ksoup:ksoup-entities", version.ref = "ksoup" } jetbrains-markdown = { module = "org.jetbrains:markdown", version.ref = "jetbrainsMarkdown" } diff --git a/richeditor-compose/build.gradle.kts b/richeditor-compose/build.gradle.kts index ee40fd76..ca0579c1 100644 --- a/richeditor-compose/build.gradle.kts +++ b/richeditor-compose/build.gradle.kts @@ -51,8 +51,6 @@ kotlin { implementation(compose.material) implementation(compose.material3) - implementation(libs.kotlinx.datetime) - // HTML parsing library implementation(libs.ksoup.html) implementation(libs.ksoup.entities) From 8072b268cc37cf054a9b92ce3e434b40161167c7 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 28 Nov 2024 21:25:31 -0800 Subject: [PATCH 24/26] Split up the file --- .../richeditor/ui/BasicRichTextEditor.kt | 57 ---------------- .../richeditor/ui/handleInteractions.kt | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 57 deletions(-) create mode 100644 richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt index 0ddd9fc2..4c1d52b5 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/BasicRichTextEditor.kt @@ -348,61 +348,4 @@ internal suspend fun adjustTextIndicatorOffset( } public typealias RichTextChangedListener = (RichTextState) -> Unit - -public enum class InteractionType { PrimaryClick, SecondaryClick, Tap, DoubleTap } public typealias RichSpanClickListener = (RichSpanStyle, TextRange, Offset, InteractionType) -> Boolean - -/** - * Provide a unified callback for listening for different types of interactions - */ -private fun Modifier.handleInteractions( - enabled: Boolean = true, - onInteraction: ((InteractionType, Offset) -> Boolean)? = null -): Modifier = composed { - this - .pointerInput(enabled) { - awaitPointerEventScope { - while (true) { - val event = awaitPointerEvent(PointerEventPass.Main) - if (!enabled) continue - - if (event.type == PointerEventType.Press) { - val position = event.changes.first().position - - when (event.changes.first().type) { - PointerType.Touch -> { - onInteraction?.invoke( - InteractionType.Tap, - event.changes.first().position - ) - } - - PointerType.Mouse -> { - if (event.buttons.isPrimaryPressed) { - val consumed = - onInteraction?.invoke( - InteractionType.PrimaryClick, - position - ) - ?: false - if (consumed) { - event.changes.forEach { it.consume() } - } - } else if (event.buttons.isSecondaryPressed) { - val consumed = - onInteraction?.invoke( - InteractionType.SecondaryClick, - position - ) - ?: false - if (consumed) { - event.changes.forEach { it.consume() } - } - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt new file mode 100644 index 00000000..906e758c --- /dev/null +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt @@ -0,0 +1,68 @@ +package com.mohamedrejeb.richeditor.ui + +import androidx.compose.ui.Modifier +import androidx.compose.ui.composed +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.input.pointer.PointerEventPass +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.PointerType +import androidx.compose.ui.input.pointer.isPrimaryPressed +import androidx.compose.ui.input.pointer.isSecondaryPressed +import androidx.compose.ui.input.pointer.pointerInput + +public enum class InteractionType { PrimaryClick, SecondaryClick, Tap, DoubleTap } + +/** + * Provide a unified callback for listening for different types of interactions + */ +internal fun Modifier.handleInteractions( + enabled: Boolean = true, + onInteraction: ((InteractionType, Offset) -> Boolean)? = null +): Modifier = composed { + this + .pointerInput(enabled) { + awaitPointerEventScope { + while (true) { + val event = awaitPointerEvent(PointerEventPass.Main) + if (!enabled) continue + + if (event.type == PointerEventType.Press) { + val position = event.changes.first().position + + when (event.changes.first().type) { + PointerType.Touch -> { + onInteraction?.invoke( + InteractionType.Tap, + event.changes.first().position + ) + } + + PointerType.Mouse -> { + if (event.buttons.isPrimaryPressed) { + val consumed = + onInteraction?.invoke( + InteractionType.PrimaryClick, + position + ) + ?: false + if (consumed) { + event.changes.forEach { it.consume() } + } + } else if (event.buttons.isSecondaryPressed) { + val consumed = + onInteraction?.invoke( + InteractionType.SecondaryClick, + position + ) + ?: false + if (consumed) { + event.changes.forEach { it.consume() } + } + } + } + } + } + } + } + } +} \ No newline at end of file From 43567dd2b7e863dbc22cb96571e46f3bdab6385b Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 28 Nov 2024 21:28:50 -0800 Subject: [PATCH 25/26] trivial cleanup --- .../com/mohamedrejeb/richeditor/ui/handleInteractions.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt index 906e758c..4e177190 100644 --- a/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt +++ b/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/ui/handleInteractions.kt @@ -27,13 +27,14 @@ internal fun Modifier.handleInteractions( if (!enabled) continue if (event.type == PointerEventType.Press) { - val position = event.changes.first().position + val eventChange = event.changes.first() + val position = eventChange.position - when (event.changes.first().type) { + when (eventChange.type) { PointerType.Touch -> { onInteraction?.invoke( InteractionType.Tap, - event.changes.first().position + eventChange.position ) } From 32a1c14e6f9f171a70b4090b0109227ac39dc1b3 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Sat, 7 Dec 2024 11:41:53 -0800 Subject: [PATCH 26/26] API Dump --- .../api/android/richeditor-compose.api | 10 ++++---- .../api/desktop/richeditor-compose.api | 10 ++++---- .../api/richeditor-compose.klib.api | 25 ++++++++++++++----- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/richeditor-compose/api/android/richeditor-compose.api b/richeditor-compose/api/android/richeditor-compose.api index c0802abd..a3a03e90 100644 --- a/richeditor-compose/api/android/richeditor-compose.api +++ b/richeditor-compose/api/android/richeditor-compose.api @@ -219,8 +219,8 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -247,11 +247,11 @@ public final class com/mohamedrejeb/richeditor/ui/InteractionType : java/lang/En } public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -259,7 +259,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { diff --git a/richeditor-compose/api/desktop/richeditor-compose.api b/richeditor-compose/api/desktop/richeditor-compose.api index f8ffaeb8..b789658f 100644 --- a/richeditor-compose/api/desktop/richeditor-compose.api +++ b/richeditor-compose/api/desktop/richeditor-compose.api @@ -219,8 +219,8 @@ public final class com/mohamedrejeb/richeditor/model/TextPaddingValues { } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextEditorKt { - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V - public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;III)V + public static final fun BasicRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Landroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Brush;Lkotlin/jvm/functions/Function3;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;III)V } public final class com/mohamedrejeb/richeditor/ui/BasicRichTextKt { @@ -247,11 +247,11 @@ public final class com/mohamedrejeb/richeditor/ui/InteractionType : java/lang/En } public final class com/mohamedrejeb/richeditor/ui/material/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextEditorKt { - public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;III)V + public static final fun RichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/material/TextFieldColors;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { @@ -259,7 +259,7 @@ public final class com/mohamedrejeb/richeditor/ui/material/RichTextKt { } public final class com/mohamedrejeb/richeditor/ui/material3/OutlinedRichTextEditorKt { - public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V + public static final fun OutlinedRichTextEditor (Lcom/mohamedrejeb/richeditor/model/RichTextState;Landroidx/compose/ui/Modifier;ZZLandroidx/compose/ui/text/TextStyle;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ZLandroidx/compose/foundation/text/KeyboardOptions;Landroidx/compose/foundation/text/KeyboardActions;ZIIILkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function1;Landroidx/compose/foundation/interaction/MutableInteractionSource;Landroidx/compose/ui/graphics/Shape;Lcom/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors;Landroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/runtime/Composer;IIII)V } public final class com/mohamedrejeb/richeditor/ui/material3/RichTextEditorColors { diff --git a/richeditor-compose/api/richeditor-compose.klib.api b/richeditor-compose/api/richeditor-compose.klib.api index bff01575..12405aa5 100644 --- a/richeditor-compose/api/richeditor-compose.klib.api +++ b/richeditor-compose/api/richeditor-compose.klib.api @@ -14,6 +14,19 @@ open annotation class com.mohamedrejeb.richeditor.annotation/InternalRichTextApi constructor () // com.mohamedrejeb.richeditor.annotation/InternalRichTextApi.|(){}[0] } +final enum class com.mohamedrejeb.richeditor.ui/InteractionType : kotlin/Enum { // com.mohamedrejeb.richeditor.ui/InteractionType|null[0] + enum entry DoubleTap // com.mohamedrejeb.richeditor.ui/InteractionType.DoubleTap|null[0] + enum entry PrimaryClick // com.mohamedrejeb.richeditor.ui/InteractionType.PrimaryClick|null[0] + enum entry SecondaryClick // com.mohamedrejeb.richeditor.ui/InteractionType.SecondaryClick|null[0] + enum entry Tap // com.mohamedrejeb.richeditor.ui/InteractionType.Tap|null[0] + + final val entries // com.mohamedrejeb.richeditor.ui/InteractionType.entries|#static{}entries[0] + final fun (): kotlin.enums/EnumEntries // com.mohamedrejeb.richeditor.ui/InteractionType.entries.|#static(){}[0] + + final fun valueOf(kotlin/String): com.mohamedrejeb.richeditor.ui/InteractionType // com.mohamedrejeb.richeditor.ui/InteractionType.valueOf|valueOf#static(kotlin.String){}[0] + final fun values(): kotlin/Array // com.mohamedrejeb.richeditor.ui/InteractionType.values|values#static(){}[0] +} + abstract interface com.mohamedrejeb.richeditor.model/ImageLoader { // com.mohamedrejeb.richeditor.model/ImageLoader|null[0] abstract fun load(kotlin/Any, androidx.compose.runtime/Composer?, kotlin/Int): com.mohamedrejeb.richeditor.model/ImageData? // com.mohamedrejeb.richeditor.model/ImageLoader.load|load(kotlin.Any;androidx.compose.runtime.Composer?;kotlin.Int){}[0] } @@ -335,17 +348,17 @@ final fun com.mohamedrejeb.richeditor.parser.html/com_mohamedrejeb_richeditor_pa final fun com.mohamedrejeb.richeditor.parser.html/com_mohamedrejeb_richeditor_parser_html_CssEncoder$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.parser.html/com_mohamedrejeb_richeditor_parser_html_CssEncoder$stableprop_getter|com_mohamedrejeb_richeditor_parser_html_CssEncoder$stableprop_getter(){}[0] final fun com.mohamedrejeb.richeditor.parser.html/com_mohamedrejeb_richeditor_parser_html_RichTextStateHtmlParser$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.parser.html/com_mohamedrejeb_richeditor_parser_html_RichTextStateHtmlParser$stableprop_getter|com_mohamedrejeb_richeditor_parser_html_RichTextStateHtmlParser$stableprop_getter(){}[0] final fun com.mohamedrejeb.richeditor.parser.markdown/com_mohamedrejeb_richeditor_parser_markdown_RichTextStateMarkdownParser$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.parser.markdown/com_mohamedrejeb_richeditor_parser_markdown_RichTextStateMarkdownParser$stableprop_getter|com_mohamedrejeb_richeditor_parser_markdown_RichTextStateMarkdownParser$stableprop_getter(){}[0] -final fun com.mohamedrejeb.richeditor.ui.material/OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, androidx.compose.material/TextFieldColors?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material/OutlinedRichTextEditor|OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;androidx.compose.material.TextFieldColors?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] +final fun com.mohamedrejeb.richeditor.ui.material/OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function4?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, androidx.compose.material/TextFieldColors?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material/OutlinedRichTextEditor|OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function4?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;androidx.compose.material.TextFieldColors?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0] final fun com.mohamedrejeb.richeditor.ui.material/RichText(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, androidx.compose.ui.graphics/Color, androidx.compose.ui.unit/TextUnit, androidx.compose.ui.text.font/FontStyle?, androidx.compose.ui.text.font/FontWeight?, androidx.compose.ui.text.font/FontFamily?, androidx.compose.ui.unit/TextUnit, androidx.compose.ui.text.style/TextDecoration?, androidx.compose.ui.text.style/TextAlign, androidx.compose.ui.unit/TextUnit, androidx.compose.ui.text.style/TextOverflow, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin.collections/Map?, kotlin/Function1?, androidx.compose.ui.text/TextStyle?, com.mohamedrejeb.richeditor.model/ImageLoader?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material/RichText|RichText(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;androidx.compose.ui.graphics.Color;androidx.compose.ui.unit.TextUnit;androidx.compose.ui.text.font.FontStyle?;androidx.compose.ui.text.font.FontWeight?;androidx.compose.ui.text.font.FontFamily?;androidx.compose.ui.unit.TextUnit;androidx.compose.ui.text.style.TextDecoration?;androidx.compose.ui.text.style.TextAlign;androidx.compose.ui.unit.TextUnit;androidx.compose.ui.text.style.TextOverflow;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.collections.Map?;kotlin.Function1?;androidx.compose.ui.text.TextStyle?;com.mohamedrejeb.richeditor.model.ImageLoader?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] -final fun com.mohamedrejeb.richeditor.ui.material/RichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, androidx.compose.material/TextFieldColors?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material/RichTextEditor|RichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;androidx.compose.material.TextFieldColors?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] +final fun com.mohamedrejeb.richeditor.ui.material/RichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function4?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, androidx.compose.material/TextFieldColors?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material/RichTextEditor|RichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function4?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;androidx.compose.material.TextFieldColors?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0] final fun com.mohamedrejeb.richeditor.ui.material3.tokens/com_mohamedrejeb_richeditor_ui_material3_tokens_FiledRichTextEditorTokens$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.ui.material3.tokens/com_mohamedrejeb_richeditor_ui_material3_tokens_FiledRichTextEditorTokens$stableprop_getter|com_mohamedrejeb_richeditor_ui_material3_tokens_FiledRichTextEditorTokens$stableprop_getter(){}[0] final fun com.mohamedrejeb.richeditor.ui.material3.tokens/com_mohamedrejeb_richeditor_ui_material3_tokens_OutlinedRichTextEditorTokens$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.ui.material3.tokens/com_mohamedrejeb_richeditor_ui_material3_tokens_OutlinedRichTextEditorTokens$stableprop_getter|com_mohamedrejeb_richeditor_ui_material3_tokens_OutlinedRichTextEditorTokens$stableprop_getter(){}[0] -final fun com.mohamedrejeb.richeditor.ui.material3/OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, com.mohamedrejeb.richeditor.ui.material3/RichTextEditorColors?, androidx.compose.foundation.layout/PaddingValues?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material3/OutlinedRichTextEditor|OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;com.mohamedrejeb.richeditor.ui.material3.RichTextEditorColors?;androidx.compose.foundation.layout.PaddingValues?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0] +final fun com.mohamedrejeb.richeditor.ui.material3/OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function4?, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, com.mohamedrejeb.richeditor.ui.material3/RichTextEditorColors?, androidx.compose.foundation.layout/PaddingValues?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material3/OutlinedRichTextEditor|OutlinedRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function4?;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;com.mohamedrejeb.richeditor.ui.material3.RichTextEditorColors?;androidx.compose.foundation.layout.PaddingValues?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0] final fun com.mohamedrejeb.richeditor.ui.material3/RichText(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, androidx.compose.ui.graphics/Color, androidx.compose.ui.unit/TextUnit, androidx.compose.ui.text.font/FontStyle?, androidx.compose.ui.text.font/FontWeight?, androidx.compose.ui.text.font/FontFamily?, androidx.compose.ui.unit/TextUnit, androidx.compose.ui.text.style/TextDecoration?, androidx.compose.ui.text.style/TextAlign, androidx.compose.ui.unit/TextUnit, androidx.compose.ui.text.style/TextOverflow, kotlin/Boolean, kotlin/Int, kotlin.collections/Map?, kotlin/Function1?, androidx.compose.ui.text/TextStyle?, com.mohamedrejeb.richeditor.model/ImageLoader?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material3/RichText|RichText(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;androidx.compose.ui.graphics.Color;androidx.compose.ui.unit.TextUnit;androidx.compose.ui.text.font.FontStyle?;androidx.compose.ui.text.font.FontWeight?;androidx.compose.ui.text.font.FontFamily?;androidx.compose.ui.unit.TextUnit;androidx.compose.ui.text.style.TextDecoration?;androidx.compose.ui.text.style.TextAlign;androidx.compose.ui.unit.TextUnit;androidx.compose.ui.text.style.TextOverflow;kotlin.Boolean;kotlin.Int;kotlin.collections.Map?;kotlin.Function1?;androidx.compose.ui.text.TextStyle?;com.mohamedrejeb.richeditor.model.ImageLoader?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] -final fun com.mohamedrejeb.richeditor.ui.material3/RichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, com.mohamedrejeb.richeditor.ui.material3/RichTextEditorColors?, androidx.compose.foundation.layout/PaddingValues?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material3/RichTextEditor|RichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;com.mohamedrejeb.richeditor.ui.material3.RichTextEditorColors?;androidx.compose.foundation.layout.PaddingValues?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0] +final fun com.mohamedrejeb.richeditor.ui.material3/RichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Function2?, kotlin/Boolean, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function4?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Shape?, com.mohamedrejeb.richeditor.ui.material3/RichTextEditorColors?, androidx.compose.foundation.layout/PaddingValues?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui.material3/RichTextEditor|RichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Function2?;kotlin.Boolean;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function4?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Shape?;com.mohamedrejeb.richeditor.ui.material3.RichTextEditorColors?;androidx.compose.foundation.layout.PaddingValues?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Int){}[0] final fun com.mohamedrejeb.richeditor.ui.material3/com_mohamedrejeb_richeditor_ui_material3_RichTextEditorColors$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.ui.material3/com_mohamedrejeb_richeditor_ui_material3_RichTextEditorColors$stableprop_getter|com_mohamedrejeb_richeditor_ui_material3_RichTextEditorColors$stableprop_getter(){}[0] final fun com.mohamedrejeb.richeditor.ui.material3/com_mohamedrejeb_richeditor_ui_material3_RichTextEditorDefaults$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.ui.material3/com_mohamedrejeb_richeditor_ui_material3_RichTextEditorDefaults$stableprop_getter|com_mohamedrejeb_richeditor_ui_material3_RichTextEditorDefaults$stableprop_getter(){}[0] final fun com.mohamedrejeb.richeditor.ui/BasicRichText(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, androidx.compose.ui.text/TextStyle?, kotlin/Function1?, androidx.compose.ui.text.style/TextOverflow, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin.collections/Map?, com.mohamedrejeb.richeditor.model/ImageLoader?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui/BasicRichText|BasicRichText(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;androidx.compose.ui.text.TextStyle?;kotlin.Function1?;androidx.compose.ui.text.style.TextOverflow;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.collections.Map?;com.mohamedrejeb.richeditor.model.ImageLoader?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0] -final fun com.mohamedrejeb.richeditor.ui/BasicRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Brush?, kotlin/Function3, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, androidx.compose.foundation.layout/PaddingValues, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui/BasicRichTextEditor|BasicRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Brush?;kotlin.Function3,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;androidx.compose.foundation.layout.PaddingValues;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] -final fun com.mohamedrejeb.richeditor.ui/BasicRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Brush?, kotlin/Function3, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui/BasicRichTextEditor|BasicRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Brush?;kotlin.Function3,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] +final fun com.mohamedrejeb.richeditor.ui/BasicRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function4?, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Brush?, kotlin/Function3, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, androidx.compose.foundation.layout/PaddingValues, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui/BasicRichTextEditor|BasicRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function4?;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Brush?;kotlin.Function3,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;androidx.compose.foundation.layout.PaddingValues;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] +final fun com.mohamedrejeb.richeditor.ui/BasicRichTextEditor(com.mohamedrejeb.richeditor.model/RichTextState, androidx.compose.ui/Modifier?, kotlin/Boolean, kotlin/Boolean, androidx.compose.ui.text/TextStyle?, androidx.compose.foundation.text/KeyboardOptions?, androidx.compose.foundation.text/KeyboardActions?, kotlin/Boolean, kotlin/Int, kotlin/Int, kotlin/Int, kotlin/Function1?, kotlin/Function4?, kotlin/Function1?, androidx.compose.foundation.interaction/MutableInteractionSource?, androidx.compose.ui.graphics/Brush?, kotlin/Function3, androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>?, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int, kotlin/Int) // com.mohamedrejeb.richeditor.ui/BasicRichTextEditor|BasicRichTextEditor(com.mohamedrejeb.richeditor.model.RichTextState;androidx.compose.ui.Modifier?;kotlin.Boolean;kotlin.Boolean;androidx.compose.ui.text.TextStyle?;androidx.compose.foundation.text.KeyboardOptions?;androidx.compose.foundation.text.KeyboardActions?;kotlin.Boolean;kotlin.Int;kotlin.Int;kotlin.Int;kotlin.Function1?;kotlin.Function4?;kotlin.Function1?;androidx.compose.foundation.interaction.MutableInteractionSource?;androidx.compose.ui.graphics.Brush?;kotlin.Function3,androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){}[0] final fun com.mohamedrejeb.richeditor.ui/com_mohamedrejeb_richeditor_ui_RichTextClipboardManager$stableprop_getter(): kotlin/Int // com.mohamedrejeb.richeditor.ui/com_mohamedrejeb_richeditor_ui_RichTextClipboardManager$stableprop_getter|com_mohamedrejeb_richeditor_ui_RichTextClipboardManager$stableprop_getter(){}[0]