fix: 1.接入ai_suggestion.
2. 接入合同起草功能。
This commit is contained in:
@@ -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
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user