Skip to content

Commit a678065

Browse files
committed
adding in h3 support
1 parent 9ca2800 commit a678065

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import kotlin.math.max
7575
import kotlin.reflect.KClass
7676
import com.mohamedrejeb.richeditor.parser.utils.H1SpanStyle
7777
import com.mohamedrejeb.richeditor.parser.utils.H2SpanStyle
78+
import com.mohamedrejeb.richeditor.parser.utils.H3SpanStyle
7879

7980
/**
8081
* rememberRichTextState - Creates and remembers a RichTextState instance with automatic state preservation.
@@ -300,6 +301,8 @@ public class RichTextState internal constructor(
300301
private set
301302
public var isH2: Boolean by mutableStateOf(false)
302303
private set
304+
public var isH3: Boolean by mutableStateOf(false)
305+
private set
303306

304307
public val config: RichTextConfig = RichTextConfig(
305308
updateText = {
@@ -4376,5 +4379,7 @@ public class RichTextState internal constructor(
43764379
currentStyle.fontWeight == H1SpanStyle.fontWeight
43774380
isH2 = currentStyle.fontSize == H2SpanStyle.fontSize &&
43784381
currentStyle.fontWeight == H2SpanStyle.fontWeight
4382+
isH3 = currentStyle.fontSize == H3SpanStyle.fontSize &&
4383+
currentStyle.fontWeight == H3SpanStyle.fontWeight
43794384
}
43804385
}

richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/parser/lexical/RichTextStateLexicalParser.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.mohamedrejeb.richeditor.paragraph.type.*
1313
import com.mohamedrejeb.richeditor.parser.RichTextStateParser
1414
import com.mohamedrejeb.richeditor.parser.utils.H1SpanStyle
1515
import com.mohamedrejeb.richeditor.parser.utils.H2SpanStyle
16+
import com.mohamedrejeb.richeditor.parser.utils.H3SpanStyle
1617
import androidx.compose.ui.util.fastForEach
1718

1819
internal object RichTextStateLexicalParser : RichTextStateParser<String> {
@@ -341,6 +342,7 @@ internal object RichTextStateLexicalParser : RichTextStateParser<String> {
341342
val headingStyle = when (node.tag) {
342343
"h1" -> H1SpanStyle
343344
"h2" -> H2SpanStyle
345+
"h3" -> H3SpanStyle
344346
else -> null
345347
}
346348

@@ -951,6 +953,9 @@ internal object RichTextStateLexicalParser : RichTextStateParser<String> {
951953
spanStyle.fontSize == H2SpanStyle.fontSize &&
952954
spanStyle.fontWeight == H2SpanStyle.fontWeight -> "h2"
953955

956+
spanStyle.fontSize == H3SpanStyle.fontSize &&
957+
spanStyle.fontWeight == H3SpanStyle.fontWeight -> "h3"
958+
954959
else -> null
955960
}
956961
}

0 commit comments

Comments
 (0)