fix: 1.接入ai_suggestion.

2. 接入合同起草功能。
This commit is contained in:
2025-12-05 00:04:45 +08:00
parent eca98fc540
commit 33f10896a0
29 changed files with 3184 additions and 981 deletions
+19 -2
View File
@@ -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
]
);
}