Skip to content

Instantly share code, notes, and snippets.

@darylteo
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save darylteo/9223886 to your computer and use it in GitHub Desktop.

Select an option

Save darylteo/9223886 to your computer and use it in GitHub Desktop.
<div class="datagrid_hack"></div>
<script>
(function ($) {
// check so that this code only fires once.
if ($._datagridHack) {
return;
}
$._datagridHack = function () {
var root = $('.datagrid_hack');
root.parent().parent().hide(); // hide control
// only fire if the edit dialog box is open
var dialog = root.parents('.ui-dialog:visible');
if (dialog.length == 0) {
return;
}
// force the dimensions of that dialog box
dialog.css({
width: 740
}).offset({
left: 0,
top: 100
})
// then initialise tinyMCE on textboxes (might be better if it was more targeted)
tinyMCE.init({
mode: 'textareas',
theme: 'advanced',
width: '700',
height: '500',
relative_urls: false, // urls get mangled by tinyMCE defaults.
// just adding some plugins that I needed. Check tinyMCE v3 documentation.
plugins: "table",
theme_advanced_buttons3_add: "tablecontrols",
});
};
var register = function () {
// only call our function once dom and script is ready
$(function () {
$._datagridHack();
})
}
// check if tinyMCE lib is loaded, else force load it with jQuery.
if (typeof(tinyMCE) !== 'undefined') {
register();
} else {
var url = '/umbraco/plugins/tinymce3/tinymce3tinymceCompress.aspx?rnd=12345&module=gzipmodule&themes=umbraco&plugins=contextmenu,umbracomacro,umbracoembed,noneditable,inlinepopups,table,advlink,spellchecker,paste,umbracoimg,umbracocss,umbracopaste,umbracolink,umbracocontextmenu&languages=en';
$.getScript(url, register);
}
})(jQuery);
</script>
@darylteo
Copy link
Copy Markdown
Author

Usage

  • you create a new datatype (uComponents: Macro Renderer)
  • modify DataTypeGrid.config to allow this data type.
  • Add that to the datatype grid as a extra parameter.
  • add a Textstring Multiple where you want a TinyMCE.

@darylteo
Copy link
Copy Markdown
Author

Added a check to see if TinyMCE is loaded (it is loaded if another data item has Richtext Editor, but if there isn't then Umbraco doesn't load it).

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