Last active
November 27, 2018 20:21
-
-
Save Melros/9119246 to your computer and use it in GitHub Desktop.
This plugin will insert a mailto: link by providing an email address within tinymce 4.
This file contains hidden or 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
/* | |
1. Create a folder named "email" within "tinymce/plugins". | |
2. Create a file called "plugin.min.js" within the folder. | |
2. Paste the below code inside "tinymce/plugins/email/plugin.min.js" | |
3. Extend your tiny.init like: | |
tinymce.init({ | |
plugins: "email", | |
toolbar: "email" | |
}); | |
*/ | |
tinymce.PluginManager.add('email', function(editor, url) { | |
// Add a button that opens a window | |
editor.addButton('email', { | |
text: 'E-Mail', | |
icon: false, | |
onclick: function() { | |
// Open window | |
editor.windowManager.open({ | |
title: 'E-Mail Address', | |
body: [ | |
{type: 'textbox', name: 'title', label: 'E-Mail'} | |
], | |
onsubmit: function(e) { | |
// Insert content when the window form is submitted | |
editor.insertContent('<a href="mailto:' + e.data.title + '">' + e.data.title + '</a>'); | |
} | |
}); | |
} | |
}); | |
// Adds a menu item to the tools menu | |
editor.addMenuItem('email', { | |
text: 'E-Mail', | |
context: 'tools', | |
onclick: function() { | |
// Open window | |
editor.windowManager.open({ | |
title: 'E-Mail Address', | |
body: [ | |
{type: 'textbox', name: 'title', label: 'E-Mail'} | |
], | |
onsubmit: function(e) { | |
// Insert content when the window form is submitted | |
editor.insertContent('<a href="mailto:' + e.data.title + '">' + e.data.title + '</a>'); | |
} | |
}); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment