Last active
May 21, 2024 20:58
-
-
Save Dayjo/7804066 to your computer and use it in GitHub Desktop.
Make Gist editor automatically resize based on content using a TamperMonkey script
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
// ==UserScript== | |
// @name gist-editor-resize-userscript | |
// @namespace https://gist.github.com/ | |
// @version 0.1 | |
// @description Automatically resize the gist editor for easier editing. | |
// @match http*://gist.github.com/* | |
// @copyright 2013+ Joel Day - blog.dayjo.org | |
// ==/UserScript== | |
var textareas = document.querySelectorAll('textarea.file_contents'); | |
var span = document.createElement('div'); | |
span.style.visibility = "hidden"; | |
document.body.appendChild(span); | |
$('textarea.file-contents').keyup(function(){ | |
span.style.width = this.offsetWidth + 'px'; | |
span.style.fontSize = this.style.fontSize; | |
span.innerText = this.value; | |
this.style.height = span.offsetHeight + 'px'; | |
}); |
@NeWbLt123 ja, same
@jm3 @NeWbLt123 - I've updated this to now at least support the normal textarea style editor (not Ace yet)
Any chance on getting this updated for Ace, or is it just a pain in the 'ace'?
Recommend setting your namespace to
https://gist.github.com/Dayjo/7804066
So people can come back to this for updates 👍
https://github.com/blog/302-gist-for-greasemonkey
FYI ... errror
ERROR: Execution of script 'gist-editor-resize-userscript' failed! $ is not a function
this may be a relevant reference for a better solution
https://codemirror.net/demo/resize.html
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this still supposed to work ?
I'm getting ERROR: Execution of script 'gist-editor-resize-userscript' failed! Cannot read property 'getDocument' of undefined
Thanks