From 67264dba4700213e1935b9a99fb942f69029f998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 1 Oct 2023 12:23:50 +0200 Subject: [PATCH] clipboard: ignore RTL for code #660 --- static/js/theme.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/js/theme.js b/static/js/theme.js index d10dbcc212..74f3d2f6b6 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -551,6 +551,7 @@ function initAnchorClipboard(){ } function initCodeClipboard(){ + var isCodeRtl = false; function getCodeText( node ){ // if highlight shortcode is used in inline lineno mode, remove lineno nodes before generating text, otherwise it doesn't hurt var code = node.cloneNode( true ); @@ -604,16 +605,16 @@ function initCodeClipboard(){ e.clearSelection(); var doBeside = e.trigger.parentNode.tagName.toLowerCase() == 'pre' || (e.trigger.previousElementSibling && e.trigger.previousElementSibling.tagName.toLowerCase() == 'table' ); e.trigger.setAttribute( 'aria-label', window.T_Copied_to_clipboard ); - e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isRtl?'e':'w')) ); + e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isCodeRtl?'e':'w')) ); }); clip.on( 'error', function( e ){ var doBeside = e.trigger.parentNode.tagName.toLowerCase() == 'pre' || (e.trigger.previousElementSibling && e.trigger.previousElementSibling.tagName.toLowerCase() == 'table' ); e.trigger.setAttribute( 'aria-label', fallbackMessage(e.action) ); - e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isRtl?'e':'w')) ); + e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isCodeRtl?'e':'w')) ); var f = function(){ e.trigger.setAttribute( 'aria-label', window.T_Copied_to_clipboard ); - e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isRtl?'e':'w')) ); + e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (doBeside ? 'w' : 's'+(isCodeRtl?'e':'w')) ); document.removeEventListener( 'copy', f ); }; document.addEventListener( 'copy', f );