์๋กค๋ก์ง ๋์ค ๊ทธ๋๋ณด๋ ์ฝ๋ ํ์ด๋ผ์ดํธ์ copy ๋ฒํผ ๋ง๋ค๊ธฐ
ํ์ด์ง ์ ๋ณด
๋ณธ๋ฌธ
์๋ ๋ด์ฉ์ highlight.php ๋ฑ ์ ๋นํ ์ด๋ฆ์ผ๋ก ๊ทธ๋๋ณด๋ extend ํด๋์ ๋ฃ๊ธฐ
ย
HighlightJs Copy Code Badge Component
ย
๋ ์ฒจ๋ถ ํ์ผ ์ฐธ๊ณ (์ถ์ฒ:ย https://github.com/RickStrahl/highlightjs-badge)
ย
[code]
<?
ย function hh_tail_sub()
ย {
ย ย global $wr_id;
ย ย // ๊ฒ์ํ์์ view.php ํธ์ถํ ๋ ์ ์ฉํ๋๋ก
ย ย if($_SERVER['SCRIPT_NAME'] != '/bbs/board.php' ย || !$wr_id) return;
ย ?>
<!--
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/agate.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
-->
ย ย <style>
ย ย ย ย /* optionally override badge styling */
ย ย ย ย .code-badge {
ย ย ย ย ย ย ย background: #555 !important;
ย ย ย ย ย ย ย padding: 8px !important;
ย ย ย ย }
ย ย ย ย .code-badge-copy-icon {
ย ย ย ย ย ย font-size: 1.3em !important;
ย ย ย ย }
ย ย </style>
ย ย ย <style>
ย ย ย pre {
ย ย ย ย ย ย overflow: auto;
ย ย ย }
ย ย ย </style>
<!-- end customization template -->
<link rel="stylesheet" href="/highlight/vs2015.css">
<script src="/highlight/highlight.min.js"></script>
<!-- then add this badge component -->
<script src="/highlight/highlightjs-badge.min.js"></script>
<script>
function sh(id) {
ย var $id = $("#" + id);
ย if ($id.length > 0) {
ย ย var html = $id.html();
ย ย html = html.split("[code]").join("<pre><code>");
ย ย html = html.split("[/code]").join("</pre></code>");
ย ย $id.html(html);
ย ย $id.find("pre>code").each(function() {
ย ย ย var text = $.trim($(this).text());
ย ย ย $(this).text(text);
ย ย });
ย }
}
$(function() {ย
ย sh("bo_v_con");ย
ย hljs.initHighlighting();
});
</script>
<script>
ย ย setTimeout(function () {
ย ย ย ย var pres = document.querySelectorAll("pre>code");
ย ย ย ย for (var i = 0; i < pres.length; i++) {
ย ย ย ย ย ย hljs.highlightBlock(pres[i]);
ย ย ย ย }
ย ย ย ย var options = {
ย ย ย ย ย ย // Delay in ms used for `setTimeout` before badging is applied
ย ย ย ย ย ย // Use if you need to time highlighting and badge application
ย ย ย ย ย ย // since the badges need to be applied afterwards.
ย ย ย ย ย ย // 0 - direct execution (ie. you handle timing
ย ย ย ย ย ย loadDelay:0,
ย ย // CSS class(es) used to render the copy icon.
ย ย copyIconClass: "fa fa-copy", ย ย ย
ย ย // optional content for icons class (<i class="fa fa-copy"></i> or <i class="material-icons">file_copy</i>)
ย ย ย
ย ย // CSS class(es) used to render the done icon.
ย ย checkIconClass: "fa fa-check text-success",
ย ย ย ย ย ย // hook to allow modifying the text before it's pasted
ย ย ย ย ย ย onBeforeTextCopied: function(text, codeElement) {
ย ย ย ย ย ย ย return text; ย // ย you can fix up the text here
ย ย ย ย ย ย }
ย ย ย ย };
ย ย ย ย window.highlightJsBadge(options);
ย ย },10);
</script>
ย <?
ย }
ย add_event('tail_sub', 'hh_tail_sub', G5_HOOK_DEFAULT_PRIORITY);
?>
[/code]
์ฒจ๋ถํ์ผ
- highlightjs-badge-master.zip (156.3K) 4ํ ๋ค์ด๋ก๋ | DATE : 2021-09-25 01:52:42
๋๊ธ๋ชฉ๋ก
๋ฑ๋ก๋ ๋๊ธ์ด ์์ต๋๋ค.
