How can I check that the page has been modified but not saved?

Hello,

I use a button in the panel to perform various actions on a page (change status, duplicate, etc.). But before performing these actions, I need to make sure that if the page has been modified, the user has saved it before clicking on the button in question. If this is not the case, I want to display an error message.

How can I check that the page has been modified but not saved?

In the PHP backend, this should work:

$page->version('changes')->exists()

If there is no changes version, everything has been saved.