@Slf4j
public class ChatWindow implements DumbAware, ToolWindowFactory {
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
Content content = ContentFactory.getInstance()
.createContent(browser.getComponent(), "", false);
ContentManager contentManager = toolWindow.getContentManager();
contentManager.addContent(content);
@Slf4j
public class ChatBrowser extends JBCefBrowser implements Disposable {
public ChatBrowser(Project project) {
super(createBuilder()
.setEnableOpenDevToolsMenuItem(true)
.setOffScreenRendering(false));
loadHTML(SIMPLE_INPUT_HTML);
public static String SIMPLE_INPUT_HTML = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
html,
body,
div,
p,
iframe {
background: transparent;
padding: 0;
margin: 0;
box-sizing: border-box;
overflow: hidden;
}
#message {
display: flex;
justify-content: center;
align-items: flex-start;
font-family: ui-sans-serif, system-ui;
}
#message div {
width: 100%;
max-width: 300px;
color: hsl(var(--foreground));
}
#message a {
color: hsl(var(--primary));
}
#message div {
margin: 16px;
}
#message div p {
margin: 8px 0;
}
iframe {
border-width: 0;
width: 100%;
height: 100vh;
}
</style>
</head>
<body>
<iframe id="chat" style="overflow: auto;"></iframe>
<script>
// // 在内层 iframe 里写一个输入框
// const innerDoc = document.getElementById("chat").contentWindow.document;
// innerDoc.open();
// innerDoc.write(`
// <!DOCTYPE html>
// <html lang="en">
// <head><meta charset="UTF-8"></head>
// <body>
// <input type="text" placeholder="请输入内容" style="width:90%;margin:10px;">
// </body>
// </html>
// `);
// innerDoc.close();
function getChatPanel() {
return document.getElementById("chat");
}
function loadChatPanel(url) {
const chat = getChatPanel();
chat.src = url;
}
</script>
</body>
</html>
""";
String script = "loadChatPanel('https://www.baidu.com/')";
executeJs(script);
public void executeJs(String script) {
this.getCefBrowser().executeJavaScript(script, this.getCefBrowser().getURL(), 0);
}
In Java plugin development, why can't this webpage embedded with iframe input Chinese? Moreover, it can't be input in idea2025.1 version and later, but it worked before. I hope to find a solution. Thank you