open-nomad/ui/tests/helpers/codemirror.js
Phil Renaud c8455d34d4 Edit Secure Variables as JSON (#13461)
* Toying with insert and update helpers before translation func

* Working prototype that lets you switch between json and tabular

* No longer add the bonus items row in json mode

* Trimmed the ivy from the codemirror (#13503)

* Trimmed the ivy from the codemirror

* editedJSONItems removal

* De-debugger

* Replaced other instances of IvyCodeMirror throughout the app (#13528)

* Replaced other instances of IvyCodeMirror throughout the app

* PR requests for codemirror modifier

* Screen reader setting as param

* Trying a simpler codemirror test helper

* Lint removal

* Screen Reader Label added for a11y

* JSONViewer cleanup

* JSON editor added to /new and all variables stringified before save or translate

* Give users a foothold when editing an empty item in JSON mode

* Copy the empty KV

* No duplicate keys in KV

* Better handling of cursor snapping in json edit field

* Catch formatting errors on the fly

* Basic tests for JSON to Table and Table to JSON in form
2022-07-11 13:34:06 -04:00

20 lines
528 B
JavaScript

export function getCodeMirrorInstance() {
return function () {
return document.querySelector('.CodeMirror').CodeMirror;
};
}
export default function setupCodeMirror(hooks) {
hooks.beforeEach(function () {
this.getCodeMirrorInstance = getCodeMirrorInstance(this.owner);
// Expose to window for access from page objects
window.getCodeMirrorInstance = this.getCodeMirrorInstance;
});
hooks.afterEach(function () {
delete window.getCodeMirrorInstance;
delete this.getCodeMirrorInstance;
});
}