我的需求是,在点击我页面的按钮后,在word中的光标位置插入指定的文本和图片到word中
我现在是这么做的:
vue项目代码:
const insertTextAtCursor = () => {
onlyOfficeEditor.value.serviceCommand('123', '321')
}
onlyoffice插件:
/**
* 接收外部数据
* @param {string} data - 外部数据
*/
window.parent.Common.Gateway.on('internalcommand', function(data){
console.log(data.command); // 接受到123参数
console.log(data.data); // 接受到321参数
Asc.plugin.callCommand(() => {
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
// 插入文本, https://api.onlyoffice.com/docs/office-api/usage-api/text-document-api/Api/Methods/CreateWordArt/
let textPr = Api.CreateTextPr();
let textArt = Api.CreateWordArt(textPr, `这是接受到的文本: ${data.command} ${data.data} `);
paragraph.AddDrawing(textArt);
});
});
当我调用**insertTextAtCursor() **方法的时候,页面显示如下:
复现步骤
- 在调用onlyoffice的页面我增加了一个插入按钮
- 点击按钮后
- 显示如上图
预期结果
能正常插入我传入的文字或图片
实际结果
报错
文档服务器版本
企业版试用版:onlyoffice-documentserver-ee 8.3.2-19
补充信息
之前您回答过我executeMethod一次性插入多条数据的问题?,现在我不知道怎么把这些数据传入到插件里从而再插入到word中?
谢谢