Highlight text snippets in WOPI application ideally in view mode

Hey all,

I’m trying to integrate the Collabora WOPI Editor in a web app while also highlighting text snippets of interest for the user.
The snippets are coming from a RAG backend, so I can’t influence them.

Is there a way to implement this functionality via post messages and UNO commands while keeping the editor in view mode?

Thanks in advance!

hii @pakue welcome to community forum :slight_smile:

No, directly highlighting text snippets in Collabora WOPI view mode using PostMessages and UNO commands for persistent, document-embedded highlights is generally not possible. View mode prevents document modifications. You would likely need to explore external UI overlays, which are complex, or temporarily switch to edit mode if acceptable.

Explanation:

  • View Mode Restriction: Collabora’s WOPI view mode (UserCanWrite: false) is designed to prevent any document modifications, including applying formatting like highlights. UNO commands for highlighting, even if sent, will likely be ignored or not persist.
  • External UI/Overlay: The most feasible approach is to overlay your own highlighting UI on top of the Collabora iframe, but this requires complex coordinate mapping to match text positions.

Although @pakue i see we have ExecuteSearch UNO comand that works to heiglight the text in read only mode but there is no post message api for that. But you can explore more options around it…

Thanks
Darshan

Hey @darshan,
thanks for the reply. I’ve played around with some of the commands stated here including the ExecuteSearch with the following PostMessage:

{
    "MessageId": "Send_UNO_Command",
    "SendTime": 1751897618184,
    "Values": {
        "Command": ".uno:ExecuteSearch",
        "Args": {
            "SearchItem": {
                "value": "randomstring",
                "type": "string"
            },
            "UseAttrItemList": {
                "value": false,
                "type": "boolean"
            },
            "Quiet": {
                "value": false,
                "type": "boolean"
            }
        }
    }
}

but without starting a search. The iframe seems to just reload the document. Some other uno commands like highlighting (after manually selecting text) work in edit mode tough.

Any idea if that’s just a mistake on my side?

Best wishes

@pakue I believe I’ve already pointed out that the scenario you’re referring to directly highlighting text snippets in WOPI view mode using PostMessages and UNO commands is most likely not possible. The command I suggested earlier was just a potential idea, but it may not work reliably in read-only mode.

Please feel free to explore other UNO commands if you’re looking for alternatives, but I don’t have any further input to add on this for now.

Thanks,
Darshan