// VocabFlow DSH 搜索栏插件 —— Client 半体(动态安装版) // 用法:作为 cordis_define 的 code.client 提交(完整函数体,直接粘贴)。 // v0.4.2 —— 动态运行环境不提供 react-dom,保留在 conversation.input.dock; // npm 原生插件由 lib/client.js 通过 React Portal 固定到会话区域最上方。 // 与 Host 通过 Package 私有 RPC 通信:host.call('lookup'|'quick'|'question', payload)。 return { inject: ['slots'], apply(ctx) { const slots = ctx.get('slots') if (slots === undefined) return const escapeHtml = (s) => String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])) const inlineMarkdown = (s) => { let out = escapeHtml(s) out = out.replace(/\*\*(.+?)\*\*/g, '$1') out = out.replace(/`([^`]+)`/g, '$1') out = out.replace(/(^|[^*])\*([^*\n]+)\*/g, '$1$2') return out } const richHtml = (text) => { const lines = String(text || '').split('\n') let html = '' let listTag = '' const closeList = () => { if (listTag) { html += ''; listTag = '' } } for (const raw of lines) { const line = raw.trim() if (/^[-*•]\s+/.test(line)) { if (listTag !== 'ul') { closeList(); html += '