Merge branch 'view-refactor' of stigma:platforma into zuber-view-refactor
[redakcja.git] / project / templates / toolbar_api / scriptlets.js
1 function ScriptletCenter() {
2
3     this.scriptlets = {
4         {% for scriptlet in scriptlets %}
5         "{{scriptlet.name}}": function(context, params) {
6             {{scriptlet.code|safe}}
7         },
8         {% endfor %}
9
10         _none: null
11     };   
12             
13 }
14
15 ScriptletCenter.prototype.XMLEditorSelectedText = function(panel) {
16     return panel.contentView.editor.selection();
17 }
18
19 ScriptletCenter.prototype.XMLEditorReplaceSelectedText = function(panel, replacement)
20 {
21     panel.contentView.editor.replaceSelection(replacement);
22     /* TODO: fire the change event */
23 }
24
25 ScriptletCenter.prototype.XMLEditorMoveCursorForward = function(panel, n) {
26     var pos = panel.contentView.editor.cursorPosition();
27     panel.contentView.editor.selectLines(pos.line, pos.character + n);
28 }
29
30 scriptletCenter = new ScriptletCenter();