How do I preserve indentation when replacing Content Control w/ Url or inserting image?

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.

Screen Recording 2023-04-10 at 19.52.09 (1)

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,
      ])
    }
  )
}

Screen Recording 2023-04-10 at 20.06.47

Running Document Server 7.2.2

Hey @fr3fou

Thank you for the file and a GIF!
We are checking the situation.
I will let you know when I get something.

I tried reproducing the bug with 7.3.3, but it seems like calling CreateImage when using InsertAndReplaceContentControls like I’m using it doesn’t seem to be working –
Using the same code, results in the image looking like this:
image
This is a really sudden breaking change that prevents me from upgrading to 7.3.3 (still using 7.2.2) :confused:

This is a really weird.
Thank you. I will add information for testing the problem.

@fr3fou
We’re aware of the issue and have added the information to bug 44599 in our tracking system. The problem will be fixed in one of the upcoming releases, but unfortunately, I can’t provide you with an exact timeline at the moment.

After refreshing the page, the added image should display correctly.

Thanks for the quick reply,

We’re aware of the issue and have added the information to bug 44599 in our tracking system. The problem will be fixed in one of the upcoming releases, but unfortunately, I can’t provide you with an exact timeline at the moment.

Are we talking about the indentation bug for Url & Image replacements, images not rendering on 7.3.3 or both?

Hey, @fr3fou
Bug 44599 - Red cross instead of the image added to the content control using the InsertAndReplaceContentControls method.

Still working on this case.

Bug 44599 - Red cross instead of the image added to the content control using the InsertAndReplaceContentControls method.

Has this been fixed in the latest 7.4.0 release?

Unfortunately, bug 44599 is not fixed in version 7.4.

Hello! Any chance it was fixed in 7.5?

Hi @fr3fou

The next version is 8.0. Unfortunately, the fix for this issue will not be included in it.

Did I understand correctly that you mentioned there was no such issue in version 7.2.2?

Correct, this issue isn’t present in 7.2.2

I will check with my colleague to see if we can prioritize the issue.
(The likelihood is low)