feat:完成Collabora初步集成(返回顶部、文档页数获取)

This commit is contained in:
PingChuan
2025-11-25 10:56:47 +08:00
parent 31614374a7
commit 272c3e8dce
14 changed files with 583 additions and 208 deletions
+3 -14
View File
@@ -51,6 +51,7 @@ export const CollaboraViewer = forwardRef<CollaboraViewerHandle, CollaboraViewer
unoCommands,
isReady: isDocumentLoaded,
mode,
getIframeWindow: () => iframeRef.current?.contentWindow || null,
}), [unoCommands, isDocumentLoaded, mode]);
// 5. 将 sendUnoCommand 挂载到 window 对象,供调试面板和控制台使用
@@ -121,24 +122,12 @@ export const CollaboraViewer = forwardRef<CollaboraViewerHandle, CollaboraViewer
}
}
}
try {
// 先让 iframe 获得焦点
iframeRef.current.focus();
console.log('[调试面板] 已聚焦 iframe');
(window as any).sendUno?.(unoCmd, args);
setUnoResult(`已发送: ${unoCmd}`);
} catch (e) {
console.error('发送 UNO 失败:', e);
setUnoResult('发送失败,请查看控制台');
}
};
return (
<div className="collabora-viewer relative w-full h-full min-h-[600px]">
{/* UNO 命令测试面板 */}
<div className="absolute top-2 left-2 z-50 bg-white bg-opacity-90 px-2 py-1 rounded shadow flex items-center gap-2">
{/* <div className="absolute top-2 left-2 z-50 bg-white bg-opacity-90 px-2 py-1 rounded shadow flex items-center gap-2">
<input
className="px-2 py-1 border rounded text-sm w-48"
value={unoCmd}
@@ -160,7 +149,7 @@ export const CollaboraViewer = forwardRef<CollaboraViewerHandle, CollaboraViewer
发送 UNO
</button>
{unoResult && <span className="text-xs text-gray-500 ml-2">{unoResult}</span>}
</div>
</div> */}
{/* 文档加载提示 */}
{!isDocumentLoaded && (