Skip to content

Commit 77806ab

Browse files
committed
chore: bump plugin version to 2.0.0-rc.5
- Update plugin version in gradle.properties. - Remove unnecessary editor disposal in DiffLangSketch. - Enhance MarkdownViewer styling with improved CSS rules. - Refactor SingleFileDiffSketch to use runInEdt for thread safety.
1 parent a98420b commit 77806ab

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code/MarkdownViewer.kt

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,53 @@ object MarkdownViewer {
1515
jEditorPane.setContentType("text/html")
1616
val htmlEditorKit = HTMLEditorKitBuilder().build()
1717

18-
// val backgroundColor = UIUtil.getPanelBackground()
19-
//
20-
// val editorFontName = EditorColorsManager.getInstance().schemeForCurrentUITheme.editorFontName
21-
// val editorFontSize = EditorColorsManager.getInstance().schemeForCurrentUITheme.editorFontSize
22-
// val fontFamilyAndSize = "font-family:'" + editorFontName + "'; font-size:" + editorFontSize + "pt;"
18+
val backgroundColor = UIUtil.getPanelBackground()
19+
val backgroundColorHex = ColorUtil.toHex(backgroundColor)
2320

24-
htmlEditorKit.getStyleSheet().addRule("code { background-color: #fff; }")
25-
htmlEditorKit.getStyleSheet().addRule("p { margin-top: 1px }")
21+
val editorFontName = EditorColorsManager.getInstance().schemeForCurrentUITheme.editorFontName
22+
val editorFontSize = EditorColorsManager.getInstance().schemeForCurrentUITheme.editorFontSize
23+
val fontFamilyAndSize = "font-family:'" + editorFontName + "'; font-size:" + editorFontSize + "pt;"
2624

25+
val cssRules = """
26+
body { $fontFamilyAndSize margin: 8px; line-height: 1.5; }
27+
p { margin-top: 0.8em; margin-bottom: 0.8em; }
28+
29+
/* Headings */
30+
h1 { font-size: 1.6em; margin-top: 1em; margin-bottom: 0.6em; font-weight: bold; }
31+
h2 { font-size: 1.4em; margin-top: 0.9em; margin-bottom: 0.5em; font-weight: bold; }
32+
h3 { font-size: 1.2em; margin-top: 0.8em; margin-bottom: 0.4em; font-weight: bold; }
33+
h4, h5, h6 { font-size: 1.1em; margin-top: 0.7em; margin-bottom: 0.3em; font-weight: bold; }
34+
35+
/* Code blocks */
36+
pre { background-color: #f5f5f5; border-radius: 4px; padding: 8px; overflow-x: auto; margin: 1em 0; }
37+
code { font-family: 'JetBrains Mono', Consolas, monospace; background-color: #f5f5f5; padding: 2px 4px; border-radius: 3px; font-size: 0.9em; }
38+
39+
/* Lists */
40+
ul, ol { margin-top: 0.5em; margin-bottom: 0.5em; padding-left: 2em; }
41+
li { margin: 0.3em 0; }
42+
43+
/* Blockquotes */
44+
blockquote { border-left: 4px solid #ddd; padding-left: 1em; margin-left: 0; margin-right: 0; color: #777; }
45+
46+
/* Tables */
47+
table { border-collapse: collapse; width: 100%; margin: 1em 0; }
48+
th, td { border: 1px solid #ddd; padding: 6px; text-align: left; }
49+
th { background-color: #f2f2f2; }
50+
51+
/* Links */
52+
a { color: #2196F3; text-decoration: none; }
53+
a:hover { text-decoration: underline; }
54+
55+
/* Horizontal rule */
56+
hr { border: 0; height: 1px; background-color: #ddd; margin: 1em 0; }
57+
58+
/* Inline elements */
59+
strong, b { font-weight: bold; }
60+
em, i { font-style: italic; }
61+
""".trimIndent()
62+
63+
htmlEditorKit.styleSheet.addRule(cssRules)
64+
2765
jEditorPane.also {
2866
it.editorKit = htmlEditorKit
2967
it.isEditable = false
@@ -45,5 +83,4 @@ object MarkdownViewer {
4583
jEditorPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
4684
return jEditorPane
4785
}
48-
49-
}
86+
}

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/DiffLangSketch.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,6 @@ fun showSingleDiff(project: Project, patchContent: String, disposable: Disposabl
228228
val virtualFile = LightVirtualFile("AutoDev-Diff-Lang.diff", patchContent)
229229
val editor = editorProvider.createEditor(project, virtualFile)
230230

231-
disposable.whenDisposed {
232-
editor.dispose()
233-
}
234-
235231
object : DialogWrapper(project) {
236232
init {
237233
title = "Diff Preview"

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/SingleFileDiffSketch.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.intellij.lang.Language
1212
import com.intellij.lang.annotation.HighlightSeverity
1313
import com.intellij.openapi.application.ApplicationManager
1414
import com.intellij.openapi.application.WriteAction
15+
import com.intellij.openapi.application.runInEdt
1516
import com.intellij.openapi.application.runReadAction
1617
import com.intellij.openapi.application.runWriteAction
1718
import com.intellij.openapi.command.CommandProcessor
@@ -171,8 +172,10 @@ class SingleFileDiffSketch(
171172
null
172173
}
173174

174-
WriteAction.compute<Unit, Throwable> {
175-
currentFile.writeText(fixedCode)
175+
runInEdt {
176+
WriteAction.compute<Unit, Throwable> {
177+
currentFile.writeText(fixedCode)
178+
}
176179
}
177180

178181
createActionButtons(currentFile, appliedPatch, patch).let { actions ->
@@ -220,6 +223,8 @@ class SingleFileDiffSketch(
220223

221224
if (file is DiffVirtualFileBase) {
222225
FileEditorManager.getInstance(myProject).closeFile(file)
226+
} else{
227+
FileEditorManager.getInstance(myProject).openFile(file, true)
223228
}
224229
}
225230
}, "ApplyPatch", null)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pluginGroup = com.phodal.autodev
77
pluginName = AutoDev
88
pluginRepositoryUrl = https://github.com/unit-mesh/auto-dev
99
# SemVer format -> https://semver.org
10-
pluginVersion = 2.0.0-rc.4
10+
pluginVersion = 2.0.0-rc.5
1111

1212
# Supported IDEs: idea, pycharm
1313
baseIDE=idea

0 commit comments

Comments
 (0)