Skip to content

Instantly share code, notes, and snippets.

@megamattron
Created March 8, 2012 00:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save megamattron/1997471 to your computer and use it in GitHub Desktop.
Save megamattron/1997471 to your computer and use it in GitHub Desktop.
JEditable TinyMCE custom input plugin
/*
* Wysiwyg input for Jeditable
*
* Copyright (c) 2008 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Depends on jWYSIWYG plugin by Juan M Martinez:
* http://projects.bundleweb.com.ar/jWYSIWYG/
*
* Project home:
* http://www.appelsiini.net/projects/jeditable
*
* Revision: $Id$
*
*/
$.editable.addInputType('mce', {
element:function (settings, original) {
var textarea = $('<textarea id="' + $(original).attr("id") + '_mce"/>');
if (settings.rows) {
textarea.attr('rows', settings.rows);
} else {
textarea.height(settings.height);
}
if (settings.cols) {
textarea.attr('cols', settings.cols);
} else {
console.log("Text area width: " + settings.width);
textarea.width(settings.width);
}
$(this).append(textarea);
return(textarea);
},
plugin:function (settings, original) {
tinyMCE.execCommand("mceAddControl", true, $(original).attr("id") + '_mce');
},
submit:function (settings, original) {
tinyMCE.triggerSave();
tinyMCE.execCommand("mceRemoveControl", true, $(original).attr("id") + '_mce');
},
reset:function (settings, original) {
tinyMCE.execCommand("mceRemoveControl", true, $(original).attr("id") + '_mce');
original.reset(this);
}
});
@mohit-rocks
Copy link

Hi Megamattron,
Thanks for sharing..
Can you please help like how to integrate it with tinyMCE and where should i include javascript for the Jeditable ?
Thanks in advance :)

@3lc0nd3
Copy link

3lc0nd3 commented Jul 18, 2016

For TinyMCE 4.xxx You should use:

  • mceAddEditor
  • mceRemoveEditor
    instead of:
  • mceAddControl
  • mceRemoveControl

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