1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import * as CodeMirror from "codemirror";
- import "codemirror/addon/edit/closebrackets";
- import "codemirror/addon/edit/matchbrackets";
- // import "codemirror/addon/hint/show-hint";
- // import "codemirror/addon/hint/anyword-hint";
- import "codemirror/addon/selection/active-line";
- import "./../util/editorMode2"
- let codeEditor = null;
- export function initTextEditor (element) {
- let id = element;
- if (element[0] == '#') {
- id = element.substring(1);
- }
- codeEditor = CodeMirror.fromTextArea(document.getElementById(id), {
- value: "",
- mode: "text/x-ivprog",
- indentUnit: 4,
- lineNumbers: true,
- matchBrackets: true,
- autoCloseBrackets: true,
- fixedGutter: true,
- styleActiveLine: true,
- readOnly: true
- });
- }
- export function disable (flag) {
- codeEditor.setOption("readOnly", flag);
- updateEditor();
- }
- export function updateEditor () {
- codeEditor.refresh();
- }
- export function setCode (code) {
- codeEditor.setValue(code);
- }
- export function getCode () {
- return codeEditor.getValue();
- }
|