pretty: add softwrapping to pastes
Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
#pasteContent {
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
span {
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
.topRightBox {
|
.topRightBox {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
padding: 18px 10px;
|
padding: 18px 10px;
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
const homePage = document.location.origin;
|
const homePage = document.location.origin;
|
||||||
|
const pasteContentDiv = document.getElementById('pasteContent');
|
||||||
|
|
||||||
function forkClicked () {
|
let wrap_level = 0;
|
||||||
const paste = document.getElementById('pasteContent');
|
|
||||||
let text = paste.innerText;
|
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;
|
localStorage["forkText"] = text;
|
||||||
|
|
||||||
console.log(text);
|
console.log(text);
|
||||||
@@ -10,6 +28,6 @@ function forkClicked () {
|
|||||||
window.location = homePage;
|
window.location = homePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
function newPasteClicked () {
|
function newPasteClicked() {
|
||||||
window.location = homePage;
|
window.location = homePage;
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,9 @@
|
|||||||
{{ body | safe }}
|
{{ body | safe }}
|
||||||
</div>
|
</div>
|
||||||
<div class="topRightBox">
|
<div class="topRightBox">
|
||||||
<button onclick="forkClicked()">⑂ Fork</button>
|
<button id="wrapBtn" onclick="wrapClicked()">⏎ Wrap</button>
|
||||||
<button onclick="newPasteClicked()">+ New</button>
|
<button id="forkBtn" onclick="forkClicked()">⑂ Fork</button>
|
||||||
|
<button id="newPasteBtn" onclick="newPasteClicked()">+ New</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user