contentControl 中 insertHtml 上的额外行
extra line on insertHtml in contentControl
在办公室 API for Word 2016 我正在使用 contentControl 的 insertHtml 函数插入 html 格式的文本。文本作为块元素插入,并在末尾添加了额外的一行。 API for Word 2013 中的类似功能,setDataAsync with coercionType "html" 工作正常并插入了一个内联元素。有没有办法指定我需要一个内联元素。
基本上当我尝试插入 (text <i>inserted</i> with <b>insertHtml</b>)
时我需要的是:
this is existing text (text inserted with insertHtml) followed by
more text
我得到的是:
this is existing text
(text inserted with insertHtml)
< blank line >
followed by more text
谢谢。
这是 Word JavaScript API 的一个已知问题,我们正在努力修复它。同时,请使用 setSelectedDataAsync with coercionType HTML 来实现您的需要。 insertHtml 将具有相同的行为。
这里是一些代码示例,用于添加问题的一些上下文。基本上,目的是获取当前选择并插入一些 HTML。在 API 中有两种方法可以做到这一点(见下文)。现在 insertHtml 在末尾添加了一个段落标记,这是一个我们很快就会修复的错误。
function insertHtmlSample() {
Word.run(function (context) {
var mySelection = context.document.getSelection();
mySelection.insertHtml("text <i>inserted</i> with <b>insertHtml</b>", "before");
return context.sync();
}).catch(function (error) {
app.showNotification(error.message);
})
}
function InsertHtmlOld() {
Office.context.document.setSelectedDataAsync("text <i>inserted</i> <p> with </p> <b>insert <p>Html</b> </p> Hello!!! ", { coercionType: 'html' });
}
在办公室 API for Word 2016 我正在使用 contentControl 的 insertHtml 函数插入 html 格式的文本。文本作为块元素插入,并在末尾添加了额外的一行。 API for Word 2013 中的类似功能,setDataAsync with coercionType "html" 工作正常并插入了一个内联元素。有没有办法指定我需要一个内联元素。
基本上当我尝试插入 (text <i>inserted</i> with <b>insertHtml</b>)
时我需要的是:
this is existing text (text inserted with insertHtml) followed by more text
我得到的是:
this is existing text
(text inserted with insertHtml)
< blank line >
followed by more text
谢谢。
这是 Word JavaScript API 的一个已知问题,我们正在努力修复它。同时,请使用 setSelectedDataAsync with coercionType HTML 来实现您的需要。 insertHtml 将具有相同的行为。
这里是一些代码示例,用于添加问题的一些上下文。基本上,目的是获取当前选择并插入一些 HTML。在 API 中有两种方法可以做到这一点(见下文)。现在 insertHtml 在末尾添加了一个段落标记,这是一个我们很快就会修复的错误。
function insertHtmlSample() {
Word.run(function (context) {
var mySelection = context.document.getSelection();
mySelection.insertHtml("text <i>inserted</i> with <b>insertHtml</b>", "before");
return context.sync();
}).catch(function (error) {
app.showNotification(error.message);
})
}
function InsertHtmlOld() {
Office.context.document.setSelectedDataAsync("text <i>inserted</i> <p> with </p> <b>insert <p>Html</b> </p> Hello!!! ", { coercionType: 'html' });
}