1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Select a text to quote

Discussion in 'XenForo Questions and Support' started by Fuhrmann, Nov 4, 2011.

  1. Fuhrmann

    Fuhrmann Well-Known Member

    When I select a text in a post and then click in the quote button in the editor, should this text get into the editor?
     
    Digital Doctor likes this.
  2. James

    James Well-Known Member

    No but it has been suggested.
     
    Fuhrmann likes this.
  3. Digital Doctor

    Digital Doctor Well-Known Member

    This feature has been requested, but by default xenforo does not work this way.
    Ninja'd by James.
     
    James likes this.
  4. Fuhrmann

    Fuhrmann Well-Known Member

    Oh, I see.

    I have asked this because I edit the editor_template.js and have changed the line 11:

    Code:
    + selection.getContent().replace(/^<p>/, '').replace(/<\/p>$/, '')
    To this:

    Code:
    + window.getSelection()
    And it works...But I really do not know if this is safe or something. Just wanted to share.
     
    EQnoble, James and Digital Doctor like this.
  5. Digital Doctor

    Digital Doctor Well-Known Member

  6. Fuhrmann

    Fuhrmann Well-Known Member

    Now I understand. The "selection.getContent()" is the selection that we made inside the editor. If the selection is inside, it works. Out, do not.

    Oh, I just saw the link. Thank you Digital.
     
  7. Digital Doctor

    Digital Doctor Well-Known Member

  8. Fuhrmann

    Fuhrmann Well-Known Member

    Digital Doctor likes this.
  9. James

    James Well-Known Member

    Let me know when you get it working so I can experiment further.

    Create a thread in development discussions and post your updates. :)
     
  10. Digital Doctor

    Digital Doctor Well-Known Member

    Fuhrmann: if your code is clean maybe Kier would slip it into xF 1.1 (not likely mind you) :)
     
    Fuhrmann likes this.
  11. Fuhrmann

    Fuhrmann Well-Known Member

  12. Digital Doctor

    Digital Doctor Well-Known Member

    Looks good :)

    Screencast-o-matic is cool as well.​
    I've always wanted to see a forum "screenshot tool" that bypasses the local PC (ie. you can grab from the screen and post online without saving it locally). ​
    Almost feels like this could do that.​
     
  13. Fuhrmann

    Fuhrmann Well-Known Member

    haha, I have always wanted that too.
     
    Digital Doctor likes this.
  14. Digital Doctor

    Digital Doctor Well-Known Member

    I wonder if there is a mobile style that would allow people to take photos with their iphones and directly attach them to a forum ? Anyone know if forumrunner or the like allow that ?
     
  15. infis

    infis Well-Known Member

  16. Fuhrmann

    Fuhrmann Well-Known Member

    This is what i have done:

    Code:
    /*
    * The following functions are bespoke and thus covered by a proprietary license.
    */
    (function() {
    var wrapBbCode = function(editor, tag)
    {
    var selection = editor.selection,
    content, range, caret;
    var range = window.getSelection().getRangeAt(0);
    var startContainer = range.startContainer;
    var spanNode = startContainer.ownerDocument.createElement("layer");
    var docfrag = range.extractContents();
    console.log(startContainer.parentNode);
    spanNode.appendChild(docfrag);
    range.insertNode(spanNode);
     
     
    content = '[' + tag + ']'
    + spanNode.innerHTML
    + '<span id="__xfBbCaret">_</span>'
    + '[/' + tag + ']';
     
     
    content = '<p>' + content + '</p>';
    selection.setContent(content);
     
     
    if (editor.getDoc().createRange)
    {
    caret = editor.dom.get('__xfBbCaret');
    range = editor.getDoc().createRange();
    range.setStartBefore(caret);
    range.setEndBefore(caret);
    selection.setRng(range);
    }
    editor.dom.remove('__xfBbCaret');
    };
    
     
  17. Digital Doctor

    Digital Doctor Well-Known Member

    Any reports of people using it ?
     
  18. Fuhrmann

    Fuhrmann Well-Known Member

    Not to me!
     
  19. KidCactus

    KidCactus Member

    I've tried to implement this, but when I select something to quote and click the quote button, the post I'm quoting from get a line break inserted before and after the selected text. When I refresh the page that is restored though, but still, it's not a desired behavior. But I am glad you are working on this, a much "needed" function on my forum, since my users have had this function in my previous SMF installation. :)
     
    Fuhrmann likes this.
  20. Fuhrmann

    Fuhrmann Well-Known Member

    Yeah...still need some 'development', but I am glad that you liked!
     

Share This Page