• 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

Fuhrmann

Well-known member
#4
This feature has been requested, but by default xenforo does not work this way.
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.
 

Fuhrmann

Well-known member
#6
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.
 

Digital Doctor

Well-known member
#10
Kier said:
March 13, 2011: It's something I've been playing with, but there is no generally agreed format for addressing the selection within a document, so this kind of feature tends to be extremely fragile.
Fuhrmann: if your code is clean maybe Kier would slip it into xF 1.1 (not likely mind you) :)
 

Digital Doctor

Well-known member
#12
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.​
 

Digital Doctor

Well-known member
#14
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 ?
 

Fuhrmann

Well-known member
#16
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');
};
 
#19
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

Well-known member
#20
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. :)
Yeah...still need some 'development', but I am glad that you liked!