Added syntax highlighting for XML Tools #156
@@ -411,3 +411,41 @@ async function restRequest(port, endpoint, xmlData, transformData) {
|
|||||||
});
|
});
|
||||||
return result;
|
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);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<script>hljs.highlightAll();</script>
|
<script>hljs.highlightAll();</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body onload="init()">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="tool" class="tool rwd-expandable">
|
<div id="tool" class="tool rwd-expandable">
|
||||||
<div class="tool-context">
|
<div class="tool-context">
|
||||||
@@ -224,40 +224,11 @@
|
|||||||
|
|
||||||
hljs.addPlugin(mergeHTMLPlugin);
|
hljs.addPlugin(mergeHTMLPlugin);
|
||||||
|
|
||||||
const editorEle = document.getElementById('jsonBlock');
|
function init() {
|
||||||
|
// Make sure that only plain text is pasted
|
||||||
|
configurePastingInElement("jsonBlock");
|
||||||
|
|
||||||
// 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);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -72,44 +72,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
configurePastingInElement("xmlArea");
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorEle = document.getElementById('xmlArea');
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -17219,6 +17219,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
// Make sure that only plain text is pasted
|
||||||
|
configurePastingInElement("xmlArea");
|
||||||
|
configurePastingInElement("transformArea");
|
||||||
|
|
||||||
//Handle clicks in whole form and set info in tooltip
|
//Handle clicks in whole form and set info in tooltip
|
||||||
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
||||||
setDefaultContent(document.getElementById("transformArea"), 'Insert XPath expression here');
|
setDefaultContent(document.getElementById("transformArea"), 'Insert XPath expression here');
|
||||||
@@ -17257,40 +17261,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorEle = document.getElementById('xmlArea');
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,10 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
function init() {
|
function init() {
|
||||||
|
// Make sure that only plain text is pasted
|
||||||
|
configurePastingInElement("xmlArea");
|
||||||
|
configurePastingInElement("transformArea");
|
||||||
|
|
||||||
//Handle clicks in whole form and set info in tooltip
|
//Handle clicks in whole form and set info in tooltip
|
||||||
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
||||||
setDefaultContent(document.getElementById("transformArea"), 'Insert XSD here');
|
setDefaultContent(document.getElementById("transformArea"), 'Insert XSD here');
|
||||||
@@ -95,7 +99,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
processTooltip();
|
processTooltip();
|
||||||
//
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,78 +116,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorEle = document.getElementById('xmlArea');
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const transformEle = document.getElementById('transformArea');
|
|
||||||
|
|
||||||
// Handle the `paste` event
|
|
||||||
transformEle.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(transformEle.id);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1199,6 +1199,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
// Make sure that only plain text is pasted
|
||||||
|
configurePastingInElement("xmlArea");
|
||||||
|
configurePastingInElement("transformArea");
|
||||||
|
|
||||||
//Handle clicks in whole form and set info in tooltip
|
//Handle clicks in whole form and set info in tooltip
|
||||||
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
|
||||||
setDefaultContent(document.getElementById("transformArea"), 'Insert XSLT here');
|
setDefaultContent(document.getElementById("transformArea"), 'Insert XSLT here');
|
||||||
@@ -1223,76 +1227,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
processTooltip();
|
processTooltip();
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorEle = document.getElementById('xmlArea');
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
});
|
|
||||||
|
|
||||||
const transformEle = document.getElementById('transformArea');
|
|
||||||
|
|
||||||
// Handle the `paste` event
|
|
||||||
transformEle.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(transformEle.id);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user