So, we have the "Save" button on the host page. I'd like to make it active only when there are unsaved changes in the document, and deactivate it as soon as the changes have been saved.
This is also needed for one scenario. When user is to terminate the session (with Close_Session postMessage) and there are unsaved changes we display a warning. Currently we don't know the state and cannot really warn him that there are unsaved changes.
This may be a regression.
Now using LibreOffice 18.104.22.168. In the previous version that came with Linux Mint 17.3, the 'save' button was greyed-out if the document was unchanged, or sufficient stabs at Ctrl-Z had reverted the document to its original form.
There is, as far as I can see, no alternative indication that unsaved changes have been made.
I'm talking about providing postMessage API messages to set the button state on the LibreOffice Online editor host page.
Sorry, my bad
Let's add this to the easyHack list.
The task is to find the code which is responsible for showing the 'Document saved' text in the statusbar and then use that code to route the document modified status through the postMessage API to hosts.
Aleksander: I'd advise against disabling the Save button, because the user might have reasons to use that even when the document is not modified. That is for the cases when the user wants to save information that is not actually changing the 'document modified' status, but still is part of the file format.
Most notable example is the position of the view and of the cursor in a spreadsheet: When you move the cursor, the view and the cursor position changes, but the document modification status does not. The users should have the possibility to save the spreadsheet when they just move the cursor.
We used to disable the Save button in the desktop version based on the 'document modified' status in the past, but changed that due to the reasons described above.
Regarding the "and there are unsaved changes" - there are never unsaved changes, the document is always saved when the session is closed. Or do you want to warn the user in a "this is not a cancel, your unfinished changes will be saved anyway" kind of way? Wouldn't that be annoying? :-)
I wasn't aware that changes are saved on Close_Session. However, I'm confused, because the desktop version does not behave like that. Well, at least not in single user mode.
When you change anything in LibreOffice Writer document and press Close button (in window or from menu) it will ask you if you want to keep the changes. Why something like this could not exist in Online version?
So, I could probably workaround that and not use Close_Session and just close the window in case the user wan't to close and cancel changes. However, Close_Session has one feature that would be hard to workaround. It informs all users in the session that the session has been closed.
Maybe Close_Session should have a parameter to disable saving changes.
BTW, Close_Session is not documented in https://www.collaboraoffice.com/collabora-online-editor-api-reference