69 lines
3.8 KiB
Markdown
69 lines
3.8 KiB
Markdown
# MNote ONLYOFFICE live bridge
|
||||
|
|
|
|||
|
|
用于操作当前已经打开的 ONLYOFFICE 编辑器会话。
|
|||
|
|
|
|||
|
|
## 适用范围
|
|||
|
|
|
|||
|
|
- 仅针对当前浏览器里打开的 ONLYOFFICE 文档
|
|||
|
|
- 支持 Word、Excel、PPT 的基础读写
|
|||
|
|
- 不用于离线批量修改文件
|
|||
|
|
|
|||
|
|
## 可用工具
|
|||
|
|
|
|||
|
|
- `mnote.onlyoffice.session.current`
|
|||
|
|
- `mnote.onlyoffice.capabilities`
|
|||
|
|
- `mnote.onlyoffice.selection.get`
|
|||
|
|
- `mnote.onlyoffice.document.insert_text`
|
|||
|
|
- `mnote.onlyoffice.document.replace_selection`
|
|||
|
|
- `mnote.onlyoffice.document.insert_html`
|
|||
|
|
- `mnote.onlyoffice.document.export`
|
|||
|
|
- `mnote.onlyoffice.document.search_replace`
|
|||
|
|
- `mnote.onlyoffice.document.insert_table`
|
|||
|
|
- `mnote.onlyoffice.document.get_comments`
|
|||
|
|
- `mnote.onlyoffice.document.add_comment`
|
|||
|
|
- `mnote.onlyoffice.sheet.get_sheets`
|
|||
|
|
- `mnote.onlyoffice.sheet.add_sheet`
|
|||
|
|
- `mnote.onlyoffice.sheet.rename_sheet`
|
|||
|
|
- `mnote.onlyoffice.sheet.get_range`
|
|||
|
|
- `mnote.onlyoffice.sheet.get_range_values`
|
|||
|
|
- `mnote.onlyoffice.sheet.get_values`
|
|||
|
|
- `mnote.onlyoffice.sheet.set_value`
|
|||
|
|
- `mnote.onlyoffice.sheet.set_formula`
|
|||
|
|
- `mnote.onlyoffice.sheet.batch_set_values`
|
|||
|
|
- `mnote.onlyoffice.sheet.set_range_values`
|
|||
|
|
- `mnote.onlyoffice.sheet.format_range`
|
|||
|
|
- `mnote.onlyoffice.sheet.set_dimensions`
|
|||
|
|
- `mnote.onlyoffice.sheet.sort_range`
|
|||
|
|
- `mnote.onlyoffice.sheet.add_chart`
|
|||
|
|
- `mnote.onlyoffice.presentation.get_slides`
|
|||
|
|
- `mnote.onlyoffice.presentation.get_slide_texts`
|
|||
|
|
- `mnote.onlyoffice.presentation.get_shapes`
|
|||
|
|
- `mnote.onlyoffice.presentation.add_text_slide`
|
|||
|
|
- `mnote.onlyoffice.presentation.replace_text`
|
|||
|
|
- `mnote.onlyoffice.presentation.set_shape_text`
|
|||
|
|
- `mnote.onlyoffice.presentation.delete_slide`
|
|||
|
|
- `mnote.onlyoffice.presentation.add_table`
|
|||
|
|
- `mnote.onlyoffice.presentation.clear_slide`
|
|||
|
|
- `mnote.onlyoffice.presentation.add_shape`
|
|||
|
|
|
|||
|
|
## 使用原则
|
|||
|
|
|
|||
|
|
- 先调用 `mnote.onlyoffice.session.current` 确认当前会话存在,并记录 `sessionId` / `documentId` / `assetId` / `fileType`
|
|||
|
|
- 多个 ONLYOFFICE 标签页同时打开时,写操作必须显式传 `onlyofficeSessionId`
|
|||
|
|
- 写入前优先做最小范围修改,并先用 `dryRun` 检查计划
|
|||
|
|
- 读取大块表格时优先使用 `sheet.get_values`,写入多格时优先使用 `sheet.batch_set_values`
|
|||
|
|
- 需要按用户可见坐标定位表格时优先使用 A1 地址工具:`sheet.get_range_values` / `sheet.set_range_values`
|
|||
|
|
- `sheet.set_range_values` 只写入 A1 区域与二维 `values` 的交集,调用前应确认尺寸
|
|||
|
|
- 表格样式只做显式小范围:`sheet.format_range` 支持字体粗斜体、颜色、对齐和数字格式;`sheet.set_dimensions` 支持零基行高/列宽
|
|||
|
|
- Excel 排序使用 `sheet.sort_range`,先确认 A1 range,`keyColumn` 是 range 内从 1 开始的列号;图表使用 `sheet.add_chart`,默认柱状图
|
|||
|
|
- `document.export` 仅支持 `markdown` 和 `html`
|
|||
|
|
- Word 精确文本替换优先使用 `document.search_replace`
|
|||
|
|
- Word 插入结构化表格使用 `document.insert_table`;评论读取/添加使用 `document.get_comments` / `document.add_comment`
|
|||
|
|
- `document.add_comment` 默认给当前选区加评论;没有可靠选区时显式传 `target: "document_start"`
|
|||
|
|
- PPT 文本读取优先使用 `presentation.get_slide_texts`;`presentation.replace_text` 只处理文本框纯文本,命中文本框会按纯文本段落重建
|
|||
|
|
- PPT 精确改某个文本框时先调用 `presentation.get_shapes` 获取 `shapeIndex` / `shapeId`,再调用 `presentation.set_shape_text`
|
|||
|
|
- 删除 PPT 幻灯片前必须先调用 `presentation.get_slides` 或 `presentation.get_slide_texts` 确认 `slideIndex`
|
|||
|
|
- PPT 插入结构化表格使用 `presentation.add_table`,默认居中插入;需要精确位置时传 `xMm` / `yMm` / `widthMm` / `heightMm`
|
|||
|
|
- PPT 清空指定页对象使用 `presentation.clear_slide`,调用前必须确认目标 `slideIndex`;添加基础图形使用 `presentation.add_shape`
|
|||
|
|
- 需要大范围离线处理时,改用 `officecli`
|