diff --git a/buildSrc/src/main/kotlin/Setup.kt b/buildSrc/src/main/kotlin/Setup.kt index 51a6b0f..c7da958 100644 --- a/buildSrc/src/main/kotlin/Setup.kt +++ b/buildSrc/src/main/kotlin/Setup.kt @@ -47,7 +47,7 @@ fun Project.setup( configure(KotlinMultiplatform(JavadocJar.Empty())) } publishToMavenCentral(SonatypeHost.S01, automaticRelease = true) - signAllPublications() +// signAllPublications() coordinates("xyz.wingio.syntakts", moduleName, System.getenv("LIBRARY_VERSION") ?: version.toString()) diff --git a/syntakts-compose/src/commonMain/kotlin/xyz/wingio/syntakts/compose/Syntakts.kt b/syntakts-compose/src/commonMain/kotlin/xyz/wingio/syntakts/compose/Syntakts.kt index 5848639..82e9177 100644 --- a/syntakts-compose/src/commonMain/kotlin/xyz/wingio/syntakts/compose/Syntakts.kt +++ b/syntakts-compose/src/commonMain/kotlin/xyz/wingio/syntakts/compose/Syntakts.kt @@ -58,13 +58,44 @@ public fun Syntakts.render(text: String, context: C, builder: AnnotatedSt /** * Remember the rendered text, only updates when either [text] or [context] updates * + * @see [rememberAsyncRendered] + * * @param text What to parse and render * @param context Additional information that nodes may need to render * @return [AnnotatedString] - The final rendered text to be used on a Text component */ @Composable public fun Syntakts.rememberRendered(text: String, context: C): AnnotatedString { - var parsedText by remember { mutableStateOf(AnnotatedString("")) } + val builder = remember { AnnotatedStyledTextBuilder() } + + LaunchedEffect(text, context) { + builder.clear() + ClickHandlerStore.clearForBuilder(builder.id) + } + + DisposableEffect(Unit) { + onDispose { + ClickHandlerStore.clearForBuilder(builder.id) + } + } + + return remember(text, context) { + render(text, context, builder) + } +} + +/** + * Remember the rendered text, only updates when either [text] or [context] updates + * --- + * This will do the text parsing in a separate thread and update the text when the rendering finishes + * + * @param text What to parse and render + * @param context Additional information that nodes may need to render + * @return [AnnotatedString] - The final rendered text to be used on a Text component + */ +@Composable +public fun Syntakts.rememberAsyncRendered(text: String, context: C): AnnotatedString { + var parsedText by remember { mutableStateOf(AnnotatedString(text)) } val builder = remember { AnnotatedStyledTextBuilder() } LaunchedEffect(text, context) {