Save scripts and update palette when undeleting a block or comment

Fixes #330.
Fixes #329.