Last active
November 20, 2017 12:02
-
-
Save brian-brazil/da211ce4fae621bffacf48835216fc64 to your computer and use it in GitHub Desktop.
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 Improve Teachable for source code | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description De-bork Teachable pre/code tags. | |
// Adds shortcuts: | |
// Alt+Shift+X: <code> | |
// Alt+P: <pre> | |
// | |
// @author You | |
// @match https://training.robustperception.io/admin/courses/*/curriculum/lectures/* | |
// @grant GM_addStyle | |
// @updateURL https://gist.githubusercontent.com/brian-brazil/da211ce4fae621bffacf48835216fc64/raw/c511b610ee4d2255f64457be519e2e7688ee9b17/gistfile1.txt | |
// @DownloadURL https://gist.githubusercontent.com/brian-brazil/da211ce4fae621bffacf48835216fc64/raw/c511b610ee4d2255f64457be519e2e7688ee9b17/gistfile1.txt | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// These functions mess with tags and newlines in pre/code tags. | |
var clean = jQuery.Redactor.prototype.clean(); | |
clean.savePreFormatting = function(t){return t;}; | |
clean.saveCodeFormatting = function(t){return t;}; | |
clean.removeSpaces = function(t){return t;}; | |
jQuery.Redactor.prototype.clean = function(t){return clean;}; | |
// The removeSpaces catches most new lines removal, but tabifier.get | |
// is called by showCode, so we need to fix that too. | |
redactorOptions.tabifier = false; | |
// Docs: https://imperavi.com/redactor/docs/settings/ | |
redactorOptions.shortcutsAdd = { | |
'alt+shift+x': { func: 'inline.format', params: ['code']}, // Same as the wordpress editor we use. | |
'alt+p': { func: 'inline.block', params: ['pre']}, | |
}; | |
// Defaults to 300px, which is a bit small. | |
GM_addStyle('.redactor-editor { max-height: unset !important; height: 500px;}'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment