feat: 모바일 페이지 복사하기 버튼 추가

main
kjh 3 months ago
parent 0769129417
commit b680b6d27d

@ -209,8 +209,24 @@
str = str.replace(/\[/g, '\\[').replace(/\]/g, '\\]') str = str.replace(/\[/g, '\\[').replace(/\]/g, '\\]')
txt = txt.replace(new RegExp(str, 'g'), span.outerHTML); txt = txt.replace(new RegExp(str, 'g'), span.outerHTML);
if (txt.indexOf(str) > -1 && style['use-copybutton']) {
let btn = document.createElement('button');
let btn_text = document.createTextNode('복사하기');
btn.appendChild(btn_text);
btn.setAttribute('type', 'button');
btn.setAttribute('data-text', str);
btn.classList.add('clipboard');
btn.style.backgroundColor = '#4990e2';
btn.style.color = 'white';
btn.style.border = 'none';
btn.style.fontSize = '2rem';
btn.style.textAlign = 'center';
btn.style.height = '3rem';
btn.style.width = '10rem';
btn.style.marginLeft = '20px';
txt = txt+btn.outerHTML;
}
} }
return txt; return txt;
} }
/* =============== /* ===============
@ -291,6 +307,12 @@
clipboardCopy(this.innerText); clipboardCopy(this.innerText);
}); });
}); });
document.querySelectorAll('button.clipboard').forEach((ele) => {
ele.addEventListener('click', function () {
clipboardCopy(this.dataset.text);
});
});
} }
/* =============== /* ===============

Loading…
Cancel
Save