1
1
package cc.unitmesh.devti.sketch.ui.code
2
2
3
+ import com.intellij.openapi.editor.colors.EditorColorsManager
3
4
import com.intellij.openapi.util.text.StringUtil
4
5
import com.intellij.temporary.gui.block.LineSpacingExtension
6
+ import com.intellij.ui.BrowserHyperlinkListener
7
+ import com.intellij.ui.ColorUtil
5
8
import com.intellij.util.ui.HTMLEditorKitBuilder
9
+ import com.intellij.util.ui.UIUtil
6
10
import javax.swing.JEditorPane
7
11
import javax.swing.text.DefaultCaret
8
12
@@ -15,6 +19,14 @@ object MarkdownViewer {
15
19
LineSpacingExtension (0.2f )
16
20
).build()
17
21
22
+ val backgroundColor = UIUtil .getPanelBackground()
23
+ val schemeForCurrentUITheme = EditorColorsManager .getInstance().schemeForCurrentUITheme
24
+ val editorFontName = schemeForCurrentUITheme.editorFontName
25
+ val editorFontSize = schemeForCurrentUITheme.editorFontSize
26
+ val fontFamilyAndSize =
27
+ " font-family:'" + editorFontName + " '; font-size:" + editorFontSize + " pt;"
28
+ val backgroundColorCss = " background-color: #" + ColorUtil .toHex(backgroundColor) + " ;"
29
+ htmlEditorKit.getStyleSheet().addRule(" code { $backgroundColorCss$fontFamilyAndSize }" )
18
30
htmlEditorKit.getStyleSheet().addRule(" p {margin-top: 1px}" )
19
31
20
32
jEditorPane.also {
@@ -35,6 +47,7 @@ object MarkdownViewer {
35
47
(jEditorPane.caret as ? DefaultCaret )?.updatePolicy = 1
36
48
}
37
49
50
+ jEditorPane.addHyperlinkListener(BrowserHyperlinkListener .INSTANCE );
38
51
return jEditorPane
39
52
}
40
53
0 commit comments