mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-31 03:45:24 +01:00 
			
		
		
		
	Add checks for adding the copy button in code-blocks
- adds checks to put copy button for code inside table and highlight code block - Fixes #363
This commit is contained in:
		| @@ -44,7 +44,7 @@ code { | |||||||
|     direction: ltr; |     direction: ltr; | ||||||
| } | } | ||||||
|  |  | ||||||
| div.highlight { | div.highlight, pre { | ||||||
|     position: relative; |     position: relative; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -60,6 +60,7 @@ div.highlight { | |||||||
|     font-size: 14px; |     font-size: 14px; | ||||||
| } | } | ||||||
|  |  | ||||||
| div.highlight:hover .copy-code { | div.highlight:hover .copy-code, | ||||||
|  | pre:hover .copy-code { | ||||||
|     display: block; |     display: block; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -120,7 +120,17 @@ | |||||||
|             selection.removeRange(range); |             selection.removeRange(range); | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         if (container.classList.contains("highlight")) { | ||||||
|             container.appendChild(copybutton); |             container.appendChild(copybutton); | ||||||
|  |         } else if (container.parentNode.firstChild == container) { | ||||||
|  |             // td containing LineNos | ||||||
|  |         } else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") { | ||||||
|  |             // table containing LineNos and code | ||||||
|  |             codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton); | ||||||
|  |         } else { | ||||||
|  |             // code blocks not having highlight as parent class | ||||||
|  |             codeblock.parentNode.appendChild(copybutton); | ||||||
|  |         } | ||||||
|     }); |     }); | ||||||
| </script> | </script> | ||||||
| {{- end }} | {{- end }} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Aditya Telange
					Aditya Telange