Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,26 @@ publishing {
}
}

signing {
useInMemoryPgpKeys(
System.getenv("OSSRH_GPG_SECRET_KEY_ID"),
System.getenv("OSSRH_GPG_SECRET_KEY"),
System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD"),
)
sign(publishing.publications)
val signingKeyId = System.getenv("OSSRH_GPG_SECRET_KEY_ID")
val signingKey = System.getenv("OSSRH_GPG_SECRET_KEY")
val signingPassword = System.getenv("OSSRH_GPG_SECRET_KEY_PASSWORD")
val hasSigning = !signingKey.isNullOrBlank() && !signingPassword.isNullOrBlank()

if (hasSigning) {
signing {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications)
}
} else {
// JitPack / CI builds usually do not have signing keys. Disable signing tasks.
tasks.withType(Sign::class.java).configureEach {
enabled = false
}
}

// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
dependsOn(project.tasks.withType(Sign::class.java))
}
if (hasSigning) {
dependsOn(project.tasks.withType(Sign::class.java))
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ org.gradle.java.installations.auto-download=true

#Kotlin
kotlin.code.style=official
kotlin.js.node.version=18.19.1

#Android
android.useAndroidX=true
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
22 changes: 14 additions & 8 deletions richeditor-compose-coil3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ plugins {
id("module.publication")
}

// JitPack build images can ship with an older GLIBC.
// Kotlin/JS downloads a Node.js binary that may not run there, so we skip JS/WASM targets on JitPack.
val isJitPack = System.getenv("JITPACK") != null

kotlin {
explicitApi()
applyDefaultHierarchyTemplate()
Expand All @@ -30,14 +34,16 @@ kotlin {
}
}

js(IR) {
browser()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser {
testTask {
enabled = false
if (!isJitPack) {
js(IR) {
browser()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser {
testTask {
enabled = false
}
}
}
}
Expand Down
20 changes: 14 additions & 6 deletions richeditor-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ plugins {
id("module.publication")
}

// JitPack build images can ship with an older GLIBC.
// Kotlin/JS downloads a Node.js binary that may not run there.
// We skip JS/WASM targets on JitPack to keep the Android/Desktop publications working.
val isJitPack = System.getenv("JITPACK") != null

kotlin {
explicitApi()
applyDefaultHierarchyTemplate()
Expand All @@ -31,12 +36,15 @@ kotlin {
}
}

js(IR).browser()
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser {
testTask {
enabled = false
if (!isJitPack) {
js(IR).browser()

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser {
testTask {
enabled = false
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.mohamedrejeb.richeditor.ui

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.ui.platform.TextToolbar
import androidx.compose.ui.platform.TextToolbarStatus

@Composable
internal actual fun ProvideNoSelectionToolbar(
disableSelectionToolbar: Boolean,
content: @Composable () -> Unit,
) {
if (!disableSelectionToolbar) {
content()
return
}

val noToolbar: TextToolbar = remember {
object : TextToolbar {
override val status: TextToolbarStatus = TextToolbarStatus.Hidden
override fun hide() = Unit
override fun showMenu(
rect: androidx.compose.ui.geometry.Rect,
onCopyRequested: (() -> Unit)?,
onPasteRequested: (() -> Unit)?,
onCutRequested: (() -> Unit)?,
onSelectAllRequested: (() -> Unit)?,
) = Unit
}
}

CompositionLocalProvider(LocalTextToolbar provides noToolbar) {
content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public fun BasicRichTextEditor(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
cursorBrush: Brush = SolidColor(Color.Black),
decorationBox: @Composable (innerTextField: @Composable () -> Unit) -> Unit =
@Composable { innerTextField -> innerTextField() }
@Composable { innerTextField -> innerTextField() },
disableSelectionToolbar: Boolean = false
) {
BasicRichTextEditor(
state = state,
Expand All @@ -116,7 +117,8 @@ public fun BasicRichTextEditor(
interactionSource = interactionSource,
cursorBrush = cursorBrush,
decorationBox = decorationBox,
contentPadding = PaddingValues()
contentPadding = PaddingValues(),
disableSelectionToolbar = disableSelectionToolbar
)
}

Expand Down Expand Up @@ -192,7 +194,8 @@ public fun BasicRichTextEditor(
cursorBrush: Brush = SolidColor(Color.Black),
decorationBox: @Composable (innerTextField: @Composable () -> Unit) -> Unit =
@Composable { innerTextField -> innerTextField() },
contentPadding: PaddingValues
contentPadding: PaddingValues,
disableSelectionToolbar: Boolean = false
) {
val density = LocalDensity.current
val layoutDirection = LocalLayoutDirection.current
Expand Down Expand Up @@ -229,8 +232,9 @@ public fun BasicRichTextEditor(
}
}

CompositionLocalProvider(LocalClipboardManager provides richClipboardManager) {
BasicTextField(
CompositionLocalProvider(LocalClipboardManager provides richClipboardManager) {
ProvideNoSelectionToolbar(disableSelectionToolbar = disableSelectionToolbar) {
BasicTextField(
value = state.textFieldValue,
onValueChange = {
if (readOnly) return@BasicTextField
Expand Down Expand Up @@ -291,6 +295,8 @@ public fun BasicRichTextEditor(
cursorBrush = cursorBrush,
decorationBox = decorationBox,
)

}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mohamedrejeb.richeditor.ui

import androidx.compose.runtime.Composable

/**
* Platform hook used to disable the system text selection toolbar (ActionMode: cut/copy/paste)
* when [disableSelectionToolbar] is true.
*
* Implemented per-platform to avoid referencing Android-only APIs from common code.
*/
@Composable
internal expect fun ProvideNoSelectionToolbar(
disableSelectionToolbar: Boolean,
content: @Composable () -> Unit,
)
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public fun OutlinedRichTextEditor(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = RichTextEditorDefaults.outlinedShape,
colors: RichTextEditorColors = RichTextEditorDefaults.outlinedRichTextEditorColors(),
disableSelectionToolbar: Boolean = false,
contentPadding: PaddingValues = RichTextEditorDefaults.outlinedRichTextEditorPadding(),
) {
// If color is not provided via the text style, use content color as a default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public fun RichTextEditor(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = RichTextEditorDefaults.filledShape,
colors: RichTextEditorColors = RichTextEditorDefaults.richTextEditorColors(),
disableSelectionToolbar: Boolean = false,
contentPadding: PaddingValues =
if (label == null) {
RichTextEditorDefaults.richTextEditorWithoutLabelPadding()
Expand Down Expand Up @@ -142,6 +143,7 @@ public fun RichTextEditor(
onTextLayout = onTextLayout,
interactionSource = interactionSource,
cursorBrush = SolidColor(colors.cursorColor(isError).value),
disableSelectionToolbar = disableSelectionToolbar,
decorationBox = @Composable { innerTextField ->
// places leading icon, text field with label and placeholder, trailing icon
RichTextEditorDefaults.RichTextEditorDecorationBox(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mohamedrejeb.richeditor.ui

import androidx.compose.runtime.Composable

@Composable
internal actual fun ProvideNoSelectionToolbar(
disableSelectionToolbar: Boolean,
content: @Composable () -> Unit,
) {
// No platform selection toolbar (ActionMode) available on this target.
content()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mohamedrejeb.richeditor.ui

import androidx.compose.runtime.Composable

@Composable
internal actual fun ProvideNoSelectionToolbar(
disableSelectionToolbar: Boolean,
content: @Composable () -> Unit,
) {
// No platform selection toolbar (ActionMode) available on this target.
content()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mohamedrejeb.richeditor.ui

import androidx.compose.runtime.Composable

@Composable
internal actual fun ProvideNoSelectionToolbar(
disableSelectionToolbar: Boolean,
content: @Composable () -> Unit,
) {
// No platform selection toolbar (ActionMode) available on this target.
content()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mohamedrejeb.richeditor.ui

import androidx.compose.runtime.Composable

@Composable
internal actual fun ProvideNoSelectionToolbar(
disableSelectionToolbar: Boolean,
content: @Composable () -> Unit,
) {
// No platform selection toolbar (ActionMode) available on this target.
content()
}
16 changes: 11 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}

val isJitPack = System.getenv("JITPACK") != null

include(
":richeditor-compose",
":richeditor-compose-coil3",

":sample:android",
":sample:desktop",
":sample:web",
":sample:common",
)

if (!isJitPack) {
include(
":sample:android",
":sample:desktop",
":sample:web",
":sample:common",
)
}