Added code highlighting and copy button
Update .gitignore, composer.php, and 15 more files...
This commit is contained in:
BIN
resources/Azias/imgs/back-03-01-01.png
Normal file
BIN
resources/Azias/imgs/back-03-01-01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
2194
resources/Azias/imgs/back-03.ai
Normal file
2194
resources/Azias/imgs/back-03.ai
Normal file
File diff suppressed because one or more lines are too long
BIN
resources/Azias/imgs/lscom/lscom-legacy-simple.png
Normal file
BIN
resources/Azias/imgs/lscom/lscom-legacy-simple.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.1 KiB |
BIN
resources/Azias/imgs/lscom/lscom-legacy.png
Normal file
BIN
resources/Azias/imgs/lscom/lscom-legacy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
49
resources/Azias/js/code-highlighter.js
Normal file
49
resources/Azias/js/code-highlighter.js
Normal file
@@ -0,0 +1,49 @@
|
||||
// Highlights the code blocks when included on a page.
|
||||
// This command is separated in its own file since highlight.js isn't on every page and because I can't use JS
|
||||
// in a script element without using an external .js file.
|
||||
|
||||
Array.from(document.getElementsByClassName("code")).forEach(eCodeContainer => {
|
||||
let language = null;
|
||||
|
||||
eCodeContainer.classList.forEach(cCodeContainer => {
|
||||
if(cCodeContainer.startsWith("language-")) {
|
||||
language = cCodeContainer;
|
||||
}
|
||||
});
|
||||
|
||||
if(language !== null) {
|
||||
Array.from(eCodeContainer.children).forEach(eCodeLine => {
|
||||
if(eCodeLine.classList.contains("code-line")) {
|
||||
eCodeLine.classList.add(language);
|
||||
hljs.highlightElement(eCodeLine);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Adding the action to copy the code to elements with the "js-code-copy" class.
|
||||
// The search works by searching the closest parent with the "code" class or that is a "code" element, and then
|
||||
// reading each of its children with the "code-line" class.
|
||||
|
||||
Array.from(document.getElementsByClassName("js-code-copy")).forEach(eCodeCopyButton => {
|
||||
let eParentCodeBlock = eCodeCopyButton;
|
||||
|
||||
while(eParentCodeBlock != null &&!eParentCodeBlock.classList.contains("code") &&
|
||||
eParentCodeBlock.nodeName.toLowerCase() !== "code") {
|
||||
eParentCodeBlock = eParentCodeBlock.parentElement;
|
||||
}
|
||||
|
||||
if(eParentCodeBlock != null) {
|
||||
let code = "";
|
||||
|
||||
Array.from(eParentCodeBlock.children).forEach(eCodeLine => {
|
||||
if(eCodeLine.classList.contains("code-line")) {
|
||||
code += eCodeLine.textContent + "\n"
|
||||
}
|
||||
});
|
||||
|
||||
eCodeCopyButton.onclick = function() {
|
||||
navigator.clipboard.writeText(code);
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -24,6 +24,7 @@
|
||||
transition-timing-function: cubic-bezier(.47,1.64,.41,.8);
|
||||
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
|
||||
&.primary {
|
||||
color: var(--dm-button-primary-text-color);
|
||||
@@ -92,4 +93,19 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.fold-top-right {
|
||||
top: 0;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%);
|
||||
|
||||
i {
|
||||
top: 0.3em;
|
||||
right: 0.3rem;
|
||||
}
|
||||
|
||||
&:hover i {
|
||||
top: 0.4rem;
|
||||
right: 0.4rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
resources/Azias/scss/highlightjs/fixes.scss
Normal file
3
resources/Azias/scss/highlightjs/fixes.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.code-line {
|
||||
background: transparent !important;
|
||||
}
|
||||
@@ -25,3 +25,6 @@
|
||||
@import 'halfmoon/element/hr';
|
||||
@import 'halfmoon/element/image';
|
||||
@import 'halfmoon/element/video';
|
||||
|
||||
/* Highlight.JS */
|
||||
@import 'highlightjs/fixes';
|
||||
Reference in New Issue
Block a user