You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes I find the "editor" div a bit distracting after I paste in the MarkDown contents, so I wrote some CSS and JS to add a new "Toggle Editor" link to the top button bar, along with a green vertical bar in the middle of the 2 divs that you can drag-resize left or right.
I have only tried this in Chrome on desktop, not yet tested this in mobile etc. But for my needs it works well, I am quite happy with it.
Extra HTML: (added "toggleButton" next to "Copy" button, and added "resizer" div between "edit" and "preview")
body {
margin:0; /* Remove default margin */height:100vh; /* Ensure full height usage */overflow: hidden; /* Prevent body scrollbars */
}
#container {
display: flex;
width:100%;
height:100%; /* Full height of the parent */overflow: hidden;
}
#edit,#preview {
flex-grow:1;
overflow: auto; /* Enable scrolling for content overflow */transition: flex 0.3s ease;
}
#resizer {
width:4px; /* Updated resizer width */background-color: green;
cursor: col-resize;
flex-shrink:0; /* Prevent shrinking */
}
#toggleButton {
margin-left:16px; /* Ensure it doesn't overflow to hide */
}
.shrunk {
flex:000px!important;
}
Extra JavaScript:
constcontainer=document.getElementById("container");constedit=document.getElementById("edit");constpreview=document.getElementById("preview");constresizer=document.getElementById("resizer");consttoggleButton=document.getElementById("toggleButton");constMIN_EDIT_WIDTH=72;// Minimum width for the editor divletisMouseDown=false;resizer.addEventListener("mousedown",(e)=>{isMouseDown=true;document.addEventListener("mousemove",resize);document.addEventListener("mouseup",stopResize);});functionresize(e){if(!isMouseDown)return;constcontainerRect=container.getBoundingClientRect();constnewEditWidth=e.clientX-containerRect.left;if(newEditWidth>=MIN_EDIT_WIDTH){edit.classList.remove("shrunk");edit.style.flex=`0 0 ${newEditWidth}px`;preview.style.flex=`1 1 auto`;}}functionstopResize(){isMouseDown=false;document.removeEventListener("mousemove",resize);document.removeEventListener("mouseup",stopResize);}functiontoggleEditor(){edit.classList.toggle("shrunk");}toggleButton.addEventListener("click",toggleEditor);
NOTE: some of the CSS is the result of some back-and-forth tweaking via ChatGPT, so I'm not sure if they are the best way or might cause problems and/or the comments are even accurate, but again it seems to work #GoodEnough for my needs.
HTH!
The text was updated successfully, but these errors were encountered:
I made a Bookmarklet, which will insert the required HTML and CSS and JavaScript (and will also redirect to MarkdownLivePreview.com if not on that page).
I also made it re-center the splitter if you double-click it.
Sometimes I find the "editor" div a bit distracting after I paste in the MarkDown contents, so I wrote some CSS and JS to add a new "Toggle Editor" link to the top button bar, along with a green vertical bar in the middle of the 2 divs that you can drag-resize left or right.
I have only tried this in Chrome on desktop, not yet tested this in mobile etc. But for my needs it works well, I am quite happy with it.
Extra HTML: (added "toggleButton" next to "Copy" button, and added "resizer" div between "edit" and "preview")
Extra CSS:
Extra JavaScript:
NOTE: some of the CSS is the result of some back-and-forth tweaking via ChatGPT, so I'm not sure if they are the best way or might cause problems and/or the comments are even accurate, but again it seems to work #GoodEnough for my needs.
HTH!
The text was updated successfully, but these errors were encountered: