feat:移除无用的UNO封装代码

This commit is contained in:
PingChuan
2025-11-25 18:58:58 +08:00
parent 08ebcf1935
commit ba83796a44
6 changed files with 116 additions and 235 deletions
-64
View File
@@ -1,64 +0,0 @@
/**
* Collabora 高亮功能模块
*
* @encoding UTF-8
*/
import { sendUnoCommand } from '../Uno';
/**
* 高亮文本
* @param iframeWindow - iframe 的 contentWindow
* @param text - 要高亮的文本
* @param color - 高亮颜色,默认 16776960 = 黄色
*/
export function unoHighlightText(
iframeWindow: Window,
text: string,
color: number = 16776960
): void {
// 1. 查找所有
sendUnoCommand(iframeWindow, '.uno:ExecuteSearch', {
'SearchItem.SearchString': { type: 'string', value: text },
'SearchItem.Command': { type: 'long', value: 1 }, // 1 = FindAll
'SearchItem.SearchFlags': { type: 'long', value: 0 },
'SearchItem.AlgorithmType': { type: 'short', value: 0 },
'SearchItem.Backward': { type: 'boolean', value: false },
'Quiet': { type: 'boolean', value: true },
});
// 2. 设置背景色
sendUnoCommand(iframeWindow, '.uno:BackColor', {
BackColor: { type: 'long', value: color },
});
}
/**
* 移除高亮
* @param iframeWindow - iframe 的 contentWindow
* @param text - 要移除高亮的文本
*/
export function unoRemoveHighlight(iframeWindow: Window, text: string): void {
// 1. 查找所有
sendUnoCommand(iframeWindow, '.uno:ExecuteSearch', {
'SearchItem.SearchString': { type: 'string', value: text },
'SearchItem.Command': { type: 'long', value: 1 }, // 1 = FindAll
'SearchItem.SearchFlags': { type: 'long', value: 0 },
'SearchItem.AlgorithmType': { type: 'short', value: 0 },
'SearchItem.Backward': { type: 'boolean', value: false },
'Quiet': { type: 'boolean', value: true },
});
// 2. 移除背景色 -1 = 无色
sendUnoCommand(iframeWindow, '.uno:BackColor', {
BackColor: { type: 'long', value: -1 },
});
}
/**
* 取消 - Escape
* @param iframeWindow - iframe 的 contentWindow
*/
export function unoEscape(iframeWindow: Window): void {
sendUnoCommand(iframeWindow, '.uno:Escape', {});
}
+12 -10
View File
@@ -4,22 +4,23 @@
* @encoding UTF-8
*/
// 搜索功能
export { unoSearchText } from './search';
// // 搜索功能
// export { unoSearchText } from './search';
// 替换功能
export { unoReplaceText } from './replace';
// // 替换功能
// export { unoReplaceText } from './replace';
// 高亮功能
export { unoHighlightText, unoRemoveHighlight, unoEscape } from './highlight';
// 高亮,已经封装好了
export { switchHighlight } from './Highlightselecttext';
// 导航/跳转功能
export {
unoScrollToTop,
unoScrollToTop
} from './navigation';
// 缩放功能
export { unoZoomPlus, unoZoomMinus, unoSetZoom } from './zoom';
// export { unoSetZoom, unoZoomMinus, unoZoomPlus } from './zoom';
// 文档操作
export { unoSave } from './document';
@@ -27,11 +28,12 @@ export { unoSave } from './document';
// 页数信息
export {
requestPageInfo,
type PageInfo,
type PageInfo
} from './pageInfo';
// 自定义页面跳转功能
export {
customGotoPage,
type GotoPageResponse,
type GotoPageResponse
} from './gotoPage';
-29
View File
@@ -1,29 +0,0 @@
/**
* 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 },
});
}
-27
View File
@@ -1,27 +0,0 @@
/**
* Collabora 搜索功能模块
*
* @encoding UTF-8
*/
import { sendUnoCommand } from '../Uno';
/**
* 搜索文本
* @param iframeWindow - iframe 的 contentWindow
* @param text - 要搜索的文本
*/
export function unoSearchText(iframeWindow: Window, text: string): void {
sendUnoCommand(iframeWindow, '.uno:ExecuteSearch', {
'SearchItem.SearchString': { type: 'string', value: text },
'SearchItem.Command': { type: 'long', value: 1 }, // 1 = Search Next (搜索下一个)
'SearchItem.Backward': { type: 'boolean', value: false },
'SearchItem.Pattern': { type: 'boolean', value: false },
'SearchItem.Content': { type: 'boolean', value: false },
'SearchItem.AsianOptions': { type: 'boolean', value: false },
'SearchItem.AlgorithmType': { type: 'short', value: 0 }, // 普通搜索
'SearchItem.SearchFlags': { type: 'long', value: 0 },
'SearchItem.Start': { type: 'boolean', value: true }, // 从头开始搜索
'SearchItem.Quiet': { type: 'boolean', value: true }, // 静默模式
});
}
+33 -33
View File
@@ -1,37 +1,37 @@
/**
* Collabora 缩放功能模块
*
* @encoding UTF-8
*/
// /**
// * Collabora 缩放功能模块
// *
// * @encoding UTF-8
// */
import { sendUnoCommand } from '../Uno';
// import { sendUnoCommand } from '../Uno';
/**
* 放大文档(固定步长)
* @param iframeWindow - iframe 的 contentWindow
*/
export function unoZoomPlus(iframeWindow: Window): void {
sendUnoCommand(iframeWindow, '.uno:ZoomPlus', {});
}
// /**
// * 放大文档(固定步长)
// * @param iframeWindow - iframe 的 contentWindow
// */
// export function unoZoomPlus(iframeWindow: Window): void {
// sendUnoCommand(iframeWindow, '.uno:ZoomPlus', {});
// }
/**
* 缩小文档(固定步长)
* @param iframeWindow - iframe 的 contentWindow
*/
export function unoZoomMinus(iframeWindow: Window): void {
sendUnoCommand(iframeWindow, '.uno:ZoomMinus', {});
}
// /**
// * 缩小文档(固定步长)
// * @param iframeWindow - iframe 的 contentWindow
// */
// export function unoZoomMinus(iframeWindow: Window): void {
// sendUnoCommand(iframeWindow, '.uno:ZoomMinus', {});
// }
/**
* 设置文档缩放比例
* @param iframeWindow - iframe 的 contentWindow
* @param percentage - 缩放百分比(例如:100 表示 100%)
*/
export function unoSetZoom(iframeWindow: Window, percentage: number): void {
sendUnoCommand(iframeWindow, '.uno:Zoom', {
Zoom: {
type: 'short',
value: percentage,
},
});
}
// /**
// * 设置文档缩放比例
// * @param iframeWindow - iframe 的 contentWindow
// * @param percentage - 缩放百分比(例如:100 表示 100%)
// */
// export function unoSetZoom(iframeWindow: Window, percentage: number): void {
// sendUnoCommand(iframeWindow, '.uno:Zoom', {
// Zoom: {
// type: 'short',
// value: percentage,
// },
// });
// }