code: def commit(self):
          
          if self.after is None:
              # If this is the first 'commit' call then do not make
              # any changes but store the current document state.
              self.after = self.qteWidget.toHtml()
          else:
              # Put the document into the edited state.
              pos = self.qteWidget.textCursor().position()
              self.qteWidget.setHtml(self.after)
              self.placeCursor(pos)
docs: Put the document into the new state.