Skip to:
Content

Opened 5 years ago

Last modified 5 months ago

#2646 reopened defect

TinyMce Reply Issue

Reported by: brashell Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5.4
Component: Component - Replies Keywords: needs-patch
Cc: pericam@…

Description

When enabling TinyMce and attempting to create a reply to a reply within a topic, you are unable to create any input or press buttons.

  • Wordpress 3.9.1 Multisite subfolder
  • It does not appear to be a Javascript conflict with another plugin
  • Without tinymce enabled it works fine

Here is a youtube video of the bug:

http://youtu.be/L1rYwcC87Tk

Attachments (1)

0001-fix-threaded-replies-with-tinyMCE.patch (4.0 KB) - added by chherbst 5 months ago.

Download all attachments as: .zip

Change History (8)

#1 @johnjamesjacoby
4 years ago

  • Milestone changed from Awaiting Review to 2.7

Move from awaiting review to 2.7 milestone.

#2 @netweb
4 years ago

#2700 was marked as a duplicate.

#3 @Stagger Lee
4 years ago

  • Cc pericam@… added

This is fix from latest WP Edit plugin. (comments, but same is when adapted to bbPress) PHP code:

// Enable comment editor
		add_filter('comment_form_defaults', 'wpep_comment_form_editor');
			add_action('wp_enqueue_scripts', 'wpep_comment_form_scripts');
			add_action('init', 'wpep_comment_form_allowed_tags');
		
		function wpep_comment_form_editor($fields) {
			$args = array(
				'teeny' => true, 
				'textarea_rows' => '13', 
				'media_buttons' => false, 
				'tinymce' => array('toolbar1' => 'bold italic underline blockquote strikethrough bullist numlist alignleft aligncenter alignright undo redo link unlink')
				);
			
			ob_start();
			wp_editor('', 'comment', $args);
			$fields['comment_field'] = ob_get_clean();
			return $fields;
		}
		
		function wpep_comment_form_scripts(){
		 
			wp_deregister_script('comment-reply');
			wp_register_script( 'comment-reply', get_template_directory_uri() . '/js/comment-reply.js', '', true );
		}
		
		function wpep_comment_form_allowed_tags() {
		
			global $allowedtags;
			
			$allowedtags['ul'] = array();
			$allowedtags['ol'] = array();
			$allowedtags['li'] = array();
			$allowedtags['strong'] = array();
			$allowedtags['ins'] = array(
				'datetime' => true
			);
			$allowedtags['del'] = array(
				'datetime' => true
			);
			$allowedtags['pre'] = array(
				'lang' => true,
				'line' => true
			);
			$allowedtags['span'] = array(
				'style' => true
			);
			$allowedtags['img'] = array(
				'width' => true,
				'height' => true,
				'src' => true,
				'alt' => true
			);
			$allowedtags['a'] = array(
				'target' => true,
				'href' => true,
				'title' => true,
			);
		}

JS file:

addComment = {
    moveForm : function(commId, parentId, respondId, postId) {
        var t = this;
 
        // Remove editor if necessary
        t.red();
 
        var div,
        comm = t.I(commId),
        respond = t.I(respondId),
        cancel = t.I('cancel-comment-reply-link'),
        parent = t.I('comment_parent'), post = t.I('comment_post_ID');
 
        if ( ! comm || ! respond || ! cancel || ! parent)
                return;
 
        t.respondId = respondId;
        postId = postId || false;
 
        if ( ! t.I('wp-temp-form-div') ) {
                div = document.createElement('div');
                div.id = 'wp-temp-form-div';
                div.style.display = 'none';
                respond.parentNode.insertBefore(div, respond);
        }
 
        comm.parentNode.insertBefore(respond, comm.nextSibling);
 
        if ( post && postId )
            post.value = postId;
        parent.value = parentId;
        cancel.style.display = '';
 
        // Add editor if necessary
        t.aed();
 
        cancel.onclick = function() {
            var t = addComment;
 
            // Remove editor if necessary
            t.red();
 
            var temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
 
            if ( ! temp || ! respond )
                return;
 
            t.I('comment_parent').value = '0';
            temp.parentNode.insertBefore(respond, temp);
            temp.parentNode.removeChild(temp);
            this.style.display = 'none';
            this.onclick = null;
 
            // Add editor if necessary
            t.aed();
 
            return false;
        }
 
        return false;
    },
    I : function(e) {
        return document.getElementById(e);
    },
    red : function() {
        /* TinyMCE defined means wp_editor has Visual or both Visual and HTML/Text editors enabled
         * If editor is in HTML editor only mode our work here is unnecessary
         */
        if(typeof(tinyMCE) == 'undefined')
            return;
 
        var tmce = tinyMCE.get('comment');
        if (tmce && !tmce.isHidden()){
            /* Remove TinyMCE from textarea if necessary
             * and mark the current editor tab as Visual
             */
            this.mode = 'tmce';
            tmce.remove();
        }else{
            /* Html editor can be moved in DOM without removal
             * so we just mark current editor tab as Html
             */
            this.mode = 'html';
        }
    },
    aed : function() {
        if(typeof(tinyMCE) == 'undefined')
            return;
 
        if (this.mode == 'tmce'){
            /* Add Visual editor to textarea using code from wp-includes/js/editor.js
             * enqueued by _WP_Editors PHP class whenever Visual editor is enabled.
             * This code switches to Visual editor with id 'comment'
             */
            switchEditors.go('comment', 'tmce');
        }else if (this.mode == 'html'){
            /* Add HTML/Text editor to textarea using code from wp-includes/js/editor.js
             * enqueued by _WP_Editors PHP class whenever Visual editor is enabled.
             * If Visual editor is not enabled 'return' above makes this code off limits.
             * This code switches to HTML editor with id 'comment'
             */
            switchEditors.go('comment', 'html');
        }
    }
}

#4 @netweb
2 years ago

  • Milestone 2.7 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Marking this as a duplicate of #2971 and which was fixed in r6096

#5 @chherbst
5 months ago

This is not a duplicate of #2971. This happens even with the fix from r6096.

#6 @chherbst
5 months ago

The attached patch is an adopted version of the one in comment #3 with all unnecessary parts removed.

#7 @chherbst
5 months ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.