/** * Collabora 替换功能模块 * * @encoding UTF-8 */ import { sendUnoCommand } from '../Uno'; /** * 替换文本 * @param iframeWindow - iframe 的 contentWindow * @param searchText - 要搜索的文本 * @param replaceText - 替换后的文本 */ export function unoReplaceText( iframeWindow: Window, searchText: string, replaceText: string ): void { sendUnoCommand(iframeWindow, '.uno:ExecuteSearch', { 'SearchItem.SearchString': { type: 'string', value: searchText }, 'SearchItem.ReplaceString': { type: 'string', value: replaceText }, 'SearchItem.Command': { type: 'long', value: 3 }, // 3 = ReplaceAll 'SearchItem.AlgorithmType': { type: 'short', value: 0 }, 'SearchItem.SearchFlags': { type: 'long', value: 0 }, 'SearchItem.Backward': { type: 'boolean', value: false }, 'Quiet': { type: 'boolean', value: true }, }); }