Update edit.php

split the saving code so as to not reload the main document, preserving undo memory