Skip to content

Commit 2c7e21e

Browse files
committed
Spellcheck test
1 parent ba473d6 commit 2c7e21e

File tree

1 file changed

+41
-15
lines changed
  • sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor

1 file changed

+41
-15
lines changed

sample/common/src/commonMain/kotlin/com/mohamedrejeb/richeditor/sample/common/richeditor/RichEditorContent.kt

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import androidx.compose.foundation.lazy.LazyColumn
55
import androidx.compose.material.icons.Icons
66
import androidx.compose.material.icons.automirrored.filled.ArrowBack
77
import androidx.compose.material3.*
8-
import androidx.compose.runtime.Composable
9-
import androidx.compose.runtime.LaunchedEffect
8+
import androidx.compose.runtime.*
109
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.geometry.Rect
11+
import androidx.compose.ui.unit.DpOffset
1112
import androidx.compose.ui.unit.dp
1213
import cafe.adriel.voyager.navigator.LocalNavigator
1314
import cafe.adriel.voyager.navigator.currentOrThrow
@@ -80,21 +81,46 @@ fun RichEditorContent() {
8081
}
8182

8283
item {
83-
BasicRichTextEditor(
84-
modifier = Modifier.fillMaxWidth(),
85-
state = basicRichTextState,
86-
onRichSpanClick = { span ->
87-
println("clicked")
88-
if (span.style is SpellCheck) {
89-
println("Spell check clicked")
90-
val position =
91-
basicRichTextState.textLayoutResult
92-
?.multiParagraph
93-
?.getBoundingBox(span.textRange.start)
94-
println("Position: ${position}")
84+
Box {
85+
var spellCheckExpanded by remember { mutableStateOf<Rect?>(null) }
86+
87+
BasicRichTextEditor(
88+
modifier = Modifier.fillMaxWidth(),
89+
state = basicRichTextState,
90+
onRichSpanClick = { span ->
91+
println("clicked")
92+
if (span.style is SpellCheck) {
93+
println("Spell check clicked")
94+
val position =
95+
basicRichTextState.textLayoutResult
96+
?.multiParagraph
97+
?.getBoundingBox(span.textRange.start)
98+
println("Position: ${position}")
99+
spellCheckExpanded = position
100+
}
95101
}
102+
)
103+
104+
DropdownMenu(
105+
expanded = spellCheckExpanded != null,
106+
onDismissRequest = { spellCheckExpanded = null },
107+
offset = DpOffset(
108+
x = spellCheckExpanded?.left?.dp ?: 0.dp,
109+
y = spellCheckExpanded?.top?.dp ?: 0.dp,
110+
),
111+
) {
112+
DropdownMenuItem(
113+
text = { Text("Spelling") },
114+
onClick = {}
115+
)
116+
117+
DropdownMenuItem(
118+
text = { Text("Spelling") },
119+
onClick = {}
120+
)
96121
}
97-
)
122+
123+
}
98124
}
99125

100126
item {

0 commit comments

Comments
 (0)