AceWidget is a widget which make ace/besping trivial to embed in your pages. The Vision is to be super simple to embed and have no server to setup. It provide the whole official embeded api. The code is available on github under MIT license and has been written by Jerome Etienne. That's it. No fuss no muss.
show, dont tell, here is a demo.
You add the following in your own page. and that it
<iframe src="http://jeromeetienne.github.com/acewidget/iframe.html"></iframe>
You can add constructor parameters the url. For example
http://jeromeetienne.github.com/acewidget/iframe.html?theme=twilight&mode=javascript
theme
To set the theme of the editor
mode
To set the mode of the editor
The api calls are done via the usual window.postMessage() to send message to the acewidget
It is jsend compatible.
It is possible to pass private data to the sent event. They will be treated as opaque data by the widget. The widget will include it in its reply. The field name is 'userdata'
setTheme
: To change current theme to twilight
{
type : "setTheme",
data : {
theme : "twilight"
}
}
setMode
: To change current mode to javascript
{
type : "setMode",
data : {
mode : "javascript"
}
}
setValue
: To change current text content
{
type : "setValue",
data : {
text : "supernewtext"
}
}
getValue
: get the current text content
{
type : "getValue",
userdata: "foobar"
}
It will returns
{
status : "succeed",
data : {
data : "super text content from widget",
userdata: "foobar"
}
}
gotoLine
: To change the current line to 42
{
type : "setValue",
data : {
line : 42
}
}
setTabSize
: To change the current tabsize to 8
{
type : "setTabSize",
data : {
size : 8
}
}