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

Content control does not refresh after AddText() / crashes on oRun.ClearContent() #149

Closed teamoo closed 3 years ago

teamoo commented 3 years ago

Do you want to request a feature or report a bug? Bug What is the current behavior?

  1. When you add text to an inline content control surrounded by text that already has text in it, it will not become visible before editing that content control.
  2. When you modify a run within a content control, the app will crash on re-render. If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
    • Create an empty document
    • add some text
    • add a content control
    • add some text to the content control aand place it somewhere between the regular text
    • Make sure to put the cursor outside of the content control so it will not get locked Run the following macro code for the first issue:
      
      let oDocument = Api.GetDocument();
      let oContentControls = oDocument.GetAllContentControls();

for (const oCC of oContentControls) { oCC.SetLock("Unlocked"); oCC.AddText("TEST"); oCC.SetLock("contentLocked"); } }

If you exit the macro screen, the content control still shows the previous text content. If you edit it, it will show "TEST" in addition.

Run the following macro code for the second issue:
````javascript
let oDocument = Api.GetDocument();
let oContentControls = oDocument.GetAllContentControls();

for (const oCC of oContentControls) {
       oCC.SetLock("Unlocked");
       for (let i=0; i < oCC.GetElementsCount(); i++) {
            const elem = oCC.GetElement(i);
            if (elem.GetClassType() == 'run') {
                elem.ClearContent();
                elem.AddText("TEST");
            }
        }
        oCC.SetLock("contentLocked");
}

When you move the cursor near the content control, the app crashes. What is the expected behavior?

  1. The content control will update whenever it's content has changed.
  2. Calling ClearContent() on a text run within a content control does not crash the app.

Which versions of sdkjs-plugins, and which browser / OS are affected by this issue? Did this work in previous versions of sdkjs-plugins? 6.2.0 / Safari 14.0.3

ShockwaveNN commented 3 years ago

@askonev Please take a look

askonev commented 3 years ago

Hello @teamoo. At the moment, these scripts have been corrected for the latest (6.3.0) version of the editor. Please upgrade DocumentServer to latest stable v6.3.0 and see if problem still actual

teamoo commented 3 years ago

Hi @askonev,

I did some testing and it seems to work. Thanks.