Saving and loading of custom web part properties is supported by the SharePoint Framework.
Override onBeforeSerialize
and onAfterDeserialize
in your web part class:
protected onBeforeSerialize(): void {
super.onBeforeSerialize();
// modify the web part's properties here - the modified version will be saved
this.properties.description = "save me";
}
protected onAfterDeserialize(deserializedObject: any, dataVersion: Version): IEmbedConfluenceContentWebPartProps {
// handle loaded data object here, modify/convert it if necessary
console.log(JSON.stringify(deserializedObject));
console.log(JSON.stringify(dataVersion));
return super.onAfterDeserialize(deserializedObject, dataVersion);
}
The rest is being taken care of by the framework. SharePoint Framework will call these methods when appropriate. (In my case onBeforeSerialize
was called every second, so be prepared for this.)
Under the hood:
Properties are saved by the framework using the REST endpoint: /_api/sitepages/pages(number)/SavePage
.
The actual data is stored in a page property CanvasContent1
and can be viewed with tools like SharePoint Online Client Browser.