Skip to content

Instantly share code, notes, and snippets.

@alvarezr
Last active August 29, 2015 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvarezr/c86baf5d21e0aed53cd3 to your computer and use it in GitHub Desktop.
Save alvarezr/c86baf5d21e0aed53cd3 to your computer and use it in GitHub Desktop.
Sparse theme Changes(fix Textblock editor)
/* Sparse theme Textblock */
// Theme Location
// Sparse/wpbakery/js_composer/
// Edit File : js_composer/asstes/js/backend/composer-view.js
// function _killEditor(){
// comment old code
// add this lines
if(!_.isUndefined(window.tinyMCE)) {
$('textarea.textarea_html', this.$el).each(function () {
var id = $(this).attr('id');
if(tinymce.majorVersion === "4") {
window.tinyMCE.execCommand('mceRemoveEditor', true, id);
} else {
window.tinyMCE.execCommand("mceRemoveControl", true, id);
}
});
}
// Edit File : js_composer/asstes/js/params/all.js
//rename function init_textarea_html to init_textarea_html_old;
//add new function
window.init_textarea_html = function($element) {
/*
Simple version without all this buttons from Wordpress
tinyMCE.init({
mode : "textareas",
theme: 'advanced',
editor_selector: $element.attr('name') + '_tinymce'
});
*/
if($('#wp-link').parent().hasClass('wp-dialog')) $('#wp-link').wpdialog('destroy');
var qt, textfield_id = $element.attr("id"), wpautop = false,
$form_line = $element.closest('.edit_form_line'),
$content_holder = $form_line.find('.vc_textarea_html_content'),
content = $content_holder.val();
// Init Quicktag
if(_.isUndefined(tinyMCEPreInit.qtInit[textfield_id])) {
window.tinyMCEPreInit.qtInit[textfield_id] = _.extend({}, window.tinyMCEPreInit.qtInit[wpActiveEditor], {id: textfield_id})
}
// Init tinymce
if(window.tinyMCEPreInit && window.tinyMCEPreInit.mceInit[wpActiveEditor]) {
window.tinyMCEPreInit.mceInit[textfield_id] = _.extend({}, window.tinyMCEPreInit.mceInit[wpActiveEditor], {
resize: 'vertical',
height: 200,
id: textfield_id,
setup: function (ed) {
if (typeof(ed.on) != 'undefined') {
ed.on('init', function (ed) {
ed.target.focus();
wpActiveEditor = textfield_id;
});
} else {
console.log("Clean inner else");
ed.onInit.add(function (ed) {
ed.focus();
wpActiveEditor = textfield_id;
});
}
}
});
window.tinyMCEPreInit.mceInit[textfield_id].plugins = window.tinyMCEPreInit.mceInit[textfield_id].plugins.replace(/,?wpfullscreen/, '');
}
$element.val($content_holder.val());
qt = quicktags( window.tinyMCEPreInit.qtInit[textfield_id] );
QTags._buttonsInit();
if(window.tinymce) {
window.switchEditors && window.switchEditors.go(textfield_id, 'tmce');
if(tinymce.majorVersion === "4") tinymce.execCommand( 'mceAddEditor', true, textfield_id );
}
vc_activeMce = textfield_id;
wpActiveEditor = textfield_id;
};
//add window object
$('.wpb-edit-form .textarea_html').each(function(){
window.init_textarea_html($(this));
});
// Edit File : js_composer/composer/lib/params/textarea_html/texarea_html.php
function vc_textarea_html_form_field($settings, $value) {
$settings_line = '';
if ( function_exists('wp_editor') ) {
$default_content = __($value, "sparse");
$output_value = '';
// WP 3.3+
ob_start();
wp_editor($default_content, 'wpb_tinymce_'.$settings['param_name'], array('editor_class' => 'wpb_vc_param_value wpb-textarea visual_composer_tinymce '.$settings['param_name'].' '.$settings['type'], 'media_buttons' => true, 'wpautop' => true ) );
$output_value = ob_get_contents();
ob_end_clean();
// this line change
$settings_line .= $output_value . '<input type="hidden" name="'.$settings['param_name'].'" class="vc_textarea_html_content wpb_vc_param_value ' . $settings['param_name'] . '" value="' . htmlspecialchars( $default_content ) . '"/>';
}
// $settings_line = '<textarea name="'.$settings['param_name'].'" class="wpb_vc_param_value wpb-textarea visual_composer_tinymce '.$settings['param_name'].' '.$settings['type'].' '.$settings['param_name'].'_tinymce"' . $dependency . '>'.$settings_value.'</textarea>';
return $settings_line;
}
//css changes
// Edit File : js_composer/assets/css/js_composer.css
/* Select Image / Select Images (multiple)
---------------------------------------------------------- */
// add this css to your file
.wpb_edit_form_elements .quicktags-toolbar input {
width: auto;
padding: 2px 4px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment