[그누보드5] ㅅㄷㄴㅅ1
본문
$(document).on('click', '#insertCodeButton', function () {
let codeSnippet = $('#codeInput').val();
let selectedLanguage = $('#languageSelector').val(); // 선택된 언어를 가져옵니다.
if (codeSnippet) {
codeSnippet = encodeHtmlEntities(codeSnippet);
const editorInstance = FroalaEditor.INSTANCES[0];
// 언어 레이블을 포함하여 코드를 삽입
editorInstance.html.insert(`<pre><span><code class="language-${selectedLanguage}">${codeSnippet}</code><span class="language-label" style="float:right; font-size:smaller; color:#ccc;">${selectedLanguage.toUpperCase()}</span></span></pre><p> </p>`, true);
setTimeout(() => {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
});
}, 100);
}
editorInstance.popups.hide('customPlugin.popup');
});
$(document).on('click', '#insertCodeButton', function () {
let codeSnippet = $('#codeInput').val();
let selectedLanguage = $('#languageSelector').val(); // 선택된 언어를 가져옵니다.
if (codeSnippet) {
codeSnippet = encodeHtmlEntities(codeSnippet);
const editorInstance = FroalaEditor.INSTANCES[0];
// 언어 레이블을 포함하여 코드를 삽입
editorInstance.html.insert(`<pre><span><code class="language-${selectedLanguage}">${codeSnippet}</code><span class="language-label" style="float:right; font-size:smaller; color:#ccc;">${selectedLanguage.toUpperCase()}</span></span></pre><p> </p>`, true);
setTimeout(() => {
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightElement(block);
});
}, 100);
}
editorInstance.popups.hide('customPlugin.popup');
});
댓글목록0