1 <?xml version="1.0" encoding="utf-8"?>
\r
2 <django-objects version="1.0"><object pk="2" model="toolbar.buttongroup"><field type="CharField" name="name">Autokorekta</field><field type="SlugField" name="slug">autokorekta</field><field type="IntegerField" name="position">0</field></object><object pk="1" model="toolbar.buttongroup"><field type="CharField" name="name">Formatowanie</field><field type="SlugField" name="slug">formatowanie</field><field type="IntegerField" name="position">0</field></object><object pk="4" model="toolbar.button"><field type="CharField" name="label">Novelpages</field><field type="SlugField" name="slug">novelpages</field><field type="TextField" name="params">({exprs: [
\r\r
3 ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."],
\r\r
4 ["„", ",,"] /* DOUBLE LOW-9 QUOTATION MARK */
\r\r
6 </field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">lineregexp</field><field type="CharField" name="key"></field><field type="CharField" name="tooltip">Wykonuję operację z novel-pages.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="2"></object></field></object><object pk="3" model="toolbar.button"><field type="CharField" name="label">Usuń spację</field><field type="SlugField" name="slug">strip_whitespace</field><field type="TextField" name="params">({exprs: [ ["^\\s+|\\s+$", ""], ["\\s+", " "] ]})</field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">lineregexp</field><field type="CharField" name="key"></field><field type="CharField" name="tooltip">Usuwa zbędne spację z dokumentu.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="2"></object></field></object><object pk="1" model="toolbar.button"><field type="CharField" name="label">Wers</field><field type="SlugField" name="slug">insert_verse</field><field type="TextField" name="params">({tag: 'wers'})</field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">insert_tag</field><field type="CharField" name="key">w</field><field type="CharField" name="tooltip">Otacza zaznaczony tekst tagiem 'wers'.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="1"></object></field></object><object pk="2" model="toolbar.button"><field type="CharField" name="label">Zamień dywiz</field><field type="SlugField" name="slug">zamien_dywiz</field><field type="TextField" name="params">({exprs:[ ["—","---"] ]})</field><field to="toolbar.scriptlet" name="scriptlet" rel="ManyToOneRel">lineregexp</field><field type="CharField" name="key"></field><field type="CharField" name="tooltip">Zamienia '—' na '---'.</field><field to="toolbar.buttongroup" name="group" rel="ManyToManyRel"><object pk="2"></object></field></object><object pk="insert_tag" model="toolbar.scriptlet"><field type="TextField" name="code">$.log(editor, panel, params);
\r\r
8 var texteditor = panel.texteditor;
\r\r
9 var text = texteditor.selection();
\r\r
10 texteditor.replaceSelection('<' + params.tag + '>' + text + '</' + params.tag + '>');
\r\r
11 if (text.length == 0)
\r\r
13 var pos = texteditor.cursorPosition();
\r\r
14 texteditor.selectLines(pos.line, pos.character + params.tag.length + 2);
\r\r
17 panel.fireEvent('contentChanged');</field></object><object pk="lineregexp" model="toolbar.scriptlet"><field type="TextField" name="code">// params: {exprs: list of {expr: "", repl: "" [, opts: "g"]}}
\r\r
18 var cm = panel.texteditor;
\r\r
20 var exprs = $.map(params.exprs, function(expr) {
\r\r
22 if(expr.length > 2)
\r\r
24 return {rx: new RegExp(expr[0], opts), repl: expr[1]};
\r\r
27 var selection = cm.selection();
\r\r
31 var lines = selection.split('\n');
\r\r
32 lines = $.map(lines, function(line) {
\r\r
33 $(exprs).each(function() {
\r\r
35 line = line.replace(expr.rx, expr.repl);
\r\r
39 cm.replaceSelection( lines.join('\n') );
\r\r
42 var line = cm.firstLine();
\r\r
44 var content = cm.lineContent(line);
\r\r
45 $.log("Swapping line: $" + content + "$");
\r\r
47 $(exprs).each(function() { var expr = this;
\r\r
48 content = content.replace(expr.rx, expr.repl);
\r\r
50 cm.setLineContent(line, content);
\r\r
51 line = cm.nextLine(line);
\r\r
52 } while( !(line === false) );
\r\r
53 }</field></object></django-objects>
\r