hide broadcast from context menu

This commit is contained in:
Jeff-Emmett 2025-03-05 18:06:22 -05:00
parent 65bf72537f
commit 36a8dfe853
2 changed files with 61 additions and 44 deletions

View File

@ -203,7 +203,7 @@ export function CustomContextMenu(props: TLUiContextMenuProps) {
/> />
<TldrawUiMenuItem <TldrawUiMenuItem
id="Prompt" id="Prompt"
label="Create Prompt" label="Create LLM Chat Prompt"
icon="prompt" icon="prompt"
kbd="alt+p" kbd="alt+p"
disabled={hasSelection} disabled={hasSelection}
@ -245,37 +245,36 @@ export function CustomContextMenu(props: TLUiContextMenuProps) {
))} ))}
</TldrawUiMenuSubmenu> </TldrawUiMenuSubmenu>
</TldrawUiMenuGroup> </TldrawUiMenuGroup>
{/* TODO: FIX & IMPLEMENT BROADCASTING*/}
<TldrawUiMenuGroup id="broadcast-controls"> {/* <TldrawUiMenuGroup id="broadcast-controls">
<TldrawUiMenuItem <TldrawUiMenuItem
id="broadcast-view" id="start-broadcast"
label="Start Broadcasting View" label="Start Broadcasting"
icon="broadcast" icon="broadcast"
kbd="alt+b" kbd="alt+b"
onSelect={() => { onSelect={() => {
const otherUsers = Array.from(editor.store.allRecords()).filter( editor.markHistoryStoppingPoint('start-broadcast')
(record) => editor.updateInstanceState({ isBroadcasting: true })
record.typeName === "instance_presence" && const url = new URL(window.location.href)
record.id !== editor.user.getId(), url.searchParams.set("followId", editor.user.getId())
) window.history.replaceState(null, "", url.toString())
otherUsers.forEach((user) => editor.startFollowingUser(user.id))
}} }}
/> />
<TldrawUiMenuItem <TldrawUiMenuItem
id="stop-broadcast" id="stop-broadcast"
label="Stop Broadcasting View" label="Stop Broadcasting"
icon="broadcast-off" icon="broadcast-off"
kbd="alt+shift+b" kbd="alt+shift+b"
onSelect={() => { onSelect={() => {
const otherUsers = Array.from(editor.store.allRecords()).filter( editor.markHistoryStoppingPoint('stop-broadcast')
(record) => editor.updateInstanceState({ isBroadcasting: false })
record.typeName === "instance_presence" && editor.stopFollowingUser()
record.id !== editor.user.getId(), const url = new URL(window.location.href)
) url.searchParams.delete("followId")
otherUsers.forEach((_user) => editor.stopFollowingUser()) window.history.replaceState(null, "", url.toString())
}} }}
/> />
</TldrawUiMenuGroup> </TldrawUiMenuGroup> */}
<TldrawUiMenuGroup id="search-controls"> <TldrawUiMenuGroup id="search-controls">
<TldrawUiMenuItem <TldrawUiMenuItem

View File

@ -51,25 +51,38 @@ export const overrides: TLUiOverrides = {
}, },
//TODO: Fix double click to zoom on selector tool later... //TODO: Fix double click to zoom on selector tool later...
onDoubleClick: (info: any) => { // onDoubleClick: (info: any) => {
const shape = editor.getShapeAtPoint(info.point) // const shape = editor.getShapeAtPoint(info.point)
if (shape?.type === "Embed") { // if (shape?.type === "Embed") {
// Let the Embed shape handle its own double-click behavior // // Let the Embed shape handle its own double-click behavior
const util = editor.getShapeUtil(shape) as EmbedShape // const util = editor.getShapeUtil(shape) as EmbedShape
util?.onDoubleClick?.(shape as IEmbedShape) // util?.onDoubleClick?.(shape as IEmbedShape)
return // return true
} // }
// Handle all pointer types (mouse, touch, pen) // // Handle all pointer types (mouse, touch, pen)
const point = info.point || (info.touches && info.touches[0]) || info // const point = info.point || (info.touches && info.touches[0]) || info
// Zoom in at the clicked/touched point // // Zoom in at the clicked/touched point
editor.zoomIn(point, { animation: { duration: 200 } }) // editor.zoomIn(point, { animation: { duration: 200 } })
// Stop event propagation and prevent default handling // // Prevent default text creation
info.stopPropagation?.() // info.preventDefault?.()
return false // info.stopPropagation?.()
}, // return true
// },
// onDoubleClickCanvas: (info: any) => {
// // Handle all pointer types (mouse, touch, pen)
// const point = info.point || (info.touches && info.touches[0]) || info
// // Zoom in at the clicked/touched point
// editor.zoomIn(point, { animation: { duration: 200 } })
// // Prevent default text creation
// info.preventDefault?.()
// info.stopPropagation?.()
// return true
// },
}, },
VideoChat: { VideoChat: {
id: "VideoChat", id: "VideoChat",
@ -276,18 +289,17 @@ export const overrides: TLUiOverrides = {
}, },
}, },
//TODO: MAKE THIS WORK, ADD USER PERMISSIONING TO JOIN BROADCAST? //TODO: MAKE THIS WORK, ADD USER PERMISSIONING TO JOIN BROADCAST?
broadcastView: { startBroadcast: {
id: "broadcast-view", id: "start-broadcast",
label: "Broadcast View", label: "Start Broadcasting",
kbd: "alt+b", kbd: "alt+b",
readonlyOk: true, readonlyOk: true,
onSelect: () => { onSelect: () => {
const collaborators = editor.getCollaborators() editor.markHistoryStoppingPoint('start-broadcast')
collaborators editor.updateInstanceState({ isBroadcasting: true })
.filter((user) => user.id !== editor.user.getId()) const url = new URL(window.location.href)
.forEach((user) => { url.searchParams.set("followId", editor.user.getId())
editor.startFollowingUser(user.id) window.history.replaceState(null, "", url.toString())
})
}, },
}, },
stopBroadcast: { stopBroadcast: {
@ -296,7 +308,13 @@ export const overrides: TLUiOverrides = {
kbd: "alt+shift+b", kbd: "alt+shift+b",
readonlyOk: true, readonlyOk: true,
onSelect: () => { onSelect: () => {
editor.updateInstanceState({ isBroadcasting: false })
editor.stopFollowingUser() editor.stopFollowingUser()
// Remove followId from URL
const url = new URL(window.location.href)
url.searchParams.delete("followId")
window.history.replaceState(null, "", url.toString())
}, },
}, },
searchShapes: { searchShapes: {