[jewel] Removed Compose UI Inspector and newer features from Markdown Preview

(cherry picked from commit 82b95915621a1348bdd822006dd17157d6b28e0b)

IJ-MR-155570

GitOrigin-RevId: 8e14a99ca100624ea538c15399c7a6ed844d5051
This commit is contained in:
Jakub Senohrabek
2025-02-26 13:25:36 +01:00
committed by intellij-monorepo-bot
parent ea1a4dce93
commit ec4e28bd29
24 changed files with 36 additions and 93 deletions

View File

@@ -10,6 +10,8 @@
/>
</extensions>
<dependencies>
<module name="intellij.libraries.skiko"/>
<module name="intellij.libraries.compose.foundation.desktop"/>
<module name="intellij.platform.jewel.foundation" />
<module name="intellij.platform.jewel.ui" />
<module name="intellij.platform.jewel.ideLafBridge" />

View File

@@ -17,7 +17,5 @@ fun JBComposePanel(
if (ApplicationManager.getApplication().isInternal) {
System.setProperty("compose.swing.render.on.graphics", Registry.stringValue("compose.swing.render.on.graphics"))
}
return JewelComposePanel { content() }.apply {
ComposeUiInspector(this)
}
return JewelComposePanel { content() }
}

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -14,9 +14,7 @@
</stringArguments>
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
</args>
<args>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</args>
</arrayArg>
</arrayArguments>
</compilerArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -16,6 +16,7 @@ import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.intui.markdown.bridge.styling.create
import org.jetbrains.jewel.markdown.MarkdownMode
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownBlockRenderer
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownMode
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownProcessor
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownStyling
import org.jetbrains.jewel.markdown.processing.MarkdownProcessor
@@ -36,6 +37,7 @@ public fun ProvideMarkdownStyling(
) {
CompositionLocalProvider(
LocalMarkdownStyling provides markdownStyling,
LocalMarkdownMode provides markdownMode,
LocalMarkdownProcessor provides markdownProcessor,
LocalMarkdownBlockRenderer provides markdownBlockRenderer,
LocalCodeHighlighter provides codeHighlighter,
@@ -61,6 +63,7 @@ public fun ProvideMarkdownStyling(
ProvideMarkdownStyling(
themeName = themeName,
markdownStyling = markdownStyling,
markdownMode = markdownMode,
markdownProcessor = markdownProcessor,
markdownBlockRenderer = markdownBlockRenderer,
codeHighlighter = codeHighlighter,

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -6,8 +6,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.intui.standalone.theme.dark
import org.jetbrains.jewel.intui.standalone.theme.light
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableColors
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableMetrics
import org.jetbrains.jewel.markdown.extensions.github.tables.GfmTableStyling

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -14,7 +14,7 @@
</stringArguments>
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</args>
<args>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</args>
</arrayArg>
</arrayArguments>
</compilerArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -15,7 +15,7 @@
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.10/kotlin-compose-compiler-plugin-2.1.10.jar</arg>
<arg>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</arg>
</args>
</arrayArg>
</arrayArguments>

View File

@@ -14,7 +14,7 @@
</stringArguments>
<arrayArguments>
<arrayArg name="pluginClasspaths">
<args>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.1.0/kotlin-compose-compiler-plugin-2.1.0.jar</args>
<args>$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-compose-compiler-plugin/2.0.21/kotlin-compose-compiler-plugin-2.0.21.jar</args>
</arrayArg>
</arrayArguments>
</compilerArguments>
@@ -34,9 +34,7 @@
<orderEntry type="module" module-name="intellij.markdown" />
<orderEntry type="module" module-name="intellij.platform.compose" />
<orderEntry type="module" module-name="intellij.libraries.compose.foundation.desktop" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.util.ui" />
<orderEntry type="module" module-name="intellij.platform.ide" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.ideLafBridgeStyling" />
<orderEntry type="module" module-name="intellij.platform.jewel.markdown.extension.gfmTables" />
</component>
</module>

View File

@@ -7,8 +7,6 @@ import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.vfs.VirtualFile
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanel
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider.AvailabilityInfo
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider.ProviderInfo
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
@OptIn(ExperimentalJewelApi::class)

View File

@@ -1,50 +1,37 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.markdown.compose.preview
import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.TweenSpec
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.intellij.ide.BrowserUtil
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.UserDataHolder
import com.intellij.openapi.util.UserDataHolderBase
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.platform.compose.JBComposePanel
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.launch
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanel
import org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelEx
import org.intellij.plugins.markdown.ui.preview.MarkdownUpdateHandler
import org.intellij.plugins.markdown.ui.preview.MarkdownUpdateHandler.PreviewRequest
import org.intellij.plugins.markdown.ui.preview.PreviewStyleScheme
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.jewel.bridge.code.highlighting.CodeHighlighterFactory
import org.jetbrains.jewel.bridge.toComposeColor
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
import org.jetbrains.jewel.foundation.code.highlighting.NoOpCodeHighlighter
import org.jetbrains.jewel.intui.markdown.bridge.ProvideMarkdownStyling
import org.jetbrains.jewel.markdown.Markdown
import org.jetbrains.jewel.markdown.MarkdownMode
import org.jetbrains.jewel.markdown.rendering.DefaultInlineMarkdownRenderer
import org.jetbrains.jewel.markdown.scrolling.ScrollSyncMarkdownBlockRenderer
import org.jetbrains.jewel.markdown.scrolling.ScrollingSynchronizer
import javax.swing.JComponent
import kotlin.time.Duration.Companion.milliseconds
@ExperimentalJewelApi
internal class MarkdownComposePanel(
class MarkdownComposePanel(
private val project: Project?,
private val virtualFile: VirtualFile?,
private val updateHandler: MarkdownUpdateHandler = MarkdownUpdateHandler.Debounced()
@@ -52,8 +39,6 @@ internal class MarkdownComposePanel(
constructor() : this(null, null)
private val scrollToLineFlow = MutableSharedFlow<Int>(replay = 1)
private val panelComponent by lazy {
JBComposePanel {
// TODO temporary styling, we will likely need our own in the future for JCEF-like rendering
@@ -66,26 +51,16 @@ internal class MarkdownComposePanel(
private fun MarkdownPanel() {
val scheme = PreviewStyleScheme.fromCurrentTheme()
val fontSize = scheme.fontSize.sp / scheme.scale
val scrollState = rememberScrollState(0)
val scrollingSynchronizer = remember(scrollState) { ScrollingSynchronizer.create(scrollState) }
val markdownStyling = JcefLikeMarkdownStyling(scheme, fontSize)
val blockRenderer = ScrollSyncMarkdownBlockRenderer(markdownStyling, emptyList(), DefaultInlineMarkdownRenderer(emptyList()))
ProvideMarkdownStyling(
markdownMode = MarkdownMode.EditorPreview(scrollingSynchronizer),
markdownStyling = markdownStyling,
codeHighlighter = remember(project) {
project?.let {
CodeHighlighterFactory.getInstance(project).createHighlighter()
} ?: NoOpCodeHighlighter
},
markdownBlockRenderer = blockRenderer
markdownStyling = JcefLikeMarkdownStyling(scheme, fontSize),
) {
Box(
modifier = Modifier
.background(scheme.backgroundColor.toComposeColor())
.padding(horizontal = fontSize.value.dp * 2)
) {
MarkdownPreviewPanel(scrollState, scrollingSynchronizer, blockRenderer)
val scrollState = rememberScrollState(0)
MarkdownPreviewPanel(scrollState)
VerticalScrollbar(
modifier = Modifier
.align(Alignment.CenterEnd),
@@ -95,33 +70,11 @@ internal class MarkdownComposePanel(
}
}
@OptIn(FlowPreview::class)
@Suppress("FunctionName")
@Composable
private fun MarkdownPreviewPanel(scrollState: ScrollState,
scrollingSynchronizer: ScrollingSynchronizer?,
blockRenderer: ScrollSyncMarkdownBlockRenderer,
animationSpec: AnimationSpec<Float> = TweenSpec(easing = LinearEasing)
) {
private fun MarkdownPreviewPanel(scrollState: ScrollState) {
val request by updateHandler.requests.collectAsState(null)
(request as? PreviewRequest.Update)?.let {
if (scrollingSynchronizer != null) {
val coroutineScope = rememberCoroutineScope()
LaunchedEffect(Unit) {
coroutineScope.launch {
scrollToLineFlow.debounce(16.milliseconds).collect { scrollToLine ->
scrollingSynchronizer.scrollToLine(scrollToLine, animationSpec)
}
}
}
LaunchedEffect(it.initialScrollOffset) {
coroutineScope.launch {
if (it.initialScrollOffset != 0) {
scrollToLineFlow.emit(it.initialScrollOffset)
}
}
}
}
Markdown(
it.content,
modifier = Modifier
@@ -130,16 +83,12 @@ internal class MarkdownComposePanel(
enabled = true,
selectable = true,
onUrlClick = { url -> BrowserUtil.open(url) },
blockRenderer = blockRenderer,
)
}
}
override fun setHtml(html: String, initialScrollOffset: Int, document: VirtualFile?) {
}
override fun setHtml(html: String, initialScrollOffset: Int, initialScrollLineNumber: Int, document: VirtualFile?) {
updateHandler.setContent(html, initialScrollLineNumber, document)
updateHandler.setContent(html, initialScrollOffset, document)
}
override fun reloadWithOffset(offset: Int) {
@@ -165,8 +114,7 @@ internal class MarkdownComposePanel(
override fun removeScrollListener(listener: MarkdownHtmlPanel.ScrollListener) {
}
override suspend fun scrollTo(editor: Editor, line: Int) {
scrollToLineFlow.emit(line)
override fun scrollToMarkdownSrcOffset(offset: Int, smooth: Boolean) {
}
override fun scrollBy(horizontalUnits: Int, verticalUnits: Int) {