From: Radek Czajka Date: Thu, 21 Oct 2010 14:34:00 +0000 (+0200) Subject: fixes #849: drama autotagging X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/0171e11c886d0d294fb05f461fe6ec1b389f02d5?ds=sidebyside;hp=1f8f2ceb0d1e77fefe8068370588d54886edee07 fixes #849: drama autotagging --- diff --git a/apps/toolbar/fixtures/initial_data.yaml b/apps/toolbar/fixtures/initial_data.yaml index 769675e9..7ff8e302 100644 --- a/apps/toolbar/fixtures/initial_data.yaml +++ b/apps/toolbar/fixtures/initial_data.yaml @@ -305,6 +305,28 @@ tooltip: "wstawia kwesti\u0119" model: toolbar.button pk: 82 +- fields: + accesskey: '' + group: [12] + label: kwestioakapit + link: '' + params: '[["insert_tag", {"tag": "akap"}], ["insert_tag", {"tag": "kwestia"}]]' + scriptlet: macro + slug: kwestioakapit + tooltip: '' + model: toolbar.button + pk: 101 +- fields: + accesskey: '' + group: [12] + label: kwestiostrofa + link: '' + params: '[["insert_stanza", {"tag": "strofa"}], ["insert_tag", {"tag": "kwestia"}]]' + scriptlet: macro + slug: kwestiostrofa + tooltip: '' + model: toolbar.button + pk: 102 - fields: accesskey: '' group: [11] @@ -404,6 +426,19 @@ tooltip: "Zamienia cudzys\u0142owy podw\xF3jne na niemieckie" model: toolbar.button pk: 3 +- fields: + accesskey: '' + group: [28] + label: "nag\u0142. dramatu" + link: '' + params: '{"exprs": [["^AKT(\\s\\w*)$", "AKT$1"], + ["^SCENA(\\s\\w*)$", "SCENA$1"], ["([A-Z\u0104\u0106\u0118\u0141\u0143\u00d3\u015a\u017b\u0179]{2}[A-Z\u0104\u0106\u0118\u0141\u0143\u00d3\u015a\u017b\u0179\\s]+)$", + "$1"]]}' + scriptlet: lineregexp + slug: nagl-dramatu + tooltip: "autotagowanie akt\xF3w, scen, nag\u0142\xF3wk\xF3w os\xF3b" + model: toolbar.button + pk: 103 - fields: accesskey: '' group: [12] diff --git a/redakcja/static/js/button_scripts.js b/redakcja/static/js/button_scripts.js index c3275938..953383ce 100644 --- a/redakcja/static/js/button_scripts.js +++ b/redakcja/static/js/button_scripts.js @@ -51,7 +51,7 @@ function ScriptletCenter() this.scriptlets['insert_tag'] = function(context, params, text, move_forward, done) { var start_tag = '<'+params.tag; - var move_cursor = false; + var cursor_inside = false; for (var attr in params.attrs) { start_tag += ' '+attr+'="' + params.attrs[attr] + '"'; @@ -83,6 +83,9 @@ function ScriptletCenter() output += end_tag; } output += token; + + // keep cursor inside tag if some previous scriptlet has already moved it + cursor_inside = move_forward != 0; } else { if(params.nocontent) { @@ -90,11 +93,11 @@ function ScriptletCenter() } else { output = start_tag + end_tag; - move_cursor = true; + cursor_inside = true; } } - if (move_cursor) { + if (cursor_inside) { move_forward -= params.tag.length+3; }