Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Created October 16, 2016 20:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephanieleary/68d53b9b729804737e9d9774bc1d0a60 to your computer and use it in GitHub Desktop.
Save stephanieleary/68d53b9b729804737e9d9774bc1d0a60 to your computer and use it in GitHub Desktop.
Blockquote + Cite TinyMCE button JS
(function() {
tinymce.PluginManager.add('blockquote_cite', function( editor, url ) {
editor.addButton( 'blockquote_cite', {
title: 'Blockquote & Cite',
icon: "icon dashicons-testimonial",
onclick: function() {
editor.windowManager.open( {
title: 'Insert Blockquote and Citation',
body: [
{
type: 'textbox',
name: 'multilineQuote',
label: 'Quotation',
value: editor.selection.getContent(),
multiline: true,
minWidth: 300,
minHeight: 100
},
{
type: 'textbox',
name: 'textboxCite',
label: 'Cite',
value: ''
},
{
type: 'textbox',
name: 'textboxURL',
label: 'Cite URL',
value: ''
},
{
type: 'listbox',
name: 'listboxAlign',
label: 'Alignment',
'values': [
{text: 'None', value: ''},
{text: 'Left', value: 'alignleft'},
{text: 'Right', value: 'alignright'}
]
}
],
onsubmit: function( e ) {
var cite, link = '';
if ( e.data.textboxURL.trim() )
cite = '<cite><a href="' + e.data.textboxURL.trim() + '">' + e.data.textboxCite.trim() + '</a></cite>';
else if ( e.data.textboxCite.trim() )
cite = '<cite>' + e.data.textboxCite.trim() + '</cite>';
editor.insertContent( '<section class="pullquote ' + e.data.listboxAlign + '"><blockquote>' + e.data.multilineQuote + cite + '</blockquote></section>');
}
});
}
});
});
})();
@haleyngonadi
Copy link

Thank you so much.

@cbdribamar
Copy link

Hello! Do you know if it's possible to open the infinite content picker inside a plugin, and how could we possible do it?

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