Fixed naming
This commit is contained in:
@@ -85,10 +85,7 @@ function escapeHTML(elementID) {
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function highlightSyntax(elementId) {
|
||||
const element = document.getElementById(elementId);
|
||||
element.innerHTML = hljs.highlightAuto(element.innerText).value
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* It fills the XML area with a sample XML.
|
||||
@@ -425,42 +422,4 @@ async function restRequest(port, endpoint, xmlData, transformData) {
|
||||
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
function configurePastingInElement(elementId) {
|
||||
const editorEle = document.getElementById(elementId);
|
||||
|
||||
// Handle the `paste` event
|
||||
editorEle.addEventListener('paste', function (e) {
|
||||
// Prevent the default action
|
||||
e.preventDefault();
|
||||
|
||||
// Get the copied text from the clipboard
|
||||
const text = e.clipboardData
|
||||
? (e.originalEvent || e).clipboardData.getData('text/plain')
|
||||
: // For IE
|
||||
window.clipboardData
|
||||
? window.clipboardData.getData('Text')
|
||||
: '';
|
||||
|
||||
if (document.queryCommandSupported('insertText')) {
|
||||
document.execCommand('insertText', false, text);
|
||||
} else {
|
||||
// Insert text at the current position of caret
|
||||
const range = document.getSelection().getRangeAt(0);
|
||||
range.deleteContents();
|
||||
|
||||
const textNode = document.createTextNode(text);
|
||||
range.insertNode(textNode);
|
||||
range.selectNodeContents(textNode);
|
||||
range.collapse(false);
|
||||
|
||||
const selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
highlightSyntax(editorEle.id);
|
||||
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user