Skip to content

Commit

Permalink
feat(docs): update documentation and add WebView functionality
Browse files Browse the repository at this point in the history
Update the documentation in `on-streaming-done.md` to correct capitalization and formatting. Add a new `showWebView` functionality in `WebViewWindow.kt` and `ShowWebviewProcessor.kt` to display a WebView. Replace `Component` with `JComponent` in `WebViewWindow.kt` for better compatibility.
  • Loading branch information
phodal committed Sep 19, 2024
1 parent 6a3ddb4 commit 15b5a4c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.MessageType
import com.intellij.openapi.ui.popup.Balloon
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.ui.dsl.builder.panel
import com.intellij.util.ui.JBUI
import com.phodal.shirecore.middleware.PostProcessor
import com.phodal.shirecore.middleware.PostProcessorContext
import com.phodal.shirecore.middleware.PostProcessorType
import com.phodal.shirecore.middleware.builtin.ui.WebViewWindow
import java.awt.Dimension

class ShowWebviewProcessor : PostProcessor {
override val processorName: String get() = PostProcessorType.ShowWebview.handleName
Expand All @@ -25,12 +29,15 @@ class ShowWebviewProcessor : PostProcessor {
?: throw IllegalStateException("No data context")

runInEdt {
val popupLocation = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext)
JBPopupFactory.getInstance()
.createHtmlTextBalloonBuilder(html ?: "", MessageType.INFO, null)
.setFadeoutTime(3000)
.createBalloon()
.show(popupLocation, Balloon.Position.above)
val component = WebViewWindow().apply { loadHtml(html ?: "") }.component

val popup = JBPopupFactory.getInstance()
.createComponentPopupBuilder(component, null)
.setMinSize(Dimension(JBUI.scale(640), JBUI.scale(320)))
.setRequestFocus(true)
.createPopup()

popup.showInBestPositionFor(dataContext)
}

return ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.phodal.shirecore.middleware.builtin.ui

import com.intellij.ui.JBColor
import com.intellij.ui.jcef.JBCefBrowser
import java.awt.Component
import javax.swing.JComponent

/**
* WebViewWindow is a class that provides a custom webview functionality. It allows developers to
Expand All @@ -25,7 +25,7 @@ class WebViewWindow {
browser.component.background = JBColor.WHITE
}

val component: Component = browser.component
val component: JComponent = browser.component

fun loadHtml(html: String) {
browser.loadHTML(html)
Expand Down
39 changes: 20 additions & 19 deletions docs/lifecycle/on-streaming-done.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,31 @@ nav_order: 5

| 后处理器 | 描述 |
|-------------------|------------------|
| Logging | 记录操作日志。 |
| TimeMetric | 记录操作耗时。 |
| AcceptanceMetric | 接受度指标。 |
| VerifyCode | 检查代码错误或 PSI 问题。 |
| RunCode | 运行生成的文本代码。 |
| ParseCode | 将文本解析为代码块。 |
| InferCodeLocation | 推断代码位置。 |
| SaveFile | 将文件保存到磁盘。 |
| OpenFile | 在编辑器中打开文件。 |
| InsertCode | 在当前光标位置插入代码。 |
| FormatCode | 格式化代码。 |
| ParseComment | 解析注释为注释块。 |
| InsertNewline | 插入新行。 |
| Append | 将文本追加到文件中。 |
| UpdateEditorText | 更新编辑器文本。 |
| Patch | 打补丁。 |
| Diff | 生成 diff view 对比。 |
| OpenWebpage | 打开网页。 |
| logging | 记录操作日志。 |
| timeMetric | 记录操作耗时。 |
| acceptanceMetric | 接受度指标。 |
| verifyCode | 检查代码错误或 PSI 问题。 |
| runCode | 运行生成的文本代码。 |
| parseCode | 将文本解析为代码块。 |
| inferCodeLocation | 推断代码位置。 |
| saveFile | 将文件保存到磁盘。 |
| openFile | 在编辑器中打开文件。 |
| insertCode | 在当前光标位置插入代码。 |
| formatCode | 格式化代码。 |
| parseComment | 解析注释为注释块。 |
| insertNewline | 插入新行。 |
| append | 将文本追加到文件中。 |
| updateEditorText | 更新编辑器文本。 |
| patch | 打补丁。 |
| diff | 生成 diff view 对比。 |
| openWebpage | 打开网页。 |
| showWebView | 显示 WebView。 |

最新版本见源码:com.phodal.shirecore.middleware.PostProcessorType

## 示例

### Hello, world 示例
### Hello, world 示例

```shire
---
Expand Down

0 comments on commit 15b5a4c

Please sign in to comment.