This fixes #40 by storing the current code (whenever it changes) in sessionStorage and bringing it back on re-instantiation. The new code is added to the CodeMirror widget's history stack to make undo/revert easy.
Also, this change requires each widget on a page to have a unique identifier, so that each widget can have its own unique sessionStorage key. This identifier is created by combining the document.referrer of the widget (i.e., the URL of the embedding page) with a number based on the position of the widget in the embedding page's DOM.
This fixes #40 by storing the current code (whenever it changes) in
sessionStorage
and bringing it back on re-instantiation. The new code is added to the CodeMirror widget's history stack to make undo/revert easy.Also, this change requires each widget on a page to have a unique identifier, so that each widget can have its own unique
sessionStorage
key. This identifier is created by combining thedocument.referrer
of the widget (i.e., the URL of the embedding page) with a number based on the position of the widget in the embedding page's DOM.