From: Radek Czajka Date: Fri, 3 Jan 2025 13:36:16 +0000 (+0100) Subject: reference previews X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/refs/heads/master reference previews --- diff --git a/src/redakcja/static/css/html.scss b/src/redakcja/static/css/html.scss index d9886d4f..91482107 100644 --- a/src/redakcja/static/css/html.scss +++ b/src/redakcja/static/css/html.scss @@ -300,12 +300,19 @@ div[x-node] > .uwaga { * Przypisy w tekście */ -.htmlview .annotation-inline-box { - &:hover > span[x-annotation-box] { - display: block; +.htmlview .annotation-inline-box, +.htmlview .reference-inline-box { + &:hover { + > span[x-annotation-box], + > span[x-preview] + { + display: block; + } } - > span[x-annotation-box] { + > span[x-annotation-box], + > span[x-preview] + { display: none; width: 300px; font-size: 10pt; diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index 726c2439..c5fa8c13 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -515,7 +515,8 @@ element: source, stripOuter: true, success: function(text){ - $('textarea', $overlay).val($.trim(text)); + let ttext = $.trim(text); + $('textarea', $overlay).val(ttext); setTimeout(function(){ $('textarea', $overlay).elastic().focus(); @@ -659,6 +660,26 @@ $('*[x-annotation-box]', editable).css({ }).show(); } + if (editable.is('.reference-inline-box')) { + let preview = $('*[x-preview]', editable); + preview.show(); + let link = $("a", preview); + let href = link.attr('href'); + if (link.attr('title') == '?' && href.startsWith('https://www.wikidata.org/wiki/')) { + link.attr('title', '…'); + let qid = href.split('/').reverse()[0]; + $.ajax({ + url: 'https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/' + qid + '?_fields=labels', + dataType: "json", + success: function(data) { + link.attr( + 'title', + data['labels']['pl'] || data['labels']['en'] + ); + }, + }); + } + } }); self.caret = new Caret(element); diff --git a/src/wlxml/templates/wlxml/wl2html.xsl b/src/wlxml/templates/wlxml/wl2html.xsl index c3af0ff4..fbb66fba 100644 --- a/src/wlxml/templates/wlxml/wl2html.xsl +++ b/src/wlxml/templates/wlxml/wl2html.xsl @@ -178,6 +178,14 @@ 📌 + + + + + + + +