Add inline content control and replace content

Integration questions/issues
Post Reply
uwohlfeil
Posts: 2
Joined: Mon Apr 29, 2019 8:53 am

Add inline content control and replace content

Post by uwohlfeil » Wed Jun 12, 2019 8:58 am

Hi,

I try to add a content control with a custom content.

Version Info:
Document Editor 5.3.0
Firefox 67.0..1

I try this calls:
AddContentControl
Request:

Code: Select all

[2, { "Id": 2885, "Lock": 0, "Tag": "{\"exp\":\"Expample\",\"wrap\":\"2\",\"lock\":\"0\",\"placeholderType\":\"text\",\"placeholder\":\"placeholder\"}" }]
Response:

Code: Select all

{"Tag": "{\"exp\":\"Expample\",\"wrap\":\"2\",\"lock\":\"0\",\"placeholderType\":\"text\",\"placeholder\":\"placeholder\"}", "Id": 2885, "Lock": 0, "InternalId": "2_2857"}
InsertAndReplaceContentControls
Then i try to update the new control content.
Request:

Code: Select all

[[ {"Props": { "InternalId": "2_2857", "Lock": 0, "Tag": "{\"exp\":\"Expample\",\"wrap\":\"2\",\"lock\":\"0\",\"placeholderType\":\"text\",\"placeholder\":\"placeholder\"}"  },  "Script": "var oDocument = Api.GetDocument();var oParagraph =  Api.CreateParagraph(); var oRun = oParagraph.AddText(\"Expample\"); oDocument.InsertContent([oParagraph], true);" } ]]
Response:

Code: Select all

[]
I also have the effect, that a delete seems not to delete the control correctly.
The control disappears on the editor but the GetContentControls still shows the control:

GetAllContentControls

Code: Select all

[{ "Tag": "{\"exp\":\"Expample\",\"wrap\":\"2\",\"lock\":\"0\",\"placeholderType\":\"text\",\"placeholder\":\"placeholder\"}", "Id": 2885,  "Lock": 0, "InternalId": "2_2857" } ]
RemoveContentControls
Request:

Code: Select all

[[ { "InternalId": "2_2857" } ] ]
Response
undefined

GetAllContentControls

Code: Select all

[
  {
    "Tag": "{\"exp\":\"Expample\",\"wrap\":\"2\",\"lock\":\"0\",\"placeholderType\":\"text\",\"placeholder\":\"placeholder\"}",
    "Id": 2885,
    "Lock": 0,
    "InternalId": "2_2857"
  },
  {
    "Tag": "{\"exp\":\"asdasd\",\"wrap\":\"2\",\"lock\":\"0\",\"placeholderType\":\"text\",\"placeholder\":\"as\"}",
    "Id": 1956,
    "Lock": 0,
    "InternalId": "2_3146"
  }
]

uwohlfeil
Posts: 2
Joined: Mon Apr 29, 2019 8:53 am

Re: Add inline content control and replace content

Post by uwohlfeil » Sat Jul 06, 2019 11:54 am

I found my mistake. The problem was not in the described calls.
It was a concurrent call from the.Asc.plugin.onExternalMouseUp window that executes a window.Asc.plugin.executeMethod('GetCurrentContentControl', []) while I add and update the new ContentControl as described.
The OnlyOffice documentation says: "For the plugin to work correctly, you must wait until the current method is executed before executing the next method". (https://api.onlyoffice.com/plugin/executemethod)
but I didn't see that effect in my code.

@OnlyOffice:
Can you mark this post as solved?
It would be great if the onlyoffice client generates some error messages for incorrectly executed concurrent calls like mine.

Maxim
Posts: 1945
Joined: Tue Oct 11, 2016 2:34 pm

Re: Add inline content control and replace content

Post by Maxim » Mon Jul 08, 2019 6:39 am

Hello uwohlfeil!
It would be great if the onlyoffice client generates some error messages for incorrectly executed concurrent calls like mine.
Thank you for your feedback.

Post Reply