ONLYOFFICE / sdkjs-plugins

The add-ons for ONLYOFFICE Document Server and ONLYOFFICE Desktop Editors.
https://www.onlyoffice.com
Apache License 2.0
136 stars 134 forks source link

some document builder functions don't work with callCommand #171

Closed lorenzoale closed 3 months ago

lorenzoale commented 2 years ago

Do you want to request a feature or report a bug? feature

What is the current behavior? some functions availables in the document builder documentation seems to be missing in the callCommand way of using it. For example Select() or Push() to select a content control or push data into it.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

What is the expected behavior? I would like to select and paste data (text or image) inside a content control or to replace the content control by the data i want to paste (because i want to delete it afterwards anyway).  I do it with pasteHtml for the moment but it would be nice to be able to do it directly inside the callCommand function. 

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins? OO doc editor version 7.0.1

l8556 commented 2 years ago

Hi @lorenzoale ! You need to update the document editor to version 7.1.1

An example of using the callCommand function on version 7.1.1 to create a content control and insert text inside it:

        {
            this.callCommand(function () {
                var oDocument = Api.GetDocument();
                var oTextForm = Api.CreateTextForm({
                    "key": "Personal information",
                    "tip": "Enter your first name",
                    "required": true,
                    "placeholder": "First name",
                    "comb": true,
                    "maxCharacters": 10,
                    "cellWidth": 3,
                    "multiLine": false,
                    "autoFit": false
                });
                var oParagraph = oDocument.GetElement(0);
                oParagraph.AddElement(oTextForm);
                oTextForm.SetText("John Smith");
            }, true);
        }
askonev commented 3 months ago

I close this issue. Feel free to comment or reopen it if you got further questions.