From 83be4d392d94be5d759a5632818b90ebf0afa763 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 6 Nov 2020 17:27:12 +0100 Subject: [PATCH 1/1] Adding references. --- .../static/js/wiki/view_editor_wysiwyg.js | 82 ++++++++++++++++-- src/redakcja/static/js/wiki/xslt.js | 2 +- src/redakcja/static/xsl/wl2html_client.xsl | 9 +- src/wiki/locale/pl/LC_MESSAGES/django.mo | Bin 3912 -> 4003 bytes src/wiki/locale/pl/LC_MESSAGES/django.po | 18 ++-- .../templates/wiki/tabs/wysiwyg_editor.html | 7 +- 6 files changed, 102 insertions(+), 16 deletions(-) diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index f056edc9..c1c9f6f1 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -110,6 +110,50 @@ } + function addReference(){ + var selection = window.getSelection(); + var n = selection.rangeCount; + + if (n == 0) { + window.alert("Nie zaznaczono żadnego obszaru"); + return false; + } + + // for now allow only 1 range + if (n > 1) { + window.alert("Zaznacz jeden obszar"); + return false; + } + + // remember the selected range + var range = selection.getRangeAt(0); + + if (!verifyTagInsertPoint(range.endContainer)) { + window.alert("Nie można wstawić w to miejsce przypisu."); + return false; + } + + var tag = $(''); + range.collapse(false); + range.insertNode(tag[0]); + + xml2html({ + xml: '', + success: function(text){ + var t = $(text); + tag.replaceWith(t); + openForEdit(t); + }, + error: function(){ + tag.remove(); + alert('Błąd przy dodawaniu referncji:' + errors); + } + }) + } + + + + /* Insert theme using current selection */ function addTheme(){ @@ -377,7 +421,7 @@ var w = $box.outerWidth(); var h = $box.innerHeight(); - if ($origin.is(".annotation-inline-box")) { + if ($origin.is(".annotation-inline-box") | $origin.is('*[x-edit-no-format]')) { w = Math.max(w, 400); h = Math.max(h, 60); if($('.htmlview div').offset().left + $('.htmlview div').width() > ($('.vsplitbar').offset().left - 480)){ @@ -397,8 +441,11 @@ }).appendTo($box[0].offsetParent || $box.parent()).show(); - if ($origin.is('.motyw')) { + if ($origin.is('*[x-edit-no-format]')) { $('.akap-edit-button').remove(); + } + + if ($origin.is('.motyw')) { $.themes.autocomplete($('textarea', $overlay)); } @@ -412,7 +459,7 @@ }; }); } - else if($box.is('*[x-annotation-box]')) { + else if($box.is('*[x-annotation-box]') || $origin.is('*[x-edit-attribute]')) { $('.delete-button', $overlay).click(function(){ if (window.confirm("Czy jesteś pewien, że chcesz usunąć ten przypis?")) { $origin.remove(); @@ -436,8 +483,16 @@ var serializer = new XMLSerializer(); + if($box.attr("x-edit-attribute")) { + source = $(''); + source.text($box.attr("data-wlf-" + $box.attr("x-edit-attribute"))); + source = source[0]; + } else { + source = $box[0]; + } + html2text({ - element: $box[0], + element: source, stripOuter: true, success: function(text){ $('textarea', $overlay).val($.trim(text)); @@ -454,13 +509,24 @@ insertedText = insertedText.replace(/,\s*$/, ''); } + if($box.attr("x-edit-attribute")) { + xml = '<' + nodeName + ' ' + $box.attr("x-edit-attribute") + '="' + insertedText + '"/>'; + } else { + xml = '<' + nodeName + '>' + insertedText + ''; + } + + xml2html({ - xml: '<' + nodeName + '>' + insertedText + '', + xml: xml, success: function(element){ if (nodeName == 'out-of-flow-text') { $(element).children().insertAfter($origin); $origin.remove() } + else if ($box.attr('x-edit-attribute')) { + $(element).insertAfter($origin); + $origin.remove(); + } else { $origin.html($(element).html()); } @@ -535,6 +601,7 @@ }); } + function VisualPerspective(options){ var old_callback = options.callback; @@ -563,6 +630,11 @@ } }); + $('#insert-reference-button').click(function(){ + addReference(); + return false; + }); + $('#insert-annotation-button').click(function(){ addAnnotation(); return false; diff --git a/src/redakcja/static/js/wiki/xslt.js b/src/redakcja/static/js/wiki/xslt.js index 1c693521..06228cd8 100644 --- a/src/redakcja/static/js/wiki/xslt.js +++ b/src/redakcja/static/js/wiki/xslt.js @@ -17,7 +17,7 @@ function withStylesheets(code_block, onError) if (!xml2htmlStylesheet) { $.blockUI({message: 'Ładowanie arkuszy stylów...'}); $.ajax({ - url: STATIC_URL + 'xsl/wl2html_client.xsl?2019121801', + url: STATIC_URL + 'xsl/wl2html_client.xsl?20201106', dataType: 'xml', timeout: 10000, success: function(data) { diff --git a/src/redakcja/static/xsl/wl2html_client.xsl b/src/redakcja/static/xsl/wl2html_client.xsl index f5a442bb..51ea70f2 100644 --- a/src/redakcja/static/xsl/wl2html_client.xsl +++ b/src/redakcja/static/xsl/wl2html_client.xsl @@ -718,6 +718,13 @@ + + + + 📌 + + + @@ -737,7 +744,7 @@ - + diff --git a/src/wiki/locale/pl/LC_MESSAGES/django.mo b/src/wiki/locale/pl/LC_MESSAGES/django.mo index cc5b3a5952621ee1ec25def79329a87d8f1c528b..ce96f6ec674a38a7efb5329af5eb3cf34f59a5a7 100644 GIT binary patch delta 1661 zcmZwHOKeP09LMo9)nYoMXwjnddcQjDbXqN?UL}Y}g2W@z$k1D+bf(&2XvByR5i7Y7 zL9oC=B!VU+1PNVuY&>?A5H^hkO;?DG?{9j_#?Aci=iE8>-19&GduCotyjGI_n4f*l zaMTmUL{*kC+i-0*CyqNg#su#vlrhh6siy}juq4w*M2BbKQd@v5-NUa25u!7M18q)Wn;y0Gp7B zO$P>;-(04l2j4{9cstW!%oF5eUU3?V@9g&;Qn8zsHScfdqtj0pzgxq5Gq9#0qTEJ1%_|vxk z3ToxIPzk?8t@thK{x8;VX&PGDPkTdvEvwQMqXtZ|*Hx$$EI=i^4wXm)>eV#kbUc9? ze+yNKd-nPf@-fdiY5ZGj`ZJ9PU-Y3SoJy}&JQuaX#i)r_*y}B*2^vrdG@>fAAC<^y zWNT!~3uZ1ci>TEF$AW$`XGg#PMKnW%2CHP6td6KAcvhyYrKpXnqoNGfq7%%4X~KemBG+i((5LsSu&?T5<<)oTu+ zJw4s4%PCx;e>PP`n^;vWA?6ch#8g6mXkj9Ys3cTjRd3)}LSshfg`879f1BInwz=_L zZfDVu$yweS|Fr52a^Bo^b-D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3@rd^65x-}9+C|3{A}?o8#KDe6m{h&{c0WMte7498=GLnGr(OMcfc DzloEM diff --git a/src/wiki/locale/pl/LC_MESSAGES/django.po b/src/wiki/locale/pl/LC_MESSAGES/django.po index 22fbe4f5..1eb74fd0 100644 --- a/src/wiki/locale/pl/LC_MESSAGES/django.po +++ b/src/wiki/locale/pl/LC_MESSAGES/django.po @@ -7,15 +7,15 @@ msgid "" msgstr "" "Project-Id-Version: Platforma Redakcyjna\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2013-07-10 16:58+0100\n" +"PO-Revision-Date: 2020-11-06 17:26+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: Fundacja Nowoczesna Polska \n" -"Language: \n" +"Language: pl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.5.4\n" +"X-Generator: Poedit 2.3\n" #: wiki/forms.py:17 wiki/forms.py:61 wiki/views.py:284 msgid "Publishable" @@ -43,7 +43,7 @@ msgstr "Twój komentarz" #: wiki/forms.py:50 msgid "Describe changes you made." -msgstr "Opisz swoje zmiany" +msgstr "Opisz swoje zmiany." #: wiki/forms.py:56 msgid "Completed" @@ -99,7 +99,7 @@ msgstr "Wersja" #: wiki/templates/wiki/document_details_base.html:52 msgid "Unknown" -msgstr "nieznana" +msgstr "Nieznana" #: wiki/templates/wiki/document_details_base.html:54 #: wiki/templates/wiki/pubmark_dialog.html:16 @@ -244,11 +244,11 @@ msgstr "stron maszynopisu" #: wiki/templates/wiki/tabs/summary_view.html:41 msgid "without footnotes and themes" -msgstr "" +msgstr "bez przypisów i motywów" #: wiki/templates/wiki/tabs/summary_view.html:42 msgid "with footnotes and themes" -msgstr "" +msgstr "z przypisami i motywami" #: wiki/templates/wiki/tabs/summary_view.html:45 msgid "untagged" @@ -266,6 +266,10 @@ msgstr "Wstaw motyw" msgid "Insert annotation" msgstr "Wstaw przypis" +#: wiki/templates/wiki/tabs/wysiwyg_editor.html:13 +msgid "Insert reference" +msgstr "Wstaw referencję" + #: wiki/templates/wiki/tabs/wysiwyg_editor_item.html:3 msgid "Visual editor" msgstr "Edytor wizualny" diff --git a/src/wiki/templates/wiki/tabs/wysiwyg_editor.html b/src/wiki/templates/wiki/tabs/wysiwyg_editor.html index 296f60a3..8b65bb55 100644 --- a/src/wiki/templates/wiki/tabs/wysiwyg_editor.html +++ b/src/wiki/templates/wiki/tabs/wysiwyg_editor.html @@ -6,10 +6,13 @@ - - {% endif %} + + {% endif %}
-- 2.20.1