Skip to content

Commit

Permalink
feat(HtmlFileController): 1.17 Preview HTML File | 预览 HTML 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
LinWanCen committed Sep 1, 2024
1 parent cf4d3f4 commit 2930947
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## [1.0.0]

- 1.17 Preview HTML File
- 1.16 ★ method call graph
- 1.15 Support .puml and navigate to class_method
- 1.14 Maven dependencies graph include/exclude
Expand All @@ -25,6 +26,7 @@

# 中文更新日志

- 1.17 预览 HTML 文件
- 1.16 ★ 方法调用图
- 1.15 支持 .puml 文件和跳转 class_method
- 1.14 Maven 关系图 包含排除
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.linwancen.drawgraph
pluginName = draw-graph
pluginRepositoryUrl = https://github.com/LinWanCen/draw-graph
# SemVer format -> https://semver.org
pluginVersion = 1.16
pluginVersion = 1.17

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# Support JavaFx
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.github.linwancen.plugin.graph.ui

import com.intellij.openapi.application.runInEdt
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiManager

object HtmlFileController {

@JvmStatic
fun html(project: Project, window: GraphWindow, files: Array<VirtualFile>) {
if (files.size == 1 && files[0].name.endsWith(".html")) {
DumbService.getInstance(project).runReadActionInSmartMode {
val psiFile = PsiManager.getInstance(project).findFile(files[0])
?: return@runReadActionInSmartMode
runInEdt {
val htmlSrc = psiFile.text
window.toolWindow.activate(null)
if (htmlSrc == window.plantumlHtml.text) {
return@runInEdt
}
window.plantumlHtml.text = htmlSrc
if (window.plantumlBrowser != null) window.plantumlBrowser?.load(htmlSrc)
window.mermaidHtml.text = htmlSrc
if (window.mermaidBrowser != null) window.mermaidBrowser?.load(htmlSrc)
window.graphvizHtml.text = htmlSrc
if (window.graphvizBrowser != null) window.graphvizBrowser?.load(htmlSrc)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ object RelController {
}
if (relData.itemMap.isEmpty()) {
PlantUmlFileController.plantUml(project, window, files)
HtmlFileController.html(project, window, files)
return@executeOnPooledThread
}
RelDataController.dataToWindow(project, window, relData)
Expand Down

0 comments on commit 2930947

Please sign in to comment.