sdkjs-plugins
sdkjs-plugins copied to clipboard
InsertAndReplaceContentControls changes ContentControlType to BlockLevelSdt
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The method InsertAndReplaceContentControls changes Inline content controls elements to Block content controls Elements.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Create an inline content control like this:
const ContentControlyType = {
Block: 1,
Inline: 2
};
const contentControl = {
Id: kpiId,
Lock: 0,
Tag: kpiSlug,
Alias: kpiName,
Appearance: 1,
Color: {
R: 24,
G: 193,
B: 197
}
};
window.Asc.plugin.executeMethod("AddContentControl", [ContentControlyType.Inline, contentControl]);
Replace the content of the inline content control:
window.Asc.plugin.onMethodReturn = function (returnValue) {
const _plugin = window.Asc.plugin;
if (_plugin.info.methodName == "AddContentControl" && returnValue && returnValue.InternalId) {
console.log(returnValue);
const contentControls = [
{
Props: {
InternalId: returnValue.InternalId,
},
Script: `var oDocument = Api.GetDocument();var oParagraph = Api.CreateParagraph();oParagraph.AddText('${kpiValue}');oDocument.InsertContent([oParagraph]);`
}
];
window.Asc.plugin.executeMethod("InsertAndReplaceContentControls", [contentControls]);
} else if (_plugin.info.methodName == "InsertAndReplaceContentControls") {
console.log(returnValue[0]);
window.Asc.plugin.executeCommand("close", "");
}
};
The inline content control will become a block level content control. I think it is due to this line of code: https://github.com/ONLYOFFICE/sdkjs/blob/19a9abb25e28698f8074bac80bc518820997e0fb/word/api.js#L589
What is the expected behavior? The method should consider the ContentControl Type. Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins? v1, browser-independent, I don't know if it worked before
@askonev Please, take a look
any updates on this? been 2 years already :/