pretty: add softwrapping to pastes

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2022-01-25 04:15:01 +05:30
parent dff3e673c2
commit eff3f0dbd6
3 changed files with 34 additions and 6 deletions

View File

@@ -1,8 +1,26 @@
const homePage = document.location.origin;
const pasteContentDiv = document.getElementById('pasteContent');
function forkClicked () {
const paste = document.getElementById('pasteContent');
let text = paste.innerText;
let wrap_level = 0;
function wrapClicked() {
wrap_level = (wrap_level === 2) ? 0 : wrap_level + 1;
switch (wrap_level) {
case 0:
pasteContentDiv.style.width = 'max-content';
break;
case 1:
pasteContentDiv.style.width = 'auto';
break;
case 2:
pasteContentDiv.style.width = '80ch';
break;
}
}
function forkClicked() {
let text = pasteContentDiv.innerText;
localStorage["forkText"] = text;
console.log(text);
@@ -10,6 +28,6 @@ function forkClicked () {
window.location = homePage;
}
function newPasteClicked () {
function newPasteClicked() {
window.location = homePage;
}