diff --git a/static/js/document.js b/static/js/document.js index b245ec85..f9ebee9e 100644 --- a/static/js/document.js +++ b/static/js/document.js @@ -667,6 +667,22 @@ import { bindMenuDismiss, dismissOrRemove } from './escMenuStack.js'; } } + function _sendToChat() { + if (!activeDocId) return; + const doc = docs.get(activeDocId); + if (!doc) return; + const content = typeof doc.content === 'string' ? doc.content : ''; + const snippet = content.substring(0, 120).replace(/\n/g, ' '); + const ref = `[${doc.title || 'Untitled'}](#document-${activeDocId})${snippet ? ' — ' + snippet + (content.length > 120 ? '...' : '') : ''}`; + const msgEl = document.getElementById('message'); + if (!msgEl) return; + const current = msgEl.value.trim(); + msgEl.value = current ? `${current}\n\n${ref}` : ref; + msgEl.focus(); + // Trigger input event so the textarea auto-resizes and any listeners fire + msgEl.dispatchEvent(new Event('input', { bubbles: true })); + } + async function _openExportPdfModal() { if (!activeDocId) return; await _saveActiveDocBeforeExport(); @@ -4596,6 +4612,7 @@ import { bindMenuDismiss, dismissOrRemove } from './escMenuStack.js'; pinned to the bottom no matter which pane (editor / md-preview / csv / html / pdf) is the one growing to fill. -->