Add replace and insert code helpers to codemirror
This commit is contained in:
parent
ef5ddc90c2
commit
e15ce7d402
1 changed files with 8 additions and 6 deletions
|
|
@ -444,14 +444,16 @@ export class StrudelMirror {
|
||||||
this.setFontSize(value);
|
this.setFontSize(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setCode(code) {
|
replaceCode(code, from, to) {
|
||||||
const changes = {
|
const changes = { from, to, insert: code };
|
||||||
from: 0,
|
|
||||||
to: this.editor.state.doc.length,
|
|
||||||
insert: code,
|
|
||||||
};
|
|
||||||
this.editor.dispatch({ changes });
|
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
|
// used for debugging but could serve other purposes
|
||||||
getActiveWidgets() {
|
getActiveWidgets() {
|
||||||
return getActiveWidgets(this.editor);
|
return getActiveWidgets(this.editor);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue