Last active
May 23, 2020 10:38
-
-
Save hogashi/58a486cdacfd1218052cadc671f28837 to your computer and use it in GitHub Desktop.
github diff content editable each line js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.styleSheets[0].insertRule('.blob-code-marker:before { border-right: black 1px dotted; }'); | |
linedata = {}; | |
[ | |
...Array.from(document.querySelectorAll('.blob-code-addition')), | |
...Array.from(document.querySelectorAll('.blob-code-context')) | |
].forEach(line => { | |
lineNumber = line.parentNode.querySelector('.blob-num').getAttribute('data-line-number'); | |
marker = line.querySelector('.blob-code-marker'); | |
editor = marker.cloneNode(); | |
marker.style.display = 'none'; | |
editor.style.display = 'inline-block'; | |
editor.style.width = '100%'; | |
editor.innerHTML = marker.innerText | |
.replace(/&/g, '&') | |
.replace(/'/g, ''') | |
.replace(/"/g, '"') | |
.replace(/</g, '<') | |
.replace(/>/g, '>'); | |
editor.contentEditable = true; | |
line.appendChild(editor); | |
linedata[lineNumber] = { line, marker, editor }; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment