Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InsertAndReplaceContentControls changes ContentControlType to BlockLevelSdt #143

Open
teamoo opened this issue Feb 16, 2021 · 2 comments
Open

Comments

@teamoo
Copy link

teamoo commented Feb 16, 2021

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

@ShockwaveNN
Copy link
Contributor

@askonev Please, take a look

@fr3fou
Copy link

fr3fou commented Mar 9, 2023

any updates on this? been 2 years already :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants