mirror of
https://github.com/open-webui/open-webui
synced 2024-11-07 00:59:52 +00:00
enh: iframe message event listener
This commit is contained in:
parent
37a052327a
commit
bc73cb1390
@ -50,6 +50,33 @@
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.origin === window.origin) {
|
||||
// Replace with your iframe's origin
|
||||
console.log('Message received from iframe:', event.data);
|
||||
if (event.data.type === 'input:prompt') {
|
||||
console.log(event.data.text);
|
||||
|
||||
const inputElement = document.getElementById('chat-textarea');
|
||||
|
||||
if (inputElement) {
|
||||
inputElement.value = event.data.text;
|
||||
inputElement.focus();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.data.type === 'action:submit-prompt') {
|
||||
console.log(event.data.text);
|
||||
|
||||
const submitButtonElement = document.getElementById('send-message-button');
|
||||
|
||||
if (submitButtonElement) {
|
||||
submitButtonElement.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
const setWakeLock = async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user