fix: 1.接入ai_suggestion.
2. 接入合同起草功能。
This commit is contained in:
@@ -279,8 +279,8 @@ export const CollaboraViewer = forwardRef<CollaboraViewerHandle, CollaboraViewer
|
||||
<div className="flex justify-center items-center h-full min-h-[600px]">
|
||||
<div className="text-center text-red-500">
|
||||
<i className="ri-error-warning-line text-4xl mb-2"></i>
|
||||
<p className="text-lg">{error || '加载配置失败'}</p>
|
||||
<p className="text-sm text-gray-500 mt-2">请刷新页面重试或联系管理员</p>
|
||||
<p className="text-lg">{error}</p>
|
||||
{/* <p className="text-sm text-gray-500 mt-2">请刷新页面重试或联系管理员</p> */}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ import { COLLABORA_URL } from '~/config/api-config';
|
||||
import { toastService } from '../ui/Toast';
|
||||
import {
|
||||
unoScrollToTop,
|
||||
unoReplaceAll
|
||||
} from './lib';
|
||||
import type { CollaboraConfig } from './types';
|
||||
|
||||
@@ -131,14 +132,30 @@ export function useCollaboraUnoCommands(iframeRef: RefObject<HTMLIFrameElement>)
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}, [iframeRef]);
|
||||
|
||||
/**
|
||||
* 替换所有匹配项
|
||||
* @param searchText 要搜索的文本
|
||||
* @param replaceText 替换后的文本
|
||||
*/
|
||||
const replaceAll = useCallback(async (searchText: string, replaceText: string) => {
|
||||
if (!iframeRef.current?.contentWindow) {
|
||||
console.warn('[UNO] iframe 不可用');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[UNO] 替换全部:', searchText, '->', replaceText);
|
||||
await unoReplaceAll(iframeRef.current.contentWindow, searchText, replaceText);
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
}, [iframeRef]);
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
scrollToTop
|
||||
scrollToTop,
|
||||
replaceAll
|
||||
}),
|
||||
[
|
||||
scrollToTop
|
||||
scrollToTop,
|
||||
replaceAll
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export interface HighlightOptions {
|
||||
/** 高亮颜色 (LibreOffice Decimal 格式), 默认 16776960 = 黄色 */
|
||||
color?: number;
|
||||
/** 目标页码 (从1开始), 默认第1页 */
|
||||
page?: number;
|
||||
page?: number | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ export interface HighlightResponse {
|
||||
success: boolean;
|
||||
message: string;
|
||||
highlightedCount?: number;
|
||||
page?: number;
|
||||
page?: number | null;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export async function highlightText(
|
||||
options?: HighlightOptions
|
||||
): Promise<HighlightResponse> {
|
||||
const color = options?.color ?? 16776960; // 默认黄色
|
||||
const page = options?.page ?? 1; // 默认第1页
|
||||
const page = options?.page ?? null; // 默认第1页
|
||||
|
||||
console.log('[HighlightSelectText] 调用 Python 脚本高亮文本:', {
|
||||
text,
|
||||
|
||||
@@ -53,6 +53,9 @@ export interface CollaboraViewerHandle {
|
||||
/** UNO 命令方法集合 */
|
||||
unoCommands: {
|
||||
scrollToTop: () => Promise<void>;
|
||||
replaceAll?: (searchText: string, replaceText: string) => Promise<void>;
|
||||
find?: (searchText: string) => Promise<void>;
|
||||
search?: (searchText: string) => Promise<void>;
|
||||
};
|
||||
/** 文档是否已加载完成 */
|
||||
isReady: boolean;
|
||||
|
||||
Reference in New Issue
Block a user