Unable to edit text inserted to plain text content control

Hi, I cannot edit text pasted into a plain text content control. I can only remove the whole text and paste another one. I’m using Aspose.Words Java 21.6. In the attachments template and the result documents. I want to know if it is possible to fix it somehow.
Test_template.docx (19.8 KB)
Result_document.docx (16.5 KB)

@bz.anton.kh

It seems that you are experiencing an issue with editing text within a plain text content control in Aspose.Words for Java. Specifically, you mentioned that you can only remove the entire text and paste a new one, rather than editing the existing text directly.

This behavior may be related to the properties of the structured document tag (SDT) you are using. Here are a few things to check and try:

  1. Check the IsTemporary Property: If the IsTemporary property of the structured document tag is set to true, it will allow the user to edit the contents only once. After the first edit, the contents will be assimilated into the document, and the tag will disappear. Ensure that this property is set to false if you want to allow multiple edits.

    StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);
    tag.setIsTemporary(false); // Allow multiple edits
    
  2. Locking Properties: Check if the LockContents or LockContentControl properties are set to true. If either of these properties is enabled, it will restrict editing of the contents or the control itself. You can set them to false to allow editing.

    tag.setLockContents(false); // Allow editing of contents
    tag.setLockContentControl(false); // Allow deletion of the control
    
  3. Placeholder Text: If the content control is showing placeholder text, ensure that the IsShowingPlaceholderText property is set to false after the user has entered text. This will allow the user to edit the text directly.

    tag.setIsShowingPlaceholderText(false); // Hide placeholder text after user input
    
  4. Using the Clear Method: If you want to clear the contents of the structured document tag while keeping the control, you can use the Clear method. This will reset the content to its placeholder state.

    tag.clear(); // Clears the content but keeps the control
    

By adjusting these properties, you should be able to edit the text within the plain text content control as expected. If you continue to face issues, please provide more details about the specific behavior you are encountering, and I would be happy to assist further.

Here are the settings of the plain text content control, locking is set to false, but the issue still reproduces
image.png (51.3 KB)

@bz.anton.kh You should set StructuredDocumentTag.isShowingPlaceholderText to false, otherwise the SDT’s content is considered as placeholder text and is removed when you edit the SDT.