From: Łukasz Rekucki Date: Fri, 4 Sep 2009 09:19:36 +0000 (+0200) Subject: Wersja XML. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/d8ac9c9786c906979c58e97b7c6df302c5d32770?ds=sidebyside Wersja XML. --- diff --git a/fixtures/przyciski.xml b/fixtures/przyciski.xml new file mode 100644 index 00000000..a8ad2c19 --- /dev/null +++ b/fixtures/przyciski.xml @@ -0,0 +1,53 @@ + +Autokorektaautokorekta0Formatowanieformatowanie0Novelpagesnovelpages({exprs: [ + ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."], + ["„", ",,"] /* DOUBLE LOW-9 QUOTATION MARK */ +]}) + lineregexpWykonuję operację z novel-pages.Usuń spacjęstrip_whitespace({exprs: [ ["^\\s+|\\s+$", ""], ["\\s+", " "] ]})lineregexpUsuwa zbędne spację z dokumentu.Wersinsert_verse({tag: 'wers'})insert_tagwOtacza zaznaczony tekst tagiem 'wers'.Zamień dywizzamien_dywiz({exprs:[ ["—","---"] ]})lineregexpZamienia '—' na '---'.$.log(editor, panel, params); + +var texteditor = panel.texteditor; +var text = texteditor.selection(); +texteditor.replaceSelection('<' + params.tag + '>' + text + '</' + params.tag + '>'); +if (text.length == 0) +{ + var pos = texteditor.cursorPosition(); + texteditor.selectLines(pos.line, pos.character + params.tag.length + 2); +} + +panel.fireEvent('contentChanged');// params: {exprs: list of {expr: "", repl: "" [, opts: "g"]}} +var cm = panel.texteditor; + +var exprs = $.map(params.exprs, function(expr) { + var opts = "g"; + if(expr.length > 2) + opts = expr[2]; + return {rx: new RegExp(expr[0], opts), repl: expr[1]}; +}); + +var selection = cm.selection(); + +if(selection) +{ + var lines = selection.split('\n'); + lines = $.map(lines, function(line) { + $(exprs).each(function() { + var expr = this; + line = line.replace(expr.rx, expr.repl); + }); + return line; + }); + cm.replaceSelection( lines.join('\n') ); +} +else { + var line = cm.firstLine(); + do { + var content = cm.lineContent(line); + $.log("Swapping line: $" + content + "$"); + + $(exprs).each(function() { var expr = this; + content = content.replace(expr.rx, expr.repl); + }); + cm.setLineContent(line, content); + line = cm.nextLine(line); + } while( !(line === false) ); +}