Factor out codemirror code into a separate file. Remove unnecessary local state management in the codemirror instance. That local state already exists in the stateful-by-default codemirror instance.