diff --git a/modules/rinbox/components/folk-inbox-client.ts b/modules/rinbox/components/folk-inbox-client.ts index aee99b8..096db8a 100644 --- a/modules/rinbox/components/folk-inbox-client.ts +++ b/modules/rinbox/components/folk-inbox-client.ts @@ -12,6 +12,20 @@ import { TourEngine } from "../../../shared/tour-engine"; import { ViewHistory } from "../../../shared/view-history.js"; import { getAccessToken, getUsername } from "../../../lib/rspace-header"; import { startPresenceHeartbeat } from '../../../shared/collab-presence'; +import { Editor } from '@tiptap/core'; +import StarterKit from '@tiptap/starter-kit'; +import Link from '@tiptap/extension-link'; +import TaskList from '@tiptap/extension-task-list'; +import TaskItem from '@tiptap/extension-task-item'; +import Placeholder from '@tiptap/extension-placeholder'; +import Underline from '@tiptap/extension-underline'; +import { Markdown } from 'tiptap-markdown'; +import * as Y from 'yjs'; +import { IndexeddbPersistence } from 'y-indexeddb'; +import { ySyncPlugin, yUndoPlugin, yCursorPlugin } from '@tiptap/y-tiptap'; +import { RSpaceYjsProvider } from '../../../shared/yjs-ws-provider'; +import { tiptapToMarkdown, extractPlainTextFromTiptap } from '../../../shared/markdown-tiptap'; +import { marked } from 'marked'; type ComposeMode = 'new' | 'reply' | 'reply-all' | 'forward'; @@ -44,6 +58,12 @@ class FolkInboxClient extends HTMLElement { private _fwdModalOpen = false; private _fwdBusy = false; private _fwdError = ''; + // TipTap / Yjs editor instances + private composeEditor: Editor | null = null; + private composeYdoc: Y.Doc | null = null; + private composeYjsProvider: RSpaceYjsProvider | null = null; + private composeYIndexedDb: IndexeddbPersistence | null = null; + private commentEditor: Editor | null = null; private demoApprovals: any[] = [ { id: "a1", subject: "Re: Q1 Budget approval for rSpace infrastructure", status: "PENDING", @@ -126,6 +146,7 @@ class FolkInboxClient extends HTMLElement { } disconnectedCallback() { + this.destroyEditors(); for (const unsub of this._offlineUnsubs) unsub(); this._offlineUnsubs = []; this._stopPresence?.(); @@ -545,6 +566,7 @@ class FolkInboxClient extends HTMLElement { } private render() { + this.destroyEditors(); this.shadow.innerHTML = `