Created
October 16, 2016 20:01
-
-
Save stephanieleary/68d53b9b729804737e9d9774bc1d0a60 to your computer and use it in GitHub Desktop.
Blockquote + Cite TinyMCE button JS
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
(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>'); | |
} | |
}); | |
} | |
}); | |
}); | |
})(); |
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
Thank you so much.