Skip to content

Instantly share code, notes, and snippets.

@sbp
Last active December 14, 2015 20:59
Show Gist options
  • Save sbp/5147948 to your computer and use it in GitHub Desktop.
Save sbp/5147948 to your computer and use it in GitHub Desktop.
Octavo colour-box command
$ ->
octavo.shortcuts["Ctrl+'"] = (position) ->
octavo.input (value) ->
return if not position.balanced
span = $("<span/>").text("").css
width: "9px"
height: "9px"
border: "1px solid #000"
background: value
display: "inline-block"
octavo.silently ->
position.range.deleteContents()
position.range.insertNode span[0]
@sbp
Copy link
Author

sbp commented Mar 12, 2013

To compile this script to embeddable JavaScript:

curl -s https://gist.github.com/sbp/5147948/raw/colourbox.coffee | coffee -cs | uglifyjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment