TinyMCE Delete Inline Template


Add this in your rx_resources/tinymce/js/tinymce/plugins/rxinline/plugin.js to add a Delete Inline Template function. You can also add in rxdeletetemplate to your config file toolbar set (icon image attached):

// Delete template function
editor.addCommand('fndeletevariant', function() {
			var dom = editor.dom;
		var rng = dom.createRng();
		var temp = dom.getParent(editor.selection.getStart(),'.rx_ephox_inlinevariant');
		if(temp) {
		rng.setStartAfter(temp);
		rng.setEndAfter(temp);
		editor.selection.setRng(rng);
		if(confirm('Confirm deletion of this inline template...')) {
		dom.remove(temp);
		}
		} else {
		alert("No inline template found at selected position.");
		}
});



// Adds a button to the toolbar
editor.addButton('rxdeletetemplate', {
image: '../rx_resources/images/variantdelete.gif',
tooltip: 'Delete Inline Template',
    cmd: 'fndeletevariant',
});	

 // Adds a menu item to the tools menu
editor.addMenuItem('rxdeletetemplate', {
    text: 'Delete Template', 
image: '../rx_resources/images/variantdelete.gif',
    cmd: 'fndeletevariant',
context: 'insert',
prependToContext: true
});

Sometimes focus isn’t the best when trying to use delete from the toolbar drop-down so best take it out of there:

// Adds a menu item to the tools menu
editor.addMenuItem(‘rxdeletetemplate’, {
text: ‘Delete Template’,
image: ‘…/rx_resources/images/variantdelete.gif’,
cmd: ‘fndeletevariant’
});