X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/308aa7c7d75b50a4b36a70681b5e012dbd023c11..7ba0bf0e4c5325d2f78ae640568e6de9ea3e9440:/fixtures/przyciski.xml diff --git a/fixtures/przyciski.xml b/fixtures/przyciski.xml index 1794c6d7..ea1d7246 100644 --- a/fixtures/przyciski.xml +++ b/fixtures/przyciski.xml @@ -83,7 +83,7 @@ A<sup>+</sup> increase_font_size - ({change: 2}) + {"change": 2} codemirror_fontsize + Zwiększ rozmiar czcionki. @@ -94,7 +94,7 @@ A<sup>-</sup> descrease_font_size - ({change: -2}) + {"change": -2} codemirror_fontsize - Zmniejsz rozmiar czcionki. @@ -105,7 +105,7 @@ A<sup>=</sup> reset_font_size - ({fontSize: 13}) + {"fontSize": 13} codemirror_fontsize = Przywróć orginalny rozmiar czcionki. @@ -113,10 +113,65 @@ + + A<sup>↓</sup> + tolowercase + [] + lowercase + u + Zamień wielkie litery na małe. + + + + + + Podstawowa + basic_correction + {"exprs": [["\n\\d+\n", "\n"], ["-\\s*\n+", ""], ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."]]} + fulltextregexp + + Wykonuję operację z novel-pages i poem-pages. + + + + + + Usuń spację + strip_whitespace + {"exprs": [["^\\s+|\\s+$", ""], ["\\s+", " "]]} + lineregexp + + Usuwa zbędne spację z dokumentu. + + + + + + Zamień Cudzysłowy + zamien-cudzyslowy + {"exprs": [["\u00bb|\u201e", ",,"], ["\u00ab", "\""], ["\"([\u0104\u0118\u00d3\u0141\u017b\u0179\u0106\u0143\u0105\u017c\u017a\u015b\u0144\u00f3\u0142\u0107\\w])", ",,$1"]]} + lineregexp + + + + + + + + Zamień dywiz + zamien_dywiz + {"exprs": [["(\\d)[\u2014-](\\d)", "$1--$2"], ["\u2014", "---"]]} + lineregexp + + Zamienia '—' na '---', oraz '1—2' na '1--2'. + + + + akapit akapit - ({tag:"akap"}) + {"tag": "akap"} insert_tag @@ -127,7 +182,7 @@ akapit cd. akapit-cd - ({tag:"akap_cd"}) + {"tag": "akap_cd"} insert_tag @@ -138,7 +193,7 @@ akapit dialogowy akapit-dialogowy - ({tag:"akap_dialog"}) + {"tag": "akap_dialog"} insert_tag @@ -149,7 +204,7 @@ akt akt - ({tag:"akt"}) + {"tag": "akt"} insert_tag @@ -160,7 +215,7 @@ autor autor - ({tag:"autor"}) + {"tag": "autor"} insert_tag @@ -171,7 +226,7 @@ część/księga czesc - ({tag:"naglowek_czesc"}) + {"tag": "naglowek_czesc"} insert_tag @@ -182,7 +237,7 @@ dedykacja dedykacja - ({tag:"dedykacja"}) + {"tag": "dedykacja"} insert_tag @@ -193,7 +248,7 @@ dedykacja dedykacja - ({tag:"dedykacja"}) + {"tag": "dedykacja"} insert_tag @@ -204,7 +259,7 @@ didaskalia didaskalia - ({tag:"didaskalia"}) + {"tag": "didaskalia"} insert_tag @@ -215,7 +270,7 @@ didaskalia didaskalia - ({tag:"didaskalia"}) + {"tag": "didaskalia"} insert_tag @@ -226,7 +281,7 @@ didaskalia wewn. didaskalia-wewn - ({tag:"didask_tekst"}) + {"tag": "didask_tekst"} insert_tag @@ -237,7 +292,7 @@ didaskalia wewn. didaskalia-wewn - ({tag:"didask_tekst"}) + {"tag": "didask_tekst"} insert_tag @@ -248,7 +303,7 @@ dramat wiersz. dramat-wiersz - ({tag:"dramat_wierszowany_l"}) + {"tag": "dramat_wierszowany_l"} insert_tag @@ -259,7 +314,7 @@ dramat wiersz./w. łam dramat-wiersz-w-lam - ({tag:"dramat_wierszowany_lp"}) + {"tag": "dramat_wierszowany_lp"} insert_tag @@ -270,7 +325,7 @@ dramat współczesny dramat-wspolczesny - ({tag:"dramat_wspolczesny"}) + {"tag": "dramat_wspolczesny"} insert_tag @@ -281,7 +336,7 @@ dzieło nadrzędne dzielo-nadrzedne - ({tag:"dzielo_nadrzedne"}) + {"tag": "dzielo_nadrzedne"} insert_tag @@ -292,7 +347,7 @@ długi cyt. poet. dlugi-cyt-poet - ({tag:"poezja_cyt"}) + {"tag": "poezja_cyt"} insert_tag @@ -303,7 +358,7 @@ długi cyta. poet. dlugi-cyt-poet - ({tag:"poezja_cyt"}) + {"tag": "poezja_cyt"} insert_tag @@ -314,29 +369,19 @@ długi cytat dlugi-cytat - ({tag:"dlugi_cyt"}) + {"tag": "dlugi_cyt"} insert_tag - - - - długi cytat - dlugi-cytat - dlugi_cytat - insert_tag - - - ekstra ekstra - ({tag:"ekstra"}) + {"tag": "ekstra"} insert_tag @@ -347,7 +392,7 @@ kwestia kwestia - ({tag:"kwestia"}) + {"tag": "kwestia"} insert_tag @@ -358,7 +403,7 @@ kwestia kwestia - ({tag:"kwestia"}) + {"tag": "kwestia"} insert_tag @@ -369,7 +414,7 @@ liryka liryka - ({tag:"liryka_l"}) + {"tag": "liryka_l"} insert_tag @@ -380,7 +425,7 @@ liryka/w. łam liryka-w-lam - ({tag:"liryka_lp"}) + {"tag": "liryka_lp"} insert_tag @@ -391,7 +436,7 @@ mamtemat. matemat - ({tag:"mat"}) + {"tag": "mat"} insert_tag @@ -402,7 +447,7 @@ motto motto - ({tag:"motto"}) + {"tag": "motto"} insert_tag @@ -413,7 +458,7 @@ motto motto - ({tag:"motto"}) + {"tag": "motto"} insert_tag @@ -424,7 +469,7 @@ motto podpis motto-podpis - ({tag:"motto_podpis"}) + {"tag": "motto_podpis"} insert_tag @@ -435,7 +480,7 @@ nagłówek kwestii naglowek-kwestii - ({tag:"naglowek_osoba"}) + {"tag": "naglowek_osoba"} insert_tag @@ -446,7 +491,7 @@ nota nota - ({tag:"nota"}) + {"tag": "nota"} insert_tag @@ -454,27 +499,10 @@ - - Novelpages - novelpages - ({exprs: [ - - ["\\,\\.\\.|\\.\\,\\.|\\.\\.\\,", "..."], - - ["„", ",,"] /* DOUBLE LOW-9 QUOTATION MARK */ - -]}) - lineregexp - - Wykonuję operację z novel-pages. - - - - opowiadanie opowiadanie - ({tag:"opowiadanie"}) + {"tag": "opowiadanie"} insert_tag @@ -485,7 +513,7 @@ osoba osoba - ({tag:"osoba"}) + {"tag": "osoba"} insert_tag @@ -496,7 +524,7 @@ osoba osoba - ({tag:"osoba"}) + {"tag": "osoba"} insert_tag @@ -507,7 +535,7 @@ podrozdział podrozdzial - ({tag:"naglowek_podrozdzial"}) + {"tag": "naglowek_podrozdzial"} insert_tag @@ -518,7 +546,7 @@ podtytuł podtytul - ({tag:"podtytul"}) + {"tag": "podtytul"} insert_tag @@ -529,7 +557,7 @@ powieść powiesc - ({tag:"powiesc"}) + {"tag": "powiesc"} insert_tag @@ -540,7 +568,7 @@ przypis autorski przypis-autorski - ({tag:"pa"}) + {"tag": "pa"} insert_tag @@ -551,7 +579,7 @@ przypis edytorski przypis-edytorski - ({tag:"pe"}) + {"tag": "pe"} insert_tag @@ -562,7 +590,7 @@ przypis redaktorski przypis-redaktorski - ({tag:"pr"}) + {"tag": "pr"} insert_tag @@ -573,7 +601,7 @@ przypis tłumacza przypis-tlumacza - ({tag:"pt"}) + {"tag": "pt"} insert_tag @@ -584,7 +612,7 @@ rozdział rozdzial - ({tag:"naglowek_rozdzial"}) + {"tag": "naglowek_rozdzial"} insert_tag @@ -595,7 +623,7 @@ scena scena - ({tag:"naglowek_scena"}) + {"tag": "naglowek_scena"} insert_tag @@ -606,7 +634,7 @@ sep. asteryks sep-asteryks - ({tag:"sekcja_asteryks"}) + {"tag": "sekcja_asteryks"} insert_tag @@ -617,7 +645,7 @@ sep. linia sep-linia - ({tag:"separator_linia"}) + {"tag": "separator_linia"} insert_tag @@ -628,7 +656,7 @@ sep. światło sep-swiatlo - ({tag:"sekcja_swiatlo"}) + {"tag": "sekcja_swiatlo"} insert_tag @@ -636,32 +664,10 @@ - - śródtytuł - srodtytul - ({tag:"srodtytul"}) - insert_tag - - - - - - - - strofa - strofa - ({tag"strofa"}) - insert_tag - - - - - - strofa strofa - ({tag:"strofa"}) + {"tag": "strofa"} insert_tag @@ -672,7 +678,7 @@ słowo obce slowo-obce - ({tag:"slowo_obce"}) + {"tag": "slowo_obce"} insert_tag @@ -683,7 +689,7 @@ tagi główne tagi-glowne - ({tag:"utwor"}) + {"tag": "utwor"} insert_tag @@ -694,7 +700,7 @@ tytuł tytul - ({tag:"nazwa_utworu"}) + {"tag": "nazwa_utworu"} insert_tag @@ -705,7 +711,7 @@ tytuł dzieła tytul-dziela - ({tag:"tytul_dziela"}) + {"tag": "tytul_dziela", "attrs": {"typ": " "}} insert_tag @@ -713,21 +719,10 @@ - - Usuń spację - strip_whitespace - ({exprs: [ ["^\\s+|\\s+$", ""], ["\\s+", " "] ]}) - lineregexp - - Usuwa zbędne spację z dokumentu. - - - - uwaga uwaga - ({tag:"uwaga"}) + {"tag": "uwaga"} insert_tag @@ -738,7 +733,7 @@ wers akap. wers-akap - ({tag:"wers_akap"}) + {"tag": "wers_akap"} insert_tag @@ -749,7 +744,7 @@ wers akap. wers-akap - ({tag:"wers_akap"}) + {"tag": "wers_akap"} insert_tag @@ -760,7 +755,7 @@ wers cd. wers-cd - ({tag:"wers_cd"}) + {"tag": "wers_cd"} insert_tag @@ -771,7 +766,7 @@ wers cd. wers-cd - ({tag:"wers_cd"}) + {"tag": "wers_cd"} insert_tag @@ -782,7 +777,7 @@ wers wcięty wers-wciety - ({tag:"wers_wciety"}) + {"tag": "wers_wciety"} insert_tag @@ -793,7 +788,7 @@ wers wcięty wers-wciety - ({tag:"wers_wciety"}) + {"tag": "wers_wciety"} insert_tag @@ -804,7 +799,7 @@ www www - ({tag:"www"}) + {"tag": "www"} insert_tag @@ -815,7 +810,7 @@ wyróżnienie wyroznienie - ({tag:"wyroznienie"}) + {"tag": "wyroznienie"} insert_tag @@ -826,7 +821,7 @@ wywiad wywiad - ({tag:"wywiad"}) + {"tag": "wywiad"} insert_tag @@ -837,7 +832,7 @@ wywiad odpowiedź wywiad-odpowiedz - ({tag:"wywiad_odp"}) + {"tag": "wywiad_odp"} insert_tag @@ -848,7 +843,7 @@ wywiad pytanie wywiad-pytanie - ({tag:"wywiad_pyt"}) + {"tag": "wywiad_pyt"} insert_tag @@ -856,21 +851,10 @@ - - Zamień dywiz - zamien_dywiz - ({exprs:[ ["—","---"] ]}) - lineregexp - - Zamienia '—' na '---'. - - - - zastępnik wersu zastepnik-wersu - ({tag:"zastepnik_wersu"}) + {"tag": "zastepnik_wersu"} insert_tag @@ -878,20 +862,43 @@ + + śródtytuł + srodtytul + {"tag": "srodtytul"} + insert_tag + + + + + + - $.log(editor, panel, params); + var texteditor = panel.texteditor; +var text = texteditor.selection(); +var out = '<'+params.tag; -var texteditor = panel.texteditor; +for (var attr in params.attrs) { -var text = texteditor.selection(); + out += ' '+attr+'="' + params.attrs[attr] + '"'; -texteditor.replaceSelection('<' + params.tag + '>' + text + '</' + params.tag + '>'); +}; -if (text.length == 0) +out += '>'; + +out += text; + +out += '</' + params.tag + '>'; + + + +texteditor.replaceSelection(out); -{ + + +if (text.length == 0) { var pos = texteditor.cursorPosition(); @@ -905,56 +912,86 @@ 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 changed = false; - var lines = selection.split('\n'); - var lines = $.map(lines, function(line) { - var old_line = line; - $(exprs).each(function() { - var expr = this; - line = line.replace(expr.rx, expr.repl); - }); - if(old_line != line) changed = true; - return line; + +var partial = true; + +var text = cm.selection(); + + + +if(!text) { + + var cpos = cm.cursorPosition(); + + cpos.line = cm.lineNumber(cpos.line) + + cm.selectLines(cm.firstLine(), 0, cm.lastLine(), 0); + + text = cm.selection(); + + partial = false; + +} + + + +var changed = false; + +var lines = text.split('\n'); + +var lines = $.map(lines, function(line) { + + var old_line = line; + + $(exprs).each(function() { + + var expr = this; + + line = line.replace(expr.rx, expr.repl); + }); - if(changed) { - cm.replaceSelection( lines.join('\n') ); - panel.fireEvent('contentChanged'); - } + if(old_line != line) changed = true; + + return line; + +}); + + + +if(changed) + +{ + + cm.replaceSelection( lines.join('\n') ); + + panel.fireEvent('contentChanged'); + } -else { - var line = cm.firstLine(); - var hasChanges = false; - do { - var content = cm.lineContent(line); - var old_content = content; - $(exprs).each(function() { var expr = this; - content = content.replace(expr.rx, expr.repl); - }); - - if(old_content != content) { - cm.setLineContent(line, content); - hasChanges = true; - } - - line = cm.nextLine(line); - } while( !(line === false) ); - - if(hasChanges) panel.fireEvent('contentChanged'); -} + + + +if(!partial) + + cm.selectLines( cm.nthLine(cpos.line), cpos.character ) var texteditor = panel.texteditor; @@ -977,4 +1014,95 @@ else { } + + var cm = panel.texteditor; + +var exprs = $.map(params.exprs, function(expr) { + + var opts = "mg"; + + if(expr.length > 2) + + opts = expr[2]; + + return {rx: new RegExp(expr[0], opts), repl: expr[1]}; + +}); + + + +var partial = true; + +var text = cm.selection(); + + + +if(!text) { + + var cpos = cm.cursorPosition(); + + cpos.line = cm.lineNumber(cpos.line) + + cm.selectLines(cm.firstLine(), 0, cm.lastLine(), 0); + + text = cm.selection(); + + partial = false; + +} + + + +var original = text; + + + +$(exprs).each(function() { + + text = text.replace(this.rx, this.repl); + +}); + + + +if( original != text) { + + cm.replaceSelection(text); + + panel.fireEvent('contentChanged'); + +} + + + +if(!partial) { + + cm.selectLines( cm.nthLine(cpos.line), cpos.character ); + +} + + + params.each(function() { + + editor.callScriptlet(this[0], this[1]); + +}); + + + var cm = panel.texteditor; + +var text = cm.selection(); + +if(!text) return; + +var repl = text.toLowerCase(); + +if(repl != text) { + + cm.replaceSelection(repl); + + panel.fireEvent('contentChanged'); + +}; +