feat: add room mentions and clickable room/relay refs

This commit is contained in:
2026-04-04 16:48:29 +05:30
parent 8e2dd8b278
commit e90e3cac2a
10 changed files with 327 additions and 4 deletions
+28
View File
@@ -0,0 +1,28 @@
import type {NodeViewRendererProps} from "@tiptap/core"
import {deriveRoom} from "@app/core/state"
export const RoomReferenceNodeView = ({node}: NodeViewRendererProps) => {
const dom = document.createElement("span")
const url = typeof node.attrs.url === "string" ? node.attrs.url : ""
const h = typeof node.attrs.h === "string" ? node.attrs.h : ""
const room = deriveRoom(url, h)
dom.classList.add("tiptap-object")
const unsubRoom = room.subscribe($room => {
dom.textContent = `~${$room.name || h}`
})
return {
dom,
destroy: () => {
unsubRoom()
},
selectNode() {
dom.classList.add("tiptap-active")
},
deselectNode() {
dom.classList.remove("tiptap-active")
},
}
}