Created
May 20, 2014 21:08
-
-
Save rsiddle/4f2095b055821bae1ee2 to your computer and use it in GitHub Desktop.
A simple TinyMCE 4 plugin to add Click to Tweet HTML to your site.
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
<script type="text/javascript"> | |
// Notes: Change @yourname to become your Twitter name. | |
tinymce.PluginManager.add('tweet', function(editor, url) { | |
// Adds a menu item to the tools menu | |
editor.addMenuItem('tweet', { | |
text: 'Tweet This', | |
context: 'insert', | |
onclick: function() { | |
editor.windowManager.open({ | |
title: 'Tweet This', | |
body: [ | |
{type: 'textbox', name: 'message', label: 'Message'} | |
], | |
onsubmit: function(e) { | |
// Insert content when the window form is submitted | |
editor.insertContent('<blockquote> ' + e.data.message + ' @yourname <footer><a href="https://twitter.com/intent/tweet?text=' + encodeURI(e.data.message) + '%20@yourname" target="_blank" rel="nofollow">Tweet This</a></footer></blockquote>'); | |
} | |
}); | |
} | |
}); | |
}); | |
tinymce.init({ | |
selector: 'textarea', | |
plugins: 'tweet' | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment