Skip to content

Commit

Permalink
Merge pull request #1117 from tidalcycles/strudelmirror-in-scope
Browse files Browse the repository at this point in the history
add strudelMirror to scope
  • Loading branch information
felixroos committed May 30, 2024
2 parents d86a183 + e408fed commit 6585640
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/codemirror/codemirror.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ export class StrudelMirror {
clear() {
this.onStartRepl && document.removeEventListener('start-repl', this.onStartRepl);
}
getCursorLocation() {
return this.editor.state.selection.main.head;
}
setCursorLocation(col) {
return this.editor.dispatch({ selection: { anchor: col } });
}
appendCode(code) {
const cursor = this.getCursorLocation();
this.setCode(this.code + code);
this.setCursorLocation(cursor);
}
}

function parseBooleans(value) {
Expand Down
1 change: 1 addition & 0 deletions website/src/repl/Repl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export function Repl({ embedded = false }) {
},
bgFill: false,
});
window.strudelMirror = editor;

// init settings

Expand Down

0 comments on commit 6585640

Please sign in to comment.