Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

In this Discussion

Combining TinyMCE and Quotations

edited December 2008 in Questions
I have made some changes to the Quotations add-on, to make it work with the TinyMCE add-on.

For those who are interested, the changes are as follows.

In extensions/Quotations/quote.js, I changed the quote function into:

function quote(commentId, authorId, authorName)
{
var selText = getSel();
var commentText = "";
commentText = dumpCodeTree(document.getElementById("CommentBody_" + commentId));

if(selText != "")
commentText = selText;

location.hash = '#CommentEditor';
var rtEditor = tinyMCE.getInstanceById('CommentBox');
tinyMCE.activeEditor.setContent(commentText);
}


The location'hash part is an addition to let the browser scroll to the editor when the user has clicked the quote button.
In my theme's Comment_Form.php I have added

<a name="CommentEditor"></a>

just before <fieldset>, for it to work.

Comments

  • thanks sylviastuurman, is sort of working now, however, the text doesn't come formatted as "quoted by" so it looks like if it's not a quote but text from the person who's writing a message if you know what I mean...
    any fix or this doesn't supposed to show up like that?
  • That's right.
    The full code I have is:

    // the quotation to paste
    var commentText = "";
    var selText = getSel();
    if(selText != "") {
    commentText = selText;
    }
    commentText = dumpCodeTree(document.getElementById("CommentBody_" + commentId));
    // the quotation in HTML
    var quoteHTML = "";
    // the TinyMCE editor
    var rtEditor = tinyMCE.getInstanceById('CommentBox');

    if(tinyMCE.activeEditor.getContent() != "") {
    quoteHTML += "&nbsp;";
    }

    quoteHTML += '<blockquote>';
    quoteHTML += '<cite>';
    quoteHTML += authorName;
    quoteHTML += ': &nbsp;&nbsp;</cite>';
    quoteHTML += commentText;
    quoteHTML += '</p></div></blockquote>';

    // present the user with the editor
    location.hash = '#CommentEditor';

    // insert the quote
    var rtEditor = tinyMCE.getInstanceById('CommentBox');
    tinyMCE.activeEditor.execCommand('mceInsertContent',false, quoteHTML);

    But there are still problems with this code in Opera: the caret is inside the blockquote, and the user can't get out of it without switching to HTML.

    Maybe http://tinymce.moxiecode.com/punbb/viewtopic.php?id=6140 (post #3) is the answer; I did not try that yet.
This discussion has been closed.