mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-31 13:21:52 -04:00
Add replace and insert code helpers to codemirror
This commit is contained in:
@@ -444,14 +444,16 @@ export class StrudelMirror {
|
||||
this.setFontSize(value);
|
||||
}
|
||||
}
|
||||
setCode(code) {
|
||||
const changes = {
|
||||
from: 0,
|
||||
to: this.editor.state.doc.length,
|
||||
insert: code,
|
||||
};
|
||||
replaceCode(code, from, to) {
|
||||
const changes = { from, to, insert: code };
|
||||
this.editor.dispatch({ changes });
|
||||
}
|
||||
insertCode(code, position) {
|
||||
this.replaceCode(code, position, position);
|
||||
}
|
||||
setCode(code) {
|
||||
this.replaceCode(code, 0, this.editor.state.doc.length);
|
||||
}
|
||||
// used for debugging but could serve other purposes
|
||||
getActiveWidgets() {
|
||||
return getActiveWidgets(this.editor);
|
||||
|
||||
Reference in New Issue
Block a user