Hello, I have the following code
function example() {
window.Asc.plugin.executeMethod(
"GetAllContentControls",
[],
(returnValue) => {
const docs = returnValue
.filter((control) => control.Tag.startsWith(nestedPrefix))
.flatMap((control) => {
return [
{
Props: {
InternalId: control.InternalId,
},
Url: "http://example.com/document.docx",
},
]
})
.filter(Boolean)
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [
docs,
])
}
)
}
When trying to replace existing content controls w/ the content of a URL, the indentation of the content control does not get preserved.
Is there a way to fix this / workaround this?
The same thing applies when inserting images with the following code:
function image() {
window.Asc.plugin.executeMethod(
"GetAllContentControls",
[], (returnValue) => {
const d = returnValue
.filter((control) => control.Tag.startsWith(imagePrefix))
.flatMap((control) => {
const key = control.Tag.slice(img.length)
const value = values[key]
return [
{
Props: {
InternalId: control.InternalId,
},
// language=JavaScript
Script: `
const oParagraph = Api.CreateParagraph();
const drawing = Api.CreateImage("${value}", 60 * 36000, 35 * 36000);
oParagraph.AddDrawing(drawing);
Api.GetDocument().InsertContent([oParagraph], true, {KeepTextOnly: true}); // I've also tried `Api.GetDocument().InsertContent([oParagraph])`
`
.replaceAll("\n", "")
.trim(),
},
]
})
.filter(Boolean)
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [
d,
])
}
)
}
Running Document Server 7.2.2