News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Re: Quote Selected Text problems

Started by Daretary, March 27, 2023, 07:44:13 AM

Previous topic - Next topic

Daretary

Unfortunately, even on this site, quoting the selected text does not work on mobile devices. The button does not appear.
On a desktop, this option does not work in Firefox - in this case, the button appears but does not function.

CRM 114

Quote from: Daretary on March 27, 2023, 07:44:13 AMOn a desktop, this option does not work in Firefox - in this case, the button appears but does not function.

Works with Firefox 91.11.0 (Debian Linux).
German Wet Shaving Forum: www.gut-rasiert.de/forum

Arantor

Works for me on Firefox 111 on Windows 10, or did yesterday anyway.

Daretary

Arantor, but how to make it work on mobile devices and Ipad?

Arantor

It's never worked on mobile as far as I know, I dint think it was ever implemented.

Kindred

Topic split.

Please avoid re-opening ancient topics which were solved for the original poster and may or may not be related to your own issues.


The quoting works fine for me on a PC in Firefox

as Arantor notes, mobile use of quote selected text is completely different.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Other platforms treat it as the same, though.

Daretary

Yes, sorry, addons got in the way in Firefox.

It will be necessary to invent something additionally on mobile devices.

Something like this:
function getSelectedText() {
    var text = "";
    var activeEl = document.activeElement;
    var selectionStart = activeEl.selectionStart;
    var selectionEnd = activeEl.selectionEnd;
    if (selectionStart !== undefined && selectionEnd !== undefined) {
        text = activeEl.value.substring(selectionStart, selectionEnd);
    }
    return text;
}

if (selectedText) {
        dQuoteText = selectedText;
    }


But it still "runs away" in else:
if (dQuoteText) {
            sceditorInstance.insert(sQuoteText.match(/^\[quote(.*)]/ig) + dQuoteText + '[/quote]' + '\n');
        } else {
            sceditorInstance.insert(sQuoteText + '\n');
        }

Arantor

The problem isn't getting the selected text but detecting text is selected at all.

I'll take a look when I'm done with work.

Arantor

OK so I have a provisional fix. This needs so much more testing than I can currently give it.

Themes/default/scripts/quotedText.js, line 123 or thereabouts.

Code (find) Select
$(document).on('mouseup', '.inner, .list_posts', function() {
Code (replace) Select
$(document).on('mouseup pointerup', '.inner, .list_posts', function() {
Same file, further down. Line 135.

Code (find) Select
if (typeof oSelected.text == 'undefined' || oSelected.text == false)
Code (replace) Select
if (typeof oSelected.text == 'undefined' || oSelected.text == false || oSelected.text == '')

If it doesn't work in Firefox for you before you make any changes, I suggest this is your theme - check the browser console, because I just tested it on my dev setup on Firefox to verify I hadn't broken it on desktop.

I tested this on an iPad that's not particularly current so it's probably good, but it may be twitchy in ways I didn't obviously find. Give it a go, let me know how it works out for you.

You'll probably want to make the change then delete all the minified_(hash).js files to ensure iPads pick it up, because Safari in general is pretty awful at holding onto things it really shouldn't.

Daretary

Arantor, you are great! Two lines fixed this problem! Your life hack is urgently needed in SMF 2.1.4 :)

Everything works on the phone.

As for Firefox - I wrote above that the reason was in the addon. Unfortunately, I can't part with my favorite Swift Selection Search, so I'll have to do without quoting selected text in this browser. :)

Arantor

I didn't see the bit about addons :-[ bit of a shame it's hijacking the browser like that.

If more folks can test it, I can make a pull request for its inclusion in 2.1.4 or something like that.

Daretary

Arantor, in mobile browsers, where "Copy, Search" or "Copy, Share" pops up when selected - this does not work. And a lot of people in mobile browsers have pop tooltips when they select text.

Arantor

Don't know what to say, it works normally for me even with my patch installed (Safari, iPad)

CRM 114

Quote from: Daretary on March 28, 2023, 05:42:40 AM...in mobile browsers, where "Copy, Search" or "Copy, Share" pops up when selected - this does not work.

Yes, does not work with IceCatMobile on my Android.
German Wet Shaving Forum: www.gut-rasiert.de/forum

Arantor

Doesn't work here, or with the patch, or what? In any case what exactly about it "doesn't work"?

Note that I don't own a single Android device so any testing I do is... limited. I don't know how Android is supposed to work so I don't know what it is or is not doing that it should...

CRM 114

Quote from: Arantor on March 28, 2023, 06:18:13 AMDoesn't work here, or with the patch, or what? In any case what exactly about it "doesn't work"?

It does not work on my forum, with the patch. When i select text, only the "Quote" Button appears. Only full-quote is possible.
German Wet Shaving Forum: www.gut-rasiert.de/forum

Arantor

And did you follow the notes about purging the minified files in case the old JavaScript is cached?

CRM 114

I switched "Minimize CSS and JavaScript files" off and again on (in the Admin Panel). All "minified_*.js" files were created new.
German Wet Shaving Forum: www.gut-rasiert.de/forum

Arantor

And that doesn't stop your browser caching the older versions anyway :(

Advertisement: