Created: 2017.04.13
CodePen is great, but an embedded shortcode is not great from an authoring perspective. Is there a better way to integrate snippet authoring into WordPress?
Ace is an embeddable code editor written in JavaScript. It matches the features and performance of native editors such as Sublime, Vim and TextMate. It can be easily embedded in any web page and JavaScript application.
Question..
I am currently testing the Ace code editor(http://ace.c9.io/) and embedded into a webpage. I am wondering if it's possible to create a output console to display console.log and output commands. Currently, I am using eval() to evaluate the code but as there is no console, the console.log command won't display. I want the editor to be able to output like in CodeCademy.
Answer..
Console is completely unrelated to ace. You need to create your own. Which is not very hard, you need to overwrite the global for console, and write some function that stringifies objects and either adds that string to another editor or to a dom node. You may want to have a look at other projects that have a console e.g. https://github.com/jsbin/jsbin/blob/master/public/js/render/console.js
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.
A rich programming API and a CSS theming system are available for customizing CodeMirror to fit your application, and extending it with new functionality.
https://github.com/azu/codemirror-console
- https://en.wikipedia.org/wiki/Comparison_of_JavaScript-based_source_code_editors
- http://qnimate.com/create-an-frontend-editor-with-code-highlighting-and-execution/ - buggy
- https://blog.codepen.io/2016/01/27/new-feature-javascript-console/
- http://tributary.io/inlet/5562666 - working demo using Codemirror plus a custom console
- Stack Snippets