mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
[feat] update some feature
sync code of fastrtc, add text support through datachannel, fix safari connect problem support chat without camera or mic
This commit is contained in:
28
frontend/shared/VideoChat/utils.ts
Normal file
28
frontend/shared/VideoChat/utils.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export function click_outside(node: Node, cb: any): any {
|
||||
const handle_click = (event: MouseEvent): void => {
|
||||
if (
|
||||
node &&
|
||||
!node.contains(event.target as Node) &&
|
||||
!event.defaultPrevented
|
||||
) {
|
||||
cb(event);
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("click", handle_click, true);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
document.removeEventListener("click", handle_click, true);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function insertStringAt(rawStr: string, insertString: string, index: number) {
|
||||
if (index < 0 || index > rawStr.length) {
|
||||
console.error("索引超出范围");
|
||||
return rawStr;
|
||||
}
|
||||
|
||||
return rawStr.substring(0, index) + insertString + rawStr.substring(index);
|
||||
}
|
||||
Reference in New Issue
Block a user