In the previous guide, we have learned how to create a basic Tool class with minimal required methods. In this part, we consider how to render previously saved data.
When user will edit previously saved article, Editor will get saved data by the dataproperty. Then the Editor will render Blocks one-by-one and pass them their data.
Let's add a saved data we got in the previous part to initialization at the example.html:
We should provide a mechanism for showing saved data by our Tool. It is quite simple: data will be passed to the class's constructor, so we can save it at the property, for example this.data and access later by any method, including render:
We will create a wrapper where all Tool's elements will be placed, add a placeholder and CSS class for Tool. Don't forget to modify the save method: Block content will be a wrapper instead of input, so we need to get an input by ourselves. Now our class looks like this.