X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/166e471ceb2a6a051abf3458d19b92d75496bfaf..6655e0be8684f27c4475154b3c4ced64839cba0d:/src/redakcja/static/js/wiki/view_editor_wysiwyg.js diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index e43905c9..c5fa8c13 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -56,7 +56,7 @@ } /* Convert HTML fragment to plaintext */ - var ANNOT_FORBIDDEN = ['pt', 'pa', 'pr', 'pe', 'begin', 'end', 'motyw']; + var ANNOT_FORBIDDEN = ['pt', 'pa', 'pr', 'pe', 'ptrad', 'begin', 'end', 'motyw']; function html2plainText(fragment){ var text = ""; @@ -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);