3.2.0 • Published 23 days ago

codemirror-console v3.2.0

Weekly downloads
58
License
MIT
Repository
github
Last release
23 days ago

codemirror-console Build Status

This library add Console to CodeMirror.

This library could execute CodeMirror editor's code.

Installation

npm install codemirror-console

If you want to use it as UI library, please use codemirror-console-ui instead of it.

Usage

open index.html

const MirrorConsole = require("codemirror-console");
const content = document.querySelector(".content");
const editor = new MirrorConsole();
editor.setText(content.textContent);
editor.swapWithElement(content); // insert editor
const consoleMock = {
    log: function (arg) {
        function line(text) {
            var div = document.createElement("div");
            div.appendChild(document.createTextNode(text));
            return div;
        }
        document.getElementById("output").appendChild(line(arg));
    }
}
// eval code
editor.runInContext({ console: consoleMock }, function (error, result) {
    if (error) {
        console.error(error);
    }
});
editor.destroy();// remote editor

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

3.2.0

23 days ago

3.1.0

11 months ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

8 years ago

0.1.0

10 years ago

0.0.7

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago