Skip to content

Instantly share code, notes, and snippets.

@jfgomez86
Created February 14, 2012 21:10
Show Gist options
  • Select an option

  • Save jfgomez86/1830471 to your computer and use it in GitHub Desktop.

Select an option

Save jfgomez86/1830471 to your computer and use it in GitHub Desktop.
$(function() {
WysiHat.Commands.promptLinkSelection = (function() {
if (this.linkSelected()) {
if (confirm("Remove link?"))
this.unlinkSelection();
} else {
var value = prompt("Enter a URL", "http://www.google.com/");
if (value)
this.linkSelection(value);
}
});
WysiHat.Toolbar.ButtonSets.Snap = WysiHat.Toolbar.ButtonSets.Standard.concat({
label: "Link",
cssClass: "toolbar_button",
handler: function(e) { return e.promptLinkSelection(); }
});
var snap_editor = (function (textarea) {
var textarea = $(textarea).wysihat({buttons: WysiHat.Toolbar.ButtonSets.Snap}),
editor = $("#" + textarea.attr('id') + '_editor');
editor.on("blur keyup paste", function (evt) {
textarea.val($(this).html());
});
return editor;
});
$(document).ready(function () {
window.editor = snap_editor($("#content"));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment