lowcode-engine icon indicating copy to clipboard operation
lowcode-engine copied to clipboard

Question : SavePage, detect if a save is needed

Open aderici opened this issue 3 years ago • 5 comments

Hi, i'd like to provide visual feedback to the user that a "save page" is needed or not. What would be the best approach about it?

I have tried project.onChangeDocument but this only fires if you open a new document. I have also tried doc.history.onChangeCursor but when you take new actions cursor always stays the same (i guess because history goes like -1 -2 -3 and current cursor is always 0)

Best regards,

aderici avatar Dec 13 '22 23:12 aderici

project.getCurrentDocument().history.isSavePoint() try this

JackLian avatar Dec 14 '22 00:12 JackLian

Thanks @JackLian this probably gives me the data i'm looking for. But that's not an event, how can i "listen" to the changes so that i can auto enable/disable the save button?

aderici avatar Dec 14 '22 00:12 aderici

try combine these two ways together, 1. check if isSavePoint === true when plugin inited, 2. monitor onChangeDocument, on event fired, check isSavePoint again. should be working

JackLian avatar Dec 14 '22 00:12 JackLian

@JackLian onChangeDocument only fires if you load a completely different document. It doesn't fire when you add a new button or another component to the current document. What i'm looking for sounds like a schema change event

aderici avatar Dec 14 '22 00:12 aderici

emmmm, well then we should provide an api to fire on every change, try this, monitor onAddNode onRemoveNode onChangeNodeProp at the same time,should cover all the cases

JackLian avatar Dec 14 '22 00:12 JackLian